linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu: arm-smmu: Fix Tegra workaround for PAGE_SIZE mappings
@ 2024-07-17  7:21 Ashish Mhetre
  2024-07-23 16:11 ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: Ashish Mhetre @ 2024-07-17  7:21 UTC (permalink / raw)
  To: thierry.reding, vdumpa, will, robin.murphy, joro
  Cc: linux-tegra, linux-arm-kernel, iommu, linux-kernel, Ashish Mhetre

PAGE_SIZE can be 16KB for Tegra which is not supported by MMU-500 on
both Tegra194 and Tegra234. So, use 4KB mappings when PAGE_SIZE is 16KB.

Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
 drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
index 4b2994b6126d..bb621a94f6fe 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
@@ -273,11 +273,12 @@ static int nvidia_smmu_init_context(struct arm_smmu_domain *smmu_domain,
 	 * release of PMD entry and avoid translations seeing stale PMD entry in
 	 * walk cache.
 	 * Fix this by limiting the page mappings to PAGE_SIZE on Tegra194 and
-	 * Tegra234.
+	 * Tegra234. Use 4K page mappings if PAGE_SIZE is 16K as MMU500 doesn't
+	 * support it.
 	 */
 	if (of_device_is_compatible(np, "nvidia,tegra234-smmu") ||
 	    of_device_is_compatible(np, "nvidia,tegra194-smmu")) {
-		smmu->pgsize_bitmap = PAGE_SIZE;
+		smmu->pgsize_bitmap = (PAGE_SIZE == SZ_16K) ? SZ_4K : PAGE_SIZE;
 		pgtbl_cfg->pgsize_bitmap = smmu->pgsize_bitmap;
 	}
 
-- 
2.25.1



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

* Re: [PATCH] iommu: arm-smmu: Fix Tegra workaround for PAGE_SIZE mappings
  2024-07-17  7:21 [PATCH] iommu: arm-smmu: Fix Tegra workaround for PAGE_SIZE mappings Ashish Mhetre
@ 2024-07-23 16:11 ` Will Deacon
  2024-07-24  4:52   ` Ashish Mhetre
  0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2024-07-23 16:11 UTC (permalink / raw)
  To: Ashish Mhetre
  Cc: thierry.reding, vdumpa, robin.murphy, joro, linux-tegra,
	linux-arm-kernel, iommu, linux-kernel

On Wed, Jul 17, 2024 at 07:21:45AM +0000, Ashish Mhetre wrote:
> PAGE_SIZE can be 16KB for Tegra which is not supported by MMU-500 on
> both Tegra194 and Tegra234. So, use 4KB mappings when PAGE_SIZE is 16KB.
> 
> Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
> ---
>  drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
> index 4b2994b6126d..bb621a94f6fe 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
> @@ -273,11 +273,12 @@ static int nvidia_smmu_init_context(struct arm_smmu_domain *smmu_domain,
>  	 * release of PMD entry and avoid translations seeing stale PMD entry in
>  	 * walk cache.
>  	 * Fix this by limiting the page mappings to PAGE_SIZE on Tegra194 and
> -	 * Tegra234.
> +	 * Tegra234. Use 4K page mappings if PAGE_SIZE is 16K as MMU500 doesn't
> +	 * support it.
>  	 */
>  	if (of_device_is_compatible(np, "nvidia,tegra234-smmu") ||
>  	    of_device_is_compatible(np, "nvidia,tegra194-smmu")) {
> -		smmu->pgsize_bitmap = PAGE_SIZE;
> +		smmu->pgsize_bitmap = (PAGE_SIZE == SZ_16K) ? SZ_4K : PAGE_SIZE;

Perhaps it would be more robust to do a read-modify-write of the
pgsize_bitmap, preserving all the page-sizes that are <= PAGE_SIZE (i.e.
and it with something like GENMASK(PAGE_SHIFT, 0)?

Will


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

* Re: [PATCH] iommu: arm-smmu: Fix Tegra workaround for PAGE_SIZE mappings
  2024-07-23 16:11 ` Will Deacon
@ 2024-07-24  4:52   ` Ashish Mhetre
  0 siblings, 0 replies; 3+ messages in thread
From: Ashish Mhetre @ 2024-07-24  4:52 UTC (permalink / raw)
  To: Will Deacon
  Cc: thierry.reding, vdumpa, robin.murphy, joro, linux-tegra,
	linux-arm-kernel, iommu, linux-kernel


On 7/23/2024 9:41 PM, Will Deacon wrote:
> External email: Use caution opening links or attachments
>
>
> On Wed, Jul 17, 2024 at 07:21:45AM +0000, Ashish Mhetre wrote:
>> PAGE_SIZE can be 16KB for Tegra which is not supported by MMU-500 on
>> both Tegra194 and Tegra234. So, use 4KB mappings when PAGE_SIZE is 16KB.
>>
>> Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
>> ---
>>   drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
>> index 4b2994b6126d..bb621a94f6fe 100644
>> --- a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
>> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c
>> @@ -273,11 +273,12 @@ static int nvidia_smmu_init_context(struct arm_smmu_domain *smmu_domain,
>>         * release of PMD entry and avoid translations seeing stale PMD entry in
>>         * walk cache.
>>         * Fix this by limiting the page mappings to PAGE_SIZE on Tegra194 and
>> -      * Tegra234.
>> +      * Tegra234. Use 4K page mappings if PAGE_SIZE is 16K as MMU500 doesn't
>> +      * support it.
>>         */
>>        if (of_device_is_compatible(np, "nvidia,tegra234-smmu") ||
>>            of_device_is_compatible(np, "nvidia,tegra194-smmu")) {
>> -             smmu->pgsize_bitmap = PAGE_SIZE;
>> +             smmu->pgsize_bitmap = (PAGE_SIZE == SZ_16K) ? SZ_4K : PAGE_SIZE;
> Perhaps it would be more robust to do a read-modify-write of the
> pgsize_bitmap, preserving all the page-sizes that are <= PAGE_SIZE (i.e.
> and it with something like GENMASK(PAGE_SHIFT, 0)?
>
> Will


Thanks for the review Will. Yes, that will be a better approach as
pgsize_bitmap will never be with 16K granularity for Tegra.
I will send new version with this update.



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

end of thread, other threads:[~2024-07-24  4:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-17  7:21 [PATCH] iommu: arm-smmu: Fix Tegra workaround for PAGE_SIZE mappings Ashish Mhetre
2024-07-23 16:11 ` Will Deacon
2024-07-24  4:52   ` Ashish Mhetre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).