From 2da8c07710b35a0eaeaba7ae5ec4441b69d72026 Mon Sep 17 00:00:00 2001 From: Scott Long Date: Thu, 25 Oct 2018 23:56:53 -0700 Subject: [PATCH] gpu: nvgpu: MISRA 21.15 fixes to pmgr code MISRA Rule 21.15 prohibits use of memcpy() with incompatible ptrs to qualified/unqualified types. To circumvent this issue we've introduced a new MISRA-compliant nvgpu_memcpy() function. This change switches all offending uses of memcpy() in pmgr/*.c code over to use nvgpu_memcpy() with appropriate casts applied. JIRA NVGPU-849 Change-Id: I949f8cff49755c4cbe328ae628cf71ace18622c7 Signed-off-by: Scott Long Reviewed-on: https://git-master.nvidia.com/r/1936181 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Nicolas Benech Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/pmgr/pwrdev.c | 5 +++-- drivers/gpu/nvgpu/pmgr/pwrmonitor.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/pmgr/pwrdev.c b/drivers/gpu/nvgpu/pmgr/pwrdev.c index a1c729b03..7e0d179c3 100644 --- a/drivers/gpu/nvgpu/pmgr/pwrdev.c +++ b/drivers/gpu/nvgpu/pmgr/pwrdev.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "pwrdev.h" #include "gp106/bios_gp106.h" @@ -156,7 +157,7 @@ static int devinit_get_pwr_device_table(struct gk20a *g, goto done; } - memcpy(&pwr_sensor_table_header, pwr_device_table_ptr, + nvgpu_memcpy((u8 *)&pwr_sensor_table_header, pwr_device_table_ptr, VBIOS_POWER_SENSORS_2X_HEADER_SIZE_08); if (pwr_sensor_table_header.version != @@ -189,7 +190,7 @@ static int devinit_get_pwr_device_table(struct gk20a *g, pwr_sensor_table_entry.flags0 = *curr_pwr_device_table_ptr; - memcpy(&pwr_sensor_table_entry.class_param0, + nvgpu_memcpy((u8 *)&pwr_sensor_table_entry.class_param0, (curr_pwr_device_table_ptr + 1), (VBIOS_POWER_SENSORS_2X_ENTRY_SIZE_15 - 1U)); diff --git a/drivers/gpu/nvgpu/pmgr/pwrmonitor.c b/drivers/gpu/nvgpu/pmgr/pwrmonitor.c index c457b921e..1a744ad1b 100644 --- a/drivers/gpu/nvgpu/pmgr/pwrmonitor.c +++ b/drivers/gpu/nvgpu/pmgr/pwrmonitor.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "pwrdev.h" #include "gp106/bios_gp106.h" @@ -204,7 +205,7 @@ static int devinit_get_pwr_topology_table(struct gk20a *g, goto done; } - memcpy(&pwr_topology_table_header, pwr_topology_table_ptr, + nvgpu_memcpy((u8 *)&pwr_topology_table_header, pwr_topology_table_ptr, VBIOS_POWER_TOPOLOGY_2X_HEADER_SIZE_06); if (pwr_topology_table_header.version != @@ -239,7 +240,7 @@ static int devinit_get_pwr_topology_table(struct gk20a *g, pwr_topology_table_entry.flags0 = *curr_pwr_topology_table_ptr; pwr_topology_table_entry.pwr_rail = *(curr_pwr_topology_table_ptr + 1); - memcpy(&pwr_topology_table_entry.param0, + nvgpu_memcpy((u8 *)&pwr_topology_table_entry.param0, (curr_pwr_topology_table_ptr + 2), (VBIOS_POWER_TOPOLOGY_2X_ENTRY_SIZE_16 - 2U));