[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200414064332.GB23359@lst.de>
Date: Tue, 14 Apr 2020 08:43:32 +0200
From: Christoph Hellwig <hch@....de>
To: David Rientjes <rientjes@...gle.com>
Cc: Christoph Hellwig <hch@....de>,
Tom Lendacky <thomas.lendacky@....com>,
"Singh, Brijesh" <brijesh.singh@....com>,
"Grimm, Jon" <jon.grimm@....com>, Joerg Roedel <joro@...tes.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"iommu@...ts.linux-foundation.org" <iommu@...ts.linux-foundation.org>
Subject: Re: [rfc v2 4/6] dma-direct: atomic allocations must come from
atomic coherent pools
> + /*
> + * Unencrypted memory must come directly from DMA atomic pools if
> + * blocking is not allowed.
> + */
> + if (IS_ENABLED(CONFIG_DMA_COHERENT_POOL) &&
> + force_dma_unencrypted(dev) && !gfpflags_allow_blocking(gfp)) {
> + ret = dma_alloc_from_pool(dev, PAGE_ALIGN(size), &page, gfp);
> + if (!ret)
> + return NULL;
> + goto done;
> + }
> +
> if (IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) &&
> dma_alloc_need_uncached(dev, attrs) &&
> !gfpflags_allow_blocking(gfp)) {
Can we keep a single conditional for the pool allocations? Maybe
add a new dma_alloc_from_pool helper ala:
static inline bool dma_alloc_from_pool(struct device *dev, gfp_t gfp)
{
if (!IS_ENABLED(CONFIG_DMA_COHERENT_POOL))
return false;
if (gfpflags_allow_blocking(gfp))
return false;
if (force_dma_unencrypted(dev))
return true;
if (dma_alloc_need_uncached(dev))
return true;
}
}
> @@ -203,6 +215,10 @@ void dma_direct_free_pages(struct device *dev, size_t size, void *cpu_addr,
> {
> unsigned int page_order = get_order(size);
>
> + if (IS_ENABLED(CONFIG_DMA_COHERENT_POOL) &&
> + dma_free_from_pool(dev, cpu_addr, PAGE_ALIGN(size)))
> + return;
> +
Similarly I think we should have a single conditional to free from the
pool instead.
Powered by blists - more mailing lists