Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1021008iog; Wed, 29 Jun 2022 15:28:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uluc6Su1iBe11FNFJwL2WI/HkpQJvm+frCZwmXEgDB4CObuQFnRsdqEGmgcC7ZDKBOMskf X-Received: by 2002:a05:6402:350f:b0:437:6618:174a with SMTP id b15-20020a056402350f00b004376618174amr7234668edd.329.1656541705655; Wed, 29 Jun 2022 15:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656541705; cv=none; d=google.com; s=arc-20160816; b=GvEXRKgxVNpmU89qBL1OAc1l2APlWrjzEfpamEyUHD3YGsJP1R49MTerMUKhocQu3n 90QflNwntf105r2lr6TzyRms7N1O3AUlKeUMceHrbqAjEsmuS7EH8hRuUb7OeVQbULq6 gkC0XMQEqN1ER8FLaQnasAT3whdyayFaTzuGGTtKTC4bLJWIhNP8u/2Jo67A8mF2jm6v bSaMOCrK50SMTFY5odzbYAcSsMp19AmjBCmC9Yxv4wW0XAcmDSk5DCaTrzmjv8YMDnEB aJrfMn4DjXJPTtoBY5tiyTh1Hc2XteD4YiaJvHY3UcBP/ONZ0XkRE+Lehf8VA44bRP0g la9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=U+P8Ka6g7jpVR1U+kU19NRN10uxmPzNbtOioLJvZPJs=; b=KiFQIOpQ5TBhL573WIm4RRqziOFCk70EAftmvgoL+9uBBJR6YndufjjUVmwjY33tqO QlYVKOv9FgwpV71osMYCGvHDpfveIZ2GGZRzvs3+34FVFGOaNxHdROpKW/1bxaYwCap7 tYm5Xtow3ida8YPXoW3XLhq+ljbq2eR4Q9fbbv6m6OAqkBmKduOS3teeHvjDpeEG+LXP FVjkQPUa1GzKWp2pFfWXNIPRvfm7iOSdK5TIWEpPXTT6yXVELiWRzzbafmECzDrnS/tG Q2ZWER+YA+FPTg198cK8RywUVCLSvRoZt+FT2MI2zFUv4U2fp70XdgkyozxunD+wDO/r kO5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di9-20020a170906730900b00711f4c750basi1548811ejc.940.2022.06.29.15.27.49; Wed, 29 Jun 2022 15:28:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229539AbiF2WAR (ORCPT + 99 others); Wed, 29 Jun 2022 18:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbiF2WAP (ORCPT ); Wed, 29 Jun 2022 18:00:15 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3B0E21E0C; Wed, 29 Jun 2022 15:00:13 -0700 (PDT) Received: from ip5b412258.dynamic.kabel-deutschland.de ([91.65.34.88] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1o6fiw-0006yD-JR; Wed, 29 Jun 2022 23:59:50 +0200 From: Heiko Stuebner To: palmer@dabbelt.com, paul.walmsley@sifive.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, wefu@redhat.com, guoren@kernel.org, cmuellner@linux.com, philipp.tomsich@vrull.eu, hch@lst.de, samuel@sholland.org, atishp@atishpatra.org, anup@brainfault.org, mick@ics.forth.gr, robh+dt@kernel.org, krzk+dt@kernel.org, devicetree@vger.kernel.org, drew@beagleboard.org, rdunlap@infradead.org, Heiko Stuebner Subject: [PATCH v5 1/4] of: also handle dma-noncoherent in of_dma_is_coherent() Date: Wed, 29 Jun 2022 23:59:41 +0200 Message-Id: <20220629215944.397952-2-heiko@sntech.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220629215944.397952-1-heiko@sntech.de> References: <20220629215944.397952-1-heiko@sntech.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org of_dma_is_coherent() currently expects the architecture to be non-coherent and some devices being coherent getting marked as such with the dma-coherent devicetree property. For PowerPC CONFIG_OF_DMA_DEFAULT_COHERENT was added which currently makes of_dma_is_coherent() always return true but doesn't handle the case of the architecture being coherent but some devices not. So modify the function to also check for dma-noncoherent and set a suitable default return value. If CONFIG_OF_DMA_DEFAULT_COHERENT is set the value starts with true and finding dma-noncoherent will set it to false and without CONFIG_OF_DMA_DEFAULT_COHERENT, the behaviour is reversed. Signed-off-by: Heiko Stuebner --- drivers/of/address.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 94f017d808c4..96f0a12e507c 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -1045,26 +1045,29 @@ phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np) * * It returns true if "dma-coherent" property was found * for this device in the DT, or if DMA is coherent by - * default for OF devices on the current platform. + * default for OF devices on the current platform and no + * "dma-noncoherent" property was found for this device. */ bool of_dma_is_coherent(struct device_node *np) { struct device_node *node; - - if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT)) - return true; + bool is_coherent = IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT); node = of_node_get(np); while (node) { if (of_property_read_bool(node, "dma-coherent")) { - of_node_put(node); - return true; + is_coherent = true; + break; + } + if (of_property_read_bool(node, "dma-noncoherent")) { + is_coherent = false; + break; } node = of_get_next_dma_parent(node); } of_node_put(node); - return false; + return is_coherent; } EXPORT_SYMBOL_GPL(of_dma_is_coherent); -- 2.35.1