Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2058051pxa; Fri, 7 Aug 2020 01:53:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6wLD3fFpF6w5qCfSIDL5LivEJgxztsDGal+pJvALshJ/4/2V65vIvK2c7XuVNvWx6cY3z X-Received: by 2002:aa7:c1d4:: with SMTP id d20mr7803814edp.81.1596790398245; Fri, 07 Aug 2020 01:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596790398; cv=none; d=google.com; s=arc-20160816; b=gR5aDx0jN6xfMpbF7lOnA2HMropbaV7/buk2e12hMbVCXIUTOtDSPu+vLt1tyd2xML DHg9rXVUbMJ7LQwNDhn2PgLxVvEm4o3+VCtxk2AM3euIPO78L8DPTd3YM5GxD3Vwo7k1 8XJPLj4ky1Eu2pCfIPdS8MXDYzbKZdSNZWjsdLNo4M4eJ3uOxHsJuu43oIK3b05PmYVz eSpmhxdPjevA8wuynXPxN9Pe9eTbAsF28lDRu9eFGVtdblSB62FT75/BtYkhZYAjWrle yqxD8kTTenyb+8kClJzsb7Pp076rFJITgQMf9T5Q0jaSbHB3TxyD6L/B1V45QFWpTOJc omKw== 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=eqNqFdvSV9L4yccEAUmkGLUoHrwTaCEAqdW6Ds0nt9Y=; b=ms2L/BZ9g/eZAx0F0kjwFnoEcU76kYjQcxj0EBpCXCnI3AhnH5B8ZYX2//ptR+aGms snZYJQZc6Bg3qrIwU7d3Ii36QRkVkvRBeRVuSDvGWmyReTNn/fXgyZLhlGiogDtebhlU GhCfaACytjtdazffkWoXrXk34+vi6tjuNBlwWUa5UjVrdCeHrbKADkhxHEQr/YKd/+4w 60QRz8WH+uv4Olwn7xRNBNyoeuwkkn1ftZIqwWP5WMEGPDvaehPJa0kxaqvCTlsyW23P XUHIGECJIwlaLVuCqZZrJagZK6VirZmMkvxWslwKl6ilBKPq8M1bqVV99m8Yns8Rd0jT aRGA== 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 r28si4390675edc.150.2020.08.07.01.52.54; Fri, 07 Aug 2020 01:53:18 -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 S1727081AbgHGIuX (ORCPT + 99 others); Fri, 7 Aug 2020 04:50:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:36472 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbgHGIuX (ORCPT ); Fri, 7 Aug 2020 04:50:23 -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 478AAAF06; Fri, 7 Aug 2020 08:50:39 +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, Marek Szyprowski , Robin Murphy , rientjes@google.com, jeremy.linton@arm.com, linux-rpi-kernel@lists.infradead.org, iommu@lists.linux-foundation.org Date: Fri, 07 Aug 2020 10:50:19 +0200 In-Reply-To: <20200807052116.GA584@lst.de> References: <20200806184756.32075-1-nsaenzjulienne@suse.de> <20200806184756.32075-3-nsaenzjulienne@suse.de> <20200807052116.GA584@lst.de> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-CN1cawQ3wxFHCl/garHR" User-Agent: Evolution 3.36.4 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-CN1cawQ3wxFHCl/garHR Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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. >=20 > 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 f= alls 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 cod= e. --=-CN1cawQ3wxFHCl/garHR 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/4FAl8tFcsACgkQlfZmHno8 x/5Wxwf+IXh+GDy4xNKtfhxHMTDolZREHO/kvmoJd/zTobn0o4992GzMyEVu9YLd MA+Yxdpi4IDDTredYMITrPM7f0nd2BpqZ1Wf8zXF2o5nmtPoAeOqH89FbajqzXle oLRzLPoC5xDcErO2J1UDIRg539IJu1kKGaPDxJT0gxcDv39DOMITNzMuphQwacLM tYXUuZ9yNFRx0AdODTOXPE7iE4qKRQvm54rExmYsT3VJIjlo+H8qrpa79q6BhooL G19pFMDFTVhX/iRA94j2HBXr7IjyDK44JJlHWZ9Ocf04S3bVCClkDH9nK74ZRHgm GS5W7k8K8VWOD1DajSTMyZjk/2+E/A== =i4iT -----END PGP SIGNATURE----- --=-CN1cawQ3wxFHCl/garHR--