From patchwork Fri Jan 15 17:58:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 12023589 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.0 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,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 6367DC433E0 for ; Fri, 15 Jan 2021 18:00:48 +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 1D3C82339E for ; Fri, 15 Jan 2021 18:00:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D3C82339E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.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-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Qj2zKwwcIwrhtbUb6gd24Yq/uN+XF3CtrvJ9CwDqlWI=; b=uL9wwXljb8CgKp+cC0JluVhedg 0jWdC6ubZaphk+Ej7KvxV5dum9fR3MFd7/P9e8ZtXU07Pi2qGESxkOnofCeXpktCRKmvw9uaZL+OL hoiYBjtP9friDmdUUFDmp6iYLJyemnLfawbqk/0GAYPZAuaxqV2DehfOf2hJXUP5mJU3VeShVD77R YZ/BDx8tJcdm7HB02nYqSEUU1q/B0FmyalkNVjBxOWyxNoF+7jvpdAqTaXQgDg6HWCir9k3ZvQotr hB/BuYqDWLGIjksXw4lsRalSbMQ1HL+Bx4DG2nbfh2F4aNCwl0/2ZLNpdUnvgdSUONM3t+Ny4MrkA VOqeWKAw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0TNB-0005xq-Ki; Fri, 15 Jan 2021 17:58:57 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0TN4-0005rd-GQ for linux-arm-kernel@lists.infradead.org; Fri, 15 Jan 2021 17:58:52 +0000 X-Originating-IP: 93.29.109.196 Received: from localhost.localdomain (196.109.29.93.rev.sfr.net [93.29.109.196]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 435151C0003; Fri, 15 Jan 2021 17:58:40 +0000 (UTC) From: Paul Kocialkowski To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] of: device: Allow DMA range map to be set before of_dma_configure_id Date: Fri, 15 Jan 2021 18:58:30 +0100 Message-Id: <20210115175831.1184260-1-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210115_125850_904122_DD1B1B58 X-CRM114-Status: GOOD ( 15.32 ) 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 , Paul Kocialkowski , Chen-Yu Tsai , Rob Herring , Thomas Petazzoni , Frank Rowand Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. 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);