[PATCH V1] accel/amdxdna: Block running when IOMMU is off

Lizhi Hou posted 1 patch 3 days, 23 hours ago
drivers/accel/amdxdna/aie2_pci.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH V1] accel/amdxdna: Block running when IOMMU is off
Posted by Lizhi Hou 3 days, 23 hours ago
The AIE2 device firmware requires IOMMU on.

Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5319
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
 drivers/accel/amdxdna/aie2_pci.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/amdxdna/aie2_pci.c
index c4d345d4c76b..22f66c7f534d 100644
--- a/drivers/accel/amdxdna/aie2_pci.c
+++ b/drivers/accel/amdxdna/aie2_pci.c
@@ -490,6 +490,11 @@ static int aie2_init(struct amdxdna_dev *xdna)
 		return -EINVAL;
 	}
 
+	if (!xdna->group) {
+		XDNA_ERR(xdna, "Running without IOMMU not supported");
+		return -EINVAL;
+	}
+
 	ndev = drmm_kzalloc(&xdna->ddev, sizeof(*ndev), GFP_KERNEL);
 	if (!ndev)
 		return -ENOMEM;
-- 
2.34.1
Re: [PATCH V1] accel/amdxdna: Block running when IOMMU is off
Posted by Mario Limonciello 3 days, 20 hours ago

On 5/20/26 17:35, Lizhi Hou wrote:
> The AIE2 device firmware requires IOMMU on.
> 
> Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5319
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
> ---
>   drivers/accel/amdxdna/aie2_pci.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/amdxdna/aie2_pci.c
> index c4d345d4c76b..22f66c7f534d 100644
> --- a/drivers/accel/amdxdna/aie2_pci.c
> +++ b/drivers/accel/amdxdna/aie2_pci.c
> @@ -490,6 +490,11 @@ static int aie2_init(struct amdxdna_dev *xdna)
>   		return -EINVAL;
>   	}
>   
> +	if (!xdna->group) {
> +		XDNA_ERR(xdna, "Running without IOMMU not supported");
> +		return -EINVAL;
> +	}
> +
>   	ndev = drmm_kzalloc(&xdna->ddev, sizeof(*ndev), GFP_KERNEL);
>   	if (!ndev)
>   		return -ENOMEM;

I think it would be better to change the return for amdxdna_iommu_init().

This has a check that lets !xdna->group pass; which can be turned into 
an error code instead.
Re: [PATCH V1] accel/amdxdna: Block running when IOMMU is off
Posted by Lizhi Hou 3 days, 17 hours ago
On 5/20/26 17:57, Mario Limonciello wrote:
>
>
> On 5/20/26 17:35, Lizhi Hou wrote:
>> The AIE2 device firmware requires IOMMU on.
>>
>> Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5319
>> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
>> ---
>>   drivers/accel/amdxdna/aie2_pci.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/accel/amdxdna/aie2_pci.c 
>> b/drivers/accel/amdxdna/aie2_pci.c
>> index c4d345d4c76b..22f66c7f534d 100644
>> --- a/drivers/accel/amdxdna/aie2_pci.c
>> +++ b/drivers/accel/amdxdna/aie2_pci.c
>> @@ -490,6 +490,11 @@ static int aie2_init(struct amdxdna_dev *xdna)
>>           return -EINVAL;
>>       }
>>   +    if (!xdna->group) {
>> +        XDNA_ERR(xdna, "Running without IOMMU not supported");
>> +        return -EINVAL;
>> +    }
>> +
>>       ndev = drmm_kzalloc(&xdna->ddev, sizeof(*ndev), GFP_KERNEL);
>>       if (!ndev)
>>           return -ENOMEM;
>
> I think it would be better to change the return for amdxdna_iommu_init().

amdxdna_iommu_init() is common code for all kinds of hardware. I would 
keep the check only for AIE2 now, which is known to require IOMMU on.


Lizhi

>
> This has a check that lets !xdna->group pass; which can be turned into 
> an error code instead.
Re: [PATCH V1] accel/amdxdna: Block running when IOMMU is off
Posted by Mario Limonciello 3 days, 17 hours ago

On 5/20/26 22:43, Lizhi Hou wrote:
> 
> On 5/20/26 17:57, Mario Limonciello wrote:
>>
>>
>> On 5/20/26 17:35, Lizhi Hou wrote:
>>> The AIE2 device firmware requires IOMMU on.
>>>
>>> Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5319
>>> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
>>> ---
>>>   drivers/accel/amdxdna/aie2_pci.c | 5 +++++
>>>   1 file changed, 5 insertions(+)
>>>
>>> diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/ 
>>> amdxdna/aie2_pci.c
>>> index c4d345d4c76b..22f66c7f534d 100644
>>> --- a/drivers/accel/amdxdna/aie2_pci.c
>>> +++ b/drivers/accel/amdxdna/aie2_pci.c
>>> @@ -490,6 +490,11 @@ static int aie2_init(struct amdxdna_dev *xdna)
>>>           return -EINVAL;
>>>       }
>>>   +    if (!xdna->group) {
>>> +        XDNA_ERR(xdna, "Running without IOMMU not supported");
>>> +        return -EINVAL;
>>> +    }
>>> +
>>>       ndev = drmm_kzalloc(&xdna->ddev, sizeof(*ndev), GFP_KERNEL);
>>>       if (!ndev)
>>>           return -ENOMEM;
>>
>> I think it would be better to change the return for amdxdna_iommu_init().
> 
> amdxdna_iommu_init() is common code for all kinds of hardware. I would 
> keep the check only for AIE2 now, which is known to require IOMMU on.
Got it.  Then this makes sense.

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> 
> 
> Lizhi
> 
>>
>> This has a check that lets !xdna->group pass; which can be turned into 
>> an error code instead.

Re: [PATCH V1] accel/amdxdna: Block running when IOMMU is off
Posted by Lizhi Hou 3 days, 4 hours ago
Applied to drm-misc-fixes

On 5/20/26 21:32, Mario Limonciello wrote:
>
>
> On 5/20/26 22:43, Lizhi Hou wrote:
>>
>> On 5/20/26 17:57, Mario Limonciello wrote:
>>>
>>>
>>> On 5/20/26 17:35, Lizhi Hou wrote:
>>>> The AIE2 device firmware requires IOMMU on.
>>>>
>>>> Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5319
>>>> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
>>>> ---
>>>>   drivers/accel/amdxdna/aie2_pci.c | 5 +++++
>>>>   1 file changed, 5 insertions(+)
>>>>
>>>> diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/ 
>>>> amdxdna/aie2_pci.c
>>>> index c4d345d4c76b..22f66c7f534d 100644
>>>> --- a/drivers/accel/amdxdna/aie2_pci.c
>>>> +++ b/drivers/accel/amdxdna/aie2_pci.c
>>>> @@ -490,6 +490,11 @@ static int aie2_init(struct amdxdna_dev *xdna)
>>>>           return -EINVAL;
>>>>       }
>>>>   +    if (!xdna->group) {
>>>> +        XDNA_ERR(xdna, "Running without IOMMU not supported");
>>>> +        return -EINVAL;
>>>> +    }
>>>> +
>>>>       ndev = drmm_kzalloc(&xdna->ddev, sizeof(*ndev), GFP_KERNEL);
>>>>       if (!ndev)
>>>>           return -ENOMEM;
>>>
>>> I think it would be better to change the return for 
>>> amdxdna_iommu_init().
>>
>> amdxdna_iommu_init() is common code for all kinds of hardware. I 
>> would keep the check only for AIE2 now, which is known to require 
>> IOMMU on.
> Got it.  Then this makes sense.
>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
>>
>>
>> Lizhi
>>
>>>
>>> This has a check that lets !xdna->group pass; which can be turned 
>>> into an error code instead.
>