AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Akash Goel <akash.goel@arm.com>
Cc: "Steven Price" <steven.price@arm.com>,
	dri-devel@lists.freedesktop.org,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Faith Ekstrand" <faith.ekstrand@collabora.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Mikko Perttunen" <mperttunen@nvidia.com>,
	"Melissa Wen" <mwen@igalia.com>,
	"Maíra Canal" <mcanal@igalia.com>,
	"Lucas De Marchi" <lucas.demarchi@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Frank Binns" <frank.binns@imgtec.com>,
	"Matt Coster" <matt.coster@imgtec.com>,
	"Rob Clark" <robin.clark@oss.qualcomm.com>,
	"Dmitry Baryshkov" <lumag@kernel.org>,
	"Abhinav Kumar" <abhinav.kumar@linux.dev>,
	"Jessica Zhang" <jessica.zhang@oss.qualcomm.com>,
	"Sean Paul" <sean@poorly.run>,
	"Marijn Suijten" <marijn.suijten@somainline.org>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	amd-gfx@lists.freedesktop.org, kernel@collabora.com
Subject: Re: [PATCH v5 07/16] drm/panthor: Add a PANTHOR_BO_SYNC ioctl
Date: Tue, 4 Nov 2025 08:41:39 +0100	[thread overview]
Message-ID: <20251104084139.728f0f00@fedora> (raw)
In-Reply-To: <a9705c1e-2377-4f50-88ee-553bbf189d6d@arm.com>

On Mon, 3 Nov 2025 20:42:05 +0000
Akash Goel <akash.goel@arm.com> wrote:

> On 10/30/25 14:05, Boris Brezillon wrote:
> > This will be used by the UMD to synchronize CPU-cached mappings when
> > the UMD can't do it directly (no usermode cache maintenance instruction
> > on Arm32).
> >
> > v2:
> > - Change the flags so they better match the drm_gem_shmem_sync()
> >    semantics
> >
> > v3:
> > - Add Steve's R-b
> >
> > v4:
> > - No changes
> >
> > v5:
> > - Drop Steve's R-b (the semantics changes call for a new review)
> >
> > Signed-off-by: Faith Ekstrand <faith.ekstrand@collabora.com>
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > ---
> >   drivers/gpu/drm/panthor/panthor_drv.c | 42 +++++++++++++++++++++-
> >   drivers/gpu/drm/panthor/panthor_gem.c | 21 +++++++++++
> >   drivers/gpu/drm/panthor/panthor_gem.h |  3 ++
> >   include/uapi/drm/panthor_drm.h        | 52 +++++++++++++++++++++++++++
> >   4 files changed, 117 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> > index 99a4534c0074..cad5c4270b04 100644
> > --- a/drivers/gpu/drm/panthor/panthor_drv.c
> > +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> > @@ -175,7 +175,8 @@ panthor_get_uobj_array(const struct drm_panthor_obj_array *in, u32 min_stride,
> >                PANTHOR_UOBJ_DECL(struct drm_panthor_sync_op, timeline_value), \
> >                PANTHOR_UOBJ_DECL(struct drm_panthor_queue_submit, syncs), \
> >                PANTHOR_UOBJ_DECL(struct drm_panthor_queue_create, ringbuf_size), \
> > -              PANTHOR_UOBJ_DECL(struct drm_panthor_vm_bind_op, syncs))
> > +              PANTHOR_UOBJ_DECL(struct drm_panthor_vm_bind_op, syncs), \
> > +              PANTHOR_UOBJ_DECL(struct drm_panthor_bo_sync_op, size))
> >
> >   /**
> >    * PANTHOR_UOBJ_SET() - Copy a kernel object to a user object.
> > @@ -1394,6 +1395,44 @@ static int panthor_ioctl_set_user_mmio_offset(struct drm_device *ddev,
> >       return 0;
> >   }
> >
> > +#define PANTHOR_BO_SYNC_OP_FLAGS                                      \
> > +     (DRM_PANTHOR_BO_SYNC_FOR_DEV | DRM_PANTHOR_BO_SYNC_FOR_READ | \
> > +      DRM_PANTHOR_BO_SYNC_FOR_WRITE)
> > +  
> 
> 
> Sorry, couldn't find where PANTHOR_BO_SYNC_OP_FLAGS and
> DRM_PANTHOR_BO_SYNC_FOR_xxx macros get used.

That's a leftover from v4, it's not supposed to be there. I'll drop
that.

> 
> 
> 
> > +static int panthor_ioctl_bo_sync(struct drm_device *ddev, void *data,
> > +                              struct drm_file *file)
> > +{
> > +     struct drm_panthor_bo_sync *args = data;
> > +     struct drm_panthor_bo_sync_op *ops;
> > +     struct drm_gem_object *obj;
> > +     int ret = 0;
> > +
> > +     ret = PANTHOR_UOBJ_GET_ARRAY(ops, &args->ops);
> > +     if (ret)
> > +             return ret;
> > +
> > +     for (u32 i = 0; i < args->ops.count; i++) {
> > +             obj = drm_gem_object_lookup(file, ops[i].handle);
> > +             if (!obj) {
> > +                     ret = -ENOENT;
> > +                     goto err_ops;
> > +             }
> > +
> > +             ret = panthor_gem_sync(obj, ops[i].type, ops[i].offset,
> > +                                    ops[i].size);
> > +
> > +             drm_gem_object_put(obj);
> > +
> > +             if (ret)
> > +                     goto err_ops;
> > +     }
> > +
> > +err_ops:
> > +     kvfree(ops);
> > +
> > +     return ret;
> > +}
> > +
> >   static int
> >   panthor_open(struct drm_device *ddev, struct drm_file *file)
> >   {
> > @@ -1468,6 +1507,7 @@ static const struct drm_ioctl_desc panthor_drm_driver_ioctls[] = {
> >       PANTHOR_IOCTL(GROUP_SUBMIT, group_submit, DRM_RENDER_ALLOW),
> >       PANTHOR_IOCTL(BO_SET_LABEL, bo_set_label, DRM_RENDER_ALLOW),
> >       PANTHOR_IOCTL(SET_USER_MMIO_OFFSET, set_user_mmio_offset, DRM_RENDER_ALLOW),
> > +     PANTHOR_IOCTL(BO_SYNC, bo_sync, DRM_RENDER_ALLOW),
> >   };
> >
> >   static int panthor_mmap(struct file *filp, struct vm_area_struct *vma)
> > diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
> > index 160692e45f44..1b1e98c61b8c 100644
> > --- a/drivers/gpu/drm/panthor/panthor_gem.c
> > +++ b/drivers/gpu/drm/panthor/panthor_gem.c
> > @@ -357,6 +357,27 @@ panthor_gem_kernel_bo_set_label(struct panthor_kernel_bo *bo, const char *label)
> >       panthor_gem_bo_set_label(bo->obj, str);
> >   }
> >
> > +int
> > +panthor_gem_sync(struct drm_gem_object *obj, u32 type,
> > +              u64 offset, u64 size)
> > +{
> > +     enum drm_gem_shmem_sync_type shmem_sync_type;
> > +     struct panthor_gem_object *bo = to_panthor_bo(obj);
> > +
> > +     switch (type) {
> > +     case DRM_PANTHOR_BO_SYNC_CPU_CACHE_FLUSH:
> > +             shmem_sync_type = DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH;
> > +             break;
> > +     case DRM_PANTHOR_BO_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE:
> > +             shmem_sync_type = DRM_GEM_SHMEM_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE;
> > +             break;
> > +     default:
> > +             return -EINVAL;
> > +     }
> > +
> > +     return drm_gem_shmem_sync(&bo->base, offset, size, shmem_sync_type);
> > +}
> > +
> >   #ifdef CONFIG_DEBUG_FS
> >   struct gem_size_totals {
> >       size_t size;
> > diff --git a/drivers/gpu/drm/panthor/panthor_gem.h b/drivers/gpu/drm/panthor/panthor_gem.h
> > index 528088839468..8705c492c5b6 100644
> > --- a/drivers/gpu/drm/panthor/panthor_gem.h
> > +++ b/drivers/gpu/drm/panthor/panthor_gem.h
> > @@ -147,6 +147,9 @@ panthor_gem_create_with_handle(struct drm_file *file,
> >   void panthor_gem_bo_set_label(struct drm_gem_object *obj, const char *label);
> >   void panthor_gem_kernel_bo_set_label(struct panthor_kernel_bo *bo, const char *label);
> >
> > +int panthor_gem_sync(struct drm_gem_object *obj,
> > +                  u32 type, u64 offset, u64 size);
> > +
> >   const struct dma_buf_ops *
> >   panthor_gem_prime_get_dma_buf_ops(struct drm_device *dev);
> >
> > diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h
> > index f0f637e0631d..bb12760abe99 100644
> > --- a/include/uapi/drm/panthor_drm.h
> > +++ b/include/uapi/drm/panthor_drm.h
> > @@ -144,6 +144,9 @@ enum drm_panthor_ioctl_id {
> >        * pgoff_t size.
> >        */
> >       DRM_PANTHOR_SET_USER_MMIO_OFFSET,
> > +
> > +     /** @DRM_PANTHOR_BO_SYNC: Sync BO data to/from the device */
> > +     DRM_PANTHOR_BO_SYNC,
> >   };
> >
> >   /**
> > @@ -1073,6 +1076,53 @@ struct drm_panthor_set_user_mmio_offset {
> >       __u64 offset;
> >   };
> >
> > +/**
> > + * enum drm_panthor_bo_sync_op_type - BO sync type
> > + */
> > +enum drm_panthor_bo_sync_op_type {
> > +     /** @DRM_PANTHOR_BO_SYNC_CPU_CACHE_FLUSH: Flush CPU caches. */
> > +     DRM_PANTHOR_BO_SYNC_CPU_CACHE_FLUSH = 0,
> > +
> > +     /** @DRM_PANTHOR_BO_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE: Flush and invalidate CPU caches. */
> > +     DRM_PANTHOR_BO_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE = 1,
> > +};
> > +
> > +/**
> > + * struct drm_panthor_bo_sync_op - BO map sync op
> > + */
> > +struct drm_panthor_bo_sync_op {
> > +     /** @handle: Handle of the buffer object to sync. */
> > +     __u32 handle;
> > +
> > +     /** @type: Type of operation. */
> > +     __u32 type;
> > +
> > +     /**
> > +      * @offset: Offset into the BO at which the sync range starts.
> > +      *
> > +      * This will be rounded down to the nearest cache line as needed.
> > +      */
> > +     __u64 offset;
> > +
> > +     /**
> > +      * @size: Size of the range to sync
> > +      *
> > +      * @size + @offset will be rounded up to the nearest cache line as
> > +      * needed.
> > +      */
> > +     __u64 size;
> > +};
> > +
> > +/**
> > + * struct drm_panthor_bo_sync - BO map sync request
> > + */
> > +struct drm_panthor_bo_sync {
> > +     /**
> > +      * @ops: Array of struct drm_panthor_bo_sync_op sync operations.
> > +      */
> > +     struct drm_panthor_obj_array ops;
> > +};
> > +
> >   /**
> >    * DRM_IOCTL_PANTHOR() - Build a Panthor IOCTL number
> >    * @__access: Access type. Must be R, W or RW.
> > @@ -1119,6 +1169,8 @@ enum {
> >               DRM_IOCTL_PANTHOR(WR, BO_SET_LABEL, bo_set_label),
> >       DRM_IOCTL_PANTHOR_SET_USER_MMIO_OFFSET =
> >               DRM_IOCTL_PANTHOR(WR, SET_USER_MMIO_OFFSET, set_user_mmio_offset),
> > +     DRM_IOCTL_PANTHOR_BO_SYNC =
> > +             DRM_IOCTL_PANTHOR(WR, BO_SYNC, bo_sync),
> >   };
> >
> >   #if defined(__cplusplus)  
> IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


  reply	other threads:[~2025-11-04  7:41 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-30 14:05 [PATCH v5 00/16] drm/panfrost, panthor: Cached maps and explicit flushing Boris Brezillon
2025-10-30 14:05 ` [PATCH v5 01/16] drm/prime: Simplify life of drivers needing custom dma_buf_ops Boris Brezillon
2025-10-30 14:25   ` Christian König
2025-10-30 14:35     ` Boris Brezillon
2025-10-30 14:05 ` [PATCH v5 02/16] drm/shmem: Provide a generic {begin, end}_cpu_access() implementation Boris Brezillon
2025-10-30 14:31   ` [PATCH v5 02/16] drm/shmem: Provide a generic {begin,end}_cpu_access() implementation Christian König
2025-11-04  8:08     ` Boris Brezillon
2025-11-03 20:34   ` [PATCH v5 02/16] drm/shmem: Provide a generic {begin, end}_cpu_access() implementation Akash Goel
2025-11-04  7:42     ` Boris Brezillon
2025-10-30 14:05 ` [PATCH v5 03/16] drm/shmem: Add a drm_gem_shmem_sync() helper Boris Brezillon
2025-11-14 15:02   ` Steven Price
2025-10-30 14:05 ` [PATCH v5 04/16] drm/panthor: Provide a custom dma_buf implementation Boris Brezillon
2025-11-14 15:02   ` Steven Price
2025-10-30 14:05 ` [PATCH v5 05/16] drm/panthor: Fix panthor_gpu_coherency_set() Boris Brezillon
2025-10-30 14:05 ` [PATCH v5 06/16] drm/panthor: Expose the selected coherency protocol to the UMD Boris Brezillon
2025-10-30 14:05 ` [PATCH v5 07/16] drm/panthor: Add a PANTHOR_BO_SYNC ioctl Boris Brezillon
2025-10-31  7:25   ` Marcin Ślusarz
2025-11-03 20:42   ` Akash Goel
2025-11-04  7:41     ` Boris Brezillon [this message]
2025-10-30 14:05 ` [PATCH v5 08/16] drm/panthor: Add an ioctl to query BO flags Boris Brezillon
2025-10-30 14:05 ` [PATCH v5 09/16] drm/panthor: Add flag to map GEM object Write-Back Cacheable Boris Brezillon
2025-11-03 16:43   ` Akash Goel
2025-11-03 17:13     ` Boris Brezillon
2025-10-30 14:05 ` [PATCH v5 10/16] drm/panthor: Bump the driver version to 1.6 Boris Brezillon
2025-10-30 14:05 ` [PATCH v5 11/16] drm/panfrost: Provide a custom dma_buf implementation Boris Brezillon
2025-11-14 16:17   ` Steven Price
2025-10-30 14:05 ` [PATCH v5 12/16] drm/panfrost: Expose the selected coherency protocol to the UMD Boris Brezillon
2025-11-14 16:19   ` Steven Price
2025-10-30 14:05 ` [PATCH v5 13/16] drm/panfrost: Add a PANFROST_SYNC_BO ioctl Boris Brezillon
2025-10-31  7:08   ` Marcin Ślusarz
2025-10-31  8:49     ` Boris Brezillon
2025-10-30 14:05 ` [PATCH v5 14/16] drm/panfrost: Add an ioctl to query BO flags Boris Brezillon
2025-10-30 14:05 ` [PATCH v5 15/16] drm/panfrost: Add flag to map GEM object Write-Back Cacheable Boris Brezillon
2025-11-14 16:22   ` Steven Price
2025-10-30 14:05 ` [PATCH v5 16/16] drm/panfrost: Bump the driver version to 1.6 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=20251104084139.728f0f00@fedora \
    --to=boris.brezillon@collabora.com \
    --cc=abhinav.kumar@linux.dev \
    --cc=airlied@gmail.com \
    --cc=akash.goel@arm.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=faith.ekstrand@collabora.com \
    --cc=frank.binns@imgtec.com \
    --cc=jessica.zhang@oss.qualcomm.com \
    --cc=kernel@collabora.com \
    --cc=lucas.demarchi@intel.com \
    --cc=lumag@kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=marijn.suijten@somainline.org \
    --cc=matt.coster@imgtec.com \
    --cc=mcanal@igalia.com \
    --cc=mperttunen@nvidia.com \
    --cc=mripard@kernel.org \
    --cc=mwen@igalia.com \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=thierry.reding@gmail.com \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tzimmermann@suse.de \
    /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