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:
Deepak Nibade
2020-10-14 15:55:54 +05:30
committed by Alex Waterman
parent 9082bcf3bd
commit a3e39c685d
10 changed files with 134 additions and 225 deletions

View File

@@ -72,6 +72,9 @@
(u32) ((a * 0x10C8ULL) >> 32) : (u16) ((u32) 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 device *dev;
struct gk20a *g;
@@ -110,13 +113,17 @@ int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp)
struct gk20a *g;
struct gk20a_ctrl_priv *priv;
int err = 0;
struct nvgpu_cdev *cdev;
l = container_of(inode->i_cdev,
struct nvgpu_os_linux, ctrl.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)
return -ENODEV;
l = nvgpu_os_linux_from_gk20a(g);
nvgpu_log_fn(g, " ");
priv = nvgpu_kzalloc(g, sizeof(struct gk20a_ctrl_priv));
@@ -562,7 +569,6 @@ static int gk20a_ctrl_alloc_as(
struct gk20a *g,
struct nvgpu_alloc_as_args *args)
{
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
struct gk20a_as_share *as_share;
int err;
int fd;
@@ -576,7 +582,7 @@ static int gk20a_ctrl_alloc_as(
(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)) {
err = PTR_ERR(file);
goto clean_up;
@@ -605,7 +611,6 @@ clean_up:
static int gk20a_ctrl_open_tsg(struct gk20a *g,
struct nvgpu_gpu_open_tsg_args *args)
{
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
int err;
int fd;
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);
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)) {
err = PTR_ERR(file);
goto clean_up;