From patchwork Fri Aug 6 11:31:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12423295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7ACB9C432BE for ; Fri, 6 Aug 2021 11:33:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D99C60FE7 for ; Fri, 6 Aug 2021 11:33:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3D99C60FE7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wmKxesTVrDJr9oh/f0nMgO9bFvNsp1vLLonxlbQJJnI=; b=i5qnwhW29Rjm65 gSpS+wc+LQBrWFbKWs4qpOKmCls3uaG+GAo7mEB2sW4F3+Lgd81+tFKtbdtpTV/wmQ9rzMgta7z3p sYy0KHloTzqGqgUJBKhu6uWjJT/MhxlBOw4W3pmv0NNbeD3SjNFuy55JgtNOMLSmau8Rjmgho8vZs daVprEtusSRV+vbzt47zoCJFoxeW/x6gbQ0IlS0gs908+Rmgxuu34WY3MYIQhGJPYgY5DrcfN2iKJ 4cyUMQMxhESDrRviNJcP9FThIzZrg+ZUZRFHHsT+eRUsZ6CLUzfTJuX/NejlQh2Y27TKux7qB+sI8 wUn1osAJ3fIlN3DsIuvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBy4r-00CHtj-Br; Fri, 06 Aug 2021 11:31:49 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBy4U-00CHmv-8p for linux-arm-kernel@lists.infradead.org; Fri, 06 Aug 2021 11:31:27 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id A267F6108D; Fri, 6 Aug 2021 11:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628249485; bh=lP9P2emkoqaG3Y9UVECzCsJ31BDk9yKNVY61WSeDVew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tnPeXiR8JiANNo5Q4fgmDmdMnadmuScbwPZoLOkAdnsNgfrCOYbo3kSZiEdn/1/RP Zr/+dp9rLGmNpbIjztJVIgDmSnZ2u4Bp5jDE8OpiQQt8I7em7FCctXinBWZxjVDqJ/ L6hmZYMH6XW6Suflz1eKmiQ5fy6PeiLIVrw45f8hQwFGrKKlkUETRkMBM26PFJNDp8 5jihYIvbLSyD1MwxZvLJOvsqwy3ZjntM1X5Xa6C5k8/O+D3AuQiwfLlZdWIZk3Ig2k gdknbFOZ0B/QtOzwAz/Qi8hVETlplIOXVmmDZ8r5zO6o7rw5eFjVRnq/pYHOoP1RuS vyhsVyLfq1bkg== From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: kernel-team@android.com, Will Deacon , Catalin Marinas , Marc Zyngier , Jade Alglave , Shameer Kolothum , kvmarm@lists.cs.columbia.edu, linux-arch@vger.kernel.org, Claire Chang , Konrad Rzeszutek Wilk , Robin Murphy , Christoph Hellwig , Rob Herring Subject: [PATCH] of: restricted dma: Don't fail device probe on rmem init failure Date: Fri, 6 Aug 2021 12:31:05 +0100 Message-Id: <20210806113109.2475-3-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210806113109.2475-1-will@kernel.org> References: <20210806113109.2475-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210806_043126_386715_C208E5C9 X-CRM114-Status: GOOD ( 15.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Cc: Konrad Rzeszutek Wilk Cc: Robin Murphy Cc: Christoph Hellwig Cc: Rob Herring Signed-off-by: Will Deacon --- 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