
setpci Command in Linux
The command setpci is a vital tool in the Linux realm, specifically tailored for querying and modifying PCI devices. It empowers users to interact with the PCI configuration space, making it an essential asset for system administrators and hardware enthusiasts alike.
The Linux command setpci is a versatile tool that allows users to query and configure PCI devices. It grants direct access to the PCI configuration space, enabling detailed control over hardware settings. Proficiency in the setpci utility enhances your ability to manage and troubleshoot PCI devices.
Table of Contents
Here is a comprehensive guide to the options available with the setpci command â
- Syntax for the setpci Command
- Commonly Used Options with the setpci Command
- Examples of setpci Command in Linux
Syntax for the setpci Command
The general syntax for the setpci command is −
setpci [options] devices operations...
- [options] specifies the various flags and parameters to refine the command's behavior.
- devices represents the PCI devices to be queried or configured.
- operations denotes the specific actions to be performed on the selected devices.
Commonly Used Options with the setpci Command
The setpci command comes with several general options that help in refining its behavior and output. Here are the commonly used options −
Option | Description |
---|---|
-v | Enables verbose mode, providing detailed information about accesses to the PCI configuration space. |
-f | Suppresses error messages when no devices are selected, useful in scripts where device presence is uncertain. |
-D | Activates 'Demo mode', which simulates operations without making any actual changes to the configuration registers. Ideal for verifying command sequences. |
--version | Displays the current version of setpci. This should be used independently. |
--help | Provides detailed help information on available options. This should be used independently. |
--dumpregs | Displays a list of all recognized PCI registers and capabilities. This should be used independently. |
PCI Access Options
The PCI utilities rely on the PCI library to communicate with PCI devices. The following options can influence its behavior −
Option | Description |
---|---|
-A <method> | Specifies the method to access the PCI hardware, overriding the default method. Use -A help to see available methods and their descriptions. |
-O <param>=<value> | Sets the value of a specific parameter that controls the behavior of the PCI library. Use -O help for a list of known parameters and their default values. |
-H1 | Uses direct hardware access through Intel configuration mechanism 1 (equivalent to -A intel-conf1). |
-H2 | Uses direct hardware access through Intel configuration mechanism 2 (equivalent to -A intel-conf2). |
-G | Increases the debug level of the PCI library. |
Device Selection Options
Before performing operations, you need to specify which devices the command should affect −
Option | Description |
---|---|
-s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]] | Selects devices based on domain, bus, slot, and function. Each part of the device address can be omitted or set to "*", meaning "any value". All numbers are in hexadecimal. |
-d [<vendor>]:[<device>] | Selects devices with the specified vendor and device ID, both in hexadecimal. IDs can be omitted or set to "*", meaning "any value". |
When using both -s and -d, only devices matching both criteria are selected. Multiple options of the same type will be overridden by the rightmost one.
Examples of setpci Command in Linux
Here are some practical scenarios where the setpci command can be effectively used −
- Querying a Configuration Register
- Setting a Configuration Register
- Enabling Verbose Mode
- Using Demo Mode
Example 1: Querying a Configuration Register
To check the value of a configuration register, you can use:
setpci -s 00:03.0 0x10.L
This command reads the value of the register at address 0x10 for the device located at bus 00, slot 03, function 0.

Example 2: Setting a Configuration Register
In case you want to modify the value of a configuration register, you can use:
setpci -s 00:03.0 0x10.L=0x12345678
This command sets the value of the register at address 0x10 to 0x12345678 for the device located at bus 00, slot 1f, function 0.
Example 3: Enabling Verbose Mode
To enable verbose mode and get detailed information about configuration space accesses, you can use:
setpci -v -s 00:1f.0 0x10.L
This command provides detailed output for the specified operation.

Example 4: Using Demo Mode
To simulate setpci operations without making any changes to the configuration registers, you can use:
setpci -vD -s 00:03.0 0x10.L=0x12345678
This command simulates the operation, verifying the sequence of commands without altering the registers.
Conclusion
The setpci command in Linux is a powerful utility for querying and configuring PCI devices. By understanding its purpose, syntax, options, and practical usage scenarios, you can effectively manage and troubleshoot PCI devices, ensuring optimal hardware performance.
Whether you need to query configuration registers, set register values, enable verbose mode, or test operations in demo mode, mastering the setpci command provides a flexible and powerful solution. Incorporating the setpci command into your toolkit enhances your ability to manage PCI devices and maintain a well-configured system.