mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 18:16:01 +03:00
gpu: nvgpu: Split as code to as IOCTL and common
Split as_gk20a.c into two parts: common/linux/ioctl_as.c deals with as related devnodes and ioctls. This file contains all the Linux specific parts of as_gk20a.c. common/as.c deals with general as_gk20a maintenance and is Linux independent. JIRA NVGPU-16 Change-Id: I2d8541e0bd6ce159dc6e4de8e819dfcff0fa8f80 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/1330803 Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
mobile promotions
parent
660c9a9510
commit
1e355ca52e
@@ -27,6 +27,7 @@ nvgpu-y := \
|
||||
common/linux/timers.o \
|
||||
common/linux/ioctl.o \
|
||||
common/linux/ioctl_ctrl.o \
|
||||
common/linux/ioctl_as.o \
|
||||
common/mm/nvgpu_allocator.o \
|
||||
common/mm/bitmap_allocator.o \
|
||||
common/mm/buddy_allocator.o \
|
||||
@@ -35,12 +36,12 @@ nvgpu-y := \
|
||||
common/pramin.o \
|
||||
common/nvgpu_common.o \
|
||||
common/semaphore.o \
|
||||
common/as.o \
|
||||
common/vbios/bios.o \
|
||||
gk20a/gk20a.o \
|
||||
gk20a/bus_gk20a.o \
|
||||
gk20a/pramin_gk20a.o \
|
||||
gk20a/sched_gk20a.o \
|
||||
gk20a/as_gk20a.o \
|
||||
gk20a/ce2_gk20a.o \
|
||||
gk20a/fifo_gk20a.o \
|
||||
gk20a/channel_gk20a.o \
|
||||
|
||||
99
drivers/gpu/nvgpu/common/as.c
Normal file
99
drivers/gpu/nvgpu/common/as.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* GK20A Address Spaces
|
||||
*
|
||||
* Copyright (c) 2011-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.
|
||||
*/
|
||||
|
||||
#include <trace/events/gk20a.h>
|
||||
|
||||
#include <nvgpu/kmem.h>
|
||||
|
||||
#include "gk20a/gk20a.h"
|
||||
|
||||
/* dumb allocator... */
|
||||
static int generate_as_share_id(struct gk20a_as *as)
|
||||
{
|
||||
gk20a_dbg_fn("");
|
||||
return ++as->last_share_id;
|
||||
}
|
||||
/* still dumb */
|
||||
static void release_as_share_id(struct gk20a_as *as, int id)
|
||||
{
|
||||
gk20a_dbg_fn("");
|
||||
return;
|
||||
}
|
||||
|
||||
int gk20a_as_alloc_share(struct gk20a *g,
|
||||
u32 big_page_size, u32 flags,
|
||||
struct gk20a_as_share **out)
|
||||
{
|
||||
struct gk20a_as_share *as_share;
|
||||
int err = 0;
|
||||
|
||||
gk20a_dbg_fn("");
|
||||
g = gk20a_get(g);
|
||||
if (!g)
|
||||
return -ENODEV;
|
||||
|
||||
*out = NULL;
|
||||
as_share = nvgpu_kzalloc(g, sizeof(*as_share));
|
||||
if (!as_share)
|
||||
return -ENOMEM;
|
||||
|
||||
as_share->as = &g->as;
|
||||
as_share->id = generate_as_share_id(as_share->as);
|
||||
|
||||
/* this will set as_share->vm. */
|
||||
err = gk20a_busy(g);
|
||||
if (err)
|
||||
goto failed;
|
||||
err = g->ops.mm.vm_alloc_share(as_share, big_page_size, flags);
|
||||
gk20a_idle(g);
|
||||
|
||||
if (err)
|
||||
goto failed;
|
||||
|
||||
*out = as_share;
|
||||
return 0;
|
||||
|
||||
failed:
|
||||
nvgpu_kfree(g, as_share);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* channels and the device nodes call this to release.
|
||||
* once the ref_cnt hits zero the share is deleted.
|
||||
*/
|
||||
int gk20a_as_release_share(struct gk20a_as_share *as_share)
|
||||
{
|
||||
struct gk20a *g = as_share->vm->mm->g;
|
||||
int err;
|
||||
|
||||
gk20a_dbg_fn("");
|
||||
|
||||
err = gk20a_busy(g);
|
||||
|
||||
if (err)
|
||||
goto release_fail;
|
||||
|
||||
err = gk20a_vm_release_share(as_share);
|
||||
|
||||
gk20a_idle(g);
|
||||
|
||||
release_fail:
|
||||
release_as_share_id(as_share->as, as_share->id);
|
||||
gk20a_put(g);
|
||||
nvgpu_kfree(g, as_share);
|
||||
|
||||
return err;
|
||||
}
|
||||
@@ -24,9 +24,9 @@
|
||||
#include "gk20a/dbg_gpu_gk20a.h"
|
||||
#include "gk20a/ctxsw_trace_gk20a.h"
|
||||
#include "gk20a/channel_gk20a.h"
|
||||
#include "gk20a/as_gk20a.h"
|
||||
#include "gk20a/tsg_gk20a.h"
|
||||
#include "ioctl_ctrl.h"
|
||||
#include "ioctl_as.h"
|
||||
|
||||
#define GK20A_NUM_CDEVS 7
|
||||
|
||||
@@ -167,9 +167,9 @@ void gk20a_user_deinit(struct device *dev, struct class *class)
|
||||
cdev_del(&g->channel.cdev);
|
||||
}
|
||||
|
||||
if (g->as.node) {
|
||||
device_destroy(class, g->as.cdev.dev);
|
||||
cdev_del(&g->as.cdev);
|
||||
if (g->as_dev.node) {
|
||||
device_destroy(class, g->as_dev.cdev.dev);
|
||||
cdev_del(&g->as_dev.cdev);
|
||||
}
|
||||
|
||||
if (g->ctrl.node) {
|
||||
@@ -228,7 +228,7 @@ int gk20a_user_init(struct device *dev, const char *interface_name,
|
||||
goto fail;
|
||||
|
||||
err = gk20a_create_device(dev, devno++, interface_name, "-as",
|
||||
&g->as.cdev, &g->as.node,
|
||||
&g->as_dev.cdev, &g->as_dev.node,
|
||||
&gk20a_as_ops,
|
||||
class);
|
||||
if (err)
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
* more details.
|
||||
*/
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/cdev.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
@@ -22,89 +20,7 @@
|
||||
|
||||
#include <uapi/linux/nvgpu.h>
|
||||
|
||||
#include <nvgpu/kmem.h>
|
||||
|
||||
#include "gk20a.h"
|
||||
|
||||
/* dumb allocator... */
|
||||
static int generate_as_share_id(struct gk20a_as *as)
|
||||
{
|
||||
gk20a_dbg_fn("");
|
||||
return ++as->last_share_id;
|
||||
}
|
||||
/* still dumb */
|
||||
static void release_as_share_id(struct gk20a_as *as, int id)
|
||||
{
|
||||
gk20a_dbg_fn("");
|
||||
return;
|
||||
}
|
||||
|
||||
int gk20a_as_alloc_share(struct gk20a_as *as,
|
||||
u32 big_page_size, u32 flags,
|
||||
struct gk20a_as_share **out)
|
||||
{
|
||||
struct gk20a *g = gk20a_from_as(as);
|
||||
struct gk20a_as_share *as_share;
|
||||
int err = 0;
|
||||
|
||||
gk20a_dbg_fn("");
|
||||
g = gk20a_get(g);
|
||||
if (!g)
|
||||
return -ENODEV;
|
||||
|
||||
*out = NULL;
|
||||
as_share = nvgpu_kzalloc(g, sizeof(*as_share));
|
||||
if (!as_share)
|
||||
return -ENOMEM;
|
||||
|
||||
as_share->as = as;
|
||||
as_share->id = generate_as_share_id(as_share->as);
|
||||
|
||||
/* this will set as_share->vm. */
|
||||
err = gk20a_busy(g);
|
||||
if (err)
|
||||
goto failed;
|
||||
err = g->ops.mm.vm_alloc_share(as_share, big_page_size, flags);
|
||||
gk20a_idle(g);
|
||||
|
||||
if (err)
|
||||
goto failed;
|
||||
|
||||
*out = as_share;
|
||||
return 0;
|
||||
|
||||
failed:
|
||||
nvgpu_kfree(g, as_share);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* channels and the device nodes call this to release.
|
||||
* once the ref_cnt hits zero the share is deleted.
|
||||
*/
|
||||
int gk20a_as_release_share(struct gk20a_as_share *as_share)
|
||||
{
|
||||
struct gk20a *g = as_share->vm->mm->g;
|
||||
int err;
|
||||
|
||||
gk20a_dbg_fn("");
|
||||
|
||||
err = gk20a_busy(g);
|
||||
|
||||
if (err)
|
||||
goto release_fail;
|
||||
|
||||
err = gk20a_vm_release_share(as_share);
|
||||
|
||||
gk20a_idle(g);
|
||||
|
||||
release_fail:
|
||||
release_as_share_id(as_share->as, as_share->id);
|
||||
nvgpu_kfree(g, as_share);
|
||||
gk20a_put(g);
|
||||
|
||||
return err;
|
||||
}
|
||||
#include "gk20a/gk20a.h"
|
||||
|
||||
static int gk20a_as_ioctl_bind_channel(
|
||||
struct gk20a_as_share *as_share,
|
||||
@@ -333,9 +249,9 @@ int gk20a_as_dev_open(struct inode *inode, struct file *filp)
|
||||
|
||||
gk20a_dbg_fn("");
|
||||
|
||||
g = container_of(inode->i_cdev, struct gk20a, as.cdev);
|
||||
g = container_of(inode->i_cdev, struct gk20a, as_dev.cdev);
|
||||
|
||||
err = gk20a_as_alloc_share(&g->as, 0, 0, &as_share);
|
||||
err = gk20a_as_alloc_share(g, 0, 0, &as_share);
|
||||
if (err) {
|
||||
gk20a_dbg_fn("failed to alloc share");
|
||||
return err;
|
||||
26
drivers/gpu/nvgpu/common/linux/ioctl_as.h
Normal file
26
drivers/gpu/nvgpu/common/linux/ioctl_as.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* GK20A Address Spaces
|
||||
*
|
||||
* Copyright (c) 2011-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_COMMON_LINUX_AS_H__
|
||||
#define __NVGPU_COMMON_LINUX_AS_H__
|
||||
|
||||
struct inode;
|
||||
struct file;
|
||||
|
||||
/* struct file_operations driver interface */
|
||||
int gk20a_as_dev_open(struct inode *inode, struct file *filp);
|
||||
int gk20a_as_dev_release(struct inode *inode, struct file *filp);
|
||||
long gk20a_as_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
|
||||
|
||||
#endif
|
||||
@@ -205,13 +205,13 @@ static int gk20a_ctrl_alloc_as(
|
||||
|
||||
snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd);
|
||||
|
||||
file = anon_inode_getfile(name, g->as.cdev.ops, NULL, O_RDWR);
|
||||
file = anon_inode_getfile(name, g->as_dev.cdev.ops, NULL, O_RDWR);
|
||||
if (IS_ERR(file)) {
|
||||
err = PTR_ERR(file);
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
err = gk20a_as_alloc_share(&g->as, args->big_page_size, args->flags,
|
||||
err = gk20a_as_alloc_share(g, args->big_page_size, args->flags,
|
||||
&as_share);
|
||||
if (err)
|
||||
goto clean_up_file;
|
||||
|
||||
@@ -37,13 +37,14 @@ struct dbg_profiler_object_data;
|
||||
#include <soc/tegra/chip-id.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/cdev.h>
|
||||
|
||||
#include "../../../arch/arm/mach-tegra/iomap.h"
|
||||
|
||||
#include <nvgpu/pramin.h>
|
||||
#include <nvgpu/acr/nvgpu_acr.h>
|
||||
#include <nvgpu/as.h>
|
||||
|
||||
#include "as_gk20a.h"
|
||||
#include "clk_gk20a.h"
|
||||
#include "ce2_gk20a.h"
|
||||
#include "fifo_gk20a.h"
|
||||
@@ -1041,6 +1042,11 @@ struct gk20a {
|
||||
struct device *node;
|
||||
} ctrl;
|
||||
|
||||
struct {
|
||||
struct cdev cdev;
|
||||
struct device *node;
|
||||
} as_dev;
|
||||
|
||||
struct {
|
||||
struct cdev cdev;
|
||||
struct device *node;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* GK20A Address Spaces
|
||||
*
|
||||
* Copyright (c) 2011-2015, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2011-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,
|
||||
@@ -12,15 +12,9 @@
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*/
|
||||
#ifndef AS_GK20A_H
|
||||
#define AS_GK20A_H
|
||||
#ifndef __NVGPU_AS_H__
|
||||
#define __NVGPU_AS_H__
|
||||
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/cdev.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
struct gk20a_as;
|
||||
struct gk20a_as_share;
|
||||
struct vm_gk20a;
|
||||
|
||||
struct gk20a_as_share {
|
||||
@@ -31,19 +25,12 @@ struct gk20a_as_share {
|
||||
|
||||
struct gk20a_as {
|
||||
int last_share_id; /* dummy allocator for now */
|
||||
struct cdev cdev;
|
||||
struct device *node;
|
||||
};
|
||||
|
||||
int gk20a_as_release_share(struct gk20a_as_share *as_share);
|
||||
|
||||
/* struct file_operations driver interface */
|
||||
int gk20a_as_dev_open(struct inode *inode, struct file *filp);
|
||||
int gk20a_as_dev_release(struct inode *inode, struct file *filp);
|
||||
long gk20a_as_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
|
||||
|
||||
/* if big_page_size == 0, the default big page size is used */
|
||||
int gk20a_as_alloc_share(struct gk20a_as *as, u32 big_page_size,
|
||||
int gk20a_as_alloc_share(struct gk20a *g, u32 big_page_size,
|
||||
u32 flags, struct gk20a_as_share **out);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user