[PATCH v3 01/15] iommu/amd: Rename DEV_DOMID_MASK to DTE_DOMID_MASK

Suravee Suthikulpanit posted 15 patches 2 months, 1 week ago
There is a newer version of this series
[PATCH v3 01/15] iommu/amd: Rename DEV_DOMID_MASK to DTE_DOMID_MASK
Posted by Suravee Suthikulpanit 2 months, 1 week ago
Also change the define to use GENMASK_ULL instead.
There is no functional change.

Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
 drivers/iommu/amd/amd_iommu_types.h | 2 +-
 drivers/iommu/amd/iommu.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
index a698a2e7ce2a..556f1df32d53 100644
--- a/drivers/iommu/amd/amd_iommu_types.h
+++ b/drivers/iommu/amd/amd_iommu_types.h
@@ -422,7 +422,7 @@
 
 #define DTE_FLAG_IOTLB	BIT_ULL(32)
 #define DTE_FLAG_MASK	(0x3ffULL << 32)
-#define DEV_DOMID_MASK	0xffffULL
+#define DTE_DOMID_MASK	GENMASK_ULL(15, 0)
 
 #define DTE_GCR3_14_12	GENMASK_ULL(60, 58)
 #define DTE_GCR3_30_15	GENMASK_ULL(31, 16)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index b57a6993179d..a9b17d31a969 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2094,7 +2094,7 @@ static void set_dte_entry(struct amd_iommu *iommu,
 	if (dev_data->ats_enabled)
 		new.data[1] |= DTE_FLAG_IOTLB;
 
-	old_domid = READ_ONCE(dte->data[1]) & DEV_DOMID_MASK;
+	old_domid = READ_ONCE(dte->data[1]) & DTE_DOMID_MASK;
 	new.data[1] |= domid;
 
 	/*
-- 
2.34.1
Re: [PATCH v3 01/15] iommu/amd: Rename DEV_DOMID_MASK to DTE_DOMID_MASK
Posted by Sairaj Kodilkar 2 months ago

On 10/10/2025 5:27 AM, Suravee Suthikulpanit wrote:
> Also change the define to use GENMASK_ULL instead.
> There is no functional change.
>
> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
>   drivers/iommu/amd/amd_iommu_types.h | 2 +-
>   drivers/iommu/amd/iommu.c           | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
> index a698a2e7ce2a..556f1df32d53 100644
> --- a/drivers/iommu/amd/amd_iommu_types.h
> +++ b/drivers/iommu/amd/amd_iommu_types.h
> @@ -422,7 +422,7 @@
>   
>   #define DTE_FLAG_IOTLB	BIT_ULL(32)
>   #define DTE_FLAG_MASK	(0x3ffULL << 32)
> -#define DEV_DOMID_MASK	0xffffULL
> +#define DTE_DOMID_MASK	GENMASK_ULL(15, 0)
>   
>   #define DTE_GCR3_14_12	GENMASK_ULL(60, 58)
>   #define DTE_GCR3_30_15	GENMASK_ULL(31, 16)
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index b57a6993179d..a9b17d31a969 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2094,7 +2094,7 @@ static void set_dte_entry(struct amd_iommu *iommu,
>   	if (dev_data->ats_enabled)
>   		new.data[1] |= DTE_FLAG_IOTLB;
>   
> -	old_domid = READ_ONCE(dte->data[1]) & DEV_DOMID_MASK;
> +	old_domid = READ_ONCE(dte->data[1]) & DTE_DOMID_MASK;
>   	new.data[1] |= domid;
>   
>   	/*
Hi suravee
Please update the replace the usage of DEV_DOMID_MASK in
init.c:__copy_device_table as well

Thanks
Sairaj
Re: [PATCH v3 01/15] iommu/amd: Rename DEV_DOMID_MASK to DTE_DOMID_MASK
Posted by Suthikulpanit, Suravee 2 months ago

On 10/13/2025 5:51 AM, Sairaj Kodilkar wrote:
> 
> 
> On 10/10/2025 5:27 AM, Suravee Suthikulpanit wrote:
>> Also change the define to use GENMASK_ULL instead.
>> There is no functional change.
>>
>> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
>> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
>> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>> ---
>>   drivers/iommu/amd/amd_iommu_types.h | 2 +-
>>   drivers/iommu/amd/iommu.c           | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iommu/amd/amd_iommu_types.h 
>> b/drivers/iommu/amd/amd_iommu_types.h
>> index a698a2e7ce2a..556f1df32d53 100644
>> --- a/drivers/iommu/amd/amd_iommu_types.h
>> +++ b/drivers/iommu/amd/amd_iommu_types.h
>> @@ -422,7 +422,7 @@
>>   #define DTE_FLAG_IOTLB    BIT_ULL(32)
>>   #define DTE_FLAG_MASK    (0x3ffULL << 32)
>> -#define DEV_DOMID_MASK    0xffffULL
>> +#define DTE_DOMID_MASK    GENMASK_ULL(15, 0)
>>   #define DTE_GCR3_14_12    GENMASK_ULL(60, 58)
>>   #define DTE_GCR3_30_15    GENMASK_ULL(31, 16)
>> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
>> index b57a6993179d..a9b17d31a969 100644
>> --- a/drivers/iommu/amd/iommu.c
>> +++ b/drivers/iommu/amd/iommu.c
>> @@ -2094,7 +2094,7 @@ static void set_dte_entry(struct amd_iommu *iommu,
>>       if (dev_data->ats_enabled)
>>           new.data[1] |= DTE_FLAG_IOTLB;
>> -    old_domid = READ_ONCE(dte->data[1]) & DEV_DOMID_MASK;
>> +    old_domid = READ_ONCE(dte->data[1]) & DTE_DOMID_MASK;
>>       new.data[1] |= domid;
>>       /*
> Hi suravee
> Please update the replace the usage of DEV_DOMID_MASK in
> init.c:__copy_device_table as well

That logic should already be removed by the following commit in the 
iommu next branch.

commit 38e5f33ee3596f37ee8d1e694073a17590904004
Author: Ashish Kalra <ashish.kalra@amd.com>
Date:   Mon Aug 25 21:46:15 2025 +0000

     iommu/amd: Reuse device table for kdump

https://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git/commit/?h=next&id=38e5f33ee3596f37ee8d1e694073a17590904004

Thanks,
Suravee