Skip to contentSkip to conversation

Support managed interrupts for platform devices

PATCH Superseded John Garry 3 participants 7 messages Oct 27, 2020 – Oct 30, 2020

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

John Garry

author
#0 lore raw

cover Support managed interrupts for platform devices

So far, managed interrupts are only used for PCI MSIs. This series add platform device support for managed interrupts. Initially this topic was discussed at [0].

The method to enable managed interrupts is to allocate all the IRQs for the device, and then switch the interrupts to managed - this is done through new function irq_update_affinity_desc().

API platform_get_irqs_affinity() is added as a helper to manage this work, such that we don't need to export irq_update_affinity_desc() or irq_create_affinity_masks().

For now, the HiSilicon SAS v2 hw driver is switched over. This is used in the D05 dev board.

Performance gain observed for 6x SAS SSDs is ~357K -> 420K IOPs for fio read.

I hope - all going well - this series can go through the SCSI tree, since the non-SCSI changes are additive, thanks!

[0] https://lore.kernel.org/lkml/[email protected]/

John Garry (2):
Driver core: platform: Add platform_get_irqs_affinity()
scsi: hisi_sas: Expose HW queues for v2 hw

Thomas Gleixner (1):
genirq/affinity: Add irq_update_affinity_desc()

 drivers/base/platform.c                | 58 +++++++++++++++++++++
 drivers/scsi/hisi_sas/hisi_sas.h       |  4 ++
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 11 ++++
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 71 ++++++++++++++++++++++----
 include/linux/interrupt.h              |  8 +++
 include/linux/platform_device.h        |  5 ++
 kernel/irq/manage.c                    | 19 +++++++
 7 files changed, 165 insertions(+), 11 deletions(-)
Signature · 1 line
2.26.2
author
#1 lore raw

PATCH 1/3 genirq/affinity: Add irq_update_affinity_desc()

From: Thomas Gleixner <[email protected]>

Add a function to allow the affinity of an interrupt be switched to managed, such that interrupts allocated for platform devices may be managed.

<Insert author sob>

[jpg: Add commit message and add prototypes]

---
Thomas, I just made you author since you provided the original code, hope it's ok.

 include/linux/interrupt.h |  8 ++++++++
 kernel/irq/manage.c       | 19 +++++++++++++++++++
 2 files changed, 27 insertions(+)
include/linux/interrupt.h +8 -0
index ee8299eb1f52..870b3251e174 100644
@@ -352,6 +352,8 @@ extern int irq_can_set_affinity(unsigned int irq);
 extern int irq_select_affinity(unsigned int irq);
 
 extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
+extern int irq_update_affinity_desc(unsigned int irq,
+				    struct irq_affinity_desc *affinity);
 
 extern int
 irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
@@ -387,6 +389,12 @@ static inline int irq_set_affinity_hint(unsigned int irq,
 	return -EINVAL;
 }
 
+static inline int irq_update_affinity_desc(unsigned int irq,
+					   struct irq_affinity_desc *affinity)
+{
+	return -EINVAL;
+}
+
 static inline int
 irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
 {
kernel/irq/manage.c +19 -0
index c460e0496006..b96af4cde4bc 100644
@@ -371,6 +371,25 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask,
 	return ret;
 }
 
+int irq_update_affinity_desc(unsigned int irq,
+			     struct irq_affinity_desc *affinity)
+{
+	unsigned long flags;
+	struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
+
+	if (!desc)
+		return -EINVAL;
+
+	if (affinity->is_managed) {
+		irqd_set(&desc->irq_data, IRQD_AFFINITY_MANAGED);
+		irqd_set(&desc->irq_data, IRQD_MANAGED_SHUTDOWN);
+	}
+
+	cpumask_copy(desc->irq_common_data.affinity, &affinity->mask);
+	irq_put_desc_unlock(desc, flags);
+	return 0;
+}
+
 int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force)
 {
 	struct irq_desc *desc = irq_to_desc(irq);
Signature · 1 line
2.26.2
#2 lore raw

Re: [PATCH 1/3] genirq/affinity: Add irq_update_affinity_desc()

John,

Quoted 6 lines · John Garry

From: Thomas Gleixner <[email protected]>

Add a function to allow the affinity of an interrupt be switched to managed, such that interrupts allocated for platform devices may be managed.

Quoted 7 lines

<Insert author sob>

[jpg: Add commit message and add prototypes]

---
Thomas, I just made you author since you provided the original code, hope it's ok.

I already forgot about this. And in fact I only gave you a broken example. So just make yourself the author and add Suggested-by: tglx.

Vs. merging. I'd like to pick that up myself as I might have other changes in that area coming up.

I'll do it as a single commit on top of rc1 and tag it so the scsi people can just pull it in.

Thanks,

tglx

author
#3 lore raw

Re: [PATCH 1/3] genirq/affinity: Add irq_update_affinity_desc()

Hi Thomas,

Quoted 8 lines
Quoted 8 lines

From: Thomas Gleixner <[email protected]>

Add a function to allow the affinity of an interrupt be switched to managed, such that interrupts allocated for platform devices may be managed.

<Insert author sob>

Quoted 7 lines
Quoted 5 lines
[jpg: Add commit message and add prototypes]

---
Thomas, I just made you author since you provided the original code, hope it's ok.

I already forgot about this.

We needed some changes to go in to make the block CPU hotplug handling usable for some scsi drivers, which took a while.

Quoted 3 lines

And in fact I only gave you a broken
example. So just make yourself the author and add Suggested-by: tglx.

ok, will repost with that, cheers

Quoted 5 lines

Vs. merging. I'd like to pick that up myself as I might have other changes in that area coming up.

I'll do it as a single commit on top of rc1 and tag it so the scsi people can just pull it in.

I guess it's ok, I will defer to the maintainers on that.

Thanks,
John

author
#4 lore raw

PATCH 2/3 Driver core: platform: Add platform_get_irqs_affinity()

In reply to John Garry

Drivers for multi-queue platform devices may also want managed interrupts for handling HW queue completion interrupts, so add support.

The function accepts an affinity descriptor pointer, which covers all IRQs expected for the device.

The platform device driver is expected to hold all the IRQ numbers, as there is no point in holding these in the common platform_device structure.

---
 drivers/base/platform.c         | 58 +++++++++++++++++++++++++++++++++
 include/linux/platform_device.h |  5 +++
 2 files changed, 63 insertions(+)
drivers/base/platform.c +58 -0
index 88aef93eb4dd..c110b35469d6 100644
@@ -269,6 +269,64 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
 }
 EXPORT_SYMBOL_GPL(platform_get_irq);
 
+/**
+ * platform_get_irqs_affinity - get all IRQs for a device using an affinity
+ *				descriptor
+ * @dev: platform device pointer
+ * @affd: affinity descriptor, must be set
+ * @count: pointer to count of IRQS
+ * @irqs: pointer holder for IRQ numbers
+ *
+ * Gets a full set of IRQs for a platform device, and updates IRQ afffinty
+ * according to the passed affinity descriptor
+ *
+ * Return: 0 on success, negative error number on failure.
+ */
+int platform_get_irqs_affinity(struct platform_device *dev,
+			       struct irq_affinity *affd,
+			       unsigned int *count,
+			       int **irqs)
+{
+	struct irq_affinity_desc *desc;
+	int i, *pirqs;
+
+	if (!affd)
+		return -EPERM;
+
+	*count = platform_irq_count(dev);
+
+	if (*count <= affd->pre_vectors + affd->post_vectors)
+		return -EIO;
+
+	pirqs = kcalloc(*count, sizeof(int), GFP_KERNEL);
+	if (!pirqs)
+		return -ENOMEM;
+
+	for (i = 0; i < *count; i++) {
+		int irq = platform_get_irq(dev, i);
+		if (irq < 0) {
+			kfree(pirqs);
+			return irq;
+		}
+		pirqs[i] = irq;
+	}
+
+	desc = irq_create_affinity_masks(*count, affd);
+	if (!desc) {
+		kfree(pirqs);
+		return -ENOMEM;
+	}
+
+	for (i = 0; i < *count; i++)
+		irq_update_affinity_desc(pirqs[i], &desc[i]);
+
+	kfree(desc);
+	*irqs = pirqs;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(platform_get_irqs_affinity);
+
 /**
  * platform_irq_count - Count the number of IRQs a platform device uses
  * @dev: platform device
include/linux/platform_device.h +5 -0
index 77a2aada106d..c3f4fc5a76b9 100644
@@ -11,6 +11,7 @@
 #define _PLATFORM_DEVICE_H_
 
 #include <linux/device.h>
+#include <linux/interrupt.h>
 
 #define PLATFORM_DEVID_NONE	(-1)
 #define PLATFORM_DEVID_AUTO	(-2)
@@ -70,6 +71,10 @@ devm_platform_ioremap_resource_byname(struct platform_device *pdev,
 extern int platform_get_irq(struct platform_device *, unsigned int);
 extern int platform_get_irq_optional(struct platform_device *, unsigned int);
 extern int platform_irq_count(struct platform_device *);
+extern int platform_get_irqs_affinity(struct platform_device *dev,
+				      struct irq_affinity *affd,
+				      unsigned int *count,
+				      int **irqs);
 extern struct resource *platform_get_resource_byname(struct platform_device *,
 						     unsigned int,
 						     const char *);
Signature · 1 line
2.26.2
#5 lore raw

Re: [PATCH 2/3] Driver core: platform: Add platform_get_irqs_affinity()

I love your patch! Perhaps something to improve:

Hi John,

I love your patch! Perhaps something to improve:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on scsi/for-next tip/irq/core driver-core/driver-core-testing linus/master v5.10-rc1 next-20201029] [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/John-Garry/Support-managed-interrupts-for-platform-devices/20201027-201557
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: h8300-randconfig-r025-20201029 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0

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
# https://github.com/0day-ci/linux/commit/8675e033c5fd8a87c202e2bc74834122f010adc5
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review John-Garry/Support-managed-interrupts-for-platform-devices/20201027-201557 git checkout 8675e033c5fd8a87c202e2bc74834122f010adc5
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=h8300

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from arch/h8300/include/asm/irq.h:5,

                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:13,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:10,
                    from include/linux/interrupt.h:11,
                    from include/linux/platform_device.h:14,
                    from include/linux/mfd/core.h:13,
                    from drivers/mfd/88pm800.c:27:
>> include/linux/irqchip.h:31:42: warning: 'struct platform_device' declared inside parameter list will not be visible outside of this definition or declaration
      31 | extern int platform_irqchip_probe(struct platform_device *pdev);
         |                                          ^~~~~~~~~~~~~~~
--
   In file included from include/linux/irqchip.h:17,
                    from arch/h8300/include/asm/irq.h:5,
                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:13,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:10,
                    from include/linux/interrupt.h:11,
                    from drivers/mfd/tps65217.c:21:
>> include/linux/platform_device.h:75:18: warning: 'struct irq_affinity' declared inside parameter list will not be visible outside of this definition or declaration
      75 |           struct irq_affinity *affd,
         |                  ^~~~~~~~~~~~
   In file included from include/linux/dev_printk.h:14,
                    from include/linux/device.h:15,
                    from drivers/mfd/tps65217.c:18:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   include/asm-generic/page.h:93:50: warning: ordered comparison of pointer with null pointer [-Wextra]
      93 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
         |                                                  ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:143:2: note: in expansion of macro 'BUG_ON'
     143 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:143:10: note: in expansion of macro 'virt_addr_valid'
     143 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
--
   In file included from include/linux/irqchip.h:17,
                    from arch/h8300/include/asm/irq.h:5,
                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:13,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:10,
                    from include/linux/interrupt.h:11,
                    from drivers/mfd/max77650.c:10:
>> include/linux/platform_device.h:75:18: warning: 'struct irq_affinity' declared inside parameter list will not be visible outside of this definition or declaration

75 | struct irq_affinity *affd,
| ^~~~~~~~~~~~
--
In file included from include/linux/kernel.h:11,

                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from drivers/mfd/si476x-prop.c:11:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   include/asm-generic/page.h:93:50: warning: ordered comparison of pointer with null pointer [-Wextra]
      93 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
         |                                                  ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:143:2: note: in expansion of macro 'BUG_ON'
     143 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:143:10: note: in expansion of macro 'virt_addr_valid'
     143 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
   In file included from arch/h8300/include/asm/irq.h:5,
                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:13,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:10,
                    from include/linux/interrupt.h:11,
                    from include/linux/platform_device.h:14,
                    from include/linux/mfd/core.h:13,
                    from include/linux/mfd/si476x-core.h:20,
                    from drivers/mfd/si476x-prop.c:13:
   include/linux/irqchip.h: At top level:
>> include/linux/irqchip.h:31:42: warning: 'struct platform_device' declared inside parameter list will not be visible outside of this definition or declaration
      31 | extern int platform_irqchip_probe(struct platform_device *pdev);
         |                                          ^~~~~~~~~~~~~~~
--
   In file included from arch/h8300/include/asm/irq.h:5,
                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:13,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:10,
                    from include/linux/interrupt.h:11,
                    from include/linux/platform_device.h:14,
                    from include/linux/of_device.h:6,
                    from drivers/irqchip/irqchip.c:13:
>> include/linux/irqchip.h:31:42: warning: 'struct platform_device' declared inside parameter list will not be visible outside of this definition or declaration
      31 | extern int platform_irqchip_probe(struct platform_device *pdev);
         |                                          ^~~~~~~~~~~~~~~
   drivers/irqchip/irqchip.c:35:5: error: conflicting types for 'platform_irqchip_probe'
      35 | int platform_irqchip_probe(struct platform_device *pdev)
         |     ^~~~~~~~~~~~~~~~~~~~~~
   In file included from arch/h8300/include/asm/irq.h:5,
                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:13,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:10,
                    from include/linux/interrupt.h:11,
                    from include/linux/platform_device.h:14,
                    from include/linux/of_device.h:6,
                    from drivers/irqchip/irqchip.c:13:
   include/linux/irqchip.h:31:12: note: previous declaration of 'platform_irqchip_probe' was here
      31 | extern int platform_irqchip_probe(struct platform_device *pdev);
         |            ^~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/kernel.h:8,
                    from include/linux/list.h:9,
                    from include/linux/kobject.h:19,
                    from include/linux/of.h:17,
                    from include/linux/irqdomain.h:35,
                    from include/linux/acpi.h:13,
                    from drivers/irqchip/irqchip.c:11:
   drivers/irqchip/irqchip.c:60:19: error: conflicting types for 'platform_irqchip_probe'
      60 | EXPORT_SYMBOL_GPL(platform_irqchip_probe);
         |                   ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:98:21: note: in definition of macro '___EXPORT_SYMBOL'
      98 |  extern typeof(sym) sym;       \
         |                     ^~~
   include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
     155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
         |                                  ^~~~~~~~~~~~~~~
   include/linux/export.h:159:33: note: in expansion of macro '_EXPORT_SYMBOL'
     159 | #define EXPORT_SYMBOL_GPL(sym)  _EXPORT_SYMBOL(sym, "_gpl")
         |                                 ^~~~~~~~~~~~~~
   drivers/irqchip/irqchip.c:60:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
      60 | EXPORT_SYMBOL_GPL(platform_irqchip_probe);
         | ^~~~~~~~~~~~~~~~~
   In file included from arch/h8300/include/asm/irq.h:5,
                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:13,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:10,
                    from include/linux/interrupt.h:11,
                    from include/linux/platform_device.h:14,
                    from include/linux/of_device.h:6,
                    from drivers/irqchip/irqchip.c:13:
   include/linux/irqchip.h:31:12: note: previous declaration of 'platform_irqchip_probe' was here
      31 | extern int platform_irqchip_probe(struct platform_device *pdev);
         |            ^~~~~~~~~~~~~~~~~~~~~~
--
   In file included from arch/h8300/include/asm/irq.h:5,
                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:13,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:10,
                    from include/linux/interrupt.h:11,
                    from include/linux/platform_device.h:14,
                    from drivers/mfd/sm501.c:17:
>> include/linux/irqchip.h:31:42: warning: 'struct platform_device' declared inside parameter list will not be visible outside of this definition or declaration
      31 | extern int platform_irqchip_probe(struct platform_device *pdev);
         |                                          ^~~~~~~~~~~~~~~
   In file included from include/linux/kernel.h:11,
                    from drivers/mfd/sm501.c:11:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   include/asm-generic/page.h:93:50: warning: ordered comparison of pointer with null pointer [-Wextra]
      93 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
         |                                                  ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:143:2: note: in expansion of macro 'BUG_ON'
     143 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:143:10: note: in expansion of macro 'virt_addr_valid'
     143 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~

--
In file included from include/linux/dev_printk.h:14,
from include/linux/device.h:15,
from include/linux/spi/spi.h:9,
from drivers/mfd/stmpe-spi.c:10:
include/linux/scatterlist.h: In function 'sg_set_buf':
include/asm-generic/page.h:93:50: warning: ordered comparison of pointer with null pointer [-Wextra]

      93 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
         |                                                  ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:143:2: note: in expansion of macro 'BUG_ON'
     143 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:143:10: note: in expansion of macro 'virt_addr_valid'
     143 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
   In file included from include/linux/irqchip.h:17,
                    from arch/h8300/include/asm/irq.h:5,
                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:13,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:10,
                    from include/linux/interrupt.h:11,
                    from drivers/mfd/stmpe-spi.c:11:
   include/linux/platform_device.h: At top level:
>> include/linux/platform_device.h:75:18: warning: 'struct irq_affinity' declared inside parameter list will not be visible outside of this definition or declaration

75 | struct irq_affinity *affd,
| ^~~~~~~~~~~~
--
In file included from include/linux/irqchip.h:17,

                    from arch/h8300/include/asm/irq.h:5,
                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:13,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:10,
                    from include/linux/interrupt.h:11,
                    from include/linux/kernel_stat.h:9,
                    from arch/h8300/kernel/asm-offsets.c:14:
>> include/linux/platform_device.h:75:18: warning: 'struct irq_affinity' declared inside parameter list will not be visible outside of this definition or declaration

75 | struct irq_affinity *affd,
| ^~~~~~~~~~~~
<stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]

vim +31 include/linux/irqchip.h

91e20b5040c67c5 Joel Porquet 2015-07-02 30
f8410e626569324 Saravana Kannan 2020-07-17 @31 extern int platform_irqchip_probe(struct platform_device *pdev); f8410e626569324 Saravana Kannan 2020-07-17 32

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

author
#6 lore raw

PATCH 3/3 scsi: hisi_sas: Expose HW queues for v2 hw

In reply to John Garry

As a performance enhancement, make the completion queue interrupts managed.

In addition, in commit bf0beec0607d ("blk-mq: drain I/O when all CPUs in a hctx are offline"), CPU hotplug for MQ devices using managed interrupts is made safe. So expose HW queues to blk-mq to take advantage of this.

Flag Scsi_host.host_tagset is also set to ensure that the HBA is not sent more commands than it can handle. However the driver still does not use request tag for IPTT as there are many HW bugs which means that special rules apply for IPTT allocation.

---
 drivers/scsi/hisi_sas/hisi_sas.h       |  4 ++
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 11 ++++
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 71 ++++++++++++++++++++++----
 3 files changed, 75 insertions(+), 11 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +4 -0
index a25cfc11c96d..33c4fb45dd99 100644
@@ -14,6 +14,7 @@
 #include <linux/debugfs.h>
 #include <linux/dmapool.h>
 #include <linux/iopoll.h>
+#include <linux/irq.h>
 #include <linux/lcm.h>
 #include <linux/libata.h>
 #include <linux/mfd/syscon.h>
@@ -312,6 +313,7 @@ enum {
 
 struct hisi_sas_hw {
 	int (*hw_init)(struct hisi_hba *hisi_hba);
+	int (*interrupt_preinit)(struct hisi_hba *hisi_hba);
 	void (*setup_itct)(struct hisi_hba *hisi_hba,
 			   struct hisi_sas_device *device);
 	int (*slot_index_alloc)(struct hisi_hba *hisi_hba,
@@ -418,6 +420,8 @@ struct hisi_hba {
 	u32 refclk_frequency_mhz;
 	u8 sas_addr[SAS_ADDR_SIZE];
 
+	int irq_map[128]; /* v2 hw */
+
 	int n_phy;
 	spinlock_t lock;
 	struct semaphore sem;
drivers/scsi/hisi_sas/hisi_sas_main.c +11 -0
index 128583dfccf2..56f914203679 100644
@@ -2614,6 +2614,13 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 	return NULL;
 }
 
+static int hisi_sas_interrupt_preinit(struct hisi_hba *hisi_hba)
+{
+	if (hisi_hba->hw->interrupt_preinit)
+		return hisi_hba->hw->interrupt_preinit(hisi_hba);
+	return 0;
+}
+
 int hisi_sas_probe(struct platform_device *pdev,
 		   const struct hisi_sas_hw *hw)
 {
@@ -2671,6 +2678,10 @@ int hisi_sas_probe(struct platform_device *pdev,
 		sha->sas_port[i] = &hisi_hba->port[i].sas_port;
 	}
 
+	rc = hisi_sas_interrupt_preinit(hisi_hba);
+	if (rc)
+		goto err_out_ha;
+
 	rc = scsi_add_host(shost, &pdev->dev);
 	if (rc)
 		goto err_out_ha;
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +60 -11

127 lines not on this page · raw message

Signature · 1 line
2.26.2