mt76: sdio: lock sdio when it is needed
authorSean Wang <sean.wang@mediatek.com>
Wed, 22 Dec 2021 05:56:28 +0000 (13:56 +0800)
committerFelix Fietkau <nbd@nbd.name>
Thu, 3 Feb 2022 12:57:57 +0000 (13:57 +0100)
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: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/sdio.c
drivers/net/wireless/mediatek/mt76/mt7921/sdio.c
drivers/net/wireless/mediatek/mt76/sdio_txrx.c

index 31c4a76b7f91a23c85c54a4f5a039a41cb041f06..71162befdae8547289bb9ab23d30e9f62ca8748b 100644 (file)
@@ -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;
        int i, err;
 
+       sdio_claim_host(sdio->func);
        err = sdio_readsb(sdio->func, irq_data, MCR_WHISR, sizeof(*irq_data));
+       sdio_release_host(sdio->func);
+
        if (err)
                return err;
 
index 65d693902c22287abdc890c20888303e3e50ded0..743b63f66efab15dc18647bb174bb1e8caf45b41 100644 (file)
@@ -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;
        int i, err;
 
+       sdio_claim_host(sdio->func);
        err = sdio_readsb(sdio->func, irq_data, MCR_WHISR, sizeof(*irq_data));
+       sdio_release_host(sdio->func);
+
        if (err < 0)
                return err;
 
index 801590a0a334f063bc142b222dbf4dcdf5500926..f2b46975d8314169dbacde241a15c0d19fe1803e 100644 (file)
@@ -102,7 +102,10 @@ mt76s_rx_run_queue(struct mt76_dev *dev, enum mt76_rxq_id qid,
 
        buf = page_address(page);
 
+       sdio_claim_host(sdio->func);
        err = sdio_readsb(sdio->func, buf, MCR_WRDR(qid), len);
+       sdio_release_host(sdio->func);
+
        if (err < 0) {
                dev_err(dev->dev, "sdio read data failed:%d\n", err);
                put_page(page);
@@ -214,7 +217,10 @@ static int __mt76s_xmit_queue(struct mt76_dev *dev, u8 *data, int len)
        if (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);
+       sdio_release_host(sdio->func);
+
        if (err)
                dev_err(dev->dev, "sdio write failed: %d\n", err);
 
@@ -298,6 +304,7 @@ void mt76s_txrx_worker(struct mt76_sdio *sdio)
        /* disable interrupt */
        sdio_claim_host(sdio->func);
        sdio_writel(sdio->func, WHLPCR_INT_EN_CLR, MCR_WHLPCR, NULL);
+       sdio_release_host(sdio->func);
 
        do {
                nframes = 0;
@@ -327,6 +334,7 @@ void mt76s_txrx_worker(struct mt76_sdio *sdio)
        } while (nframes > 0);
 
        /* enable interrupt */
+       sdio_claim_host(sdio->func);
        sdio_writel(sdio->func, WHLPCR_INT_EN_SET, MCR_WHLPCR, NULL);
        sdio_release_host(sdio->func);
 }