From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 6317CC433DB for ; Sat, 16 Jan 2021 14:59:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 05DC322DBF for ; Sat, 16 Jan 2021 14:59:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05DC322DBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fa5tQtiIQ20niQU8WN1wjfRk6GbfMatcs+q5BpnMQpk=; b=1pFau9AzydMcfUjGc9MdGdWGv pnd+PthGY67dfZOGrY8rqjfZubcu1wzcGLPt7YgbzOTshkGB+WLWrCAQcij8OODvna9rcsXu899Ws DFnTsxp53SISGvDXQZBoXsTbSt3Q1wHWoFe1qLMDv7gy1a1tatC8ouFhD1wUqMSYqYP7OcxOJM8by OBIyyu391e0c2oge0wQa76QdYIq90dB2Li4fBQxVBsDdQnpb/zp5OcLyxlUashIGvo2I5ct9A9dvh ulz7Pwa8t6aj+qNfSq+Mnt7ysDW8Q+pFmFnmFCIQuRiTWadK4yHV0aj27OobT3rXrjs0NnMFRRoXg 7qOYLgRyg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0n1W-0004x3-6m; Sat, 16 Jan 2021 14:57:54 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0n1T-0004wM-C1 for linux-arm-kernel@lists.infradead.org; Sat, 16 Jan 2021 14:57:52 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C0947ED1; Sat, 16 Jan 2021 06:57:46 -0800 (PST) Received: from [10.57.56.43] (unknown [10.57.56.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1BDB43F719; Sat, 16 Jan 2021 06:57:44 -0800 (PST) Subject: Re: [PATCH 1/2] of: device: Allow DMA range map to be set before of_dma_configure_id To: Paul Kocialkowski , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20210115175831.1184260-1-paul.kocialkowski@bootlin.com> From: Robin Murphy Message-ID: Date: Sat, 16 Jan 2021 14:57:43 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210115175831.1184260-1-paul.kocialkowski@bootlin.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210116_095751_549554_B92EDA75 X-CRM114-Status: GOOD ( 29.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jernej Skrabec , Daniel Vetter , Maxime Ripard , Chen-Yu Tsai , Rob Herring , Thomas Petazzoni , Frank Rowand Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2021-01-15 17:58, Paul Kocialkowski wrote: > A mechanism was recently introduced for the sunxi architecture where > the DMA offset for specific devices (under the MBUS) is set by a common > driver (sunxi_mbus). This driver calls dma_direct_set_offset to set > the device's dma_range_map manually. > > However this information was overwritten by of_dma_configure_id, which > obtains the map from of_dma_get_range (or keeps it NULL when it fails > and the force_dma argument is true, which is the case for platform > devices). > > As a result, the dma_range_map was always overwritten and the mechanism > could not correctly take effect. > > This adds a check to ensure that no previous DMA range map is > overwritten and prints a warning when the map was already set while > also being available from dt. In this case, the map that was already > set is kept. Hang on, the hard-coded offset is only intended to be installed when there *isn't* anything described in DT, in which case of_dma_get_range() should always bail out early without touching it anyway. This sounds like something's not quite right in the MBUS driver, so I don't think working around it in core code is really the right thing to do. Do you have a case where one of the relevant devices inherits a "dma-ranges" via the regular hierarchy without indirecting via an "interconnects" reference? Currently you're only checking for the latter, so that would be one way things could go awry (although to be a problem, said "dma-ranges" would also have to encode something *other* than the appropriate MBUS offset, which implies an incorrect or at least inaccurately-structured DT as well). Robin. > Fixes: b4bdc4fbf8d0 ("soc: sunxi: Deal with the MBUS DMA offsets in a central place") > Signed-off-by: Paul Kocialkowski > --- > drivers/of/device.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/of/device.c b/drivers/of/device.c > index aedfaaafd3e7..db1b8634c2c7 100644 > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -181,7 +181,14 @@ int of_dma_configure_id(struct device *dev, struct device_node *np, > > arch_setup_dma_ops(dev, dma_start, size, iommu, coherent); > > - dev->dma_range_map = map; > + if (!dev->dma_range_map) { > + dev->dma_range_map = map; > + } else if (map) { > + dev_warn(dev, > + "DMA range map was already set, ignoring range map from dt\n"); > + kfree(map); > + } > + > return 0; > } > EXPORT_SYMBOL_GPL(of_dma_configure_id); > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel