drm/amdgpu: use PCI_IRQ_MSI_TYPES where appropriate
Subsystems (2)
PATCH 7/15 drm/amdgpu: use PCI_IRQ_MSI_TYPES where appropriate
Seeing as there is shorthand available to use when asking for any type of interrupt, or any type of message signalled interrupt, leverage it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +4 -4
@@ -251,11 +251,11 @@ int amdgpu_irq_init(struct amdgpu_device *adev)int nvec =pci_msix_vec_count (adev->pdev);unsigned int flags; -if (nvec <=0 ) { +if (nvec >0 ) + flags =PCI_IRQ_MSI_TYPES ; +else flags =PCI_IRQ_MSI ; - }else { - flags =PCI_IRQ_MSI |PCI_IRQ_MSIX ; - } +/* we only need one vector */ nvec =pci_alloc_irq_vectors (adev->pdev,1 ,1 , flags);if (nvec >0 ) {
Signature · 1 line
2.17.2
Quoted 19 lines · Piotr Stankiewicz
Seeing as there is shorthand available to use when asking for any type of interrupt, or any type of message signalled interrupt, leverage it.
Signed-off-by Piotr Stankiewicz <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +0
-1@@ -251,11 +251,11 @@ int amdgpu_irq_init(struct amdgpu_device *adev)int nvec =pci_msix_vec_count (adev->pdev);unsigned int flags; -if (nvec <=0 ) {
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c int amdgpu_irq_init(struct amdgpu_device *adev) · line 260
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +4
-3+if (nvec >0 ) + flags =PCI_IRQ_MSI_TYPES ; +else flags =PCI_IRQ_MSI ; - }else { - flags =PCI_IRQ_MSI |PCI_IRQ_MSIX ; - } +/* we only need one vector */ nvec =pci_alloc_irq_vectors (adev->pdev,1 ,1 , flags);
I'm not sure if you have seen my last comment internally about this patch.
I don't understand why we need these pci_msix_vec_count() followed by conditional at all.
Perhaps we may simple drop all these and supply flag directly?
But OTOH, I don't know the initial motivation, so, the above patch is non-intrusive and keeps original logic.
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +0
-1if (nvec >0 ) { --2.17.2
Signature · 6 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 47 lines
-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Tuesday, June 2, 2020 11:49 AM
To: Stankiewicz, Piotr <[email protected]>
Cc: Alex Deucher <[email protected]>; Christian König <[email protected]>; David Zhou <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; amd- [email protected]; dri-devel <[email protected]>; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH 07/15] drm/amdgpu: usePCI_IRQ_MSI_TYPESwhere appropriateReview
Quoted 11 lines · Piotr Stankiewicz
Seeing as there is shorthand available to use when asking for any type of interrupt, or any type of message signalled interrupt, leverage it.
Signed-off-by Piotr Stankiewicz <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.cQuoted 8 lines
index
5ed4227f304b..6dbe173a9fd4100644drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +0
-1@@ -251,11 +251,11 @@ int amdgpu_irq_init(struct amdgpu_device *adev)int nvec =pci_msix_vec_count (adev->pdev);unsigned int flags; -if (nvec <=0 ) {drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c int amdgpu_irq_init(struct amdgpu_device *adev) · line 260
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +4
-3+if (nvec >0 ) + flags =PCI_IRQ_MSI_TYPES ; +else flags =PCI_IRQ_MSI ; - }else { - flags =PCI_IRQ_MSI |PCI_IRQ_MSIX ; - } +/* we only need one vector */ nvec =pci_alloc_irq_vectors (adev->pdev,1 ,1 , flags);I'm not sure if you have seen my last comment internally about this patch.
Quoted 7 lines
I don't understand why we need these
pci_msix_vec_count()followed by conditional at all.
Perhaps we may simple drop all these and supply flag directly?But OTOH, I don't know the initial motivation, so, the above patch is non-intrusive and keeps original logic.
Sorry, I must have misunderstood or missed that comment. I am happy to do a V2 if dropping the conditional is preferable.
Quoted 9 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +0
-1if (nvec >0 ) { --2.17.2
--
With Best Regards,
Andy Shevchenko
BR,
Piotr Stankiewicz
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 13 lines · Piotr
Quoted 13 lines
-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Tuesday, June 2, 2020 11:49 AM
To: Stankiewicz, Piotr <[email protected]>
Cc: Alex Deucher <[email protected]>; Christian König <[email protected]>; David Zhou <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; amd- [email protected]; dri-devel <[email protected]>; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH 07/15] drm/amdgpu: usePCI_IRQ_MSI_TYPESwhere appropriate
On Tue, Jun 2, 2020 at 12:24 PM Piotr Stankiewicz <[email protected]> wrote:
...
Quoted 21 lines
Quoted 21 lines
Quoted 4 lines
int nvec = pci_msix_vec_count(adev->pdev); unsigned int flags;drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +0
-1-if (nvec <=0 ) {drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c int amdgpu_irq_init(struct amdgpu_device *adev) · line 260
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +4
-3+if (nvec >0 ) + flags =PCI_IRQ_MSI_TYPES ; +else flags =PCI_IRQ_MSI ; - }else { - flags =PCI_IRQ_MSI |PCI_IRQ_MSIX ; - } +/* we only need one vector */ nvec =pci_alloc_irq_vectors (adev->pdev,1 ,1 , flags);I'm not sure if you have seen my last comment internally about this patch.
I don't understand why we need these
pci_msix_vec_count()followed by conditional at all.
Perhaps we may simple drop all these and supply flag directly?
Quoted 6 lines
Quoted 3 lines
But OTOH, I don't know the initial motivation, so, the above patch is non-intrusive and keeps original logic.
Sorry, I must have misunderstood or missed that comment. I am happy to do a V2 if dropping the conditional is preferable.
Let's wait for AMD people to confirm either.
Signature · 6 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 29 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Piotr Stankiewicz
Sent: Tuesday, June 2, 2020 5:21 AM
To: Alex Deucher <[email protected]>; Christian König <[email protected]>; David Zhou <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>
Cc: Stankiewicz, Piotr <[email protected]>; dri- [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH 07/15] drm/amdgpu: usePCI_IRQ_MSI_TYPESwhere appropriateSeeing as there is shorthand available to use when asking for any type of interrupt, or any type of message signalled interrupt, leverage it.
Signed-off-by Piotr Stankiewicz <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c| 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +0
-0@@ -251,11 +251,11 @@ int amdgpu_irq_init(struct amdgpu_device *adev)int nvec =pci_msix_vec_count (adev->pdev);
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c int amdgpu_irq_init(struct amdgpu_device *adev) · line 258
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +3
-4unsigned int flags; -if (nvec <=0 ) { +if (nvec >0 ) + flags =PCI_IRQ_MSI_TYPES ; +else flags =PCI_IRQ_MSI ; - }else { - flags =PCI_IRQ_MSI |PCI_IRQ_MSIX ; - }
Minor nit:
Is it really necessary to set do this check? Can flags just be set?
I.e.:
flags = PCI_IRQ_MSI_TYPES;
pci_alloc_irq_vector() tries stuff in order. If MSIX is not available, it will try MSI.
M
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +1
-1+/* we only need one vector */ nvec =pci_alloc_irq_vectors (adev->pdev,1 ,1 , flags);if (nvec >0 ) { --2.17.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 12 lines · Michael J
Quoted 12 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Piotr Stankiewicz
Sent: Tuesday, June 2, 2020 5:21 AM
To: Alex Deucher <[email protected]>; Christian König <[email protected]>; David Zhou <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>
Cc: Stankiewicz, Piotr <[email protected]>; dri- [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH 07/15] drm/amdgpu: usePCI_IRQ_MSI_TYPESwhere appropriate
...
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c int amdgpu_irq_init(struct amdgpu_device *adev) · line 258
Quoted 11 lines
int nvec = pci_msix_vec_count(adev->pdev); unsigned int flags;drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +3
-4-if (nvec <=0 ) { +if (nvec >0 ) + flags =PCI_IRQ_MSI_TYPES ; +else flags =PCI_IRQ_MSI ; - }else { - flags =PCI_IRQ_MSI |PCI_IRQ_MSIX ; - }Minor nit:
Quoted 8 lines
Is it really necessary to set do this check? Can flags just be set?
I.e.:
flags = PCI_IRQ_MSI_TYPES;
pci_alloc_irq_vector()tries stuff in order. If MSIX is not available, it will try MSI.
That's also what I proposed earlier. But I suggested as well to wait for AMD people to confirm that neither pci_msix_vec_count() nor flags is needed and we can directly supply MSI_TYPES to the below call.
Quoted 2 lines
Quoted 2 lines
/* we only need one vector */ nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, flags);
Signature · 6 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 37 lines · Andy Shevchenko
Quoted 12 lines · Michael J
Quoted 12 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Piotr Stankiewicz
Sent: Tuesday, June 2, 2020 5:21 AM
To: Alex Deucher <[email protected]>; Christian König <[email protected]>; David Zhou <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>
Cc: Stankiewicz, Piotr <[email protected]>; dri- [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH 07/15] drm/amdgpu: usePCI_IRQ_MSI_TYPESwhere appropriate...
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c int amdgpu_irq_init(struct amdgpu_device *adev) · line 258
Quoted 11 lines
int nvec = pci_msix_vec_count(adev->pdev); unsigned int flags;drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +3
-4-if (nvec <=0 ) { +if (nvec >0 ) + flags =PCI_IRQ_MSI_TYPES ; +else flags =PCI_IRQ_MSI ; - }else { - flags =PCI_IRQ_MSI |PCI_IRQ_MSIX ; - }Minor nit:
Is it really necessary to set do this check? Can flags just be set?
I.e.:
flags = PCI_IRQ_MSI_TYPES;
Quoted 7 lines
Quoted 2 lines
pci_alloc_irq_vector()tries stuff in order. If MSIX is not available, it will try MSI.That's also what I proposed earlier. But I suggested as well to wait for AMD people to confirm that neither
pci_msix_vec_count()nor flags is needed and we can directly supplyMSI_TYPESto the below call.
I think it was leftover from debugging and just to be careful. We had some issues when we originally enabled MSI-X on certain boards. The fix was to just allocate a single vector (since that is all we use anyway) and we were using the wrong irq (pdev->irq vs pci_irq_vector(pdev, 0)). For reference, the original patch to add MSI-X:
commit bd660f4f111161f60392dd02424c3a3d2240dc2f
Author: shaoyunl <[email protected]> Date: Tue Oct 1 15:52:31 2019 -0400
drm/amdgpu : enable msix for amdgpu driver
We might used out of the msi resources in some cloud project which have a lot gpu devices(including PF and VF), msix can provide enough resources from system level view
And the fix:
commit 8a745c7ff2ddb8511ef760b4d9cb4cf56a15fc8d
Author: Alex Deucher <[email protected]> Date: Thu Oct 3 10:34:30 2019 -0500
drm/amdgpu: improve MSI-X handling (v3)
Check the number of supported vectors and fall back to MSI if we return or error or 0 MSI-X vectors.
v2: only allocate one vector. We can't currently use more than one anyway.
v3: install the irq on vector 0.
Alex
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 34 lines · Alex Deucher
Quoted 24 lines · Andy Shevchenko
Quoted 23 lines · Michael J
Quoted 6 lines
From: dri-devel <[email protected]> On Behalf Of Piotr Stankiewicz
int nvec = pci_msix_vec_count(adev->pdev); unsigned int flags;drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c int amdgpu_irq_init(struct amdgpu_device *adev) · line 258
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +3
-4-if (nvec <=0 ) { +if (nvec >0 ) + flags =PCI_IRQ_MSI_TYPES ; +else flags =PCI_IRQ_MSI ; - }else { - flags =PCI_IRQ_MSI |PCI_IRQ_MSIX ; - }Minor nit:
Is it really necessary to set do this check? Can flags just be set?
I.e.:
flags = PCI_IRQ_MSI_TYPES;Quoted 7 lines
Quoted 2 lines
pci_alloc_irq_vector()tries stuff in order. If MSIX is not available, it will try MSI.That's also what I proposed earlier. But I suggested as well to wait for AMD people to confirm that neither
pci_msix_vec_count()nor flags is needed and we can directly supplyMSI_TYPESto the below call.
Quoted 5 lines
I think it was leftover from debugging and just to be careful. We had some issues when we originally enabled MSI-X on certain boards. The fix was to just allocate a single vector (since that is all we use anyway) and we were using the wrong irq (
pdev->irqvspci_irq_vector(pdev, 0)).
Do you agree that simple
nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, PCI_IRQ_MSI_TYPES);
will work and we can remove that leftover?
Signature · 6 lines
With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 42 lines · Andy Shevchenko
Quoted 34 lines · Alex Deucher
Quoted 24 lines · Andy Shevchenko
Quoted 23 lines · Michael J
Quoted 6 lines
From: dri-devel <[email protected]> On Behalf Of Piotr Stankiewicz
int nvec = pci_msix_vec_count(adev->pdev); unsigned int flags;Review
Quoted 8 lines
(quoted diff) +3
-4- if (nvec <= 0) { + if (nvec > 0) + flags = PCI_IRQ_MSI_TYPES; + else flags = PCI_IRQ_MSI; - } else { - flags = PCI_IRQ_MSI | PCI_IRQ_MSIX; - }Minor nit:
Is it really necessary to set do this check? Can flags just be set?
I.e.:
flags = PCI_IRQ_MSI_TYPES;Quoted 7 lines
Quoted 2 lines
pci_alloc_irq_vector()tries stuff in order. If MSIX is not available, it will try MSI.That's also what I proposed earlier. But I suggested as well to wait for AMD people to confirm that neither
pci_msix_vec_count()nor flags is needed and we can directly supplyMSI_TYPESto the below call.Quoted 5 lines
I think it was leftover from debugging and just to be careful. We had some issues when we originally enabled MSI-X on certain boards. The fix was to just allocate a single vector (since that is all we use anyway) and we were using the wrong irq (
pdev->irqvspci_irq_vector(pdev, 0)).
Quoted 5 lines
Do you agree that simple
nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, PCI_IRQ_MSI_TYPES);will work and we can remove that leftover?
Yes, I believe so. Tom, can you give this a quick spin on raven just in case if you get a chance? Something like this:
(quoted diff) +0 -0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 0cc4c67f95f7..c59111b57cc2 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +2 -8
@@ -248,16 +248,10 @@ int amdgpu_irq_init(struct amdgpu_device *adev) adev->irq.msi_enabled = false;if (amdgpu_msi_ok (adev)) { -int nvec =pci_msix_vec_count (adev->pdev); -unsigned int flags; +int nvec; -if (nvec <=0 ) { - flags =PCI_IRQ_MSI ; - }else { - flags =PCI_IRQ_MSI |PCI_IRQ_MSIX ; - }/* we only need one vector */ - nvec =pci_alloc_irq_vectors (adev->pdev,1 ,1 , flags); + nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1,
PCI_IRQ_MSI | PCI_IRQ_MSIX);
if (nvec > 0) {
adev->irq.msi_enabled = true;
dev_dbg(adev->dev, "using MSI/MSI-X.\n");Thanks,
Alex