提交 46817769 编写于 作者: A Alexander Gordeev 提交者: Jens Axboe

skd: Fix incomplete cleanup of MSI-X interrupt

When enabling MSI-X interrupts fails due to lack of memory
the call to pci_disable_msix() is missed and the device is
left with MSI-X interrupts enabled while the driver assumes
otherwise. This update fixes the described misbehaviour and
cleans up the code of skd_release_msix() function.
Signed-off-by: NAlexander Gordeev <agordeev@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: linux-pci@vger.kernel.org
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 c5e3035c
......@@ -3910,43 +3910,44 @@ 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;
}
static int skd_acquire_msix(struct skd_device *skdev)
{
int i, rc;
struct pci_dev *pdev;
struct msix_entry *entries = NULL;
int i, rc, msix_count = SKD_MAX_MSIX_COUNT;
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);
entries = kzalloc(sizeof(struct msix_entry) * msix_count, GFP_KERNEL);
if (!entries)
return -ENOMEM;
for (i = 0; i < SKD_MAX_MSIX_COUNT; i++)
for (i = 0; i < msix_count; i++)
entries[i].entry = i;
rc = pci_enable_msix(pdev, entries, SKD_MAX_MSIX_COUNT);
rc = pci_enable_msix(pdev, entries, msix_count);
if (rc < 0)
goto msix_out;
if (rc) {
else if (rc) {
if (rc < SKD_MIN_MSIX_COUNT) {
pr_err("(%s): failed to enable MSI-X %d\n",
skd_name(skdev), rc);
......@@ -3956,20 +3957,21 @@ static int skd_acquire_msix(struct skd_device *skdev)
skdev->name, __func__, __LINE__,
pci_name(pdev), skdev->name, rc);
skdev->msix_count = rc;
rc = pci_enable_msix(pdev, entries, skdev->msix_count);
msix_count = rc;
rc = pci_enable_msix(pdev, entries, msix_count);
if (rc) {
pr_err("(%s): failed to enable MSI-X "
"support (%d) %d\n",
skd_name(skdev), skdev->msix_count, rc);
skd_name(skdev), msix_count, rc);
goto msix_out;
}
}
skdev->msix_count = msix_count;
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册