Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
PCI(4)			     Kernel Interfaces Manual			  PCI(4)

NAME
     pci -- generic PCI/PCIe bus driver

SYNOPSIS
     To compile the PCI bus driver into the kernel, place the following line in
     your kernel configuration file:

	   device pci

     To compile in support for Single Root I/O Virtualization (SR-IOV):

	   options PCI_IOV

     To compile in support for native PCI-express HotPlug:

	   options PCI_HP

DESCRIPTION
     The  pci driver provides support for PCI and PCIe devices in the kernel and
     limited access to PCI devices for userland.

     The pci driver provides a /dev/pci character device that  can  be	used  by
     userland  programs to read and write PCI configuration registers.	Programs
     can also use this device to get a list of all PCI devices, or all	PCI  de-
     vices that match various patterns.

     Since  the pci driver provides a write interface for PCI configuration reg-
     isters, system administrators should exercise caution when granting  access
     to  the pci device.  If used improperly, this driver can allow userland ap-
     plications to crash a machine or cause data loss.	 In  particular,  driver
     only allows operations on the opened /dev/pci to modify system state if the
     file  descriptor  was  opened for writing.  For instance, the PCIOCREAD and
     PCIOCBARMMAP operations require a writeable descriptor, because  reading  a
     config  register or a BAR read access could have function-specific side-ef-
     fects.

     The pci driver implements the PCI bus in the kernel.  It enumerates any de-
     vices on the PCI bus and gives PCI client drivers the chance to  attach  to
     them.   It assigns resources to children, when the BIOS does not.	It takes
     care of routing interrupts when necessary.  It reprobes the unattached  PCI
     children  when  PCI  client drivers are dynamically loaded at runtime.  The
     pci driver also includes support for PCI-PCI bridges, various platform-spe-
     cific Host-PCI bridges, and basic support for PCI VGA adapters.

IOCTLS
     The following ioctl(2) calls are supported by the pci driver.  They are de-
     fined in the header file <sys/pciio.h>.

     PCIOCGETCONF

     PCIOCREAD

     PCIOCWRITE

     PCIOCATTACHED

     PCIOCBARMMAP

     PCIOCBARIO

LOADER TUNABLES
     Tunables can be set at the loader(8) prompt before booting the  kernel,  or
     stored in loader.conf(5).	The current value of these tunables can be exam-
     ined  at  runtime	via  sysctl(8) nodes of the same name.	Unless otherwise
     specified, each of these tunables is a boolean that can be enabled by  set-
     ting the tunable to a non-zero value.

     hw.pci.clear_bars (Defaults to 0)
	     Ignore  any  firmware-assigned memory and I/O port resources.  This
	     forces the PCI bus driver to allocate resource  ranges  for  memory
	     and I/O port resources from scratch.

     hw.pci.clear_buses (Defaults to 0)
	     Ignore  any  firmware-assigned  bus  number  registers  in  PCI-PCI
	     bridges.  This forces the PCI bus driver and PCI-PCI bridge  driver
	     to allocate bus numbers for secondary buses behind PCI-PCI bridges.

     hw.pci.clear_pcib (Defaults to 0)
	     Ignore  any  firmware-assigned memory and I/O port resource windows
	     in PCI-PCI bridges.  This forces the PCI-PCI bridge driver to allo-
	     cate memory and  I/O  port  resources  for  resource  windows  from
	     scratch.

	     By  default  the  PCI-PCI	bridge driver will allocate windows that
	     contain the firmware-assigned resources devices behind the  bridge.
	     In addition, the PCI-PCI bridge driver will suballocate from exist-
	     ing window regions when possible to satisfy a resource request.  As
	     a	result, both hw.pci.clear_bars and hw.pci.clear_pcib must be en-
	     abled to fully ignore firmware-supplied resource assignments.

     hw.pci.default_vgapci_unit (Defaults to -1)
	     By default, the first PCI VGA adapter encountered by the system  is
	     assumed  to be the boot display device.  This tunable can be set to
	     choose a specific VGA adapter by specifying the unit number of  the
	     associated vgapciX device.

     hw.pci.do_power_nodriver (Defaults to 0)
	     Place  devices  into  a low power state (D3) when a suitable device
	     driver is not found.  Can be set to one of the following values:

	     3	     Powers down all PCI devices without a device driver.

	     2	     Powers down most devices without a device driver.	PCI  de-
		     vices  with the display, memory, and base peripheral device
		     classes are not powered down.

	     1	     Similar to a setting of 2 except that  storage  controllers
		     are also not powered down.

	     0	     All devices are left fully powered.

	     A	PCI  device  must  support  power management to be powered down.
	     Placing a device into a low power state may not reduce  power  con-
	     sumption.

     hw.pci.do_power_resume (Defaults to 1)
	     Place PCI devices into the fully powered state when resuming either
	     the  system  or an individual device.  Setting this to zero is dis-
	     couraged as the system will not attempt to power up non-powered PCI
	     devices after a suspend.

     hw.pci.do_power_suspend (Defaults to 1)
	     Place PCI devices into a low power state when suspending either the
	     system or individual devices.  Normally the D3 state is used as the
	     low power state, but firmware may override the desired power  state
	     during a system suspend.

     hw.pci.enable_ari (Defaults to 1)
	     Enable  support  for  PCI-express	Alternative  RID Interpretation.
	     This is often used in conjunction with SR-IOV.

     hw.pci.enable_io_modes (Defaults to 1)
	     Enable memory or I/O port decoding in a PCI device's command regis-
	     ter if it has firmware-assigned memory or I/O port resources.   The
	     firmware  (BIOS) in some systems does not enable memory or I/O port
	     decoding for some devices even when it has  assigned  resources  to
	     the  device.   This  enables decoding for such resources during bus
	     probe.

     hw.pci.enable_msi (Defaults to 1)
	     Enable support for Message Signalled Interrupts (MSI).  MSI  inter-
	     rupts can be disabled by setting this tunable to 0.

     hw.pci.enable_msix (Defaults to 1)
	     Enable  support  for extended Message Signalled Interrupts (MSI-X).
	     MSI-X interrupts can be disabled by setting this tunable to 0.

     hw.pci.enable_pcie_ei (Defaults to 0)
	     Enable support for PCI-express Electromechanical Interlock.

     hw.pci.enable_pcie_hp (Defaults to 1)
	     Enable support for native PCI-express HotPlug.

     hw.pci.honor_msi_blacklist (Defaults to 1)
	     MSI and MSI-X interrupts are disabled for certain chipsets known to
	     have broken MSI and MSI-X implementations when this tunable is set.
	     It can be set to zero to permit use of MSI and MSI-X interrupts  if
	     the chipset match is a false positive.

     hw.pci.iov_max_config (Defaults to 1MB)
	     The  maximum amount of memory permitted for the configuration para-
	     meters used when creating Virtual Functions via SR-IOV.  This  tun-
	     able can also be changed at runtime via sysctl(8).

     hw.pci.realloc_bars (Defaults to 0)
	     Attempt  to allocate a new resource range during the initial device
	     scan for any memory or I/O port  resources  with  firmware-assigned
	     ranges that conflict with another active resource.

     hw.pci.usb_early_takeover (Defaults to 1 on amd64 and i386)
	     Disable  legacy  device emulation of USB devices during the initial
	     device scan.  Set this tunable to	zero  to  use  USB  devices  via
	     legacy  emulation when using a custom kernel without USB controller
	     drivers.

     hw.pci<D>.<B>.<S>.INT<P>.irq
	     These tunables can be used to override the  interrupt  routing  for
	     legacy  PCI  INTx	interrupts.  Unlike other tunables in this list,
	     these do not have corresponding sysctl nodes.  The tunable name in-
	     cludes the address of the PCI device as well as the pin of the  de-
	     sired INTx IRQ to override:

	     <D>     The domain (or segment) of the PCI device in decimal.

	     <B>     The bus address of the PCI device in decimal.

	     <S>     The slot of the PCI device in decimal.

	     <P>     The interrupt pin of the PCI slot to override.  One of `A',
		     `B', `C', or `D'.

	     The  value  of the tunable is the raw IRQ value to use for the INTx
	     interrupt pin identified by the tunable name.  Mapping of IRQ  val-
	     ues to platform interrupt sources is machine dependent.

DEVICE WIRING
     You can wire the device unit at a given location with device.hints(5).

   BSF Based Wiring
     Devices may be wired to a Bus / Slot / Function (BSF) address.  This is the
     form     reported	   by	  pciconf(8)	 Entries     of     the     form
     hints.<name>.<unit>.at="pci<B>:<S>:<F>"				      or
     hints.<name>.<unit>.at="pci<D>:<B>:<S>:<F>"  will	force the driver name to
     probe and attach at unit unit for any PCI device found to match the  speci-
     fication, where:

     <D>      The domain (or segment) of the PCI device in decimal.  Defaults to
	      0 if unspecified.

     <B>      The bus address of the PCI device in decimal.

     <S>      The slot of the PCI device in decimal.

     <F>      The function of the PCI device in decimal.

     The code to do the matching requires an exact string match.  Do not specify
     the angle brackets (< >) in the hints file.  Wiring multiple devices to the
     same name and unit produces undefined results.

   Examples
     Given the following lines in /boot/device.hints:

     hint.nvme.3.at="pci6:0:0"
     hint.igb.8.at="pci14:0:0"

     If  there is a device that supports igb(4) at PCI bus 14 slot 0 function 0,
     then it will be assigned igb8 for probe and attach.  Likewise, if there  is
     an  nvme(4) device at PCI bus 6 slot 0 function 0, then it will be assigned
     nvme3 for probe and attach.  If another type of card is in either of  these
     locations,  the  name  and  unit of that card will be the default names and
     will be unaffected by these hints.  If other igb or nvme cards are  located
     elsewhere,  they will be assigned their unit numbers sequentially, skipping
     the unit numbers that have 'at' hints.

   Location Based Wiring
     While simple to locate where to place a device for BSF wiring, the bus num-
     ber of that is not invariant.  Any number of changes to the devices  within
     the  system can cause this value to vary from boot to boot.  The UEFI Stan-
     dard defines a device path that's based only on the invariant parts of  the
     address:  The  root  complex  (domain),  the  slot number and the function.
     These paths are hard to construct by hand, please see  devctl(8)  `getpath'
     command  with  a `UEFI' locator.  The above example could also be expressed
     as

     hint.nvme.3.at="PciRoot(0x2)/Pci(0x1,0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)"
     hint.nvme.8.at="PciRoot(0x1)/Pci(0x2,0x2)/Pci(0x0,0x0)/Pci(0x0,0x0)"

     The advantage of this notation is that you can specify the exact location a
     device will be at.  For deployments of multiple systems with the same  con-
     figuration,  this	can  be  helpful in managing the devices.  However, even
     slight variation in motherboards can cause  the  path  to	change	substan-
     tially.   It  is  also less natural to think of the UEFI Device Paths since
     little else will report it.

FILES
     /dev/pci  Character device for the pci driver.

SEE ALSO
     device.hints(5) pciconf(8)

HISTORY
     The pci driver (not the  kernel's	PCI  support  code)  first  appeared  in
     FreeBSD  2.2, and was written by Stefan Esser and Garrett Wollman.  Support
     for device listing and matching was re-implemented by  Kenneth  Merry,  and
     first appeared in FreeBSD 3.0.

AUTHORS
     Kenneth Merry <ken@FreeBSD.org>

BUGS
     It  is not possible for users to specify an accurate offset into the device
     list without calling the PCIOCGETCONF at least once, since they have no way
     of knowing the current generation number otherwise.  This probably is not a
     serious problem, though, since users can  easily  narrow  their  search  by
     specifying a pattern or patterns for the kernel to match against.

FreeBSD ports 15.quarterly	 March 10, 2026 			  PCI(4)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=pci&manpath=FreeBSD+15.1-RELEASE+and+Ports.quarterly>

home | help