diff options
Diffstat (limited to 'drivers/block/skd_main.c')
-rw-r--r-- | drivers/block/skd_main.c | 67 |
1 files changed, 27 insertions, 40 deletions
diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index eb6e1e0e8db2..a69dd93d1bd5 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -3910,18 +3910,22 @@ static void skd_release_msix(struct skd_device *skdev) struct skd_msix_entry *qentry; int i; - if (skdev->msix_entries == NULL) - return; - for (i = 0; i < skdev->msix_count; i++) { - qentry = &skdev->msix_entries[i]; - skdev = qentry->rsp; + if (skdev->msix_entries) { + for (i = 0; i < skdev->msix_count; i++) { + qentry = &skdev->msix_entries[i]; + skdev = qentry->rsp; + + if (qentry->have_irq) + devm_free_irq(&skdev->pdev->dev, + qentry->vector, qentry->rsp); + } - if (qentry->have_irq) - devm_free_irq(&skdev->pdev->dev, - qentry->vector, qentry->rsp); + kfree(skdev->msix_entries); } - pci_disable_msix(skdev->pdev); - kfree(skdev->msix_entries); + + if (skdev->msix_count) + pci_disable_msix(skdev->pdev); + skdev->msix_count = 0; skdev->msix_entries = NULL; } @@ -3929,12 +3933,10 @@ static void skd_release_msix(struct skd_device *skdev) static int skd_acquire_msix(struct skd_device *skdev) { int i, rc; - struct pci_dev *pdev; - struct msix_entry *entries = NULL; + struct pci_dev *pdev = skdev->pdev; + struct msix_entry *entries; struct skd_msix_entry *qentry; - pdev = skdev->pdev; - skdev->msix_count = SKD_MAX_MSIX_COUNT; entries = kzalloc(sizeof(struct msix_entry) * SKD_MAX_MSIX_COUNT, GFP_KERNEL); if (!entries) @@ -3943,40 +3945,26 @@ static int skd_acquire_msix(struct skd_device *skdev) for (i = 0; i < SKD_MAX_MSIX_COUNT; i++) entries[i].entry = i; - rc = pci_enable_msix(pdev, entries, SKD_MAX_MSIX_COUNT); - if (rc < 0) + rc = pci_enable_msix_range(pdev, entries, + SKD_MIN_MSIX_COUNT, SKD_MAX_MSIX_COUNT); + if (rc < 0) { + pr_err("(%s): failed to enable MSI-X %d\n", + skd_name(skdev), rc); goto msix_out; - if (rc) { - if (rc < SKD_MIN_MSIX_COUNT) { - pr_err("(%s): failed to enable MSI-X %d\n", - skd_name(skdev), rc); - goto msix_out; - } - pr_debug("%s:%s:%d %s: <%s> allocated %d MSI-X vectors\n", - skdev->name, __func__, __LINE__, - pci_name(pdev), skdev->name, rc); - - skdev->msix_count = rc; - rc = pci_enable_msix(pdev, entries, skdev->msix_count); - if (rc) { - pr_err("(%s): failed to enable MSI-X " - "support (%d) %d\n", - skd_name(skdev), skdev->msix_count, rc); - goto msix_out; - } } + + skdev->msix_count = rc; skdev->msix_entries = kzalloc(sizeof(struct skd_msix_entry) * skdev->msix_count, GFP_KERNEL); if (!skdev->msix_entries) { rc = -ENOMEM; - skdev->msix_count = 0; pr_err("(%s): msix table allocation error\n", skd_name(skdev)); goto msix_out; } - qentry = skdev->msix_entries; for (i = 0; i < skdev->msix_count; i++) { + qentry = &skdev->msix_entries[i]; qentry->vector = entries[i].vector; qentry->entry = entries[i].entry; qentry->rsp = NULL; @@ -3985,11 +3973,10 @@ static int skd_acquire_msix(struct skd_device *skdev) skdev->name, __func__, __LINE__, pci_name(pdev), skdev->name, i, qentry->vector, qentry->entry); - qentry++; } /* Enable MSI-X vectors for the base queue */ - for (i = 0; i < SKD_MAX_MSIX_COUNT; i++) { + for (i = 0; i < skdev->msix_count; i++) { qentry = &skdev->msix_entries[i]; snprintf(qentry->isr_name, sizeof(qentry->isr_name), "%s%d-msix %s", DRV_NAME, skdev->devno, @@ -4045,8 +4032,8 @@ RETRY_IRQ_TYPE: case SKD_IRQ_MSI: snprintf(skdev->isr_name, sizeof(skdev->isr_name), "%s%d-msi", DRV_NAME, skdev->devno); - rc = pci_enable_msi(pdev); - if (!rc) { + rc = pci_enable_msi_range(pdev, 1, 1); + if (rc > 0) { rc = devm_request_irq(&pdev->dev, pdev->irq, skd_isr, 0, skdev->isr_name, skdev); if (rc) { |