mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] accel/amdxdna: Reject device heap BO when dev_mem_size is not set
@ 2026-10-08 23:24 David Zhang
  2026-10-09 15:57 ` Lizhi Hou
  0 siblings, 1 reply; 2+ messages in thread
From: David Zhang @ 2026-10-08 23:24 UTC (permalink / raw)
  To: quic_jhugo, karol.wachowski, max.zhen, lizhi.hou, ogabbay,
	dri-devel, linux-kernel
  Cc: David Zhang, sonal.santan, mario.limonciello

NPU3 devices do not set dev_mem_size, since they do not use a device
heap. Creating an AMDXDNA_BO_DEV_HEAP BO on such a device hits the
WARN_ON(!is_power_of_2(dev_mem_size)) check, which any user with
access to the device node can trigger.

Return -EOPNOTSUPP when dev_mem_size is 0.

Fixes: d76856beb4a4 ("accel/amdxdna: Refactor GEM BO handling and add helper APIs for address retrieval")
Signed-off-by: David Zhang <yidong.zhang@amd.com>
---
 drivers/accel/amdxdna/amdxdna_gem.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
index f4832337ec31..f14484bc31ec 100644
--- a/drivers/accel/amdxdna/amdxdna_gem.c
+++ b/drivers/accel/amdxdna/amdxdna_gem.c
@@ -1140,6 +1140,11 @@ amdxdna_drm_create_dev_heap_bo(struct drm_device *dev,
 	struct amdxdna_gem_obj *abo;
 	int ret;
 
+	if (!xdna->dev_info->dev_mem_size) {
+		XDNA_DBG(xdna, "Device heap is not supported");
+		return ERR_PTR(-EOPNOTSUPP);
+	}
+
 	WARN_ON(!is_power_of_2(xdna->dev_info->dev_mem_size));
 	XDNA_DBG(xdna, "Requested dev heap size 0x%llx", args->size);
 	if (!args->size || !IS_ALIGNED(args->size, xdna->dev_info->dev_mem_size)) {
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] accel/amdxdna: Reject device heap BO when dev_mem_size is not set
  2026-10-08 23:24 [PATCH] accel/amdxdna: Reject device heap BO when dev_mem_size is not set David Zhang
@ 2026-10-09 15:57 ` Lizhi Hou
  0 siblings, 0 replies; 2+ messages in thread
From: Lizhi Hou @ 2026-10-09 15:57 UTC (permalink / raw)
  To: David Zhang, quic_jhugo, karol.wachowski, max.zhen, ogabbay,
	dri-devel, linux-kernel
  Cc: sonal.santan, mario.limonciello


On 10/8/26 16:24, David Zhang wrote:
> NPU3 devices do not set dev_mem_size, since they do not use a device
> heap. Creating an AMDXDNA_BO_DEV_HEAP BO on such a device hits the
> WARN_ON(!is_power_of_2(dev_mem_size)) check, which any user with
> access to the device node can trigger.
>
> Return -EOPNOTSUPP when dev_mem_size is 0.
>
> Fixes: d76856beb4a4 ("accel/amdxdna: Refactor GEM BO handling and add helper APIs for address retrieval")
> Signed-off-by: David Zhang <yidong.zhang@amd.com>
> ---
>   drivers/accel/amdxdna/amdxdna_gem.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index f4832337ec31..f14484bc31ec 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
> @@ -1140,6 +1140,11 @@ amdxdna_drm_create_dev_heap_bo(struct drm_device *dev,
>   	struct amdxdna_gem_obj *abo;
>   	int ret;
>   
> +	if (!xdna->dev_info->dev_mem_size) {
> +		XDNA_DBG(xdna, "Device heap is not supported");
> +		return ERR_PTR(-EOPNOTSUPP);
> +	}
> +
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
>   	WARN_ON(!is_power_of_2(xdna->dev_info->dev_mem_size));
>   	XDNA_DBG(xdna, "Requested dev heap size 0x%llx", args->size);
>   	if (!args->size || !IS_ALIGNED(args->size, xdna->dev_info->dev_mem_size)) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-09 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08 23:24 [PATCH] accel/amdxdna: Reject device heap BO when dev_mem_size is not set David Zhang
2026-10-09 15:57 ` Lizhi Hou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®