From 76ad9e8366f5c73d1ea47d54cea043f8cd9fa23e Mon Sep 17 00:00:00 2001 From: Mahantesh Kumbar Date: Tue, 27 Feb 2018 14:52:19 +0530 Subject: gpu: nvgpu: Updated RPC to support copyback & callback - Updated & added new parameter "bool is_copy_back" to nvgpu_pmu_rpc_execute() to support copy back processed RPC request from PMU to caller by passing parameter value true & this blocks method till it receives ACK from PMU for requested RPC. - Added "struct rpc_handler_payload" to hold info required for RPC handler like RPC buff address & clear memory if copy back is not requested. - Added define PMU_RPC_EXECUTE_CPB to support to copy back processed RPC request from PMU to caller. - Updated RPC callback handler support, crated memory & assigned default handler if callback is not requested else use callback parameters data to request to PMU. - Added define PMU_RPC_EXECUTE_CB to support callback - Updated pmu_wait_message_cond(), restricted condition check to 8-bit instead 32-bit condition check. Change-Id: Ic05289b074954979fd0102daf5ab806bf1f07b62 Signed-off-by: Mahantesh Kumbar Reviewed-on: https://git-master.nvidia.com/r/1664962 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/pmu.h | 40 ++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/pmu.h b/drivers/gpu/nvgpu/include/nvgpu/pmu.h index 76a54fa1..507b8133 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/pmu.h +++ b/drivers/gpu/nvgpu/include/nvgpu/pmu.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2018, 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"), @@ -154,12 +154,45 @@ enum { \ _stat = nvgpu_pmu_rpc_execute(_pmu, &((_prpc)->hdr), \ (sizeof(*(_prpc)) - sizeof((_prpc)->scratch)),\ - (_size), NULL, NULL); \ + (_size), NULL, NULL, false); \ + } while (0) + +/* RPC blocking call to copy back data from PMU to _prpc */ +#define PMU_RPC_EXECUTE_CPB(_stat, _pmu, _unit, _func, _prpc, _size)\ + do { \ + memset(&((_prpc)->hdr), 0, sizeof((_prpc)->hdr));\ + \ + (_prpc)->hdr.unit_id = PMU_UNIT_##_unit; \ + (_prpc)->hdr.function = NV_PMU_RPC_ID_##_unit##_##_func;\ + (_prpc)->hdr.flags = 0x0; \ + \ + _stat = nvgpu_pmu_rpc_execute(_pmu, &((_prpc)->hdr), \ + (sizeof(*(_prpc)) - sizeof((_prpc)->scratch)),\ + (_size), NULL, NULL, true); \ + } while (0) + +/* RPC non-blocking with call_back handler option */ +#define PMU_RPC_EXECUTE_CB(_stat, _pmu, _unit, _func, _prpc, _size, _cb, _cbp)\ + do { \ + memset(&((_prpc)->hdr), 0, sizeof((_prpc)->hdr));\ + \ + (_prpc)->hdr.unit_id = PMU_UNIT_##_unit; \ + (_prpc)->hdr.function = NV_PMU_RPC_ID_##_unit##_##_func;\ + (_prpc)->hdr.flags = 0x0; \ + \ + _stat = nvgpu_pmu_rpc_execute(_pmu, &((_prpc)->hdr), \ + (sizeof(*(_prpc)) - sizeof((_prpc)->scratch)),\ + (_size), _cb, _cbp, false); \ } while (0) typedef void (*pmu_callback)(struct gk20a *, struct pmu_msg *, void *, u32, u32); +struct rpc_handler_payload { + void *rpc_buff; + bool is_mem_free_set; +}; + struct pmu_rpc_desc { void *prpc; u16 size_rpc; @@ -500,6 +533,7 @@ bool nvgpu_find_hex_in_string(char *strings, struct gk20a *g, u32 *hex_pos); /* PMU RPC */ int nvgpu_pmu_rpc_execute(struct nvgpu_pmu *pmu, struct nv_pmu_rpc_header *rpc, - u16 size_rpc, u16 size_scratch, pmu_callback callback, void *cb_param); + u16 size_rpc, u16 size_scratch, pmu_callback callback, void *cb_param, + bool is_copy_back); #endif /* __NVGPU_PMU_H__ */ -- cgit v1.2.2