From: Will Deacon <will@kernel.org> To: linux-kernel@vger.kernel.org Cc: iommu@lists.linux-foundation.org, Will Deacon <will@kernel.org>, Claire Chang <tientzu@chromium.org>, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>, Robin Murphy <robin.murphy@arm.com>, Christoph Hellwig <hch@lst.de>, Rob Herring <robh+dt@kernel.org> Subject: [PATCH] of: restricted dma: Don't fail device probe on rmem init failure Date: Thu, 5 Aug 2021 10:47:36 +0100 [thread overview] Message-ID: <20210805094736.902-1-will@kernel.org> (raw) If CONFIG_DMA_RESTRICTED_POOL=n then probing a device with a reference to a "restricted-dma-pool" will fail with a reasonably cryptic error: | pci-host-generic: probe of 10000.pci failed with error -22 Print a more helpful message in this case and try to continue probing the device as we do if the kernel doesn't have the restricted DMA patches applied or either CONFIG_OF_ADDRESS or CONFIG_HAS_DMA =n. Cc: Claire Chang <tientzu@chromium.org> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Rob Herring <robh+dt@kernel.org> Signed-off-by: Will Deacon <will@kernel.org> --- drivers/of/address.c | 8 ++++---- drivers/of/device.c | 2 +- drivers/of/of_private.h | 8 +++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 973257434398..f6bf4b423c2a 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -997,7 +997,7 @@ int of_dma_get_range(struct device_node *np, const struct bus_dma_region **map) return ret; } -int of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) +void of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) { struct device_node *node, *of_node = dev->of_node; int count, i; @@ -1022,11 +1022,11 @@ int of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) */ if (of_device_is_compatible(node, "restricted-dma-pool") && of_device_is_available(node)) - return of_reserved_mem_device_init_by_idx(dev, of_node, - i); + break; } - return 0; + if (i != count && of_reserved_mem_device_init_by_idx(dev, of_node, i)) + dev_warn(dev, "failed to initialise \"restricted-dma-pool\" memory node\n"); } #endif /* CONFIG_HAS_DMA */ diff --git a/drivers/of/device.c b/drivers/of/device.c index 2defdca418ec..258a2b099410 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -166,7 +166,7 @@ int of_dma_configure_id(struct device *dev, struct device_node *np, arch_setup_dma_ops(dev, dma_start, size, iommu, coherent); if (!iommu) - return of_dma_set_restricted_buffer(dev, np); + of_dma_set_restricted_buffer(dev, np); return 0; } diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index f557bd22b0cf..bc883f69496b 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -163,18 +163,16 @@ 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); -int of_dma_set_restricted_buffer(struct device *dev, struct device_node *np); +void of_dma_set_restricted_buffer(struct device *dev, 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 int of_dma_set_restricted_buffer(struct device *dev, - struct device_node *np) +static inline void of_dma_set_restricted_buffer(struct device *dev, + struct device_node *np) { - /* Do nothing, successfully. */ - return 0; } #endif -- 2.32.0.605.g8dce9f2422-goog
WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will@kernel.org> To: linux-kernel@vger.kernel.org Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>, Robin Murphy <robin.murphy@arm.com>, iommu@lists.linux-foundation.org, Rob Herring <robh+dt@kernel.org>, Claire Chang <tientzu@chromium.org>, Will Deacon <will@kernel.org>, Christoph Hellwig <hch@lst.de> Subject: [PATCH] of: restricted dma: Don't fail device probe on rmem init failure Date: Thu, 5 Aug 2021 10:47:36 +0100 [thread overview] Message-ID: <20210805094736.902-1-will@kernel.org> (raw) If CONFIG_DMA_RESTRICTED_POOL=n then probing a device with a reference to a "restricted-dma-pool" will fail with a reasonably cryptic error: | pci-host-generic: probe of 10000.pci failed with error -22 Print a more helpful message in this case and try to continue probing the device as we do if the kernel doesn't have the restricted DMA patches applied or either CONFIG_OF_ADDRESS or CONFIG_HAS_DMA =n. Cc: Claire Chang <tientzu@chromium.org> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Rob Herring <robh+dt@kernel.org> Signed-off-by: Will Deacon <will@kernel.org> --- drivers/of/address.c | 8 ++++---- drivers/of/device.c | 2 +- drivers/of/of_private.h | 8 +++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 973257434398..f6bf4b423c2a 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -997,7 +997,7 @@ int of_dma_get_range(struct device_node *np, const struct bus_dma_region **map) return ret; } -int of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) +void of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) { struct device_node *node, *of_node = dev->of_node; int count, i; @@ -1022,11 +1022,11 @@ int of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) */ if (of_device_is_compatible(node, "restricted-dma-pool") && of_device_is_available(node)) - return of_reserved_mem_device_init_by_idx(dev, of_node, - i); + break; } - return 0; + if (i != count && of_reserved_mem_device_init_by_idx(dev, of_node, i)) + dev_warn(dev, "failed to initialise \"restricted-dma-pool\" memory node\n"); } #endif /* CONFIG_HAS_DMA */ diff --git a/drivers/of/device.c b/drivers/of/device.c index 2defdca418ec..258a2b099410 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -166,7 +166,7 @@ int of_dma_configure_id(struct device *dev, struct device_node *np, arch_setup_dma_ops(dev, dma_start, size, iommu, coherent); if (!iommu) - return of_dma_set_restricted_buffer(dev, np); + of_dma_set_restricted_buffer(dev, np); return 0; } diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index f557bd22b0cf..bc883f69496b 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -163,18 +163,16 @@ 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); -int of_dma_set_restricted_buffer(struct device *dev, struct device_node *np); +void of_dma_set_restricted_buffer(struct device *dev, 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 int of_dma_set_restricted_buffer(struct device *dev, - struct device_node *np) +static inline void of_dma_set_restricted_buffer(struct device *dev, + struct device_node *np) { - /* Do nothing, successfully. */ - return 0; } #endif -- 2.32.0.605.g8dce9f2422-goog _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next reply other threads:[~2021-08-05 9:47 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-05 9:47 Will Deacon [this message] 2021-08-05 9:47 ` [PATCH] of: restricted dma: Don't fail device probe on rmem init failure Will Deacon 2021-08-05 10:26 ` Robin Murphy 2021-08-05 10:26 ` Robin Murphy 2021-08-06 11:41 ` Will Deacon 2021-08-06 11:41 ` Will Deacon 2021-08-06 14:11 ` Rob Herring 2021-08-06 14:11 ` Rob Herring 2021-08-06 11:31 [PATCH 0/4] Fix racing TLBI with ASID/VMID reallocation Will Deacon 2021-08-06 11:31 ` [PATCH] of: restricted dma: Don't fail device probe on rmem init failure Will Deacon 2021-08-06 11:31 ` Will Deacon 2021-08-06 11:31 ` Will Deacon 2021-08-06 11:34 ` Will Deacon 2021-08-06 11:34 ` Will Deacon 2021-08-06 11:34 ` Will Deacon
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210805094736.902-1-will@kernel.org \ --to=will@kernel.org \ --cc=hch@lst.de \ --cc=iommu@lists.linux-foundation.org \ --cc=konrad.wilk@oracle.com \ --cc=linux-kernel@vger.kernel.org \ --cc=robh+dt@kernel.org \ --cc=robin.murphy@arm.com \ --cc=tientzu@chromium.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.