[PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors
Which cleans up a lot of the MSI-X handling, and allows us to use the PCI IRQ layer provided vector mapping, which we can then expose to blk-mq. Signed-off-by: Christoph HellwigReviewed-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn Acked-by: Don Brace Tested-by: Don Brace --- drivers/scsi/smartpqi/smartpqi.h | 2 - drivers/scsi/smartpqi/smartpqi_init.c | 102 +++--- 2 files changed, 32 insertions(+), 72 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h index 07b6444..b673825 100644 --- a/drivers/scsi/smartpqi/smartpqi.h +++ b/drivers/scsi/smartpqi/smartpqi.h @@ -929,8 +929,6 @@ struct pqi_ctrl_info { int max_msix_vectors; int num_msix_vectors_enabled; int num_msix_vectors_initialized; - u32 msix_vectors[PQI_MAX_MSIX_VECTORS]; - void*intr_data[PQI_MAX_MSIX_VECTORS]; int event_irq; struct Scsi_Host *scsi_host; diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index a535b26..8702d9c 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -2887,19 +2888,19 @@ static irqreturn_t pqi_irq_handler(int irq, void *data) static int pqi_request_irqs(struct pqi_ctrl_info *ctrl_info) { + struct pci_dev *pdev = ctrl_info->pci_dev; int i; int rc; - ctrl_info->event_irq = ctrl_info->msix_vectors[0]; + ctrl_info->event_irq = pci_irq_vector(pdev, 0); for (i = 0; i < ctrl_info->num_msix_vectors_enabled; i++) { - rc = request_irq(ctrl_info->msix_vectors[i], - pqi_irq_handler, 0, - DRIVER_NAME_SHORT, ctrl_info->intr_data[i]); + rc = request_irq(pci_irq_vector(pdev, i), pqi_irq_handler, 0, + DRIVER_NAME_SHORT, _info->queue_groups[i]); if (rc) { - dev_err(_info->pci_dev->dev, + dev_err(>dev, "irq %u init failed with error %d\n", - ctrl_info->msix_vectors[i], rc); + pci_irq_vector(pdev, i), rc); return rc; } ctrl_info->num_msix_vectors_initialized++; @@ -2908,72 +2909,23 @@ static int pqi_request_irqs(struct pqi_ctrl_info *ctrl_info) return 0; } -static void pqi_free_irqs(struct pqi_ctrl_info *ctrl_info) -{ - int i; - - for (i = 0; i < ctrl_info->num_msix_vectors_initialized; i++) - free_irq(ctrl_info->msix_vectors[i], - ctrl_info->intr_data[i]); -} - static int pqi_enable_msix_interrupts(struct pqi_ctrl_info *ctrl_info) { - unsigned int i; - int max_vectors; - int num_vectors_enabled; - struct msix_entry msix_entries[PQI_MAX_MSIX_VECTORS]; - - max_vectors = ctrl_info->num_queue_groups; - - for (i = 0; i < max_vectors; i++) - msix_entries[i].entry = i; - - num_vectors_enabled = pci_enable_msix_range(ctrl_info->pci_dev, - msix_entries, PQI_MIN_MSIX_VECTORS, max_vectors); + int ret; - if (num_vectors_enabled < 0) { + ret = pci_alloc_irq_vectors(ctrl_info->pci_dev, + PQI_MIN_MSIX_VECTORS, ctrl_info->num_queue_groups, + PCI_IRQ_MSIX | PCI_IRQ_AFFINITY); + if (ret < 0) { dev_err(_info->pci_dev->dev, - "MSI-X init failed with error %d\n", - num_vectors_enabled); - return num_vectors_enabled; - } - - ctrl_info->num_msix_vectors_enabled = num_vectors_enabled; - for (i = 0; i < num_vectors_enabled; i++) { - ctrl_info->msix_vectors[i] = msix_entries[i].vector; - ctrl_info->intr_data[i] = _info->queue_groups[i]; + "MSI-X init failed with error %d\n", ret); + return ret; } + ctrl_info->num_msix_vectors_enabled = ret; return 0; } -static void pqi_irq_set_affinity_hint(struct pqi_ctrl_info *ctrl_info) -{ - int i; - int rc; - int cpu; - - cpu = cpumask_first(cpu_online_mask); - for (i = 0; i < ctrl_info->num_msix_vectors_initialized; i++) { - rc = irq_set_affinity_hint(ctrl_info->msix_vectors[i], - get_cpu_mask(cpu)); - if (rc) - dev_err(_info->pci_dev->dev, - "error %d setting affinity hint for irq vector %u\n", - rc, ctrl_info->msix_vectors[i]); - cpu =
RE: [PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors
> -Original Message- > From: Don Brace > Sent: Monday, October 17, 2016 8:45 AM > To: 'Johannes Thumshirn'; Christoph Hellwig > Cc: martin.peter...@oracle.com; ax...@kernel.dk; linux- > s...@vger.kernel.org; linux-bl...@vger.kernel.org > Subject: RE: [PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors > > > > -Original Message- > > From: Johannes Thumshirn [mailto:jthumsh...@suse.de] > > Sent: Monday, October 17, 2016 2:34 AM > > To: Christoph Hellwig > > Cc: martin.peter...@oracle.com; Don Brace; ax...@kernel.dk; linux- > > s...@vger.kernel.org; linux-bl...@vger.kernel.org > > Subject: Re: [PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors > > > > EXTERNAL EMAIL > > > > > > On Sat, Oct 15, 2016 at 10:47:21AM +0200, Christoph Hellwig wrote: > > > Which cleans up a lot of the MSI-X handling, and allows us to use the > > > PCI IRQ layer provided vector mapping, which we can then expose to blk- > > mq. > > > > > > Signed-off-by: Christoph Hellwig <h...@lst.de> > > > --- > > > > Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de> > > -- > > Johannes Thumshirn Storage > > jthumsh...@suse.de+49 911 74053 689 > > SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg > > GF: Felix Imendörffer, Jane Smithard, Graham Norton > > HRB 21284 (AG Nürnberg) > > Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850 > > Acked-by: Don Brace <don.br...@microsemi.com> Tested-by: Don Brace <don.br...@microsemi.com> -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors
> -Original Message- > From: Christoph Hellwig [mailto:h...@lst.de] > Sent: Monday, October 17, 2016 9:21 AM > To: Don Brace > Cc: Johannes Thumshirn; Christoph Hellwig; martin.peter...@oracle.com; > ax...@kernel.dk; linux-scsi@vger.kernel.org; linux-bl...@vger.kernel.org > Subject: Re: [PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors > > EXTERNAL EMAIL > > > Hi Don, > > did you also have a chance to test the patch and verify that the > queues are properly set up with a smartpqi controller? I need more time to test, I need to apply some other patches to fully test. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors
Hi Don, did you also have a chance to test the patch and verify that the queues are properly set up with a smartpqi controller? -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors
> -Original Message- > From: Johannes Thumshirn [mailto:jthumsh...@suse.de] > Sent: Monday, October 17, 2016 2:34 AM > To: Christoph Hellwig > Cc: martin.peter...@oracle.com; Don Brace; ax...@kernel.dk; linux- > s...@vger.kernel.org; linux-bl...@vger.kernel.org > Subject: Re: [PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors > > EXTERNAL EMAIL > > > On Sat, Oct 15, 2016 at 10:47:21AM +0200, Christoph Hellwig wrote: > > Which cleans up a lot of the MSI-X handling, and allows us to use the > > PCI IRQ layer provided vector mapping, which we can then expose to blk- > mq. > > > > Signed-off-by: Christoph Hellwig <h...@lst.de> > > --- > > Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de> > -- > Johannes Thumshirn Storage > jthumsh...@suse.de+49 911 74053 689 > SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg > GF: Felix Imendörffer, Jane Smithard, Graham Norton > HRB 21284 (AG Nürnberg) > Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850 Acked-by: Don Brace <don.br...@microsemi.com> -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors
On Sat, Oct 15, 2016 at 10:47:21AM +0200, Christoph Hellwig wrote: > Which cleans up a lot of the MSI-X handling, and allows us to use the > PCI IRQ layer provided vector mapping, which we can then expose to blk-mq. > > Signed-off-by: Christoph Hellwig> --- Reviewed-by: Johannes Thumshirn -- Johannes Thumshirn Storage jthumsh...@suse.de+49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors
On 10/15/2016 10:47 AM, Christoph Hellwig wrote: Which cleans up a lot of the MSI-X handling, and allows us to use the PCI IRQ layer provided vector mapping, which we can then expose to blk-mq. Signed-off-by: Christoph Hellwig--- drivers/scsi/smartpqi/smartpqi.h | 2 - drivers/scsi/smartpqi/smartpqi_init.c | 102 +++--- 2 files changed, 32 insertions(+), 72 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke zSeries & Storage h...@suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors
Which cleans up a lot of the MSI-X handling, and allows us to use the PCI IRQ layer provided vector mapping, which we can then expose to blk-mq. Signed-off-by: Christoph Hellwig--- drivers/scsi/smartpqi/smartpqi.h | 2 - drivers/scsi/smartpqi/smartpqi_init.c | 102 +++--- 2 files changed, 32 insertions(+), 72 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h index 07b6444..b673825 100644 --- a/drivers/scsi/smartpqi/smartpqi.h +++ b/drivers/scsi/smartpqi/smartpqi.h @@ -929,8 +929,6 @@ struct pqi_ctrl_info { int max_msix_vectors; int num_msix_vectors_enabled; int num_msix_vectors_initialized; - u32 msix_vectors[PQI_MAX_MSIX_VECTORS]; - void*intr_data[PQI_MAX_MSIX_VECTORS]; int event_irq; struct Scsi_Host *scsi_host; diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index a535b26..8702d9c 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -2887,19 +2888,19 @@ static irqreturn_t pqi_irq_handler(int irq, void *data) static int pqi_request_irqs(struct pqi_ctrl_info *ctrl_info) { + struct pci_dev *pdev = ctrl_info->pci_dev; int i; int rc; - ctrl_info->event_irq = ctrl_info->msix_vectors[0]; + ctrl_info->event_irq = pci_irq_vector(pdev, 0); for (i = 0; i < ctrl_info->num_msix_vectors_enabled; i++) { - rc = request_irq(ctrl_info->msix_vectors[i], - pqi_irq_handler, 0, - DRIVER_NAME_SHORT, ctrl_info->intr_data[i]); + rc = request_irq(pci_irq_vector(pdev, i), pqi_irq_handler, 0, + DRIVER_NAME_SHORT, _info->queue_groups[i]); if (rc) { - dev_err(_info->pci_dev->dev, + dev_err(>dev, "irq %u init failed with error %d\n", - ctrl_info->msix_vectors[i], rc); + pci_irq_vector(pdev, i), rc); return rc; } ctrl_info->num_msix_vectors_initialized++; @@ -2908,72 +2909,23 @@ static int pqi_request_irqs(struct pqi_ctrl_info *ctrl_info) return 0; } -static void pqi_free_irqs(struct pqi_ctrl_info *ctrl_info) -{ - int i; - - for (i = 0; i < ctrl_info->num_msix_vectors_initialized; i++) - free_irq(ctrl_info->msix_vectors[i], - ctrl_info->intr_data[i]); -} - static int pqi_enable_msix_interrupts(struct pqi_ctrl_info *ctrl_info) { - unsigned int i; - int max_vectors; - int num_vectors_enabled; - struct msix_entry msix_entries[PQI_MAX_MSIX_VECTORS]; - - max_vectors = ctrl_info->num_queue_groups; - - for (i = 0; i < max_vectors; i++) - msix_entries[i].entry = i; - - num_vectors_enabled = pci_enable_msix_range(ctrl_info->pci_dev, - msix_entries, PQI_MIN_MSIX_VECTORS, max_vectors); + int ret; - if (num_vectors_enabled < 0) { + ret = pci_alloc_irq_vectors(ctrl_info->pci_dev, + PQI_MIN_MSIX_VECTORS, ctrl_info->num_queue_groups, + PCI_IRQ_MSIX | PCI_IRQ_AFFINITY); + if (ret < 0) { dev_err(_info->pci_dev->dev, - "MSI-X init failed with error %d\n", - num_vectors_enabled); - return num_vectors_enabled; - } - - ctrl_info->num_msix_vectors_enabled = num_vectors_enabled; - for (i = 0; i < num_vectors_enabled; i++) { - ctrl_info->msix_vectors[i] = msix_entries[i].vector; - ctrl_info->intr_data[i] = _info->queue_groups[i]; + "MSI-X init failed with error %d\n", ret); + return ret; } + ctrl_info->num_msix_vectors_enabled = ret; return 0; } -static void pqi_irq_set_affinity_hint(struct pqi_ctrl_info *ctrl_info) -{ - int i; - int rc; - int cpu; - - cpu = cpumask_first(cpu_online_mask); - for (i = 0; i < ctrl_info->num_msix_vectors_initialized; i++) { - rc = irq_set_affinity_hint(ctrl_info->msix_vectors[i], - get_cpu_mask(cpu)); - if (rc) - dev_err(_info->pci_dev->dev, - "error %d setting affinity hint for irq vector %u\n", - rc, ctrl_info->msix_vectors[i]); - cpu = cpumask_next(cpu, cpu_online_mask); - } -} - -static void pqi_irq_unset_affinity_hint(struct pqi_ctrl_info *ctrl_info) -{ - int i; - - for (i = 0; i <