Skip to content

Commit 4fa1834

Browse files
Michael Hernandezmartinkpetersen
authored andcommitted
scsi: qla2xxx: Utilize pci_alloc_irq_vectors/pci_free_irq_vectors calls.
Replaces the old pci_enable_msi[x]* and pci_disable_msi[x] calls. Signed-off-by: Michael Hernandez <[email protected]> Signed-off-by: Himanshu Madhani <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 77ddb94 commit 4fa1834

File tree

3 files changed

+36
-57
lines changed

3 files changed

+36
-57
lines changed

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2747,7 +2747,7 @@ struct qla_msix_entry {
27472747
int have_irq;
27482748
uint32_t vector;
27492749
uint16_t entry;
2750-
struct rsp_que *rsp;
2750+
void *handle;
27512751
struct irq_affinity_notify irq_notify;
27522752
int cpuid;
27532753
};

drivers/scsi/qla2xxx/qla_isr.c

Lines changed: 34 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,52 +3025,17 @@ static struct qla_init_msix_entry qla83xx_msix_entries[3] = {
30253025
{ "qla2xxx (atio_q)", qla83xx_msix_atio_q },
30263026
};
30273027

3028-
static void
3029-
qla24xx_disable_msix(struct qla_hw_data *ha)
3030-
{
3031-
int i;
3032-
struct qla_msix_entry *qentry;
3033-
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
3034-
3035-
for (i = 0; i < ha->msix_count; i++) {
3036-
qentry = &ha->msix_entries[i];
3037-
if (qentry->have_irq) {
3038-
/* un-register irq cpu affinity notification */
3039-
irq_set_affinity_notifier(qentry->vector, NULL);
3040-
free_irq(qentry->vector, qentry->rsp);
3041-
}
3042-
}
3043-
pci_disable_msix(ha->pdev);
3044-
kfree(ha->msix_entries);
3045-
ha->msix_entries = NULL;
3046-
ha->flags.msix_enabled = 0;
3047-
ql_dbg(ql_dbg_init, vha, 0x0042,
3048-
"Disabled the MSI.\n");
3049-
}
3050-
30513028
static int
30523029
qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
30533030
{
30543031
#define MIN_MSIX_COUNT 2
30553032
#define ATIO_VECTOR 2
30563033
int i, ret;
3057-
struct msix_entry *entries;
30583034
struct qla_msix_entry *qentry;
30593035
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
30603036

3061-
entries = kzalloc(sizeof(struct msix_entry) * ha->msix_count,
3062-
GFP_KERNEL);
3063-
if (!entries) {
3064-
ql_log(ql_log_warn, vha, 0x00bc,
3065-
"Failed to allocate memory for msix_entry.\n");
3066-
return -ENOMEM;
3067-
}
3068-
3069-
for (i = 0; i < ha->msix_count; i++)
3070-
entries[i].entry = i;
3071-
3072-
ret = pci_enable_msix_range(ha->pdev,
3073-
entries, MIN_MSIX_COUNT, ha->msix_count);
3037+
ret = pci_alloc_irq_vectors(ha->pdev, MIN_MSIX_COUNT, ha->msix_count,
3038+
PCI_IRQ_MSIX);
30743039
if (ret < 0) {
30753040
ql_log(ql_log_fatal, vha, 0x00c7,
30763041
"MSI-X: Failed to enable support, "
@@ -3097,10 +3062,10 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
30973062

30983063
for (i = 0; i < ha->msix_count; i++) {
30993064
qentry = &ha->msix_entries[i];
3100-
qentry->vector = entries[i].vector;
3101-
qentry->entry = entries[i].entry;
3065+
qentry->vector = pci_irq_vector(ha->pdev, i);
3066+
qentry->entry = i;
31023067
qentry->have_irq = 0;
3103-
qentry->rsp = NULL;
3068+
qentry->handle = NULL;
31043069
qentry->irq_notify.notify = qla_irq_affinity_notify;
31053070
qentry->irq_notify.release = qla_irq_affinity_release;
31063071
qentry->cpuid = -1;
@@ -3109,7 +3074,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
31093074
/* Enable MSI-X vectors for the base queue */
31103075
for (i = 0; i < 2; i++) {
31113076
qentry = &ha->msix_entries[i];
3112-
qentry->rsp = rsp;
3077+
qentry->handle = rsp;
31133078
rsp->msix = qentry;
31143079
if (IS_P3P_TYPE(ha))
31153080
ret = request_irq(qentry->vector,
@@ -3142,7 +3107,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
31423107
*/
31433108
if (QLA_TGT_MODE_ENABLED() && IS_ATIO_MSIX_CAPABLE(ha)) {
31443109
qentry = &ha->msix_entries[ATIO_VECTOR];
3145-
qentry->rsp = rsp;
3110+
qentry->handle = rsp;
31463111
rsp->msix = qentry;
31473112
ret = request_irq(qentry->vector,
31483113
qla83xx_msix_entries[ATIO_VECTOR].handler,
@@ -3155,7 +3120,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
31553120
ql_log(ql_log_fatal, vha, 0x00cb,
31563121
"MSI-X: unable to register handler -- %x/%d.\n",
31573122
qentry->vector, ret);
3158-
qla24xx_disable_msix(ha);
3123+
qla2x00_free_irqs(vha);
31593124
ha->mqenable = 0;
31603125
goto msix_out;
31613126
}
@@ -3177,7 +3142,6 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
31773142
ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues);
31783143

31793144
msix_out:
3180-
kfree(entries);
31813145
return ret;
31823146
}
31833147

@@ -3230,7 +3194,7 @@ qla2x00_request_irqs(struct qla_hw_data *ha, struct rsp_que *rsp)
32303194
!IS_QLA27XX(ha))
32313195
goto skip_msi;
32323196

3233-
ret = pci_enable_msi(ha->pdev);
3197+
ret = pci_alloc_irq_vectors(ha->pdev, 1, 1, PCI_IRQ_MSI);
32343198
if (!ret) {
32353199
ql_dbg(ql_dbg_init, vha, 0x0038,
32363200
"MSI: Enabled.\n");
@@ -3275,6 +3239,8 @@ qla2x00_free_irqs(scsi_qla_host_t *vha)
32753239
{
32763240
struct qla_hw_data *ha = vha->hw;
32773241
struct rsp_que *rsp;
3242+
struct qla_msix_entry *qentry;
3243+
int i;
32783244

32793245
/*
32803246
* We need to check that ha->rsp_q_map is valid in case we are called
@@ -3284,13 +3250,24 @@ qla2x00_free_irqs(scsi_qla_host_t *vha)
32843250
return;
32853251
rsp = ha->rsp_q_map[0];
32863252

3287-
if (ha->flags.msix_enabled)
3288-
qla24xx_disable_msix(ha);
3289-
else if (ha->flags.msi_enabled) {
3290-
free_irq(ha->pdev->irq, rsp);
3291-
pci_disable_msi(ha->pdev);
3292-
} else
3293-
free_irq(ha->pdev->irq, rsp);
3253+
if (ha->flags.msix_enabled) {
3254+
for (i = 0; i < ha->msix_count; i++) {
3255+
qentry = &ha->msix_entries[i];
3256+
if (qentry->have_irq) {
3257+
irq_set_affinity_notifier(qentry->vector, NULL);
3258+
free_irq(pci_irq_vector(ha->pdev, i), qentry->handle);
3259+
}
3260+
}
3261+
kfree(ha->msix_entries);
3262+
ha->msix_entries = NULL;
3263+
ha->flags.msix_enabled = 0;
3264+
ql_dbg(ql_dbg_init, vha, 0x0042,
3265+
"Disabled MSI-X.\n");
3266+
} else {
3267+
free_irq(pci_irq_vector(ha->pdev, 0), rsp);
3268+
}
3269+
3270+
pci_free_irq_vectors(ha->pdev);
32943271
}
32953272

32963273

@@ -3310,7 +3287,7 @@ int qla25xx_request_irq(struct rsp_que *rsp)
33103287
return ret;
33113288
}
33123289
msix->have_irq = 1;
3313-
msix->rsp = rsp;
3290+
msix->handle = rsp;
33143291
return ret;
33153292
}
33163293

@@ -3323,11 +3300,12 @@ static void qla_irq_affinity_notify(struct irq_affinity_notify *notify,
33233300
container_of(notify, struct qla_msix_entry, irq_notify);
33243301
struct qla_hw_data *ha;
33253302
struct scsi_qla_host *base_vha;
3303+
struct rsp_que *rsp = e->handle;
33263304

33273305
/* user is recommended to set mask to just 1 cpu */
33283306
e->cpuid = cpumask_first(mask);
33293307

3330-
ha = e->rsp->hw;
3308+
ha = rsp->hw;
33313309
base_vha = pci_get_drvdata(ha->pdev);
33323310

33333311
ql_dbg(ql_dbg_init, base_vha, 0xffff,
@@ -3351,7 +3329,8 @@ static void qla_irq_affinity_release(struct kref *ref)
33513329
container_of(ref, struct irq_affinity_notify, kref);
33523330
struct qla_msix_entry *e =
33533331
container_of(notify, struct qla_msix_entry, irq_notify);
3354-
struct scsi_qla_host *base_vha = pci_get_drvdata(e->rsp->hw->pdev);
3332+
struct rsp_que *rsp = e->handle;
3333+
struct scsi_qla_host *base_vha = pci_get_drvdata(rsp->hw->pdev);
33553334

33563335
ql_dbg(ql_dbg_init, base_vha, 0xffff,
33573336
"%s: host%ld: vector %d cpu %d \n", __func__,

drivers/scsi/qla2xxx/qla_mid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ qla25xx_free_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
542542
if (rsp->msix && rsp->msix->have_irq) {
543543
free_irq(rsp->msix->vector, rsp);
544544
rsp->msix->have_irq = 0;
545-
rsp->msix->rsp = NULL;
545+
rsp->msix->handle = NULL;
546546
}
547547
dma_free_coherent(&ha->pdev->dev, (rsp->length + 1) *
548548
sizeof(response_t), rsp->ring, rsp->dma);

0 commit comments

Comments
 (0)