Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3157401iog; Mon, 20 Jun 2022 12:42:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uRJgpjdLAwRIVH6fPLM1pEVAXaOxMgKigoofvztLR7KKV+HBJ9fgW8vshYo9xLM1WrS7GB X-Received: by 2002:a17:90b:17d2:b0:1ec:be52:56e2 with SMTP id me18-20020a17090b17d200b001ecbe5256e2mr2323836pjb.207.1655754174668; Mon, 20 Jun 2022 12:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655754174; cv=none; d=google.com; s=arc-20160816; b=0Hj2dXKgi4NVaUUJDpDyB1riliBGPp+qSIJl7nS5AgHDAkl7B+OFrzcIh3h60fyeym t4hSbNsrpim4mq8a68juh8ekMbccFHrlXx9IkduvnU9NhFonEri0XRvbxRuvnj0LdOlM B4xKR5XenG91vbAV2AMPx22mEhdHbZtRy2Q3T+HAlBv4tmhVxuGZup/gNFJuSR+UEfoR NN/W2inXQetPxqgIgt7A6jZnwc6y6OSOj2+odGqhSiHCve8HlDAIYzrRAmiQa5B44rU3 M/M5SPE9jaKVRxvSwFf9K76cA5SERV/uwv5TEzN5NqRqtxqHPpUwjqyhKTKF4xOR6r/A Y2Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=W3cF1VcNZKMUkal3wxdtJamU5dlHgg7QxmEQyZt0dz0=; b=PkLEHZpZKr2iPGRCFJNa4G4wX+kV5mlyP/kAcFZFYRkovnxzpYEUYL9GDjbgpoV8Ey zUq+FOFi3glxujt6b9A36DJ5N1VcqnWF7E/yr6kSheHPOCZk0zbJocL/OrDhpq6gpfaO nW41opKNofhUkiWCjjyJ2TiAWTOCNDNeJlcT0ec9shMUXwZ6d6rU/B5n9UTRGcyXXppw C/xsGt2ojy8jgKma7dvZJzADpF4lNHROAnj7tXdcpmxQ0lmSjsopc8g9mNgd7S+ZfHdr wJ/TYmzvFITMSdQZ3lwHIstL7iuAZTpcUVH0VscErOSYAU6GWyPDf13Qtiz86Oycy9BD m26A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=aO2AYN3z; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q187-20020a632ac4000000b0040ca7c68c36si6457510pgq.774.2022.06.20.12.42.41; Mon, 20 Jun 2022 12:42:54 -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; dkim=pass header.i=@atishpatra.org header.s=google header.b=aO2AYN3z; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244329AbiFTTl3 (ORCPT + 99 others); Mon, 20 Jun 2022 15:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233184AbiFTTlZ (ORCPT ); Mon, 20 Jun 2022 15:41:25 -0400 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 690B41401C for ; Mon, 20 Jun 2022 12:41:24 -0700 (PDT) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-31772f8495fso109503327b3.4 for ; Mon, 20 Jun 2022 12:41:24 -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=W3cF1VcNZKMUkal3wxdtJamU5dlHgg7QxmEQyZt0dz0=; b=aO2AYN3zp0ClZrYRS2Q8cyVAwbUa7767aMcv8OyCU5rPa5d03QKD5NJP4c5JAuGSij 3lnUxhivwtYF2TKpUEfHSSRwjzT74jT3s63IHP+4lGXEO3JebLxdma7I2g+t4M9pmcrP ZBoIfAsp16J6LeFM7E9trq+cVZZhVBVFyWgw4= 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=W3cF1VcNZKMUkal3wxdtJamU5dlHgg7QxmEQyZt0dz0=; b=7YvITn48JW0+qEsqX5tT+bYyeZQxWc6FqJHyYq3G00kI69BczEl4QOhzQOa0pR0QpE GckQLvLtO+qYb9qrHQUHzPgO1YSavg2XZwy1YV5BnZRMTWT1p+vk/T5SIfVib0K0HzGG X+YEM0w0+dMrcIEKVDIyVD0jNRhKdjEilJxuLhkRFzhA5b1aFsrDCZ52Pp+g+2ZbGPoZ OD0/WZEO2JLaiwVRBkh+ryGJw8EyT4O6X/DPPIcVCvvck3KbjYIlqKicoIHNl2HRa3m8 n2LAfWUpIzbVRj69ibouOQ8ZeLI7oN/pfn3PE+aO+g40m9r1cRFweiOty+oh9FmJrZ6o TADQ== X-Gm-Message-State: AJIora9+Q2VM44amFecF/Cd+6E9fjYzKkbLDHxvsWh0+orbgm4WSAwwg U4fxz7ANNnb0KAT3GPFr80RxP8QOgz7D6nPP6DbSL9/qPw== X-Received: by 2002:a0d:cbc8:0:b0:317:95ef:399e with SMTP id n191-20020a0dcbc8000000b0031795ef399emr15460241ywd.340.1655754083630; Mon, 20 Jun 2022 12:41:23 -0700 (PDT) MIME-Version: 1.0 References: <20220619203212.3604485-1-heiko@sntech.de> <20220619203212.3604485-2-heiko@sntech.de> <5907887.LM0AJKV5NW@phil> In-Reply-To: <5907887.LM0AJKV5NW@phil> From: Atish Patra Date: Mon, 20 Jun 2022 12:41:12 -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" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Mon, Jun 20, 2022 at 11:11 AM Heiko Stuebner wrote: > > Hi Atish, > > Am Montag, 20. Juni 2022, 18:33:09 CEST schrieb Atish Patra: > > 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 ? > > The dma-coherent is part of the core devicetree-spec, > so I sent a patch adding dma-noncoherent [0] > to the devicetree-spec mailing list yesterday as well. > Ahh. That's great. Thanks! > [0] https://www.spinics.net/lists/devicetree-spec/msg01053.html > > > > > > > */ > > > 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