Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
d7722134
Commit
d7722134
authored
Nov 01, 2017
by
Ben Skeggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drm/nouveau: switch over to new memory and vmm interfaces
Signed-off-by:
Ben Skeggs
<
bskeggs@redhat.com
>
parent
10842ba0
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
209 additions
and
156 deletions
+209
-156
drivers/gpu/drm/nouveau/include/nvif/device.h
drivers/gpu/drm/nouveau/include/nvif/device.h
+0
-2
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_bo.c
+61
-31
drivers/gpu/drm/nouveau/nouveau_chan.c
drivers/gpu/drm/nouveau/nouveau_chan.c
+11
-0
drivers/gpu/drm/nouveau/nouveau_gem.c
drivers/gpu/drm/nouveau/nouveau_gem.c
+1
-0
drivers/gpu/drm/nouveau/nouveau_mem.c
drivers/gpu/drm/nouveau/nouveau_mem.c
+112
-80
drivers/gpu/drm/nouveau/nouveau_mem.h
drivers/gpu/drm/nouveau/nouveau_mem.h
+6
-15
drivers/gpu/drm/nouveau/nouveau_sgdma.c
drivers/gpu/drm/nouveau/nouveau_sgdma.c
+1
-1
drivers/gpu/drm/nouveau/nouveau_ttm.c
drivers/gpu/drm/nouveau/nouveau_ttm.c
+3
-15
drivers/gpu/drm/nouveau/nouveau_vmm.c
drivers/gpu/drm/nouveau/nouveau_vmm.c
+14
-10
drivers/gpu/drm/nouveau/nouveau_vmm.h
drivers/gpu/drm/nouveau/nouveau_vmm.h
+0
-2
No files found.
drivers/gpu/drm/nouveau/include/nvif/device.h
View file @
d7722134
...
@@ -38,7 +38,6 @@ u64 nvif_device_time(struct nvif_device *);
...
@@ -38,7 +38,6 @@ u64 nvif_device_time(struct nvif_device *);
/*XXX*/
/*XXX*/
#include <subdev/bios.h>
#include <subdev/bios.h>
#include <subdev/fb.h>
#include <subdev/fb.h>
#include <subdev/mmu.h>
#include <subdev/bar.h>
#include <subdev/bar.h>
#include <subdev/gpio.h>
#include <subdev/gpio.h>
#include <subdev/clk.h>
#include <subdev/clk.h>
...
@@ -57,7 +56,6 @@ u64 nvif_device_time(struct nvif_device *);
...
@@ -57,7 +56,6 @@ u64 nvif_device_time(struct nvif_device *);
})
})
#define nvxx_bios(a) nvxx_device(a)->bios
#define nvxx_bios(a) nvxx_device(a)->bios
#define nvxx_fb(a) nvxx_device(a)->fb
#define nvxx_fb(a) nvxx_device(a)->fb
#define nvxx_mmu(a) nvxx_device(a)->mmu
#define nvxx_gpio(a) nvxx_device(a)->gpio
#define nvxx_gpio(a) nvxx_device(a)->gpio
#define nvxx_clk(a) nvxx_device(a)->clk
#define nvxx_clk(a) nvxx_device(a)->clk
#define nvxx_i2c(a) nvxx_device(a)->i2c
#define nvxx_i2c(a) nvxx_device(a)->i2c
...
...
drivers/gpu/drm/nouveau/nouveau_bo.c
View file @
d7722134
...
@@ -40,6 +40,10 @@
...
@@ -40,6 +40,10 @@
#include "nouveau_mem.h"
#include "nouveau_mem.h"
#include "nouveau_vmm.h"
#include "nouveau_vmm.h"
#include <nvif/class.h>
#include <nvif/if500b.h>
#include <nvif/if900b.h>
/*
/*
* NV10-NV40 tiling helpers
* NV10-NV40 tiling helpers
*/
*/
...
@@ -1034,21 +1038,18 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
...
@@ -1034,21 +1038,18 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
{
{
struct
nouveau_mem
*
old_mem
=
nouveau_mem
(
&
bo
->
mem
);
struct
nouveau_mem
*
old_mem
=
nouveau_mem
(
&
bo
->
mem
);
struct
nouveau_mem
*
new_mem
=
nouveau_mem
(
reg
);
struct
nouveau_mem
*
new_mem
=
nouveau_mem
(
reg
);
struct
nvkm_vm
*
vmm
=
drm
->
client
.
vm
;
struct
nvif_vmm
*
vmm
=
&
drm
->
client
.
vmm
.
vmm
;
u64
size
=
(
u64
)
reg
->
num_pages
<<
PAGE_SHIFT
;
int
ret
;
int
ret
;
ret
=
nv
km_vm_get
(
vmm
,
size
,
old_mem
->
mem
.
page
,
NV_MEM_ACCESS_RW
,
ret
=
nv
if_vmm_get
(
vmm
,
LAZY
,
false
,
old_mem
->
mem
.
page
,
0
,
&
old_mem
->
vma
[
0
]);
old_mem
->
mem
.
size
,
&
old_mem
->
vma
[
0
]);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
ret
=
nvkm_vm_get
(
vmm
,
size
,
new_mem
->
mem
.
page
,
NV_MEM_ACCESS_RW
,
ret
=
nvif_vmm_get
(
vmm
,
LAZY
,
false
,
new_mem
->
mem
.
page
,
0
,
&
old_mem
->
vma
[
1
]);
new_mem
->
mem
.
size
,
&
old_mem
->
vma
[
1
]);
if
(
ret
)
{
if
(
ret
)
nvkm_vm_put
(
&
old_mem
->
vma
[
0
]);
goto
done
;
return
ret
;
}
ret
=
nouveau_mem_map
(
old_mem
,
vmm
,
&
old_mem
->
vma
[
0
]);
ret
=
nouveau_mem_map
(
old_mem
,
vmm
,
&
old_mem
->
vma
[
0
]);
if
(
ret
)
if
(
ret
)
...
@@ -1057,8 +1058,8 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
...
@@ -1057,8 +1058,8 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo,
ret
=
nouveau_mem_map
(
new_mem
,
vmm
,
&
old_mem
->
vma
[
1
]);
ret
=
nouveau_mem_map
(
new_mem
,
vmm
,
&
old_mem
->
vma
[
1
]);
done:
done:
if
(
ret
)
{
if
(
ret
)
{
nv
km_vm_put
(
&
old_mem
->
vma
[
1
]);
nv
if_vmm_put
(
vmm
,
&
old_mem
->
vma
[
1
]);
nv
km_vm_put
(
&
old_mem
->
vma
[
0
]);
nv
if_vmm_put
(
vmm
,
&
old_mem
->
vma
[
0
]);
}
}
return
0
;
return
0
;
}
}
...
@@ -1374,7 +1375,6 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
...
@@ -1374,7 +1375,6 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
struct
nouveau_drm
*
drm
=
nouveau_bdev
(
bdev
);
struct
nouveau_drm
*
drm
=
nouveau_bdev
(
bdev
);
struct
nvkm_device
*
device
=
nvxx_device
(
&
drm
->
client
.
device
);
struct
nvkm_device
*
device
=
nvxx_device
(
&
drm
->
client
.
device
);
struct
nouveau_mem
*
mem
=
nouveau_mem
(
reg
);
struct
nouveau_mem
*
mem
=
nouveau_mem
(
reg
);
int
ret
;
reg
->
bus
.
addr
=
NULL
;
reg
->
bus
.
addr
=
NULL
;
reg
->
bus
.
offset
=
0
;
reg
->
bus
.
offset
=
0
;
...
@@ -1395,7 +1395,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
...
@@ -1395,7 +1395,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
reg
->
bus
.
is_iomem
=
!
drm
->
agp
.
cma
;
reg
->
bus
.
is_iomem
=
!
drm
->
agp
.
cma
;
}
}
#endif
#endif
if
(
drm
->
client
.
device
.
info
.
family
<
NV_DEVICE_INFO_V0_TESLA
||
!
mem
->
kind
)
if
(
drm
->
client
.
mem
->
oclass
<
NVIF_CLASS_MEM_NV50
||
!
mem
->
kind
)
/* untiled */
/* untiled */
break
;
break
;
/* fallthrough, tiled memory */
/* fallthrough, tiled memory */
...
@@ -1403,20 +1403,40 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
...
@@ -1403,20 +1403,40 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
reg
->
bus
.
offset
=
reg
->
start
<<
PAGE_SHIFT
;
reg
->
bus
.
offset
=
reg
->
start
<<
PAGE_SHIFT
;
reg
->
bus
.
base
=
device
->
func
->
resource_addr
(
device
,
1
);
reg
->
bus
.
base
=
device
->
func
->
resource_addr
(
device
,
1
);
reg
->
bus
.
is_iomem
=
true
;
reg
->
bus
.
is_iomem
=
true
;
if
(
drm
->
client
.
device
.
info
.
family
>=
NV_DEVICE_INFO_V0_TESLA
)
{
if
(
drm
->
client
.
mem
->
oclass
>=
NVIF_CLASS_MEM_NV50
)
{
struct
nvkm_vmm
*
bar
=
nvkm_bar_bar1_vmm
(
device
);
union
{
int
page_shift
=
12
;
struct
nv50_mem_map_v0
nv50
;
if
(
drm
->
client
.
device
.
info
.
family
>=
NV_DEVICE_INFO_V0_FERMI
)
struct
gf100_mem_map_v0
gf100
;
page_shift
=
mem
->
mem
.
page
;
}
args
;
u64
handle
,
length
;
ret
=
nvkm_vm_get
(
bar
,
mem
->
_mem
->
size
<<
12
,
u32
argc
=
0
;
page_shift
,
NV_MEM_ACCESS_RW
,
int
ret
;
&
mem
->
bar_vma
);
if
(
ret
)
switch
(
mem
->
mem
.
object
.
oclass
)
{
return
ret
;
case
NVIF_CLASS_MEM_NV50
:
args
.
nv50
.
version
=
0
;
args
.
nv50
.
ro
=
0
;
args
.
nv50
.
kind
=
mem
->
kind
;
args
.
nv50
.
comp
=
mem
->
comp
;
break
;
case
NVIF_CLASS_MEM_GF100
:
args
.
gf100
.
version
=
0
;
args
.
gf100
.
ro
=
0
;
args
.
gf100
.
kind
=
mem
->
kind
;
break
;
default:
WARN_ON
(
1
);
break
;
}
ret
=
nvif_object_map_handle
(
&
mem
->
mem
.
object
,
&
argc
,
argc
,
&
handle
,
&
length
);
if
(
ret
!=
1
)
return
ret
?
ret
:
-
EINVAL
;
nvkm_vm_map
(
&
mem
->
bar_vma
,
mem
->
_mem
)
;
reg
->
bus
.
base
=
0
;
reg
->
bus
.
offset
=
mem
->
bar_vma
.
offset
;
reg
->
bus
.
offset
=
handle
;
}
}
break
;
break
;
default:
default:
...
@@ -1428,12 +1448,22 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
...
@@ -1428,12 +1448,22 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
static
void
static
void
nouveau_ttm_io_mem_free
(
struct
ttm_bo_device
*
bdev
,
struct
ttm_mem_reg
*
reg
)
nouveau_ttm_io_mem_free
(
struct
ttm_bo_device
*
bdev
,
struct
ttm_mem_reg
*
reg
)
{
{
struct
nouveau_drm
*
drm
=
nouveau_bdev
(
bdev
);
struct
nouveau_mem
*
mem
=
nouveau_mem
(
reg
);
struct
nouveau_mem
*
mem
=
nouveau_mem
(
reg
);
if
(
!
mem
->
bar_vma
.
node
)
if
(
drm
->
client
.
mem
->
oclass
>=
NVIF_CLASS_MEM_NV50
)
{
return
;
switch
(
reg
->
mem_type
)
{
case
TTM_PL_TT
:
nvkm_vm_put
(
&
mem
->
bar_vma
);
if
(
mem
->
kind
)
nvif_object_unmap_handle
(
&
mem
->
mem
.
object
);
break
;
case
TTM_PL_VRAM
:
nvif_object_unmap_handle
(
&
mem
->
mem
.
object
);
break
;
default:
break
;
}
}
}
}
static
int
static
int
...
...
drivers/gpu/drm/nouveau/nouveau_chan.c
View file @
d7722134
...
@@ -84,6 +84,14 @@ nouveau_channel_del(struct nouveau_channel **pchan)
...
@@ -84,6 +84,14 @@ nouveau_channel_del(struct nouveau_channel **pchan)
{
{
struct
nouveau_channel
*
chan
=
*
pchan
;
struct
nouveau_channel
*
chan
=
*
pchan
;
if
(
chan
)
{
if
(
chan
)
{
struct
nouveau_cli
*
cli
=
(
void
*
)
chan
->
user
.
client
;
bool
super
;
if
(
cli
)
{
super
=
cli
->
base
.
super
;
cli
->
base
.
super
=
true
;
}
if
(
chan
->
fence
)
if
(
chan
->
fence
)
nouveau_fence
(
chan
->
drm
)
->
context_del
(
chan
);
nouveau_fence
(
chan
->
drm
)
->
context_del
(
chan
);
nvif_object_fini
(
&
chan
->
nvsw
);
nvif_object_fini
(
&
chan
->
nvsw
);
...
@@ -98,6 +106,9 @@ nouveau_channel_del(struct nouveau_channel **pchan)
...
@@ -98,6 +106,9 @@ nouveau_channel_del(struct nouveau_channel **pchan)
nouveau_bo_unpin
(
chan
->
push
.
buffer
);
nouveau_bo_unpin
(
chan
->
push
.
buffer
);
nouveau_bo_ref
(
NULL
,
&
chan
->
push
.
buffer
);
nouveau_bo_ref
(
NULL
,
&
chan
->
push
.
buffer
);
kfree
(
chan
);
kfree
(
chan
);
if
(
cli
)
cli
->
base
.
super
=
super
;
}
}
*
pchan
=
NULL
;
*
pchan
=
NULL
;
}
}
...
...
drivers/gpu/drm/nouveau/nouveau_gem.c
View file @
d7722134
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "nouveau_ttm.h"
#include "nouveau_ttm.h"
#include "nouveau_gem.h"
#include "nouveau_gem.h"
#include "nouveau_mem.h"
#include "nouveau_vmm.h"
#include "nouveau_vmm.h"
#include <nvif/class.h>
#include <nvif/class.h>
...
...
drivers/gpu/drm/nouveau/nouveau_mem.c
View file @
d7722134
...
@@ -25,19 +25,70 @@
...
@@ -25,19 +25,70 @@
#include <drm/ttm/ttm_bo_driver.h>
#include <drm/ttm/ttm_bo_driver.h>
#include <nvif/class.h>
#include <nvif/if000a.h>
#include <nvif/if500b.h>
#include <nvif/if500d.h>
#include <nvif/if900b.h>
#include <nvif/if900d.h>
int
int
nouveau_mem_map
(
struct
nouveau_mem
*
mem
,
nouveau_mem_map
(
struct
nouveau_mem
*
mem
,
struct
nv
km_vmm
*
vmm
,
struct
nvkm
_vma
*
vma
)
struct
nv
if_vmm
*
vmm
,
struct
nvif
_vma
*
vma
)
{
{
nvkm_vm_map
(
vma
,
mem
->
_mem
);
union
{
return
0
;
struct
nv50_vmm_map_v0
nv50
;
struct
gf100_vmm_map_v0
gf100
;
}
args
;
u32
argc
=
0
;
bool
super
;
int
ret
;
switch
(
vmm
->
object
.
oclass
)
{
case
NVIF_CLASS_VMM_NV04
:
break
;
case
NVIF_CLASS_VMM_NV50
:
args
.
nv50
.
version
=
0
;
args
.
nv50
.
ro
=
0
;
args
.
nv50
.
priv
=
0
;
args
.
nv50
.
kind
=
mem
->
kind
;
args
.
nv50
.
comp
=
mem
->
comp
;
argc
=
sizeof
(
args
.
nv50
);
break
;
case
NVIF_CLASS_VMM_GF100
:
case
NVIF_CLASS_VMM_GM200
:
case
NVIF_CLASS_VMM_GP100
:
args
.
gf100
.
version
=
0
;
if
(
mem
->
mem
.
type
&
NVIF_MEM_VRAM
)
args
.
gf100
.
vol
=
0
;
else
args
.
gf100
.
vol
=
1
;
args
.
gf100
.
ro
=
0
;
args
.
gf100
.
priv
=
0
;
args
.
gf100
.
kind
=
mem
->
kind
;
argc
=
sizeof
(
args
.
gf100
);
break
;
default:
WARN_ON
(
1
);
return
-
ENOSYS
;
}
super
=
vmm
->
object
.
client
->
super
;
vmm
->
object
.
client
->
super
=
true
;
ret
=
nvif_vmm_map
(
vmm
,
vma
->
addr
,
mem
->
mem
.
size
,
&
args
,
argc
,
&
mem
->
mem
,
0
);
vmm
->
object
.
client
->
super
=
super
;
return
ret
;
}
}
void
void
nouveau_mem_fini
(
struct
nouveau_mem
*
mem
)
nouveau_mem_fini
(
struct
nouveau_mem
*
mem
)
{
{
nvkm_vm_put
(
&
mem
->
vma
[
1
]);
nvif_vmm_put
(
&
mem
->
cli
->
drm
->
client
.
vmm
.
vmm
,
&
mem
->
vma
[
1
]);
nvkm_vm_put
(
&
mem
->
vma
[
0
]);
nvif_vmm_put
(
&
mem
->
cli
->
drm
->
client
.
vmm
.
vmm
,
&
mem
->
vma
[
0
]);
mutex_lock
(
&
mem
->
cli
->
drm
->
master
.
lock
);
nvif_mem_fini
(
&
mem
->
mem
);
mutex_unlock
(
&
mem
->
cli
->
drm
->
master
.
lock
);
}
}
int
int
...
@@ -45,67 +96,79 @@ nouveau_mem_host(struct ttm_mem_reg *reg, struct ttm_dma_tt *tt)
...
@@ -45,67 +96,79 @@ nouveau_mem_host(struct ttm_mem_reg *reg, struct ttm_dma_tt *tt)
{
{
struct
nouveau_mem
*
mem
=
nouveau_mem
(
reg
);
struct
nouveau_mem
*
mem
=
nouveau_mem
(
reg
);
struct
nouveau_cli
*
cli
=
mem
->
cli
;
struct
nouveau_cli
*
cli
=
mem
->
cli
;
struct
nouveau_drm
*
drm
=
cli
->
drm
;
struct
nvif_mmu
*
mmu
=
&
cli
->
mmu
;
struct
nvif_mem_ram_v0
args
=
{};
bool
super
=
cli
->
base
.
super
;
u8
type
;
int
ret
;
if
(
mmu
->
type
[
drm
->
ttm
.
type_host
].
type
&
NVIF_MEM_UNCACHED
)
type
=
drm
->
ttm
.
type_ncoh
;
else
type
=
drm
->
ttm
.
type_host
;
if
(
mem
->
kind
&&
cli
->
device
.
info
.
chipset
==
0x50
)
if
(
mem
->
kind
&&
!
(
mmu
->
type
[
type
].
type
&
NVIF_MEM_KIND
)
)
mem
->
comp
=
mem
->
kind
=
0
;
mem
->
comp
=
mem
->
kind
=
0
;
if
(
mem
->
comp
)
{
if
(
mem
->
comp
&&
!
(
mmu
->
type
[
type
].
type
&
NVIF_MEM_COMP
)
)
{
if
(
cli
->
device
.
info
.
chipset
>=
0xc
0
)
if
(
mmu
->
object
.
oclass
>=
NVIF_CLASS_MMU_GF10
0
)
mem
->
kind
=
gf100_pte_storage_type_map
[
mem
->
kind
];
mem
->
kind
=
mmu
->
kind
[
mem
->
kind
];
mem
->
comp
=
0
;
mem
->
comp
=
0
;
}
}
mem
->
__mem
.
size
=
(
reg
->
num_pages
<<
PAGE_SHIFT
)
>>
12
;
if
(
tt
->
ttm
.
sg
)
args
.
sgl
=
tt
->
ttm
.
sg
->
sgl
;
mem
->
__mem
.
memtype
=
(
mem
->
comp
<<
7
)
|
mem
->
kind
;
else
args
.
dma
=
tt
->
dma_address
;
if
(
tt
->
ttm
.
sg
)
mem
->
__mem
.
sg
=
tt
->
ttm
.
sg
;
else
mem
->
__mem
.
pages
=
tt
->
dma_address
;
mem
->
_mem
=
&
mem
->
__mem
;
mem
->
mem
.
page
=
12
;
mem
->
_mem
->
memory
=
&
mem
->
memory
;
return
0
;
}
#include <subdev/fb/nv50.h>
struct
nvkm_vram
{
mutex_lock
(
&
drm
->
master
.
lock
);
struct
nvkm_memory
memory
;
cli
->
base
.
super
=
true
;
struct
nvkm_ram
*
ram
;
ret
=
nvif_mem_init_type
(
mmu
,
cli
->
mem
->
oclass
,
type
,
PAGE_SHIFT
,
u8
page
;
reg
->
num_pages
<<
PAGE_SHIFT
,
struct
nvkm_mm_node
*
mn
;
&
args
,
sizeof
(
args
),
&
mem
->
mem
);
};
cli
->
base
.
super
=
super
;
mutex_unlock
(
&
drm
->
master
.
lock
);
return
ret
;
}
int
int
nouveau_mem_vram
(
struct
ttm_mem_reg
*
reg
,
bool
contig
,
u8
page
)
nouveau_mem_vram
(
struct
ttm_mem_reg
*
reg
,
bool
contig
,
u8
page
)
{
{
struct
nouveau_mem
*
mem
=
nouveau_mem
(
reg
);
struct
nouveau_mem
*
mem
=
nouveau_mem
(
reg
);
struct
nouveau_cli
*
cli
=
mem
->
cli
;
struct
nouveau_cli
*
cli
=
mem
->
cli
;
struct
nvkm_device
*
device
=
nvxx_device
(
&
cli
->
device
);
struct
nouveau_drm
*
drm
=
cli
->
drm
;
struct
nvif_mmu
*
mmu
=
&
cli
->
mmu
;
bool
super
=
cli
->
base
.
super
;
u64
size
=
ALIGN
(
reg
->
num_pages
<<
PAGE_SHIFT
,
1
<<
page
);
u64
size
=
ALIGN
(
reg
->
num_pages
<<
PAGE_SHIFT
,
1
<<
page
);
u8
type
;
int
ret
;
int
ret
;
mem
->
mem
.
page
=
page
;
mutex_lock
(
&
drm
->
master
.
lock
);
mem
->
_mem
=
&
mem
->
__mem
;
cli
->
base
.
super
=
true
;
switch
(
cli
->
mem
->
oclass
)
{
if
(
cli
->
device
.
info
.
chipset
<
0xc0
)
{
case
NVIF_CLASS_MEM_GF100
:
type
=
nv50_fb_memtype
[
mem
->
kind
];
ret
=
nvif_mem_init_type
(
mmu
,
cli
->
mem
->
oclass
,
}
else
{
drm
->
ttm
.
type_vram
,
page
,
size
,
if
(
!
mem
->
comp
)
&
(
struct
gf100_mem_v0
)
{
mem
->
kind
=
gf100_pte_storage_type_map
[
mem
->
kind
];
.
contig
=
contig
,
mem
->
comp
=
0
;
},
sizeof
(
struct
gf100_mem_v0
),
type
=
0x01
;
&
mem
->
mem
);
break
;
case
NVIF_CLASS_MEM_NV50
:
ret
=
nvif_mem_init_type
(
mmu
,
cli
->
mem
->
oclass
,
drm
->
ttm
.
type_vram
,
page
,
size
,
&
(
struct
nv50_mem_v0
)
{
.
bankswz
=
mmu
->
kind
[
mem
->
kind
]
==
2
,
.
contig
=
contig
,
},
sizeof
(
struct
nv50_mem_v0
),
&
mem
->
mem
);
break
;
default:
ret
=
-
ENOSYS
;
WARN_ON
(
1
);
break
;
}
}
cli
->
base
.
super
=
super
;
mutex_unlock
(
&
drm
->
master
.
lock
);
ret
=
nvkm_ram_get
(
device
,
NVKM_RAM_MM_NORMAL
,
type
,
page
,
size
,
reg
->
start
=
mem
->
mem
.
addr
>>
PAGE_SHIFT
;
contig
,
false
,
&
mem
->
_mem
->
memory
);
if
(
ret
)
return
ret
;
mem
->
_mem
->
size
=
size
>>
NVKM_RAM_MM_SHIFT
;
mem
->
_mem
->
offset
=
nvkm_memory_addr
(
mem
->
_mem
->
memory
);
mem
->
_mem
->
mem
=
((
struct
nvkm_vram
*
)
mem
->
_mem
->
memory
)
->
mn
;
mem
->
_mem
->
memtype
=
(
mem
->
comp
<<
7
)
|
mem
->
kind
;
reg
->
start
=
mem
->
_mem
->
offset
>>
PAGE_SHIFT
;
return
ret
;
return
ret
;
}
}
...
@@ -118,36 +181,6 @@ nouveau_mem_del(struct ttm_mem_reg *reg)
...
@@ -118,36 +181,6 @@ nouveau_mem_del(struct ttm_mem_reg *reg)
reg
->
mm_node
=
NULL
;
reg
->
mm_node
=
NULL
;
}
}
static
enum
nvkm_memory_target
nouveau_mem_memory_target
(
struct
nvkm_memory
*
memory
)
{
struct
nouveau_mem
*
mem
=
container_of
(
memory
,
typeof
(
*
mem
),
memory
);
if
(
mem
->
_mem
->
mem
)
return
NVKM_MEM_TARGET_VRAM
;
return
NVKM_MEM_TARGET_HOST
;
};
static
u8
nouveau_mem_memory_page
(
struct
nvkm_memory
*
memory
)
{
struct
nouveau_mem
*
mem
=
container_of
(
memory
,
typeof
(
*
mem
),
memory
);
return
mem
->
mem
.
page
;
};
static
u64
nouveau_mem_memory_size
(
struct
nvkm_memory
*
memory
)
{
struct
nouveau_mem
*
mem
=
container_of
(
memory
,
typeof
(
*
mem
),
memory
);
return
mem
->
_mem
->
size
<<
12
;
}
static
const
struct
nvkm_memory_func
nouveau_mem_memory
=
{
.
target
=
nouveau_mem_memory_target
,
.
page
=
nouveau_mem_memory_page
,
.
size
=
nouveau_mem_memory_size
,
};
int
int
nouveau_mem_new
(
struct
nouveau_cli
*
cli
,
u8
kind
,
u8
comp
,
nouveau_mem_new
(
struct
nouveau_cli
*
cli
,
u8
kind
,
u8
comp
,
struct
ttm_mem_reg
*
reg
)
struct
ttm_mem_reg
*
reg
)
...
@@ -159,7 +192,6 @@ nouveau_mem_new(struct nouveau_cli *cli, u8 kind, u8 comp,
...
@@ -159,7 +192,6 @@ nouveau_mem_new(struct nouveau_cli *cli, u8 kind, u8 comp,
mem
->
cli
=
cli
;
mem
->
cli
=
cli
;
mem
->
kind
=
kind
;
mem
->
kind
=
kind
;
mem
->
comp
=
comp
;
mem
->
comp
=
comp
;
nvkm_memory_ctor
(
&
nouveau_mem_memory
,
&
mem
->
memory
);
reg
->
mm_node
=
mem
;
reg
->
mm_node
=
mem
;
return
0
;
return
0
;
...
...
drivers/gpu/drm/nouveau/nouveau_mem.h
View file @
d7722134
#ifndef __NOUVEAU_MEM_H__
#ifndef __NOUVEAU_MEM_H__
#define __NOUVEAU_MEM_H__
#define __NOUVEAU_MEM_H__
#include <core/memory.h>
#include <subdev/fb.h>
#include <subdev/mmu.h>
#include <drm/ttm/ttm_bo_api.h>
#include <drm/ttm/ttm_bo_api.h>
struct
ttm_dma_tt
;
struct
ttm_dma_tt
;
#include <nvif/mem.h>
#include <nvif/vmm.h>
static
inline
struct
nouveau_mem
*
static
inline
struct
nouveau_mem
*
nouveau_mem
(
struct
ttm_mem_reg
*
reg
)
nouveau_mem
(
struct
ttm_mem_reg
*
reg
)
{
{
...
@@ -17,16 +16,8 @@ struct nouveau_mem {
...
@@ -17,16 +16,8 @@ struct nouveau_mem {
struct
nouveau_cli
*
cli
;
struct
nouveau_cli
*
cli
;
u8
kind
;
u8
kind
;
u8
comp
;
u8
comp
;
struct
{
struct
nvif_mem
mem
;
u8
page
;
struct
nvif_vma
vma
[
2
];
}
mem
;
struct
nvkm_vma
vma
[
2
];
struct
nvkm_mem
__mem
;
struct
nvkm_mem
*
_mem
;
struct
nvkm_vma
bar_vma
;
struct
nvkm_memory
memory
;
};
};
int
nouveau_mem_new
(
struct
nouveau_cli
*
,
u8
kind
,
u8
comp
,
int
nouveau_mem_new
(
struct
nouveau_cli
*
,
u8
kind
,
u8
comp
,
...
@@ -35,5 +26,5 @@ void nouveau_mem_del(struct ttm_mem_reg *);
...
@@ -35,5 +26,5 @@ void nouveau_mem_del(struct ttm_mem_reg *);
int
nouveau_mem_vram
(
struct
ttm_mem_reg
*
,
bool
contig
,
u8
page
);
int
nouveau_mem_vram
(
struct
ttm_mem_reg
*
,
bool
contig
,
u8
page
);
int
nouveau_mem_host
(
struct
ttm_mem_reg
*
,
struct
ttm_dma_tt
*
);
int
nouveau_mem_host
(
struct
ttm_mem_reg
*
,
struct
ttm_dma_tt
*
);
void
nouveau_mem_fini
(
struct
nouveau_mem
*
);
void
nouveau_mem_fini
(
struct
nouveau_mem
*
);
int
nouveau_mem_map
(
struct
nouveau_mem
*
,
struct
nv
km_vmm
*
,
struct
nvkm
_vma
*
);
int
nouveau_mem_map
(
struct
nouveau_mem
*
,
struct
nv
if_vmm
*
,
struct
nvif
_vma
*
);
#endif
#endif
drivers/gpu/drm/nouveau/nouveau_sgdma.c
View file @
d7722134
...
@@ -35,7 +35,7 @@ nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)
...
@@ -35,7 +35,7 @@ nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
ret
=
nouveau_mem_map
(
mem
,
mem
->
cli
->
v
m
,
&
mem
->
vma
[
0
]);
ret
=
nouveau_mem_map
(
mem
,
&
mem
->
cli
->
vmm
.
vm
m
,
&
mem
->
vma
[
0
]);
if
(
ret
)
{
if
(
ret
)
{
nouveau_mem_fini
(
mem
);
nouveau_mem_fini
(
mem
);
return
ret
;
return
ret
;
...
...
drivers/gpu/drm/nouveau/nouveau_ttm.c
View file @
d7722134
...
@@ -56,15 +56,6 @@ nouveau_manager_debug(struct ttm_mem_type_manager *man,
...
@@ -56,15 +56,6 @@ nouveau_manager_debug(struct ttm_mem_type_manager *man,
{
{
}
}
static
void
nouveau_vram_manager_del
(
struct
ttm_mem_type_manager
*
man
,
struct
ttm_mem_reg
*
reg
)
{
struct
nvkm_memory
*
memory
=
nouveau_mem
(
reg
)
->
_mem
->
memory
;
nouveau_mem_del
(
reg
);
nvkm_memory_unref
(
&
memory
);
}
static
int
static
int
nouveau_vram_manager_new
(
struct
ttm_mem_type_manager
*
man
,
nouveau_vram_manager_new
(
struct
ttm_mem_type_manager
*
man
,
struct
ttm_buffer_object
*
bo
,
struct
ttm_buffer_object
*
bo
,
...
@@ -101,7 +92,7 @@ const struct ttm_mem_type_manager_func nouveau_vram_manager = {
...
@@ -101,7 +92,7 @@ const struct ttm_mem_type_manager_func nouveau_vram_manager = {
.
init
=
nouveau_manager_init
,
.
init
=
nouveau_manager_init
,
.
takedown
=
nouveau_manager_fini
,
.
takedown
=
nouveau_manager_fini
,
.
get_node
=
nouveau_vram_manager_new
,
.
get_node
=
nouveau_vram_manager_new
,
.
put_node
=
nouveau_
vram_
manager_del
,
.
put_node
=
nouveau_manager_del
,
.
debug
=
nouveau_manager_debug
,
.
debug
=
nouveau_manager_debug
,
};
};
...
@@ -121,7 +112,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
...
@@ -121,7 +112,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
mem
->
_mem
=
&
mem
->
__mem
;
reg
->
start
=
0
;
reg
->
start
=
0
;
return
0
;
return
0
;
}
}
...
@@ -143,7 +133,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
...
@@ -143,7 +133,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
struct
nouveau_bo
*
nvbo
=
nouveau_bo
(
bo
);
struct
nouveau_bo
*
nvbo
=
nouveau_bo
(
bo
);
struct
nouveau_drm
*
drm
=
nvbo
->
cli
->
drm
;
struct
nouveau_drm
*
drm
=
nvbo
->
cli
->
drm
;
struct
nouveau_mem
*
mem
;
struct
nouveau_mem
*
mem
;
struct
nvkm_mmu
*
mmu
=
nvxx_mmu
(
&
drm
->
client
.
device
);
int
ret
;
int
ret
;
ret
=
nouveau_mem_new
(
&
drm
->
master
,
nvbo
->
kind
,
nvbo
->
comp
,
reg
);
ret
=
nouveau_mem_new
(
&
drm
->
master
,
nvbo
->
kind
,
nvbo
->
comp
,
reg
);
...
@@ -151,8 +140,8 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
...
@@ -151,8 +140,8 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
ret
=
nv
km_vm_get
(
mmu
->
vmm
,
reg
->
num_pages
<<
12
,
12
,
ret
=
nv
if_vmm_get
(
&
mem
->
cli
->
vmm
.
vmm
,
PTES
,
false
,
12
,
0
,
NV_MEM_ACCESS_RW
,
&
mem
->
vma
[
0
]);
reg
->
num_pages
<<
PAGE_SHIFT
,
&
mem
->
vma
[
0
]);
if
(
ret
)
{
if
(
ret
)
{
nouveau_mem_del
(
reg
);
nouveau_mem_del
(
reg
);
if
(
ret
==
-
ENOSPC
)
{
if
(
ret
==
-
ENOSPC
)
{
...
@@ -162,7 +151,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
...
@@ -162,7 +151,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
return
ret
;
return
ret
;
}
}
mem
->
_mem
=
&
mem
->
__mem
;
reg
->
start
=
mem
->
vma
[
0
].
addr
>>
PAGE_SHIFT
;
reg
->
start
=
mem
->
vma
[
0
].
addr
>>
PAGE_SHIFT
;
return
0
;
return
0
;
}
}
...
...
drivers/gpu/drm/nouveau/nouveau_vmm.c
View file @
d7722134
...
@@ -28,7 +28,7 @@ void
...
@@ -28,7 +28,7 @@ void
nouveau_vma_unmap
(
struct
nouveau_vma
*
vma
)
nouveau_vma_unmap
(
struct
nouveau_vma
*
vma
)
{
{
if
(
vma
->
mem
)
{
if
(
vma
->
mem
)
{
nv
km_vm_unmap
(
&
vma
->
_vma
);
nv
if_vmm_unmap
(
&
vma
->
vmm
->
vmm
,
vma
->
addr
);
vma
->
mem
=
NULL
;
vma
->
mem
=
NULL
;
}
}
}
}
...
@@ -36,7 +36,8 @@ nouveau_vma_unmap(struct nouveau_vma *vma)
...
@@ -36,7 +36,8 @@ nouveau_vma_unmap(struct nouveau_vma *vma)
int
int
nouveau_vma_map
(
struct
nouveau_vma
*
vma
,
struct
nouveau_mem
*
mem
)
nouveau_vma_map
(
struct
nouveau_vma
*
vma
,
struct
nouveau_mem
*
mem
)
{
{
int
ret
=
nouveau_mem_map
(
mem
,
vma
->
vmm
->
vm
,
&
vma
->
_vma
);
struct
nvif_vma
tmp
=
{
.
addr
=
vma
->
addr
};
int
ret
=
nouveau_mem_map
(
mem
,
&
vma
->
vmm
->
vmm
,
&
tmp
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
vma
->
mem
=
mem
;
vma
->
mem
=
mem
;
...
@@ -61,8 +62,10 @@ nouveau_vma_del(struct nouveau_vma **pvma)
...
@@ -61,8 +62,10 @@ nouveau_vma_del(struct nouveau_vma **pvma)
{
{
struct
nouveau_vma
*
vma
=
*
pvma
;
struct
nouveau_vma
*
vma
=
*
pvma
;
if
(
vma
&&
--
vma
->
refs
<=
0
)
{
if
(
vma
&&
--
vma
->
refs
<=
0
)
{
if
(
likely
(
vma
->
addr
!=
~
0ULL
))
if
(
likely
(
vma
->
addr
!=
~
0ULL
))
{
nvkm_vm_put
(
&
vma
->
_vma
);
struct
nvif_vma
tmp
=
{
.
addr
=
vma
->
addr
,
.
size
=
1
};
nvif_vmm_put
(
&
vma
->
vmm
->
vmm
,
&
tmp
);
}
list_del
(
&
vma
->
head
);
list_del
(
&
vma
->
head
);
*
pvma
=
NULL
;
*
pvma
=
NULL
;
kfree
(
*
pvma
);
kfree
(
*
pvma
);
...
@@ -75,6 +78,7 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
...
@@ -75,6 +78,7 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
{
{
struct
nouveau_mem
*
mem
=
nouveau_mem
(
&
nvbo
->
bo
.
mem
);
struct
nouveau_mem
*
mem
=
nouveau_mem
(
&
nvbo
->
bo
.
mem
);
struct
nouveau_vma
*
vma
;
struct
nouveau_vma
*
vma
;
struct
nvif_vma
tmp
;
int
ret
;
int
ret
;
if
((
vma
=
*
pvma
=
nouveau_vma_find
(
nvbo
,
vmm
)))
{
if
((
vma
=
*
pvma
=
nouveau_vma_find
(
nvbo
,
vmm
)))
{
...
@@ -92,17 +96,17 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
...
@@ -92,17 +96,17 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
if
(
nvbo
->
bo
.
mem
.
mem_type
!=
TTM_PL_SYSTEM
&&
if
(
nvbo
->
bo
.
mem
.
mem_type
!=
TTM_PL_SYSTEM
&&
mem
->
mem
.
page
==
nvbo
->
page
)
{
mem
->
mem
.
page
==
nvbo
->
page
)
{
ret
=
nv
km_vm_get
(
vmm
->
vm
,
mem
->
_mem
->
size
<<
12
,
mem
->
mem
.
page
,
ret
=
nv
if_vmm_get
(
&
vmm
->
vmm
,
LAZY
,
false
,
mem
->
mem
.
page
,
0
,
NV_MEM_ACCESS_RW
,
&
vma
->
_vma
);
mem
->
mem
.
size
,
&
tmp
);
if
(
ret
)
if
(
ret
)
goto
done
;
goto
done
;
vma
->
addr
=
vma
->
_vma
.
offset
;
vma
->
addr
=
tmp
.
addr
;
ret
=
nouveau_vma_map
(
vma
,
mem
);
ret
=
nouveau_vma_map
(
vma
,
mem
);
}
else
{
}
else
{
ret
=
nv
km_vm_get
(
vmm
->
vm
,
mem
->
_mem
->
size
<<
12
,
mem
->
mem
.
page
,
ret
=
nv
if_vmm_get
(
&
vmm
->
vmm
,
PTES
,
false
,
mem
->
mem
.
page
,
0
,
NV_MEM_ACCESS_RW
,
&
vma
->
_vma
);
mem
->
mem
.
size
,
&
tmp
);
vma
->
addr
=
vma
->
_vma
.
offset
;
vma
->
addr
=
tmp
.
addr
;
}
}
done:
done:
...
...
drivers/gpu/drm/nouveau/nouveau_vmm.h
View file @
d7722134
...
@@ -12,8 +12,6 @@ struct nouveau_vma {
...
@@ -12,8 +12,6 @@ struct nouveau_vma {
u64
addr
;
u64
addr
;
struct
nouveau_mem
*
mem
;
struct
nouveau_mem
*
mem
;
struct
nvkm_vma
_vma
;
};
};
struct
nouveau_vma
*
nouveau_vma_find
(
struct
nouveau_bo
*
,
struct
nouveau_vmm
*
);
struct
nouveau_vma
*
nouveau_vma_find
(
struct
nouveau_bo
*
,
struct
nouveau_vmm
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment