Skip to content

Commit ca5ad9c

Browse files
mohamexietygregkh
authored andcommitted
drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations
[ Upstream commit 959314c ] Allow PTE kind and tile mode on BO create with VM_BIND, and add 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 Fixes: b88baab ("drm/nouveau: implement new VM_BIND uAPI") Signed-off-by: Mohamed Ahmed <[email protected]> Reviewed-by: Faith Ekstrand <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 831af90 commit ca5ad9c

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

drivers/gpu/drm/nouveau/nouveau_abi16.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
272272
getparam->value = (u64)ttm_resource_manager_usage(vram_mgr);
273273
break;
274274
}
275+
case NOUVEAU_GETPARAM_HAS_VMA_TILEMODE:
276+
getparam->value = 1;
277+
break;
275278
default:
276279
NV_PRINTK(dbg, cli, "unknown parameter %lld\n", getparam->param);
277280
return -EINVAL;

drivers/gpu/drm/nouveau/nouveau_bo.c

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -241,28 +241,28 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
241241
}
242242

243243
nvbo->contig = !(tile_flags & NOUVEAU_GEM_TILE_NONCONTIG);
244-
if (!nouveau_cli_uvmm(cli) || internal) {
245-
/* for BO noVM allocs, don't assign kinds */
246-
if (cli->device.info.family >= NV_DEVICE_INFO_V0_FERMI) {
247-
nvbo->kind = (tile_flags & 0x0000ff00) >> 8;
248-
if (!nvif_mmu_kind_valid(mmu, nvbo->kind)) {
249-
kfree(nvbo);
250-
return ERR_PTR(-EINVAL);
251-
}
252244

253-
nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind;
254-
} else if (cli->device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
255-
nvbo->kind = (tile_flags & 0x00007f00) >> 8;
256-
nvbo->comp = (tile_flags & 0x00030000) >> 16;
257-
if (!nvif_mmu_kind_valid(mmu, nvbo->kind)) {
258-
kfree(nvbo);
259-
return ERR_PTR(-EINVAL);
260-
}
261-
} else {
262-
nvbo->zeta = (tile_flags & 0x00000007);
245+
if (cli->device.info.family >= NV_DEVICE_INFO_V0_FERMI) {
246+
nvbo->kind = (tile_flags & 0x0000ff00) >> 8;
247+
if (!nvif_mmu_kind_valid(mmu, nvbo->kind)) {
248+
kfree(nvbo);
249+
return ERR_PTR(-EINVAL);
250+
}
251+
252+
nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind;
253+
} else if (cli->device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
254+
nvbo->kind = (tile_flags & 0x00007f00) >> 8;
255+
nvbo->comp = (tile_flags & 0x00030000) >> 16;
256+
if (!nvif_mmu_kind_valid(mmu, nvbo->kind)) {
257+
kfree(nvbo);
258+
return ERR_PTR(-EINVAL);
263259
}
264-
nvbo->mode = tile_mode;
260+
} else {
261+
nvbo->zeta = (tile_flags & 0x00000007);
262+
}
263+
nvbo->mode = tile_mode;
265264

265+
if (!nouveau_cli_uvmm(cli) || internal) {
266266
/* Determine the desirable target GPU page size for the buffer. */
267267
for (i = 0; i < vmm->page_nr; i++) {
268268
/* 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,
304304
}
305305
nvbo->page = vmm->page[pi].shift;
306306
} else {
307-
/* reject other tile flags when in VM mode. */
308-
if (tile_mode)
309-
return ERR_PTR(-EINVAL);
310-
if (tile_flags & ~NOUVEAU_GEM_TILE_NONCONTIG)
311-
return ERR_PTR(-EINVAL);
312-
313307
/* Determine the desirable target GPU page size for the buffer. */
314308
for (i = 0; i < vmm->page_nr; i++) {
315309
/* Because we cannot currently allow VMM maps to fail

include/uapi/drm/nouveau_drm.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ extern "C" {
6868
*/
6969
#define NOUVEAU_GETPARAM_VRAM_USED 19
7070

71+
/*
72+
* NOUVEAU_GETPARAM_HAS_VMA_TILEMODE
73+
*
74+
* Query whether tile mode and PTE kind are accepted with VM allocs or not.
75+
*/
76+
#define NOUVEAU_GETPARAM_HAS_VMA_TILEMODE 20
77+
7178
struct drm_nouveau_getparam {
7279
__u64 param;
7380
__u64 value;

0 commit comments

Comments
 (0)