From: Thomas Zimmermann <tzimmermann@suse.de>
To: javierm@redhat.com, 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: [PATCH 6/8] drm/ofdrm: Preallocate xfrm buffer in plane's atomic_check
Date: Wed, 20 Sep 2023 13:10:18 +0200 [thread overview]
Message-ID: <20230920112508.11770-7-tzimmermann@suse.de> (raw)
In-Reply-To: <20230920112508.11770-1-tzimmermann@suse.de>
Preallocate the xfrm buffer's storage in the plane's atomic_check
function if a format conversion will be necessary. Allows the update
to fail if no memory is available. Avoids the same allocation within
atomic_update, which may not fail.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/tiny/ofdrm.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/gpu/drm/tiny/ofdrm.c b/drivers/gpu/drm/tiny/ofdrm.c
index 08e4b04e0590e..d81b986f5cbc6 100644
--- a/drivers/gpu/drm/tiny/ofdrm.c
+++ b/drivers/gpu/drm/tiny/ofdrm.c
@@ -759,6 +759,8 @@ static const uint64_t ofdrm_primary_plane_format_modifiers[] = {
static int ofdrm_primary_plane_helper_atomic_check(struct drm_plane *plane,
struct drm_atomic_state *new_state)
{
+ struct drm_device *dev = plane->dev;
+ struct ofdrm_device *odev = ofdrm_device_of_dev(dev);
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(new_state, plane);
struct drm_framebuffer *new_fb = new_plane_state->fb;
struct drm_crtc *new_crtc = new_plane_state->crtc;
@@ -778,6 +780,15 @@ static int ofdrm_primary_plane_helper_atomic_check(struct drm_plane *plane,
else if (!new_plane_state->visible)
return 0;
+ if (new_fb->format != odev->format) {
+ void *buf;
+
+ /* format conversion necessary; reserve buffer */
+ buf = drm_xfrm_buf_reserve(&odev->xfrm, odev->pitch, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+ }
+
new_crtc_state = drm_atomic_get_new_crtc_state(new_state, new_plane_state->crtc);
new_ofdrm_crtc_state = to_ofdrm_crtc_state(new_crtc_state);
--
2.42.0
next prev parent reply other threads:[~2023-09-20 11:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 11:10 [PATCH 0/8] drm: Reuse temporary memory for format conversion Thomas Zimmermann
2023-09-20 11:10 ` [PATCH 1/8] drm/format-helper: Add struct drm_xfrm_buf to cache " Thomas Zimmermann
2023-09-20 11:10 ` [PATCH 2/8] drm/format-helper: Pass xfrm buffer to format-conversion helpers Thomas Zimmermann
2023-09-20 11:40 ` Jani Nikula
2023-09-20 11:10 ` [PATCH 3/8] drm/simpledrm: Store xfrm buffer in device instance Thomas Zimmermann
2023-09-20 11:10 ` [PATCH 4/8] drm/simpledrm: Preallocate xfrm buffer in plane's atomic_check Thomas Zimmermann
2023-09-20 11:10 ` [PATCH 5/8] drm/ofdrm: Store xfrm buffer in device instance Thomas Zimmermann
2023-09-20 11:10 ` Thomas Zimmermann [this message]
2023-09-20 11:10 ` [PATCH 7/8] drm/ssd130x: " Thomas Zimmermann
2023-09-20 11:10 ` [PATCH 8/8] drm/ssd130x: Preallocate xfrm buffer in plane's atomic_check Thomas Zimmermann
2023-09-20 11:30 ` Thomas Zimmermann
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=20230920112508.11770-7-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=arthurgrillo@riseup.net \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--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 \
/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