Re: [PATCHv3 01/10] mpt3sas: switch to pci_alloc_irq_vectors

2017-02-23 Thread Sreekanth Reddy
On Thu, Feb 23, 2017 at 6:22 AM, Martin K. Petersen
 wrote:
>> "Christoph" == Christoph Hellwig  writes:
>
> Christoph> Martin, can we get at least this patch still in for 4.11?
> Christoph> I'd really like to see as many intance of the old MSI-X
> Christoph> allocation and IRQ affinity mess dead as soon as possible.
>
> Me too. I'll queue it up for 4.11 unless Broadcom objects. And then
> we'll do the rest for 4.12.

This patch looks good. Please consider this patch for 4.11.

We need some time to review remaining patches as it has lot code
refinement and we need to cover some basic test cases.

Thanks,
Sreekanth

>
> --
> Martin K. Petersen  Oracle Linux Engineering


Re: [PATCHv3 01/10] mpt3sas: switch to pci_alloc_irq_vectors

2017-02-22 Thread Martin K. Petersen
> "Christoph" == Christoph Hellwig  writes:

Christoph> Martin, can we get at least this patch still in for 4.11?
Christoph> I'd really like to see as many intance of the old MSI-X
Christoph> allocation and IRQ affinity mess dead as soon as possible.

Me too. I'll queue it up for 4.11 unless Broadcom objects. And then
we'll do the rest for 4.12.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCHv3 01/10] mpt3sas: switch to pci_alloc_irq_vectors

2017-02-22 Thread Hannes Reinecke
On 02/22/2017 09:28 AM, Christoph Hellwig wrote:
> Martin,
> 
> can we get at least this patch still in for 4.11?  I'd really like
> to see as many intance of the old MSI-X allocation and IRQ affinity
> mess dead as soon as possible.
> 
I'm currently reworking the patchset with the suggestions from
Christoph, will be posting the next iteration later today.

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCHv3 01/10] mpt3sas: switch to pci_alloc_irq_vectors

2017-02-22 Thread Christoph Hellwig
Martin,

can we get at least this patch still in for 4.11?  I'd really like
to see as many intance of the old MSI-X allocation and IRQ affinity
mess dead as soon as possible.


[PATCHv3 01/10] mpt3sas: switch to pci_alloc_irq_vectors

2017-02-21 Thread Hannes Reinecke
Cleanup the MSI-X handling allowing us to use
the PCI-layer provided vector allocation.

Signed-off-by: Hannes Reinecke 
Reviewed-by: Christoph Hellwig 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 105 +---
 drivers/scsi/mpt3sas/mpt3sas_base.h |   2 -
 2 files changed, 48 insertions(+), 59 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index a3fe1fb..5b7aec5 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -1148,7 +1148,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
/* TMs are on msix_index == 0 */
if (reply_q->msix_index == 0)
continue;
-   synchronize_irq(reply_q->vector);
+   synchronize_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index));
}
 }
 
@@ -1837,11 +1837,8 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
 
list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) {
list_del(&reply_q->list);
-   if (smp_affinity_enable) {
-   irq_set_affinity_hint(reply_q->vector, NULL);
-   free_cpumask_var(reply_q->affinity_hint);
-   }
-   free_irq(reply_q->vector, reply_q);
+   free_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index),
+reply_q);
kfree(reply_q);
}
 }
@@ -1850,13 +1847,13 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
  * _base_request_irq - request irq
  * @ioc: per adapter object
  * @index: msix index into vector table
- * @vector: irq vector
  *
  * Inserting respective reply_queue into the list.
  */
 static int
-_base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index, u32 vector)
+_base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index)
 {
+   struct pci_dev *pdev = ioc->pdev;
struct adapter_reply_queue *reply_q;
int r;
 
@@ -1868,14 +1865,6 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
}
reply_q->ioc = ioc;
reply_q->msix_index = index;
-   reply_q->vector = vector;
-
-   if (smp_affinity_enable) {
-   if (!zalloc_cpumask_var(&reply_q->affinity_hint, GFP_KERNEL)) {
-   kfree(reply_q);
-   return -ENOMEM;
-   }
-   }
 
atomic_set(&reply_q->busy, 0);
if (ioc->msix_enable)
@@ -1884,12 +1873,11 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
else
snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d",
ioc->driver_name, ioc->id);
-   r = request_irq(vector, _base_interrupt, IRQF_SHARED, reply_q->name,
-   reply_q);
+   r = request_irq(pci_irq_vector(pdev, index), _base_interrupt,
+   IRQF_SHARED, reply_q->name, reply_q);
if (r) {
pr_err(MPT3SAS_FMT "unable to allocate interrupt %d!\n",
-   reply_q->name, vector);
-   free_cpumask_var(reply_q->affinity_hint);
+  reply_q->name, pci_irq_vector(pdev, index));
kfree(reply_q);
return -EBUSY;
}
@@ -1925,6 +1913,21 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
if (!nr_msix)
return;
 
+   if (smp_affinity_enable) {
+   list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
+   const cpumask_t *mask = pci_irq_get_affinity(ioc->pdev,
+   reply_q->msix_index);
+   if (!mask) {
+   pr_warn(MPT3SAS_FMT "no affinity for msi %x\n",
+   ioc->name, reply_q->msix_index);
+   continue;
+   }
+
+   for_each_cpu(cpu, mask)
+   ioc->cpu_msix_table[cpu] = reply_q->msix_index;
+   }
+   return;
+   }
cpu = cpumask_first(cpu_online_mask);
 
list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
@@ -1938,18 +1941,9 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
group++;
 
for (i = 0 ; i < group ; i++) {
-   ioc->cpu_msix_table[cpu] = index;
-   if (smp_affinity_enable)
-   cpumask_or(reply_q->affinity_hint,
-  reply_q->affinity_hint, get_cpu_mask(cpu));
+   ioc->cpu_msix_table[cpu] = reply_q->msix_index;
cpu = cpumask_next(cpu, cpu_online_mask);
}
-   if (smp_affinity_enable)
-   if (irq_set_affinity_hint(reply_q->vector,
-  reply_q->affinity_hint))
-   dinitprintk(ioc, pr_info(MPT3SAS_F