All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Maxime Ripard <mripard@kernel.org>
Cc: jfalempe@redhat.com, javierm@redhat.com,
	dri-devel@lists.freedesktop.org, mairacanal@riseup.net,
	noralf@tronnes.org, jose.exposito89@gmail.com,
	arthurgrillo@riseup.net
Subject: Re: [PATCH v2 0/5] drm: Reuse temporary memory for format conversion
Date: Fri, 29 Sep 2023 16:58:30 +0200	[thread overview]
Message-ID: <cf9eb014-8f84-4203-ba4e-a38f2aa7c769@suse.de> (raw)
In-Reply-To: <kvsuwskjydl24euafxnlr52xhozw7ldyut7hjib3sveb7uyo66@pkpncxahqx5l>


[-- Attachment #1.1: Type: text/plain, Size: 3894 bytes --]

Hi

Am 29.09.23 um 14:11 schrieb Maxime Ripard:
> On Wed, Sep 20, 2023 at 04:24:26PM +0200, Thomas Zimmermann wrote:
>> DRM's format-conversion helpers require temporary memory. Pass the
>> buffer from the caller and keep it allocated over several calls. Allow
>> the caller to preallocate the buffer memory.
>>
>> The motivation for this patchset is the recent work on a DRM panic
>> handler. The panic handler requires format conversion to display an
>> error to the screen. But allocating memory during kernel panics is
>> fragile. The changes in this patchset enable the DRM panic handler to
>> preallocate buffer storage before the panic occurs.
>>
>> As an additonal benefit, drivers can now keep the temporary storage
>> across multiple display updates. Avoiding memory allocation reduces
>> the CPU overhead of the format helpers.
> 
> This argument is getting a bit tiring. The main reason is that it isn't
> one, and:

CPU overhead isn't the driver behind this patchset, but if it is 
affected, why not say that in the commit message? There's a alloc/free 
pair for each updated scanline. For a full-screen updates, that's quite 
a bit.

> 
>    - we allocate something in the 10-20 range objects at a given commit,
>      so another small one is not insignificant.
> 
>    - If it was, it would be trivial to produce a benchmark, but no-one
>      ever actually showed a workload and numbers where there's actually
>      any difference.
> 
>    - Also, the CPU overhead is indeed (even if marginally) decreased, but
>      the memory overhead is increased. I don't know whether that's a good
>      trade-off or not, see the point above.
> 
> It really sounds like an empty statement to me: "But just think of the
> CPU!".
> 
> That being said, I also have more fundamental doubts about this series.
> 
> The first one is that storing the buffer pointer in the device instead
> of the state makes it harder to reason about. When you have a state, the
> framework provides the guarantee at commit time that there's only going
> to be one at a given time. And since the buffer is stored in that state
> object, you can't access it by mistake. The buffer size also depends on
> the state, so that all makes sense from a logical PoV.

Yes. I discussed this with Javier already. Putting this into the state 
is the clean solution.

> 
> If we store the buffer into the device, then suddenly you have to think
> about whether there's multiple CRTCs or not (since commits aren't
> serialised if they affect different CRTCs), whether the buffer size you
> allocated is large enough now for your current resolution and format,
> etc. It adds a decent chunk of complexity on something that was quite
> complex already.

It's in the device because it's good enough for these simple drivers. 
The next best place would be a dedicated plane structure in each driver. 
The per-plane cache would then be clearly attributed to a single plane.

> 
> I understand that the motivation is for drm_panic to have a buffer ready
> when it has to kick in. But why don't we just allocate (and check) a
> spare commit at probe time so we just have to commit it when we panic.

DRM panic doesn't commit anything. It picks up whatever the current 
scanout buffer is and draws into that. If the DRM driver cannot provide 
a scanout buffer, DRM panic does nothing.

Best regards
Thomas

> 
> That would fall nicely into the rest of the atomic modesetting code, and
> since we pretty much require not to allocate anything during
> atomic_commit, we have that constraints already figured out.
> 
> Maxime

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2023-09-29 14:58 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
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 [this message]
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=cf9eb014-8f84-4203-ba4e-a38f2aa7c769@suse.de \
    --to=tzimmermann@suse.de \
    --cc=arthurgrillo@riseup.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=jfalempe@redhat.com \
    --cc=jose.exposito89@gmail.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 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.