The Linux Kernel/PCI

From Wikibooks, open books for an open world
Jump to navigation Jump to search

PCI bus support in Linux kernel

Querying information from a shell:

lspci -vv
column -t /proc/bus/pci/devices

Acronyms[edit]

  • ACPI - Advanced Configuration and Power Interface
  • ACS - Access Control Service
  • AER - Advanced Error Reporting port service
  • ASPM - Active State Power Management
  • EDR - Error Disconnect Recover
  • FLR - function level reset
  • HT - Hypertransport
  • BAR - Base Address Registers
  • BW - Bandwidth
  • DPC - Downstream Port Containment port service
  • EP - Endpoint
  • mmrbc - maximum memory read byte count
  • mps - maximum payload size
  • MWI - Memory-Write-Invalidate
  • PM - Power Management
  • PMC - ... ... Controller
  • PME - ... ... Event, port service
  • SR-IOV - Single-root input/output virtualization
  • VF - virtual functions

Most used API[edit]

User mode API:

uapi/linux/pci.h
uapi/linux/pci_regs.h


Kernel mode API:

pci_device_id - has vendor, device and class IDs. It is used for probing.

pci_driver - central struct

module_pci_driver - helper macro to register pci_driver. It uses pci_register_driver and pci_unregister_driver .

pci_enable_device , pci_disable_device - must be called in probe and remove callbacks of pci_driver.

pci_set_drvdata , pci_get_drvdata

pci_dev

pci_name

pci_set_master

pci_request_region , pci_request_regions / pci_release_regions

pci_alloc_irq_vectors / pci_free_irq_vectors , pci_request_irq or pci_irq_vector

pci_iomap , pci_iounmap

to_pci_dev

pci_resource_flags , pci_resource_start , pci_resource_len

pci_dev_put

pci_read_config_dword , pci_write_config_dword

pci_set_power_state


Examples:

PCI Linux Driver Template
samples/v4l/v4l2-pci-skeleton.c


Internals[edit]

linux/pci_ids.h
drivers/pci
pci_ops


Mainline documents with summary[edit]

PCI driver API docs


PCI Support Library[edit]

PCI Support Library


pci_bus_max_busnr , pci_status_get_and_clear_errors , pci_find_capability , pci_bus_find_capability , pci_find_next_ext_capability , pci_find_ext_capability , pci_get_dsn , pci_find_next_ht_capability , pci_find_ht_capability , pci_find_parent_resource , pci_find_resource , pci_platform_power_transition , pci_set_power_state , pci_choose_state , pci_save_state , pci_restore_state , pci_store_saved_state , pci_load_saved_state , pci_load_and_free_saved_state , pci_reenable_device , pci_enable_device_io , pci_enable_device_mem , pci_enable_device , pcim_enable_device , pcim_pin_device , pci_disable_device , pci_set_pcie_reset_state , pci_pme_capable , pci_pme_active , pci_enable_wake , pci_wake_from_d3 , pci_prepare_to_sleep , pci_back_from_sleep , pci_dev_run_wake , pci_d3cold_enable , pci_d3cold_disable , pci_enable_atomic_ops_to_root , pci_common_swizzle , pci_release_region , pci_request_region , pci_release_selected_regions , pci_request_selected_regions , pci_release_regions , pci_request_regions , pci_request_regions_exclusive , pci_remap_iospace , pci_unmap_iospace , device , devm_pci_remap_iospace , device , devm_pci_remap_cfgspace , device , devm_pci_remap_cfg_resource , pci_set_master , pci_clear_master , pci_set_cacheline_size , pci_set_mwi , pcim_set_mwi , pci_try_set_mwi , pci_clear_mwi , pci_intx , pci_check_and_mask_intx , pci_check_and_unmask_intx , pci_wait_for_pending_transaction , pcie_has_flr , pcie_flr , pci_bridge_secondary_bus_reset , __pci_reset_function_locked , pci_reset_function , pci_reset_function_locked , pci_try_reset_function , pci_probe_reset_slot , pci_probe_reset_bus , pci_reset_bus , pcix_get_max_mmrbc , pcix_get_mmrbc , pcix_set_mmrbc , pcie_get_readrq , pcie_set_readrq , pcie_get_mps , pcie_set_mps , pcie_bandwidth_available , pcie_get_speed_cap , pcie_get_width_cap , pcie_print_link_status , pci_select_bars , pci_driver , pci_add_dynid , pci_device_id , pci_device_id , pci_match_id , pci_driver , __pci_register_driver , pci_driver , pci_unregister_driver , pci_driver , pci_dev_driver , pci_dev_get , pci_dev_put , pci_stop_and_remove_bus_device , pci_find_bus , pci_find_next_bus , pci_get_slot , pci_get_domain_bus_and_slot , pci_get_subsys , pci_get_device , pci_get_class , pci_device_id , pci_dev_present , irq_data , pci_msi_mask_irq , irq_data , pci_msi_unmask_irq , pci_msi_vec_count , pci_msix_vec_count , pci_msi_enabled , pci_enable_msix_range , irq_affinity , pci_alloc_irq_vectors_affinity , pci_free_irq_vectors , pci_irq_vector , pci_irq_get_affinity , pci_msi_create_irq_domain , pci_bus_alloc_resource , pci_bus_add_device , pci_bus_add_devices , pci_bus_set_ops , pci_cfg_access_lock , pci_cfg_access_trylock , pci_cfg_access_unlock , pci_request_irq , pci_free_irq , pcie_relaxed_ordering_enabled , pci_scan_slot , pci_scan_child_bus , pci_rescan_bus , pci_create_slot , pci_destroy_slot , pci_hp_create_module_link , pci_hp_remove_module_link , pci_enable_rom , pci_disable_rom , pci_map_rom , pci_unmap_rom , pci_enable_sriov , pci_disable_sriov , pci_num_vf , pci_vfs_assigned , pci_sriov_set_totalvfs , pci_sriov_get_totalvfs , pci_sriov_configure_simple , pci_read_legacy_io , pci_write_legacy_io , pci_mmap_legacy_mem , pci_mmap_legacy_io , pci_adjust_legacy_attr , pci_create_legacy_files , pci_mmap_resource , pci_remove_resource_files , pci_create_resource_files , pci_write_rom , pci_read_rom , pci_remove_sysfs_dev_files ,

PCI Hotplug Support Library

__pci_hp_register , __pci_hp_initialize , pci_hp_add , pci_hp_deregister , pci_hp_del , pci_hp_destroy ,

PCI Peer-to-Peer DMA Support[edit]

PCI Peer-to-Peer DMA Support


ient-drivers , pci_p2pdma_add_resource , device , pci_p2pdma_distance_many , pci_has_p2pmem , device , pci_p2pmem_find_many , pci_alloc_p2pmem , pci_free_p2pmem , pci_p2pmem_virt_to_bus , pci_p2pmem_alloc_sgl , pci_p2pmem_free_sgl , pci_p2pmem_publish , device , pci_p2pdma_map_sg_attrs , device , pci_p2pdma_unmap_sg_attrs , pci_p2pdma_enable_store , pci_p2pdma_enable_show ,

PCI subsystem docs[edit]

PCI subsystem docs , newer on the top:


Boot Interrupts reroute


X86_REROUTE_FOR_BROKEN_BOOT_IRQS

Kernel parameters pci=ioapicreroute


EP - Endpoint Framework

Querying information from shell:

find /sys/kernel/config/pci_ep/


EPC - EP Controller:

linux/pci-epc.h

pci_epc_create , devm_pci_epc_create


EPF - EP Function:

linux/pci-epf.h

pci_epf_create


Internals: drivers/pci/endpoint/


Driver to test endpoint functionality: drivers/pci/endpoint/functions/pci-epf-test.c


PCIe virtualization, SR-IOV , 2009

API: pci_enable_sriov , pci_disable_sriov , sriov_configure


MSI - Message Signaled Interrupts , 2008

MSI Example:

vectors = pci_alloc_irq_vectors (pci_dev, 1, 1, PCI_IRQ_MSI | PCI_IRQ_MSIX);
irq = pci_irq_vector (pci_dev, 0);


AER - Advanced Error Reporting , 2006

API: linux/aer.h , pci_enable_pcie_error_reporting , pci_disable_pcie_error_reporting , pci_aer_clear_nonfatal_status


ERS - Error Recovery System

API: pci_error_handlers , pci_ers_result , pci_channel_state_t


PCIe - PCI Express Port Bus Driver , 2004

API: pcie_port_service_driver ,pcie_port_service_register , pcie_port_service_unregister


Old manual PCI API

pci_get_device , pci_get_class , pci_get_subsys , pci_dev_put


Old articles:

More info[edit]