Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2309626iog; Sun, 19 Jun 2022 13:44:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1udzqwJwqBqirr+UBq5W5U61T9Q5ZqqsE5U0owGCkgxEaUElqBCIHTqOGUcwlBoDIOR9ZZb X-Received: by 2002:a17:907:1b1e:b0:6d7:31b0:e821 with SMTP id mp30-20020a1709071b1e00b006d731b0e821mr18421466ejc.334.1655671461387; Sun, 19 Jun 2022 13:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655671461; cv=none; d=google.com; s=arc-20160816; b=0zJjzePzwM0AXFhmwJPwMgtXP8zvGn/5tEBYWKckCZf9c//In8ximo7I4/XHHMZUnG rFpCs8NHdYsGYJdZGr7xQgfoRKCWO0w0WWnhVhVfBVFzLG8Ahth2lDQ/gbV0TP2YjLdu H03E0rAQBg38m7iJPQciJi4UA0fnO5P7OdOWan1Qd4NhHMJ9teOeU8NQdD/sxHYpMyIc SX6/GwEgizV1HlZdIE51/F/48RE/+KgjMeYIEapams+/fpgCu6L0eJDwIG8tle7+9N/Y lJEElnPd58roM46QuaAM0F4hxxU1w7ClQDxge9jjdGJtoQCfBftzQbGcj26DTScZ/voI g2YQ== 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=mknniqH96a+U2U64jbLX6IEeLzRih1gfYsK7BP17IkQ=; b=YbXMU91duoQfcezN1Asda3ug9FmWVV3XZJ7XfAWhVghxnsnpVQ0vWcV6eDMu1z7wfR nNZZMkykVTw+QlNMe7KU7uPdT66XvIXAvdU7ByQTGu0XzEdged8BQXJRj0/kTi67dk3A ccp2V7GudRfOjQ3A26V7jCJomIxEYoAV7xzuM70GnLuGGy8XQHLaw358rhuvTGWaM3/3 x4BIgV8JwL9oYFjs8rYy7MZKxvud6ktlqY83IOZwgrb8msQ97S9kJdVX9JV6OBSjJc7n eTKeh11eIZAnfMp5ejj4lbP+ZioA5vFqDUkqraGXJEA/Go7fW/d8w2tTM0yRAq2AmzrI X6zA== 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 hc8-20020a170907168800b00704dc5420adsi12154267ejc.38.2022.06.19.13.43.55; Sun, 19 Jun 2022 13:44:21 -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 S237039AbiFSUcj (ORCPT + 99 others); Sun, 19 Jun 2022 16:32:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231547AbiFSUch (ORCPT ); Sun, 19 Jun 2022 16:32:37 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50558B841; Sun, 19 Jun 2022 13:32:35 -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 1o31an-0000EW-AZ; Sun, 19 Jun 2022 22:32:21 +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 1/4] of: also handle dma-noncoherent in of_dma_is_coherent() Date: Sun, 19 Jun 2022 22:32:09 +0200 Message-Id: <20220619203212.3604485-2-heiko@sntech.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220619203212.3604485-1-heiko@sntech.de> References: <20220619203212.3604485-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 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 94f017d808c4..1c362d09983d 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -1045,26 +1045,32 @@ 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; + bool ret = false; if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT)) - return true; + ret = true; node = of_node_get(np); while (node) { if (of_property_read_bool(node, "dma-coherent")) { - of_node_put(node); - return true; + ret = true; + break; + } + if (of_property_read_bool(node, "dma-noncoherent")) { + ret = false; + break; } node = of_get_next_dma_parent(node); } of_node_put(node); - return false; + return ret; } EXPORT_SYMBOL_GPL(of_dma_is_coherent); -- 2.35.1