From 66a2511a366113fa4d42dc500c9df9b348d9f208 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Tue, 23 May 2017 18:21:14 +0100 Subject: gpu: nvgpu: Begin removing variables in struct gk20a Begin removing all of the myriad flag variables in struct gk20a and replace that with one API that checks for flags being enabled or disabled. The API is as follows: bool nvgpu_is_enabled(struct gk20a *g, int flag); bool __nvgpu_set_enabled(struct gk20a *g, int flag, bool state); These APIs allow many of the gk20a flags to be replaced by defines. This makes flag usage consistent and saves a small amount of memory in struct gk20a. Also it makes struct gk20a easier to read since there's less clutter scattered through out. JIRA NVGPU-84 Change-Id: I6525cecbe97c4e8379e5f53e29ef0b4dbd1a7fc2 Signed-off-by: Alex Waterman Reviewed-on: http://git-master/r/1488049 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/enabled.h | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 drivers/gpu/nvgpu/include/nvgpu/enabled.h (limited to 'drivers/gpu/nvgpu/include') diff --git a/drivers/gpu/nvgpu/include/nvgpu/enabled.h b/drivers/gpu/nvgpu/include/nvgpu/enabled.h new file mode 100644 index 00000000..5d30ba12 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/enabled.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __NVGPU_ENABLED_H__ +#define __NVGPU_ENABLED_H__ + +struct gk20a; + +#include + +/* + * Available flags that describe what's enabled and what's not in the GPU. Each + * flag here is defined by it's offset in a bitmap. + */ +#define NVGPU_IS_FMODEL 1 +#define NVGPU_DRIVER_IS_DYING 2 + +/* + * Must be greater than the largest bit offset in the above list. + */ +#define NVGPU_MAX_ENABLED_BITS 64 + +/** + * nvgpu_is_enabled - Check if the passed flag is enabled. + * + * @g - The GPU. + * @flag - Which flag to check. + * + * Returns true if the passed @flag is true; false otherwise. + */ +bool nvgpu_is_enabled(struct gk20a *g, int flag); + +/** + * __nvgpu_set_enabled - Set the state of a flag. + * + * @g - The GPU. + * @flag - Which flag to modify. + * @state - The state to set the flag to. + * + * Set the state of the passed @flag to @state. This will return the previous + * state of the passed @flag. + */ +bool __nvgpu_set_enabled(struct gk20a *g, int flag, bool state); + +int nvgpu_init_enabled_flags(struct gk20a *g); + +#endif -- cgit v1.2.2