[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240313121933.15839-1-john.hsu@mediatek.com>
Date: Wed, 13 Mar 2024 20:19:30 +0800
From: John Hsu <john.hsu@...iatek.com>
To: Christoph Hellwig <hch@....de>, Marek Szyprowski
<m.szyprowski@...sung.com>, Robin Murphy <robin.murphy@....com>, "Matthias
Brugger" <matthias.bgg@...il.com>, AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
CC: <surenb@...gle.com>, John Hsu <john.hsu@...iatek.com>, Chinwen Chang
<chinwen.change@...iatek.com>, Casper Li <casper.li@...iatek.com>, "Kuan-Ying
Lee" <Kuan-Ying.Lee@...iatek.com>, <iommu@...ts.linux.dev>,
<linux-kernel@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
<linux-mediatek@...ts.infradead.org>
Subject: [PATCH] direct-dma: WARN_ON_ONCE when the page is not addressable by device's coherent_dma_mask
From: JohnHsu <john.hsu@...iatek.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@...iatek.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
Powered by blists - more mailing lists