mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: track dev nodes using dynamic linked list
Remove static dev node meta data from struct nvgpu_os_linux and replace it by a dynamic list. Struct nvgpu_os_linux will only keep track of list head and number of entries. Add new structure nvgpu_cdev to store meta data of each dev node and create/setup it dynamically in gk20a_user_init(). Once done, add the new node under list head maintained in nvgpu_os_linux. Add a static list dev_node_list[] that contains list of dev node names and file operations. This static list is used to create nvgpu_cdev data structures and to register new device nodes. Update all dev node open file operations (e.g. gk20a_as_dev_open()) to extract struct gk20a pointer from device pointer of dev node. gk20a device is the parent of dev node device. Jira NVGPU-5648 Change-Id: If070c3428afd6215e45b4919335d9f43e04c36f9 Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2428500 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: Alex Waterman <alexw@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
9082bcf3bd
commit
a3e39c685d
@@ -310,24 +310,25 @@ static int gk20a_ctxsw_dev_ioctl_poll(struct gk20a_ctxsw_dev *dev)
|
|||||||
|
|
||||||
int gk20a_ctxsw_dev_open(struct inode *inode, struct file *filp)
|
int gk20a_ctxsw_dev_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l;
|
|
||||||
struct gk20a *g;
|
struct gk20a *g;
|
||||||
struct gk20a_ctxsw_trace *trace;
|
struct gk20a_ctxsw_trace *trace;
|
||||||
struct gk20a_ctxsw_dev *dev;
|
struct gk20a_ctxsw_dev *dev;
|
||||||
int err;
|
int err;
|
||||||
size_t size;
|
size_t size;
|
||||||
u32 n;
|
u32 n;
|
||||||
|
|
||||||
/* only one VM for now */
|
/* only one VM for now */
|
||||||
const int vmid = 0;
|
const int vmid = 0;
|
||||||
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
l = container_of(inode->i_cdev, struct nvgpu_os_linux, ctxsw.cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = nvgpu_get(&l->g);
|
g = get_gk20a(cdev->node->parent);
|
||||||
|
|
||||||
|
g = nvgpu_get(g);
|
||||||
if (!g)
|
if (!g)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_FECS_CTXSW_TRACE)) {
|
if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_FECS_CTXSW_TRACE)) {
|
||||||
nvgpu_put(&l->g);
|
nvgpu_put(g);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,6 @@
|
|||||||
#include "fecs_trace_linux.h"
|
#include "fecs_trace_linux.h"
|
||||||
#include "platform_gk20a.h"
|
#include "platform_gk20a.h"
|
||||||
|
|
||||||
#define GK20A_NUM_CDEVS 10
|
|
||||||
|
|
||||||
const struct file_operations gk20a_channel_ops = {
|
const struct file_operations gk20a_channel_ops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.release = gk20a_channel_release,
|
.release = gk20a_channel_release,
|
||||||
@@ -67,7 +65,7 @@ static const struct file_operations gk20a_dbg_ops = {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct file_operations gk20a_as_ops = {
|
const struct file_operations gk20a_as_ops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.release = gk20a_as_dev_release,
|
.release = gk20a_as_dev_release,
|
||||||
.open = gk20a_as_dev_open,
|
.open = gk20a_as_dev_open,
|
||||||
@@ -150,6 +148,26 @@ static const struct file_operations gk20a_sched_ops = {
|
|||||||
.read = gk20a_sched_dev_read,
|
.read = gk20a_sched_dev_read,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct nvgpu_dev_node {
|
||||||
|
char name[20];
|
||||||
|
const struct file_operations *fops;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct nvgpu_dev_node dev_node_list[] = {
|
||||||
|
{"as", &gk20a_as_ops},
|
||||||
|
{"channel", &gk20a_channel_ops},
|
||||||
|
{"ctrl", &gk20a_ctrl_ops},
|
||||||
|
#if defined(CONFIG_NVGPU_FECS_TRACE)
|
||||||
|
{"ctxsw", &gk20a_ctxsw_ops},
|
||||||
|
#endif
|
||||||
|
{"dbg", &gk20a_dbg_ops},
|
||||||
|
{"prof", &gk20a_prof_ops},
|
||||||
|
{"prof-ctx", &gk20a_prof_ctx_ops},
|
||||||
|
{"prof-dev", &gk20a_prof_dev_ops},
|
||||||
|
{"sched", &gk20a_sched_ops},
|
||||||
|
{"tsg", &gk20a_tsg_ops},
|
||||||
|
};
|
||||||
|
|
||||||
static char *nvgpu_devnode(const char *cdev_name)
|
static char *nvgpu_devnode(const char *cdev_name)
|
||||||
{
|
{
|
||||||
/* Special case to maintain legacy names */
|
/* Special case to maintain legacy names */
|
||||||
@@ -226,66 +244,28 @@ void gk20a_user_deinit(struct device *dev)
|
|||||||
struct gk20a *g = gk20a_from_dev(dev);
|
struct gk20a *g = gk20a_from_dev(dev);
|
||||||
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
||||||
struct class *class = l->devnode_class;
|
struct class *class = l->devnode_class;
|
||||||
|
struct nvgpu_cdev *cdev, *n;
|
||||||
|
|
||||||
if (class == NULL) {
|
if (class == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->channel.node) {
|
nvgpu_list_for_each_entry_safe(cdev, n, &l->cdev_list_head, nvgpu_cdev, list_entry) {
|
||||||
device_destroy(class, l->channel.cdev.dev);
|
nvgpu_list_del(&cdev->list_entry);
|
||||||
cdev_del(&l->channel.cdev);
|
|
||||||
|
device_destroy(class, cdev->cdev.dev);
|
||||||
|
cdev_del(&cdev->cdev);
|
||||||
|
|
||||||
|
nvgpu_kfree(g, cdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->as_dev.node) {
|
if (l->cdev_region) {
|
||||||
device_destroy(class, l->as_dev.cdev.dev);
|
unregister_chrdev_region(l->cdev_region, l->num_cdevs);
|
||||||
cdev_del(&l->as_dev.cdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->ctrl.node) {
|
|
||||||
device_destroy(class, l->ctrl.cdev.dev);
|
|
||||||
cdev_del(&l->ctrl.cdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (l->dbg.node) {
|
|
||||||
device_destroy(class, l->dbg.cdev.dev);
|
|
||||||
cdev_del(&l->dbg.cdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (l->prof.node) {
|
|
||||||
device_destroy(class, l->prof.cdev.dev);
|
|
||||||
cdev_del(&l->prof.cdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (l->prof_dev.node) {
|
|
||||||
device_destroy(class, l->prof_dev.cdev.dev);
|
|
||||||
cdev_del(&l->prof_dev.cdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (l->prof_ctx.node) {
|
|
||||||
device_destroy(class, l->prof_ctx.cdev.dev);
|
|
||||||
cdev_del(&l->prof_ctx.cdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (l->tsg.node) {
|
|
||||||
device_destroy(class, l->tsg.cdev.dev);
|
|
||||||
cdev_del(&l->tsg.cdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (l->ctxsw.node) {
|
|
||||||
device_destroy(class, l->ctxsw.cdev.dev);
|
|
||||||
cdev_del(&l->ctxsw.cdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (l->sched.node) {
|
|
||||||
device_destroy(class, l->sched.cdev.dev);
|
|
||||||
cdev_del(&l->sched.cdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (l->cdev_region)
|
|
||||||
unregister_chrdev_region(l->cdev_region, GK20A_NUM_CDEVS);
|
|
||||||
|
|
||||||
class_destroy(class);
|
class_destroy(class);
|
||||||
l->devnode_class = NULL;
|
l->devnode_class = NULL;
|
||||||
|
l->num_cdevs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gk20a_user_init(struct device *dev)
|
int gk20a_user_init(struct device *dev)
|
||||||
@@ -295,6 +275,9 @@ int gk20a_user_init(struct device *dev)
|
|||||||
struct gk20a *g = gk20a_from_dev(dev);
|
struct gk20a *g = gk20a_from_dev(dev);
|
||||||
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
||||||
struct class *class;
|
struct class *class;
|
||||||
|
u32 num_cdevs;
|
||||||
|
struct nvgpu_cdev *cdev;
|
||||||
|
u32 cdev_index;
|
||||||
|
|
||||||
if (g->pci_class != 0U) {
|
if (g->pci_class != 0U) {
|
||||||
class = class_create(THIS_MODULE, "nvidia-pci-gpu");
|
class = class_create(THIS_MODULE, "nvidia-pci-gpu");
|
||||||
@@ -312,86 +295,38 @@ int gk20a_user_init(struct device *dev)
|
|||||||
class->devnode = NULL;
|
class->devnode = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = alloc_chrdev_region(&devno, 0, GK20A_NUM_CDEVS, dev_name(dev));
|
num_cdevs = sizeof(dev_node_list) / sizeof(dev_node_list[0]);
|
||||||
|
err = alloc_chrdev_region(&devno, 0, num_cdevs, dev_name(dev));
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(dev, "failed to allocate devno\n");
|
dev_err(dev, "failed to allocate devno\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
l->cdev_region = devno;
|
l->cdev_region = devno;
|
||||||
|
|
||||||
err = gk20a_create_device(dev, devno++, "channel",
|
nvgpu_init_list_node(&l->cdev_list_head);
|
||||||
&l->channel.cdev, &l->channel.node,
|
|
||||||
&gk20a_channel_ops,
|
|
||||||
class);
|
|
||||||
if (err)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
err = gk20a_create_device(dev, devno++, "as",
|
for (cdev_index = 0; cdev_index < num_cdevs; cdev_index++) {
|
||||||
&l->as_dev.cdev, &l->as_dev.node,
|
cdev = nvgpu_kzalloc(g, sizeof(*cdev));
|
||||||
&gk20a_as_ops,
|
if (cdev == NULL) {
|
||||||
class);
|
dev_err(dev, "failed to allocate cdev\n");
|
||||||
if (err)
|
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
err = gk20a_create_device(dev, devno++, "ctrl",
|
err = gk20a_create_device(dev, devno++, dev_node_list[cdev_index].name,
|
||||||
&l->ctrl.cdev, &l->ctrl.node,
|
&cdev->cdev, &cdev->node,
|
||||||
&gk20a_ctrl_ops,
|
dev_node_list[cdev_index].fops,
|
||||||
class);
|
class);
|
||||||
if (err)
|
if (err) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
err = gk20a_create_device(dev, devno++, "dbg",
|
nvgpu_init_list_node(&cdev->list_entry);
|
||||||
&l->dbg.cdev, &l->dbg.node,
|
nvgpu_list_add(&cdev->list_entry, &l->cdev_list_head);
|
||||||
&gk20a_dbg_ops,
|
}
|
||||||
class);
|
|
||||||
if (err)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
err = gk20a_create_device(dev, devno++, "prof",
|
|
||||||
&l->prof.cdev, &l->prof.node,
|
|
||||||
&gk20a_prof_ops,
|
|
||||||
class);
|
|
||||||
if (err)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
err = gk20a_create_device(dev, devno++, "prof-dev",
|
|
||||||
&l->prof_dev.cdev, &l->prof_dev.node,
|
|
||||||
&gk20a_prof_dev_ops,
|
|
||||||
class);
|
|
||||||
if (err)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
err = gk20a_create_device(dev, devno++, "prof-ctx",
|
|
||||||
&l->prof_ctx.cdev, &l->prof_ctx.node,
|
|
||||||
&gk20a_prof_ctx_ops,
|
|
||||||
class);
|
|
||||||
if (err)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
err = gk20a_create_device(dev, devno++, "tsg",
|
|
||||||
&l->tsg.cdev, &l->tsg.node,
|
|
||||||
&gk20a_tsg_ops,
|
|
||||||
class);
|
|
||||||
if (err)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
#if defined(CONFIG_NVGPU_FECS_TRACE)
|
|
||||||
err = gk20a_create_device(dev, devno++, "ctxsw",
|
|
||||||
&l->ctxsw.cdev, &l->ctxsw.node,
|
|
||||||
&gk20a_ctxsw_ops,
|
|
||||||
class);
|
|
||||||
if (err)
|
|
||||||
goto fail;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
err = gk20a_create_device(dev, devno++, "sched",
|
|
||||||
&l->sched.cdev, &l->sched.node,
|
|
||||||
&gk20a_sched_ops,
|
|
||||||
class);
|
|
||||||
if (err)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
|
l->num_cdevs = num_cdevs;
|
||||||
l->devnode_class = class;
|
l->devnode_class = class;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
gk20a_user_deinit(dev);
|
gk20a_user_deinit(dev);
|
||||||
|
|||||||
@@ -302,13 +302,13 @@ static int nvgpu_as_ioctl_get_sync_ro_map(
|
|||||||
|
|
||||||
int gk20a_as_dev_open(struct inode *inode, struct file *filp)
|
int gk20a_as_dev_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l;
|
|
||||||
struct gk20a_as_share *as_share;
|
struct gk20a_as_share *as_share;
|
||||||
struct gk20a *g;
|
struct gk20a *g;
|
||||||
int err;
|
int err;
|
||||||
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
l = container_of(inode->i_cdev, struct nvgpu_os_linux, as_dev.cdev);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
g = &l->g;
|
g = get_gk20a(cdev->node->parent);
|
||||||
|
|
||||||
nvgpu_log_fn(g, " ");
|
nvgpu_log_fn(g, " ");
|
||||||
|
|
||||||
|
|||||||
@@ -529,10 +529,12 @@ free_ref:
|
|||||||
|
|
||||||
int gk20a_channel_open(struct inode *inode, struct file *filp)
|
int gk20a_channel_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l = container_of(inode->i_cdev,
|
struct gk20a *g;
|
||||||
struct nvgpu_os_linux, channel.cdev);
|
|
||||||
struct gk20a *g = &l->g;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
|
g = get_gk20a(cdev->node->parent);
|
||||||
|
|
||||||
nvgpu_log_fn(g, "start");
|
nvgpu_log_fn(g, "start");
|
||||||
ret = __gk20a_channel_open(g, filp, -1);
|
ret = __gk20a_channel_open(g, filp, -1);
|
||||||
@@ -549,7 +551,6 @@ int gk20a_channel_open_ioctl(struct gk20a *g,
|
|||||||
struct file *file;
|
struct file *file;
|
||||||
char name[64];
|
char name[64];
|
||||||
s32 runlist_id = args->in.runlist_id;
|
s32 runlist_id = args->in.runlist_id;
|
||||||
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
|
||||||
|
|
||||||
err = get_unused_fd_flags(O_RDWR);
|
err = get_unused_fd_flags(O_RDWR);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
@@ -559,7 +560,7 @@ int gk20a_channel_open_ioctl(struct gk20a *g,
|
|||||||
(void) snprintf(name, sizeof(name), "nvhost-%s-fd%d",
|
(void) snprintf(name, sizeof(name), "nvhost-%s-fd%d",
|
||||||
dev_name(dev_from_gk20a(g)), fd);
|
dev_name(dev_from_gk20a(g)), fd);
|
||||||
|
|
||||||
file = anon_inode_getfile(name, l->channel.cdev.ops, NULL, O_RDWR);
|
file = anon_inode_getfile(name, &gk20a_channel_ops, NULL, O_RDWR);
|
||||||
if (IS_ERR(file)) {
|
if (IS_ERR(file)) {
|
||||||
err = PTR_ERR(file);
|
err = PTR_ERR(file);
|
||||||
goto clean_up;
|
goto clean_up;
|
||||||
|
|||||||
@@ -72,6 +72,9 @@
|
|||||||
(u32) ((a * 0x10C8ULL) >> 32) : (u16) ((u32) a/MHZ))
|
(u32) ((a * 0x10C8ULL) >> 32) : (u16) ((u32) a/MHZ))
|
||||||
#define MHZ_TO_HZ(a) ((u64)a * MHZ)
|
#define MHZ_TO_HZ(a) ((u64)a * MHZ)
|
||||||
|
|
||||||
|
extern const struct file_operations gk20a_as_ops;
|
||||||
|
extern const struct file_operations gk20a_tsg_ops;
|
||||||
|
|
||||||
struct gk20a_ctrl_priv {
|
struct gk20a_ctrl_priv {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct gk20a *g;
|
struct gk20a *g;
|
||||||
@@ -110,13 +113,17 @@ int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp)
|
|||||||
struct gk20a *g;
|
struct gk20a *g;
|
||||||
struct gk20a_ctrl_priv *priv;
|
struct gk20a_ctrl_priv *priv;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
l = container_of(inode->i_cdev,
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
struct nvgpu_os_linux, ctrl.cdev);
|
g = get_gk20a(cdev->node->parent);
|
||||||
g = nvgpu_get(&l->g);
|
|
||||||
|
g = nvgpu_get(g);
|
||||||
if (!g)
|
if (!g)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
l = nvgpu_os_linux_from_gk20a(g);
|
||||||
|
|
||||||
nvgpu_log_fn(g, " ");
|
nvgpu_log_fn(g, " ");
|
||||||
|
|
||||||
priv = nvgpu_kzalloc(g, sizeof(struct gk20a_ctrl_priv));
|
priv = nvgpu_kzalloc(g, sizeof(struct gk20a_ctrl_priv));
|
||||||
@@ -562,7 +569,6 @@ static int gk20a_ctrl_alloc_as(
|
|||||||
struct gk20a *g,
|
struct gk20a *g,
|
||||||
struct nvgpu_alloc_as_args *args)
|
struct nvgpu_alloc_as_args *args)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
|
||||||
struct gk20a_as_share *as_share;
|
struct gk20a_as_share *as_share;
|
||||||
int err;
|
int err;
|
||||||
int fd;
|
int fd;
|
||||||
@@ -576,7 +582,7 @@ static int gk20a_ctrl_alloc_as(
|
|||||||
|
|
||||||
(void) snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd);
|
(void) snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd);
|
||||||
|
|
||||||
file = anon_inode_getfile(name, l->as_dev.cdev.ops, NULL, O_RDWR);
|
file = anon_inode_getfile(name, &gk20a_as_ops, NULL, O_RDWR);
|
||||||
if (IS_ERR(file)) {
|
if (IS_ERR(file)) {
|
||||||
err = PTR_ERR(file);
|
err = PTR_ERR(file);
|
||||||
goto clean_up;
|
goto clean_up;
|
||||||
@@ -605,7 +611,6 @@ clean_up:
|
|||||||
static int gk20a_ctrl_open_tsg(struct gk20a *g,
|
static int gk20a_ctrl_open_tsg(struct gk20a *g,
|
||||||
struct nvgpu_gpu_open_tsg_args *args)
|
struct nvgpu_gpu_open_tsg_args *args)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
|
||||||
int err;
|
int err;
|
||||||
int fd;
|
int fd;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
@@ -618,7 +623,7 @@ static int gk20a_ctrl_open_tsg(struct gk20a *g,
|
|||||||
|
|
||||||
(void) snprintf(name, sizeof(name), "nvgpu-%s-tsg%d", g->name, fd);
|
(void) snprintf(name, sizeof(name), "nvgpu-%s-tsg%d", g->name, fd);
|
||||||
|
|
||||||
file = anon_inode_getfile(name, l->tsg.cdev.ops, NULL, O_RDWR);
|
file = anon_inode_getfile(name, &gk20a_tsg_ops, NULL, O_RDWR);
|
||||||
if (IS_ERR(file)) {
|
if (IS_ERR(file)) {
|
||||||
err = PTR_ERR(file);
|
err = PTR_ERR(file);
|
||||||
goto clean_up;
|
goto clean_up;
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ static int nvgpu_profiler_reserve_release(struct dbg_session_gk20a *dbg_s,
|
|||||||
|
|
||||||
static int dbg_unbind_all_channels_gk20a(struct dbg_session_gk20a *dbg_s);
|
static int dbg_unbind_all_channels_gk20a(struct dbg_session_gk20a *dbg_s);
|
||||||
|
|
||||||
static int gk20a_dbg_gpu_do_dev_open(struct inode *inode,
|
static int gk20a_dbg_gpu_do_dev_open(struct gk20a *g,
|
||||||
struct file *filp, bool is_profiler);
|
struct file *filp, bool is_profiler);
|
||||||
|
|
||||||
unsigned int gk20a_dbg_gpu_dev_poll(struct file *filep, poll_table *wait)
|
unsigned int gk20a_dbg_gpu_dev_poll(struct file *filep, poll_table *wait)
|
||||||
@@ -230,12 +230,14 @@ int gk20a_dbg_gpu_dev_release(struct inode *inode, struct file *filp)
|
|||||||
|
|
||||||
int gk20a_prof_gpu_dev_open(struct inode *inode, struct file *filp)
|
int gk20a_prof_gpu_dev_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l = container_of(inode->i_cdev,
|
struct gk20a *g;
|
||||||
struct nvgpu_os_linux, prof.cdev);
|
struct nvgpu_cdev *cdev;
|
||||||
struct gk20a *g = &l->g;
|
|
||||||
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
|
g = get_gk20a(cdev->node->parent);
|
||||||
|
|
||||||
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(inode, filp, true /* is profiler */);
|
return gk20a_dbg_gpu_do_dev_open(g, filp, true /* is profiler */);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nvgpu_dbg_gpu_ioctl_timeout(struct dbg_session_gk20a *dbg_s,
|
static int nvgpu_dbg_gpu_ioctl_timeout(struct dbg_session_gk20a *dbg_s,
|
||||||
@@ -380,25 +382,15 @@ static int nvgpu_dbg_timeout_enable(struct dbg_session_gk20a *dbg_s,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gk20a_dbg_gpu_do_dev_open(struct inode *inode,
|
static int gk20a_dbg_gpu_do_dev_open(struct gk20a *g,
|
||||||
struct file *filp, bool is_profiler)
|
struct file *filp, bool is_profiler)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l;
|
|
||||||
struct dbg_session_gk20a_linux *dbg_session_linux;
|
struct dbg_session_gk20a_linux *dbg_session_linux;
|
||||||
struct dbg_session_gk20a *dbg_s;
|
struct dbg_session_gk20a *dbg_s;
|
||||||
struct gk20a *g;
|
|
||||||
|
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!is_profiler)
|
g = nvgpu_get(g);
|
||||||
l = container_of(inode->i_cdev,
|
|
||||||
struct nvgpu_os_linux, dbg.cdev);
|
|
||||||
else
|
|
||||||
l = container_of(inode->i_cdev,
|
|
||||||
struct nvgpu_os_linux, prof.cdev);
|
|
||||||
g = nvgpu_get(&l->g);
|
|
||||||
if (!g)
|
if (!g)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
@@ -2015,12 +2007,14 @@ static int nvgpu_dbg_gpu_cycle_stats_snapshot(struct dbg_session_gk20a *dbg_s,
|
|||||||
|
|
||||||
int gk20a_dbg_gpu_dev_open(struct inode *inode, struct file *filp)
|
int gk20a_dbg_gpu_dev_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l = container_of(inode->i_cdev,
|
struct gk20a *g;
|
||||||
struct nvgpu_os_linux, dbg.cdev);
|
struct nvgpu_cdev *cdev;
|
||||||
struct gk20a *g = &l->g;
|
|
||||||
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
|
g = get_gk20a(cdev->node->parent);
|
||||||
|
|
||||||
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(inode, filp, false /* not profiler */);
|
return gk20a_dbg_gpu_do_dev_open(g, filp, false /* not profiler */);
|
||||||
}
|
}
|
||||||
|
|
||||||
long gk20a_dbg_gpu_dev_ioctl(struct file *filp, unsigned int cmd,
|
long gk20a_dbg_gpu_dev_ioctl(struct file *filp, unsigned int cmd,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <nvgpu/pm_reservation.h>
|
#include <nvgpu/pm_reservation.h>
|
||||||
#include <nvgpu/tsg.h>
|
#include <nvgpu/tsg.h>
|
||||||
|
|
||||||
|
#include "platform_gk20a.h"
|
||||||
#include "os_linux.h"
|
#include "os_linux.h"
|
||||||
#include "ioctl_prof.h"
|
#include "ioctl_prof.h"
|
||||||
#include "ioctl_dbg.h"
|
#include "ioctl_dbg.h"
|
||||||
@@ -129,12 +130,14 @@ free_priv:
|
|||||||
|
|
||||||
int nvgpu_prof_dev_fops_open(struct inode *inode, struct file *filp)
|
int nvgpu_prof_dev_fops_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l = container_of(inode->i_cdev,
|
|
||||||
struct nvgpu_os_linux, prof_dev.cdev);
|
|
||||||
struct gk20a *g;
|
struct gk20a *g;
|
||||||
int err;
|
int err;
|
||||||
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
g = nvgpu_get(&l->g);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
|
g = get_gk20a(cdev->node->parent);
|
||||||
|
|
||||||
|
g = nvgpu_get(g);
|
||||||
if (!g) {
|
if (!g) {
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
@@ -155,12 +158,14 @@ int nvgpu_prof_dev_fops_open(struct inode *inode, struct file *filp)
|
|||||||
|
|
||||||
int nvgpu_prof_ctx_fops_open(struct inode *inode, struct file *filp)
|
int nvgpu_prof_ctx_fops_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l = container_of(inode->i_cdev,
|
|
||||||
struct nvgpu_os_linux, prof_ctx.cdev);
|
|
||||||
struct gk20a *g;
|
struct gk20a *g;
|
||||||
int err;
|
int err;
|
||||||
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
g = nvgpu_get(&l->g);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
|
g = get_gk20a(cdev->node->parent);
|
||||||
|
|
||||||
|
g = nvgpu_get(g);
|
||||||
if (!g) {
|
if (!g) {
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -466,13 +466,12 @@ free_ref:
|
|||||||
|
|
||||||
int nvgpu_ioctl_tsg_dev_open(struct inode *inode, struct file *filp)
|
int nvgpu_ioctl_tsg_dev_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l;
|
|
||||||
struct gk20a *g;
|
struct gk20a *g;
|
||||||
int ret;
|
int ret;
|
||||||
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
l = container_of(inode->i_cdev,
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
struct nvgpu_os_linux, tsg.cdev);
|
g = get_gk20a(cdev->node->parent);
|
||||||
g = &l->g;
|
|
||||||
|
|
||||||
nvgpu_log_fn(g, " ");
|
nvgpu_log_fn(g, " ");
|
||||||
|
|
||||||
@@ -482,7 +481,7 @@ int nvgpu_ioctl_tsg_dev_open(struct inode *inode, struct file *filp)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = nvgpu_ioctl_tsg_open(&l->g, filp);
|
ret = nvgpu_ioctl_tsg_open(g, filp);
|
||||||
|
|
||||||
gk20a_idle(g);
|
gk20a_idle(g);
|
||||||
nvgpu_log_fn(g, "done");
|
nvgpu_log_fn(g, "done");
|
||||||
|
|||||||
@@ -73,6 +73,19 @@ struct dgpu_thermal_alert {
|
|||||||
u32 event_delay;
|
u32 event_delay;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct nvgpu_cdev {
|
||||||
|
struct cdev cdev;
|
||||||
|
struct device *node;
|
||||||
|
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_os_linux {
|
struct nvgpu_os_linux {
|
||||||
struct gk20a g;
|
struct gk20a g;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
@@ -80,55 +93,8 @@ struct nvgpu_os_linux {
|
|||||||
struct nvgpu_interrupts interrupts;
|
struct nvgpu_interrupts interrupts;
|
||||||
struct class *devnode_class;
|
struct class *devnode_class;
|
||||||
|
|
||||||
struct {
|
struct nvgpu_list_node cdev_list_head;
|
||||||
struct cdev cdev;
|
u32 num_cdevs;
|
||||||
struct device *node;
|
|
||||||
} channel;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct cdev cdev;
|
|
||||||
struct device *node;
|
|
||||||
} ctrl;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct cdev cdev;
|
|
||||||
struct device *node;
|
|
||||||
} as_dev;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct cdev cdev;
|
|
||||||
struct device *node;
|
|
||||||
} dbg;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct cdev cdev;
|
|
||||||
struct device *node;
|
|
||||||
} prof;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct cdev cdev;
|
|
||||||
struct device *node;
|
|
||||||
} prof_dev;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct cdev cdev;
|
|
||||||
struct device *node;
|
|
||||||
} prof_ctx;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct cdev cdev;
|
|
||||||
struct device *node;
|
|
||||||
} tsg;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct cdev cdev;
|
|
||||||
struct device *node;
|
|
||||||
} ctxsw;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct cdev cdev;
|
|
||||||
struct device *node;
|
|
||||||
} sched;
|
|
||||||
|
|
||||||
dev_t cdev_region;
|
dev_t cdev_region;
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <nvgpu/gr/ctx.h>
|
#include <nvgpu/gr/ctx.h>
|
||||||
#include <nvgpu/nvgpu_init.h>
|
#include <nvgpu/nvgpu_init.h>
|
||||||
|
|
||||||
|
#include "platform_gk20a.h"
|
||||||
#include "sched.h"
|
#include "sched.h"
|
||||||
#include "os_linux.h"
|
#include "os_linux.h"
|
||||||
#include "ioctl_tsg.h"
|
#include "ioctl_tsg.h"
|
||||||
@@ -387,13 +388,15 @@ static int gk20a_sched_dev_ioctl_put_tsg(struct gk20a *g,
|
|||||||
|
|
||||||
int gk20a_sched_dev_open(struct inode *inode, struct file *filp)
|
int gk20a_sched_dev_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct nvgpu_os_linux *l = container_of(inode->i_cdev,
|
|
||||||
struct nvgpu_os_linux, sched.cdev);
|
|
||||||
struct gk20a *g;
|
struct gk20a *g;
|
||||||
struct nvgpu_sched_ctrl *sched;
|
struct nvgpu_sched_ctrl *sched;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
struct nvgpu_cdev *cdev;
|
||||||
|
|
||||||
g = nvgpu_get(&l->g);
|
cdev = container_of(inode->i_cdev, struct nvgpu_cdev, cdev);
|
||||||
|
g = get_gk20a(cdev->node->parent);
|
||||||
|
|
||||||
|
g = nvgpu_get(g);
|
||||||
if (!g)
|
if (!g)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
sched = &g->sched_ctrl;
|
sched = &g->sched_ctrl;
|
||||||
|
|||||||
Reference in New Issue
Block a user