mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: track cdev minor numbers
The existing Linux character device nodes are statically configured once. For other dynamically created devices, track the next minor number in nvgpu_os_linux as a rudimentary allocator. Only a small number of increments are expected at this time; in the future, a bitmap might be more appropriate for tracking out-of-order deallocations too. Jira NVGPU-6788 Change-Id: I016ee8471313086620f9ab371583d6763848b0e2 Signed-off-by: Konsta Hölttä <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2651163 Reviewed-by: svcacv <svcacv@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
mobile promotions
parent
79b37d7832
commit
82df5b0219
@@ -667,6 +667,7 @@ int gk20a_user_nodes_init(struct device *dev)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
l->cdev_region = devno;
|
l->cdev_region = devno;
|
||||||
|
atomic_set(&l->next_cdev_minor, MINOR(devno) + total_cdevs);
|
||||||
|
|
||||||
nvgpu_list_for_each_entry(class, &l->class_list_head, nvgpu_class, list_entry) {
|
nvgpu_list_for_each_entry(class, &l->class_list_head, nvgpu_class, list_entry) {
|
||||||
if (!check_valid_class(g, class)) {
|
if (!check_valid_class(g, class)) {
|
||||||
@@ -711,6 +712,15 @@ fail:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int nvgpu_allocate_cdev_minor(struct gk20a *g)
|
||||||
|
{
|
||||||
|
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
||||||
|
unsigned int next = (unsigned int)atomic_add_return(1, &l->next_cdev_minor);
|
||||||
|
|
||||||
|
WARN_ON(next >= MINOR(UINT_MAX));
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
struct gk20a *nvgpu_get_gk20a_from_cdev(struct nvgpu_cdev *cdev)
|
struct gk20a *nvgpu_get_gk20a_from_cdev(struct nvgpu_cdev *cdev)
|
||||||
{
|
{
|
||||||
return get_gk20a(cdev->node->parent);
|
return get_gk20a(cdev->node->parent);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
|
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
@@ -71,6 +71,7 @@ int gk20a_power_node_init(struct device *dev);
|
|||||||
void gk20a_user_nodes_deinit(struct device *dev);
|
void gk20a_user_nodes_deinit(struct device *dev);
|
||||||
void gk20a_power_node_deinit(struct device *dev);
|
void gk20a_power_node_deinit(struct device *dev);
|
||||||
|
|
||||||
|
unsigned int nvgpu_allocate_cdev_minor(struct gk20a *g);
|
||||||
struct gk20a *nvgpu_get_gk20a_from_cdev(struct nvgpu_cdev *cdev);
|
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);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
|
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
@@ -87,6 +87,7 @@ struct nvgpu_os_linux {
|
|||||||
|
|
||||||
dev_t power_cdev_region;
|
dev_t power_cdev_region;
|
||||||
dev_t cdev_region;
|
dev_t cdev_region;
|
||||||
|
atomic_t next_cdev_minor;
|
||||||
|
|
||||||
/* see gk20a_ctrl_priv */
|
/* see gk20a_ctrl_priv */
|
||||||
struct nvgpu_list_node ctrl_privs;
|
struct nvgpu_list_node ctrl_privs;
|
||||||
|
|||||||
Reference in New Issue
Block a user