ReBAR Support

I’ve done a bit more testing with mesa from git and the new BIOS upgrade.
For the A770 I can say: On a pcie3 Desktop, even with ReBAR disabled the performance isn’t nearly as bad as an eGPU, so I’m thinking those 4 lanes just don’t suffice, given that the eGPU performance of the A770 is much worse than the eGPU performance of the nvidia 1060 where I don’t even really see much of a difference to the desktop.
So, yeah, it would surely be nice to see if ReBAR makes SOME difference, but I doubt it’ll be that much.
At the end of the day, my eGPU breakaway will just be a dock with a 1060 and the A770 will live in the desktop. I’ve mostly been using the FW for work now. It does work nice for external nvme enclosures with systemd-homed :wink:

3 Likes

I don’t think its the 4x PCIe Gen3 lanes, I had a 1650 Super before and it worked way better. The A770 cant even play 4k h265 video. Some things it works ok on and others its worse that the integrated graphics which is what makes me think we need ReBAR support. I guess i’m going to put the 1650 back and put the A770 in the desktop (I knew this might happen but got the A770 to play with).

2 Likes

I seriously doubt it is the bandwidth. ReBAR is a far more likely culprit. @Kieran_Levin is ReBAR possible? Either through a BIOS update or future products? I feel like I had asked this before but I can’t find where or if I got a response.

I was thinking considering the RX6400 on PCIe Gen 3.0 suffered 14-23% performance drops in gaming due to the 4x lanes available making it even worse than both the RX 570 and GTX 1650, the reverse should apply to the A770.

That being said, from the output of
sudo lspci -v | grep "Memory.*64-bit"
and
sudo dmesg | grep BAR

It seems to be enabled in Linux for 12th Gen?

I don’t have an eGPU to test, I am on the fence of considering to get one, but thinking that Meteor Lake is coming soon in late 2023 to 2024 with an Arc graphics tile, seems like unnecessarily (at least for my use case).

The AMD Adrenalin software says resizable BAR is not enabled (11th gen):

Just in case anyone running Linux is having performance issues with eGPUs, I recently set up an RX 580, and had to manually force the amdgpu driver to the correct PCI speeds (kernel argument: amdgpu.pcie_gen_cap=0x40000). Resulted in a measurable performance improvement when running benchmarks.

I’m not sure if something similar is happening to other GPU brands, but worth taking a look at the output of lspci.

1 Like

Same on 12th gen.

1 Like

Although an option to enable ReBAR support isn’t available in the BIOS menu, it is supported by the BIOS. On 12th gen I got it enabled by using GitHub - datasone/setup_var.efi: UEFI command-line tool for read/write access of variables to change the hidden option from auto to enabled.

setup_var 0x42B 0x1 -n SaSetup
3 Likes

@Iwan_Timmer nice! Would you mind explaining a bit further:

  • How you got setup_var.efi to run on the Framework.
  • How to eventually revert the option to its original value.

Thank you!

Also, the following quote should be respected:

Use this tool with extreme caution as accessing wrong varstore or variable may completely brick your computer!

So, until we understand what exactly these parameters do, when to set them, when not to, how to revert and how to debug I wouldn’t want to fiddle around with these.

2 Likes

@Iwan_Timmer do you know what the command is for 11th gen?

1 Like

For 11th gen, the command should be:

setup_var.efi 0x431 0x1 -n SaSetup

The idea is taken from https//ristovski.github.io/posts/inside-insydeh2o, but instead of dumping the BIOS I’ve download the EFI Bios update zip which contains a ~34 MB file called hx20_capsule_3.10.bin or firmware.cap. This file can be opened in GitHub - LongSoft/UEFITool: UEFI firmware image viewer and editor Using this tool you can extract the PE Image Section of a DXE Driver called DriverSampleDxe and having the text SetupUtility. After dumping this file you can use GitHub - LongSoft/IFRExtractor-RS: Rust utility to extract UEFI IFR data into human-readable text to extract a list of text files containing definitions of the BIOS setup menu including the hidden menu’s and options. For example in one of the text files you will find for 12th gen:

		OneOf Prompt: "PCIE Resizable BAR Support", Help: "Enable/Disable PCIE Resizable BAR Support", QuestionFlags: 0x10, QuestionId: 0x444, VarStoreId: 0x2, VarOffset: 0x42B, Flags: 0x10, Size: 8, Min: 0x0, Max: 0x2, Step: 0x0
			OneOfOption Option: "Auto" Value: 2, Default, MfgDefault
			OneOfOption Option: "Enabled" Value: 1
			OneOfOption Option: "Disabled" Value: 0
		End 

The VarStoreId is a reference to a VarStoreEFI definition in the top of the text file

VarStoreEfi Guid: 72C5E28C-7783-43A1-8767-FAD73FCCAFA4, VarStoreId: 0x2, Attributes: 0x7, Size: 0x578, Name: "SaSetup"

So based on this information you know you have to change byte 0x42B (VarOffset) to the value 1 in SaSetup (Name of VarStoreEfi) to set ReBAR support from Auto (default) to Enabled. To change it back you have set it back to 2. Notice on 11th gen you can only disable or enable ReBAR support.

For changing the values I use setup_var.efi which you can run from within an EFI shell but there are also patches for Grub to add the setup_var command.

@Iwan_Timmer thank you for the very detailed explainer!

I guess my only remaining question is: how to do that exactly? How to run an “EFI shell”? Google is not very helpful…

@Kieran_Levin since ReBAR is apparently supported, can we have the BIOS option in the next update?

AFAIK that’s a big feature for eGPU users.

The thing I don’t understand is … if it’s by default on auto, does that not mean it should work?

Maybe we’re looking for a kernel parameter which forces ReBAR for Linux?

Sorry, I’m new to eGPUs and ReBAR, so this may be a stupid question.

@Iwan_Timmer After you set that value did GPU-Z show “Resizable BAR enabled in BIOS” as “Yes”? I did it with a slightly different combination of software but ultimately I changed the value to 1 and GPU-Z still shows “Resizable BAR enabled in BIOS” as “No”

1 Like

If I try to open the 12th gen 3.06 firmware.cap, it says Invalid UEFI volume. Anything else I need?

Also, if the default is ‘Auto’… then why is it not smart enough to know that that should mean enabled :wink:

@WolfgangBlub I used this to extract the part of the bios file with the rebar option: Releases · LongSoft/UEFITool · GitHub

Then I used this to convert it into human readable text files: Releases · LongSoft/IFRExtractor-RS · GitHub

Then I searched each text file for rebar and found the settings.

This is what i found in the 12th 3.06 bios:
0xE2E45: OneOf Prompt: “PCIE Resizable BAR Support”, Help: “Enable/Disable PCIE Resizable BAR Support”, QuestionFlags: 0x10, QuestionId: 0x7CA, VarStoreId: 0x2, VarOffset: 0x42B, Flags: 0x10, Size: 8, Min: 0x0, Max: 0x2, Step: 0x0 { 05 91 5D 14 5E 14 CA 07 02 00 2B 04 10 10 00 02 00 }
0xE2E56: OneOfOption Option: “Auto” Value: 2, Default, MfgDefault { 09 07 90 13 30 00 02 }
0xE2E5D: OneOfOption Option: “Enabled” Value: 1 { 09 07 91 13 00 00 01 }
0xE2E64: OneOfOption Option: “Disabled” Value: 0 { 09 07 92 13 00 00 00 }

In addition to what is in this thread I also used this post on Reddit: https://www.reddit.com/r/eGPU/comments/wx5g0f/my_adventure_in_the_attempt_of_enabling_rebar_on/

The person who posted that has the same result as me though, the option is set to enabled in the bios now but still says it is not in CPU-Z, I don’t know enough about how it works to have any idea why.

I just realized this with my Razer Core X and AMD RX 6600:

lspci -vvv gives me:

        Capabilities: [200 v1] Physical Resizable BAR
                BAR 0: current size: 8GB, supported: 256MB 512MB 1GB 2GB 4GB 8GB
                BAR 2: current size: 2MB, supported: 2MB 4MB 8MB 16MB 32MB 64MB 128MB 256MB

Notice how the BAR 0 is maximum, but the BAR 2 is minimum. I’ll investigate.

@Anachron is this before or after setting the ReBAR option in the BIOS?