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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E980EC43334 for ; Mon, 20 Jun 2022 16:33:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231756AbiFTQd0 (ORCPT ); Mon, 20 Jun 2022 12:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242850AbiFTQdW (ORCPT ); Mon, 20 Jun 2022 12:33:22 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A9C92194 for ; Mon, 20 Jun 2022 09:33:21 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id i15so15060360ybp.1 for ; Mon, 20 Jun 2022 09:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atishpatra.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7bPts1cfdv5X3yhWIjMyjMOB+mWmCdJwIk3IAS5T6jU=; b=BCHxrCAqT1fggNN76GvFOUep69xvzXSAOMihzm9MMmw1s64DY79TEN0kB/epprxzSS 9UP1zn9jb6iD5khFQJfk+palG/jx7n5qyr1Y8L5u+/bshhVUkO2yrHyAetM4s1+AJUoF qrgUTV65Qfuye/F8wEGx40CfhynB/DzumyZjg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7bPts1cfdv5X3yhWIjMyjMOB+mWmCdJwIk3IAS5T6jU=; b=xCmVnw5DfH9CzzE+b/7rMS+SmdqAe8jG1Vb7coaAQnc7lFT9aa5X1SxO/pjiR9vEaH 2+FIBSQGPQiK6BYwmRzKboBIWL03xburC4HRzBcQEXJerMbAhSL+r5EsjY4qRnFXQUAm i/1L8xEK+p4Pi/Kzz+os0FRudEu4p+cy5d6Uw5Dd7I5OFKjBofFIVLOn/+76Y8fK9Taf F0DQ5wd7mOF0EgA0Ej6xjeBWjdevKPFDXTIT5/XcE6SlJHGoG4RTy+P20WvEKuEsp7M0 y4QFkIJXVTRw2kLiuZqnLgKAF79d6iSiPxiIKwOQFz3Xoyr7W/ySXE8khsC0Je2wlXHj taCQ== X-Gm-Message-State: AJIora+wpQpBQZgg5IHvH43rrIrDLud/ew3xkCEp++YHByg4SG7zKvBZ /MvdZpBrmnjZkiWpTmmwbjr6dM4eQDcZ4qoofvT/ X-Google-Smtp-Source: AGRyM1uCnTSHZ6dQRjcBpYrT28bl/gWbXFV1h4g4UkNHU1QZjMEp26wKkcXCCaOUdXGQ7W25WsJf2I76NazlVxRHJCc= X-Received: by 2002:a25:73d7:0:b0:668:e7db:d62 with SMTP id o206-20020a2573d7000000b00668e7db0d62mr11647503ybc.265.1655742800378; Mon, 20 Jun 2022 09:33:20 -0700 (PDT) MIME-Version: 1.0 References: <20220619203212.3604485-1-heiko@sntech.de> <20220619203212.3604485-2-heiko@sntech.de> In-Reply-To: <20220619203212.3604485-2-heiko@sntech.de> From: Atish Patra Date: Mon, 20 Jun 2022 09:33:09 -0700 Message-ID: Subject: Re: [PATCH 1/4] of: also handle dma-noncoherent in of_dma_is_coherent() To: Heiko Stuebner Cc: Palmer Dabbelt , Paul Walmsley , linux-riscv , "linux-kernel@vger.kernel.org List" , Wei Fu , Guo Ren , Christoph Muellner , Philipp Tomsich , Christoph Hellwig , Samuel Holland , Anup Patel , Nick Kossifidis , Rob Herring , krzk+dt@kernel.org, devicetree , Drew Fustini , Randy Dunlap Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Sun, Jun 19, 2022 at 1:32 PM Heiko Stuebner wrote: > > 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. "dma-noncoherent" is not a standard DT property. I couldn't find any references to it in the kernel as well. If we are introducing a new DT property for non-coherent devices, it should be added in DT bindings as well ? > */ > 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 > -- Regards, Atish