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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 272C1C388F9 for ; Thu, 22 Oct 2020 14:03:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC2A12225F for ; Thu, 22 Oct 2020 14:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2900581AbgJVODV (ORCPT ); Thu, 22 Oct 2020 10:03:21 -0400 Received: from mx2.suse.de ([195.135.220.15]:46564 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2894676AbgJVODV (ORCPT ); Thu, 22 Oct 2020 10:03:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B00A3B181; Thu, 22 Oct 2020 14:03:19 +0000 (UTC) Message-ID: Subject: Re: [PATCH v4 3/7] of/address: Introduce of_dma_get_max_cpu_address() From: Nicolas Saenz Julienne To: Ard Biesheuvel Cc: Rob Herring , Catalin Marinas , Christoph Hellwig , Linux Kernel Mailing List , Frank Rowand , Robin Murphy , Linux ARM , "moderated list:BROADCOM BCM2835 ARM ARCHITECTURE" , Jeremy Linton , Linux IOMMU , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Will Deacon , Lorenzo Pieralisi , Hanjun Guo Date: Thu, 22 Oct 2020 16:03:16 +0200 In-Reply-To: References: <20201021123437.21538-1-nsaenzjulienne@suse.de> <20201021123437.21538-4-nsaenzjulienne@suse.de> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-UvLPWvl3/tbDetGzXF2K" User-Agent: Evolution 3.36.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-UvLPWvl3/tbDetGzXF2K Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 roo= t > > + * > > + * Gets the highest CPU physical address that is addressable by all DM= A 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 =3D 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 =3D 0; > > + int len; > > + > > + if (!np) > > + np =3D of_root; > > + > > + ranges =3D 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 =3D range.cpu_addr + range.size= ; >=20 >=20 > Shouldn't this be 'range.cpu_addr + range.size - 1' ? Yes, I agree. In that case arm64's counterpart should be: zone_dma_bits =3D max(32U, fls64(of_dma_get_max_cpu_address(NULL))); I'll update it. Regards, Nicolas --=-UvLPWvl3/tbDetGzXF2K Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEErOkkGDHCg2EbPcGjlfZmHno8x/4FAl+RkSUACgkQlfZmHno8 x/6WbQgAkVcDhB3SycLRGqPjX7WUnNsAxd8ccdYnBA32Lo5ualAFZpZH1lAjlBrF fsE03ZH1EMEFjaV5UJfaquybvyGf4z6boCw+jX30MUDLJePhl3XTMfWhIjTN81t+ 8ZW+wKCaL0M+F1hMjE4wGtk4toTaeYHNHxB8t9DKIwxjZ4mUE5sPBmpRQZv6eK/t YezVQWfjCjOP2MyY76PzZ54F4qSHXBQnsfZciol8tOCFARX/e0HfZtHtsILye37P nRydYfQsLGMhkDoDUDK4o529hPYTRY4REnEp1lbD0EUiXvpR/ZbnKMTLGz6y5uoQ 2KCLhICIqbSK6ab+UBgXrHFRIRoavA== =hL5X -----END PGP SIGNATURE----- --=-UvLPWvl3/tbDetGzXF2K--