[SeaBIOS] [RESEND PATCH] fw/pciinit: don't misalign large BARs

Daniil Tatianin posted 1 patch 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/seabios tags/patchew/20240411195135.181615-1-d-tatianin@yandex-team.ru
src/fw/pciinit.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[SeaBIOS] [RESEND PATCH] fw/pciinit: don't misalign large BARs
Posted by Daniil Tatianin 6 months ago
Previously we would unconditionally lower the alignment for large BARs
in case their alignment was greater than "pci_mem64_top >> 11", this
would make it impossible to use these devices by the kernel:
    [   13.821108] pci 0000:9c:00.0: can't claim BAR 1 [mem 0x66000000000-0x67fffffffff 64bit pref]: no compatible bridge window
    [   13.823492] pci 0000:9d:00.0: can't claim BAR 1 [mem 0x64000000000-0x65fffffffff 64bit pref]: no compatible bridge window
    [   13.824218] pci 0000:9e:00.0: can't claim BAR 1 [mem 0x62000000000-0x63fffffffff 64bit pref]: no compatible bridge window
    [   13.828322] pci 0000:8a:00.0: can't claim BAR 1 [mem 0x6e000000000-0x6ffffffffff 64bit pref]: no compatible bridge window
    [   13.830691] pci 0000:8b:00.0: can't claim BAR 1 [mem 0x6c000000000-0x6dfffffffff 64bit pref]: no compatible bridge window
    [   13.832218] pci 0000:8c:00.0: can't claim BAR 1 [mem 0x6a000000000-0x6bfffffffff 64bit pref]: no compatible bridge window

Fix it by only overwriting the alignment in case it's actually greater
than the desired by the BAR window.

Fixes: 96a8d130a8c ("be less conservative with the 64bit pci io window")
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
---
 src/fw/pciinit.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
index 6b13cd5b..bb44dc29 100644
--- a/src/fw/pciinit.c
+++ b/src/fw/pciinit.c
@@ -970,9 +970,11 @@ static int pci_bios_check_devices(struct pci_bus *busses)
             int resource_optional = 0;
             if (hotplug_support == HOTPLUG_PCIE)
                 resource_optional = pcie_cap && (type == PCI_REGION_TYPE_IO);
+
+            u64 top_align = pci_mem64_top >> 11;
             if (hotplug_support && pci_pad_mem64 && is64
-                && (type == PCI_REGION_TYPE_PREFMEM))
-                align = pci_mem64_top >> 11;
+                && (type == PCI_REGION_TYPE_PREFMEM) && (top_align > align))
+                align = top_align;
             if (align > sum && hotplug_support && !resource_optional)
                 sum = align; /* reserve min size for hot-plug */
             if (size > sum) {
-- 
2.34.1

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [RESEND PATCH] fw/pciinit: don't misalign large BARs
Posted by Kevin O'Connor 5 months, 4 weeks ago
On Thu, Apr 11, 2024 at 10:51:35PM +0300, Daniil Tatianin wrote:
> Previously we would unconditionally lower the alignment for large BARs
> in case their alignment was greater than "pci_mem64_top >> 11", this
> would make it impossible to use these devices by the kernel:
>     [   13.821108] pci 0000:9c:00.0: can't claim BAR 1 [mem 0x66000000000-0x67fffffffff 64bit pref]: no compatible bridge window
>     [   13.823492] pci 0000:9d:00.0: can't claim BAR 1 [mem 0x64000000000-0x65fffffffff 64bit pref]: no compatible bridge window
>     [   13.824218] pci 0000:9e:00.0: can't claim BAR 1 [mem 0x62000000000-0x63fffffffff 64bit pref]: no compatible bridge window
>     [   13.828322] pci 0000:8a:00.0: can't claim BAR 1 [mem 0x6e000000000-0x6ffffffffff 64bit pref]: no compatible bridge window
>     [   13.830691] pci 0000:8b:00.0: can't claim BAR 1 [mem 0x6c000000000-0x6dfffffffff 64bit pref]: no compatible bridge window
>     [   13.832218] pci 0000:8c:00.0: can't claim BAR 1 [mem 0x6a000000000-0x6bfffffffff 64bit pref]: no compatible bridge window
> 
> Fix it by only overwriting the alignment in case it's actually greater
> than the desired by the BAR window.

Thanks.  I committed this change.

-Kevin
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [RESEND PATCH] fw/pciinit: don't misalign large BARs
Posted by Daniil Tatianin 5 months, 4 weeks ago
Hey there!

Do we need more reviewed-bys before this can be merged?

Thanks!

On 4/11/24 10:51 PM, Daniil Tatianin wrote:
> Previously we would unconditionally lower the alignment for large BARs
> in case their alignment was greater than "pci_mem64_top >> 11", this
> would make it impossible to use these devices by the kernel:
>      [   13.821108] pci 0000:9c:00.0: can't claim BAR 1 [mem 0x66000000000-0x67fffffffff 64bit pref]: no compatible bridge window
>      [   13.823492] pci 0000:9d:00.0: can't claim BAR 1 [mem 0x64000000000-0x65fffffffff 64bit pref]: no compatible bridge window
>      [   13.824218] pci 0000:9e:00.0: can't claim BAR 1 [mem 0x62000000000-0x63fffffffff 64bit pref]: no compatible bridge window
>      [   13.828322] pci 0000:8a:00.0: can't claim BAR 1 [mem 0x6e000000000-0x6ffffffffff 64bit pref]: no compatible bridge window
>      [   13.830691] pci 0000:8b:00.0: can't claim BAR 1 [mem 0x6c000000000-0x6dfffffffff 64bit pref]: no compatible bridge window
>      [   13.832218] pci 0000:8c:00.0: can't claim BAR 1 [mem 0x6a000000000-0x6bfffffffff 64bit pref]: no compatible bridge window
>
> Fix it by only overwriting the alignment in case it's actually greater
> than the desired by the BAR window.
>
> Fixes: 96a8d130a8c ("be less conservative with the 64bit pci io window")
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   src/fw/pciinit.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
> index 6b13cd5b..bb44dc29 100644
> --- a/src/fw/pciinit.c
> +++ b/src/fw/pciinit.c
> @@ -970,9 +970,11 @@ static int pci_bios_check_devices(struct pci_bus *busses)
>               int resource_optional = 0;
>               if (hotplug_support == HOTPLUG_PCIE)
>                   resource_optional = pcie_cap && (type == PCI_REGION_TYPE_IO);
> +
> +            u64 top_align = pci_mem64_top >> 11;
>               if (hotplug_support && pci_pad_mem64 && is64
> -                && (type == PCI_REGION_TYPE_PREFMEM))
> -                align = pci_mem64_top >> 11;
> +                && (type == PCI_REGION_TYPE_PREFMEM) && (top_align > align))
> +                align = top_align;
>               if (align > sum && hotplug_support && !resource_optional)
>                   sum = align; /* reserve min size for hot-plug */
>               if (size > sum) {
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [RESEND PATCH] fw/pciinit: don't misalign large BARs
Posted by Philippe Mathieu-Daudé 5 months, 4 weeks ago
On 15/4/24 08:38, Daniil Tatianin wrote:
> Hey there!
> 
> Do we need more reviewed-bys before this can be merged?
> 
> Thanks!
> 
> On 4/11/24 10:51 PM, Daniil Tatianin wrote:
>> Previously we would unconditionally lower the alignment for large BARs
>> in case their alignment was greater than "pci_mem64_top >> 11", this
>> would make it impossible to use these devices by the kernel:
>>      [   13.821108] pci 0000:9c:00.0: can't claim BAR 1 [mem 
>> 0x66000000000-0x67fffffffff 64bit pref]: no compatible bridge window
>>      [   13.823492] pci 0000:9d:00.0: can't claim BAR 1 [mem 
>> 0x64000000000-0x65fffffffff 64bit pref]: no compatible bridge window
>>      [   13.824218] pci 0000:9e:00.0: can't claim BAR 1 [mem 
>> 0x62000000000-0x63fffffffff 64bit pref]: no compatible bridge window
>>      [   13.828322] pci 0000:8a:00.0: can't claim BAR 1 [mem 
>> 0x6e000000000-0x6ffffffffff 64bit pref]: no compatible bridge window
>>      [   13.830691] pci 0000:8b:00.0: can't claim BAR 1 [mem 
>> 0x6c000000000-0x6dfffffffff 64bit pref]: no compatible bridge window
>>      [   13.832218] pci 0000:8c:00.0: can't claim BAR 1 [mem 
>> 0x6a000000000-0x6bfffffffff 64bit pref]: no compatible bridge window
>>
>> Fix it by only overwriting the alignment in case it's actually greater
>> than the desired by the BAR window.
>>
>> Fixes: 96a8d130a8c ("be less conservative with the 64bit pci io window")
>> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
>> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
>> ---
>>   src/fw/pciinit.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org