linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/1] scsi: mpi3mr: Introduce smp_affinity_enable module parameter
@ 2025-06-01  1:40 Aaron Tomlin
  2025-06-01  1:40 ` [RFC PATCH v2 1/1] " Aaron Tomlin
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Tomlin @ 2025-06-01  1:40 UTC (permalink / raw)
  To: mpi3mr-linuxdrv.pdl
  Cc: kashyap.desai, sumit.saxena, sreekanth.reddy, James.Bottomley,
	martin.petersen, atomlin, linux-scsi, linux-kernel

I noticed that the Linux MegaRAID driver for SAS based RAID controllers has
the same aforementioned module parameter. Despite the potential performance
drawbacks, I suspect it would be useful with the Broadcom MPI3 Storage
Controller Driver too, to respect the default IRQ affinity.
Please let me know your thoughts.

Changes since v1 [1]
 - Addressed WARN_ON() in pci_alloc_irq_vectors_affinity()
   due to affd != NULL when smp_affinity_enable = 0
 - Avoid unnecessary complexity for a single queue

[1]: https://lore.kernel.org/lkml/20250428094141.1385188-2-atomlin@atomlin.com/

Aaron Tomlin (1):
  scsi: mpi3mr: Introduce smp_affinity_enable module parameter

 drivers/scsi/mpi3mr/mpi3mr.h    |  1 +
 drivers/scsi/mpi3mr/mpi3mr_fw.c | 14 ++++++++++++--
 drivers/scsi/mpi3mr/mpi3mr_os.c | 14 +++++++++++---
 3 files changed, 24 insertions(+), 5 deletions(-)

-- 
2.49.0


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

* [RFC PATCH v2 1/1] scsi: mpi3mr: Introduce smp_affinity_enable module parameter
  2025-06-01  1:40 [RFC PATCH v2 0/1] scsi: mpi3mr: Introduce smp_affinity_enable module parameter Aaron Tomlin
@ 2025-06-01  1:40 ` Aaron Tomlin
  2025-06-16 20:51   ` Martin K. Petersen
  2025-06-17  7:18   ` John Garry
  0 siblings, 2 replies; 4+ messages in thread
From: Aaron Tomlin @ 2025-06-01  1:40 UTC (permalink / raw)
  To: mpi3mr-linuxdrv.pdl
  Cc: kashyap.desai, sumit.saxena, sreekanth.reddy, James.Bottomley,
	martin.petersen, atomlin, linux-scsi, linux-kernel

This patch introduces a new module parameter namely
"smp_affinity_enable", to govern the application of system-wide IRQ
affinity (with kernel boot-time parameter "irqaffinity") for MSI-X
interrupts. By default, the default IRQ affinity mask will not be
respected. Set smp_affinity_enable to 0 disables this behaviour.
Consequently, preventing the auto-assignment of MSI-X IRQs.

Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
---
 drivers/scsi/mpi3mr/mpi3mr.h    |  1 +
 drivers/scsi/mpi3mr/mpi3mr_fw.c | 14 ++++++++++++--
 drivers/scsi/mpi3mr/mpi3mr_os.c | 14 +++++++++++---
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h
index 9bbc7cb98ca3..82a0c1dd2f59 100644
--- a/drivers/scsi/mpi3mr/mpi3mr.h
+++ b/drivers/scsi/mpi3mr/mpi3mr.h
@@ -1378,6 +1378,7 @@ struct mpi3mr_ioc {
 	u32 num_tb_segs;
 	struct dma_pool *trace_buf_pool;
 	struct segments *trace_buf;
+	bool smp_affinity_enable;
 
 };
 
diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
index 1d7901a8f0e4..9cbe1744213d 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -22,6 +22,10 @@ static int poll_queues;
 module_param(poll_queues, int, 0444);
 MODULE_PARM_DESC(poll_queues, "Number of queues for io_uring poll mode. (Range 1 - 126)");
 
+static int smp_affinity_enable = 1;
+module_param(smp_affinity_enable, int, 0444);
+MODULE_PARM_DESC(smp_affinity_enable, "SMP affinity feature enable/disable Default: enable(1)");
+
 #if defined(writeq) && defined(CONFIG_64BIT)
 static inline void mpi3mr_writeq(__u64 b, volatile void __iomem *addr)
 {
@@ -821,6 +825,7 @@ static int mpi3mr_setup_isr(struct mpi3mr_ioc *mrioc, u8 setup_one)
 	int retval;
 	int i;
 	struct irq_affinity desc = { .pre_vectors =  1, .post_vectors = 1 };
+	struct irq_affinity *descp = &desc;
 
 	if (mrioc->is_intr_info_set)
 		return 0;
@@ -852,10 +857,13 @@ static int mpi3mr_setup_isr(struct mpi3mr_ioc *mrioc, u8 setup_one)
 
 		desc.post_vectors = mrioc->requested_poll_qcount;
 		min_vec = desc.pre_vectors + desc.post_vectors;
-		irq_flags |= PCI_IRQ_AFFINITY | PCI_IRQ_ALL_TYPES;
+		if (mrioc->smp_affinity_enable)
+			irq_flags |= PCI_IRQ_AFFINITY | PCI_IRQ_ALL_TYPES;
+		else
+			descp = NULL;
 
 		retval = pci_alloc_irq_vectors_affinity(mrioc->pdev,
-			min_vec, max_vectors, irq_flags, &desc);
+			min_vec, max_vectors, irq_flags, descp);
 
 		if (retval < 0) {
 			ioc_err(mrioc, "cannot allocate irq vectors, ret %d\n",
@@ -4233,6 +4241,8 @@ int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc)
 		goto out_failed_noretry;
 	}
 
+	mrioc->smp_affinity_enable = smp_affinity_enable ? true : false;
+
 	retval = mpi3mr_setup_isr(mrioc, 1);
 	if (retval) {
 		ioc_err(mrioc, "Failed to setup ISR error %d\n",
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index ce444efd859e..6ea73cf7579b 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -4064,6 +4064,9 @@ static void mpi3mr_map_queues(struct Scsi_Host *shost)
 	int i, qoff, offset;
 	struct blk_mq_queue_map *map = NULL;
 
+	if (shost->nr_hw_queues == 1)
+		return;
+
 	offset = mrioc->op_reply_q_offset;
 
 	for (i = 0, qoff = 0; i < HCTX_MAX_TYPES; i++) {
@@ -5422,8 +5425,6 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	shost->max_channel = 0;
 	shost->max_id = 0xFFFFFFFF;
 
-	shost->host_tagset = 1;
-
 	if (prot_mask >= 0)
 		scsi_host_set_prot(shost, prot_mask);
 	else {
@@ -5471,7 +5472,14 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto init_ioc_failed;
 	}
 
-	shost->nr_hw_queues = mrioc->num_op_reply_q;
+	shost->host_tagset = 0;
+	shost->nr_hw_queues = 1;
+
+	if (mrioc->smp_affinity_enable) {
+		shost->nr_hw_queues = mrioc->num_op_reply_q;
+		shost->host_tagset = 1;
+	}
+
 	if (mrioc->active_poll_qcount)
 		shost->nr_maps = 3;
 
-- 
2.49.0


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

* Re: [RFC PATCH v2 1/1] scsi: mpi3mr: Introduce smp_affinity_enable module parameter
  2025-06-01  1:40 ` [RFC PATCH v2 1/1] " Aaron Tomlin
@ 2025-06-16 20:51   ` Martin K. Petersen
  2025-06-17  7:18   ` John Garry
  1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2025-06-16 20:51 UTC (permalink / raw)
  To: Aaron Tomlin
  Cc: mpi3mr-linuxdrv.pdl, kashyap.desai, sumit.saxena, sreekanth.reddy,
	James.Bottomley, martin.petersen, linux-scsi, linux-kernel


> This patch introduces a new module parameter namely
> "smp_affinity_enable", to govern the application of system-wide IRQ
> affinity (with kernel boot-time parameter "irqaffinity") for MSI-X
> interrupts. By default, the default IRQ affinity mask will not be
> respected. Set smp_affinity_enable to 0 disables this behaviour.
> Consequently, preventing the auto-assignment of MSI-X IRQs.

Broadcom: Please review!

-- 
Martin K. Petersen

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

* Re: [RFC PATCH v2 1/1] scsi: mpi3mr: Introduce smp_affinity_enable module parameter
  2025-06-01  1:40 ` [RFC PATCH v2 1/1] " Aaron Tomlin
  2025-06-16 20:51   ` Martin K. Petersen
@ 2025-06-17  7:18   ` John Garry
  1 sibling, 0 replies; 4+ messages in thread
From: John Garry @ 2025-06-17  7:18 UTC (permalink / raw)
  To: Aaron Tomlin, mpi3mr-linuxdrv.pdl
  Cc: kashyap.desai, sumit.saxena, sreekanth.reddy, James.Bottomley,
	martin.petersen, linux-scsi, linux-kernel

On 01/06/2025 02:40, Aaron Tomlin wrote:
> This patch introduces a new module parameter namely
> "smp_affinity_enable", to govern the application of system-wide IRQ
> affinity (with kernel boot-time parameter "irqaffinity") for MSI-X
> interrupts. By default, the default IRQ affinity mask will not be
> respected. Set smp_affinity_enable to 0 disables this behaviour.
> Consequently, preventing the auto-assignment of MSI-X IRQs.

You have given no substantial motivation for this change.

On the cover letter you have, "I noticed that the Linux MegaRAID driver 
for SAS based RAID controllers has the same aforementioned module 
parameter ..." and " I suspect it would be useful ..."

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

end of thread, other threads:[~2025-06-17  7:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-01  1:40 [RFC PATCH v2 0/1] scsi: mpi3mr: Introduce smp_affinity_enable module parameter Aaron Tomlin
2025-06-01  1:40 ` [RFC PATCH v2 1/1] " Aaron Tomlin
2025-06-16 20:51   ` Martin K. Petersen
2025-06-17  7:18   ` John Garry

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