Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp250158pxa; Fri, 14 Aug 2020 03:13:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfjzz/dvCPZNxHiYB9tnhk5ItRxag31q34X31BO36+G4WMU0AUsejOakV26H+z4xwTERXh X-Received: by 2002:a17:906:4dc8:: with SMTP id f8mr1693878ejw.257.1597399983011; Fri, 14 Aug 2020 03:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597399983; cv=none; d=google.com; s=arc-20160816; b=AK2AKPWjm81R7hHVEAr2/a2YLwGXg3IjYPbHRSn2xqO/nmYhCCHaH+KaId7TxyFwks g+UVxR1SbkuRxHlTh20rdFAuMlRADzSOBr7iwwDMV3fA7EYULlhno2mEewS6TGkSyB2H kAfK8fXBqRt3L4Bv/oEKBmcvSE2jtYjIwz8vK0NlcaqMo55HTPCzK/fVPaSLnPRnj/K3 IafmkFWrbNP2uAFm/3bVNH9bW9B//S8rZmskOmmMwO+ZiHluBXSY89kkzSoDXau73Ako ASAzuPDwwplGRjRhTI4n5AkTUoxfiglRZc6zOcPY1ZD3lnJ82wunoCYmVtyXB3Djs6SL bUdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=U4oWym4i6b79O6c9yQJS7TzuEIOWAggf0WuWuwiYtos=; b=ewL9zu7U6eDnqlga+YVljoUABKpjI0C8TmYg3W9Q80PnlNQ80qwkKA4BsfffVofl4K jg6L+UljukPqI/q9Ug0a++dXkArL5JqnX7zeolT1bETyVNk/lSzdfGrekcOjjkO4ZLZi gV7acEAnGvAu8YSIYvBP7dLz2N6zGP3fJRf038cFkBMLKfml5ARqH+3O6hVX1DetnDuh +Kz9Ppuxk5RroygrgOyg/nnvCSkGBlGBByHrKIRi7LKAwh32/L8L5cqZf9Ovq/ULTT8X Xoshsv49OYAcoIonw07Ml7GqFA2E+zkFb1d3MKcnT3i174nD4TQBBl/mlf5krIhPIvdn CX2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c12si5797805edx.494.2020.08.14.03.12.40; Fri, 14 Aug 2020 03:13:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726320AbgHNKDN (ORCPT + 99 others); Fri, 14 Aug 2020 06:03:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:43340 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbgHNKDM (ORCPT ); Fri, 14 Aug 2020 06:03:12 -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 0E37FAD1B; Fri, 14 Aug 2020 10:03:34 +0000 (UTC) Message-ID: Subject: Re: [PATCH v3 2/2] dma-pool: Only allocate from CMA when in same memory zone From: Nicolas Saenz Julienne To: Christoph Hellwig Cc: amit.pundir@linaro.org, linux-kernel@vger.kernel.org, jeremy.linton@arm.com, iommu@lists.linux-foundation.org, linux-rpi-kernel@lists.infradead.org, rientjes@google.com, Robin Murphy Date: Fri, 14 Aug 2020 12:03:09 +0200 In-Reply-To: <20200814060642.GA1338@lst.de> References: <20200806184756.32075-1-nsaenzjulienne@suse.de> <20200806184756.32075-3-nsaenzjulienne@suse.de> <20200807052116.GA584@lst.de> <20200808063354.GA17329@lst.de> <20200814060642.GA1338@lst.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2020-08-14 at 08:06 +0200, Christoph Hellwig wrote: > On Sat, Aug 08, 2020 at 08:33:54AM +0200, Christoph Hellwig wrote: > > On Fri, Aug 07, 2020 at 10:50:19AM +0200, Nicolas Saenz Julienne wrote: > > > On Fri, 2020-08-07 at 07:21 +0200, Christoph Hellwig wrote: > > > > On Thu, Aug 06, 2020 at 08:47:55PM +0200, Nicolas Saenz Julienne wrote: > > > > > There is no guarantee to CMA's placement, so allocating a zone specific > > > > > atomic pool from CMA might return memory from a completely different > > > > > memory zone. To get around this double check CMA's placement before > > > > > allocating from it. > > > > > > > > As the builtbot pointed out, memblock_start_of_DRAM can't be used from > > > > non-__init code. But lookig at it I think throwing that in > > > > is bogus anyway, as cma_get_base returns a proper physical address > > > > already. > > > > > > It does indeed, but I'm comparing CMA's base with bitmasks that don't take into > > > account where the memory starts. Say memory starts at 0x80000000, and CMA falls > > > into ZONE_DMA [0x80000000 0xC0000000], if you want to compare it with > > > DMA_BIT_MASK(zone_dma_bits) you're forced to unify the memory bases. > > > > > > That said, I now realize that this doesn't work for ZONE_DMA32 which has a hard > > > limit on 32bit addresses reglardless of the memory base. > > > > > > That said I still need to call memblock_start_of_DRAM() any suggestions WRT > > > that? I could save the value in dma_atomic_pool_init(), which is __init code. > > > > The pool must be about a 32-bit physical address. The offsets can be > > different for every device.. I now see what you mean. I was trying to blindly fit CMA with arm64's DMA zone setup, which, as it turns out, doesn't really honor its purpose. arm64 introduced ZONE_DMA to provide a 30-bit address space, but we're creating it regardless of whether it exists or not. This creates a mismatch between zone_dma_bits and ZONE_DMA's real placement. I'll try to look at fixing that in arm64. > Do you plan to resend this one without the memblock_start_of_DRAM > thingy? Yes, sorry for the wait, I've been on vacation and short on time, I'll send it during the day. Regards, Nicolas