[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e1da254cdf27edb3de798058bb234d8ded80267b.camel@suse.de>
Date: Thu, 22 Oct 2020 16:03:16 +0200
From: Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
To: Ard Biesheuvel <ardb@...nel.org>
Cc: Rob Herring <robh+dt@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
Christoph Hellwig <hch@....de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Frank Rowand <frowand.list@...il.com>,
Robin Murphy <robin.murphy@....com>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
"moderated list:BROADCOM BCM2835 ARM ARCHITECTURE"
<linux-rpi-kernel@...ts.infradead.org>,
Jeremy Linton <jeremy.linton@....com>,
Linux IOMMU <iommu@...ts.linux-foundation.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@...r.kernel.org>, Will Deacon <will@...nel.org>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Hanjun Guo <guohanjun@...wei.com>
Subject: Re: [PATCH v4 3/7] of/address: Introduce
of_dma_get_max_cpu_address()
On Thu, 2020-10-22 at 14:23 +0200, Ard Biesheuvel wrote:
> > +/**
> > + * of_dma_get_max_cpu_address - Gets highest CPU address suitable for DMA
> > + * @np: The node to start searching from or NULL to start from the root
> > + *
> > + * Gets the highest CPU physical address that is addressable by all DMA masters
> > + * in the sub-tree pointed by np, or the whole tree if NULL is passed. If no
> > + * DMA constrained device is found, it returns PHYS_ADDR_MAX.
> > + */
> > +phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np)
> > +{
> > + phys_addr_t max_cpu_addr = PHYS_ADDR_MAX;
> > + struct of_range_parser parser;
> > + phys_addr_t subtree_max_addr;
> > + struct device_node *child;
> > + struct of_range range;
> > + const __be32 *ranges;
> > + u64 cpu_end = 0;
> > + int len;
> > +
> > + if (!np)
> > + np = of_root;
> > +
> > + ranges = of_get_property(np, "dma-ranges", &len);
> > + if (ranges && len) {
> > + of_dma_range_parser_init(&parser, np);
> > + for_each_of_range(&parser, &range)
> > + if (range.cpu_addr + range.size > cpu_end)
> > + cpu_end = range.cpu_addr + range.size;
>
>
> Shouldn't this be 'range.cpu_addr + range.size - 1' ?
Yes, I agree. In that case arm64's counterpart should be:
zone_dma_bits = max(32U, fls64(of_dma_get_max_cpu_address(NULL)));
I'll update it.
Regards,
Nicolas
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists