Re: [PATCH v4 3/6] qla2xxx: Utilize pci_alloc_irq_vectors/pci_free_irq_vectors calls.

2016-12-08 Thread Madhani, Himanshu
Hi Christoph, 



On 12/7/16, 11:03 AM, "Christoph Hellwig"  wrote:

>>  static int
>>  qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
>>  {
>>  #define MIN_MSIX_COUNT  2
>>  #define ATIO_VECTOR 2
>>  int i, ret;
>>  struct qla_msix_entry *qentry;
>>  scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
>>  
>> +ret = pci_alloc_irq_vectors(ha->pdev,
>> +MIN_MSIX_COUNT, ha->msix_count, PCI_IRQ_MSIX|PCI_IRQ_AFFINITY);
>
>Given that as-is the code only uses two vectors, and they are not
>for per-cpu queues using PCI_IRQ_AFFINITY is actually wrong, and
>you're better off without it.  Also please fix the spacing:
>tabs for aligning continued arguments, and spaces around operators
>(although the revised version won't have an operator - so this is
>just for future reference:
>

Ack. Agree here this change should not be part of this patch.

>   ret = pci_alloc_irq_vectors(ha->pdev, MIN_MSIX_COUNT,
>   ha->msix_count, PCI_IRQ_MSIX);
>
>> +struct rsp_que *rsp = (struct rsp_que *)e->handle;
>
>No need for the cast here.

Ack. Will post update in new series. 

>
>> +struct rsp_que *rsp = (struct rsp_que *)e->handle;
>
>Same here.

Will send new series soon.

>
N�r��yb�X��ǧv�^�)޺{.n�+{���"�{ay�ʇڙ�,j��f���h���z��w���
���j:+v���w�j�mzZ+�ݢj"��!�i

Re: [PATCH v4 3/6] qla2xxx: Utilize pci_alloc_irq_vectors/pci_free_irq_vectors calls.

2016-12-08 Thread Hannes Reinecke

On 12/06/2016 08:07 PM, Himanshu Madhani wrote:

From: Michael Hernandez 

Replaces the old pci_enable_msi[x]* and pci_disable_msi[x] calls.

Signed-off-by: Michael Hernandez 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h |  2 +-
 drivers/scsi/qla2xxx/qla_isr.c | 89 --
 drivers/scsi/qla2xxx/qla_mid.c |  2 +-
 3 files changed, 36 insertions(+), 57 deletions(-)


Reviewed-by: Hannes Reinecke 

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)
--
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 v4 3/6] qla2xxx: Utilize pci_alloc_irq_vectors/pci_free_irq_vectors calls.

2016-12-07 Thread Christoph Hellwig
>  static int
>  qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
>  {
>  #define MIN_MSIX_COUNT   2
>  #define ATIO_VECTOR  2
>   int i, ret;
>   struct qla_msix_entry *qentry;
>   scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
>  
> + ret = pci_alloc_irq_vectors(ha->pdev,
> + MIN_MSIX_COUNT, ha->msix_count, PCI_IRQ_MSIX|PCI_IRQ_AFFINITY);

Given that as-is the code only uses two vectors, and they are not
for per-cpu queues using PCI_IRQ_AFFINITY is actually wrong, and
you're better off without it.  Also please fix the spacing:
tabs for aligning continued arguments, and spaces around operators
(although the revised version won't have an operator - so this is
just for future reference:

ret = pci_alloc_irq_vectors(ha->pdev, MIN_MSIX_COUNT,
ha->msix_count, PCI_IRQ_MSIX);

> + struct rsp_que *rsp = (struct rsp_que *)e->handle;

No need for the cast here.

> + struct rsp_que *rsp = (struct rsp_que *)e->handle;

Same here.
--
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 v4 3/6] qla2xxx: Utilize pci_alloc_irq_vectors/pci_free_irq_vectors calls.

2016-12-06 Thread Himanshu Madhani
From: Michael Hernandez 

Replaces the old pci_enable_msi[x]* and pci_disable_msi[x] calls.

Signed-off-by: Michael Hernandez 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h |  2 +-
 drivers/scsi/qla2xxx/qla_isr.c | 89 --
 drivers/scsi/qla2xxx/qla_mid.c |  2 +-
 3 files changed, 36 insertions(+), 57 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 9a6ddcb..8a6780c 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2747,7 +2747,7 @@ struct qla_msix_entry {
int have_irq;
uint32_t vector;
uint16_t entry;
-   struct rsp_que *rsp;
+   void *handle;
struct irq_affinity_notify irq_notify;
int cpuid;
 };
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 19f1848..0601ba2 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -3025,52 +3025,17 @@ struct qla_init_msix_entry {
{ "qla2xxx (atio_q)", qla83xx_msix_atio_q },
 };
 
-static void
-qla24xx_disable_msix(struct qla_hw_data *ha)
-{
-   int i;
-   struct qla_msix_entry *qentry;
-   scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
-
-   for (i = 0; i < ha->msix_count; i++) {
-   qentry = >msix_entries[i];
-   if (qentry->have_irq) {
-   /* un-register irq cpu affinity notification */
-   irq_set_affinity_notifier(qentry->vector, NULL);
-   free_irq(qentry->vector, qentry->rsp);
-   }
-   }
-   pci_disable_msix(ha->pdev);
-   kfree(ha->msix_entries);
-   ha->msix_entries = NULL;
-   ha->flags.msix_enabled = 0;
-   ql_dbg(ql_dbg_init, vha, 0x0042,
-   "Disabled the MSI.\n");
-}
-
 static int
 qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
 {
 #define MIN_MSIX_COUNT 2
 #define ATIO_VECTOR2
int i, ret;
-   struct msix_entry *entries;
struct qla_msix_entry *qentry;
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
 
-   entries = kzalloc(sizeof(struct msix_entry) * ha->msix_count,
-   GFP_KERNEL);
-   if (!entries) {
-   ql_log(ql_log_warn, vha, 0x00bc,
-   "Failed to allocate memory for msix_entry.\n");
-   return -ENOMEM;
-   }
-
-   for (i = 0; i < ha->msix_count; i++)
-   entries[i].entry = i;
-
-   ret = pci_enable_msix_range(ha->pdev,
-   entries, MIN_MSIX_COUNT, ha->msix_count);
+   ret = pci_alloc_irq_vectors(ha->pdev,
+   MIN_MSIX_COUNT, ha->msix_count, PCI_IRQ_MSIX|PCI_IRQ_AFFINITY);
if (ret < 0) {
ql_log(ql_log_fatal, vha, 0x00c7,
"MSI-X: Failed to enable support, "
@@ -3097,10 +3062,10 @@ struct qla_init_msix_entry {
 
for (i = 0; i < ha->msix_count; i++) {
qentry = >msix_entries[i];
-   qentry->vector = entries[i].vector;
-   qentry->entry = entries[i].entry;
+   qentry->vector = pci_irq_vector(ha->pdev, i);
+   qentry->entry = i;
qentry->have_irq = 0;
-   qentry->rsp = NULL;
+   qentry->handle = NULL;
qentry->irq_notify.notify  = qla_irq_affinity_notify;
qentry->irq_notify.release = qla_irq_affinity_release;
qentry->cpuid = -1;
@@ -3109,7 +3074,7 @@ struct qla_init_msix_entry {
/* Enable MSI-X vectors for the base queue */
for (i = 0; i < 2; i++) {
qentry = >msix_entries[i];
-   qentry->rsp = rsp;
+   qentry->handle = rsp;
rsp->msix = qentry;
if (IS_P3P_TYPE(ha))
ret = request_irq(qentry->vector,
@@ -3142,7 +3107,7 @@ struct qla_init_msix_entry {
 */
if (QLA_TGT_MODE_ENABLED() && IS_ATIO_MSIX_CAPABLE(ha)) {
qentry = >msix_entries[ATIO_VECTOR];
-   qentry->rsp = rsp;
+   qentry->handle = rsp;
rsp->msix = qentry;
ret = request_irq(qentry->vector,
qla83xx_msix_entries[ATIO_VECTOR].handler,
@@ -3155,7 +3120,7 @@ struct qla_init_msix_entry {
ql_log(ql_log_fatal, vha, 0x00cb,
"MSI-X: unable to register handler -- %x/%d.\n",
qentry->vector, ret);
-   qla24xx_disable_msix(ha);
+   qla2x00_free_irqs(vha);
ha->mqenable = 0;
goto msix_out;
}
@@ -3177,7 +3142,6 @@ struct qla_init_msix_entry {
ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues);
 
 msix_out:
-   kfree(entries);
return ret;
 }
 
@@ -3230,7 +3194,7 @@ struct