[PATCH] drm/amdgpu: add print for iommu translation mode

Felix Kuehling felix.kuehling at amd.com
Fri Mar 17 21:16:21 UTC 2023


On 2023-03-17 16:04, Sider, Graham wrote:
> [AMD Official Use Only - General]
>
>
>
>> -----Original Message-----
>> From: Russell, Kent <Kent.Russell at amd.com>
>> Sent: Friday, March 17, 2023 3:58 PM
>> To: Mahfooz, Hamza <Hamza.Mahfooz at amd.com>; Sider, Graham
>> <Graham.Sider at amd.com>; amd-gfx at lists.freedesktop.org
>> Cc: Kuehling, Felix <Felix.Kuehling at amd.com>
>> Subject: RE: [PATCH] drm/amdgpu: add print for iommu translation mode
>>
>> [AMD Official Use Only - General]
>>
>>
>>
>>> -----Original Message-----
>>> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of
>>> Hamza Mahfooz
>>> Sent: Friday, March 17, 2023 3:58 PM
>>> To: Sider, Graham <Graham.Sider at amd.com>;
>>> amd-gfx at lists.freedesktop.org
>>> Cc: Kuehling, Felix <Felix.Kuehling at amd.com>
>>> Subject: Re: [PATCH] drm/amdgpu: add print for iommu translation mode
>>>
>>>
>>> On 3/17/23 15:47, Graham Sider wrote:
>>>> Add log to display whether RAM is direct vs DMA mapped.
>>>>
>>>> Signed-off-by: Graham Sider <Graham.Sider at amd.com>
>>> If this information is only useful for debugging purposes, please use
>>> drm_dbg() instead of pr_info().
> It's useful for more than just debug I would say. Just a quick way to grep whether IOMMU is off/pt vs device isolation mode.

I agree. The kernel log otherwise tells you the default IOMMU domain, 
but it may not match the domain actually used for the GPU. Without this 
message there is no easy way to tell from a kernel log. This will help 
with triaging issues from logs provided by external and internal users.


>
> Graham
>
>>>> ---
>>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++++-
>>>>    1 file changed, 5 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>>> index 8bba5e6872a1..8797a9523244 100644
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>>> @@ -3528,8 +3528,12 @@ static void
>>> amdgpu_device_check_iommu_direct_map(struct amdgpu_device *adev)
>>>>    	struct iommu_domain *domain;
>>>>
>>>>    	domain = iommu_get_domain_for_dev(adev->dev);
>>>> -	if (!domain || domain->type == IOMMU_DOMAIN_IDENTITY)
>>>> +	if (!domain || domain->type == IOMMU_DOMAIN_IDENTITY) {
>>>> +		pr_info("RAM is direct mapped to GPU (not traslated by

Use dev_info. That way you can tell which GPU the message applies to in 
a multi-GPU system.

Regards,
   Felix


>> traslated -> translated
>>
> Thanks, my keyboard keeps skipping the on the 'n' key lately :( time for a clean.
>
> Graham
>
>>   Kent
>>> IOMMU)\n");
>>>>    		adev->ram_is_direct_mapped = true;
>>>> +	} else {
>>>> +		pr_info("RAM is DMA mapped to GPU (translated by
>>> IOMMU)\n");
>>>> +	}
>>>>    }
>>>>
>>>>    static const struct attribute *amdgpu_dev_attributes[] = {
>>> --
>>> Hamza


More information about the amd-gfx mailing list