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=-7.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 BCCFCC43331 for ; Fri, 5 Mar 2021 15:14:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3A9965090 for ; Fri, 5 Mar 2021 15:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbhCEPOK (ORCPT ); Fri, 5 Mar 2021 10:14:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbhCEPNx (ORCPT ); Fri, 5 Mar 2021 10:13:53 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00CBDC061574; Fri, 5 Mar 2021 07:13:52 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id m6so2391134pfk.1; Fri, 05 Mar 2021 07:13:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0eleFytR2/yM+dxl23Ms8EpKkzd5tBsQkHtS/SXNX0k=; b=BhZwf7o+ARbMRBKOyhSfvcpfSTMGDi8E6QYOHnXlb3DIKi4CTzEOJzxP2Mdety9KY7 9vn7+HDjtu8E8P9If2rP2c1glzgyUYFgsvAvSIZ6hA21gVR0nl1+wqZU9q5ySjoI+zgm MCJTjsr2Eb/I4wth2uEEh+h4cTyw4AOu5PThBSfdL5maY20PLrIJ0B7hI6u+rCh9fjVU h5UQXzapNPhsQWyl08uX6BQjgtAZHg9lt6OryZ3k126bvOygbf+tUGCTm+5cjOWavH3A +d1BihC+s+3NuFmhZDbxI0/mKzKJwVFwzLdVeBDSfAR0OQn1zSeDI5LDchdib2vG4cyy 4raQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0eleFytR2/yM+dxl23Ms8EpKkzd5tBsQkHtS/SXNX0k=; b=p+qYy4ZXpa2arPzvzvyhoBvaqYuYjHYMMZEFZgZ77uqtxBgvHClRNYy0AgKXkkjZjh CT1a2R2IBzBabwwnyUjnP+KOHgV/n2GpjbhTsF8pYrhckC71AI+ecEXFFrO5C/kxQnLE 97+R2Mi49ArSNR2E8/EvgyqMrCmsOQ6CGzyV75RT9DC6Zblx2Ge9fEgGxB6HWQpBF37I 3zImCqGyVCewRmtzAR5RrwC22EcTTVtoIfQAQzXFhXnnCSdblqHuOuYDvfrUwcWx8BT6 oOmC/s86l6DeekndeJMlpAT7kJN1+0tuYd4eHUsd25HN89ENXupls8YWKP1tQBhKrlvr A+Og== X-Gm-Message-State: AOAM5302RmggO8HWQZh62X74r5EAJe2xNa5UuySr8fnMbgY0leZfF68i Fw/a9VtKcQk2Ndxmf4qsZTCSeZsw5mEKdybMvfhqawuEi424uw== X-Google-Smtp-Source: ABdhPJy6ItIglcuderuEnfARE6d7B9METFkClRBMWOPNEjL7y8zg14IVBTva4UrBbARAxuw3VEqdm6QYPMMoBRzIK1M= X-Received: by 2002:a63:ce15:: with SMTP id y21mr9188159pgf.4.1614957232385; Fri, 05 Mar 2021 07:13:52 -0800 (PST) MIME-Version: 1.0 References: <20210304213902.83903-1-marcan@marcan.st> <20210304213902.83903-13-marcan@marcan.st> In-Reply-To: <20210304213902.83903-13-marcan@marcan.st> From: Andy Shevchenko Date: Fri, 5 Mar 2021 17:13:36 +0200 Message-ID: Subject: Re: [RFT PATCH v3 12/27] of/address: Add infrastructure to declare MMIO as non-posted To: Hector Martin Cc: linux-arm Mailing List , Marc Zyngier , Rob Herring , Arnd Bergmann , Olof Johansson , Krzysztof Kozlowski , Mark Kettenis , Tony Lindgren , Mohamed Mediouni , Stan Skowronek , Alexander Graf , Will Deacon , Linus Walleij , Mark Rutland , Greg Kroah-Hartman , Jonathan Corbet , Catalin Marinas , Christoph Hellwig , "David S. Miller" , devicetree , "open list:SERIAL DRIVERS" , Linux Documentation List , Linux Samsung SOC , Linux-Arch , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 4, 2021 at 11:40 PM Hector Martin wrote: > > This implements the 'nonposted-mmio' and 'posted-mmio' boolean > properties. Placing these properties in a bus marks all child devices as > requiring non-posted or posted MMIO mappings. If no such properties are > found, the default is posted MMIO. > > of_mmio_is_nonposted() performs the tree walking 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 Apple ARM platforms, as an > optimization. ... > @@ -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)); This doesn't sound right. Why _np is so exceptional? Why don't we have other flavours (it also rings a bell to my previous comment that the flag in ioresource is not in the right place)? ... > + if (res.flags & IORESOURCE_MEM_NONPOSTED) > + mem = ioremap_np(res.start, resource_size(&res)); > + else > + mem = ioremap(res.start, resource_size(&res)); > + Ditto. ... > + while (node) { > + if (!of_property_read_bool(node, "ranges")) { > + break; > + } else if (of_property_read_bool(node, "nonposted-mmio")) { > + of_node_put(node); > + return true; > + } else if (of_property_read_bool(node, "posted-mmio")) { > + break; > + } > + parent = of_get_parent(node); > + of_node_put(node); > + node = parent; > + } I believe above can be slightly optimized. Don't we have helpers to traverse to all parents? -- With Best Regards, Andy Shevchenko