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=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 E39B5C2D0DB for ; Sun, 26 Jan 2020 11:53:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B24732083E for ; Sun, 26 Jan 2020 11:53:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="f0lLJ+wL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387398AbgAZLxC (ORCPT ); Sun, 26 Jan 2020 06:53:02 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:43863 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgAZLxB (ORCPT ); Sun, 26 Jan 2020 06:53:01 -0500 Received: by ozlabs.org (Postfix, from userid 1034) id 485B8W5j9qz9sPW; Sun, 26 Jan 2020 22:52:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1580039579; bh=p07F/CpplD8xOEUuHxcTkyl+DVWiH+CxasxVO4NeadU=; h=From:To:Cc:Subject:Date:From; b=f0lLJ+wLPW9T1W+7sHA+E5bDTsZsJ1vHmX7yonomPYiVeX08NU5hnJyC+nmEz4Lrv OI+MH+IJOKqsv6jg23Pj2xK2JLw72iMuh/wn+JMBTZExkTJnN2YqvttlMOjTkTbOoO k1OuEUsvpZfEXqmphdbcLZ6RsG+5z4s1w65dRCkvkwJeNTvIFEuEKOcBmlcaRrCtcM B0N/mA0vyZz1CNBrbUFXEAmhRA7H2z5M8yB1EJrr7gf3Oz/YxCswVH5aLxVZavMxxc lF8I+hPprrvKPfL8vTPKRHoPL1JINI3Lrkdf4aG7lX+//IpLqya8QKMLasni6pc48j nbrn11jxgdp6A== From: Michael Ellerman To: robh+dt@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, hch@lst.de, ulf.hansson@linaro.org, chzigotzky@xenosoft.de, linuxppc-dev@ozlabs.org Subject: [PATCH] of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc Date: Sun, 26 Jan 2020 22:52:47 +1100 Message-Id: <20200126115247.13402-1-mpe@ellerman.id.au> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org There's an OF helper called of_dma_is_coherent(), which checks if a device has a "dma-coherent" property to see if the device is coherent for DMA. But on some platforms devices are coherent by default, and on some platforms it's not possible to update existing device trees to add the "dma-coherent" property. So add a Kconfig symbol to allow arch code to tell of_dma_is_coherent() that devices are coherent by default, regardless of the presence of the property. Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie. when the system has a coherent cache. Fixes: 92ea637edea3 ("of: introduce of_dma_is_coherent() helper") Cc: stable@vger.kernel.org # v3.16+ Reported-by: Christian Zigotzky Tested-by: Christian Zigotzky Signed-off-by: Michael Ellerman --- arch/powerpc/Kconfig | 1 + drivers/of/Kconfig | 4 ++++ drivers/of/address.c | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 1ec34e16ed65..19f5aa8ac9a3 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -238,6 +238,7 @@ config PPC select NEED_DMA_MAP_STATE if PPC64 || NOT_COHERENT_CACHE select NEED_SG_DMA_LENGTH select OF + select OF_DMA_DEFAULT_COHERENT if !NOT_COHERENT_CACHE select OF_EARLY_FLATTREE select OLD_SIGACTION if PPC32 select OLD_SIGSUSPEND diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 37c2ccbefecd..d91618641be6 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -103,4 +103,8 @@ config OF_OVERLAY config OF_NUMA bool +config OF_DMA_DEFAULT_COHERENT + # arches should select this if DMA is coherent by default for OF devices + bool + endif # OF diff --git a/drivers/of/address.c b/drivers/of/address.c index 99c1b8058559..e8a39c3ec4d4 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -995,12 +995,16 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz * @np: device node * * It returns true if "dma-coherent" property was found - * for this device in DT. + * for this device in the DT, or if DMA is coherent by + * default for OF devices on the current platform. */ bool of_dma_is_coherent(struct device_node *np) { struct device_node *node = of_node_get(np); + if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT)) + return true; + while (node) { if (of_property_read_bool(node, "dma-coherent")) { of_node_put(node); -- 2.21.1