mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: add API to extract gk20a pointer from cdev
Add new API nvgpu_get_gk20a_from_cdev() that extracts gk20a pointer from cdev pointer. This helps in keeping cdev related implementation details in ioctl.c and away from other device ioctl files. Also move struct nvgpu_cdev, nvgpu_class, and nvgpu_cdev_class_priv_data from os_linux.h to ioctl.h since all of these structures are more IOCTL related and better to keep them in ioctl specific header. Jira NVGPU-5648 Change-Id: Ifad8454fd727ae2389ccf3d1ba492551ef1613ac Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2435466 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: Lakshmanan M <lm@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
Alex Waterman
parent
d0a1f30e66
commit
be9271d721
@@ -34,6 +34,7 @@
|
|||||||
#include "platform_gk20a.h"
|
#include "platform_gk20a.h"
|
||||||
#include "os_linux.h"
|
#include "os_linux.h"
|
||||||
#include "fecs_trace_linux.h"
|
#include "fecs_trace_linux.h"
|
||||||
|
#include "ioctl.h"
|
||||||
|
|
||||||
/* Userland-facing FIFO (one global + eventually one per VM) */
|
/* Userland-facing FIFO (one global + eventually one per VM) */
|
||||||
struct gk20a_ctxsw_dev {
|
struct gk20a_ctxsw_dev {
|
||||||
@@ -321,7 +322,7 @@ int gk20a_ctxsw_dev_open(struct inode *inode, struct file *filp)
|
|||||||
struct nvgpu_cdev *cdev;
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = get_gk20a(cdev->node->parent);
|
g = nvgpu_get_gk20a_from_cdev(cdev);
|
||||||
|
|
||||||
g = nvgpu_get(g);
|
g = nvgpu_get(g);
|
||||||
if (!g)
|
if (!g)
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "ioctl_tsg.h"
|
#include "ioctl_tsg.h"
|
||||||
#include "ioctl_dbg.h"
|
#include "ioctl_dbg.h"
|
||||||
#include "ioctl_prof.h"
|
#include "ioctl_prof.h"
|
||||||
|
#include "ioctl.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "os_linux.h"
|
#include "os_linux.h"
|
||||||
#include "fecs_trace_linux.h"
|
#include "fecs_trace_linux.h"
|
||||||
@@ -559,6 +560,11 @@ fail:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct gk20a *nvgpu_get_gk20a_from_cdev(struct nvgpu_cdev *cdev)
|
||||||
|
{
|
||||||
|
return get_gk20a(cdev->node->parent);
|
||||||
|
}
|
||||||
|
|
||||||
u32 nvgpu_get_gpu_instance_id_from_cdev(struct gk20a *g, struct nvgpu_cdev *cdev)
|
u32 nvgpu_get_gpu_instance_id_from_cdev(struct gk20a *g, struct nvgpu_cdev *cdev)
|
||||||
{
|
{
|
||||||
struct nvgpu_cdev_class_priv_data *priv_data;
|
struct nvgpu_cdev_class_priv_data *priv_data;
|
||||||
|
|||||||
@@ -13,12 +13,56 @@
|
|||||||
#ifndef __NVGPU_IOCTL_H__
|
#ifndef __NVGPU_IOCTL_H__
|
||||||
#define __NVGPU_IOCTL_H__
|
#define __NVGPU_IOCTL_H__
|
||||||
|
|
||||||
|
#include <linux/cdev.h>
|
||||||
|
|
||||||
|
#include <nvgpu/types.h>
|
||||||
|
#include <nvgpu/list.h>
|
||||||
|
|
||||||
struct device;
|
struct device;
|
||||||
struct nvgpu_cdev;
|
struct class;
|
||||||
|
|
||||||
|
struct nvgpu_cdev {
|
||||||
|
struct cdev cdev;
|
||||||
|
struct device *node;
|
||||||
|
struct class *class;
|
||||||
|
struct nvgpu_list_node list_entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline struct nvgpu_cdev *
|
||||||
|
nvgpu_cdev_from_list_entry(struct nvgpu_list_node *node)
|
||||||
|
{
|
||||||
|
return (struct nvgpu_cdev *)
|
||||||
|
((uintptr_t)node - offsetof(struct nvgpu_cdev, list_entry));
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nvgpu_cdev_class_priv_data {
|
||||||
|
char class_name[64];
|
||||||
|
u32 local_instance_id;
|
||||||
|
u32 major_instance_id;
|
||||||
|
u32 minor_instance_id;
|
||||||
|
bool pci;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nvgpu_class {
|
||||||
|
struct class *class;
|
||||||
|
struct nvgpu_list_node list_entry;
|
||||||
|
|
||||||
|
struct nvgpu_cdev_class_priv_data *priv_data;
|
||||||
|
|
||||||
|
enum nvgpu_mig_gpu_instance_type instance_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline struct nvgpu_class *
|
||||||
|
nvgpu_class_from_list_entry(struct nvgpu_list_node *node)
|
||||||
|
{
|
||||||
|
return (struct nvgpu_class *)
|
||||||
|
((uintptr_t)node - offsetof(struct nvgpu_class, list_entry));
|
||||||
|
};
|
||||||
|
|
||||||
int gk20a_user_init(struct device *dev);
|
int gk20a_user_init(struct device *dev);
|
||||||
void gk20a_user_deinit(struct device *dev);
|
void gk20a_user_deinit(struct device *dev);
|
||||||
|
|
||||||
|
struct gk20a *nvgpu_get_gk20a_from_cdev(struct nvgpu_cdev *cdev);
|
||||||
u32 nvgpu_get_gpu_instance_id_from_cdev(struct gk20a *g, struct nvgpu_cdev *cdev);
|
u32 nvgpu_get_gpu_instance_id_from_cdev(struct gk20a *g, struct nvgpu_cdev *cdev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "platform_gk20a.h"
|
#include "platform_gk20a.h"
|
||||||
#include "ioctl_as.h"
|
#include "ioctl_as.h"
|
||||||
#include "ioctl_channel.h"
|
#include "ioctl_channel.h"
|
||||||
|
#include "ioctl.h"
|
||||||
#include "os_linux.h"
|
#include "os_linux.h"
|
||||||
|
|
||||||
static u32 gk20a_as_translate_as_alloc_space_flags(struct gk20a *g, u32 flags)
|
static u32 gk20a_as_translate_as_alloc_space_flags(struct gk20a *g, u32 flags)
|
||||||
@@ -308,7 +309,7 @@ int gk20a_as_dev_open(struct inode *inode, struct file *filp)
|
|||||||
struct nvgpu_cdev *cdev;
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = get_gk20a(cdev->node->parent);
|
g = nvgpu_get_gk20a_from_cdev(cdev);
|
||||||
|
|
||||||
nvgpu_log_fn(g, " ");
|
nvgpu_log_fn(g, " ");
|
||||||
|
|
||||||
|
|||||||
@@ -539,7 +539,7 @@ int gk20a_channel_open(struct inode *inode, struct file *filp)
|
|||||||
struct nvgpu_cdev *cdev;
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = get_gk20a(cdev->node->parent);
|
g = nvgpu_get_gk20a_from_cdev(cdev);
|
||||||
|
|
||||||
nvgpu_log_fn(g, "start");
|
nvgpu_log_fn(g, "start");
|
||||||
ret = __gk20a_channel_open(g, cdev, filp, -1);
|
ret = __gk20a_channel_open(g, cdev, filp, -1);
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
#include "ioctl_as.h"
|
#include "ioctl_as.h"
|
||||||
#include "ioctl_tsg.h"
|
#include "ioctl_tsg.h"
|
||||||
#include "ioctl_channel.h"
|
#include "ioctl_channel.h"
|
||||||
|
#include "ioctl.h"
|
||||||
|
|
||||||
#include "platform_gk20a.h"
|
#include "platform_gk20a.h"
|
||||||
#include "os_linux.h"
|
#include "os_linux.h"
|
||||||
@@ -117,7 +118,7 @@ int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp)
|
|||||||
struct nvgpu_cdev *cdev;
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = get_gk20a(cdev->node->parent);
|
g = nvgpu_get_gk20a_from_cdev(cdev);
|
||||||
|
|
||||||
g = nvgpu_get(g);
|
g = nvgpu_get(g);
|
||||||
if (!g)
|
if (!g)
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
#include "platform_gk20a.h"
|
#include "platform_gk20a.h"
|
||||||
#include "ioctl_dbg.h"
|
#include "ioctl_dbg.h"
|
||||||
#include "ioctl_channel.h"
|
#include "ioctl_channel.h"
|
||||||
|
#include "ioctl.h"
|
||||||
#include "dmabuf_vidmem.h"
|
#include "dmabuf_vidmem.h"
|
||||||
|
|
||||||
struct dbg_session_gk20a_linux {
|
struct dbg_session_gk20a_linux {
|
||||||
@@ -234,7 +235,7 @@ int gk20a_prof_gpu_dev_open(struct inode *inode, struct file *filp)
|
|||||||
struct nvgpu_cdev *cdev;
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = get_gk20a(cdev->node->parent);
|
g = nvgpu_get_gk20a_from_cdev(cdev);
|
||||||
|
|
||||||
nvgpu_log(g, gpu_dbg_fn | gpu_dbg_gpu_dbg, " ");
|
nvgpu_log(g, gpu_dbg_fn | gpu_dbg_gpu_dbg, " ");
|
||||||
return gk20a_dbg_gpu_do_dev_open(g, filp, true /* is profiler */);
|
return gk20a_dbg_gpu_do_dev_open(g, filp, true /* is profiler */);
|
||||||
@@ -2011,7 +2012,7 @@ int gk20a_dbg_gpu_dev_open(struct inode *inode, struct file *filp)
|
|||||||
struct nvgpu_cdev *cdev;
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = get_gk20a(cdev->node->parent);
|
g = nvgpu_get_gk20a_from_cdev(cdev);
|
||||||
|
|
||||||
nvgpu_log(g, gpu_dbg_fn | gpu_dbg_gpu_dbg, " ");
|
nvgpu_log(g, gpu_dbg_fn | gpu_dbg_gpu_dbg, " ");
|
||||||
return gk20a_dbg_gpu_do_dev_open(g, filp, false /* not profiler */);
|
return gk20a_dbg_gpu_do_dev_open(g, filp, false /* not profiler */);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "ioctl_prof.h"
|
#include "ioctl_prof.h"
|
||||||
#include "ioctl_dbg.h"
|
#include "ioctl_dbg.h"
|
||||||
#include "ioctl_tsg.h"
|
#include "ioctl_tsg.h"
|
||||||
|
#include "ioctl.h"
|
||||||
|
|
||||||
#define NVGPU_PROF_UMD_COPY_WINDOW_SIZE SZ_4K
|
#define NVGPU_PROF_UMD_COPY_WINDOW_SIZE SZ_4K
|
||||||
|
|
||||||
@@ -135,7 +136,7 @@ int nvgpu_prof_dev_fops_open(struct inode *inode, struct file *filp)
|
|||||||
struct nvgpu_cdev *cdev;
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = get_gk20a(cdev->node->parent);
|
g = nvgpu_get_gk20a_from_cdev(cdev);
|
||||||
|
|
||||||
g = nvgpu_get(g);
|
g = nvgpu_get(g);
|
||||||
if (!g) {
|
if (!g) {
|
||||||
@@ -163,7 +164,7 @@ int nvgpu_prof_ctx_fops_open(struct inode *inode, struct file *filp)
|
|||||||
struct nvgpu_cdev *cdev;
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = get_gk20a(cdev->node->parent);
|
g = nvgpu_get_gk20a_from_cdev(cdev);
|
||||||
|
|
||||||
g = nvgpu_get(g);
|
g = nvgpu_get(g);
|
||||||
if (!g) {
|
if (!g) {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include "platform_gk20a.h"
|
#include "platform_gk20a.h"
|
||||||
#include "ioctl_tsg.h"
|
#include "ioctl_tsg.h"
|
||||||
#include "ioctl_channel.h"
|
#include "ioctl_channel.h"
|
||||||
|
#include "ioctl.h"
|
||||||
#include "os_linux.h"
|
#include "os_linux.h"
|
||||||
|
|
||||||
struct tsg_private {
|
struct tsg_private {
|
||||||
@@ -471,7 +472,7 @@ int nvgpu_ioctl_tsg_dev_open(struct inode *inode, struct file *filp)
|
|||||||
struct nvgpu_cdev *cdev;
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = get_gk20a(cdev->node->parent);
|
g = nvgpu_get_gk20a_from_cdev(cdev);
|
||||||
|
|
||||||
nvgpu_log_fn(g, " ");
|
nvgpu_log_fn(g, " ");
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#ifndef NVGPU_OS_LINUX_H
|
#ifndef NVGPU_OS_LINUX_H
|
||||||
#define NVGPU_OS_LINUX_H
|
#define NVGPU_OS_LINUX_H
|
||||||
|
|
||||||
#include <linux/cdev.h>
|
|
||||||
#include <linux/iommu.h>
|
#include <linux/iommu.h>
|
||||||
#include <linux/hashtable.h>
|
#include <linux/hashtable.h>
|
||||||
#include <linux/notifier.h>
|
#include <linux/notifier.h>
|
||||||
@@ -29,8 +28,6 @@
|
|||||||
#include "cde.h"
|
#include "cde.h"
|
||||||
#include "sched.h"
|
#include "sched.h"
|
||||||
|
|
||||||
struct class;
|
|
||||||
|
|
||||||
struct nvgpu_os_linux_ops {
|
struct nvgpu_os_linux_ops {
|
||||||
struct {
|
struct {
|
||||||
void (*get_program_numbers)(struct gk20a *g,
|
void (*get_program_numbers)(struct gk20a *g,
|
||||||
@@ -73,44 +70,6 @@ struct dgpu_thermal_alert {
|
|||||||
u32 event_delay;
|
u32 event_delay;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nvgpu_cdev {
|
|
||||||
struct cdev cdev;
|
|
||||||
struct device *node;
|
|
||||||
struct class *class;
|
|
||||||
struct nvgpu_list_node list_entry;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline struct nvgpu_cdev *
|
|
||||||
nvgpu_cdev_from_list_entry(struct nvgpu_list_node *node)
|
|
||||||
{
|
|
||||||
return (struct nvgpu_cdev *)
|
|
||||||
((uintptr_t)node - offsetof(struct nvgpu_cdev, list_entry));
|
|
||||||
};
|
|
||||||
|
|
||||||
struct nvgpu_cdev_class_priv_data {
|
|
||||||
char class_name[64];
|
|
||||||
u32 local_instance_id;
|
|
||||||
u32 major_instance_id;
|
|
||||||
u32 minor_instance_id;
|
|
||||||
bool pci;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct nvgpu_class {
|
|
||||||
struct class *class;
|
|
||||||
struct nvgpu_list_node list_entry;
|
|
||||||
|
|
||||||
struct nvgpu_cdev_class_priv_data *priv_data;
|
|
||||||
|
|
||||||
enum nvgpu_mig_gpu_instance_type instance_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline struct nvgpu_class *
|
|
||||||
nvgpu_class_from_list_entry(struct nvgpu_list_node *node)
|
|
||||||
{
|
|
||||||
return (struct nvgpu_class *)
|
|
||||||
((uintptr_t)node - offsetof(struct nvgpu_class, list_entry));
|
|
||||||
};
|
|
||||||
|
|
||||||
struct nvgpu_os_linux {
|
struct nvgpu_os_linux {
|
||||||
struct gk20a g;
|
struct gk20a g;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "sched.h"
|
#include "sched.h"
|
||||||
#include "os_linux.h"
|
#include "os_linux.h"
|
||||||
#include "ioctl_tsg.h"
|
#include "ioctl_tsg.h"
|
||||||
|
#include "ioctl.h"
|
||||||
|
|
||||||
ssize_t gk20a_sched_dev_read(struct file *filp, char __user *buf,
|
ssize_t gk20a_sched_dev_read(struct file *filp, char __user *buf,
|
||||||
size_t size, loff_t *off)
|
size_t size, loff_t *off)
|
||||||
@@ -394,7 +395,7 @@ int gk20a_sched_dev_open(struct inode *inode, struct file *filp)
|
|||||||
struct nvgpu_cdev *cdev;
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = get_gk20a(cdev->node->parent);
|
g = nvgpu_get_gk20a_from_cdev(cdev);
|
||||||
|
|
||||||
g = nvgpu_get(g);
|
g = nvgpu_get(g);
|
||||||
if (!g)
|
if (!g)
|
||||||
|
|||||||
Reference in New Issue
Block a user