Skip to content

Commit

Permalink
sof-dump-status.py: don't crash on unknown Intel audio PCI devices
Browse files Browse the repository at this point in the history
Set pci_info['hw_name'] to "PCI device unknown by SOF" and keep going.

Before this commit, any test that invokes sof-dump-status.py for any
reason crashes like this when the PCI ID is unknown:

```
Traceback (most recent call last):
  File "sof-test/tools/sof-dump-status.py", line 497, in <module>
    sysinfo.loadPCI()
  File "sof-test/tools/sof-dump-status.py", line 139, in loadPCI
    pci_info['hw_name'] = self._pci_ids["0x" + tmp_line[4] + tmp_line[3]]
KeyError: '0xe328'
```

The lack of a known PCI ID does not have to be fatal: there are plenty
of use cases where the PCI ID is not needed. This commit makes it
possible to run all these test cases even when the PCI ID is unknown.

This could help with #288 too.

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb committed Jun 6, 2024
1 parent f2e3ae9 commit 6571dcf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/sof-dump-status.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,13 @@ def loadPCI(self):
# 1st line of PCI config space in hex
tmp_line = tmp_output[i].split()
break
pci_info['hw_id']="0x" + tmp_line[2] + tmp_line[1] + " 0x" + tmp_line[4] + tmp_line[3]
pci_info['hw_name'] = self._pci_ids["0x" + tmp_line[4] + tmp_line[3]]
pci_dev_id = "0x" + tmp_line[4] + tmp_line[3]
pci_info['hw_id'] = "0x" + tmp_line[2] + tmp_line[1] + " " + pci_dev_id
try:
pci_info['hw_name'] = self._pci_ids[pci_dev_id]
except KeyError:
pci_info['hw_name'] = "PCI ID unknown by sof-dump-status.py"

self.pci_lst.append(pci_info)

def loadACPI(self):
Expand Down

0 comments on commit 6571dcf

Please sign in to comment.