linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mt76: mt7915: add MSI support
@ 2021-05-07 10:45 Felix Fietkau
  2021-05-07 10:45 ` [PATCH 2/2] mt76: mt7915: disable ASPM Felix Fietkau
  2021-05-07 15:35 ` [PATCH 1/2] mt76: mt7915: add MSI support kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Felix Fietkau @ 2021-05-07 10:45 UTC (permalink / raw)
  To: linux-wireless

Move IRQ processing to a tasklet, similar to MT7615/MT7663

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 .../net/wireless/mediatek/mt76/mt7915/init.c  |  1 +
 .../wireless/mediatek/mt76/mt7915/mt7915.h    |  7 +++-
 .../net/wireless/mediatek/mt76/mt7915/pci.c   | 39 ++++++++++++++++---
 3 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
index 822f3aa6bb8b..a8fd822cc46e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
@@ -752,6 +752,7 @@ void mt7915_unregister_device(struct mt7915_dev *dev)
 	mt7915_mcu_exit(dev);
 	mt7915_tx_token_put(dev);
 	mt7915_dma_cleanup(dev);
+	tasklet_disable(&dev->irq_tasklet);
 
 	mt76_free_device(&dev->mt76);
 }
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index 4ea8972d4e2f..7a3c172afc98 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
@@ -169,6 +169,7 @@ struct mt7915_dev {
 	struct mt7915_hif *hif2;
 
 	const struct mt76_bus_ops *bus_ops;
+	struct tasklet_struct irq_tasklet;
 	struct mt7915_phy phy;
 
 	u16 chainmask;
@@ -374,9 +375,11 @@ void mt7915_dual_hif_set_irq_mask(struct mt7915_dev *dev, bool write_reg,
 static inline void mt7915_irq_enable(struct mt7915_dev *dev, u32 mask)
 {
 	if (dev->hif2)
-		mt7915_dual_hif_set_irq_mask(dev, true, 0, mask);
+		mt7915_dual_hif_set_irq_mask(dev, false, 0, mask);
 	else
-		mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, 0, mask);
+		mt76_set_irq_mask(&dev->mt76, 0, 0, mask);
+
+	tasklet_schedule(&dev->irq_tasklet);
 }
 
 static inline void mt7915_irq_disable(struct mt7915_dev *dev, u32 mask)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/pci.c b/drivers/net/wireless/mediatek/mt76/mt7915/pci.c
index 643f171884cf..0bba0efc5bc0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/pci.c
@@ -94,11 +94,15 @@ mt7915_rx_poll_complete(struct mt76_dev *mdev, enum mt76_rxq_id q)
 }
 
 /* TODO: support 2/4/6/8 MSI-X vectors */
-static irqreturn_t mt7915_irq_handler(int irq, void *dev_instance)
+static void mt7915_irq_tasklet(struct tasklet_struct *t)
 {
-	struct mt7915_dev *dev = dev_instance;
+	struct mt7915_dev *dev = from_tasklet(dev, t, irq_tasklet);
 	u32 intr, intr1, mask;
 
+	mt76_wr(dev, MT_INT_MASK_CSR, 0);
+	if (dev->hif2)
+		mt76_wr(dev, MT_INT1_MASK_CSR, 0);
+
 	intr = mt76_rr(dev, MT_INT_SOURCE_CSR);
 	intr &= dev->mt76.mmio.irqmask;
 	mt76_wr(dev, MT_INT_SOURCE_CSR, intr);
@@ -111,9 +115,6 @@ static irqreturn_t mt7915_irq_handler(int irq, void *dev_instance)
 		intr |= intr1;
 	}
 
-	if (!test_bit(MT76_STATE_INITIALIZED, &dev->mphy.state))
-		return IRQ_NONE;
-
 	trace_dev_irq(&dev->mt76, intr, dev->mt76.mmio.irqmask);
 
 	mask = intr & MT_INT_RX_DONE_ALL;
@@ -150,6 +151,20 @@ static irqreturn_t mt7915_irq_handler(int irq, void *dev_instance)
 			wake_up(&dev->reset_wait);
 		}
 	}
+}
+
+static irqreturn_t mt7915_irq_handler(int irq, void *dev_instance)
+{
+	struct mt7915_dev *dev = dev_instance;
+
+	mt76_wr(dev, MT_INT_MASK_CSR, 0);
+	if (dev->hif2)
+		mt76_wr(dev, MT_INT1_MASK_CSR, 0);
+
+	if (!test_bit(MT76_STATE_INITIALIZED, &dev->mphy.state))
+		return IRQ_NONE;
+
+	tasklet_schedule(&dev->irq_tasklet);
 
 	return IRQ_HANDLED;
 }
@@ -248,12 +263,20 @@ static int mt7915_pci_probe(struct pci_dev *pdev,
 	if (!mdev)
 		return -ENOMEM;
 
+	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	if (ret < 0)
+		goto free;
+
 	dev = container_of(mdev, struct mt7915_dev, mt76);
 
 	ret = mt7915_mmio_init(mdev, pcim_iomap_table(pdev)[0], pdev->irq);
 	if (ret)
 		goto error;
 
+	tasklet_setup(&dev->irq_tasklet, mt7915_irq_tasklet);
+
+	mt76_wr(dev, MT_INT_MASK_CSR, 0);
+
 	/* master switch of PCIe tnterrupt enable */
 	mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff);
 
@@ -266,10 +289,14 @@ static int mt7915_pci_probe(struct pci_dev *pdev,
 
 	ret = mt7915_register_device(dev);
 	if (ret)
-		goto error;
+		goto free_irq;
 
 	return 0;
+free_irq:
+	devm_free_irq(mdev->dev, pdev->irq, dev);
 error:
+	pci_free_irq_vectors(pdev);
+free:
 	mt76_free_device(&dev->mt76);
 
 	return ret;
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] mt76: mt7915: disable ASPM
  2021-05-07 10:45 [PATCH 1/2] mt76: mt7915: add MSI support Felix Fietkau
@ 2021-05-07 10:45 ` Felix Fietkau
  2021-05-07 15:35 ` [PATCH 1/2] mt76: mt7915: add MSI support kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: Felix Fietkau @ 2021-05-07 10:45 UTC (permalink / raw)
  To: linux-wireless

The same is done on the other chips already, so it is very likely needed
on MT7915 as well

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt7915/pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/pci.c b/drivers/net/wireless/mediatek/mt76/mt7915/pci.c
index 0bba0efc5bc0..243338ce342d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/pci.c
@@ -255,6 +255,8 @@ static int mt7915_pci_probe(struct pci_dev *pdev,
 	if (ret)
 		return ret;
 
+	mt76_pci_disable_aspm(pdev);
+
 	if (id->device == 0x7916)
 		return mt7915_pci_hif2_probe(pdev);
 
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] mt76: mt7915: add MSI support
  2021-05-07 10:45 [PATCH 1/2] mt76: mt7915: add MSI support Felix Fietkau
  2021-05-07 10:45 ` [PATCH 2/2] mt76: mt7915: disable ASPM Felix Fietkau
@ 2021-05-07 15:35 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-05-07 15:35 UTC (permalink / raw)
  To: Felix Fietkau, linux-wireless; +Cc: kbuild-all, clang-built-linux

[-- Attachment #1: Type: text/plain, Size: 5295 bytes --]

Hi Felix,

I love your patch! Perhaps something to improve:

[auto build test WARNING on wireless-drivers-next/master]
[also build test WARNING on next-20210507]
[cannot apply to wireless-drivers/master v5.12]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Felix-Fietkau/mt76-mt7915-add-MSI-support/20210507-184735
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: arm64-randconfig-r013-20210507 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a3a8a1a15b524d91b5308db68e9d293b34cd88dd)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/057445f40716fc2ee5b1c4aa7d02023c1a92be86
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Felix-Fietkau/mt76-mt7915-add-MSI-support/20210507-184735
        git checkout 057445f40716fc2ee5b1c4aa7d02023c1a92be86
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/mediatek/mt76/mt7915/pci.c:267:6: warning: variable 'dev' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (ret < 0)
               ^~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7915/pci.c:300:20: note: uninitialized use occurs here
           mt76_free_device(&dev->mt76);
                             ^~~
   drivers/net/wireless/mediatek/mt76/mt7915/pci.c:267:2: note: remove the 'if' if its condition is always false
           if (ret < 0)
           ^~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7915/pci.c:240:24: note: initialize the variable 'dev' to silence this warning
           struct mt7915_dev *dev;
                                 ^
                                  = NULL
   1 warning generated.


vim +267 drivers/net/wireless/mediatek/mt76/mt7915/pci.c

   218	
   219	static int mt7915_pci_probe(struct pci_dev *pdev,
   220				    const struct pci_device_id *id)
   221	{
   222		static const struct mt76_driver_ops drv_ops = {
   223			/* txwi_size = txd size + txp size */
   224			.txwi_size = MT_TXD_SIZE + sizeof(struct mt7915_txp),
   225			.drv_flags = MT_DRV_TXWI_NO_FREE | MT_DRV_HW_MGMT_TXQ |
   226				     MT_DRV_AMSDU_OFFLOAD,
   227			.survey_flags = SURVEY_INFO_TIME_TX |
   228					SURVEY_INFO_TIME_RX |
   229					SURVEY_INFO_TIME_BSS_RX,
   230			.token_size = MT7915_TOKEN_SIZE,
   231			.tx_prepare_skb = mt7915_tx_prepare_skb,
   232			.tx_complete_skb = mt7915_tx_complete_skb,
   233			.rx_skb = mt7915_queue_rx_skb,
   234			.rx_poll_complete = mt7915_rx_poll_complete,
   235			.sta_ps = mt7915_sta_ps,
   236			.sta_add = mt7915_mac_sta_add,
   237			.sta_remove = mt7915_mac_sta_remove,
   238			.update_survey = mt7915_update_channel,
   239		};
   240		struct mt7915_dev *dev;
   241		struct mt76_dev *mdev;
   242		int ret;
   243	
   244		ret = pcim_enable_device(pdev);
   245		if (ret)
   246			return ret;
   247	
   248		ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
   249		if (ret)
   250			return ret;
   251	
   252		pci_set_master(pdev);
   253	
   254		ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
   255		if (ret)
   256			return ret;
   257	
   258		if (id->device == 0x7916)
   259			return mt7915_pci_hif2_probe(pdev);
   260	
   261		mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7915_ops,
   262					 &drv_ops);
   263		if (!mdev)
   264			return -ENOMEM;
   265	
   266		ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 > 267		if (ret < 0)
   268			goto free;
   269	
   270		dev = container_of(mdev, struct mt7915_dev, mt76);
   271	
   272		ret = mt7915_mmio_init(mdev, pcim_iomap_table(pdev)[0], pdev->irq);
   273		if (ret)
   274			goto error;
   275	
   276		tasklet_setup(&dev->irq_tasklet, mt7915_irq_tasklet);
   277	
   278		mt76_wr(dev, MT_INT_MASK_CSR, 0);
   279	
   280		/* master switch of PCIe tnterrupt enable */
   281		mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff);
   282	
   283		ret = devm_request_irq(mdev->dev, pdev->irq, mt7915_irq_handler,
   284				       IRQF_SHARED, KBUILD_MODNAME, dev);
   285		if (ret)
   286			goto error;
   287	
   288		mt7915_pci_init_hif2(dev);
   289	
   290		ret = mt7915_register_device(dev);
   291		if (ret)
   292			goto free_irq;
   293	
   294		return 0;
   295	free_irq:
   296		devm_free_irq(mdev->dev, pdev->irq, dev);
   297	error:
   298		pci_free_irq_vectors(pdev);
   299	free:
   300		mt76_free_device(&dev->mt76);
   301	
   302		return ret;
   303	}
   304	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 40684 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-07 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 10:45 [PATCH 1/2] mt76: mt7915: add MSI support Felix Fietkau
2021-05-07 10:45 ` [PATCH 2/2] mt76: mt7915: disable ASPM Felix Fietkau
2021-05-07 15:35 ` [PATCH 1/2] mt76: mt7915: add MSI support kernel test robot

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).