From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
Cc: "Murthy, Arun R" <arun.r.murthy@intel.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v3 2/5] drm/plane: Expose function to create format/modifier blob
Date: Mon, 27 Jan 2025 21:13:57 +0200 [thread overview]
Message-ID: <Z5fa9RyRoZ0CXQjK@intel.com> (raw)
In-Reply-To: <SJ1PR11MB6129F369898E2962C12D6024B9EC2@SJ1PR11MB6129.namprd11.prod.outlook.com>
On Mon, Jan 27, 2025 at 07:25:31AM +0000, Borah, Chaitanya Kumar wrote:
> Hello Ville,
>
> > -----Original Message-----
> > From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Murthy,
> > Arun R
> > Sent: Saturday, January 25, 2025 12:25 PM
> > To: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > Cc: dri-devel@lists.freedesktop.org; intel-gfx@lists.freedesktop.org; intel-
> > xe@lists.freedesktop.org
> > Subject: RE: [PATCH v3 2/5] drm/plane: Expose function to create
> > format/modifier blob
> >
> > > On Thu, Jan 23, 2025 at 07:47:14AM +0000, Murthy, Arun R wrote:
> > > > > > On Wed, Jan 08, 2025 at 11:09:00AM +0530, Arun R Murthy wrote:
> > > > > > > Expose drm plane function to create formats/modifiers blob.
> > > > > > > This function can be used to expose list of supported
> > > > > > > formats/modifiers for sync/async flips.
> > > > > > >
> > > > > > > Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
> > > > > > > ---
> > > > > > > drivers/gpu/drm/drm_plane.c | 44
> > > > > > > +++++++++++++++++++++++++++++-------
> > > > > > --------
> > > > > > > include/drm/drm_plane.h | 4 ++++
> > > > > > > 2 files changed, 33 insertions(+), 15 deletions(-)
> > > > > > >
> > > > > > > diff --git a/drivers/gpu/drm/drm_plane.c
> > > > > > > b/drivers/gpu/drm/drm_plane.c index
> > > > > > >
> > > > > >
> > > > >
> > >
> > 416818e54ccffcf3d3aada2723e96ce8ccf1dd97..4f35eec2b7770fcc90c3e07a90
> > > > > 6
> > > > > > 8
> > > > > > > b31c0563a4c0 100644
> > > > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > > > @@ -191,7 +191,10 @@ modifiers_ptr(struct
> > > > > > > drm_format_modifier_blob
> > > > > > *blob)
> > > > > > > return (struct drm_format_modifier *)(((char *)blob) +
> > > > > > > blob->modifiers_offset); }
> > > > > > >
> > > > > > > -static int create_in_format_blob(struct drm_device *dev,
> > > > > > > struct drm_plane *plane)
> > > > > > > +int drm_plane_create_format_blob(struct drm_device *dev,
> > > > > > > + struct drm_plane *plane, u64
> > > *modifiers,
> > > > > > > + unsigned int modifier_count, u32
> > > *formats,
> > > > > > > + unsigned int format_count, bool
> > > is_async)
> > > > > > > {
> > > > > > > const struct drm_mode_config *config = &dev->mode_config;
> > > > > > > struct drm_property_blob *blob; @@ -200,14 +203,14 @@
> > static
> > > > > > > int create_in_format_blob(struct drm_device
> > > > > > *dev, struct drm_plane *plane
> > > > > > > struct drm_format_modifier_blob *blob_data;
> > > > > > > unsigned int i, j;
> > > > > > >
> > > > > > > - formats_size = sizeof(__u32) * plane->format_count;
> > > > > > > + formats_size = sizeof(__u32) * format_count;
> > > > > > > if (WARN_ON(!formats_size)) {
> > > > > > > /* 0 formats are never expected */
> > > > > > > return 0;
> > > > > > > }
> > > > > > >
> > > > > > > modifiers_size =
> > > > > > > - sizeof(struct drm_format_modifier) * plane-
> > >modifier_count;
> > > > > > > + sizeof(struct drm_format_modifier) * modifier_count;
> > > > > > >
> > > > > > > blob_size = sizeof(struct drm_format_modifier_blob);
> > > > > > > /* Modifiers offset is a pointer to a struct with a 64 bit
> > > > > > > field so it @@ -223,37 +226,45 @@ static int
> > > > > > > create_in_format_blob(struct drm_device *dev, struct drm_plane
> > > > > > > *plane
> > > > > > >
> > > > > > > blob_data = blob->data;
> > > > > > > blob_data->version = FORMAT_BLOB_CURRENT;
> > > > > > > - blob_data->count_formats = plane->format_count;
> > > > > > > + blob_data->count_formats = format_count;
> > > > > > > blob_data->formats_offset = sizeof(struct
> > drm_format_modifier_blob);
> > > > > > > - blob_data->count_modifiers = plane->modifier_count;
> > > > > > > + blob_data->count_modifiers = modifier_count;
> > > > > > >
> > > > > > > blob_data->modifiers_offset =
> > > > > > > ALIGN(blob_data->formats_offset + formats_size, 8);
> > > > > > >
> > > > > > > - memcpy(formats_ptr(blob_data), plane->format_types,
> > formats_size);
> > > > > > > + memcpy(formats_ptr(blob_data), formats, formats_size);
> > > > > > >
> > > > > > > mod = modifiers_ptr(blob_data);
> > > > > > > - for (i = 0; i < plane->modifier_count; i++) {
> > > > > > > - for (j = 0; j < plane->format_count; j++) {
> > > > > > > - if (!plane->funcs->format_mod_supported ||
> > > > > > > + for (i = 0; i < modifier_count; i++) {
> > > > > > > + for (j = 0; j < format_count; j++) {
> > > > > > > + if (is_async ||
> > > > > > > + !plane->funcs->format_mod_supported ||
> > > > > > > plane->funcs-
> > >format_mod_supported(plane,
> > > > > > > - plane-
> > > > > > >format_types[j],
> > > > > > > - plane-
> > > > > > >modifiers[i])) {
> > > > > > > + formats[j],
> > > > > > > +
> > > modifiers[i])) {
> > > > > > > mod->formats |= 1ULL << j;
> > > > > > > }
> > > > > > > }
> > > > > > >
> > > > > > > - mod->modifier = plane->modifiers[i];
> > > > > > > + mod->modifier = modifiers[i];
> > > > > > > mod->offset = 0;
> > > > > > > mod->pad = 0;
> > > > > > > mod++;
> > > > > > > }
> > > > > > >
> > > > > > > - drm_object_attach_property(&plane->base, config-
> > > > > > >modifiers_property,
> > > > > > > - blob->base.id);
> > > > > > > + if (is_async)
> > > > > > > + drm_object_attach_property(&plane->base,
> > > > > > > + config-
> > > >async_modifiers_property,
> > > > > > > + blob->base.id);
> > > > > > > + else
> > > > > > > + drm_object_attach_property(&plane->base,
> > > > > > > + config->modifiers_property,
> > > > > > > + blob->base.id);
> > > > > >
> > > > > > IMO the function should only create the blob. Leave it to the
> > > > > > caller to attach
> > > > > it.
> > > > > >
> > > > > Prior to this change for sync formats/modifiers the property
> > > > > attach was also done in the same function. So retained it as it.
> > > > >
> > > > > > The 'is_async' parameter could also be replaced with with a
> > > > > > function pointer to the appropriate format_mod_supported()
> > > > > > function. That makes the implementation entirely generic.
> > > > > >
> > > > > If the list of formats/modifiers for sync and async is passed to
> > > > > this function, then based on the list the corresponding function
> > > > > pointer can
> > > be called.
> > > > > This was done in the earlier patchset.
> > > > >
> > > > > > >
> > > > > > > return 0;
> > > > > > > }
> > > > > > > +EXPORT_SYMBOL(drm_plane_create_format_blob);
> > > > > > >
> > > > > > > /**
> > > > > > > * DOC: hotspot properties
> > > > > > > @@ -476,7 +487,10 @@ static int
> > > > > > > __drm_universal_plane_init(struct
> > > > > > drm_device *dev,
> > > > > > > }
> > > > > > >
> > > > > > > if (format_modifier_count)
> > > > > > > - create_in_format_blob(dev, plane);
> > > > > > > + drm_plane_create_format_blob(dev, plane, plane-
> > > >modifiers,
> > > > > > > + format_modifier_count,
> > > > > > > + plane->format_types,
> > > > > > format_count,
> > > > > > > + false);
> > > > > > >
> > > > > > > return 0;
> > > > > > > }
> > > > > > > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > > > > > > index
> > > > > > >
> > > > > >
> > > > >
> > >
> > e8749e6fc3bc0acfc73bbd8401f85c3126e86759..eb84830fbb723e39436bfbadf
> > > > > > 369
> > > > > > > 894a5657cd45 100644
> > > > > > > --- a/include/drm/drm_plane.h
> > > > > > > +++ b/include/drm/drm_plane.h
> > > > > > > @@ -1008,5 +1008,9 @@ int
> > > > > > > drm_plane_create_scaling_filter_property(struct drm_plane
> > > > > > > *plane, int
> > > > > > drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > > > > > const struct drm_plane_size_hint
> > *hints,
> > > > > > > int num_hints);
> > > > > > > +int drm_plane_create_format_blob(struct drm_device *dev,
> > > > > > > + struct drm_plane *plane, u64
> > > *modifiers,
> > > > > > > + unsigned int modifier_count, u32
> > > *formats,
> > > > > > > + unsigned int format_count, bool
> > > is_async);
> > > > > >
> > > > > > I don't think this needs to be exposed to anyone.
> > > > > > __drm_universal_plane_init() should just populate both the
> > > > > > normal blob, and and the async blob (iff
> > > > > > .format_mod_supported_async() is provided).
> > > > > >
> > > > > Ok!
> > > > >
> > > > For __drm_universal_plane_init() to have both the sync/async
> > > format/modifiers list we will have to add new elements to struct
> > > drm_plane to hold the async formats/modifiers.
> > >
> > > No, you can just use the already existing format/modifier lists.
> > > .format_mod_supported_async() will filter out what's not wanted.
> > >
> > Agree, to populate the struct drm_format_modifier
> > .format_mod_supported_async along with the existing formats/modifier list
> > should be sufficient.
> > In case of async for the struct drm_format_modifier_blob the elements
> > format_offset includes the list of formats supported by async only. For this we
> > will need to have the static list. So can passing this list be done by adding new
> > elements in drm_plane specifically for async.
>
> Just to add to Arun's point. We had this discussion on thread [1].
>
> If we populate struct drm_format_modifier_blob for async using just the existing format/modifier lists in struct drm_plane,
> We will be mis-representing the following members of the structure to the user space
>
> struct drm_format_modifier_blob {
> /* Number of fourcc formats supported */
> __u32 count_formats;
>
> /* Number of drm_format_modifiers */
> __u32 count_modifiers;
> };
Nothing is misrepresentd. Those things just tell you what the bits in
the bimask mean.
>
> However, as you correctly point out, it should still work because of the format-modifier bit mask.
> But it leaves the overall blob unnecessarily bloated (for example, with unnecessary entries in the format list).
>
> We could however change the function in such a way that the loop
>
> for (i = 0; i < modifier_count; i++) {
> for (j = 0; j < format_count; j++)
>
> runs before filling up these members.
>
> I am not sure how much juggling that would take but it could be a solution.
>
> Anything you would suggest?
You're complicating things needlessly. The slightly bloated blob
should make no practical difference anywhere.
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2025-01-27 19:14 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 5:38 [PATCH v3 0/5] Expose modifiers/formats supported by async flips Arun R Murthy
2025-01-08 5:38 ` [PATCH v3 1/5] drm/plane: Add new plane property IN_FORMATS_ASYNC Arun R Murthy
2025-01-12 7:59 ` Borah, Chaitanya Kumar
2025-01-13 8:22 ` Murthy, Arun R
2025-01-13 17:38 ` Borah, Chaitanya Kumar
2025-01-16 9:54 ` Murthy, Arun R
2025-02-17 6:30 ` Kumar, Naveen1
2025-01-08 5:39 ` [PATCH v3 2/5] drm/plane: Expose function to create format/modifier blob Arun R Murthy
2025-01-12 8:00 ` Borah, Chaitanya Kumar
2025-01-13 8:22 ` Murthy, Arun R
2025-01-13 18:44 ` Borah, Chaitanya Kumar
2025-01-16 9:54 ` Murthy, Arun R
2025-01-20 20:42 ` Ville Syrjälä
2025-01-22 9:27 ` Murthy, Arun R
2025-01-23 7:47 ` Murthy, Arun R
2025-01-24 11:25 ` Ville Syrjälä
2025-01-25 6:55 ` Murthy, Arun R
2025-01-27 7:25 ` Borah, Chaitanya Kumar
2025-01-27 19:13 ` Ville Syrjälä [this message]
2025-01-28 5:32 ` Borah, Chaitanya Kumar
2025-01-08 5:39 ` [PATCH v3 3/5] drm/plane: Function to check async supported modifier/format Arun R Murthy
2025-01-12 8:01 ` Borah, Chaitanya Kumar
2025-01-08 5:39 ` [PATCH v3 4/5] drm/i915/display: Populate list of async supported formats/modifiers Arun R Murthy
2025-01-12 8:02 ` Borah, Chaitanya Kumar
2025-01-20 20:47 ` Ville Syrjälä
2025-01-21 3:34 ` Murthy, Arun R
2025-01-21 13:40 ` Ville Syrjälä
2025-01-08 5:39 ` [PATCH v3 5/5] drm/i915/display: Add function for format_mod_supported_async Arun R Murthy
2025-01-12 8:02 ` Borah, Chaitanya Kumar
2025-01-08 5:58 ` ✓ CI.Patch_applied: success for Expose modifiers/formats supported by async flips (rev2) Patchwork
2025-01-08 5:58 ` ✗ CI.checkpatch: warning " Patchwork
2025-01-08 6:00 ` ✓ CI.KUnit: success " Patchwork
2025-01-08 6:20 ` ✓ CI.Hooks: " Patchwork
2025-01-08 6:22 ` ✗ CI.checksparse: warning " Patchwork
2025-01-08 6:49 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-01-08 7:00 ` ✗ i915.CI.BAT: " Patchwork
2025-01-09 22:08 ` ✗ Xe.CI.Full: " Patchwork
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=Z5fa9RyRoZ0CXQjK@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=arun.r.murthy@intel.com \
--cc=chaitanya.kumar.borah@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
/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 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.