All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: "Maíra Canal" <mcanal@igalia.com>,
	"Javier Martinez Canillas" <javierm@redhat.com>,
	"Fabio Piparo" <holofermes@gmail.com>,
	"Melissa Wen" <mwen@igalia.com>,
	"Chema Casanova" <jmcasanova@igalia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: drm/ssd130x: stale pixels when the GPU renders into the framebuffer
Date: Fri, 2 Oct 2026 10:12:26 +0200	[thread overview]
Message-ID: <55914ef9-517d-48dd-a084-0f553f04cb8a@suse.de> (raw)
In-Reply-To: <3bfe2517-a5d3-4e86-99bd-6c28556f0f2d@igalia.com>

Hi

Am 30.09.26 um 21:57 schrieb Maíra Canal:
> + cc Chema (Mesa developer in V3D)
>
> Hi,
>
> On 30/09/26 12:52, Javier Martinez Canillas wrote:
>> Maíra Canal <mcanal@igalia.com> writes:
>>
>> Hello Maíra,
>>
>>> Hi,
>>>
>>> On 30/09/26 05:32, Thomas Zimmermann wrote:
>>>> Hi
>>>>
>>>> Am 30.09.26 um 09:48 schrieb Javier Martinez Canillas:
>>>> [...]
>>>>>>> I have a patch implementing begin/end_cpu_access to
>>>>>>> drm_gem_prime_dmabuf_ops, which fixed the issue. However, I'm 
>>>>>>> not sure
>>>>>>> we would like to support this use case upstream because, as you
>>>>>>> mentioned, dumb buffers are usually used for software-rendering 
>>>>>>> only.
>>>>>> Before we fix anything, I think we should talk to someone with
>>>>>> dma-buf/PRIME credentials.  As I outlined, the ideomatic pattern 
>>>>>> is a
>>>>>> producer-consumer relationship and HW rendering into dumb-buffers 
>>>>>> is not
>>>>>> supported. Those buffers should have been allocated on the v3d side.
>>>>>>
>>>>>> IMHO we should write down these rules in the PRIME documentation and
>>>>>> (soft-)enforce them in the implementation.
>>>>>>
>>>>> Yeah, I think either drm_gem_fb_begin_cpu_access() needs to also sync
>>>>> exported buffers (what Maíra is proposing as a fix) or there 
>>>>> should be
>>>>> documentation of the rules for cross-devices buffer sharing through
>>>>> PRIME.
>>>>
>>>> This specific case only happens with v3d and only this driver can know
>>>> when to flush caches. If we flush caches in begin_cpu_access, we 
>>>> easily
>>>> end up paying the overhead on all systems.
>>>>
>>>
>>> I believe that's the main issue. We would pay a reasonably big price to
>>> support this uncommon (and maybe even wrong) use case.
>>>
>>> P.S.: To be clear, I wasn't proposing a fix. I should have called my
>>> patch a "hack", because although it works, I don't believe we should
>>> support this use case for the reasons stated by Thomas.
>>>
>>
>> Yes, I agree with you. Making v3d to warn as Thomas suggested seems 
>> to be
>> the best compromise.
>
> I was thinking about Thomas' suggestion, and I might be missing
> something. If v3d warns when rendering to imported buffers, it will
> warn on every RPi 4/5, as Mesa renders the display path into dumb
> buffers imported from vc4. That works because vc4 buffers are WC and
> scanned out by hardware, so the CPU never reads them [1].

Oh, that's not good. It actually convinces me that v3d (and every other 
driver) should have warned about this situation. See my example below.


>
> From my point of view, the issue here is cross-device sharing of a dumb
> buffer that the exporter reads with the CPU through a cached mapping.

The whole workaround with WC doesn't fully capture the issue.

Imagine the renderer would have used discrete video memory (e.g. like on 
an old PCI device). Rendering to an imported buffer would simply not 
work at all. After rendering a frame into the video memory, the render 
driver would have to memcpy the result from the video memory to the 
imported buffer. This would need to be done on every frame because the 
importer doesn't know when exactly the exporter requires the image.  
  Sharing buffers in the other direction would work fine.  The importer 
(now ssd130x) can always setup a page mapping from the dma-buf's 
provided s/g table. The s/g table can refer directly to the video memory 
on the PCI device.


>
> [1] Right after writing this paragraph, I decided to read the
> documentation in drm_dumb_object.c and I found:
>
> * Note that dumb objects may not be used for gpu acceleration, as has 
> been
> * attempted on some ARM embedded platforms. Such drivers really must have
> * a hardware-specific ioctl to allocate suitable buffer objects.
>
> Does anyone know why Mesa kmsro create dumb buffers for rendering? Maybe
> I understood the documentation incorrectly, but it looks like we
> shouldn't be doing that.

The first bullet point talks specifically about GPU acceleration. Mesa 
creates dumb buffers for _software rendering_. Ssd130x scans out the 
final result and transfers it to the panel. No GPU rendering involved there.

Best regards
Thomas


>
> Best regards,
> - Maíra
>
>>
>>> Best regards,
>>> - Maíra
>>>
>>
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)



  reply	other threads:[~2026-10-02  8:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13  4:27 drm/ssd130x: stale pixels when the GPU renders into the framebuffer Fabio Piparo
2026-08-14 18:34 ` Javier Martinez Canillas
2026-09-14  8:43 ` Thomas Zimmermann
2026-09-23 16:00   ` Fabio Piparo
2026-09-29  9:04     ` Thomas Zimmermann
2026-09-29 21:50       ` Maíra Canal
2026-09-30  6:48         ` Thomas Zimmermann
2026-09-30  7:48           ` Javier Martinez Canillas
2026-09-30  8:32             ` Thomas Zimmermann
2026-09-30 13:49               ` Maíra Canal
2026-09-30 15:52                 ` Javier Martinez Canillas
2026-09-30 18:45                   ` Fabio Piparo
2026-10-02  8:18                     ` Thomas Zimmermann
2026-09-30 19:57                   ` Maíra Canal
2026-10-02  8:12                     ` Thomas Zimmermann [this message]
2026-10-02 21:13                       ` Maíra Canal
2026-10-06  6:50                         ` 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=55914ef9-517d-48dd-a084-0f553f04cb8a@suse.de \
    --to=tzimmermann@suse.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=holofermes@gmail.com \
    --cc=javierm@redhat.com \
    --cc=jmcasanova@igalia.com \
    --cc=mcanal@igalia.com \
    --cc=mwen@igalia.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 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.