Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp980545ybe; Wed, 11 Sep 2019 07:37:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaNAt7jKzU4UKLc+XoH9lcrPxhAW3ZFrgqUffnnJixcLstbh5FacS+vJiINeKhqlYYQ3Ce X-Received: by 2002:a17:906:b7c9:: with SMTP id fy9mr29192952ejb.237.1568212674099; Wed, 11 Sep 2019 07:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568212674; cv=none; d=google.com; s=arc-20160816; b=b5E+fTgkMwqvUTBtwmTp1J3ZAlDwJxwRwPHiCJD1S2NJs9NwsC9boj3aGXGKPZurp/ DjpFuUg05lHnACQ6Ojoqz4cW1JVo+RlAhTfWSojwbHM639ZfjdXErvWiYGDGTR6kD6JN wWY3Nz5gkzeTsbRj35phIiExV05KKnY/PHAsKW+nIA6e75swxK1MWicX6BF8lecm2he3 GXUaTTCZPqR4z+dOB2WjocoToDh9s30KOIdB4GmckQA89Y7hMthFltdMiA1kM1IcuyO6 PZSs70gRdxEL6MEgQR4rmS5a4rMaWfmQrf1jhGDt4vAAPmE/5YxvvWFgp96Q7GU22BEF 5B1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=jWHRRvPf36O+WgIf6HAqCifRJyMKQgub4lYLwF5DV6s=; b=WYgLs87uihkDSwvfUNBzAa8nez6moRYU6I6aJAMqCy00J71q/gykqOLRkg6NyfV8Qb /GsDJtF/zZC41uM0l7CLz5xdL8yCpncwZoI8BQIj5bFzdZqmdtveaiSHMJdc8x6+c63A jktTcfy4RsTPnjY42OD4fPcUbn+Fm0M204bjnVrdv1m+oArL7c8M5+8lK7SIVT3GF9bI CJV7ERp8Rl1MqxmI4Dx8LncgZmNVJJY3vbpZTicBLI1X9edfMg3yK7KMUQiYxrB3hAym Ys7uwasgLtYNFnjokn39rLDqts0its65SCCFt/0mMxyP78RKAjjUMrzfB27upV0mnuDb 4Q4Q== 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 j9si5413709edq.304.2019.09.11.07.37.29; Wed, 11 Sep 2019 07:37:54 -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 S1728080AbfIKOff (ORCPT + 99 others); Wed, 11 Sep 2019 10:35:35 -0400 Received: from foss.arm.com ([217.140.110.172]:48602 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726381AbfIKOfe (ORCPT ); Wed, 11 Sep 2019 10:35:34 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0980D1000; Wed, 11 Sep 2019 07:35:34 -0700 (PDT) Received: from C02TF0J2HF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5DC9C3F67D; Wed, 11 Sep 2019 07:35:30 -0700 (PDT) Date: Wed, 11 Sep 2019 15:35:27 +0100 From: Catalin Marinas To: Nicolas Saenz Julienne 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 Subject: Re: [PATCH v5 3/4] arm64: use both ZONE_DMA and ZONE_DMA32 Message-ID: <20190911143527.GB43864@C02TF0J2HF1T.local> References: <20190909095807.18709-1-nsaenzjulienne@suse.de> <20190909095807.18709-4-nsaenzjulienne@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 devices will > > - * use a DMA offset. > > + * Return the maximum physical address for a zone with a given address 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 = 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()); > > } > > while testing other code on top of this series on odd arm64 machines I found an > issue: when memblock_start_of_DRAM() != 0, max_zone_phys() isn't taking into > account the offset to the beginning of memory. This doesn't matter with > zone_bits == 32 but it does when zone_bits == 30. 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. 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). I guess the fix here is to use GENMASK_ULL(63, zone_bits). -- Catalin