[PATCH V1] accel/amdxdna: Preserve user address when PASID is disabled

Lizhi Hou posted 1 patch 5 days, 23 hours ago
drivers/accel/amdxdna/amdxdna_gem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[PATCH V1] accel/amdxdna: Preserve user address when PASID is disabled
Posted by Lizhi Hou 5 days, 23 hours ago
When PASID is not used, the buffer user address is set to
AMDXDNA_INVALID_ADDR. As a result, heap buffer user address validation
fails even though the original userspace address is available.

Preserve the userspace address regardless of PASID usage so heap buffer
address validation works correctly.

Fixes: dbc8fd7a03cb ("accel/amdxdna: Add expandable device heap support")
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
 drivers/accel/amdxdna/amdxdna_gem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
index 77e5fad08ae5..33cf5af98ceb 100644
--- a/drivers/accel/amdxdna/amdxdna_gem.c
+++ b/drivers/accel/amdxdna/amdxdna_gem.c
@@ -349,8 +349,11 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
 	u32 nr_pages;
 	int ret;
 
-	if (!amdxdna_pasid_on(abo->client))
+	if (!amdxdna_pasid_on(abo->client)) {
+		/* Need to set uva for heap uva validation */
+		abo->mem.uva = addr;
 		return 0;
+	}
 
 	mapp = kzalloc_obj(*mapp);
 	if (!mapp)
-- 
2.34.1
Re: [PATCH V1] accel/amdxdna: Preserve user address when PASID is disabled
Posted by Mario Limonciello 5 days, 13 hours ago

On 6/1/26 23:06, Lizhi Hou wrote:
> When PASID is not used, the buffer user address is set to
> AMDXDNA_INVALID_ADDR. As a result, heap buffer user address validation
> fails even though the original userspace address is available.
> 
> Preserve the userspace address regardless of PASID usage so heap buffer
> address validation works correctly.
> 
> Fixes: dbc8fd7a03cb ("accel/amdxdna: Add expandable device heap support")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
>   drivers/accel/amdxdna/amdxdna_gem.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index 77e5fad08ae5..33cf5af98ceb 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
> @@ -349,8 +349,11 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
>   	u32 nr_pages;
>   	int ret;
>   
> -	if (!amdxdna_pasid_on(abo->client))
> +	if (!amdxdna_pasid_on(abo->client)) {
> +		/* Need to set uva for heap uva validation */
> +		abo->mem.uva = addr;
>   		return 0;
> +	}
>   
>   	mapp = kzalloc_obj(*mapp);
>   	if (!mapp)
Re: [PATCH V1] accel/amdxdna: Preserve user address when PASID is disabled
Posted by Lizhi Hou 5 days, 11 hours ago
Applied to drm-misc-next-fixes

On 6/2/26 07:15, Mario Limonciello wrote:
>
>
> On 6/1/26 23:06, Lizhi Hou wrote:
>> When PASID is not used, the buffer user address is set to
>> AMDXDNA_INVALID_ADDR. As a result, heap buffer user address validation
>> fails even though the original userspace address is available.
>>
>> Preserve the userspace address regardless of PASID usage so heap buffer
>> address validation works correctly.
>>
>> Fixes: dbc8fd7a03cb ("accel/amdxdna: Add expandable device heap 
>> support")
>> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
>> ---
>>   drivers/accel/amdxdna/amdxdna_gem.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c 
>> b/drivers/accel/amdxdna/amdxdna_gem.c
>> index 77e5fad08ae5..33cf5af98ceb 100644
>> --- a/drivers/accel/amdxdna/amdxdna_gem.c
>> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
>> @@ -349,8 +349,11 @@ static int amdxdna_hmm_register(struct 
>> amdxdna_gem_obj *abo,
>>       u32 nr_pages;
>>       int ret;
>>   -    if (!amdxdna_pasid_on(abo->client))
>> +    if (!amdxdna_pasid_on(abo->client)) {
>> +        /* Need to set uva for heap uva validation */
>> +        abo->mem.uva = addr;
>>           return 0;
>> +    }
>>         mapp = kzalloc_obj(*mapp);
>>       if (!mapp)
>