Broken PCI BusID parsing on machines with several domains
Kalanyr opened this issue · 12 comments
When using the BusID X:X:X syntax SUSEPrime is generating an actional x conf file with BusID 0:0:2 when the correct BusID is 0:2:0 (ie the standard one for Intel Integrated GPUs).
SUSEPrime and X.org actually both behave pretty strangely with the Optimus setup on this laptop generally. But I figure one problem at a time.
Hmm. Could you please provide the output of /sbin/lspci
and the generated x conf file? 0:0:2 looks pretty common to me. Are you sure changing it to 0:2:0 fixes the issue?
0000:00:02.0 VGA compatible controller: Intel Corporation Alder Lake-HX GT1 [UHD Graphics 770] (rev 0c)
--> PCI:0:0:2
There is nothing wrong with that. Config file looks also fine.
I guess with the wrong PCI ID (you're trying to configure) Xserver tries to use only NVIDIA card and then fails for some reason. I would need the logfiles /var/log/Xorg.0.log for both cases.
Hmm. Seems the lspci output format changed, which broke parsing. :-( Are you using Tumbleweed? You're right. It should be PCI:0:2:0 and PCI:1:0:0.
line=$(/sbin/lspci | grep "VGA compatible controller: Intel")
echo $line| cut -f 1 -d ' ' | sed -e 's/./:/g;s/:/ /g' | awk -Wposix '{printf("PCI:%d:%d:%d\n","0x" $1, "0x" $2, "0x" $3 )}'
With
0000:00:02.0 VGA compatible controller: Intel Corporation Alder Lake-HX GT1 [UHD Graphics 770] (rev 0c)
this results
in PCI:0:0:2 instead of PCI:0:2:0 with
00:02.0 VGA compatible controller: Intel Corporation ... (I see this on Leap 15.3/15.4)
Looking into it, Kalanyr PC has two domains (0000
and 10000
) thus lspci
prefixes the devices with the domains:
0000:00:00.0 Host bridge: Intel Corporation Device 4637 (rev 02)
...
10000:e0:06.0 PCI bridge: Intel Corporation 12th Gen Core Processor PCI Express x4 Controller #0 (rev 02)
....
Most PCs I suppose only have one domain (domain 0) and in that case lspci
omits it in its output (quoting the man
for lspci
: By default, lspci suppresses them on machines which have only domain 0).
Thus it is a parsing bug when there are more than 1 domain.
These modifications should fix it:
line=$(lspci -D | grep "$lspci_line" | head -1)
...
card_busid=$(echo $line | cut -f 1 -d ' ' | sed -e 's/\./:/g;s/:/ /g' | awk -Wposix '{printf("PCI:%d:%d:%d\n","0x" $2, "0x" $3, "0x" $4 )}')
This adds the -D option to lspci
to always output the domain and shift the printf arguments by one to $2, $3, $4 to take into account the new domain field in the lspci output.
@bubbleguuum Thanks. Good catch. Didn't know this domain trick. I would have used $(NF-2)
, $(NF-1)
and $NF
, but II like the -D
option much better.
I think I have seen several domains on big server machines before, but not so much on Laptops. ;-)
Now fixed in git and made an new release 0.8.9 with this fix. Also updated the suse-prime package and submitted for Tumbleweed.