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 X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27A58C433ED for ; Tue, 6 Apr 2021 16:47:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06DA8613CD for ; Tue, 6 Apr 2021 16:47:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238263AbhDFQsB (ORCPT ); Tue, 6 Apr 2021 12:48:01 -0400 Received: from mail-oo1-f49.google.com ([209.85.161.49]:44911 "EHLO mail-oo1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232032AbhDFQr7 (ORCPT ); Tue, 6 Apr 2021 12:47:59 -0400 Received: by mail-oo1-f49.google.com with SMTP id p2-20020a4aa8420000b02901bc7a7148c4so3834382oom.11; Tue, 06 Apr 2021 09:47:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KsEFQn5ynPj9Q6od5ymvE84NEzlALObqjlPA4SQWRs8=; b=Caw06k2MWg1OwP78wZ8gxa1iBXixjWgwRK2lx5HicQ+kWOMh530QGvjE3JBelhmRd0 l07PZY89Xc+IP2Fe3Q07P00Zrud9P99oyC3rVkj5hNHogjeFOs2WXWYX6NHrkcS77WDB P94qXGk/+0YrRAgXMMq1WAsVWu8yQuFD3GSljzjKlW2YkKn3Ln9bZZmwVfedZBvP9wye sb+bJ+cmCDA7UEeKzcLBmFvfHHy+K6I9ZkNz1T//ij1po0BAvYPxqH/ngulIh+neVnwM dBeZx5xLXFV3/2z9Ru2STWfxz+G2LpmUaRNkVTanJflI0gOfcrhU00ZS71tPKGEe4II+ yk1w== X-Gm-Message-State: AOAM533bh+Z9JfB6jSH1+OBEj7zpjZAA7gedjUbhfsCpclV+KT8gGytY EzrbMCvb+rUCHrDKj0jiVw== X-Google-Smtp-Source: ABdhPJwPZn4vyuV4WbEQb7jrirEmMI3mRcpb+G+wNqe7KnEHeN8KG33o//cShwHkWNjdpn2Mmze2sA== X-Received: by 2002:a4a:d354:: with SMTP id d20mr27213126oos.12.1617727670969; Tue, 06 Apr 2021 09:47:50 -0700 (PDT) Received: from robh.at.kernel.org (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.gmail.com with ESMTPSA id m16sm4687480otj.11.2021.04.06.09.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 09:47:50 -0700 (PDT) Received: (nullmailer pid 1942347 invoked by uid 1000); Tue, 06 Apr 2021 16:47:48 -0000 Date: Tue, 6 Apr 2021 11:47:48 -0500 From: Rob Herring To: Hector Martin Cc: linux-arm-kernel@lists.infradead.org, Marc Zyngier , Arnd Bergmann , Olof Johansson , Krzysztof Kozlowski , Mark Kettenis , Tony Lindgren , Mohamed Mediouni , Stan Skowronek , Alexander Graf , Will Deacon , Linus Walleij , Mark Rutland , Andy Shevchenko , Jonathan Corbet , Catalin Marinas , Christoph Hellwig , "David S. Miller" , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 12/18] of/address: Add infrastructure to declare MMIO as non-posted Message-ID: <20210406164748.GA1937719@robh.at.kernel.org> References: <20210402090542.131194-1-marcan@marcan.st> <20210402090542.131194-13-marcan@marcan.st> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210402090542.131194-13-marcan@marcan.st> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 02, 2021 at 06:05:36PM +0900, Hector Martin wrote: > This implements the 'nonposted-mmio' boolean property. Placing this > property in a bus marks all direct child devices as requiring > non-posted MMIO mappings. If no such property is found, the default > is posted MMIO. > > of_mmio_is_nonposted() performs this check to determine if a given > device has requested non-posted MMIO. > > of_address_to_resource() uses this to set the IORESOURCE_MEM_NONPOSTED > flag on resources that require non-posted MMIO. > > of_iomap() and of_io_request_and_map() then use this flag to pick the > correct ioremap() variant. > > This mechanism is currently restricted to builds that support Apple ARM > platforms, as an optimization. > > Reviewed-by: Linus Walleij > Signed-off-by: Hector Martin > --- > drivers/of/address.c | 43 ++++++++++++++++++++++++++++++++++++-- > include/linux/of_address.h | 1 + > 2 files changed, 42 insertions(+), 2 deletions(-) > > diff --git a/drivers/of/address.c b/drivers/of/address.c > index 73ddf2540f3f..6485cc536e81 100644 > --- a/drivers/of/address.c > +++ b/drivers/of/address.c > @@ -847,6 +847,9 @@ static int __of_address_to_resource(struct device_node *dev, > return -EINVAL; > memset(r, 0, sizeof(struct resource)); > > + if (of_mmio_is_nonposted(dev)) > + flags |= IORESOURCE_MEM_NONPOSTED; > + > r->start = taddr; > r->end = taddr + size - 1; > r->flags = flags; > @@ -896,7 +899,10 @@ void __iomem *of_iomap(struct device_node *np, int index) > if (of_address_to_resource(np, index, &res)) > return NULL; > > - return ioremap(res.start, resource_size(&res)); > + if (res.flags & IORESOURCE_MEM_NONPOSTED) > + return ioremap_np(res.start, resource_size(&res)); > + else > + return ioremap(res.start, resource_size(&res)); > } > EXPORT_SYMBOL(of_iomap); > > @@ -928,7 +934,11 @@ void __iomem *of_io_request_and_map(struct device_node *np, int index, > if (!request_mem_region(res.start, resource_size(&res), name)) > return IOMEM_ERR_PTR(-EBUSY); > > - mem = ioremap(res.start, resource_size(&res)); > + if (res.flags & IORESOURCE_MEM_NONPOSTED) > + mem = ioremap_np(res.start, resource_size(&res)); > + else > + mem = ioremap(res.start, resource_size(&res)); > + > if (!mem) { > release_mem_region(res.start, resource_size(&res)); > return IOMEM_ERR_PTR(-ENOMEM); > @@ -1094,3 +1104,32 @@ bool of_dma_is_coherent(struct device_node *np) > return false; > } > EXPORT_SYMBOL_GPL(of_dma_is_coherent); > + > +/** > + * of_mmio_is_nonposted - Check if device uses non-posted MMIO > + * @np: device node > + * > + * Returns true if the "nonposted-mmio" property was found for > + * the device's bus. > + * > + * This is currently only enabled on builds that support Apple ARM devices, as > + * an optimization. > + */ > +bool of_mmio_is_nonposted(struct device_node *np) > +{ > + struct device_node *parent; > + bool nonposted; > + > + if (!IS_ENABLED(CONFIG_ARCH_APPLE)) > + return false; > + > + parent = of_get_parent(np); > + if (!parent) > + return false; > + > + nonposted = of_property_read_bool(parent, "nonposted-mmio"); > + > + of_node_put(parent); > + return nonposted; > +} > +EXPORT_SYMBOL_GPL(of_mmio_is_nonposted); Is this needed outside of of/address.c? If not, please make it static and don't export. With that, Reviewed-by: Rob Herring 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 X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D896C433ED for ; Tue, 6 Apr 2021 16:49:59 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0CB7B613D0 for ; Tue, 6 Apr 2021 16:49:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CB7B613D0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yWEjTpgapqDa95MPuF/9OrfP/py0sgv15q7M3rHS2B0=; b=a2TJ2JAj2Crh6laRmC8MHNiv6 jT3tsH/f51pMdw2VkZfPaKzuOCTPtHdJyCCMEKNs6Erj42I+lOqnK17RB9VLBX8dvJVoevjZzmFWq JuQifwNt0p3b2QxVtWivCWSydcfplSqgWGLG4RBS/Kmthkd8HjKD61CHGFHe+4u142sgccIJQa2AA wWhGz7XGbcNMWnE3v8mBTZb+WsMFEj8UdwMMoHxWVPxiePDYs28kh57zRSFtrgyXTemcHvDjVNfIh 5rUi3AblVapJDuCjBNeNjC04JiivoR8CoAAjjympusbpm9X12iuT1YS3Ss6lzu1ki2Rqt1lCIccAL OFgjH0/UQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTorw-0032Aw-KP; Tue, 06 Apr 2021 16:48:00 +0000 Received: from mail-oo1-f50.google.com ([209.85.161.50]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lToro-00329X-Pi for linux-arm-kernel@lists.infradead.org; Tue, 06 Apr 2021 16:47:59 +0000 Received: by mail-oo1-f50.google.com with SMTP id x187-20020a4a41c40000b02901b664cf3220so3842197ooa.10 for ; Tue, 06 Apr 2021 09:47:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KsEFQn5ynPj9Q6od5ymvE84NEzlALObqjlPA4SQWRs8=; b=PKbLkBVtgQvFUtv4eOLuf3llQ/eefYxv/W5Ks3YdKVuqUnSeimGceHJRtMdpK9NvXb bABt6mdRqKRnlguZthKYEV2cjlQJwP2PGJYpbR7P0/m0momnTTc9ciAbajSfRHbEdrkh nDGLPSxq9ao55pVuY+QrQdrWLSkdXMEAiQlWMqC3B/Jvz0p0nnn8QtNevs0vA2+KU0gW d56nMEsL0wByoXlXhUeMhTIwju5QARn6WHMwNqivd3hf9trz4nx3xq9f/mOYjOFWUbgO AEC/jZqb3ndByzNKfUwy7vXj3OOudkpzHBEk8q/4myHBFgBwUKYYCWNaJoyO654kUUk6 eDxg== X-Gm-Message-State: AOAM532oqSY5Ry3LnXtaKShQ/0lFulV69ZTEvTAsacL8BEG2kFZdFtIl b+hmlmYL0VFCXqAy4DWCzQ== X-Google-Smtp-Source: ABdhPJwPZn4vyuV4WbEQb7jrirEmMI3mRcpb+G+wNqe7KnEHeN8KG33o//cShwHkWNjdpn2Mmze2sA== X-Received: by 2002:a4a:d354:: with SMTP id d20mr27213126oos.12.1617727670969; Tue, 06 Apr 2021 09:47:50 -0700 (PDT) Received: from robh.at.kernel.org (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.gmail.com with ESMTPSA id m16sm4687480otj.11.2021.04.06.09.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 09:47:50 -0700 (PDT) Received: (nullmailer pid 1942347 invoked by uid 1000); Tue, 06 Apr 2021 16:47:48 -0000 Date: Tue, 6 Apr 2021 11:47:48 -0500 From: Rob Herring To: Hector Martin Cc: linux-arm-kernel@lists.infradead.org, Marc Zyngier , Arnd Bergmann , Olof Johansson , Krzysztof Kozlowski , Mark Kettenis , Tony Lindgren , Mohamed Mediouni , Stan Skowronek , Alexander Graf , Will Deacon , Linus Walleij , Mark Rutland , Andy Shevchenko , Jonathan Corbet , Catalin Marinas , Christoph Hellwig , "David S. Miller" , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 12/18] of/address: Add infrastructure to declare MMIO as non-posted Message-ID: <20210406164748.GA1937719@robh.at.kernel.org> References: <20210402090542.131194-1-marcan@marcan.st> <20210402090542.131194-13-marcan@marcan.st> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210402090542.131194-13-marcan@marcan.st> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210406_174757_524321_48B6EDB5 X-CRM114-Status: GOOD ( 30.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 02, 2021 at 06:05:36PM +0900, Hector Martin wrote: > This implements the 'nonposted-mmio' boolean property. Placing this > property in a bus marks all direct child devices as requiring > non-posted MMIO mappings. If no such property is found, the default > is posted MMIO. > > of_mmio_is_nonposted() performs this check to determine if a given > device has requested non-posted MMIO. > > of_address_to_resource() uses this to set the IORESOURCE_MEM_NONPOSTED > flag on resources that require non-posted MMIO. > > of_iomap() and of_io_request_and_map() then use this flag to pick the > correct ioremap() variant. > > This mechanism is currently restricted to builds that support Apple ARM > platforms, as an optimization. > > Reviewed-by: Linus Walleij > Signed-off-by: Hector Martin > --- > drivers/of/address.c | 43 ++++++++++++++++++++++++++++++++++++-- > include/linux/of_address.h | 1 + > 2 files changed, 42 insertions(+), 2 deletions(-) > > diff --git a/drivers/of/address.c b/drivers/of/address.c > index 73ddf2540f3f..6485cc536e81 100644 > --- a/drivers/of/address.c > +++ b/drivers/of/address.c > @@ -847,6 +847,9 @@ static int __of_address_to_resource(struct device_node *dev, > return -EINVAL; > memset(r, 0, sizeof(struct resource)); > > + if (of_mmio_is_nonposted(dev)) > + flags |= IORESOURCE_MEM_NONPOSTED; > + > r->start = taddr; > r->end = taddr + size - 1; > r->flags = flags; > @@ -896,7 +899,10 @@ void __iomem *of_iomap(struct device_node *np, int index) > if (of_address_to_resource(np, index, &res)) > return NULL; > > - return ioremap(res.start, resource_size(&res)); > + if (res.flags & IORESOURCE_MEM_NONPOSTED) > + return ioremap_np(res.start, resource_size(&res)); > + else > + return ioremap(res.start, resource_size(&res)); > } > EXPORT_SYMBOL(of_iomap); > > @@ -928,7 +934,11 @@ void __iomem *of_io_request_and_map(struct device_node *np, int index, > if (!request_mem_region(res.start, resource_size(&res), name)) > return IOMEM_ERR_PTR(-EBUSY); > > - mem = ioremap(res.start, resource_size(&res)); > + if (res.flags & IORESOURCE_MEM_NONPOSTED) > + mem = ioremap_np(res.start, resource_size(&res)); > + else > + mem = ioremap(res.start, resource_size(&res)); > + > if (!mem) { > release_mem_region(res.start, resource_size(&res)); > return IOMEM_ERR_PTR(-ENOMEM); > @@ -1094,3 +1104,32 @@ bool of_dma_is_coherent(struct device_node *np) > return false; > } > EXPORT_SYMBOL_GPL(of_dma_is_coherent); > + > +/** > + * of_mmio_is_nonposted - Check if device uses non-posted MMIO > + * @np: device node > + * > + * Returns true if the "nonposted-mmio" property was found for > + * the device's bus. > + * > + * This is currently only enabled on builds that support Apple ARM devices, as > + * an optimization. > + */ > +bool of_mmio_is_nonposted(struct device_node *np) > +{ > + struct device_node *parent; > + bool nonposted; > + > + if (!IS_ENABLED(CONFIG_ARCH_APPLE)) > + return false; > + > + parent = of_get_parent(np); > + if (!parent) > + return false; > + > + nonposted = of_property_read_bool(parent, "nonposted-mmio"); > + > + of_node_put(parent); > + return nonposted; > +} > +EXPORT_SYMBOL_GPL(of_mmio_is_nonposted); Is this needed outside of of/address.c? If not, please make it static and don't export. With that, Reviewed-by: Rob Herring _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel