* [PATCH v7 1/3] wifi: iwlwifi: pcie: migrate to modern pci_alloc_irq_vectors API
@ 2026-03-19 18:29 Adrián García Casado
2026-03-19 18:50 ` Jeff Johnson
2026-03-20 8:28 ` Johannes Berg
0 siblings, 2 replies; 3+ messages in thread
From: Adrián García Casado @ 2026-03-19 18:29 UTC (permalink / raw)
To: Miri Korenblit
Cc: linux-wireless, linux-kernel, Miguel Ojeda,
Adrián García Casado
Johannes Berg suggested using pci_alloc_irq_vectors() and delegating
affinity management to the kernel. This patch replaces
pci_enable_msix_range() with the modern API and leverages
PCI_IRQ_AFFINITY. The manual affinity loop is removed as it's now
redundant.
Signed-off-by: Adrián García Casado <adriangarciacasado42@gmail.com>
---
.../intel/iwlwifi/pcie/gen1_2/trans.c | 46 ++++++-------------
1 file changed, 13 insertions(+), 33 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c
index 4560d92d76fe0..e4808cfe1caef 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c
@@ -1274,7 +1274,7 @@ void iwl_pcie_synchronize_irqs(struct iwl_trans *trans)
int i;
for (i = 0; i < trans_pcie->alloc_vecs; i++)
- synchronize_irq(trans_pcie->msix_entries[i].vector);
+ synchronize_irq(pci_irq_vector(trans_pcie->pci_dev, i));
} else {
synchronize_irq(trans_pcie->pci_dev->irq);
}
@@ -1608,18 +1608,20 @@ iwl_pcie_set_interrupt_capa(struct pci_dev *pdev,
max_rx_queues = IWL_9000_MAX_RX_HW_QUEUES;
max_irqs = min_t(u32, num_online_cpus() + 2, max_rx_queues);
- for (i = 0; i < max_irqs; i++)
- trans_pcie->msix_entries[i].entry = i;
-
- num_irqs = pci_enable_msix_range(pdev, trans_pcie->msix_entries,
- MSIX_MIN_INTERRUPT_VECTORS,
- max_irqs);
+ num_irqs = pci_alloc_irq_vectors(pdev, MSIX_MIN_INTERRUPT_VECTORS,
+ max_irqs, PCI_IRQ_MSIX | PCI_IRQ_AFFINITY);
if (num_irqs < 0) {
IWL_DEBUG_INFO(trans,
"Failed to enable msi-x mode (ret %d). Moving to msi mode.\n",
num_irqs);
goto enable_msi;
}
+
+ trans_pcie->msix_enabled = true;
+ trans_pcie->alloc_vecs = num_irqs;
+ for (i = 0; i < num_irqs; i++)
+ trans_pcie->msix_entries[i].entry = i;
+
trans_pcie->def_irq = (num_irqs == max_irqs) ? num_irqs - 1 : 0;
IWL_DEBUG_INFO(trans,
@@ -1671,28 +1673,7 @@ iwl_pcie_set_interrupt_capa(struct pci_dev *pdev,
static void iwl_pcie_irq_set_affinity(struct iwl_trans *trans,
struct iwl_trans_info *info)
{
-#if defined(CONFIG_SMP)
- int iter_rx_q, i, ret, cpu, offset;
- struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
-
- i = trans_pcie->shared_vec_mask & IWL_SHARED_IRQ_FIRST_RSS ? 0 : 1;
- iter_rx_q = info->num_rxqs - 1 + i;
- offset = 1 + i;
- for (; i < iter_rx_q ; i++) {
- /*
- * Get the cpu prior to the place to search
- * (i.e. return will be > i - 1).
- */
- cpu = cpumask_next(i - offset, cpu_online_mask);
- cpumask_set_cpu(cpu, &trans_pcie->affinity_mask[i]);
- ret = irq_set_affinity_hint(trans_pcie->msix_entries[i].vector,
- &trans_pcie->affinity_mask[i]);
- if (ret)
- IWL_ERR(trans_pcie->trans,
- "Failed to set affinity mask for IRQ %d\n",
- trans_pcie->msix_entries[i].vector);
- }
-#endif
+ /* Handled by PCI_IRQ_AFFINITY in pci_alloc_irq_vectors() */
}
static int iwl_pcie_init_msix_handler(struct pci_dev *pdev,
@@ -1703,15 +1684,14 @@ static int iwl_pcie_init_msix_handler(struct pci_dev *pdev,
for (i = 0; i < trans_pcie->alloc_vecs; i++) {
int ret;
- struct msix_entry *msix_entry;
+ struct msix_entry *msix_entry = &trans_pcie->msix_entries[i];
const char *qname = queue_name(&pdev->dev, trans_pcie, i);
if (!qname)
return -ENOMEM;
- msix_entry = &trans_pcie->msix_entries[i];
ret = devm_request_threaded_irq(&pdev->dev,
- msix_entry->vector,
+ pci_irq_vector(pdev, i),
iwl_pcie_msix_isr,
(i == trans_pcie->def_irq) ?
iwl_pcie_irq_msix_handler :
@@ -1988,7 +1968,7 @@ void iwl_trans_pcie_free(struct iwl_trans *trans)
if (trans_pcie->msix_enabled) {
for (i = 0; i < trans_pcie->alloc_vecs; i++) {
irq_set_affinity_hint(
- trans_pcie->msix_entries[i].vector,
+ pci_irq_vector(trans_pcie->pci_dev, i),
NULL);
}
base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v7 1/3] wifi: iwlwifi: pcie: migrate to modern pci_alloc_irq_vectors API
2026-03-19 18:29 [PATCH v7 1/3] wifi: iwlwifi: pcie: migrate to modern pci_alloc_irq_vectors API Adrián García Casado
@ 2026-03-19 18:50 ` Jeff Johnson
2026-03-20 8:28 ` Johannes Berg
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Johnson @ 2026-03-19 18:50 UTC (permalink / raw)
To: Adrián García Casado, Miri Korenblit
Cc: linux-wireless, linux-kernel, Miguel Ojeda
On 3/19/2026 11:29 AM, Adrián García Casado wrote:
> Johannes Berg suggested using pci_alloc_irq_vectors() and delegating
> affinity management to the kernel. This patch replaces
> pci_enable_msix_range() with the modern API and leverages
> PCI_IRQ_AFFINITY. The manual affinity loop is removed as it's now
> redundant.
I see from the archive that you've been pointed to this link, but I'm going to
do so again...
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes
"Describe your problem. Whether your patch is a one-line bug fix or 5000 lines
of a new feature, there must be an underlying problem that motivated you to do
this work. Convince the reviewer that there is a problem worth fixing and that
it makes sense for them to read past the first paragraph."
"Describe your changes in imperative mood, e.g. “make xyzzy do frotz” instead
of “[This patch] makes xyzzy do frotz” or “[I] changed xyzzy to do frotz”, as
if you are giving orders to the codebase to change its behaviour."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v7 1/3] wifi: iwlwifi: pcie: migrate to modern pci_alloc_irq_vectors API
2026-03-19 18:29 [PATCH v7 1/3] wifi: iwlwifi: pcie: migrate to modern pci_alloc_irq_vectors API Adrián García Casado
2026-03-19 18:50 ` Jeff Johnson
@ 2026-03-20 8:28 ` Johannes Berg
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2026-03-20 8:28 UTC (permalink / raw)
To: Adrián García Casado, Miri Korenblit
Cc: linux-wireless, linux-kernel, Miguel Ojeda
Hi,
So given your exchange with Miguel, I was not going to reply, but
On Thu, 2026-03-19 at 19:29 +0100, Adrián García Casado wrote:
> Johannes Berg suggested using pci_alloc_irq_vectors() and delegating
> affinity management to the kernel.
I don't know where this came from, I never suggested that?
I _did_ suggest that if this change is somehow necessary (which you've
not convinced anyone of), the driver should allocate fewer queues rather
than just spreading the same number of queues over fewer cores and
double-booking one of the cores.
Please take a step back, (re-)read all the feedback you've been given,
figure out why you want this change, and come back with a coherent
explanation and changes addressing feedback (or explanations why not.)
johannes
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-20 8:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 18:29 [PATCH v7 1/3] wifi: iwlwifi: pcie: migrate to modern pci_alloc_irq_vectors API Adrián García Casado
2026-03-19 18:50 ` Jeff Johnson
2026-03-20 8:28 ` Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox