mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
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
69 lines
1.7 KiB
C
69 lines
1.7 KiB
C
/*
|
|
* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*/
|
|
#ifndef __NVGPU_IOCTL_H__
|
|
#define __NVGPU_IOCTL_H__
|
|
|
|
#include <linux/cdev.h>
|
|
|
|
#include <nvgpu/types.h>
|
|
#include <nvgpu/list.h>
|
|
|
|
struct device;
|
|
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);
|
|
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);
|
|
|
|
#endif
|