<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 8, 2024 at 6:06 PM Mohamed Ahmed <<a href="mailto:mohamedahmedegypt2001@gmail.com">mohamedahmedegypt2001@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Allows PTE kind and tile mode on BO create with VM_BIND,<br>
and adds a GETPARAM to indicate this change. This is needed to support<br>
modifiers in NVK and ensure correctness when dealing with the nouveau<br>
GL driver.<br>
<br>
The userspace modifiers implementation this is for can be found here:<br>
<a href="https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28843" rel="noreferrer" target="_blank">https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28843</a><br>
<br>
Fixes: b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI")<br>
Signed-off-by: Mohamed Ahmed <<a href="mailto:mohamedahmedegypt2001@gmail.com" target="_blank">mohamedahmedegypt2001@gmail.com</a>><br>
---<br>
drivers/gpu/drm/nouveau/nouveau_abi16.c | 3 ++<br>
drivers/gpu/drm/nouveau/nouveau_bo.c | 45 +++++++++++--------------<br>
include/uapi/drm/nouveau_drm.h | 7 ++++<br>
3 files changed, 30 insertions(+), 25 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c<br>
index 80f74ee0f..47e53e17b 100644<br>
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c<br>
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c<br>
@@ -272,6 +272,9 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)<br>
getparam->value = (u64)ttm_resource_manager_usage(vram_mgr);<br>
break;<br>
}<br>
+ case NOUVEAU_GETPARAM_HAS_VMA_TILEMODE:<br>
+ getparam->value = 1;<br>
+ break;<br>
default:<br>
NV_PRINTK(dbg, cli, "unknown parameter %lld\n", getparam->param);<br>
return -EINVAL;<br>
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c<br>
index db8cbf615..583c962ef 100644<br>
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c<br>
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c<br>
@@ -241,28 +241,29 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,<br>
}<br>
<br>
nvbo->contig = !(tile_flags & NOUVEAU_GEM_TILE_NONCONTIG);<br>
- if (!nouveau_cli_uvmm(cli) || internal) {<br>
- /* for BO noVM allocs, don't assign kinds */<br>
- if (cli->device.info.family >= NV_DEVICE_INFO_V0_FERMI) {<br>
- nvbo->kind = (tile_flags & 0x0000ff00) >> 8;<br>
- if (!nvif_mmu_kind_valid(mmu, nvbo->kind)) {<br>
- kfree(nvbo);<br>
- return ERR_PTR(-EINVAL);<br>
- }<br>
<br>
- nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind;<br>
- } else if (cli->device.info.family >= NV_DEVICE_INFO_V0_TESLA) {<br>
- nvbo->kind = (tile_flags & 0x00007f00) >> 8;<br>
- nvbo->comp = (tile_flags & 0x00030000) >> 16;<br>
- if (!nvif_mmu_kind_valid(mmu, nvbo->kind)) {<br>
- kfree(nvbo);<br>
- return ERR_PTR(-EINVAL);<br>
- }<br>
- } else {<br>
- nvbo->zeta = (tile_flags & 0x00000007);<br>
+ /* for BO allocs, don't assign kinds */<br></blockquote><div><br></div><div>I think this comment is stale. We're now assigning them in both cases.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ if (cli->device.info.family >= NV_DEVICE_INFO_V0_FERMI) {<br>
+ nvbo->kind = (tile_flags & 0x0000ff00) >> 8;<br>
+ if (!nvif_mmu_kind_valid(mmu, nvbo->kind)) {<br>
+ kfree(nvbo);<br>
+ return ERR_PTR(-EINVAL);<br>
+ }<br>
+<br>
+ nvbo->comp = mmu->kind[nvbo->kind] != nvbo->kind;<br>
+ } else if (cli->device.info.family >= NV_DEVICE_INFO_V0_TESLA) {<br>
+ nvbo->kind = (tile_flags & 0x00007f00) >> 8;<br>
+ nvbo->comp = (tile_flags & 0x00030000) >> 16;<br>
+ if (!nvif_mmu_kind_valid(mmu, nvbo->kind)) {<br>
+ kfree(nvbo);<br>
+ return ERR_PTR(-EINVAL);<br>
}<br>
- nvbo->mode = tile_mode;<br>
+ } else {<br>
+ nvbo->zeta = (tile_flags & 0x00000007);<br>
+ }<br>
+ nvbo->mode = tile_mode;<br>
<br>
+ if (!nouveau_cli_uvmm(cli) || internal) {<br>
/* Determine the desirable target GPU page size for the buffer. */<br>
for (i = 0; i < vmm->page_nr; i++) {<br>
/* Because we cannot currently allow VMM maps to fail<br>
@@ -304,12 +305,6 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,<br>
}<br>
nvbo->page = vmm->page[pi].shift;<br>
} else {<br>
- /* reject other tile flags when in VM mode. */<br>
- if (tile_mode)<br>
- return ERR_PTR(-EINVAL);<br>
- if (tile_flags & ~NOUVEAU_GEM_TILE_NONCONTIG)<br>
- return ERR_PTR(-EINVAL);<br>
-<br>
/* Determine the desirable target GPU page size for the buffer. */<br>
for (i = 0; i < vmm->page_nr; i++) {<br>
/* Because we cannot currently allow VMM maps to fail<br>
diff --git a/include/uapi/drm/nouveau_drm.h b/include/uapi/drm/nouveau_drm.h<br>
index cd84227f1..5402f77ee 100644<br>
--- a/include/uapi/drm/nouveau_drm.h<br>
+++ b/include/uapi/drm/nouveau_drm.h<br>
@@ -68,6 +68,13 @@ extern "C" {<br>
*/<br>
#define NOUVEAU_GETPARAM_VRAM_USED 19<br>
<br>
+/*<br>
+ * NOUVEAU_GETPARAM_HAS_VMA_TILEMODE<br>
+ *<br>
+ * Query whether tile mode and PTE kind are accepted with VM allocs or not.<br>
+ */<br>
+#define NOUVEAU_GETPARAM_HAS_VMA_TILEMODE 20<br>
+<br>
struct drm_nouveau_getparam {<br>
__u64 param;<br>
__u64 value;<br>
-- <br>
2.44.0<br>
<br>
</blockquote></div></div>