Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1008118ybe; Wed, 11 Sep 2019 08:03:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTFRr6Tga/vZHIOvb+iFE0XiKp6UXQU+RS1pnJDpPtPcLcOwDrhTMuNEKfWz2dga8GAYse X-Received: by 2002:a17:906:349b:: with SMTP id g27mr30234925ejb.130.1568214191456; Wed, 11 Sep 2019 08:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568214191; cv=none; d=google.com; s=arc-20160816; b=dDEeny3Wtz0A6dN9DM9Z4OHWBXoSITgh7S8T40S7Q2nKAeM0Nc2VqtRlcBX+uk2o41 jg4mQS579kXerCylkw3Ma0rMaRWbYxSQW5cpQFFAB2HIDIzf2YM/KTj5NQ3r42kVju1W vY3axpgD8WL2j9HZtXinjKUW2gjhv4ezxAjcXrsoW70r9cMYGCWSDFzNYoGeGYphykCy MqxCHEp3AdAsTXAvaDzOkfaO98iOCIZJkE/1SA21P/Q6bcGjw51h1RHjdCkCuCnhZmxH l35hWkDWIwRF9v67mNMYBZHwhnDt0zhl6wD8VMqiBscssopzMiWinwmHQt7TAh7Zp6/F 6Vtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=jP5v9KXMb6Zlv55ber/X82FoF/n4d7kDENCqyyKSjlA=; b=l3k/5uDg/6PTXq0Jl/T5jGbvLV2rTsd1RhbLgHemwkJywZgo7jpVc6g3tNNXyL0UYl SfdEpnfgacEBlV8skaNQe0RZt7Mijms7MIsJb3OiTOhA1pjacsPXV4QHhQkqcnP9Ikp6 7JzrZJHvOOVI3DC7c9Hhaarao6c4vt8Ceqn/+PlDKysuUT17TlHycGiA4EJlcKAlaGtp vYbnQk4/6otlZgomHMrx9kSOfGUaaAJWrtzXFsiaIuSikDAq3hwYvCly3ZB6fPQLC7Du ZXxbz41UUKoNf7zxGPR4Xhhk23LuzzY44udZu2jl4Ku2H6fCx8Gpf6aPLORrmaVo2nST Wv2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e25si12502904edb.308.2019.09.11.08.02.47; Wed, 11 Sep 2019 08:03:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728487AbfIKPAG (ORCPT + 99 others); Wed, 11 Sep 2019 11:00:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:59314 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727576AbfIKPAF (ORCPT ); Wed, 11 Sep 2019 11:00:05 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F3045B81C; Wed, 11 Sep 2019 15:00:02 +0000 (UTC) Message-ID: Subject: Re: [PATCH v5 3/4] arm64: use both ZONE_DMA and ZONE_DMA32 From: Nicolas Saenz Julienne To: Catalin Marinas Cc: hch@lst.de, wahrenst@gmx.net, marc.zyngier@arm.com, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Will Deacon , f.fainelli@gmail.com, robin.murphy@arm.com, linux-kernel@vger.kernel.org, mbrugger@suse.com, linux-rpi-kernel@lists.infradead.org, phill@raspberrypi.org, m.szyprowski@samsung.com Date: Wed, 11 Sep 2019 17:00:00 +0200 In-Reply-To: <20190911143527.GB43864@C02TF0J2HF1T.local> References: <20190909095807.18709-1-nsaenzjulienne@suse.de> <20190909095807.18709-4-nsaenzjulienne@suse.de> <20190911143527.GB43864@C02TF0J2HF1T.local> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-p7TAQdIbBeJ5BGhbbxNM" User-Agent: Evolution 3.32.4 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-p7TAQdIbBeJ5BGhbbxNM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2019-09-11 at 15:35 +0100, Catalin Marinas wrote: > On Wed, Sep 11, 2019 at 12:54:38PM +0200, Nicolas Saenz Julienne wrote: > > On Mon, 2019-09-09 at 11:58 +0200, Nicolas Saenz Julienne wrote: > > > /* > > > - * Return the maximum physical address for ZONE_DMA32 (DMA_BIT_MASK(= 32)). > > > It > > > - * currently assumes that for memory starting above 4G, 32-bit devic= es > > > will > > > - * use a DMA offset. > > > + * Return the maximum physical address for a zone with a given addre= ss > > > size > > > + * limit. It currently assumes that for memory starting above 4G, 32= -bit > > > + * devices will use a DMA offset. > > > */ > > > -static phys_addr_t __init max_zone_dma32_phys(void) > > > +static phys_addr_t __init max_zone_phys(unsigned int zone_bits) > > > { > > > phys_addr_t offset =3D memblock_start_of_DRAM() & GENMASK_ULL= (63, > > > 32); > > > - return min(offset + (1ULL << 32), memblock_end_of_DRAM()); > > > + return min(offset + (1ULL << zone_bits), memblock_end_of_DRAM= ()); > > > } > >=20 > > while testing other code on top of this series on odd arm64 machines I = found > > an > > issue: when memblock_start_of_DRAM() !=3D 0, max_zone_phys() isn't taki= ng into > > account the offset to the beginning of memory. This doesn't matter with > > zone_bits =3D=3D 32 but it does when zone_bits =3D=3D 30. >=20 > I thought about this but I confused myself and the only case I had in > mind was an AMD Seattle system with RAM starting at 4GB. I found the issue on a Cavium ThunderX2 server. Oddly enough the memory sta= rts at 0x802f0000. > What we need from this function is that the lowest naturally aligned > 2^30 RAM is covered by ZONE_DMA while the rest to 2^32 are ZONE_DMA32. > This assumed that devices only capable of 30-bit (or 32-bit), have the > top address bits hardwired to be able access the bottom of the memory > (and this would be expressed in DT as the DMA offset). Ok, I was testing a fix I wrote under these assumptions... > I guess the fix here is to use GENMASK_ULL(63, zone_bits). ...but this is way cleaner than my solution. Thanks! Regards, Nicolas --=-p7TAQdIbBeJ5BGhbbxNM 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/4FAl15C/AACgkQlfZmHno8 x/5f8ggAsuyzvV52JP8D4F3gMeBcgMlqN3+DQV47QfnPQoZyacvk5k1N3xUfcbNc TnGiLoB3xsPta+yqccbFl2njg+FBjZc2Ja/+Natqxx+ulXxkIsp7eGP+yeWJiiw9 oUApF6wwL6WYXWn0H+ZoYfwjCFqUDGWuCUYP3K8vHSVytsTmYegU/B+9nvncBfmk iF5Ql/Pd/TA0RLKvs2wftE8h889R2JSGWvdVMCIWWtC5qENC2ar2/ITluJ7kTCRX 9Ekkkh3L8fI6/qgPxKEcC8HuzO4aUTFlpWxxnfUMCd83wzWFWUUdOZ+rcaPpTMN2 ih1+8l3//QFXzpY5utTMqIWXxeKMKA== =r2f7 -----END PGP SIGNATURE----- --=-p7TAQdIbBeJ5BGhbbxNM--