lkml.org 
[lkml]   [2021]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFT PATCH v3 12/27] of/address: Add infrastructure to declare MMIO as non-posted
On Thu, Mar 4, 2021 at 11:40 PM Hector Martin <marcan@marcan.st> 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

\
 
 \ /
  Last update: 2021-03-05 16:14    [W:1.498 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site