TEXT 28
Pci.txt Guest on 26th April 2021 05:33:07 AM
  1. Documentation/PCI/index.rst            |   2 +
  2.  Documentation/PCI/{pci.txt => pci.rst} | 267 +++++++++++++------------
  3.  2 files changed, 140 insertions(+), 129 deletions(-)
  4.  rename Documentation/PCI/{pci.txt => pci.rst} (78%)
  5.  
  6. diff --git a/Documentation/PCI/index.rst b/Documentation/PCI/index.rst
  7. index c2f8728d11cf..7babf43709b0 100644
  8. --- a/Documentation/PCI/index.rst
  9. +++ b/Documentation/PCI/index.rst
  10. @@ -7,3 +7,5 @@ Linux PCI Bus Subsystem
  11.  .. toctree::
  12.     :maxdepth: 2
  13.     :numbered:
  14. +
  15. +   pci
  16. diff --git a/Documentation/PCI/pci.txt b/Documentation/PCI/pci.rst
  17. similarity index 78%
  18. rename from Documentation/PCI/pci.txt
  19. rename to Documentation/PCI/pci.rst
  20. index badb26ac33dc..29ddd2e9177a 100644
  21. --- a/Documentation/PCI/pci.txt
  22. +++ b/Documentation/PCI/pci.rst
  23. @@ -1,10 +1,12 @@
  24. +.. SPDX-License-Identifier: GPL-2.0
  25.  
  26. -                 How To Write Linux PCI Drivers
  27. +==============================
  28. +How To Write Linux PCI Drivers
  29. +==============================
  30.  
  31. -           by Martin Mares <mj@ucw.cz> on 07-Feb-2000
  32. -     updated by Grant Grundler <grundler@parisc-linux.org> on 23-Dec-2006
  33. +:Authors: - Martin Mares <mj@ucw.cz>
  34. +          - Grant Grundler <grundler@parisc-linux.org>
  35.  
  36. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37.  The world of PCI is vast and full of (mostly unpleasant) surprises.
  38.  Since each CPU architecture implements different chip-sets and PCI devices
  39.  have different requirements (erm, "features"), the result is the PCI support
  40. @@ -26,8 +28,8 @@ Please send questions/comments/patches about Linux PCI API to the
  41.  
  42.  
  43.  
  44. -0. Structure of PCI drivers
  45. -~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. +Structure of PCI drivers
  47. +========================
  48.  PCI drivers "discover" PCI devices in a system via pci_register_driver().
  49.  Actually, it's the other way around. When the PCI generic code discovers
  50.  a new device, the driver with a matching "description" will be notified.
  51. @@ -42,24 +44,25 @@ pointers and thus dictates the high level structure of a driver.
  52.  Once the driver knows about a PCI device and takes ownership, the
  53.  driver generally needs to perform the following initialization:
  54.  
  55. -     Enable the device
  56. -     Request MMIO/IOP resources
  57. -     Set the DMA mask size (for both coherent and streaming DMA)
  58. -     Allocate and initialize shared control data (pci_allocate_coherent())
  59. -     Access device configuration space (if needed)
  60. -     Register IRQ handler (request_irq())
  61. -     Initialize non-PCI (i.e. LAN/SCSI/etc parts of the chip)
  62. -     Enable DMA/processing engines
  63. +  - Enable the device
  64. +  - Request MMIO/IOP resources
  65. +  - Set the DMA mask size (for both coherent and streaming DMA)
  66. +  - Allocate and initialize shared control data (pci_allocate_coherent())
  67. +  - Access device configuration space (if needed)
  68. +  - Register IRQ handler (request_irq())
  69. +  - Initialize non-PCI (i.e. LAN/SCSI/etc parts of the chip)
  70. +  - Enable DMA/processing engines
  71.  
  72.  When done using the device, and perhaps the module needs to be unloaded,
  73.  the driver needs to take the follow steps:
  74. -     Disable the device from generating IRQs
  75. -     Release the IRQ (free_irq())
  76. -     Stop all DMA activity
  77. -     Release DMA buffers (both streaming and coherent)
  78. -     Unregister from other subsystems (e.g. scsi or netdev)
  79. -     Release MMIO/IOP resources
  80. -     Disable the device
  81. +
  82. +  - Disable the device from generating IRQs
  83. +  - Release the IRQ (free_irq())
  84. +  - Stop all DMA activity
  85. +  - Release DMA buffers (both streaming and coherent)
  86. +  - Unregister from other subsystems (e.g. scsi or netdev)
  87. +  - Release MMIO/IOP resources
  88. +  - Disable the device
  89.  
  90.  Most of these topics are covered in the following sections.
  91.  For the rest look at LDD3 or <linux/pci.h> .
  92. @@ -70,13 +73,12 @@ completely empty or just returning an appropriate error codes to avoid
  93.  lots of ifdefs in the drivers.
  94.  
  95.  
  96. -
  97. -1. pci_register_driver() call
  98. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  99. +pci_register_driver() call
  100. +==========================
  101.  
  102.  PCI device drivers call pci_register_driver() during their
  103.  initialization with a pointer to a structure describing the driver
  104. -(struct pci_driver):
  105. +(struct pci_driver)::
  106.  
  107.       field name  Description
  108.       ----------  ------------------------------------------------------
  109. @@ -125,7 +127,7 @@ initialization with a pointer to a structure describing the driver
  110.  The ID table is an array of struct pci_device_id entries ending with an
  111.  all-zero entry.  Definitions with static const are generally preferred.
  112.  
  113. -Each entry consists of:
  114. +Each entry consists of::
  115.  
  116.       vendor,device     Vendor and device ID to match (or PCI_ANY_ID)
  117.  
  118. @@ -160,9 +162,10 @@ echo "vendor device subvendor subdevice class class_mask driver_data" > \
  119.  All fields are passed in as hexadecimal values (no leading 0x).
  120.  The vendor and device fields are mandatory, the others are optional. Users
  121.  need pass only as many optional fields as necessary:
  122. -     o subvendor and subdevice fields default to PCI_ANY_ID (FFFFFFFF)
  123. -     o class and classmask fields default to 0
  124. -     o driver_data defaults to 0UL.
  125. +
  126. +  - subvendor and subdevice fields default to PCI_ANY_ID (FFFFFFFF)
  127. +  - class and classmask fields default to 0
  128. +  - driver_data defaults to 0UL.
  129.  
  130.  Note that driver_data must match the value used by any of the pci_device_id
  131.  entries defined in the driver. This makes the driver_data field mandatory
  132. @@ -175,29 +178,30 @@ When the driver exits, it just calls pci_unregister_driver() and the PCI layer
  133.  automatically calls the remove hook for all devices handled by the driver.
  134.  
  135.  
  136. -1.1 "Attributes" for driver functions/data
  137. +"Attributes" for driver functions/data
  138. +--------------------------------------
  139.  
  140.  Please mark the initialization and cleanup functions where appropriate
  141. -(the corresponding macros are defined in <linux/init.h>):
  142. +(the corresponding macros are defined in <linux/init.h>)::
  143.  
  144.       __init            Initialization code. Thrown away after the driver
  145.                   initializes.
  146.       __exit            Exit code. Ignored for non-modular drivers.
  147.  
  148.  Tips on when/where to use the above attributes:
  149. -     o The module_init()/module_exit() functions (and all
  150. +     - The module_init()/module_exit() functions (and all
  151.         initialization functions called _only_ from these)
  152.         should be marked __init/__exit.
  153.  
  154. -     o Do not mark the struct pci_driver.
  155. +     - Do not mark the struct pci_driver.
  156.  
  157. -     o Do NOT mark a function if you are not sure which mark to use.
  158. +     - Do NOT mark a function if you are not sure which mark to use.
  159.         Better to not mark the function than mark the function wrong.
  160.  
  161.  
  162.  
  163. -2. How to find PCI devices manually
  164. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  165. +How to find PCI devices manually
  166. +================================
  167.  
  168.  PCI drivers should have a really good reason for not using the
  169.  pci_register_driver() interface to search for PCI devices.
  170. @@ -207,17 +211,17 @@ E.g. combined serial/parallel port/floppy controller.
  171.  
  172.  A manual search may be performed using the following constructs:
  173.  
  174. -Searching by vendor and device ID:
  175. +Searching by vendor and device ID::
  176.  
  177.       struct pci_dev *dev = NULL;
  178.       while (dev = pci_get_device(VENDOR_ID, DEVICE_ID, dev))
  179.             configure_device(dev);
  180.  
  181. -Searching by class ID (iterate in a similar way):
  182. +Searching by class ID (iterate in a similar way)::
  183.  
  184.       pci_get_class(CLASS_ID, dev)
  185.  
  186. -Searching by both vendor/device and subsystem vendor/device ID:
  187. +Searching by both vendor/device and subsystem vendor/device ID::
  188.  
  189.       pci_get_subsys(VENDOR_ID,DEVICE_ID, SUBSYS_VENDOR_ID, SUBSYS_DEVICE_ID, dev).
  190.  
  191. @@ -231,20 +235,20 @@ decrement the reference count on these devices by calling pci_dev_put().
  192.  
  193.  
  194.  
  195. -3. Device Initialization Steps
  196. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  197. +Device Initialization Steps
  198. +===========================
  199.  
  200.  As noted in the introduction, most PCI drivers need the following steps
  201.  for device initialization:
  202.  
  203. -     Enable the device
  204. -     Request MMIO/IOP resources
  205. -     Set the DMA mask size (for both coherent and streaming DMA)
  206. -     Allocate and initialize shared control data (pci_allocate_coherent())
  207. -     Access device configuration space (if needed)
  208. -     Register IRQ handler (request_irq())
  209. -     Initialize non-PCI (i.e. LAN/SCSI/etc parts of the chip)
  210. -     Enable DMA/processing engines.
  211. +  - Enable the device
  212. +  - Request MMIO/IOP resources
  213. +  - Set the DMA mask size (for both coherent and streaming DMA)
  214. +  - Allocate and initialize shared control data (pci_allocate_coherent())
  215. +  - Access device configuration space (if needed)
  216. +  - Register IRQ handler (request_irq())
  217. +  - Initialize non-PCI (i.e. LAN/SCSI/etc parts of the chip)
  218. +  - Enable DMA/processing engines.
  219.  
  220.  The driver can access PCI config space registers at any time.
  221.  (Well, almost. When running BIST, config space can go away...but
  222. @@ -252,17 +256,18 @@ that will just result in a PCI Bus Master Abort and config reads
  223.  will return garbage).
  224.  
  225.  
  226. -3.1 Enable the PCI device
  227. -~~~~~~~~~~~~~~~~~~~~~~~~~
  228. +Enable the PCI device
  229. +---------------------
  230.  Before touching any device registers, the driver needs to enable
  231.  the PCI device by calling pci_enable_device(). This will:
  232. -     o wake up the device if it was in suspended state,
  233. -     o allocate I/O and memory regions of the device (if BIOS did not),
  234. -     o allocate an IRQ (if BIOS did not).
  235.  
  236. -NOTE: pci_enable_device() can fail! Check the return value.
  237. +  - wake up the device if it was in suspended state,
  238. +  - allocate I/O and memory regions of the device (if BIOS did not),
  239. +  - allocate an IRQ (if BIOS did not).
  240. +
  241. +.. note:: pci_enable_device() can fail! Check the return value.
  242.  
  243. -[ OS BUG: we don't check resource allocations before enabling those
  244. +.. warning:: OS BUG: we don't check resource allocations before enabling those
  245.    resources. The sequence would make more sense if we called
  246.    pci_request_resources() before calling pci_enable_device().
  247.    Currently, the device drivers can't detect the bug when when two
  248. @@ -271,7 +276,7 @@ NOTE: pci_enable_device() can fail! Check the return value.
  249.  
  250.    This has been discussed before but not changed as of 2.6.19:
  251.       http://lkml.org/lkml/2006/3/2/194
  252. -]
  253. +
  254.  
  255.  pci_set_master() will enable DMA by setting the bus master bit
  256.  in the PCI_COMMAND register. It also fixes the latency timer value if
  257. @@ -288,8 +293,8 @@ pci_try_set_mwi() to have the system do its best effort at enabling
  258.  Mem-Wr-Inval.
  259.  
  260.  
  261. -3.2 Request MMIO/IOP resources
  262. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  263. +Request MMIO/IOP resources
  264. +--------------------------
  265.  Memory (MMIO), and I/O port addresses should NOT be read directly
  266.  from the PCI device config space. Use the values in the pci_dev structure
  267.  as the PCI "bus address" might have been remapped to a "host physical"
  268. @@ -304,9 +309,9 @@ Conversely, drivers should call pci_release_region() AFTER
  269.  calling pci_disable_device().
  270.  The idea is to prevent two devices colliding on the same address range.
  271.  
  272. -[ See OS BUG comment above. Currently (2.6.19), The driver can only
  273. +.. tip:: See OS BUG comment above. Currently (2.6.19), The driver can only
  274.    determine MMIO and IO Port resource availability _after_ calling
  275. -  pci_enable_device(). ]
  276. +  pci_enable_device().
  277.  
  278.  Generic flavors of pci_request_region() are request_mem_region()
  279.  (for MMIO ranges) and request_region() (for IO Port ranges).
  280. @@ -316,12 +321,12 @@ BARs.
  281.  Also see pci_request_selected_regions() below.
  282.  
  283.  
  284. -3.3 Set the DMA mask size
  285. -~~~~~~~~~~~~~~~~~~~~~~~~~
  286. -[ If anything below doesn't make sense, please refer to
  287. +Set the DMA mask size
  288. +---------------------
  289. +.. note:: If anything below doesn't make sense, please refer to
  290.    Documentation/DMA-API.txt. This section is just a reminder that
  291.    drivers need to indicate DMA capabilities of the device and is not
  292. -  an authoritative source for DMA interfaces. ]
  293. +  an authoritative source for DMA interfaces.
  294.  
  295.  While all drivers should explicitly indicate the DMA capability
  296.  (e.g. 32 or 64 bit) of the PCI bus master, devices with more than
  297. @@ -342,23 +347,23 @@ Many 64-bit "PCI" devices (before PCI-X) and some PCI-X devices are
  298.  ("consistent") data.
  299.  
  300.  
  301. -3.4 Setup shared control data
  302. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  303. +Setup shared control data
  304. +-------------------------
  305.  Once the DMA masks are set, the driver can allocate "consistent" (a.k.a. shared)
  306.  memory.  See Documentation/DMA-API.txt for a full description of
  307.  the DMA APIs. This section is just a reminder that it needs to be done
  308.  before enabling DMA on the device.
  309.  
  310.  
  311. -3.5 Initialize device registers
  312. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  313. +Initialize device registers
  314. +---------------------------
  315.  Some drivers will need specific "capability" fields programmed
  316.  or other "vendor specific" register initialized or reset.
  317.  E.g. clearing pending interrupts.
  318.  
  319.  
  320. -3.6 Register IRQ handler
  321. -~~~~~~~~~~~~~~~~~~~~~~~~
  322. +Register IRQ handler
  323. +--------------------
  324.  While calling request_irq() is the last step described here,
  325.  this is often just another intermediate step to initialize a device.
  326.  This step can often be deferred until the device is opened for use.
  327. @@ -396,6 +401,7 @@ and msix_enabled flags in the pci_dev structure after calling
  328.  pci_alloc_irq_vectors.
  329.  
  330.  There are (at least) two really good reasons for using MSI:
  331. +
  332.  1) MSI is an exclusive interrupt vector by definition.
  333.     This means the interrupt handler doesn't have to verify
  334.     its device caused the interrupt.
  335. @@ -411,23 +417,23 @@ of MSI/MSI-X usage.
  336.  
  337.  
  338.  
  339. -4. PCI device shutdown
  340. -~~~~~~~~~~~~~~~~~~~~~~~
  341. +PCI device shutdown
  342. +===================
  343.  
  344.  When a PCI device driver is being unloaded, most of the following
  345.  steps need to be performed:
  346.  
  347. -     Disable the device from generating IRQs
  348. -     Release the IRQ (free_irq())
  349. -     Stop all DMA activity
  350. -     Release DMA buffers (both streaming and consistent)
  351. -     Unregister from other subsystems (e.g. scsi or netdev)
  352. -     Disable device from responding to MMIO/IO Port addresses
  353. -     Release MMIO/IO Port resource(s)
  354. +  - Disable the device from generating IRQs
  355. +  - Release the IRQ (free_irq())
  356. +  - Stop all DMA activity
  357. +  - Release DMA buffers (both streaming and consistent)
  358. +  - Unregister from other subsystems (e.g. scsi or netdev)
  359. +  - Disable device from responding to MMIO/IO Port addresses
  360. +  - Release MMIO/IO Port resource(s)
  361.  
  362.  
  363. -4.1 Stop IRQs on the device
  364. -~~~~~~~~~~~~~~~~~~~~~~~~~~~
  365. +Stop IRQs on the device
  366. +-----------------------
  367.  How to do this is chip/device specific. If it's not done, it opens
  368.  the possibility of a "screaming interrupt" if (and only if)
  369.  the IRQ is shared with another device.
  370. @@ -446,16 +452,16 @@ MSI and MSI-X are defined to be exclusive interrupts and thus
  371.  are not susceptible to the "screaming interrupt" problem.
  372.  
  373.  
  374. -4.2 Release the IRQ
  375. -~~~~~~~~~~~~~~~~~~~
  376. +Release the IRQ
  377. +---------------
  378.  Once the device is quiesced (no more IRQs), one can call free_irq().
  379.  This function will return control once any pending IRQs are handled,
  380.  "unhook" the drivers IRQ handler from that IRQ, and finally release
  381.  the IRQ if no one else is using it.
  382.  
  383.  
  384. -4.3 Stop all DMA activity
  385. -~~~~~~~~~~~~~~~~~~~~~~~~~
  386. +Stop all DMA activity
  387. +---------------------
  388.  It's extremely important to stop all DMA operations BEFORE attempting
  389.  to deallocate DMA control data. Failure to do so can result in memory
  390.  corruption, hangs, and on some chip-sets a hard crash.
  391. @@ -467,8 +473,8 @@ While this step sounds obvious and trivial, several "mature" drivers
  392.  didn't get this step right in the past.
  393.  
  394.  
  395. -4.4 Release DMA buffers
  396. -~~~~~~~~~~~~~~~~~~~~~~~
  397. +Release DMA buffers
  398. +-------------------
  399.  Once DMA is stopped, clean up streaming DMA first.
  400.  I.e. unmap data buffers and return buffers to "upstream"
  401.  owners if there is one.
  402. @@ -478,8 +484,8 @@ Then clean up "consistent" buffers which contain the control data.
  403.  See Documentation/DMA-API.txt for details on unmapping interfaces.
  404.  
  405.  
  406. -4.5 Unregister from other subsystems
  407. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  408. +Unregister from other subsystems
  409. +--------------------------------
  410.  Most low level PCI device drivers support some other subsystem
  411.  like USB, ALSA, SCSI, NetDev, Infiniband, etc. Make sure your
  412.  driver isn't losing resources from that other subsystem.
  413. @@ -487,31 +493,31 @@ If this happens, typically the symptom is an Oops (panic) when
  414.  the subsystem attempts to call into a driver that has been unloaded.
  415.  
  416.  
  417. -4.6 Disable Device from responding to MMIO/IO Port addresses
  418. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  419. +Disable Device from responding to MMIO/IO Port addresses
  420. +--------------------------------------------------------
  421.  io_unmap() MMIO or IO Port resources and then call pci_disable_device().
  422.  This is the symmetric opposite of pci_enable_device().
  423.  Do not access device registers after calling pci_disable_device().
  424.  
  425.  
  426. -4.7 Release MMIO/IO Port Resource(s)
  427. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  428. +Release MMIO/IO Port Resource(s)
  429. +--------------------------------
  430.  Call pci_release_region() to mark the MMIO or IO Port range as available.
  431.  Failure to do so usually results in the inability to reload the driver.
  432.  
  433.  
  434.  
  435. -5. How to access PCI config space
  436. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  437. +How to access PCI config space
  438. +==============================
  439.  
  440. -You can use pci_(read|write)_config_(byte|word|dword) to access the config
  441. -space of a device represented by struct pci_dev *. All these functions return 0
  442. -when successful or an error code (PCIBIOS_...) which can be translated to a text
  443. -string by pcibios_strerror. Most drivers expect that accesses to valid PCI
  444. +You can use `pci_(read|write)_config_(byte|word|dword)` to access the config
  445. +space of a device represented by `struct pci_dev *`. All these functions return
  446. +0 when successful or an error code (`PCIBIOS_...`) which can be translated to a
  447. +text string by pcibios_strerror. Most drivers expect that accesses to valid PCI
  448.  devices don't fail.
  449.  
  450.  If you don't have a struct pci_dev available, you can call
  451. -pci_bus_(read|write)_config_(byte|word|dword) to access a given device
  452. +`pci_bus_(read|write)_config_(byte|word|dword)` to access a given device
  453.  and function on that bus.
  454.  
  455.  If you access fields in the standard portion of the config header, please
  456. @@ -522,28 +528,29 @@ pci_find_capability() for the particular capability and it will find the
  457.  corresponding register block for you.
  458.  
  459.  
  460. +Other interesting functions
  461. +===========================
  462.  
  463. -6. Other interesting functions
  464. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  465. +::
  466.  
  467. -pci_get_domain_bus_and_slot()      Find pci_dev corresponding to given domain,
  468. -                       bus and slot and number. If the device is
  469. -                       found, its reference count is increased.
  470. -pci_set_power_state()        Set PCI Power Management state (0=D0 ... 3=D3)
  471. -pci_find_capability()        Find specified capability in device's capability
  472. +  pci_get_domain_bus_and_slot()    Find pci_dev corresponding to given domain,
  473. +                       bus and slot and number. If the device is
  474. +                       found, its reference count is increased.
  475. +  pci_set_power_state()            Set PCI Power Management state (0=D0 ... 3=D3)
  476. +  pci_find_capability()            Find specified capability in device's capability
  477.                         list.
  478. -pci_resource_start()         Returns bus start address for a given PCI region
  479. -pci_resource_end()           Returns bus end address for a given PCI region
  480. -pci_resource_len()           Returns the byte length of a PCI region
  481. -pci_set_drvdata()            Set private driver data pointer for a pci_dev
  482. -pci_get_drvdata()            Return private driver data pointer for a pci_dev
  483. -pci_set_mwi()                Enable Memory-Write-Invalidate transactions.
  484. -pci_clear_mwi()              Disable Memory-Write-Invalidate transactions.
  485. +  pci_resource_start()       Returns bus start address for a given PCI region
  486. +  pci_resource_end()         Returns bus end address for a given PCI region
  487. +  pci_resource_len()         Returns the byte length of a PCI region
  488. +  pci_set_drvdata()          Set private driver data pointer for a pci_dev
  489. +  pci_get_drvdata()          Return private driver data pointer for a pci_dev
  490. +  pci_set_mwi()              Enable Memory-Write-Invalidate transactions.
  491. +  pci_clear_mwi()                  Disable Memory-Write-Invalidate transactions.
  492.  
  493.  
  494.  
  495. -7. Miscellaneous hints
  496. -~~~~~~~~~~~~~~~~~~~~~~
  497. +Miscellaneous hints
  498. +===================
  499.  
  500.  When displaying PCI device names to the user (for example when a driver wants
  501.  to tell the user what card has it found), please use pci_name(pci_dev).
  502. @@ -560,8 +567,8 @@ to be handled by platform and generic code, not individual drivers.
  503.  
  504.  
  505.  
  506. -8. Vendor and device identifications
  507. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  508. +Vendor and device identifications
  509. +=================================
  510.  
  511.  Do not add new device or vendor IDs to include/linux/pci_ids.h unless they
  512.  are shared across multiple drivers.  You can add private definitions in
  513. @@ -576,18 +583,20 @@ and https://github.com/pciutils/pciids.
  514.  
  515.  
  516.  
  517. -9. Obsolete functions
  518. -~~~~~~~~~~~~~~~~~~~~~
  519. +Obsolete functions
  520. +==================
  521.  
  522.  There are several functions which you might come across when trying to
  523.  port an old driver to the new PCI interface.  They are no longer present
  524.  in the kernel as they aren't compatible with hotplug or PCI domains or
  525.  having sane locking.
  526.  
  527. -pci_find_device()      Superseded by pci_get_device()
  528. -pci_find_subsys()      Superseded by pci_get_subsys()
  529. -pci_find_slot()        Superseded by pci_get_domain_bus_and_slot()
  530. -pci_get_slot()         Superseded by pci_get_domain_bus_and_slot()
  531. +::
  532. +
  533. +  pci_find_device()    Superseded by pci_get_device()
  534. +  pci_find_subsys()    Superseded by pci_get_subsys()
  535. +  pci_find_slot()      Superseded by pci_get_domain_bus_and_slot()
  536. +  pci_get_slot() Superseded by pci_get_domain_bus_and_slot()
  537.  
  538.  
  539.  The alternative is the traditional PCI device driver that walks PCI
  540. @@ -595,8 +604,8 @@ device lists. This is still possible but discouraged.
  541.  
  542.  
  543.  
  544. -10. MMIO Space and "Write Posting"
  545. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  546. +MMIO Space and "Write Posting"
  547. +==============================
  548.  
  549.  Converting a driver from using I/O Port space to using MMIO space
  550.  often requires some additional changes. Specifically, "write posting"
  551. @@ -609,14 +618,14 @@ the CPU before the transaction has reached its destination.
  552.  
  553.  Thus, timing sensitive code should add readl() where the CPU is
  554.  expected to wait before doing other work.  The classic "bit banging"
  555. -sequence works fine for I/O Port space:
  556. +sequence works fine for I/O Port space::
  557.  
  558.         for (i = 8; --i; val >>= 1) {
  559.                 outb(val & 1, ioport_reg);      /* write bit */
  560.                 udelay(10);
  561.         }
  562.  
  563. -The same sequence for MMIO space should be:
  564. +The same sequence for MMIO space should be::
  565.  
  566.         for (i = 8; --i; val >>= 1) {
  567.                 writeb(val & 1, mmio_reg);      /* write bit */
  568. --
  569. 2.20.1

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.