From bb7ed28ab17ce68c71838bc2aa3fd6e2a0a71a15 Mon Sep 17 00:00:00 2001 From: Sourab Gupta Date: Tue, 1 May 2018 18:11:14 +0530 Subject: gpu: nvgpu: add worker for clk arb work handling Implement a worker thread to replace the workqueue based handling for clk arbiter update callbacks. The work items scheduled with the thread are of two types, update_vf_table and arb_update. Previously, there were two workqueues for handling these two work struct's separately. Now the single worker thread would process these two events. If a work item of a particular type is scheduled to be run on the worker, another instance of same type won't be scheduled, which mirrors the linux workqueue behavior. This also removes dependency on linux workqueues/work struct and makes code portable to be used by QNX also. Jira VQRM-3741 Change-Id: Ic27ce718c62c7d7c3f8820fbd1db386a159e28f2 Signed-off-by: Sourab Gupta Reviewed-on: https://git-master.nvidia.com/r/1706032 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/clk_arb_linux.h | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux/clk_arb_linux.h') diff --git a/drivers/gpu/nvgpu/common/linux/clk_arb_linux.h b/drivers/gpu/nvgpu/common/linux/clk_arb_linux.h index e5ada25d..464590d5 100644 --- a/drivers/gpu/nvgpu/common/linux/clk_arb_linux.h +++ b/drivers/gpu/nvgpu/common/linux/clk_arb_linux.h @@ -39,6 +39,18 @@ * The defines here should finally move to clk_arb.h, once these are * refactored to be free of Linux fields. */ + +enum clk_arb_work_item_type { + CLK_ARB_WORK_UPDATE_VF_TABLE, + CLK_ARB_WORK_UPDATE_ARB +}; + +struct nvgpu_clk_arb_work_item { + enum clk_arb_work_item_type item_type; + struct nvgpu_clk_arb *arb; + struct nvgpu_list_node worker_item; +}; + struct nvgpu_clk_arb { struct nvgpu_spinlock sessions_lock; struct nvgpu_spinlock users_lock; @@ -62,10 +74,8 @@ struct nvgpu_clk_arb { u16 gpc2clk_min, gpc2clk_max; u16 mclk_min, mclk_max; - struct work_struct update_fn_work; - struct workqueue_struct *update_work_queue; - struct work_struct vf_table_fn_work; - struct workqueue_struct *vf_table_work_queue; + struct nvgpu_clk_arb_work_item update_vf_table_work_item; + struct nvgpu_clk_arb_work_item update_arb_work_item; struct nvgpu_cond request_wq; @@ -140,5 +150,14 @@ nvgpu_clk_dev_from_link(struct nvgpu_list_node *node) ((uintptr_t)node - offsetof(struct nvgpu_clk_dev, link)); }; +static inline struct nvgpu_clk_arb_work_item * +nvgpu_clk_arb_work_item_from_worker_item(struct nvgpu_list_node *node) +{ + return (struct nvgpu_clk_arb_work_item *) + ((uintptr_t)node - offsetof(struct nvgpu_clk_arb_work_item, worker_item)); +}; + +void nvgpu_clk_arb_worker_enqueue(struct gk20a *g, + struct nvgpu_clk_arb_work_item *work_item); #endif /* __NVGPU_CLK_ARB_LINUX_H__ */ -- cgit v1.2.2