Limit AMD Radeon rebar hack to a single revision
Subsystems (2)
PATCH 1/1 Limit AMD Radeon rebar hack to a single revision
A particular RX 5600 device requires a hack in the rebar logic, but the current branch is too general and catches other devices too, breaking them. This patch changes the branch to be more selective on the particular revision.
See also: https://gitlab.freedesktop.org/drm/amd/-/issues/1707
This patch fixes intermittent freezes on other RX 5600 devices where the hack is unnecessary. Credit to all contributors in the linked issue on the AMD bug tracker.
--- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci.c +1 -1
@@ -3647,7 +3647,7 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)/* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */ if (pdev->vendor ==PCI_VENDOR_ID_ATI && pdev->device ==0x731f && - bar ==0 && cap ==0x7000 ) + pdev->revision ==0xC1 && bar ==0 && cap ==0x7000 ) cap =0x3f000 ;return cap >>4 ;
Signature · 1 line
2.31.1
[+cc Christian, Nirmoy, authors of 907830b0fc9e]
Subject line should look like previous ones for this file, e.g.,
88769e64cf99 ("PCI: Add ACS quirk for Pericom PI7C9X2G switches") e3f4bd3462f6 ("PCI: Mark Atheros QCA6174 to avoid bus reset") 60b78ed088eb ("PCI: Add AMD GPU multi-function power dependencies") 8304a3a199ee ("PCI: Set dma-can-stall for HiSilicon chips") 8c09e896cef8 ("PCI: Allow PASID on fake PCIe devices without TLP prefixes") 32837d8a8f63 ("PCI: Add ACS quirks for Cavium multi-function devices") e0bff4322092 ("PCI: Increase D3 delay for AMD Renoir/Cezanne XHCI")
...
907830b0fc9e ("PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse")
Would be good to mention "Sapphire RX 5600 XT Pulse" explicitly since that's what 907830b0fc9e said.
Quoted 6 lines · Robin McCorkell
A particular RX 5600 device requires a hack in the rebar logic, but the current branch is too general and catches other devices too, breaking them. This patch changes the branch to be more selective on the particular revision.
See also: https://gitlab.freedesktop.org/drm/amd/-/issues/1707
There's a lot of legwork in the bug report to bisect this, but no explanation of what the root cause turned out to be.
907830b0fc9e says RX 5600 XT Pulse advertises 256MB-1GB BAR 0 sizes but actually supports up to 8GB.
Does this patch mean your RX 5600 XT Pulse supports fewer sizes and advertises them correctly? And consequently we resize BAR 0 to something that's too big, and something fails when we try to access the part the isn't actually implemented by the device?
It would be useful to attach your "lspci -vv" output to the bug report.
Quoted 3 lines
This patch fixes intermittent freezes on other RX 5600 devices where the hack is unnecessary. Credit to all contributors in the linked issue on the AMD bug tracker.
Thanks. This would need a signed-off-by [1].
We should also include a "Fixes:" line for the commit the problem was bisected to, 907830b0fc9e ("PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse"), if I understand correctly, e.g.,
And probably a stable tag, since 907830b0fc9e appeared in v5.12, e.g.,
If stable maintainers backported 907830b0fc9e to earlier kernels, as it appears they have, it's up to them to watch for fixes to 907830b0fc9e.
Quoted 9 lines
--- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci.c +0
-0
drivers/pci/pci.c u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar) · line 3650
Quoted 5 lines
drivers/pci/pci.c +1
-1@@ -3647,7 +3647,7 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)/* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */ if (pdev->vendor ==PCI_VENDOR_ID_ATI && pdev->device ==0x731f && - bar ==0 && cap ==0x7000 ) + pdev->revision ==0xC1 && bar ==0 && cap ==0x7000 )
I'd like to get the AMD folks to chime in and confirm that revision 0xC1 is the only one that requires this quirk.
Quoted 6 lines
drivers/pci/pci.c +0
-0cap =0x3f000 ;return cap >>4 ;Signature · 1 line
2.31.1
PATCH v2 1/1 PCI: Limit REBAR quirk to just Sapphire RX 5600 XT Pulse
A particular RX 5600 device requires a hack in the rebar logic, but the current branch is too general and catches other devices too, breaking them. This patch changes the branch to be more selective on the particular revision.
This patch fixes intermittent freezes on other RX 5600 devices where the hack is unnecessary. Credit to all contributors in the linked issue on the AMD bug tracker.
See also: https://gitlab.freedesktop.org/drm/amd/-/issues/1707
--- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci.c +1 -1
@@ -3647,7 +3647,7 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)/* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */ if (pdev->vendor ==PCI_VENDOR_ID_ATI && pdev->device ==0x731f && - bar ==0 && cap ==0x7000 ) + pdev->revision ==0xC1 && bar ==0 && cap ==0x7000 ) cap =0x3f000 ;return cap >>4 ;
Signature · 1 line
2.31.1
Re: [PATCH v2] PCI: Limit REBAR quirk to just Sapphire RX 5600 XT Pulse
[+CC adding Bjorn as the PCI sub-system maintainer]
Hi Robin,
Thank you for sending the patch over!
Quoted 10 lines
A particular RX 5600 device requires a hack in the rebar logic, but the current branch is too general and catches other devices too, breaking them. This patch changes the branch to be more selective on the particular revision.
This patch fixes intermittent freezes on other RX 5600 devices where the hack is unnecessary. Credit to all contributors in the linked issue on the AMD bug tracker.
See also: https://gitlab.freedesktop.org/drm/amd/-/issues/1707
[...]
The commit message could be improved a little bit so that it's more in preferred imperative tone describing what precisely is broken and how it fixes the problem for Sapphire RX 5600 XT and other ATI cards. Also, consistent capitalisation of "REBAR" between the subject and the commit message would be a plus.
There is also no need to add "this patch" - we also know that this is this very patch, especially since this isn't a series that comprises of multiple other patches.
Also, sine this is a v2, it would be nice to include a small changelog, even if the change is trivial, with helps as people don't have to go and read other e-mail threads to find out what was changed and why.
Quoted 4 lines
Reported-by Simon May <@Socob on gitlab.freedesktop.com>Tested-by Kain Centeno <@kaincenteno on gitlab.freedesktop.com>Tested-by Tobias Jakobi <@tobiasjakobi on gitlab.freedesktop.com>Suggested-by lijo lazar <@lijo on gitlab.freedesktop.com>
The above would be "gitlab.freedesktop.org", I believe. Having said that, I am not sure if we can accept username handles to some remote Git hosting platform in lieu of proper, so to speak, e-mail addresses.
[...]
drivers/pci/pci.c u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar) · line 3650
Quoted 4 lines
drivers/pci/pci.c +1
-1/* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */ if (pdev->vendor ==PCI_VENDOR_ID_ATI && pdev->device ==0x731f && - bar ==0 && cap ==0x7000 ) + pdev->revision ==0xC1 && bar ==0 && cap ==0x7000 )
A small nitpick: lowercase hexadecimal values to match how it's been used in other places.
Krzysztof
Re: [PATCH v2] PCI: Limit REBAR quirk to just Sapphire RX 5600 XT Pulse
In reply to Robin McCorkell[+cc Christian, Nirmoy]
Quoted 11 lines · Robin McCorkell
A particular RX 5600 device requires a hack in the rebar logic, but the current branch is too general and catches other devices too, breaking them. This patch changes the branch to be more selective on the particular revision.
This patch fixes intermittent freezes on other RX 5600 devices where the hack is unnecessary. Credit to all contributors in the linked issue on the AMD bug tracker.
See also: https://gitlab.freedesktop.org/drm/amd/-/issues/1707
Quoted 7 lines
Fixes 907830b0fc9e ("PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse")Cc [email protected] # v5.12+Signed-off-by Robin McCorkell <[email protected]>Reported-by Simon May <@Socob on gitlab.freedesktop.com>Tested-by Kain Centeno <@kaincenteno on gitlab.freedesktop.com>Tested-by Tobias Jakobi <@tobiasjakobi on gitlab.freedesktop.com>Suggested-by lijo lazar <@lijo on gitlab.freedesktop.com>
I'll wait for an ack from Christian on this one, since it doesn't seem to make sense to him.
Quoted 20 lines
--- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci.c +1
-1@@ -3647,7 +3647,7 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)/* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */ if (pdev->vendor ==PCI_VENDOR_ID_ATI && pdev->device ==0x731f && - bar ==0 && cap ==0x7000 ) + pdev->revision ==0xC1 && bar ==0 && cap ==0x7000 ) cap =0x3f000 ;return cap >>4 ;Signature · 1 line
2.31.1
Re: [PATCH v2] PCI: Limit REBAR quirk to just Sapphire RX 5600 XT Pulse
Am 01.11.21 um 22:55 schrieb Bjorn Helgaas:
Quoted 21 lines
[+cc Christian, Nirmoy]
Quoted 11 lines · Robin McCorkell
A particular RX 5600 device requires a hack in the rebar logic, but the current branch is too general and catches other devices too, breaking them. This patch changes the branch to be more selective on the particular revision.
This patch fixes intermittent freezes on other RX 5600 devices where the hack is unnecessary. Credit to all contributors in the linked issue on the AMD bug tracker.
Quoted 7 lines
Fixes 907830b0fc9e ("PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse")Cc [email protected] # v5.12+Signed-off-by Robin McCorkell <[email protected]>Reported-by Simon May <@Socob on gitlab.freedesktop.com>Tested-by Kain Centeno <@kaincenteno on gitlab.freedesktop.com>Tested-by Tobias Jakobi <@tobiasjakobi on gitlab.freedesktop.com>Suggested-by lijo lazar <@lijo on gitlab.freedesktop.com>
Quoted 2 lines
I'll wait for an ack from Christian on this one, since it doesn't seem to make sense to him.
Please just completely drop the patch for now.
It's really interesting that resizing the BAR makes the problem on that hardware more likely to appear, but we have already found people reporting issues even with the patch in question completely reverted.
So that is most likely not the root cause and we need to dig deeper.
Thanks,
Christian.
Quoted 21 lines
Quoted 21 lines
--- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci.c +1
-1@@ -3647,7 +3647,7 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)/* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */ if (pdev->vendor ==PCI_VENDOR_ID_ATI && pdev->device ==0x731f && - bar ==0 && cap ==0x7000 ) + pdev->revision ==0xC1 && bar ==0 && cap ==0x7000 ) cap =0x3f000 ;return cap >>4 ;Signature · 1 line
2.31.1
Thanks, v2 posted with the commit message fixes and correct tagging.
My device isn't a Sapphire RX 5600 XT Pulse, it's an RX 5600M and OEM as far as I can tell. The condition in the original code was too broad and was catching devices like mine (or the devices of the other bug participants) where the hack was breaking things.
Quoted 86 lines · Bjorn Helgaas
[+cc Christian, Nirmoy, authors of
907830b0fc9e]Subject line should look like previous ones for this file, e.g.,
88769e64cf99("PCI: Add ACS quirk for Pericom PI7C9X2G switches")e3f4bd3462f6("PCI: Mark Atheros QCA6174 to avoid bus reset")60b78ed088eb("PCI: Add AMD GPU multi-function power dependencies")8304a3a199ee("PCI: Set dma-can-stall for HiSilicon chips")8c09e896cef8("PCI: Allow PASID on fake PCIe devices without TLP prefixes")32837d8a8f63("PCI: Add ACS quirks for Cavium multi-function devices")e0bff4322092("PCI: Increase D3 delay for AMD Renoir/Cezanne XHCI")
...
907830b0fc9e("PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse")Would be good to mention "Sapphire RX 5600 XT Pulse" explicitly since that's what
907830b0fc9esaid.Quoted 6 lines · Robin McCorkell
A particular RX 5600 device requires a hack in the rebar logic, but the current branch is too general and catches other devices too, breaking them. This patch changes the branch to be more selective on the particular revision.
See also: https://gitlab.freedesktop.org/drm/amd/-/issues/1707
There's a lot of legwork in the bug report to bisect this, but no explanation of what the root cause turned out to be.
907830b0fc9esays RX 5600 XT Pulse advertises 256MB-1GB BAR 0 sizes but actually supports up to 8GB.Does this patch mean your RX 5600 XT Pulse supports fewer sizes and advertises them correctly? And consequently we resize BAR 0 to something that's too big, and something fails when we try to access the part the isn't actually implemented by the device?
It would be useful to attach your "lspci -vv" output to the bug report.
Quoted 3 lines
This patch fixes intermittent freezes on other RX 5600 devices where the hack is unnecessary. Credit to all contributors in the linked issue on the AMD bug tracker.
Thanks. This would need a signed-off-by [1].
We should also include a "Fixes:" line for the commit the problem was bisected to,
907830b0fc9e("PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse"), if I understand correctly, e.g.,Fixes 907830b0fc9e ("PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse")And probably a stable tag, since
907830b0fc9eappeared in v5.12, e.g.,Cc [email protected] # v5.12+If stable maintainers backported
907830b0fc9eto earlier kernels, as it appears they have, it's up to them to watch for fixes to907830b0fc9e.Quoted 9 lines
--- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci.c +0
-0drivers/pci/pci.c u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar) · line 3650
Quoted 5 lines
drivers/pci/pci.c +1
-1@@ -3647,7 +3647,7 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)/* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */ if (pdev->vendor ==PCI_VENDOR_ID_ATI && pdev->device ==0x731f && - bar ==0 && cap ==0x7000 ) + pdev->revision ==0xC1 && bar ==0 && cap ==0x7000 )I'd like to get the AMD folks to chime in and confirm that revision
0xC1is the only one that requires this quirk.Quoted 6 lines
drivers/pci/pci.c +0
-1cap =0x3f000 ;return cap >>4 ; --2.31.1
Hi Robin and Bjorn,
Am 26.10.21 um 23:49 schrieb Robin McCorkell:
Quoted 6 lines
Thanks, v2 posted with the commit message fixes and correct tagging.
My device isn't a Sapphire RX 5600 XT Pulse, it's an RX 5600M and OEM as far as I can tell. The condition in the original code was too broad and was catching devices like mine (or the devices of the other bug participants) where the hack was breaking things.
well that doesn't really make sense. As far as I know the problem is an invalid PCIe config space on the whole series of the ASIC, but I can double check with the hardware engineers once more.
What could be is that a later hardware revision doesn't have that bug any more and we don't need to apply the workaround. That is trivial to confirm with an verbose lspci output, but even then the workaround won't hurt in any way.
Quoted 19 lines · Bjorn Helgaas
Quoted 18 lines
[+cc Christian, Nirmoy, authors of
907830b0fc9e]Subject line should look like previous ones for this file, e.g.,
88769e64cf99("PCI: Add ACS quirk for Pericom PI7C9X2G switches")e3f4bd3462f6("PCI: Mark Atheros QCA6174 to avoid bus reset")60b78ed088eb("PCI: Add AMD GPU multi-function power dependencies")8304a3a199ee("PCI: Set dma-can-stall for HiSilicon chips")8c09e896cef8("PCI: Allow PASID on fake PCIe devices without TLP prefixes")32837d8a8f63("PCI: Add ACS quirks for Cavium multi-function devices")e0bff4322092("PCI: Increase D3 delay for AMD Renoir/Cezanne XHCI")
...
907830b0fc9e("PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse")Would be good to mention "Sapphire RX 5600 XT Pulse" explicitly since that's what
907830b0fc9esaid.On Tue, Oct 26, 2021 at 09:46:38PM +0100, Robin McCorkell wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
A particular RX 5600 device requires a hack in the rebar logic, but the current branch is too general and catches other devices too, breaking them. This patch changes the branch to be more selective on the particular revision.
There's a lot of legwork in the bug report to bisect this, but no explanation of what the root cause turned out to be.
Yes agree, that bisection is extremely unlikely to be correct.
See the driver allocates addresses from both ends of the BAR and works towards the middle.
So if something doesn't work correctly we see that immediately because the driver isn't even able to initialize the hardware.
What could be is that resizing the BAR reduces the overhead drastically. Resulting in some use cases to have a 10-20% performance benefit. When we have a timing bug somewhere else the patch could potentially make that much more likely to be seen.
Going to comment on the bug report as well.
Quoted 7 lines
Quoted 7 lines
907830b0fc9esays RX 5600 XT Pulse advertises 256MB-1GB BAR 0 sizes but actually supports up to 8GB.Does this patch mean your RX 5600 XT Pulse supports fewer sizes and advertises them correctly? And consequently we resize BAR 0 to something that's too big, and something fails when we try to access the part the isn't actually implemented by the device?
We do have devices which have a non power of two local memory, e.g. 3GiB or 6GiB. In those cases we resize the BAR to the next power of two and that still works.
Quoted 15 lines
Quoted 15 lines
It would be useful to attach your "lspci -vv" output to the bug report.
Quoted 3 lines
This patch fixes intermittent freezes on other RX 5600 devices where the hack is unnecessary. Credit to all contributors in the linked issue on the AMD bug tracker.
Thanks. This would need a signed-off-by [1].
We should also include a "Fixes:" line for the commit the problem was bisected to,
907830b0fc9e("PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse"), if I understand correctly, e.g.,Fixes 907830b0fc9e ("PCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse")
Quoted 7 lines
Quoted 7 lines
And probably a stable tag, since
907830b0fc9eappeared in v5.12, e.g.,Cc: [email protected] # v5.12+If stable maintainers backported
907830b0fc9eto earlier kernels, as it appears they have, it's up to them to watch for fixes to907830b0fc9e.
What would be very helpful as well is to CC the relevant AMD engineers which wrote the original patch and signed it off.
Regards,
Christian.
Quoted 26 lines
Quoted 26 lines
Quoted 9 lines
--- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci.c +0
-0drivers/pci/pci.c u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar) · line 3650
Quoted 5 lines
drivers/pci/pci.c +1
-1@@ -3647,7 +3647,7 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)/* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */ if (pdev->vendor ==PCI_VENDOR_ID_ATI && pdev->device ==0x731f && - bar ==0 && cap ==0x7000 ) + pdev->revision ==0xC1 && bar ==0 && cap ==0x7000 )I'd like to get the AMD folks to chime in and confirm that revision
0xC1is the only one that requires this quirk.Quoted 6 lines
drivers/pci/pci.c +0
-1cap =0x3f000 ;return cap >>4 ; --2.31.1