Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp693546ybt; Wed, 8 Jul 2020 09:21:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOGNIK0t0jMd92QsH0qJ9CzHP3krmx+G21cAnq3Eykk6WWXq8p4JF8hNi9y1v/jDcelb2C X-Received: by 2002:a17:906:f20d:: with SMTP id gt13mr27990322ejb.117.1594225286498; Wed, 08 Jul 2020 09:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594225286; cv=none; d=google.com; s=arc-20160816; b=r7zrgsLJJdYTd1JywSgDtFDaNk7HQL30rX9BU5jCvdPym8L2e1nyN+6N0sXYeViFJm 9ACp5+L1jWSQ0DGt1Q8aNvO9Kr1vzaBgHwgL8vQTe3V53/n+1ttLF3DDDe6GrF4H3hfX E3pk647JAMKOyHamGY9F/ukt6p4FpVUgzKN+40On/oSqcTrfJQeqWoa4R4xOdSFWIGuP NOgUjfujHKno3KJlffomJcLMm2r9K4lBwexLl0LviCAf0L7AJh4eJfE8TEbDOh1njWC7 nQaIIgoYod2XeW1jrFYfjlsfCGuVAOrPXa8m3gPt5+oZboAvdCNkba8sk/tzWtJ54Er5 d/OQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=REvC9LVWiHywBG8LgfsaH4W1s6UfhuidyWhvpza19RI=; b=bUQsqQE0IGZfBCDjKP3ClpMdAgon4iL2GItFXNJ6GYo5G/y+7p0J4TVyqbC3P88yU8 S6wHNgyk/OREblpVmUVkw/Gu9qj+5dC3lDY+Awk9xstG5v0rmr48OwFOYnFjqLrxCqXO AO6rIbAWAGna/v7XCwG5gcTc869WMZT/6Od67+/z+YeMq3o560bsh7HENj4PREh185Gx LtDCEd9S9qQhwdDN/4zl+jamLlfqvQcDp0oSw8PzrU574O0A7pvhqpcWuIDTf5epS5Vf c0Ntx5hOyTyd7FiWDY3nJTDI5F7lAeqhD12OCwKURvP62vgYQPfQKouDEOckaPj0GXYi tRsw== 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 x13si176205ejb.488.2020.07.08.09.21.03; Wed, 08 Jul 2020 09:21:26 -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 S1730316AbgGHQUT (ORCPT + 99 others); Wed, 8 Jul 2020 12:20:19 -0400 Received: from foss.arm.com ([217.140.110.172]:49976 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730260AbgGHQUS (ORCPT ); Wed, 8 Jul 2020 12:20:18 -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 33BB831B; Wed, 8 Jul 2020 09:20:18 -0700 (PDT) Received: from [10.57.21.32] (unknown [10.57.21.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D5F663F68F; Wed, 8 Jul 2020 09:20:16 -0700 (PDT) Subject: Re: [PATCH] dma-pool: use single atomic pool for both DMA zones To: Christoph Hellwig , Nicolas Saenz Julienne Cc: Jeremy Linton , Marek Szyprowski , David Rientjes , linux-rpi-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20200707122804.21262-1-nsaenzjulienne@suse.de> <21a7276e98ae245404d82537ac1ee597a92f9150.camel@suse.de> <20200708153635.GB26743@lst.de> From: Robin Murphy Message-ID: <304053c7-9f88-8830-3287-2496a4cb48cd@arm.com> Date: Wed, 8 Jul 2020 17:20:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200708153635.GB26743@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-07-08 16:36, Christoph Hellwig wrote: > On Wed, Jul 08, 2020 at 12:35:34PM +0200, Nicolas Saenz Julienne wrote: >>> Which allows me to switch between ACPI/DT on the machine. In DT mode it >>> works fine now, >> >> Nice, would that count as a Tested-by from you? >> >>> but with ACPI I continue to have failures unless I >>> disable CMA via cma=0 on the kernel command line. >> >> Yes, I see why, in atomic_pool_expand() memory is allocated from CMA without >> checking its correctness. That calls for a separate fix. I'll try to think of >> something. > > I think we need a dma_coherent_ok for the allocations from the > pool and then fall back to the next better one to get started. And > yes, CMA is a bit of a mess, that generally needs better checks. Yeah, another thought that came to mind later is that iommu-dma can use pages from any pool regardless of the device's DMA mask, so we could stand to be a lot less restrictive in that case too. Perhaps it is better to just bite the bullet, keep the straightforward one-pool-per-zone setup, and implement the dma_coherent_ok() type fallback logic. More complexity for dma_alloc_from_pool(), but everything else stays nice and simple - lose the assumption that dev_to_pool() can work for this and and just let callers pass an allocation mask directly, and have dma_free_from_pool() simply check all available pools. Robin.