Message ID | 6319e6d0b39b58552dcfb1c111b6ec45a5ca6bf8.1664276646.git.robin.murphy@arm.com |
---|---|
State | Superseded, archived |
Headers | show |
Series | of: Fix "dma-ranges" handling for bus controllers | expand |
Context | Check | Description |
---|---|---|
robh/checkpatch | warning | total: 0 errors, 1 warnings, 45 lines checked |
robh/patch-applied | fail | build log |
Hi Robin, I love your patch! Yet something to improve: [auto build test ERROR on robh/for-next] [also build test ERROR on linus/master v6.0-rc7 next-20220927] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Robin-Murphy/of-Fix-dma-ranges-handling-for-bus-controllers/20220927-190806 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next config: sh-allmodconfig compiler: sh4-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/fd09e551a6765fd2ac8d16595f436ba95284cdf6 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Robin-Murphy/of-Fix-dma-ranges-handling-for-bus-controllers/20220927-190806 git checkout fd09e551a6765fd2ac8d16595f436ba95284cdf6 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> drivers/of/address.c:582:21: error: redefinition of '__of_get_dma_parent' 582 | struct device_node *__of_get_dma_parent(const struct device_node *np) | ^~~~~~~~~~~~~~~~~~~ In file included from drivers/of/address.c:18: drivers/of/of_private.h:165:35: note: previous definition of '__of_get_dma_parent' with type 'struct device_node *(const struct device_node *)' 165 | static inline struct device_node *__of_get_dma_parent(const struct device_node *np) | ^~~~~~~~~~~~~~~~~~~ vim +/__of_get_dma_parent +582 drivers/of/address.c 581 > 582 struct device_node *__of_get_dma_parent(const struct device_node *np) 583 { 584 struct of_phandle_args args; 585 int ret, index; 586 587 index = of_property_match_string(np, "interconnect-names", "dma-mem"); 588 if (index < 0) 589 return of_get_parent(np); 590 591 ret = of_parse_phandle_with_args(np, "interconnects", 592 "#interconnect-cells", 593 index, &args); 594 if (ret < 0) 595 return of_get_parent(np); 596 597 return of_node_get(args.np); 598 } 599
diff --git a/drivers/of/address.c b/drivers/of/address.c index 96f0a12e507c..497bb64e338b 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -579,7 +579,7 @@ u64 of_translate_address(struct device_node *dev, const __be32 *in_addr) } EXPORT_SYMBOL(of_translate_address); -static struct device_node *__of_get_dma_parent(const struct device_node *np) +struct device_node *__of_get_dma_parent(const struct device_node *np) { struct of_phandle_args args; int ret, index; diff --git a/drivers/of/device.c b/drivers/of/device.c index 75b6cbffa755..8cefe5a7d04e 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -116,12 +116,19 @@ int of_dma_configure_id(struct device *dev, struct device_node *np, { const struct iommu_ops *iommu; const struct bus_dma_region *map = NULL; + struct device_node *bus_np; u64 dma_start = 0; u64 mask, end, size = 0; bool coherent; int ret; - ret = of_dma_get_range(np, &map); + if (np == dev->of_node) + bus_np = __of_get_dma_parent(np); + else + bus_np = of_node_get(np); + + ret = of_dma_get_range(bus_np, &map); + of_node_put(bus_np); if (ret < 0) { /* * For legacy reasons, we have to assume some devices need diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 9324483397f6..fb6792d381a6 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -155,12 +155,17 @@ struct bus_dma_region; #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_HAS_DMA) int of_dma_get_range(struct device_node *np, const struct bus_dma_region **map); +struct device_node *__of_get_dma_parent(const struct device_node *np); #else static inline int of_dma_get_range(struct device_node *np, const struct bus_dma_region **map) { return -ENODEV; } +static inline struct device_node *__of_get_dma_parent(const struct device_node *np) +{ + return of_get_parent(np); +} #endif void fdt_init_reserved_mem(void);
Commit 951d48855d86 ("of: Make of_dma_get_range() work on bus nodes") relaxed the handling of "dma-ranges" for any leaf node on the assumption that it would still represent a usage error for the property to be present on a non-bus leaf node. However there turns out to be a fiddly case where a bus also represents a DMA-capable device in its own right, such as a PCIe root complex with an integrated DMA engine on its platform side. In such cases, "dma-ranges" translation is entirely valid for devices discovered behind the bus, but should not be erroneously applied to the bus controller device itself which operates in its parent's address space. Fix this by restoring the previous behaviour for the specific case where a device is configured via its own OF node, since it is logical to assume that a device should never represent its own parent bus. Reported-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Signed-off-by: Robin Murphy <robin.murphy@arm.com> --- drivers/of/address.c | 2 +- drivers/of/device.c | 9 ++++++++- drivers/of/of_private.h | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-)