The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH V1] accel/amdxdna: Require carveout when PASID and force_iova are disabled
@ 2026-06-04 19:54 Lizhi Hou
  2026-06-04 19:56 ` Mario Limonciello
  0 siblings, 1 reply; 3+ messages in thread
From: Lizhi Hou @ 2026-06-04 19:54 UTC (permalink / raw)
  To: ogabbay, quic_jhugo, dri-devel, mario.limonciello,
	karol.wachowski
  Cc: Lizhi Hou, linux-kernel, max.zhen, sonal.santan

When both PASID and force_iova are disabled, carveout memory should be
used. Reject buffer allocations that cannot use carveout memory in this
configuration and return an error.

Fixes: 3cc5d7a59519 ("accel/amdxdna: Add carveout memory support for non-IOMMU systems")
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
 drivers/accel/amdxdna/amdxdna_pci_drv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/accel/amdxdna/amdxdna_pci_drv.c b/drivers/accel/amdxdna/amdxdna_pci_drv.c
index c677293c1ae7..1f066ed8d236 100644
--- a/drivers/accel/amdxdna/amdxdna_pci_drv.c
+++ b/drivers/accel/amdxdna/amdxdna_pci_drv.c
@@ -120,8 +120,14 @@ static int amdxdna_drm_open(struct drm_device *ddev, struct drm_file *filp)
 
 	if (!amdxdna_iova_on(xdna)) {
 		/* No need to fail open since user may use pa + carveout later. */
-		if (amdxdna_sva_init(client))
+		if (amdxdna_sva_init(client)) {
 			XDNA_WARN(xdna, "PASID not available for pid %d", client->pid);
+			if (!amdxdna_use_carveout(xdna)) {
+				XDNA_ERR(xdna, "PASID unavailable and carveout not configured");
+				kfree(client);
+				return -EINVAL;
+			}
+		}
 	}
 	mmgrab(client->mm);
 	init_srcu_struct(&client->hwctx_srcu);
-- 
2.34.1


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

* Re: [PATCH V1] accel/amdxdna: Require carveout when PASID and force_iova are disabled
  2026-06-04 19:54 [PATCH V1] accel/amdxdna: Require carveout when PASID and force_iova are disabled Lizhi Hou
@ 2026-06-04 19:56 ` Mario Limonciello
  2026-06-05 16:22   ` Lizhi Hou
  0 siblings, 1 reply; 3+ messages in thread
From: Mario Limonciello @ 2026-06-04 19:56 UTC (permalink / raw)
  To: Lizhi Hou, ogabbay, quic_jhugo, dri-devel, karol.wachowski
  Cc: linux-kernel, max.zhen, sonal.santan



On 6/4/26 14:54, Lizhi Hou wrote:
> When both PASID and force_iova are disabled, carveout memory should be
> used. Reject buffer allocations that cannot use carveout memory in this
> configuration and return an error.
> 
> Fixes: 3cc5d7a59519 ("accel/amdxdna: Add carveout memory support for non-IOMMU systems")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
>   drivers/accel/amdxdna/amdxdna_pci_drv.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/accel/amdxdna/amdxdna_pci_drv.c b/drivers/accel/amdxdna/amdxdna_pci_drv.c
> index c677293c1ae7..1f066ed8d236 100644
> --- a/drivers/accel/amdxdna/amdxdna_pci_drv.c
> +++ b/drivers/accel/amdxdna/amdxdna_pci_drv.c
> @@ -120,8 +120,14 @@ static int amdxdna_drm_open(struct drm_device *ddev, struct drm_file *filp)
>   
>   	if (!amdxdna_iova_on(xdna)) {
>   		/* No need to fail open since user may use pa + carveout later. */
> -		if (amdxdna_sva_init(client))
> +		if (amdxdna_sva_init(client)) {
>   			XDNA_WARN(xdna, "PASID not available for pid %d", client->pid);
> +			if (!amdxdna_use_carveout(xdna)) {
> +				XDNA_ERR(xdna, "PASID unavailable and carveout not configured");
> +				kfree(client);
> +				return -EINVAL;
> +			}
> +		}
>   	}
>   	mmgrab(client->mm);
>   	init_srcu_struct(&client->hwctx_srcu);


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

* Re: [PATCH V1] accel/amdxdna: Require carveout when PASID and force_iova are disabled
  2026-06-04 19:56 ` Mario Limonciello
@ 2026-06-05 16:22   ` Lizhi Hou
  0 siblings, 0 replies; 3+ messages in thread
From: Lizhi Hou @ 2026-06-05 16:22 UTC (permalink / raw)
  To: Mario Limonciello, ogabbay, quic_jhugo, dri-devel,
	karol.wachowski
  Cc: linux-kernel, max.zhen, sonal.santan

Applied to drm-misc-next-fixes

On 6/4/26 12:56, Mario Limonciello wrote:
>
>
> On 6/4/26 14:54, Lizhi Hou wrote:
>> When both PASID and force_iova are disabled, carveout memory should be
>> used. Reject buffer allocations that cannot use carveout memory in this
>> configuration and return an error.
>>
>> Fixes: 3cc5d7a59519 ("accel/amdxdna: Add carveout memory support for 
>> non-IOMMU systems")
>> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
>> ---
>>   drivers/accel/amdxdna/amdxdna_pci_drv.c | 8 +++++++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/accel/amdxdna/amdxdna_pci_drv.c 
>> b/drivers/accel/amdxdna/amdxdna_pci_drv.c
>> index c677293c1ae7..1f066ed8d236 100644
>> --- a/drivers/accel/amdxdna/amdxdna_pci_drv.c
>> +++ b/drivers/accel/amdxdna/amdxdna_pci_drv.c
>> @@ -120,8 +120,14 @@ static int amdxdna_drm_open(struct drm_device 
>> *ddev, struct drm_file *filp)
>>         if (!amdxdna_iova_on(xdna)) {
>>           /* No need to fail open since user may use pa + carveout 
>> later. */
>> -        if (amdxdna_sva_init(client))
>> +        if (amdxdna_sva_init(client)) {
>>               XDNA_WARN(xdna, "PASID not available for pid %d", 
>> client->pid);
>> +            if (!amdxdna_use_carveout(xdna)) {
>> +                XDNA_ERR(xdna, "PASID unavailable and carveout not 
>> configured");
>> +                kfree(client);
>> +                return -EINVAL;
>> +            }
>> +        }
>>       }
>>       mmgrab(client->mm);
>>       init_srcu_struct(&client->hwctx_srcu);
>

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

end of thread, other threads:[~2026-06-05 16:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04 19:54 [PATCH V1] accel/amdxdna: Require carveout when PASID and force_iova are disabled Lizhi Hou
2026-06-04 19:56 ` Mario Limonciello
2026-06-05 16:22   ` Lizhi Hou

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