Skip to content

Commit

Permalink
pcie_check: will not show unavailable PCI or PCIe info in the list
Browse files Browse the repository at this point in the history
Add the judgment that PCI capability is 0, it will not show unavailable PCI
or PCIe info in the list.

Reported-by: Yi Lai <[email protected]>
Signed-off-by: Pengfei Xu <[email protected]>
  • Loading branch information
xupengfe authored and ysun committed Sep 13, 2024
1 parent dd4f00e commit f404368
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions BM/tools/pcie/pcie_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,9 @@ int recognize_pcie(u32 *ptrdata)
/* 0x34/4 is capability pointer in PCI */
nextpoint = (u8)(*(ptrdata + PCI_CAP_START / 4));

/* If 0x34 next point is 0, will continue and code is 3 */
if (nextpoint == 0)
return 0;
return 3;

ptrsearch = ptrdata + nextpoint / 4;
while (1) {
Expand Down Expand Up @@ -511,7 +512,7 @@ int scan_pci(void)
u32 bus, dev, fun;
// Must 32bit for data check!
u32 *ptrdata = malloc(sizeof(unsigned long) * 4096);
int fd;
int fd, ret;

fd = open("/dev/mem", O_RDWR);

Expand All @@ -537,14 +538,17 @@ int scan_pci(void)
}

if ((*ptrdata != ptr_content) && (*ptrdata != 0)) {
if (recognize_pcie(ptrdata) == 2) {
ret = recognize_pcie(ptrdata);
if (ret == 2) {
printf("[ERROR] PCI %02x:%02x.%x offset 0xff,",
bus, dev, fun);
printf("please debug:pcie_check a %x %x %x\n",
bus, dev, fun);
munmap(ptrdata, LEN_SIZE);
close(fd);
return 2;
} else if (ret == 3) {
continue;
}

if (is_pcie == 0)
Expand Down Expand Up @@ -589,6 +593,9 @@ int specific_pcie_cap(u32 *ptrdata, u16 cap)
* PCI_CAP_START, ptrdata, *ptrdata);
*/
return 2;
/* If 0x34 next point is 0, will continue and code is 3 */
} else if (nextpoint == 0) {
return 3;
}

cap_value = (u16)(*(ptrdata + next / 4));
Expand Down Expand Up @@ -797,6 +804,8 @@ int find_pcie_reg(u16 cap, u32 offset, u32 size)
printf("please debug:pcie_check a %x %x %x\n",
bus, dev, func);
continue;
} else if (result == 3) {
continue;
}
}
munmap(ptrdata, LEN_SIZE);
Expand Down Expand Up @@ -971,6 +980,8 @@ int find_pci_reg(u16 cap, u32 offset, u32 size)
printf("please debug:pcie_check a %x %x %x\n",
bus, dev, func);
continue;
} else if (result == 3) {
continue;
}
}
munmap(ptrdata, LEN_SIZE);
Expand Down

0 comments on commit f404368

Please sign in to comment.