User Tools

Site Tools


linux:kernel:pci_devices

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux:kernel:pci_devices [2021/01/29 10:29] – created peterlinux:kernel:pci_devices [2022/10/08 11:37] (current) peter
Line 3: Line 3:
 The PCI standard has become the de-facto standard for system buses. The PCI standard has become the de-facto standard for system buses.
  
-Linux provide extensive support for PCI, and contains numerous drivers for network, storage and 3rd party adapters. +Linux provide extensive support for PCI, and contains numerous drivers for network, storage and 3rd party adapters.
  
 ---- ----
Line 15: Line 15:
 returns: returns:
  
-<code bash>+<code>
 total 0 total 0
 drwxr-xr-x 2 root root 0 Jan 29 03:47 . drwxr-xr-x 2 root root 0 Jan 29 03:47 .
Line 65: Line 65:
 lrwxrwxrwx 1 root root 0 Jan 29 03:47 0000:0b:00.4 -> ../../../devices/pci0000:00/0000:00:08.1/0000:0b:00.4 lrwxrwxrwx 1 root root 0 Jan 29 03:47 0000:0b:00.4 -> ../../../devices/pci0000:00/0000:00:08.1/0000:0b:00.4
 </code> </code>
 +
 +----
 +
 +===== Analyze one device =====
 +
 +Take one example from the list:
 +
 +<code bash>
 +lrwxrwxrwx 1 root root 0 Jan 29 03:47 0000:00:03.0 -> ../../../devices/pci0000:00/0000:00:03.0
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  Break the device string **0000:03:00.0** down as follows:
 +
 +  * **0000** : PCI domain.  Each domain can contain up to 256 PCI buses.
 +  * **03**   : The bus number the device is attached to.
 +  * **00**   : The device number.
 +  * **.0**   : PCI device function.
 +
 +Vendor and device information is stored in a centralized [[http://pci-ids.ucw.cz/|PCI ID repository]], so you can figure out what a given device is by decoding the PCI data manually.
 +
 +</WRAP>
 +
 +----
 +
 +===== Obtain Information on a specific PCI device =====
 +
 +<code bash>
 +cd /sys/devices/pci0000:00/0000:00:03.0
 +ls -al
 +</code>
 +
 +returns:
 +
 +<code bash>
 +total 0
 +drwxr-xr-x  4 root root    0 Jan 29 03:47 .
 +drwxr-xr-x 28 root root    0 Jan 23 13:03 ..
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 ari_enabled
 +-rw-r--r--  1 root root 4.0K Jan 29 10:35 broken_parity_status
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 class
 +-rw-r--r--  1 root root 4.0K Jan 29 10:35 config
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 consistent_dma_mask_bits
 +-rw-r--r--  1 root root 4.0K Jan 29 10:35 d3cold_allowed
 +-r--r--r--  1 root root 4.0K Jan 29 03:47 device
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 dma_mask_bits
 +-rw-r--r--  1 root root 4.0K Jan 29 10:35 driver_override
 +-rw-r--r--  1 root root 4.0K Jan 29 10:35 enable
 +lrwxrwxrwx  1 root root    0 Jan 29 10:35 iommu -> ../0000:00:00.2/iommu/ivhd0
 +lrwxrwxrwx  1 root root    0 Jan 29 10:35 iommu_group -> ../../../kernel/iommu_groups/3
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 irq
 +drwxr-xr-x  2 root root    0 Jan 29 10:35 link
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 local_cpulist
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 local_cpus
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 modalias
 +-rw-r--r--  1 root root 4.0K Jan 29 10:35 msi_bus
 +-rw-r--r--  1 root root 4.0K Jan 29 10:35 numa_node
 +drwxr-xr-x  2 root root    0 Jan 29 10:35 power
 +--w--w----  1 root root 4.0K Jan 29 10:35 remove
 +--w-------  1 root root 4.0K Jan 29 10:35 rescan
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 resource
 +-r--r--r--  1 root root 4.0K Jan 29 03:47 revision
 +lrwxrwxrwx  1 root root    0 Jan 29 03:47 subsystem -> ../../../bus/pci
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 subsystem_device
 +-r--r--r--  1 root root 4.0K Jan 29 10:35 subsystem_vendor
 +-rw-r--r--  1 root root 4.0K Jan 29 03:47 uevent
 +-r--r--r--  1 root root 4.0K Jan 29 03:47 vendor
 +</code>
 +
 +----
 +
 +<WRAP info>
 +**NOTE:**  Each sysfs entry contains a unique piece of data, such as the PCI vendor id (vendor) the device class (class), the device identifier (device), and information on irq and resource assignments.
 +</WRAP>
 +
 +
 +==== Get Vendor ====
 +
 +<code bash>
 +cat vendor 0x14e4
 +</code>
 +
 +returns:
 +
 +<code bash>
 +0x1022
 +</code>
 +
 +----
 +
 +==== Get Device ====
 +
 +<code bash>
 +cat device
 +</code>
 +
 +returns:
 +
 +<code bash>
 +0x1482
 +</code>
 +
 +----
 +
 +==== Get Class ====
 +
 +<code bash>
 +cat class
 +</code>
 +
 +returns:
 +
 +<code bash>
 +0x060000
 +</code>
 +
 +----
 +
 +===== Viewing PCI data with lspci =====
 +
 +View the devices connected to your system:
 +
 +<code bash>
 +lspci | tail -10
 +</code>
 +
 +returns:
 +
 +<code bash>
 +06:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller
 +07:00.0 SATA controller: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] (rev 51)
 +08:00.0 SATA controller: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] (rev 51)
 +09:00.0 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050 Ti] (rev a1)
 +09:00.1 Audio device: NVIDIA Corporation GP107GL High Definition Audio Controller (rev a1)
 +0a:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Function
 +0b:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Reserved SPP
 +0b:00.1 Encryption controller: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Cryptographic Coprocessor PSPCPP
 +0b:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller
 +0b:00.4 Audio device: Advanced Micro Devices, Inc. [AMD] Starship/Matisse HD Audio Controller
 +</code>
 +
 +<WRAP info>
 +**NOTE:** lspci read through the sysfs entries and decoded the vendor and device numbers using the vendor and device information in **/usr/share/hwdata/pci.ids**.
 +
 +lspci uses libpci, which returns the data using the PCI identification data in /usr/share/hwdata/pci.ids.
 +
 +</WRAP>
 +
 +----
 +
 +<code bash>
 +lspci -n | tail -10
 +</code>
 +
 +returns:
 +
 +<code bash>
 +06:00.3 0c03: 1022:149c
 +07:00.0 0106: 1022:7901 (rev 51)
 +08:00.0 0106: 1022:7901 (rev 51)
 +09:00.0 0300: 10de:1c82 (rev a1)
 +09:00.1 0403: 10de:0fb9 (rev a1)
 +0a:00.0 1300: 1022:148a
 +0b:00.0 1300: 1022:1485
 +0b:00.1 1080: 1022:1486
 +0b:00.3 0c03: 1022:149c
 +0b:00.4 0403: 1022:1487
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  lspci displays the raw PCI identification data.
 +</WRAP>
 +
 +----
 +
 +==== Expand on one device ====
 +
 +As an example, taking this from above list:
 +
 +<code bash>
 +09:00.0 0300: 10de:1c82 (rev a1)
 +</code>
 +
 +<WRAP info>
 +**NOTE:** 
 +
 +  * 09:00.0 : Bus number (09), Device number (00) and Function (0).
 +  * 0300    : Device class.
 +  * 10de    : Vendor ID.
 +  * 1c82    : Device ID.
 +
 +Looking up the identifiers in the [[http://pci-ids.ucw.cz/|PCI ID repository]]:
 +
 +  * 0300    : Device class => Display controller.
 +  * 10de    : Vendor ID => NVIDIA Corporation.
 +  * 1c82    : Device ID => GP107 [GeForce GTX 1050 Ti].
 +
 +which matches the output from the default **lspci | tail -10**:
 +
 +<code bash>
 +09:00.0 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050 Ti] (rev a1)
 +</code>
 +</WRAP>
 +
 +----
 +
 +===== Updating the PCI identification list =====
 +
 +The lspci utility uses the pci.ids file to determine the vendor and device type.
 +
 +This file will grow as new vendors and devices are added, and can be updated automatically by running the update-pciids utility:
 +
 +<code bash>
 +/sbin/update-pciids
 +</code>
 +
 +returns:
 +
 +
 +<code bash>
 +  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
 +                                 Dload  Upload   Total   Spent    Left  Speed
 +100  264k  100  264k    0       494k      0 --:--:-- --:--:-- --:--:--  493k
 +</code>
 +
 +----
 +
 +===== References =====
 +
 +http://pci-ids.ucw.cz/
 +
 +http://www.pcisig.com/home
 +
  
linux/kernel/pci_devices.1611916146.txt.gz · Last modified: 2021/01/29 10:29 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki