[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOnJCUJC3dk21cYXXDOsamvwFDHsukoBx7HEYwqHM+MN5fLRpA@mail.gmail.com>
Date: Mon, 20 Jun 2022 09:33:09 -0700
From: Atish Patra <atishp@...shpatra.org>
To: Heiko Stuebner <heiko@...ech.de>
Cc: Palmer Dabbelt <palmer@...belt.com>,
Paul Walmsley <paul.walmsley@...ive.com>,
linux-riscv <linux-riscv@...ts.infradead.org>,
"linux-kernel@...r.kernel.org List" <linux-kernel@...r.kernel.org>,
Wei Fu <wefu@...hat.com>, Guo Ren <guoren@...nel.org>,
Christoph Muellner <cmuellner@...ux.com>,
Philipp Tomsich <philipp.tomsich@...ll.eu>,
Christoph Hellwig <hch@....de>,
Samuel Holland <samuel@...lland.org>,
Anup Patel <anup@...infault.org>,
Nick Kossifidis <mick@....forth.gr>,
Rob Herring <robh+dt@...nel.org>, krzk+dt@...nel.org,
devicetree <devicetree@...r.kernel.org>,
Drew Fustini <drew@...gleboard.org>,
Randy Dunlap <rdunlap@...radead.org>
Subject: Re: [PATCH 1/4] of: also handle dma-noncoherent in of_dma_is_coherent()
On Sun, Jun 19, 2022 at 1:32 PM Heiko Stuebner <heiko@...ech.de> 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 <heiko@...ech.de>
> ---
> 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
Powered by blists - more mailing lists