* [RFC] drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations
@ 2024-04-27 10:55 Mohamed Ahmed
2024-04-28 20:22 ` Dave Airlie
0 siblings, 1 reply; 2+ messages in thread
From: Mohamed Ahmed @ 2024-04-27 10:55 UTC (permalink / raw)
To: dri-devel; +Cc: airlied, Mohamed Ahmed
Allows PTE kind and tile mode on BO create with VM_BIND. This is needed to support modifiers in NVK and ensure correctness when dealing with the nouveau GL driver.
Signed-off-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
---
drivers/gpu/drm/nouveau/nouveau_bo.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index db8cbf615..0da0b5286 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -304,11 +304,25 @@ 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);
+ 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);
+ }
+ nvbo->mode = tile_mode;
/* Determine the desirable target GPU page size for the buffer. */
for (i = 0; i < vmm->page_nr; i++) {
--
2.44.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [RFC] drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations
2024-04-27 10:55 [RFC] drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations Mohamed Ahmed
@ 2024-04-28 20:22 ` Dave Airlie
0 siblings, 0 replies; 2+ messages in thread
From: Dave Airlie @ 2024-04-28 20:22 UTC (permalink / raw)
To: Mohamed Ahmed; +Cc: dri-devel, airlied
This looks like a good start, though I wonder can we just refactor out
the common code from the vma and non-vma paths easier.
Also I wonder should we add a new GETPARAM so userspace can know this
change is available.
Of course we also need a pointer to the userspace implementation to
move forward.
Thanks,
Dave.
On Sun, 28 Apr 2024 at 19:32, Mohamed Ahmed
<mohamedahmedegypt2001@gmail.com> wrote:
>
> Allows PTE kind and tile mode on BO create with VM_BIND. This is needed to support modifiers in NVK and ensure correctness when dealing with the nouveau GL driver.
>
> Signed-off-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
> ---
> drivers/gpu/drm/nouveau/nouveau_bo.c | 24 +++++++++++++++++++-----
> 1 file changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index db8cbf615..0da0b5286 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -304,11 +304,25 @@ 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);
> + 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);
> + }
> + nvbo->mode = tile_mode;
>
> /* Determine the desirable target GPU page size for the buffer. */
> for (i = 0; i < vmm->page_nr; i++) {
> --
> 2.44.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-28 20:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-27 10:55 [RFC] drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations Mohamed Ahmed
2024-04-28 20:22 ` Dave Airlie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.