From: John Hsu <john.hsu@mediatek.com>
To: Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Robin Murphy <robin.murphy@arm.com>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Cc: <surenb@google.com>, John Hsu <john.hsu@mediatek.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: [PATCH] direct-dma: WARN_ON_ONCE when the page is not addressable by device's coherent_dma_mask
Date: Wed, 13 Mar 2024 20:19:30 +0800 [thread overview]
Message-ID: <20240313121933.15839-1-john.hsu@mediatek.com> (raw)
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.
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;
}
--
2.18.0
next reply other threads:[~2024-03-13 12:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 12:19 John Hsu [this message]
2024-03-13 12:43 ` [PATCH] direct-dma: WARN_ON_ONCE when the page is not addressable by device's coherent_dma_mask Robin Murphy
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=20240313121933.15839-1-john.hsu@mediatek.com \
--to=john.hsu@mediatek.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=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=robin.murphy@arm.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).