IOMMU Archive mirror
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: John Hsu <john.hsu@mediatek.com>, Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>
Cc: surenb@google.com, Chinwen Chang <chinwen.change@mediatek.com>,
	Casper Li <casper.li@mediatek.com>,
	Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH] direct-dma: WARN_ON_ONCE when the page is not addressable by device's coherent_dma_mask
Date: Wed, 13 Mar 2024 12:43:52 +0000	[thread overview]
Message-ID: <6b2fa7af-0fef-4c18-a6ff-1bf4ea16810f@arm.com> (raw)
In-Reply-To: <20240313121933.15839-1-john.hsu@mediatek.com>

On 2024-03-13 12:19 pm, John Hsu wrote:
> From: JohnHsu <john.hsu@mediatek.com>
> 
> The dma_direct_alloc() may return null in some cases. For example, the
> allocated page is not addressable for the device's coherent_dma_mask,
> and the allocated page will be assigned to null.
> 
> This patch can WARN_ON_ONCE() when the returned page is null in
> dma_direct_alloc. It helps the developers position the root cause of
> allocation failure rapidly.

No. Failure to allocate a buffer can happen for any number of reasons, 
it is not specific to dma-direct, and in some cases it is even expected, 
hence why DMA_ATTR_NO_WARN exists. And either way it's still not a 
condition worthy of panicking when panic_on_warn is in use.

Sure, this may well be a handy development hack for debugging a 
particular driver which isn't handling failure correctly, but it is not 
suitable for mainline.

Thanks,
Robin.

> Signed-off-by: JohnHsu <john.hsu@mediatek.com>
> ---
>   kernel/dma/direct.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> index 9596ae1aa0da..a73b8ad1ef9e 100644
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -156,6 +156,8 @@ static struct page *__dma_direct_alloc_pages(struct device *dev, size_t size,
>   		}
>   	}
>   
> +	WARN_ON_ONCE(!page);
> +
>   	return page;
>   }
>   

      reply	other threads:[~2024-03-13 12:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 12:19 [PATCH] direct-dma: WARN_ON_ONCE when the page is not addressable by device's coherent_dma_mask John Hsu
2024-03-13 12:43 ` Robin Murphy [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=6b2fa7af-0fef-4c18-a6ff-1bf4ea16810f@arm.com \
    --to=robin.murphy@arm.com \
    --cc=Kuan-Ying.Lee@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=casper.li@mediatek.com \
    --cc=chinwen.change@mediatek.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=john.hsu@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=m.szyprowski@samsung.com \
    --cc=matthias.bgg@gmail.com \
    --cc=surenb@google.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).