Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: "Gaël PORTAY" <gael.portay@collabora.com>
Cc: Laura Abbott <labbott@redhat.com>,
	linux-mm@kvack.org, kernel@collabora.com,
	Gabriel Krisman Bertazi <krisman@collabora.com>,
	linux-arm-kernel@lists.infradead.org,
	Mike Kravetz <mike.kravetz@oracle.com>
Subject: Re: [PATCH] ARM: dma-mapping: prevent writeback deadlock in CMA allocator
Date: Tue, 12 Feb 2019 10:25:11 -0800
Message-ID: <20190212182511.GA10532@infradead.org> (raw)
In-Reply-To: <20190212042458.31856-1-gael.portay@collabora.com>

On Mon, Feb 11, 2019 at 11:24:58PM -0500, Gaël PORTAY wrote:
> The ARM DMA layer checks for allow blocking flag (__GFP_DIRECT_RECLAIM)
> to decide whether to go for CMA or not. That test is not sufficient to
> cover the case of writeback (GFP_NOIO).

The ARM DMA layer doesn't, the CMA helper does.

> -	bool allowblock, cma;
> +	bool allowblock, allowwriteback, cma;
>  	struct arm_dma_buffer *buf;
>  	struct arm_dma_alloc_args args = {
>  		.dev = dev,
> @@ -769,7 +769,8 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
>  
>  	*handle = DMA_MAPPING_ERROR;
>  	allowblock = gfpflags_allow_blocking(gfp);
> -	cma = allowblock ? dev_get_cma_area(dev) : false;
> +	allowwriteback = gfpflags_allow_writeback(gfp);
> +	cma = (allowblock && !allowwriteback) ? dev_get_cma_area(dev) : false;

But this only fixes ARM, but not all the user callers of
gfpflags_allow_blocking and dma_alloc_from_contiguous.

I think we just need a dma_can_alloc_from_contigous helper and
switch all callers of dma_alloc_from_contiguous to it.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12  4:24 Gaël PORTAY
2019-02-12 18:25 ` Christoph Hellwig [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190212182511.GA10532@infradead.org \
    --to=hch@infradead.org \
    --cc=gael.portay@collabora.com \
    --cc=kernel@collabora.com \
    --cc=krisman@collabora.com \
    --cc=labbott@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git