Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of/pci: Add of_pci_dma_configure() to update DMA configuration

Add of_pci_dma_configure() to allow updating the DMA configuration of the
PCI device using the configuration from DT of the parent of the root bridge
device. Use the newly added APIs pci_get/put_host_bridge_device() for
implementing this.

[bhelgaas: fold in fix for host bridges with no parent OF device]
Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> (AMD Seattle)
Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Rob Herring <robh+dt@kernel.org>
Acked-by: Will Deacon <will.deacon@arm.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: Grant Likely <grant.likely@linaro.org>
CC: Russell King <linux@arm.linux.org.uk>
CC: Arnd Bergmann <arnd@arndb.de>

authored by

Murali Karicheri and committed by
Bjorn Helgaas
c49b8fc2 6675a601

+24
+21
drivers/of/of_pci.c
··· 2 2 #include <linux/export.h> 3 3 #include <linux/of.h> 4 4 #include <linux/of_address.h> 5 + #include <linux/of_device.h> 5 6 #include <linux/of_pci.h> 6 7 #include <linux/slab.h> 7 8 ··· 116 115 return domain; 117 116 } 118 117 EXPORT_SYMBOL_GPL(of_get_pci_domain_nr); 118 + 119 + /** 120 + * of_pci_dma_configure - Setup DMA configuration 121 + * @dev: ptr to pci_dev struct of the PCI device 122 + * 123 + * Function to update PCI devices's DMA configuration using the same 124 + * info from the OF node of host bridge's parent (if any). 125 + */ 126 + void of_pci_dma_configure(struct pci_dev *pci_dev) 127 + { 128 + struct device *dev = &pci_dev->dev; 129 + struct device *bridge = pci_get_host_bridge_device(pci_dev); 130 + 131 + if (!bridge->parent) 132 + return; 133 + 134 + of_dma_configure(dev, bridge->parent->of_node); 135 + pci_put_host_bridge_device(bridge); 136 + } 137 + EXPORT_SYMBOL_GPL(of_pci_dma_configure); 119 138 120 139 #if defined(CONFIG_OF_ADDRESS) 121 140 /**
+3
include/linux/of_pci.h
··· 16 16 int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); 17 17 int of_pci_parse_bus_range(struct device_node *node, struct resource *res); 18 18 int of_get_pci_domain_nr(struct device_node *node); 19 + void of_pci_dma_configure(struct pci_dev *pci_dev); 19 20 #else 20 21 static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) 21 22 { ··· 51 50 { 52 51 return -1; 53 52 } 53 + 54 + static inline void of_pci_dma_configure(struct pci_dev *pci_dev) { } 54 55 #endif 55 56 56 57 #if defined(CONFIG_OF_ADDRESS)