From: Javier Martinez Canillas <javierm@redhat.com>
To: Thomas Zimmermann <tzimmermann@suse.de>,
jfalempe@redhat.com, jose.exposito89@gmail.com,
arthurgrillo@riseup.net, mairacanal@riseup.net,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
airlied@gmail.com, daniel@ffwll.ch, noralf@tronnes.org
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 5/5] drm/ssd130x: Store xfrm buffer in device instance
Date: Fri, 29 Sep 2023 11:16:07 +0200 [thread overview]
Message-ID: <87edih49wo.fsf@minerva.mail-host-address-is-not-set> (raw)
In-Reply-To: <20230920142535.19321-6-tzimmermann@suse.de>
Thomas Zimmermann <tzimmermann@suse.de> writes:
> Store and instance of struct drm_xfrm_buf in struct ssd130x_device and
> keep the allocated memory allocated across display updates. Avoid
> possibly reallocating temporary memory on each display update. Instead
> preallocate temporary memory during initialization. Releasing the DRM
> device also releases the xfrm buffer.
>
> v2:
> * reserve storage during probe
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
[...]
> @@ -1084,6 +1081,8 @@ struct ssd130x_device *ssd130x_probe(struct device *dev, struct regmap *regmap)
> struct ssd130x_device *ssd130x;
> struct backlight_device *bl;
> struct drm_device *drm;
> + const struct drm_format_info *fi;
> + void *buf;
> int ret;
>
> ssd130x = devm_drm_dev_alloc(dev, &ssd130x_drm_driver,
> @@ -1117,6 +1116,18 @@ struct ssd130x_device *ssd130x_probe(struct device *dev, struct regmap *regmap)
> bl->props.max_brightness = MAX_CONTRAST;
> ssd130x->bl_dev = bl;
>
> + ret = drmm_xfrm_buf_init(drm, &ssd130x->xfrm);
> + if (ret)
> + return ERR_PTR(ret);
> + fi = drm_format_info(DRM_FORMAT_R1);
> + if (!fi)
> + return ERR_PTR(-EINVAL);
> + buf = drm_xfrm_buf_reserve(&ssd130x->xfrm,
> + drm_format_info_min_pitch(fi, 0, ssd130x->width),
> + GFP_KERNEL);
> + if (!buf)
> + return ERR_PTR(-ENOMEM);
> +
I think this is OK but then I wonder if we should not just allocate all
the buffers in the probe function. Right now, what the driver does is to
have two structures to keep the driver-private atomic state:
1) struct ssd130x_crtc_state that has a .data_array to store the pixels
in the HW format (e.g: R1) and written to the panel.
2) struct ssd130x_plane_state that has a .buffer to store the pixels that
are converted from the emulated XRGB8888 used by the shadow-plane, to
the HW pixel format.
The (2) will be optional once Geert's R1 support lands. Now we are adding
a third buffer so I wonder if should be part of one of these private state
or not.
I said that should be a field of struct ssd130x_plane_state in a previous
email, but on a second thought it makes more sense if is a field of the
struct ssd130x_crtc_state.
That way the allocation will only be in ssd130x_crtc_atomic_check() and
the release in the ssd130x_crtc_destroy_state(). If you do that on patch
#2, then this patch #5 could be dropped.
The reason why I added those private state structures is twofold: because
the buffers are tied to the CRTC and planes and to show how a driver can
maintain their own private atomic state.
After all, one of my goals of this driver is to be used for educational
purposes and provide a simple driver that people can use as a reference.
--
Best regards,
Javier Martinez Canillas
Core Platforms
Red Hat
next prev parent reply other threads:[~2023-09-29 9:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 14:24 [PATCH v2 0/5] drm: Reuse temporary memory for format conversion Thomas Zimmermann
2023-09-20 14:24 ` [PATCH v2 1/5] drm/format-helper: Add struct drm_xfrm_buf to cache " Thomas Zimmermann
2023-09-29 8:27 ` Javier Martinez Canillas
2023-10-04 7:08 ` Thomas Zimmermann
2023-10-04 7:30 ` Javier Martinez Canillas
2023-09-20 14:24 ` [PATCH v2 2/5] drm/format-helper: Pass xfrm buffer to format-conversion helpers Thomas Zimmermann
2023-09-29 9:04 ` Javier Martinez Canillas
2023-09-20 14:24 ` [PATCH v2 3/5] drm/simpledrm: Store xfrm buffer in device instance Thomas Zimmermann
2023-09-26 7:31 ` Jocelyn Falempe
2023-09-28 8:15 ` Thomas Zimmermann
2023-09-20 14:24 ` [PATCH v2 4/5] drm/ofdrm: " Thomas Zimmermann
2023-09-20 14:24 ` [PATCH v2 5/5] drm/ssd130x: " Thomas Zimmermann
2023-09-29 9:16 ` Javier Martinez Canillas [this message]
2023-09-26 7:28 ` [PATCH v2 0/5] drm: Reuse temporary memory for format conversion Jocelyn Falempe
2023-09-29 12:11 ` Maxime Ripard
2023-09-29 14:58 ` Thomas Zimmermann
2023-10-02 13:24 ` Maxime Ripard
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=87edih49wo.fsf@minerva.mail-host-address-is-not-set \
--to=javierm@redhat.com \
--cc=airlied@gmail.com \
--cc=arthurgrillo@riseup.net \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jfalempe@redhat.com \
--cc=jose.exposito89@gmail.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mairacanal@riseup.net \
--cc=mripard@kernel.org \
--cc=noralf@tronnes.org \
--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 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.