Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.
This repository was archived by the owner on Dec 29, 2025. It is now read-only.

AutoASPM fails on systems with multiple domains #10

@jfikar

Description

@jfikar

Some machines have multiple domains (multiple host bridges). The simplest example is Raspberry Pi 5:

$ sudo lspci
0001:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries BCM2712 PCIe Bridge (rev 30)
0001:01:00.0 Non-Volatile memory controller: Toshiba Corporation XG4 NVMe SSD Controller (rev 01)
0002:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries BCM2712 PCIe Bridge (rev 30)
0002:01:00.0 Ethernet controller: Raspberry Pi Ltd RP1 PCIe 2.0 South Bridge

And here your script fails with:

$ sudo ./autoaspm.py.orig 
Traceback (most recent call last):
  File "/home/fik/./autoaspm.py.orig", line 114, in <module>
    main()
    ~~~~^^
  File "/home/fik/./autoaspm.py.orig", line 111, in main
    patch_device(device, aspm_mode)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/fik/./autoaspm.py.orig", line 77, in patch_device
    endpoint_bytes = read_all_bytes(addr)
  File "/home/fik/./autoaspm.py.orig", line 54, in read_all_bytes
    all_bytes.extend(bytearray.fromhex(line.split(": ")[1]))
                     ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
ValueError: non-hexadecimal number found in fromhex() arg at position 1

Maybe the way is to supply -D to lspci, which will always display the domain number also on systems with single domain (in that case 0000). And then iterate also over the domains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions