nouveau.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v4] drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations
       [not found] <20240509204352.7597-1-mohamedahmedegypt2001@gmail.com>
@ 2024-05-09 20:53 ` Faith Ekstrand
  2024-05-13 20:28 ` Danilo Krummrich
  1 sibling, 0 replies; 2+ messages in thread
From: Faith Ekstrand @ 2024-05-09 20:53 UTC (permalink / raw)
  To: Mohamed Ahmed; +Cc: dri-devel, airlied, nouveau

[-- Attachment #1: Type: text/plain, Size: 5616 bytes --]

On Thu, May 9, 2024 at 3:44 PM Mohamed Ahmed <
mohamedahmedegypt2001@gmail.com> wrote:

> 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
>
> Fixes: b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI")
> Signed-off-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
>

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>


> ---
>  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(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c
> b/drivers/gpu/drm/nouveau/nouveau_abi16.c
> index 80f74ee0f..47e53e17b 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
> @@ -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;
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c
> b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index db8cbf615..186add400 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -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
> diff --git a/include/uapi/drm/nouveau_drm.h
> b/include/uapi/drm/nouveau_drm.h
> index cd84227f1..5402f77ee 100644
> --- a/include/uapi/drm/nouveau_drm.h
> +++ b/include/uapi/drm/nouveau_drm.h
> @@ -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;
> --
> 2.44.0
>
>

[-- Attachment #2: Type: text/html, Size: 7314 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations
       [not found] <20240509204352.7597-1-mohamedahmedegypt2001@gmail.com>
  2024-05-09 20:53 ` [PATCH v4] drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations Faith Ekstrand
@ 2024-05-13 20:28 ` Danilo Krummrich
  1 sibling, 0 replies; 2+ messages in thread
From: Danilo Krummrich @ 2024-05-13 20:28 UTC (permalink / raw)
  To: Mohamed Ahmed, airlied, Faith Ekstrand; +Cc: nouveau, dri-devel

Hi Mohamed,

Thank you for fixing this up!

On 5/9/24 22:43, Mohamed Ahmed wrote:
> 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.

> 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: b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI")
> Signed-off-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>

Applied to drm-misc-next-fixes.

Generally, please make sure to use scripts/get_maintainer.pl before sending
patches.

- Danilo

> ---
>   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(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
> index 80f74ee0f..47e53e17b 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
> @@ -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;
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index db8cbf615..186add400 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -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
> diff --git a/include/uapi/drm/nouveau_drm.h b/include/uapi/drm/nouveau_drm.h
> index cd84227f1..5402f77ee 100644
> --- a/include/uapi/drm/nouveau_drm.h
> +++ b/include/uapi/drm/nouveau_drm.h
> @@ -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;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-13 20:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20240509204352.7597-1-mohamedahmedegypt2001@gmail.com>
2024-05-09 20:53 ` [PATCH v4] drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations Faith Ekstrand
2024-05-13 20:28 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).