From 6571dcf91951aad997743c5481ecc64345066e03 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Mon, 27 Sep 2021 04:53:32 +0000 Subject: [PATCH] sof-dump-status.py: don't crash on unknown Intel audio PCI devices 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 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 --- tools/sof-dump-status.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/sof-dump-status.py b/tools/sof-dump-status.py index 34d62ae6..1296f861 100755 --- a/tools/sof-dump-status.py +++ b/tools/sof-dump-status.py @@ -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):