Skip to contentSkip to conversation

ath12k: add module param to control MSI mode and address width

PATCH In review Govind Singh 5 participants 6 messages Jun 24, 2025 – Jun 30, 2025 Qualcomm ATH12K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath12k: add module param to control MSI mode and address width

This patch adds two module parameters to the ath12k PCI driver.

- ath12k_msi_mode: Allows selecting the MSI allocation mode.
* 0 = multi-vector MSI (default)
* 1 = single-vector MSI

- ath12k_32bit_msi: Forces the use of 32-bit MSI addressing by setting pdev->no_64bit_msi = 1 before IRQ vector allocation.

These options are useful for working around hardware or platform limitations(ex: i.MX 8M Plus) where 64-bit MSI or multi-vector MSI allocations fails or cause stability issues.

The original MSI allocation logic remains unchanged unless the parameters are explicitly set via modprobe or kernel boot options.

Tested-on: QCN9274 hw2.0 WLAN.WBE.1.4.1-00103-QCAHKSWPL_SILICONZ-1 with
i.MX 8M Plus SOC

---
 drivers/net/wireless/ath/ath12k/pci.c | 25 +++++++++++++++++++++----
 drivers/net/wireless/ath/ath12k/pci.h |  5 +++++
 2 files changed, 26 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath12k/pci.c +21 -4
index 1f3cfd9b89fd..4f58cb1e03f6 100644
@@ -45,6 +45,14 @@
 #define DOMAIN_NUMBER_MASK		GENMASK(7, 4)
 #define BUS_NUMBER_MASK			GENMASK(3, 0)
 
+int ath12k_msi_mode;
+module_param(ath12k_msi_mode, int, 0644);
+MODULE_PARM_DESC(ath12k_msi_mode, "MSI mode: 0 = multi-vector (default), 1 = single-vector");
+
+bool ath12k_32bit_msi;
+module_param(ath12k_32bit_msi, bool, 0644);
+MODULE_PARM_DESC(ath12k_32bit_msi, "Force 32-bit MSI addressing");
+
 static const struct pci_device_id ath12k_pci_id_table[] = {
 	{ PCI_VDEVICE(QCOM, QCN9274_DEVICE_ID) },
 	{ PCI_VDEVICE(QCOM, WCN7850_DEVICE_ID) },
@@ -773,10 +781,19 @@ static int ath12k_pci_msi_alloc(struct ath12k_pci *ab_pci)
 	int num_vectors;
 	int ret;
 
-	num_vectors = pci_alloc_irq_vectors(ab_pci->pdev,
-					    msi_config->total_vectors,
-					    msi_config->total_vectors,
-					    PCI_IRQ_MSI);
+	/* Set 32-bit MSI flag early if requested */
+	if (ath12k_32bit_msi)
+		ab_pci->pdev->no_64bit_msi = 1;
+
+	/* Force single MSI mode if requested */
+	if (ath12k_msi_mode == ATH12K_MSI_VEC_SINGLE) {
+		num_vectors = -EINVAL; /* Force fallback path */
+	} else {
+		num_vectors = pci_alloc_irq_vectors(ab_pci->pdev,
+						    msi_config->total_vectors,
+						    msi_config->total_vectors,
+						    PCI_IRQ_MSI);
+	}
 
 	if (num_vectors == msi_config->total_vectors) {
 		set_bit(ATH12K_PCI_FLAG_MULTI_MSI_VECTORS, &ab_pci->flags);
drivers/net/wireless/ath/ath12k/pci.h +5 -0
index d1ec8aad7f6c..4fa8bb619cd9 100644
@@ -92,6 +92,11 @@ enum ath12k_pci_flags {
 	ATH12K_PCI_FLAG_MULTI_MSI_VECTORS,
 };
 
+enum ath12k_msi_mode {
+	ATH12K_MSI_VEC_AUTO = 0,
+	ATH12K_MSI_VEC_SINGLE = 1,
+};
+
 struct ath12k_pci_ops {
 	int (*wakeup)(struct ath12k_base *ab);
 	void (*release)(struct ath12k_base *ab);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 1 line · Govind Singh

This patch adds two module parameters to the ath12k PCI driver.

Please use imperative voice.
And it is preferential to first describe the problem, and then describe the proposed solution.

Quoted 11 lines

- ath12k_msi_mode: Allows selecting the MSI allocation mode.
* 0 = multi-vector MSI (default)
* 1 = single-vector MSI

- ath12k_32bit_msi: Forces the use of 32-bit MSI addressing by setting pdev->no_64bit_msi = 1 before IRQ vector allocation.

These options are useful for working around hardware or platform limitations(ex: i.MX 8M Plus) where 64-bit MSI or multi-vector MSI allocations fails or cause stability issues.

So there is no way to detect this?

Quoted 6 lines

The original MSI allocation logic remains unchanged unless the parameters are explicitly set via modprobe or kernel boot options.

Tested-on: QCN9274 hw2.0 WLAN.WBE.1.4.1-00103-QCAHKSWPL_SILICONZ-1 with
i.MX 8M Plus SOC

Don't split tags, and need a blank line after Tested-on since it is an ath-only tag, not an upstream tag

Quoted 11 lines
---
 drivers/net/wireless/ath/ath12k/pci.c | 25 +++++++++++++++++++++----
 drivers/net/wireless/ath/ath12k/pci.h |  5 +++++
 2 files changed, 26 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath12k/pci.c +0 -0
index 1f3cfd9b89fd..4f58cb1e03f6 100644

drivers/net/wireless/ath/ath12k/pci.c line 48

Quoted 4 lines
drivers/net/wireless/ath/ath12k/pci.c +1 -0
@@ -45,6 +45,14 @@
 #define DOMAIN_NUMBER_MASK		GENMASK(7, 4)
 #define BUS_NUMBER_MASK			GENMASK(3, 0)
 
+int ath12k_msi_mode;

should be static, make W=1 reports:
drivers/net/wireless/ath/ath12k/pci.c:48:5: warning: symbol 'ath12k_msi_mode' was not declared. Should it be static?

drivers/net/wireless/ath/ath12k/pci.c line 49

Quoted 1 line
drivers/net/wireless/ath/ath12k/pci.c +1 -0
+module_param(ath12k_msi_mode, int, 0644);

why is this writable via sysfs?

drivers/net/wireless/ath/ath12k/pci.c line 52

Quoted 3 lines
drivers/net/wireless/ath/ath12k/pci.c +3 -0
+MODULE_PARM_DESC(ath12k_msi_mode, "MSI mode: 0 = multi-vector (default), 1 = single-vector");
+
+bool ath12k_32bit_msi;

should be static, make W=1 reports:
drivers/net/wireless/ath/ath12k/pci.c:52:6: warning: symbol 'ath12k_32bit_msi' was not declared. Should it be static?

drivers/net/wireless/ath/ath12k/pci.c line 53

Quoted 1 line
drivers/net/wireless/ath/ath12k/pci.c +1 -0
+module_param(ath12k_32bit_msi, bool, 0644);

why is this writable via sysfs?

Quoted 34 lines
drivers/net/wireless/ath/ath12k/pci.c +15 -4
+MODULE_PARM_DESC(ath12k_32bit_msi, "Force 32-bit MSI addressing");
+
 static const struct pci_device_id ath12k_pci_id_table[] = {
 	{ PCI_VDEVICE(QCOM, QCN9274_DEVICE_ID) },
 	{ PCI_VDEVICE(QCOM, WCN7850_DEVICE_ID) },
@@ -773,10 +781,19 @@ static int ath12k_pci_msi_alloc(struct ath12k_pci *ab_pci)
 	int num_vectors;
 	int ret;
 
-	num_vectors = pci_alloc_irq_vectors(ab_pci->pdev,
-					    msi_config->total_vectors,
-					    msi_config->total_vectors,
-					    PCI_IRQ_MSI);
+	/* Set 32-bit MSI flag early if requested */
+	if (ath12k_32bit_msi)
+		ab_pci->pdev->no_64bit_msi = 1;
+
+	/* Force single MSI mode if requested */
+	if (ath12k_msi_mode == ATH12K_MSI_VEC_SINGLE) {
+		num_vectors = -EINVAL; /* Force fallback path */
+	} else {
+		num_vectors = pci_alloc_irq_vectors(ab_pci->pdev,
+						    msi_config->total_vectors,
+						    msi_config->total_vectors,
+						    PCI_IRQ_MSI);
+	}
 
 	if (num_vectors == msi_config->total_vectors) {
 		set_bit(ATH12K_PCI_FLAG_MULTI_MSI_VECTORS, &ab_pci->flags);
drivers/net/wireless/ath/ath12k/pci.h +0 -0
index d1ec8aad7f6c..4fa8bb619cd9 100644

drivers/net/wireless/ath/ath12k/pci.h enum ath12k_pci_flags { · line 98

Quoted 7 lines
drivers/net/wireless/ath/ath12k/pci.h +4 -0
@@ -92,6 +92,11 @@ enum ath12k_pci_flags {
 	ATH12K_PCI_FLAG_MULTI_MSI_VECTORS,
 };
 
+enum ath12k_msi_mode {
+	ATH12K_MSI_VEC_AUTO = 0,
+	ATH12K_MSI_VEC_SINGLE = 1,
+};

I'd put this in pci.c since this is not part of an external driver interface to pci.c

Quoted 4 lines
drivers/net/wireless/ath/ath12k/pci.h +1 -0
+
 struct ath12k_pci_ops {
 	int (*wakeup)(struct ath12k_base *ab);
 	void (*release)(struct ath12k_base *ab);
#2 lore raw
Quoted 12 lines · Jeff Johnson
Quoted 1 line · Govind Singh

This patch adds two module parameters to the ath12k PCI driver.

Please use imperative voice.
And it is preferential to first describe the problem, and then describe the proposed solution.

Quoted 5 lines

- ath12k_msi_mode: Allows selecting the MSI allocation mode.
* 0 = multi-vector MSI (default)
* 1 = single-vector MSI

Quoted 8 lines
Quoted 6 lines

- ath12k_32bit_msi: Forces the use of 32-bit MSI addressing by setting pdev->no_64bit_msi = 1 before IRQ vector allocation.

These options are useful for working around hardware or platform limitations(ex: i.MX 8M Plus) where 64-bit MSI or multi-vector MSI allocations fails or cause stability issues.

So there is no way to detect this?

For the record, Jakub has very much been pushing back against new module parameters, so I don't think we should take this.

johannes

#4 lore raw
In reply to Govind Singh
Quoted 13 lines · Govind Singh

This patch adds two module parameters to the ath12k PCI driver.

- ath12k_msi_mode: Allows selecting the MSI allocation mode.
* 0 = multi-vector MSI (default)
* 1 = single-vector MSI

- ath12k_32bit_msi: Forces the use of 32-bit MSI addressing by setting pdev->no_64bit_msi = 1 before IRQ vector allocation.

These options are useful for working around hardware or platform limitations(ex: i.MX 8M Plus) where 64-bit MSI or multi-vector MSI allocations fails or cause stability issues.

Quoted 6 lines

The original MSI allocation logic remains unchanged unless the parameters are explicitly set via modprobe or kernel boot options.

Tested-on: QCN9274 hw2.0 WLAN.WBE.1.4.1-00103-QCAHKSWPL_SILICONZ-1 with
i.MX 8M Plus SOC

Like I commented in the Bugzilla, this is not a ath12k issue. Fix/workarounds need to go to the PCIe controller driver, not its users.

Quoted 64 lines
---
 drivers/net/wireless/ath/ath12k/pci.c | 25 +++++++++++++++++++++----
 drivers/net/wireless/ath/ath12k/pci.h |  5 +++++
 2 files changed, 26 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath12k/pci.c +21 -4
index 1f3cfd9b89fd..4f58cb1e03f6 100644
@@ -45,6 +45,14 @@
 #define DOMAIN_NUMBER_MASK		GENMASK(7, 4)
 #define BUS_NUMBER_MASK			GENMASK(3, 0)
 
+int ath12k_msi_mode;
+module_param(ath12k_msi_mode, int, 0644);
+MODULE_PARM_DESC(ath12k_msi_mode, "MSI mode: 0 = multi-vector (default), 1 = single-vector");
+
+bool ath12k_32bit_msi;
+module_param(ath12k_32bit_msi, bool, 0644);
+MODULE_PARM_DESC(ath12k_32bit_msi, "Force 32-bit MSI addressing");
+
 static const struct pci_device_id ath12k_pci_id_table[] = {
 	{ PCI_VDEVICE(QCOM, QCN9274_DEVICE_ID) },
 	{ PCI_VDEVICE(QCOM, WCN7850_DEVICE_ID) },
@@ -773,10 +781,19 @@ static int ath12k_pci_msi_alloc(struct ath12k_pci *ab_pci)
 	int num_vectors;
 	int ret;
 
-	num_vectors = pci_alloc_irq_vectors(ab_pci->pdev,
-					    msi_config->total_vectors,
-					    msi_config->total_vectors,
-					    PCI_IRQ_MSI);
+	/* Set 32-bit MSI flag early if requested */
+	if (ath12k_32bit_msi)
+		ab_pci->pdev->no_64bit_msi = 1;
+
+	/* Force single MSI mode if requested */
+	if (ath12k_msi_mode == ATH12K_MSI_VEC_SINGLE) {
+		num_vectors = -EINVAL; /* Force fallback path */
+	} else {
+		num_vectors = pci_alloc_irq_vectors(ab_pci->pdev,
+						    msi_config->total_vectors,
+						    msi_config->total_vectors,
+						    PCI_IRQ_MSI);
+	}
 
 	if (num_vectors == msi_config->total_vectors) {
 		set_bit(ATH12K_PCI_FLAG_MULTI_MSI_VECTORS, &ab_pci->flags);
drivers/net/wireless/ath/ath12k/pci.h +5 -0
index d1ec8aad7f6c..4fa8bb619cd9 100644
@@ -92,6 +92,11 @@ enum ath12k_pci_flags {
 	ATH12K_PCI_FLAG_MULTI_MSI_VECTORS,
 };
 
+enum ath12k_msi_mode {
+	ATH12K_MSI_VEC_AUTO = 0,
+	ATH12K_MSI_VEC_SINGLE = 1,
+};
+
 struct ath12k_pci_ops {
 	int (*wakeup)(struct ath12k_base *ab);
 	void (*release)(struct ath12k_base *ab);
#5 lore raw
In reply to Govind Singh
kernel test robot noticed the following build warnings:

Hi Govind,

kernel test robot noticed the following build warnings:

[auto build test WARNING on ath/ath-next]
[also build test WARNING on wireless/main wireless-next/main linus/master v6.16-rc4 next-20250630] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Govind-Singh/ath12k-add-module-param-to-control-MSI-mode-and-address-width/20250625-005348
base:   https://git.kernel.org/pub/scm/linux/kernel/git/ath/ath.git ath-next
patch link:    https://lore.kernel.org/r/20250624165031.58616-1-govind.sk85%40gmail.com
patch subject: [PATCH] ath12k: add module param to control MSI mode and address width
config: sparc-randconfig-r112-20250630 (https://download.01.org/0day-ci/archive/20250701/[email protected]/config)
compiler: sparc-linux-gcc (GCC) 12.4.0
reproduce: (https://download.01.org/0day-ci/archive/20250701/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> drivers/net/wireless/ath/ath12k/pci.c:52:6: sparse: sparse: symbol 'ath12k_32bit_msi' was not declared. Should it be static?

vim +/ath12k_32bit_msi +52 drivers/net/wireless/ath/ath12k/pci.c

    51	
  > 52	bool ath12k_32bit_msi;
    53	module_param(ath12k_32bit_msi, bool, 0644);
    54	MODULE_PARM_DESC(ath12k_32bit_msi, "Force 32-bit MSI addressing");
    55	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki