drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations
Subsystems (3)
PATCH v4 1/1 drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations
Allows PTE kind and tile mode on BO create with VM_BIND, and adds a GETPARAM to indicate this change. This is needed to support modifiers in NVK and ensure correctness when dealing with the nouveau GL driver.
The userspace modifiers implementation this is for can be found here:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24795
--- drivers/gpu/drm/nouveau/nouveau_abi16.c | 3 ++ drivers/gpu/drm/nouveau/nouveau_bo.c | 44 +++++++++++-------------- include/uapi/drm/nouveau_drm.h | 7 ++++ 3 files changed, 29 insertions(+), 25 deletions(-)
drivers/gpu/drm/nouveau/nouveau_abi16.c +3 -0
@@ -272,6 +272,9 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) getparam->value = (u64 )ttm_resource_manager_usage (vram_mgr);break ; } +case NOUVEAU_GETPARAM_HAS_VMA_TILEMODE : + getparam->value =1 ; +break ;default :NV_PRINTK (dbg, cli,"unknown parameter %lld\n" , getparam->param);return -EINVAL ;
drivers/gpu/drm/nouveau/nouveau_bo.c +19 -25
59 lines not on this page · raw message
include/uapi/drm/nouveau_drm.h +7 -0
@@ -68,6 +68,13 @@ extern "C" {*/ #define NOUVEAU_GETPARAM_VRAM_USED 19 +/* +* NOUVEAU_GETPARAM_HAS_VMA_TILEMODE +* +* Query whether tile mode and PTE kind are accepted with VM allocs or not. +*/ +#define NOUVEAU_GETPARAM_HAS_VMA_TILEMODE 20 +struct drm_nouveau_getparam {__u64 param;__u64 value;
Signature · 1 line
2.44.0
Quoted 11 lines · Mohamed Ahmed
Allows PTE kind and tile mode on BO create with
VM_BIND, and adds a GETPARAM to indicate this change. This is needed to support modifiers in NVK and ensure correctness when dealing with the nouveau GL driver.The userspace modifiers implementation this is for can be found here:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24795Fixes b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI")Signed-off-by Mohamed Ahmed <[email protected]>
Quoted 120 lines
--- drivers/gpu/drm/nouveau/nouveau_abi16.c | 3 ++ drivers/gpu/drm/nouveau/nouveau_bo.c | 44 +++++++++++-------------- include/uapi/drm/nouveau_drm.h | 7 ++++ 3 files changed, 29 insertions(+), 25 deletions(-)drivers/gpu/drm/nouveau/nouveau_abi16.c +3
-0@@ -272,6 +272,9 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) getparam->value = (u64 )ttm_resource_manager_usage (vram_mgr);break ; } +case NOUVEAU_GETPARAM_HAS_VMA_TILEMODE : + getparam->value =1 ; +break ;default : NV_PRINTK(dbg, cli, "unknown parameter %lld\n",getparam->param); return -EINVAL;drivers/gpu/drm/nouveau/nouveau_bo.c +19
-19@@ -241,28 +241,28 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain, } nvbo->contig = !(tile_flags & NOUVEAU_GEM_TILE_NONCONTIG); -if (!nouveau_cli_uvmm (cli) || internal) { -/* for BO noVM allocs, don't assign kinds */ -if (cli->device.info.family >=NV_DEVICE_INFO_V0_FERMI ) { - nvbo->kind = (tile_flags &0x0000ff00 ) >>8 ; -if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { -kfree (nvbo); -return ERR_PTR (-EINVAL ); - } - nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind; - }else if (cli->device.info.family >= NV_DEVICE_INFO_V0_TESLA) { - nvbo->kind = (tile_flags &0x00007f00 ) >>8 ; - nvbo->comp = (tile_flags &0x00030000 ) >>16 ; -if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { -kfree (nvbo); -return ERR_PTR (-EINVAL ); - } - }else { - nvbo->zeta = (tile_flags &0x00000007 ); +if (cli->device.info.family >=NV_DEVICE_INFO_V0_FERMI ) { + nvbo->kind = (tile_flags &0x0000ff00 ) >>8 ; +if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { +kfree (nvbo); +return ERR_PTR (-EINVAL ); + } + + nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind; + }else if (cli->device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { + nvbo->kind = (tile_flags &0x00007f00 ) >>8 ; + nvbo->comp = (tile_flags &0x00030000 ) >>16 ; +if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { +kfree (nvbo); +return ERR_PTR (-EINVAL ); } - nvbo->mode = tile_mode; + }else { + nvbo->zeta = (tile_flags &0x00000007 ); + } + nvbo->mode = tile_mode; +if (!nouveau_cli_uvmm (cli) || internal) {/* Determine the desirable target GPU page size for the buffer. */
for (i = 0; i < vmm->page_nr; i++) { /* Because we cannot currently allow VMM maps tofail
drivers/gpu/drm/nouveau/nouveau_bo.c +0
-6@@ -304,12 +304,6 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain, } nvbo->page = vmm->page[pi].shift; }else { -/* reject other tile flags when in VM mode. */ -if (tile_mode) -return ERR_PTR (-EINVAL ); -if (tile_flags & ~NOUVEAU_GEM_TILE_NONCONTIG ) -return ERR_PTR (-EINVAL ); -/* Determine the desirable target GPU page size for the buffer. */
for (i = 0; i < vmm->page_nr; i++) { /* Because we cannot currently allow VMM maps tofail
include/uapi/drm/nouveau_drm.h +4
-0@@ -68,6 +68,13 @@ extern "C" {*/ #define NOUVEAU_GETPARAM_VRAM_USED 19 +/* +* NOUVEAU_GETPARAM_HAS_VMA_TILEMODE +* +* Query whether tile mode and PTE kind are accepted with VM allocs or not.
+ */include/uapi/drm/nouveau_drm.h +2
-1+#define NOUVEAU_GETPARAM_HAS_VMA_TILEMODE 20 +struct drm_nouveau_getparam {__u64 param;__u64 value; --2.44.0
Danilo Krummrich
AppliedHi Mohamed,
Thank you for fixing this up!
Quoted 2 lines · Mohamed Ahmed
Allows PTE kind and tile mode on BO create with
VM_BIND, and adds a GETPARAM to indicate this change. This is needed to support
It's usually better to use imperative verb form for commit messages. No need to send a new version though.
Quoted 8 lines
modifiers in NVK and ensure correctness when dealing with the nouveau GL driver.
The userspace modifiers implementation this is for can be found here:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24795Fixes b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI")Signed-off-by Mohamed Ahmed <[email protected]>
Applied to drm-misc-next-fixes.
Generally, please make sure to use scripts/get_maintainer.pl before sending patches.
- Danilo
Quoted 103 lines
--- drivers/gpu/drm/nouveau/nouveau_abi16.c | 3 ++ drivers/gpu/drm/nouveau/nouveau_bo.c | 44 +++++++++++-------------- include/uapi/drm/nouveau_drm.h | 7 ++++ 3 files changed, 29 insertions(+), 25 deletions(-)drivers/gpu/drm/nouveau/nouveau_abi16.c +3
-0@@ -272,6 +272,9 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) getparam->value = (u64 )ttm_resource_manager_usage (vram_mgr);break ; } +case NOUVEAU_GETPARAM_HAS_VMA_TILEMODE : + getparam->value =1 ; +break ;default :NV_PRINTK (dbg, cli,"unknown parameter %lld\n" , getparam->param);return -EINVAL ;drivers/gpu/drm/nouveau/nouveau_bo.c +19
-25@@ -241,28 +241,28 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain, } nvbo->contig = !(tile_flags &NOUVEAU_GEM_TILE_NONCONTIG ); -if (!nouveau_cli_uvmm (cli) || internal) { -/* for BO noVM allocs, don't assign kinds */ -if (cli->device.info.family >=NV_DEVICE_INFO_V0_FERMI ) { - nvbo->kind = (tile_flags &0x0000ff00 ) >>8 ; -if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { -kfree (nvbo); -return ERR_PTR (-EINVAL ); - } - nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind; - }else if (cli->device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { - nvbo->kind = (tile_flags &0x00007f00 ) >>8 ; - nvbo->comp = (tile_flags &0x00030000 ) >>16 ; -if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { -kfree (nvbo); -return ERR_PTR (-EINVAL ); - } - }else { - nvbo->zeta = (tile_flags &0x00000007 ); +if (cli->device.info.family >=NV_DEVICE_INFO_V0_FERMI ) { + nvbo->kind = (tile_flags &0x0000ff00 ) >>8 ; +if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { +kfree (nvbo); +return ERR_PTR (-EINVAL ); + } + + nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind; + }else if (cli->device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { + nvbo->kind = (tile_flags &0x00007f00 ) >>8 ; + nvbo->comp = (tile_flags &0x00030000 ) >>16 ; +if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { +kfree (nvbo); +return ERR_PTR (-EINVAL ); } - nvbo->mode = tile_mode; + }else { + nvbo->zeta = (tile_flags &0x00000007 ); + } + nvbo->mode = tile_mode; +if (!nouveau_cli_uvmm (cli) || internal) {/* Determine the desirable target GPU page size for the buffer. */ for (i =0 ; i < vmm->page_nr; i++) {/* Because we cannot currently allow VMM maps to fail @@ -304,12 +304,6 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain, } nvbo->page = vmm->page[pi].shift; }else { -/* reject other tile flags when in VM mode. */ -if (tile_mode) -return ERR_PTR (-EINVAL ); -if (tile_flags & ~NOUVEAU_GEM_TILE_NONCONTIG ) -return ERR_PTR (-EINVAL ); -/* Determine the desirable target GPU page size for the buffer. */ for (i =0 ; i < vmm->page_nr; i++) {/* Because we cannot currently allow VMM maps to fail include/uapi/drm/nouveau_drm.h +7
-0@@ -68,6 +68,13 @@ extern "C" {*/ #define NOUVEAU_GETPARAM_VRAM_USED 19 +/* +* NOUVEAU_GETPARAM_HAS_VMA_TILEMODE +* +* Query whether tile mode and PTE kind are accepted with VM allocs or not. +*/ +#define NOUVEAU_GETPARAM_HAS_VMA_TILEMODE 20 +struct drm_nouveau_getparam {__u64 param;__u64 value;
Hey,
Understood. Thanks a lot and sorry for any inconvenience.
Mohamed
Quoted 146 lines · Danilo Krummrich
Hi Mohamed,
Thank you for fixing this up!
Quoted 2 lines · Mohamed Ahmed
Allows PTE kind and tile mode on BO create with
VM_BIND, and adds a GETPARAM to indicate this change. This is needed to supportIt's usually better to use imperative verb form for commit messages. No need to send a new version though.
Quoted 8 lines
modifiers in NVK and ensure correctness when dealing with the nouveau GL driver.
The userspace modifiers implementation this is for can be found here:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24795Fixes b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI")Signed-off-by Mohamed Ahmed <[email protected]>Applied to drm-misc-next-fixes.
Generally, please make sure to use
scripts/get_maintainer.plbefore sending
patches.- Danilo
Review
Quoted 7 lines
--- drivers/gpu/drm/nouveau/nouveau_abi16.c | 3 ++ drivers/gpu/drm/nouveau/nouveau_bo.c | 44 +++++++++++-------------- include/uapi/drm/nouveau_drm.h | 7 ++++ 3 files changed, 29 insertions(+), 25 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/nouveau/nouveau_abi16.cdrivers/gpu/drm/nouveau/nouveau_abi16.c nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) · line 272
Quoted 5 lines
index
80f74ee0f..47e53e17b100644drivers/gpu/drm/nouveau/nouveau_abi16.c +0
-0@@ -272,6 +272,9 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) getparam->value =(u64)ttm_resource_manager_usage(vram_mgr);
drivers/gpu/drm/nouveau/nouveau_abi16.c nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
Quoted 7 lines
drivers/gpu/drm/nouveau/nouveau_abi16.c +3
-0break ; } +case NOUVEAU_GETPARAM_HAS_VMA_TILEMODE : + getparam->value =1 ; +break ;default : NV_PRINTK(dbg, cli, "unknown parameter %lld\n",
getparam->param);Review
Quoted 2 lines
drivers/gpu/drm/nouveau/nouveau_abi16.c +0
-0return -EINVAL ;(quoted diff) +0
-0
b/drivers/gpu/drm/nouveau/nouveau_bo.cdrivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_alloc(struct nouveau_cli *cli, u64
Quoted 4 lines
index
db8cbf615..186add400100644drivers/gpu/drm/nouveau/nouveau_bo.c +0
-0@@ -241,28 +241,28 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64*size, int *align, u32 domain,
Quoted 4 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +0
-1} nvbo->contig = !(tile_flags &NOUVEAU_GEM_TILE_NONCONTIG ); -if (!nouveau_cli_uvmm (cli) || internal) {drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +0
-9-/* for BO noVM allocs, don't assign kinds */ -if (cli->device.info.family >=NV_DEVICE_INFO_V0_FERMI ) { - nvbo->kind = (tile_flags &0x0000ff00 ) >>8 ; -if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { -kfree (nvbo); -return ERR_PTR (-EINVAL ); - } - nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind; - } else if (cli->device.info.family >=
NV_DEVICE_INFO_V0_TESLA) {Quoted 21 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +13
-8- nvbo->kind = (tile_flags &0x00007f00 ) >>8 ; - nvbo->comp = (tile_flags &0x00030000 ) >>16 ; -if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { -kfree (nvbo); -return ERR_PTR (-EINVAL ); - } - }else { - nvbo->zeta = (tile_flags &0x00000007 ); +if (cli->device.info.family >=NV_DEVICE_INFO_V0_FERMI ) { + nvbo->kind = (tile_flags &0x0000ff00 ) >>8 ; +if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { +kfree (nvbo); +return ERR_PTR (-EINVAL ); + } + + nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind; + }else if (cli->device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { + nvbo->kind = (tile_flags &0x00007f00 ) >>8 ; + nvbo->comp = (tile_flags &0x00030000 ) >>16 ; +if (!nvif_mmu_kind_valid (mmu, nvbo->kind)) { +kfree (nvbo);drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +6
-1+return ERR_PTR (-EINVAL ); } - nvbo->mode = tile_mode; + }else { + nvbo->zeta = (tile_flags &0x00000007 ); + } + nvbo->mode = tile_mode; +if (!nouveau_cli_uvmm (cli) || internal) {/* Determine the desirable target GPU page size for the buffer. */
drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_alloc(struct nouveau_cli *cli, u64 · line 268
Quoted 2 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +0
-0for (i =0 ; i < vmm->page_nr; i++) {/* Because we cannot currently allow VMM maps to fail
drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_alloc(struct nouveau_cli *cli, u64
Quoted 1 line
drivers/gpu/drm/nouveau/nouveau_bo.c +0
-0@@ -304,12 +304,6 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64*size, int *align, u32 domain,
drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +0
-6} nvbo->page = vmm->page[pi].shift; }else { -/* reject other tile flags when in VM mode. */ -if (tile_mode) -return ERR_PTR (-EINVAL ); -if (tile_flags & ~NOUVEAU_GEM_TILE_NONCONTIG ) -return ERR_PTR (-EINVAL ); -/* Determine the desirable target GPU page size for the buffer. */
drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_alloc(struct nouveau_cli *cli, u64 · line 309
Quoted 2 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +0
-0for (i =0 ; i < vmm->page_nr; i++) {/* Because we cannot currently allow VMM maps to fail
Review
Quoted 1 line
(quoted diff) +0
-0
b/include/uapi/drm/nouveau_drm.hinclude/uapi/drm/nouveau_drm.h extern "C" { · line 74
Quoted 11 lines
index
cd84227f1..5402f77ee100644include/uapi/drm/nouveau_drm.h +4
-0@@ -68,6 +68,13 @@ extern "C" {*/ #define NOUVEAU_GETPARAM_VRAM_USED 19 +/* +* NOUVEAU_GETPARAM_HAS_VMA_TILEMODE +* +* Query whether tile mode and PTE kind are accepted with VM allocs or not.
Quoted 6 lines
include/uapi/drm/nouveau_drm.h +3
-0+*/ +#define NOUVEAU_GETPARAM_HAS_VMA_TILEMODE 20 +struct drm_nouveau_getparam {__u64 param;__u64 value;