Commit 491e3731 authored by Sean Wang's avatar Sean Wang Committed by Felix Fietkau

mt76: sdio: lock sdio when it is needed

Acquire the SDIO as needed as possible because either MT7663S or MT7921S
is a multiple-function device that always includes Bluetooth that would
share with the same SDIO bus. So not to avoid breaking Bluetooth pairing,
audio, and HID such kind of time critical application on that, we only
lock sdio bus when it is necessary in WiFi driver.
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent abdb8bc9
...@@ -56,7 +56,10 @@ static int mt7663s_parse_intr(struct mt76_dev *dev, struct mt76s_intr *intr) ...@@ -56,7 +56,10 @@ static int mt7663s_parse_intr(struct mt76_dev *dev, struct mt76s_intr *intr)
struct mt7663s_intr *irq_data = sdio->intr_data; struct mt7663s_intr *irq_data = sdio->intr_data;
int i, err; int i, err;
sdio_claim_host(sdio->func);
err = sdio_readsb(sdio->func, irq_data, MCR_WHISR, sizeof(*irq_data)); err = sdio_readsb(sdio->func, irq_data, MCR_WHISR, sizeof(*irq_data));
sdio_release_host(sdio->func);
if (err) if (err)
return err; return err;
......
...@@ -58,7 +58,10 @@ static int mt7921s_parse_intr(struct mt76_dev *dev, struct mt76s_intr *intr) ...@@ -58,7 +58,10 @@ static int mt7921s_parse_intr(struct mt76_dev *dev, struct mt76s_intr *intr)
struct mt7921_sdio_intr *irq_data = sdio->intr_data; struct mt7921_sdio_intr *irq_data = sdio->intr_data;
int i, err; int i, err;
sdio_claim_host(sdio->func);
err = sdio_readsb(sdio->func, irq_data, MCR_WHISR, sizeof(*irq_data)); err = sdio_readsb(sdio->func, irq_data, MCR_WHISR, sizeof(*irq_data));
sdio_release_host(sdio->func);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -102,7 +102,10 @@ mt76s_rx_run_queue(struct mt76_dev *dev, enum mt76_rxq_id qid, ...@@ -102,7 +102,10 @@ mt76s_rx_run_queue(struct mt76_dev *dev, enum mt76_rxq_id qid,
buf = page_address(page); buf = page_address(page);
sdio_claim_host(sdio->func);
err = sdio_readsb(sdio->func, buf, MCR_WRDR(qid), len); err = sdio_readsb(sdio->func, buf, MCR_WRDR(qid), len);
sdio_release_host(sdio->func);
if (err < 0) { if (err < 0) {
dev_err(dev->dev, "sdio read data failed:%d\n", err); dev_err(dev->dev, "sdio read data failed:%d\n", err);
put_page(page); put_page(page);
...@@ -214,7 +217,10 @@ static int __mt76s_xmit_queue(struct mt76_dev *dev, u8 *data, int len) ...@@ -214,7 +217,10 @@ static int __mt76s_xmit_queue(struct mt76_dev *dev, u8 *data, int len)
if (len > sdio->func->cur_blksize) if (len > sdio->func->cur_blksize)
len = roundup(len, sdio->func->cur_blksize); len = roundup(len, sdio->func->cur_blksize);
sdio_claim_host(sdio->func);
err = sdio_writesb(sdio->func, MCR_WTDR1, data, len); err = sdio_writesb(sdio->func, MCR_WTDR1, data, len);
sdio_release_host(sdio->func);
if (err) if (err)
dev_err(dev->dev, "sdio write failed: %d\n", err); dev_err(dev->dev, "sdio write failed: %d\n", err);
...@@ -298,6 +304,7 @@ void mt76s_txrx_worker(struct mt76_sdio *sdio) ...@@ -298,6 +304,7 @@ void mt76s_txrx_worker(struct mt76_sdio *sdio)
/* disable interrupt */ /* disable interrupt */
sdio_claim_host(sdio->func); sdio_claim_host(sdio->func);
sdio_writel(sdio->func, WHLPCR_INT_EN_CLR, MCR_WHLPCR, NULL); sdio_writel(sdio->func, WHLPCR_INT_EN_CLR, MCR_WHLPCR, NULL);
sdio_release_host(sdio->func);
do { do {
nframes = 0; nframes = 0;
...@@ -327,6 +334,7 @@ void mt76s_txrx_worker(struct mt76_sdio *sdio) ...@@ -327,6 +334,7 @@ void mt76s_txrx_worker(struct mt76_sdio *sdio)
} while (nframes > 0); } while (nframes > 0);
/* enable interrupt */ /* enable interrupt */
sdio_claim_host(sdio->func);
sdio_writel(sdio->func, WHLPCR_INT_EN_SET, MCR_WHLPCR, NULL); sdio_writel(sdio->func, WHLPCR_INT_EN_SET, MCR_WHLPCR, NULL);
sdio_release_host(sdio->func); sdio_release_host(sdio->func);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment