mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
gpu: nvgpu: Add check for invalid nvgpu_aperture
Currently, in nvgpu_aperture_mask_raw function, if NVGPU_MM_HONORS_APERTURE flag is disabled, invalid or junk aperture input is changed to APERTURE_VIDMEM instead of raising a warning.To resolve this bug, need to check if input aperture is APERTURE_INVALID or undefined. This patch adds APERTURE_MAX_ENUM to nvgpu_aperture structure which gives upperbound of nvgpu_aperture types. This patch also adds condition in nvgpu_aperture_mask_raw function to check for invalid or undefined aperture input. For invalid inputs, function will BUG(). Jira NVGPU-2933 Change-Id: Ic9d260250e3083d693f025c6e32657f6a863aafb Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2034281 Reviewed-by: Philip Elcan <pelcan@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
0931d699a5
commit
bc2ee54301
@@ -38,6 +38,10 @@ u32 nvgpu_aperture_mask_raw(struct gk20a *g, enum nvgpu_aperture aperture,
|
||||
u32 sysmem_mask, u32 sysmem_coh_mask,
|
||||
u32 vidmem_mask)
|
||||
{
|
||||
if ((aperture == APERTURE_INVALID) || (aperture >= APERTURE_MAX_ENUM)) {
|
||||
nvgpu_do_assert_print(g, "Bad aperture");
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Some iGPUs treat sysmem (i.e SoC DRAM) as vidmem. In these cases the
|
||||
* "sysmem" aperture should really be translated to VIDMEM.
|
||||
@@ -54,10 +58,12 @@ u32 nvgpu_aperture_mask_raw(struct gk20a *g, enum nvgpu_aperture aperture,
|
||||
case APERTURE_VIDMEM:
|
||||
return vidmem_mask;
|
||||
case APERTURE_INVALID:
|
||||
case APERTURE_MAX_ENUM:
|
||||
default:
|
||||
nvgpu_do_assert_print(g, "Bad aperture");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
u32 nvgpu_aperture_mask(struct gk20a *g, struct nvgpu_mem *mem,
|
||||
u32 sysmem_mask, u32 sysmem_coh_mask, u32 vidmem_mask)
|
||||
|
||||
@@ -58,7 +58,9 @@ enum nvgpu_aperture {
|
||||
/* Don't use directly. Use APERTURE_SYSMEM, this is used internally. */
|
||||
APERTURE_SYSMEM_COH,
|
||||
|
||||
APERTURE_VIDMEM
|
||||
APERTURE_VIDMEM,
|
||||
/* This should always be last in the list */
|
||||
APERTURE_MAX_ENUM
|
||||
};
|
||||
|
||||
struct nvgpu_mem {
|
||||
@@ -157,6 +159,8 @@ static inline const char *nvgpu_aperture_str(struct gk20a *g,
|
||||
return "SYSCOH";
|
||||
case APERTURE_VIDMEM:
|
||||
return "VIDMEM";
|
||||
case APERTURE_MAX_ENUM:
|
||||
return "UNKNOWN";
|
||||
};
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user