PCI PCIe portdrv: Add kerneldoc comments to some core functions
PATCH 1/4 PCI PCIe portdrv: Add kerneldoc comments to some core functions
In reply to a message not in the archiveAdd kerneldoc comments to some functions in drivers/pci/pcie/portdrv_core.c, since the code in there is not easy to follow without any additional description.
--- drivers/pci/pcie/portdrv_core.c | 77 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 7 deletions(-)
drivers/pci/pcie/portdrv_core.c +70 -7
@@ -94,12 +94,12 @@ static int pcie_port_resume_service(strureturn 0 ; } -/* -* release_pcie_device -* -* Being invoked automatically when device is being removed -* in response to device_unregister(dev) call. -* Release all resources being claimed. +/** +* release_pcie_device - free PCI Express port service device structure +* @dev: Port service device to release +* +* Invoked automatically when device is being removed in response to +* device_unregister(dev). Release all resources being claimed. */ static void release_pcie_device (struct device *dev) {
@@ -128,7 +128,16 @@ static int is_msi_quirked(struct pci_dev }return quirk; } - + +/** +* assign_interrupt_mode - choose interrupt mode for PCI Express port services +* (INTx, MSI-X, MSI) and set up vectors +* @dev: PCI Express port to handle +* @vectors: Array of interrupt vectors to populate +* @mask: Bitmask of port capabilities returned by get_port_device_capability() +* +* Return value: Interrupt mode associated with the port +*/ static int assign_interrupt_mode (struct pci_dev *dev,int *vectors,int mask) {int i, pos, nvec, status = -EINVAL ;
@@ -177,6 +186,16 @@ static int assign_interrupt_mode(structreturn interrupt_mode; } +/** +* get_port_device_capability - discover capabilities of a PCI Express port +* @dev: PCI Express port to examine +* +* The capabilities are read from the port's PCI Express configuration registers +* as described in PCI Express Base Specification 1.0a sections 7.8.2, 7.8.9 and +* 7.9 - 7.11. +* +* Return value: Bitmask of discovered port capabilities +*/ static int get_port_device_capability (struct pci_dev *dev) {int services =0 , pos;
@@ -204,6 +223,15 @@ static int get_port_device_capability(streturn services; } +/** +* pcie_device_init - initialize PCI Express port service device +* @dev: Port service device to initialize +* @parent: PCI Express port to associate the service device with +* @port_type: Type of the port +* @service_type: Type of service to associate with the service device +* @irq: Interrupt vector to associate with the service device +* @irq_mode: Interrupt mode of the service (INTx, MSI-X, MSI) +*/ static void pcie_device_init (struct pci_dev *parent,struct pcie_device *dev,int port_type,int service_type,int irq,int irq_mode) {
@@ -229,6 +257,14 @@ static void pcie_device_init(struct pci_ device->parent = &parent->dev; } +/** +* alloc_pcie_device - allocate PCI Express port service device structure +* @parent: PCI Express port to associate the service device with +* @port_type: Type of the port +* @service_type: Type of service to associate with the service device +* @irq: Interrupt vector to associate with the service device +* @irq_mode: Interrupt mode of the service (INTx, MSI-X, MSI) +*/ static struct pcie_device *alloc_pcie_device (struct pci_dev *parent,int port_type,int service_type,int irq,int irq_mode) {
@@ -243,6 +279,10 @@ static struct pcie_device* alloc_pcie_dereturn device; } +/** +* pcie_port_device_probe - check if device is a PCI Express port +* @dev: Device to check +*/ int pcie_port_device_probe (struct pci_dev *dev) {int pos, type;
@@ -260,6 +300,13 @@ int pcie_port_device_probe(struct pci_dereturn -ENODEV ; } +/** +* pcie_port_device_register - register PCI Express port +* @dev: PCI Express port to register +* +* Allocate the port extension structure and register services associated with +* the port. +*/ int pcie_port_device_register (struct pci_dev *dev) {struct pcie_port_device_ext *p_ext;
@@ -323,6 +370,11 @@ static int suspend_iter(struct device *dreturn 0 ; } +/** +* pcie_port_device_suspend - suspend port services associated with a PCIe port +* @dev: PCI Express port to handle +* @state: Representation of system power management transition in progress +*/ int pcie_port_device_suspend (struct pci_dev *dev,pm_message_t state) {return device_for_each_child (&dev->dev, &state, suspend_iter);
@@ -341,6 +393,10 @@ static int resume_iter(struct device *dereturn 0 ; } +/** +* pcie_port_device_suspend - resume port services associated with a PCIe port +* @dev: PCI Express port to handle +*/ int pcie_port_device_resume (struct pci_dev *dev) {return device_for_each_child (&dev->dev,NULL , resume_iter);
@@ -363,6 +419,13 @@ static int remove_iter(struct device *dereturn 0 ; } +/** +* pcie_port_device_remove - unregister PCI Express port service devices +* @dev: PCI Express port the service devices to unregister are associated with +* +* Remove PCI Express port service devices associated with given port and +* disable MSI-X or MSI for the port. +*/ void pcie_port_device_remove (struct pci_dev *dev) {struct device *device;
PATCH 2/4 PCI PCIe portdrv: Fix suspend and resume of PCI Express port services
In reply to a message not in the archiveThere is a problem with the suspend and resume of PCI Express port service devices that the ->suspend() and ->resume() routines of each service device are called twice in each suspend-resume cycle, which is obviously wrong.
The scenario is that first, the PCI Express port driver calls suspend and resume routines of each port service driver from its pcie_portdrv_suspend() and pcie_portdrv_resume() callbacks, respectively (which is correct), and second, the pcie_port_bus_type driver calls them from its ->suspend() and ->resume() callbacks (which is not correct, because it doesn't happen at the right time).
The solution is to remove the ->suspend() and ->resume() callbacks from pcie_port_bus_type and the associated functions.
--- drivers/pci/pcie/portdrv_bus.c | 34 ---------------------------------- drivers/pci/pcie/portdrv_core.c | 33 --------------------------------- 2 files changed, 67 deletions(-)
drivers/pci/pcie/portdrv_bus.c +0 -34
@@ -16,14 +16,10 @@#include "portdrv.h" static int pcie_port_bus_match (struct device *dev,struct device_driver *drv); -static int pcie_port_bus_suspend (struct device *dev,pm_message_t state); -static int pcie_port_bus_resume (struct device *dev);struct bus_type pcie_port_bus_type = { .name ="pci_express" , .match = pcie_port_bus_match, - .suspend = pcie_port_bus_suspend, - .resume = pcie_port_bus_resume, };EXPORT_SYMBOL_GPL (pcie_port_bus_type);
@@ -48,33 +44,3 @@ static int pcie_port_bus_match(struct dereturn 1 ; } - -static int pcie_port_bus_suspend (struct device *dev,pm_message_t state) -{ -struct pcie_device *pciedev; -struct pcie_port_service_driver *driver; - -if (!dev || !dev->driver) -return 0 ; - - pciedev =to_pcie_device (dev); - driver =to_service_driver (dev->driver); -if (driver && driver->suspend) - driver->suspend (pciedev, state); -return 0 ; -} - -static int pcie_port_bus_resume (struct device *dev) -{ -struct pcie_device *pciedev; -struct pcie_port_service_driver *driver; - -if (!dev || !dev->driver) -return 0 ; - - pciedev =to_pcie_device (dev); - driver =to_service_driver (dev->driver); -if (driver && driver->resume) - driver->resume (pciedev); -return 0 ; -}
drivers/pci/pcie/portdrv_core.c +0 -33
@@ -63,37 +63,6 @@ static int pcie_port_remove_service(strustatic void pcie_port_shutdown_service (struct device *dev) {} -static int pcie_port_suspend_service (struct device *dev,pm_message_t state) -{ -struct pcie_device *pciedev; -struct pcie_port_service_driver *driver; - -if (!dev || !dev->driver) -return 0 ; - - pciedev =to_pcie_device (dev); - driver =to_service_driver (dev->driver); -if (driver && driver->suspend) - driver->suspend (pciedev, state); -return 0 ; -} - -static int pcie_port_resume_service (struct device *dev) -{ -struct pcie_device *pciedev; -struct pcie_port_service_driver *driver; - -if (!dev || !dev->driver) -return 0 ; - - pciedev =to_pcie_device (dev); - driver =to_service_driver (dev->driver); - -if (driver && driver->resume) - driver->resume (pciedev); -return 0 ; -} -/** * release_pcie_device - free PCI Express port service device structure * @dev: Port service device to release
@@ -466,8 +435,6 @@ int pcie_port_service_register(struct pc new->driver.probe = pcie_port_probe_service; new->driver.remove = pcie_port_remove_service; new->driver.shutdown = pcie_port_shutdown_service; - new->driver.suspend = pcie_port_suspend_service; - new->driver.resume = pcie_port_resume_service;return driver_register (&new->driver); }
PATCH 3/4 PCI PCIe portdrv: Rearrange code so that related things are together
In reply to a message not in the archiveRearrange code in drivers/pci/pcie/portdrv_bus.c and drivers/pci/pcie/portdrv_core.c so that related functions and data structures are closer together.
--- drivers/pci/pcie/portdrv_bus.c | 10 ++++ drivers/pci/pcie/portdrv_core.c | 90 +++++++++++++++++----------------------- 2 files changed, 50 insertions(+), 50 deletions(-)
drivers/pci/pcie/portdrv_bus.c +10 -0
@@ -44,3 +44,13 @@ static int pcie_port_bus_match(struct dereturn 1 ; } + +int pcie_port_bus_register (void ) +{ +return bus_register (&pcie_port_bus_type); +} + +void pcie_port_bus_unregister (void ) +{ +bus_unregister (&pcie_port_bus_type); +}
drivers/pci/pcie/portdrv_core.c +40 -50
115 lines not on this page · raw message
PATCH 4/4 PCI PCIe portdrv: Add kerneldoc comments to remining core funtions
In reply to a message not in the archiveAdd kerneldoc comments to the reamining functions in drivers/pci/pcie/portdrv_core.c .
--- drivers/pci/pcie/portdrv_core.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/pci/pcie/portdrv_core.c +34 -0
@@ -374,6 +374,14 @@ void pcie_port_device_remove(struct pci_pci_disable_msi (dev); } +/** +* pcie_port_probe_service - probe driver for given PCI Express port service +* @dev: PCI Express port service device to probe against +* +* If PCI Express port service driver is registered with +* pcie_port_service_register(), this function will be called by the driver core +* whenever match is found between the driver and a port service device. +*/ static int pcie_port_probe_service (struct device *dev) {struct pcie_device *pciedev;
@@ -397,6 +405,15 @@ static int pcie_port_probe_service(strucreturn status; } +/** +* pcie_port_remove_service - detach driver from given PCI Express port service +* @dev: PCI Express port service device to handle +* +* If PCI Express port service driver is registered with +* pcie_port_service_register(), this function will be called by the driver core +* when device_unregister() is called for the port service device associated +* with the driver. +*/ static int pcie_port_remove_service (struct device *dev) {struct pcie_device *pciedev;
@@ -416,8 +433,21 @@ static int pcie_port_remove_service(strureturn 0 ; } +/** +* pcie_port_shutdown_service - shut down given PCI Express port service +* @dev: PCI Express port service device to handle +* +* If PCI Express port service driver is registered with +* pcie_port_service_register(), this function will be called by the driver core +* when device_shutdown() is called for the port service device associated +* with the driver. +*/ static void pcie_port_shutdown_service (struct device *dev) {} +/** +* pcie_port_service_register - register PCI Express port service driver +* @new: PCI Express port service driver to register +*/ int pcie_port_service_register (struct pcie_port_service_driver *new) { new->driver.name = (char *)new->name;
@@ -429,6 +459,10 @@ int pcie_port_service_register(struct pcreturn driver_register (&new->driver); } +/** +* pcie_port_service_unregister - unregister PCI Express port service driver +* @drv: PCI Express port service driver to unregister +*/ void pcie_port_service_unregister (struct pcie_port_service_driver *drv) {driver_unregister (&drv->driver);
Quoted 5 lines · Rafael J. Wysocki
Add kerneldoc comments to some functions in
drivers/pci/pcie/portdrv_core.c, since the code in there is not easy to follow without any additional description.Signed-off-by Rafael J. Wysocki <[email protected]>
Ok, applied these ones, thanks.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center