* [PATCH] mt76x0: pci: add mt76x0e_cleanup routine
@ 2018-09-29 17:26 Lorenzo Bianconi
2018-10-01 5:42 ` Stanislaw Gruszka
0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Bianconi @ 2018-09-29 17:26 UTC (permalink / raw)
To: nbd; +Cc: sgruszka, linux-wireless
Add mt76x0e_cleanup routine to tidy up the device
during netdevice removal
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
.../net/wireless/mediatek/mt76/mt76x0/pci.c | 30 +++++++++++++++----
.../net/wireless/mediatek/mt76/mt76x02_regs.h | 3 ++
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
index 876291dd3c1e..8cf9cabcbe2f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
@@ -41,13 +41,8 @@ static int mt76x0e_start(struct ieee80211_hw *hw)
return 0;
}
-static void mt76x0e_stop(struct ieee80211_hw *hw)
+static void mt76x0e_stop_hw(struct mt76x0_dev *dev)
{
- struct mt76x0_dev *dev = hw->priv;
-
- mutex_lock(&dev->mt76.mutex);
-
- clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
cancel_delayed_work_sync(&dev->cal_work);
cancel_delayed_work_sync(&dev->mac_work);
@@ -62,7 +57,15 @@ static void mt76x0e_stop(struct ieee80211_hw *hw)
0, 1000))
dev_warn(dev->mt76.dev, "TX DMA did not stop\n");
mt76_clear(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_RX_DMA_EN);
+}
+
+static void mt76x0e_stop(struct ieee80211_hw *hw)
+{
+ struct mt76x0_dev *dev = hw->priv;
+ mutex_lock(&dev->mt76.mutex);
+ clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
+ mt76x0e_stop_hw(dev);
mutex_unlock(&dev->mt76.mutex);
}
@@ -160,12 +163,27 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
return ret;
}
+static void mt76x0e_cleanup(struct mt76x0_dev *dev)
+{
+ clear_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
+ mt76x0_chip_onoff(dev, false, false);
+ mt76x0e_stop_hw(dev);
+
+ mt76_wr(dev, MT_H2M_MAILBOX_CID, ~0);
+ mt76_wr(dev, MT_H2M_MAILBOX_STATUS, ~0);
+
+ mt76_dma_cleanup(&dev->mt76);
+ mt76x02_mcu_cleanup(&dev->mt76);
+}
+
static void
mt76x0e_remove(struct pci_dev *pdev)
{
struct mt76_dev *mdev = pci_get_drvdata(pdev);
+ struct mt76x0_dev *dev = container_of(mdev, struct mt76x0_dev, mt76);
mt76_unregister_device(mdev);
+ mt76x0e_cleanup(dev);
ieee80211_free_hw(mdev->hw);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h b/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
index 24d1e6d747dd..f8003ee03a89 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
@@ -622,6 +622,9 @@
#define MT_SRAM_BASE 0x4000
+#define MT_H2M_MAILBOX_CID 0x7014
+#define MT_H2M_MAILBOX_STATUS 0x701c
+
#define MT_WCID_KEY_BASE 0x8000
#define MT_WCID_KEY(_n) (MT_WCID_KEY_BASE + (_n) * 32)
--
2.19.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mt76x0: pci: add mt76x0e_cleanup routine
2018-09-29 17:26 [PATCH] mt76x0: pci: add mt76x0e_cleanup routine Lorenzo Bianconi
@ 2018-10-01 5:42 ` Stanislaw Gruszka
2018-10-01 8:22 ` Lorenzo Bianconi
0 siblings, 1 reply; 3+ messages in thread
From: Stanislaw Gruszka @ 2018-10-01 5:42 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: nbd, linux-wireless
Hi
On Sat, Sep 29, 2018 at 07:26:41PM +0200, Lorenzo Bianconi wrote:
> Add mt76x0e_cleanup routine to tidy up the device
> during netdevice removal
>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> + mt76_wr(dev, MT_H2M_MAILBOX_CID, ~0);
> + mt76_wr(dev, MT_H2M_MAILBOX_STATUS, ~0);
I don't think this is needed. Those are legacy communication registers,
most likely not used in new chips and stay in vendor driver, because
it wasn't cleaned up.
Regards
Stanislaw
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mt76x0: pci: add mt76x0e_cleanup routine
2018-10-01 5:42 ` Stanislaw Gruszka
@ 2018-10-01 8:22 ` Lorenzo Bianconi
0 siblings, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2018-10-01 8:22 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: nbd, linux-wireless
On Oct 01, Stanislaw Gruszka wrote:
> Hi
>
> On Sat, Sep 29, 2018 at 07:26:41PM +0200, Lorenzo Bianconi wrote:
> > Add mt76x0e_cleanup routine to tidy up the device
> > during netdevice removal
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> > + mt76_wr(dev, MT_H2M_MAILBOX_CID, ~0);
> > + mt76_wr(dev, MT_H2M_MAILBOX_STATUS, ~0);
>
> I don't think this is needed. Those are legacy communication registers,
> most likely not used in new chips and stay in vendor driver, because
> it wasn't cleaned up.
Ack, I will remove them in v2.
Regards,
Lorenzo
>
> Regards
> Stanislaw
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-01 8:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-29 17:26 [PATCH] mt76x0: pci: add mt76x0e_cleanup routine Lorenzo Bianconi
2018-10-01 5:42 ` Stanislaw Gruszka
2018-10-01 8:22 ` Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).