dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Faith Ekstrand <faith@gfxstrand.net>
Cc: dri-devel@lists.freedesktop.org,
	"Loïc Molinari" <loic.molinari@collabora.com>,
	"Faith Ekstrand" <faith.ekstrand@collabora.com>
Subject: Re: [PATCH 2/7] drm/panthor: Add flag to map GEM object Write-Back Cacheable
Date: Fri, 22 Aug 2025 17:19:39 +0200	[thread overview]
Message-ID: <20250822171939.0fc2bbb2@fedora> (raw)
In-Reply-To: <20250822142954.902402-3-faith.ekstrand@collabora.com>

On Fri, 22 Aug 2025 10:29:11 -0400
Faith Ekstrand <faith@gfxstrand.net> wrote:

> From: Loïc Molinari <loic.molinari@collabora.com>
> 
> Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
> Signed-off-by: Faith Ekstrand <faith.ekstrand@collabora.com>
> ---
>  drivers/gpu/drm/panthor/panthor_drv.c |  7 ++++++-
>  drivers/gpu/drm/panthor/panthor_gem.c |  3 +++
>  include/uapi/drm/panthor_drm.h        | 10 ++++++++++
>  3 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index 1116f2d2826e..06ae6a2aeb16 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> @@ -899,7 +899,8 @@ static int panthor_ioctl_vm_destroy(struct drm_device *ddev, void *data,
>  	return panthor_vm_pool_destroy_vm(pfile->vms, args->id);
>  }
>  
> -#define PANTHOR_BO_FLAGS		DRM_PANTHOR_BO_NO_MMAP
> +#define PANTHOR_BO_FLAGS		(DRM_PANTHOR_BO_NO_MMAP | \
> +					 DRM_PANTHOR_BO_WB_MMAP)
>  
>  static int panthor_ioctl_bo_create(struct drm_device *ddev, void *data,
>  				   struct drm_file *file)
> @@ -918,6 +919,10 @@ static int panthor_ioctl_bo_create(struct drm_device *ddev, void *data,
>  		goto out_dev_exit;
>  	}
>  
> +	if ((args->flags & DRM_PANTHOR_BO_NO_MMAP) &&
> +	    (args->flags & DRM_PANTHOR_BO_WB_MMAP))
> +		return -EINVAL;

I know it's obvious, but I'd still add a comment explaining why WB_MMAP
can't be set if NO_MMAP is.

> +
>  	if (args->exclusive_vm_id) {
>  		vm = panthor_vm_pool_get_vm(pfile->vms, args->exclusive_vm_id);
>  		if (!vm) {
> diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
> index a123bc740ba1..530bad12d545 100644
> --- a/drivers/gpu/drm/panthor/panthor_gem.c
> +++ b/drivers/gpu/drm/panthor/panthor_gem.c
> @@ -283,6 +283,9 @@ panthor_gem_create_with_handle(struct drm_file *file,
>  	bo = to_panthor_bo(&shmem->base);
>  	bo->flags = flags;
>  
> +	if (flags & DRM_PANTHOR_BO_WB_MMAP)
> +		shmem->map_wc = false;
> +
>  	if (exclusive_vm) {
>  		bo->exclusive_vm_root_gem = panthor_vm_root_gem(exclusive_vm);
>  		drm_gem_object_get(bo->exclusive_vm_root_gem);
> diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h
> index e1f43deb7eca..bf47369c0220 100644
> --- a/include/uapi/drm/panthor_drm.h
> +++ b/include/uapi/drm/panthor_drm.h
> @@ -635,6 +635,16 @@ struct drm_panthor_vm_get_state {
>  enum drm_panthor_bo_flags {
>  	/** @DRM_PANTHOR_BO_NO_MMAP: The buffer object will never be CPU-mapped in userspace. */
>  	DRM_PANTHOR_BO_NO_MMAP = (1 << 0),
> +
> +	/**
> +	 *@DRM_PANTHOR_BO_WB_MMAP: Force "Write-Back Cacheable" CPU mapping.

          ^ missing space after '*'

> +	 *
> +	 * CPU map the buffer object in userspace by forcing the "Write-Back
> +	 * Cacheable" cacheability attribute. The mapping otherwise uses the
> +	 * "Non-Cacheable" attribute if the ACE-Lite coherency protocol isn't
> +	 * supported by the GPU.
> +	 */
> +	DRM_PANTHOR_BO_WB_MMAP = (1 << 1),

We probably want to expose the coherency caps before introducing this
flag (through some DEV_QUERY argument), so the UMD knows when it can
skip cache maintenance operations.

>  };
>  
>  /**


  reply	other threads:[~2025-08-22 15:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22 14:29 [PATCH 0/7] panfrost,panthor: Cached maps and explicit flushing Faith Ekstrand
2025-08-22 14:29 ` [PATCH 1/7] drm/shmem: Add a drm_gem_shmem_sync_mmap() helper Faith Ekstrand
2025-08-22 15:13   ` Boris Brezillon
2025-08-23  5:36   ` kernel test robot
2025-09-01  8:18   ` Adrian Larumbe
2025-09-01  8:47     ` Boris Brezillon
2025-08-22 14:29 ` [PATCH 2/7] drm/panthor: Add flag to map GEM object Write-Back Cacheable Faith Ekstrand
2025-08-22 15:19   ` Boris Brezillon [this message]
2025-08-22 14:29 ` [PATCH 3/7] drm/panthor: Add a PANTHOR_BO_SYNC ioctl Faith Ekstrand
2025-08-22 15:28   ` Boris Brezillon
2025-08-22 14:29 ` [PATCH 4/7] drm/panthor: Bump the driver version to 1.6 Faith Ekstrand
2025-09-01  8:21   ` Adrian Larumbe
2025-08-22 14:29 ` [PATCH 5/7] drm/panfrost: Add flag to map GEM object Write-Back Cacheable Faith Ekstrand
2025-09-01  8:24   ` Adrian Larumbe
2025-08-22 14:29 ` [PATCH 6/7] drm/panfrost: Add a PANFROST_SYNC_BO ioctl Faith Ekstrand
2025-08-24  4:01   ` kernel test robot
2025-08-22 14:29 ` [PATCH 7/7] drm/panfrost: Bump the driver version to 1.5 Faith Ekstrand
2025-08-22 15:05 ` [PATCH 0/7] panfrost,panthor: Cached maps and explicit flushing Boris Brezillon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250822171939.0fc2bbb2@fedora \
    --to=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=faith.ekstrand@collabora.com \
    --cc=faith@gfxstrand.net \
    --cc=loic.molinari@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox