<div dir="ltr"><p><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px">Hi,all</span></p>
<p><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px">I have some
questions about PCI testing.</span><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"></span><br>
</p>
<span style="color:rgb(36,41,46)">testcases/kernel/device-drivers/pci/tpci_user/tpci.c
->static void test_run(void) ,the
code scan the devices on a bus one by one,</span><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;padding:0px;margin:0px;background:initial;border-radius:6px;word-break:normal;white-space:pre;border:0px;display:inline;overflow:visible;line-height:inherit"><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px;white-space:normal">then it calls pci_scan_slot() in kernel.</span></code><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;padding:0px;margin:0px;background:initial;border-radius:6px;word-break:normal;white-space:pre;border:0px;display:inline;overflow:visible;line-height:inherit"><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px;white-space:normal">But A PCIe device has only 8 functions. Isn’t it possible to scan the next device here?</span></code>
<p><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;padding:0px;margin:0px;background:initial;border-radius:6px;word-break:normal;white-space:pre;border:0px;display:inline;overflow:visible;line-height:inherit"><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px;white-space:normal">For example, on the problematic machine: </span></code></p><p><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;padding:0px;margin:0px;background:initial;border-radius:6px;word-break:normal;white-space:pre;border:0px;display:inline;overflow:visible;line-height:inherit"><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px;white-space:normal">1. When traversing to the 8.1 device, it will scan to 9.0 by mistake, and then the kernel will turn 9.0 into a multi-function device (the 9.0 device is a single-function device) </span></code></p><p><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;padding:0px;margin:0px;background:initial;border-radius:6px;word-break:normal;white-space:pre;border:0px;display:inline;overflow:visible;line-height:inherit"><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px;white-space:normal">2. When traversing to the 8.2 device, call pci_rescan_bus in test-case 6 of the ltp test program to scan all devices on bus 0. At this time, when the 9.0 device is accessed, it is judged to be a multi-function device, and the subsequent functions are accessed. Before accessing the function, it will first judge the vendor id. If it is 0xFFFF, it means that the function does not exist. However, at this time, it is found that the vendor id of 9.1 exists and is the same as 9.0 (it should be 0xffff), so the kernel recognizes 9.1. Next, I reconfigured 9.1 and assigned its next level of bus to bus 4. In fact, bus 4 does not exist (the serial port log is as follows)</span></code></p>
<p><span style="color:rgb(33,33,33);font-family:"Roboto Mono","SF Mono","Lucida Console",Monaco,monospace;font-size:13.006px;white-space:pre-wrap">[ 4218.291890][ 0] ltp_tpci: found pci_dev '0000:00:08.2', bus 0, devfn 66
[ 4218.298560][ 0] ltp_tpci: Bus number: 0
[ 4218.302503][ 0] ltp_tpci: test-case 1
[ 4218.306232][ 0] ltp_tpci: enable pci device
[ 4218.310482][ 0] ltp_tpci: enabled pci device
[ 4218.314919][ 0] ltp_tpci: test-case 2
[ 4218.318679][ 0] ltp_tpci: find bus
[ 4218.322164][ 0] ltp_tpci: success returned bus pointer
[ 4218.327538][ 0] ltp_tpci: test-case 3
[ 4218.331271][ 0] ltp_tpci: get pci device
[ 4218.335266][ 0] ltp_tpci: found pci device from device info
[ 4218.340974][ 0] ltp_tpci: test-case 4
[ 4218.344709][ 0] ltp_tpci: find pci class
[ 4218.348740][ 0] ltp_tpci: found pci device from class number
[ 4218.354664][ 0] ltp_tpci: test-case 5
[ 4218.358387][ 0] ltp_tpci: get pci subsys
[ 4218.362383][ 0] ltp_tpci: found pci device from subsys info
[ 4218.368070][ 0] ltp_tpci: test-case 6
[ 4218.371802][ 0] ltp_tpci: scan pci bus
[ 4218.375816][ 0] pci 0000:00:09.1: [Firmware Bug]: reg 0x10: invalid BAR (can't size)
[ 4218.384249][ 0] pci 0000:00:09.1: bridge configuration invalid ([bus 00-00]), reconfiguring
[ 4218.393594][ 0] pci 0000:00:09.1: PCI bridge to [bus 04]
[ 4218.399043][ 0] pcieport 0000:00:09.1: Device 14:7a19, irq 96
[ 4218.405064][ 0] pcieport 0000:00:09.1: Signaling PME with IRQ 133
[ 4218.411336][ 1] ltp_tpci: success scan bus
[ 4218.415692][ 1] ltp_tpci: test-case 7
[ 4218.419500][ 1] ltp_tpci: scan pci slot</span><br>
<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;padding:0px;margin:0px;background:initial;border-radius:6px;word-break:normal;white-space:pre;border:0px;display:inline;overflow:visible;line-height:inherit"><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px;white-space:normal"></span></code></p>
<p><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;padding:0px;margin:0px;background:initial;border-radius:6px;word-break:normal;white-space:pre;border:0px;display:inline;overflow:visible;line-height:inherit"><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px;white-space:normal">
</span></code></p>
<p><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;padding:0px;margin:0px;background:initial;border-radius:6px;word-break:normal;white-space:pre;border:0px;display:inline;overflow:visible;line-height:inherit"><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px;white-space:normal">I think although there may be problems with PCI devices(vendor id of 9.1), is the ltp test correct? </span></code></p></div>