From e1438818b90c5b0d73aae800b12bd6b36aec5142 Mon Sep 17 00:00:00 2001 From: Richard Zhao Date: Thu, 21 Jul 2016 16:51:40 -0700 Subject: gpu: nvgpu: vgpu: add vgpu private data and helper functions Move vgpu private data to a dedicated structure and allocate it at probe time. Also add virt_handle helper function which is used everywhere. JIRA VFND-2103 Change-Id: I125911420be72ca9be948125d8357fa85d1d3afd Signed-off-by: Richard Zhao Reviewed-on: http://git-master/r/1185206 GVS: Gerrit_Virtual_Submit Reviewed-by: Vladislav Buzov --- drivers/gpu/nvgpu/vgpu/vgpu.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'drivers/gpu/nvgpu/vgpu/vgpu.h') diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.h b/drivers/gpu/nvgpu/vgpu/vgpu.h index f79c8aab..e1fff966 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.h +++ b/drivers/gpu/nvgpu/vgpu/vgpu.h @@ -21,6 +21,42 @@ #include "gk20a/gk20a.h" #ifdef CONFIG_TEGRA_GR_VIRTUALIZATION + +struct vgpu_priv_data { + u64 virt_handle; + struct task_struct *intr_handler; +}; + +static inline +struct vgpu_priv_data *vgpu_get_priv_data_from_dev(struct device *dev) +{ + struct gk20a_platform *plat = gk20a_get_platform(dev); + + return (struct vgpu_priv_data *)plat->vgpu_priv; +} + +static inline struct vgpu_priv_data *vgpu_get_priv_data(struct gk20a *g) +{ + return vgpu_get_priv_data_from_dev(g->dev); +} + +static inline u64 vgpu_get_handle_from_dev(struct device *dev) +{ + struct vgpu_priv_data *priv = vgpu_get_priv_data_from_dev(dev); + + if (unlikely(!priv)) { + dev_err(dev, "invalid vgpu_priv_data in %s\n", __func__); + return INT_MAX; + } + + return priv->virt_handle; +} + +static inline u64 vgpu_get_handle(struct gk20a *g) +{ + return vgpu_get_handle_from_dev(g->dev); +} + int vgpu_pm_prepare_poweroff(struct device *dev); int vgpu_pm_finalize_poweron(struct device *dev); int vgpu_probe(struct platform_device *dev); -- cgit v1.2.2