Commit a1ce3e1f authored by Ma Jun's avatar Ma Jun Committed by Alex Deucher

drm/amd: Fix the flag setting code for interrupt request

[1] Remove the irq flags setting code since pci_alloc_irq_vectors()
handles these flags.
[2] Free the msi vectors in case of error.
Signed-off-by: default avatarMa Jun <Jun.Ma2@amd.com>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent dbb80521
...@@ -270,30 +270,30 @@ static void amdgpu_restore_msix(struct amdgpu_device *adev) ...@@ -270,30 +270,30 @@ static void amdgpu_restore_msix(struct amdgpu_device *adev)
*/ */
int amdgpu_irq_init(struct amdgpu_device *adev) int amdgpu_irq_init(struct amdgpu_device *adev)
{ {
int r = 0; unsigned int irq, flags;
unsigned int irq; int r;
spin_lock_init(&adev->irq.lock); spin_lock_init(&adev->irq.lock);
/* Enable MSI if not disabled by module parameter */ /* Enable MSI if not disabled by module parameter */
adev->irq.msi_enabled = false; adev->irq.msi_enabled = false;
if (amdgpu_msi_ok(adev)) { if (!amdgpu_msi_ok(adev))
int nvec = pci_msix_vec_count(adev->pdev); flags = PCI_IRQ_LEGACY;
unsigned int flags;
if (nvec <= 0)
flags = PCI_IRQ_MSI;
else else
flags = PCI_IRQ_MSI | PCI_IRQ_MSIX; flags = PCI_IRQ_ALL_TYPES;
/* we only need one vector */ /* we only need one vector */
nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, flags); r = pci_alloc_irq_vectors(adev->pdev, 1, 1, flags);
if (nvec > 0) { if (r < 0) {
dev_err(adev->dev, "Failed to alloc msi vectors\n");
return r;
}
if (amdgpu_msi_ok(adev)) {
adev->irq.msi_enabled = true; adev->irq.msi_enabled = true;
dev_dbg(adev->dev, "using MSI/MSI-X.\n"); dev_dbg(adev->dev, "using MSI/MSI-X.\n");
} }
}
INIT_WORK(&adev->irq.ih1_work, amdgpu_irq_handle_ih1); INIT_WORK(&adev->irq.ih1_work, amdgpu_irq_handle_ih1);
INIT_WORK(&adev->irq.ih2_work, amdgpu_irq_handle_ih2); INIT_WORK(&adev->irq.ih2_work, amdgpu_irq_handle_ih2);
...@@ -302,22 +302,29 @@ int amdgpu_irq_init(struct amdgpu_device *adev) ...@@ -302,22 +302,29 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
/* Use vector 0 for MSI-X. */ /* Use vector 0 for MSI-X. */
r = pci_irq_vector(adev->pdev, 0); r = pci_irq_vector(adev->pdev, 0);
if (r < 0) if (r < 0)
return r; goto free_vectors;
irq = r; irq = r;
/* PCI devices require shared interrupts. */ /* PCI devices require shared interrupts. */
r = request_irq(irq, amdgpu_irq_handler, IRQF_SHARED, adev_to_drm(adev)->driver->name, r = request_irq(irq, amdgpu_irq_handler, IRQF_SHARED, adev_to_drm(adev)->driver->name,
adev_to_drm(adev)); adev_to_drm(adev));
if (r) if (r)
return r; goto free_vectors;
adev->irq.installed = true; adev->irq.installed = true;
adev->irq.irq = irq; adev->irq.irq = irq;
adev_to_drm(adev)->max_vblank_count = 0x00ffffff; adev_to_drm(adev)->max_vblank_count = 0x00ffffff;
DRM_DEBUG("amdgpu: irq initialized.\n"); DRM_DEBUG("amdgpu: irq initialized.\n");
return 0; return 0;
}
free_vectors:
if (adev->irq.msi_enabled)
pci_free_irq_vectors(adev->pdev);
adev->irq.msi_enabled = false;
return r;
}
void amdgpu_irq_fini_hw(struct amdgpu_device *adev) void amdgpu_irq_fini_hw(struct amdgpu_device *adev)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment