From 44c4611fda8769240c8575f02a691ea5eaeffc71 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Wed, 28 Apr 2021 22:39:17 +0530 Subject: [PATCH] gpu: nvgpu: update pd clear condition to address IOMMU prefetch issue IOMMU fault is observed with 64KB PAGE_SIZE. This is due to IOMMU prefetching stale/invalid pd entries. IOMMU can prefetch more than 4K worth of entries. Clear pd when NVGPU_PD_CACHE_SIZE is more than 4K. Bug 200719161 Change-Id: Iac2a9bcfbcfaa36840da1fa85594520a6fd4eaaf Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2521912 Tested-by: mobile promotions Reviewed-by: Peter Daifuku Reviewed-by: Alex Waterman Reviewed-by: Deepak Nibade Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/mm/gmmu/pd_cache.c | 4 ++-- drivers/gpu/nvgpu/include/nvgpu/utils.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/common/mm/gmmu/pd_cache.c b/drivers/gpu/nvgpu/common/mm/gmmu/pd_cache.c index 2e8294123..ff41343ff 100644 --- a/drivers/gpu/nvgpu/common/mm/gmmu/pd_cache.c +++ b/drivers/gpu/nvgpu/common/mm/gmmu/pd_cache.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -449,7 +449,7 @@ static void nvgpu_pd_cache_do_free(struct gk20a *g, * fill them with zero. */ if ((nvgpu_iommuable(g)) && - (NVGPU_PD_CACHE_SIZE > PAGE_SIZE) && + (NVGPU_PD_CACHE_SIZE > NVGPU_CPU_SMALL_PAGE_SIZE) && (pd->mem->cpu_va != NULL)) { (void)memset(((u8 *)pd->mem->cpu_va + pd->mem_offs), 0, pd->pd_size); diff --git a/drivers/gpu/nvgpu/include/nvgpu/utils.h b/drivers/gpu/nvgpu/include/nvgpu/utils.h index 2e903f58f..e59e6265e 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/utils.h +++ b/drivers/gpu/nvgpu/include/nvgpu/utils.h @@ -36,7 +36,9 @@ * PAGE_SIZE is OS specific and can vary across OSes. Depending on the OS it maybe * defined to 4K or 64K. */ -#define NVGPU_CPU_PAGE_SIZE PAGE_SIZE +#define NVGPU_CPU_PAGE_SIZE PAGE_SIZE + +#define NVGPU_CPU_SMALL_PAGE_SIZE 4096U /** * @file