Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
c83c4097
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
c83c4097
编写于
11月 01, 2017
作者:
B
Ben Skeggs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
drm/nouveau/mmu: define user interfaces to mmu memory allocation
Signed-off-by:
N
Ben Skeggs
<
bskeggs@redhat.com
>
上级
eea5cf0f
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
363 addition
and
1 deletion
+363
-1
drivers/gpu/drm/nouveau/include/nvif/if000a.h
drivers/gpu/drm/nouveau/include/nvif/if000a.h
+9
-0
drivers/gpu/drm/nouveau/include/nvif/mem.h
drivers/gpu/drm/nouveau/include/nvif/mem.h
+18
-0
drivers/gpu/drm/nouveau/include/nvkm/core/client.h
drivers/gpu/drm/nouveau/include/nvkm/core/client.h
+3
-0
drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
+1
-0
drivers/gpu/drm/nouveau/nvif/Kbuild
drivers/gpu/drm/nouveau/nvif/Kbuild
+1
-0
drivers/gpu/drm/nouveau/nvif/mem.c
drivers/gpu/drm/nouveau/nvif/mem.c
+88
-0
drivers/gpu/drm/nouveau/nvkm/core/client.c
drivers/gpu/drm/nouveau/nvkm/core/client.c
+2
-0
drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+1
-1
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild
+1
-0
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
+192
-0
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
+26
-0
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
+21
-0
未找到文件。
drivers/gpu/drm/nouveau/include/nvif/if000a.h
浏览文件 @
c83c4097
#ifndef __NVIF_IF000A_H__
#define __NVIF_IF000A_H__
struct
nvif_mem_v0
{
__u8
version
;
__u8
type
;
__u8
page
;
__u8
pad03
[
5
];
__u64
size
;
__u64
addr
;
__u8
data
[];
};
struct
nvif_mem_ram_vn
{
};
...
...
drivers/gpu/drm/nouveau/include/nvif/mem.h
0 → 100644
浏览文件 @
c83c4097
#ifndef __NVIF_MEM_H__
#define __NVIF_MEM_H__
#include "mmu.h"
struct
nvif_mem
{
struct
nvif_object
object
;
u8
type
;
u8
page
;
u64
addr
;
u64
size
;
};
int
nvif_mem_init_type
(
struct
nvif_mmu
*
mmu
,
s32
oclass
,
int
type
,
u8
page
,
u64
size
,
void
*
argv
,
u32
argc
,
struct
nvif_mem
*
);
int
nvif_mem_init
(
struct
nvif_mmu
*
mmu
,
s32
oclass
,
u8
type
,
u8
page
,
u64
size
,
void
*
argv
,
u32
argc
,
struct
nvif_mem
*
);
void
nvif_mem_fini
(
struct
nvif_mem
*
);
#endif
drivers/gpu/drm/nouveau/include/nvkm/core/client.h
浏览文件 @
c83c4097
...
...
@@ -17,6 +17,9 @@ struct nvkm_client {
int
(
*
ntfy
)(
const
void
*
,
u32
,
const
void
*
,
u32
);
struct
nvkm_vm
*
vm
;
struct
list_head
umem
;
spinlock_t
lock
;
};
int
nvkm_client_new
(
const
char
*
name
,
u64
device
,
const
char
*
cfg
,
...
...
drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
浏览文件 @
c83c4097
...
...
@@ -98,6 +98,7 @@ int nvkm_vmm_map(struct nvkm_vmm *, struct nvkm_vma *, void *argv, u32 argc,
struct
nvkm_vmm_map
*
);
void
nvkm_vmm_unmap
(
struct
nvkm_vmm
*
,
struct
nvkm_vma
*
);
struct
nvkm_memory
*
nvkm_umem_search
(
struct
nvkm_client
*
,
u64
);
struct
nvkm_vmm
*
nvkm_uvmm_search
(
struct
nvkm_client
*
,
u64
handle
);
struct
nvkm_mmu
{
...
...
drivers/gpu/drm/nouveau/nvif/Kbuild
浏览文件 @
c83c4097
...
...
@@ -2,5 +2,6 @@ nvif-y := nvif/object.o
nvif-y += nvif/client.o
nvif-y += nvif/device.o
nvif-y += nvif/driver.o
nvif-y += nvif/mem.o
nvif-y += nvif/mmu.o
nvif-y += nvif/notify.o
drivers/gpu/drm/nouveau/nvif/mem.c
0 → 100644
浏览文件 @
c83c4097
/*
* Copyright 2017 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <nvif/mem.h>
#include <nvif/client.h>
#include <nvif/if000a.h>
void
nvif_mem_fini
(
struct
nvif_mem
*
mem
)
{
nvif_object_fini
(
&
mem
->
object
);
}
int
nvif_mem_init_type
(
struct
nvif_mmu
*
mmu
,
s32
oclass
,
int
type
,
u8
page
,
u64
size
,
void
*
argv
,
u32
argc
,
struct
nvif_mem
*
mem
)
{
struct
nvif_mem_v0
*
args
;
u8
stack
[
128
];
int
ret
;
mem
->
object
.
client
=
NULL
;
if
(
type
<
0
)
return
-
EINVAL
;
if
(
sizeof
(
*
args
)
+
argc
>
sizeof
(
stack
))
{
if
(
!
(
args
=
kmalloc
(
sizeof
(
*
args
)
+
argc
,
GFP_KERNEL
)))
return
-
ENOMEM
;
}
else
{
args
=
(
void
*
)
stack
;
}
args
->
version
=
0
;
args
->
type
=
type
;
args
->
page
=
page
;
args
->
size
=
size
;
memcpy
(
args
->
data
,
argv
,
argc
);
ret
=
nvif_object_init
(
&
mmu
->
object
,
0
,
oclass
,
args
,
sizeof
(
*
args
)
+
argc
,
&
mem
->
object
);
if
(
ret
==
0
)
{
mem
->
type
=
mmu
->
type
[
type
].
type
;
mem
->
page
=
args
->
page
;
mem
->
addr
=
args
->
addr
;
mem
->
size
=
args
->
size
;
}
if
(
args
!=
(
void
*
)
stack
)
kfree
(
args
);
return
ret
;
}
int
nvif_mem_init
(
struct
nvif_mmu
*
mmu
,
s32
oclass
,
u8
type
,
u8
page
,
u64
size
,
void
*
argv
,
u32
argc
,
struct
nvif_mem
*
mem
)
{
int
ret
=
-
EINVAL
,
i
;
mem
->
object
.
client
=
NULL
;
for
(
i
=
0
;
ret
&&
i
<
mmu
->
type_nr
;
i
++
)
{
if
((
mmu
->
type
[
i
].
type
&
type
)
==
type
)
{
ret
=
nvif_mem_init_type
(
mmu
,
oclass
,
i
,
page
,
size
,
argv
,
argc
,
mem
);
}
}
return
ret
;
}
drivers/gpu/drm/nouveau/nvkm/core/client.c
浏览文件 @
c83c4097
...
...
@@ -301,5 +301,7 @@ nvkm_client_new(const char *name, u64 device, const char *cfg,
client
->
debug
=
nvkm_dbgopt
(
dbg
,
"CLIENT"
);
client
->
objroot
=
RB_ROOT
;
client
->
ntfy
=
ntfy
;
INIT_LIST_HEAD
(
&
client
->
umem
);
spin_lock_init
(
&
client
->
lock
);
return
0
;
}
drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
浏览文件 @
c83c4097
...
...
@@ -53,7 +53,7 @@ nvkm_ioctl_sclass(struct nvkm_client *client,
union
{
struct
nvif_ioctl_sclass_v0
v0
;
}
*
args
=
data
;
struct
nvkm_oclass
oclass
;
struct
nvkm_oclass
oclass
=
{
.
client
=
client
}
;
int
ret
=
-
ENOSYS
,
i
=
0
;
nvif_ioctl
(
object
,
"sclass size %d
\n
"
,
size
);
...
...
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild
浏览文件 @
c83c4097
...
...
@@ -30,4 +30,5 @@ nvkm-y += nvkm/subdev/mmu/vmmgm20b.o
nvkm-y += nvkm/subdev/mmu/vmmgp100.o
nvkm-y += nvkm/subdev/mmu/vmmgp10b.o
nvkm-y += nvkm/subdev/mmu/umem.o
nvkm-y += nvkm/subdev/mmu/ummu.o
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.c
0 → 100644
浏览文件 @
c83c4097
/*
* Copyright 2017 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "umem.h"
#include "ummu.h"
#include <core/client.h>
#include <core/memory.h>
#include <subdev/bar.h>
#include <nvif/class.h>
#include <nvif/if000a.h>
#include <nvif/unpack.h>
static
const
struct
nvkm_object_func
nvkm_umem
;
struct
nvkm_memory
*
nvkm_umem_search
(
struct
nvkm_client
*
client
,
u64
handle
)
{
struct
nvkm_client
*
master
=
client
->
object
.
client
;
struct
nvkm_memory
*
memory
=
NULL
;
struct
nvkm_object
*
object
;
struct
nvkm_umem
*
umem
;
object
=
nvkm_object_search
(
client
,
handle
,
&
nvkm_umem
);
if
(
IS_ERR
(
object
))
{
if
(
client
->
super
&&
client
!=
master
)
{
spin_lock
(
&
master
->
lock
);
list_for_each_entry
(
umem
,
&
master
->
umem
,
head
)
{
if
(
umem
->
object
.
object
==
handle
)
{
memory
=
nvkm_memory_ref
(
umem
->
memory
);
break
;
}
}
spin_unlock
(
&
master
->
lock
);
}
}
else
{
umem
=
nvkm_umem
(
object
);
if
(
!
umem
->
priv
||
client
->
super
)
memory
=
nvkm_memory_ref
(
umem
->
memory
);
}
return
memory
?
memory
:
ERR_PTR
(
-
ENOENT
);
}
static
int
nvkm_umem_unmap
(
struct
nvkm_object
*
object
)
{
struct
nvkm_umem
*
umem
=
nvkm_umem
(
object
);
if
(
!
umem
->
map
)
return
-
EEXIST
;
if
(
umem
->
io
)
{
if
(
!
IS_ERR
(
umem
->
bar
))
{
struct
nvkm_device
*
device
=
umem
->
mmu
->
subdev
.
device
;
nvkm_vmm_put
(
nvkm_bar_bar1_vmm
(
device
),
&
umem
->
bar
);
}
else
{
umem
->
bar
=
NULL
;
}
}
else
{
vunmap
(
umem
->
map
);
umem
->
map
=
NULL
;
}
return
0
;
}
static
int
nvkm_umem_map
(
struct
nvkm_object
*
object
,
void
*
argv
,
u32
argc
,
enum
nvkm_object_map
*
type
,
u64
*
handle
,
u64
*
length
)
{
struct
nvkm_umem
*
umem
=
nvkm_umem
(
object
);
struct
nvkm_mmu
*
mmu
=
umem
->
mmu
;
if
(
!
umem
->
mappable
)
return
-
EINVAL
;
if
(
umem
->
map
)
return
-
EEXIST
;
if
((
umem
->
type
&
NVKM_MEM_HOST
)
&&
!
argc
)
{
int
ret
=
nvkm_mem_map_host
(
umem
->
memory
,
&
umem
->
map
);
if
(
ret
)
return
ret
;
*
handle
=
(
unsigned
long
)(
void
*
)
umem
->
map
;
*
length
=
nvkm_memory_size
(
umem
->
memory
);
*
type
=
NVKM_OBJECT_MAP_VA
;
return
0
;
}
else
if
((
umem
->
type
&
NVKM_MEM_VRAM
)
||
(
umem
->
type
&
NVKM_MEM_KIND
))
{
int
ret
=
mmu
->
func
->
mem
.
umap
(
mmu
,
umem
->
memory
,
argv
,
argc
,
handle
,
length
,
&
umem
->
bar
);
if
(
ret
)
return
ret
;
*
type
=
NVKM_OBJECT_MAP_IO
;
}
else
{
return
-
EINVAL
;
}
umem
->
io
=
(
*
type
==
NVKM_OBJECT_MAP_IO
);
return
0
;
}
static
void
*
nvkm_umem_dtor
(
struct
nvkm_object
*
object
)
{
struct
nvkm_umem
*
umem
=
nvkm_umem
(
object
);
spin_lock
(
&
umem
->
object
.
client
->
lock
);
list_del_init
(
&
umem
->
head
);
spin_unlock
(
&
umem
->
object
.
client
->
lock
);
nvkm_memory_unref
(
&
umem
->
memory
);
return
umem
;
}
static
const
struct
nvkm_object_func
nvkm_umem
=
{
.
dtor
=
nvkm_umem_dtor
,
.
map
=
nvkm_umem_map
,
.
unmap
=
nvkm_umem_unmap
,
};
int
nvkm_umem_new
(
const
struct
nvkm_oclass
*
oclass
,
void
*
argv
,
u32
argc
,
struct
nvkm_object
**
pobject
)
{
struct
nvkm_mmu
*
mmu
=
nvkm_ummu
(
oclass
->
parent
)
->
mmu
;
union
{
struct
nvif_mem_v0
v0
;
}
*
args
=
argv
;
struct
nvkm_umem
*
umem
;
int
type
,
ret
=
-
ENOSYS
;
u8
page
;
u64
size
;
if
(
!
(
ret
=
nvif_unpack
(
ret
,
&
argv
,
&
argc
,
args
->
v0
,
0
,
0
,
true
)))
{
type
=
args
->
v0
.
type
;
page
=
args
->
v0
.
page
;
size
=
args
->
v0
.
size
;
}
else
return
ret
;
if
(
type
>=
mmu
->
type_nr
)
return
-
EINVAL
;
if
(
!
(
umem
=
kzalloc
(
sizeof
(
*
umem
),
GFP_KERNEL
)))
return
-
ENOMEM
;
nvkm_object_ctor
(
&
nvkm_umem
,
oclass
,
&
umem
->
object
);
umem
->
mmu
=
mmu
;
umem
->
type
=
mmu
->
type
[
type
].
type
;
umem
->
priv
=
oclass
->
client
->
super
;
INIT_LIST_HEAD
(
&
umem
->
head
);
*
pobject
=
&
umem
->
object
;
if
(
mmu
->
type
[
type
].
type
&
NVKM_MEM_MAPPABLE
)
{
page
=
max_t
(
u8
,
page
,
PAGE_SHIFT
);
umem
->
mappable
=
true
;
}
ret
=
nvkm_mem_new_type
(
mmu
,
type
,
page
,
size
,
argv
,
argc
,
&
umem
->
memory
);
if
(
ret
)
return
ret
;
spin_lock
(
&
umem
->
object
.
client
->
lock
);
list_add
(
&
umem
->
head
,
&
umem
->
object
.
client
->
umem
);
spin_unlock
(
&
umem
->
object
.
client
->
lock
);
args
->
v0
.
page
=
nvkm_memory_page
(
umem
->
memory
);
args
->
v0
.
addr
=
nvkm_memory_addr
(
umem
->
memory
);
args
->
v0
.
size
=
nvkm_memory_size
(
umem
->
memory
);
return
0
;
}
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/umem.h
0 → 100644
浏览文件 @
c83c4097
#ifndef __NVKM_UMEM_H__
#define __NVKM_UMEM_H__
#define nvkm_umem(p) container_of((p), struct nvkm_umem, object)
#include <core/object.h>
#include "mem.h"
struct
nvkm_umem
{
struct
nvkm_object
object
;
struct
nvkm_mmu
*
mmu
;
u8
type
:
8
;
bool
priv
:
1
;
bool
mappable
:
1
;
bool
io
:
1
;
struct
nvkm_memory
*
memory
;
struct
list_head
head
;
union
{
struct
nvkm_vma
*
bar
;
void
*
map
;
};
};
int
nvkm_umem_new
(
const
struct
nvkm_oclass
*
,
void
*
argv
,
u32
argc
,
struct
nvkm_object
**
);
#endif
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/ummu.c
浏览文件 @
c83c4097
...
...
@@ -20,10 +20,30 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "ummu.h"
#include "umem.h"
#include <core/client.h>
#include <nvif/if0008.h>
#include <nvif/unpack.h>
static
int
nvkm_ummu_sclass
(
struct
nvkm_object
*
object
,
int
index
,
struct
nvkm_oclass
*
oclass
)
{
struct
nvkm_mmu
*
mmu
=
nvkm_ummu
(
object
)
->
mmu
;
if
(
mmu
->
func
->
mem
.
user
.
oclass
&&
oclass
->
client
->
super
)
{
if
(
index
--
==
0
)
{
oclass
->
base
=
mmu
->
func
->
mem
.
user
;
oclass
->
ctor
=
nvkm_umem_new
;
return
0
;
}
}
return
-
EINVAL
;
}
static
int
nvkm_ummu_heap
(
struct
nvkm_ummu
*
ummu
,
void
*
argv
,
u32
argc
)
{
...
...
@@ -115,6 +135,7 @@ nvkm_ummu_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
static
const
struct
nvkm_object_func
nvkm_ummu
=
{
.
mthd
=
nvkm_ummu_mthd
,
.
sclass
=
nvkm_ummu_sclass
,
};
int
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录