mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 23:22:31 +02:00
wifi: mt76: mt7921s: Introduce SDIO WiFi/BT combo module card reset
Add a hardware reset method to recover from the SDIO bus error that cannot be resolved by the current WiFi/BT subsystem reset. Signed-off-by: Leon Yen <leon.yen@mediatek.com> Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com> Link: https://patch.msgid.link/20250418093740.3814909-1-mingyen.hsieh@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
55e95ce469
commit
e553ac0d76
|
|
@ -78,6 +78,10 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
|
|||
unsigned long expires;
|
||||
int ret, seq;
|
||||
|
||||
if (mt76_is_sdio(dev))
|
||||
if (test_bit(MT76_RESET, &dev->phy.state) && atomic_read(&dev->bus_hung))
|
||||
return -EIO;
|
||||
|
||||
if (ret_skb)
|
||||
*ret_skb = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -983,6 +983,8 @@ struct mt76_dev {
|
|||
struct mt76_usb usb;
|
||||
struct mt76_sdio sdio;
|
||||
};
|
||||
|
||||
atomic_t bus_hung;
|
||||
};
|
||||
|
||||
/* per-phy stats. */
|
||||
|
|
|
|||
|
|
@ -675,6 +675,8 @@ void mt7921_mac_reset_work(struct work_struct *work)
|
|||
if (!ret)
|
||||
break;
|
||||
}
|
||||
if (mt76_is_sdio(&dev->mt76) && atomic_read(&dev->mt76.bus_hung))
|
||||
return;
|
||||
|
||||
if (i == 10)
|
||||
dev_err(dev->mt76.dev, "chip reset failed\n");
|
||||
|
|
|
|||
|
|
@ -150,6 +150,8 @@ static int mt7921s_probe(struct sdio_func *func,
|
|||
if (ret)
|
||||
goto error;
|
||||
|
||||
atomic_set(&mdev->bus_hung, false);
|
||||
|
||||
mdev->rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) |
|
||||
(mt76_rr(dev, MT_HW_REV) & 0xff);
|
||||
dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include "mt7921.h"
|
||||
#include "../mt76_connac2_mac.h"
|
||||
#include "../sdio.h"
|
||||
#include <linux/mmc/host.h>
|
||||
#include <linux/kallsyms.h>
|
||||
|
||||
static void mt7921s_enable_irq(struct mt76_dev *dev)
|
||||
{
|
||||
|
|
@ -35,6 +37,9 @@ int mt7921s_wfsys_reset(struct mt792x_dev *dev)
|
|||
struct mt76_sdio *sdio = &dev->mt76.sdio;
|
||||
u32 val, status;
|
||||
|
||||
if (atomic_read(&dev->mt76.bus_hung))
|
||||
return 0;
|
||||
|
||||
mt7921s_mcu_drv_pmctrl(dev);
|
||||
|
||||
sdio_claim_host(sdio->func);
|
||||
|
|
@ -91,11 +96,64 @@ int mt7921s_init_reset(struct mt792x_dev *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct mt76_sdio *msdio;
|
||||
static void mt7921s_card_reset(struct work_struct *work)
|
||||
{
|
||||
struct mmc_host *sdio_host = msdio->func->card->host;
|
||||
|
||||
sdio_claim_host(msdio->func);
|
||||
sdio_release_irq(msdio->func);
|
||||
sdio_release_host(msdio->func);
|
||||
|
||||
mmc_remove_host(sdio_host);
|
||||
msleep(50);
|
||||
mmc_add_host(sdio_host);
|
||||
}
|
||||
|
||||
static DECLARE_WORK(sdio_reset_work, mt7921s_card_reset);
|
||||
static int mt7921s_check_bus(struct mt76_dev *dev)
|
||||
{
|
||||
struct mt76_sdio *sdio = &dev->sdio;
|
||||
int err;
|
||||
|
||||
sdio_claim_host(sdio->func);
|
||||
sdio_readl(dev->sdio.func, MCR_WHCR, &err);
|
||||
sdio_release_host(sdio->func);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int mt7921s_host_reset(struct mt792x_dev *dev)
|
||||
{
|
||||
struct mt76_dev *mdev = &dev->mt76;
|
||||
int err = -1;
|
||||
|
||||
if (!atomic_read(&mdev->bus_hung))
|
||||
err = mt7921s_check_bus(&dev->mt76);
|
||||
|
||||
if (err) {
|
||||
atomic_set(&mdev->bus_hung, true);
|
||||
msdio = &dev->mt76.sdio;
|
||||
dev_err(mdev->dev, "SDIO bus problem detected(%d), resetting card!!\n", err);
|
||||
schedule_work(&sdio_reset_work);
|
||||
return err;
|
||||
}
|
||||
|
||||
atomic_set(&mdev->bus_hung, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mt7921s_mac_reset(struct mt792x_dev *dev)
|
||||
{
|
||||
int err;
|
||||
|
||||
mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
|
||||
|
||||
mt7921s_host_reset(dev);
|
||||
if (atomic_read(&dev->mt76.bus_hung))
|
||||
return 0;
|
||||
|
||||
mt76_txq_schedule_all(&dev->mphy);
|
||||
mt76_worker_disable(&dev->mt76.tx_worker);
|
||||
set_bit(MT76_MCU_RESET, &dev->mphy.state);
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ mt76s_rx_run_queue(struct mt76_dev *dev, enum mt76_rxq_id qid,
|
|||
|
||||
if (err < 0) {
|
||||
dev_err(dev->dev, "sdio read data failed:%d\n", err);
|
||||
atomic_set(&dev->bus_hung, true);
|
||||
put_page(page);
|
||||
return err;
|
||||
}
|
||||
|
|
@ -234,9 +235,10 @@ static int __mt76s_xmit_queue(struct mt76_dev *dev, u8 *data, int 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);
|
||||
|
||||
atomic_set(&dev->bus_hung, true);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user