mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guillaume La Roque <glaroque@baylibre.com>
To: Gyeyoung Baek <gye976@gmail.com>
Cc: Alessio Belle <alessio.belle@imgtec.com>,
	Luigi Santivetti <luigi.santivetti@imgtec.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	imagination@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH] drm/imagination: drop redundant zeroing of new GEM objects
Date: Mon, 23 Nov 2026 14:55:51 +0100	[thread overview]
Message-ID: <5278036d-c939-4726-a591-91c7dbedd431@baylibre.com> (raw)
In-Reply-To: <CAKbEznssOrO84z_msOZ0tYjVYkaQ8P+f8uma3PhOF6+zp32Hvw@mail.gmail.com>

Hi Gyeyoung,

thanks for the review.

Le 22/11/2026 à 08:55, Gyeyoung Baek a écrit :
> Hi Guillaume,
>
> On Wed, Nov 11, 2026 at 6:43 PM Guillaume La Roque
> <glaroque@baylibre.com> wrote:
>> pvr_gem_object_create() clears every new object through a CPU mapping
>> so that userspace never sees data left by a previous owner of the
>> pages [1]. shmem already guarantees that: it clears each page it
>> allocates, and the dma_sync_sgtable_for_device() call that follows
>> makes those zeroes visible to the GPU. The second pass, write-combined
>> on non-coherent devices, only adds latency.
> I'm not very familiar with shmem, so I'd like to ask: is this zeroing
> something shmem guarantees, or just a current implementation detail?
 From what I see in the code, it is guaranteed by shmem, not just an
implementation detail. The zeroing is done in shmem_get_folio_gfp():

           if (sgp != SGP_WRITE && !folio_test_uptodate(folio)) {
                   long i, n = folio_nr_pages(folio);

                   for (i = 0; i < n; i++)
                           clear_highpage(folio_page(folio, i));
                   flush_dcache_folio(folio);
                   folio_mark_uptodate(folio);
           }

pvr objects get their pages through drm_gem_shmem_get_pages_sgt() ->
drm_gem_get_pages() -> shmem_read_folio_gfp(), which uses SGP_CACHE.
Each object is a new shmem file, so all its folios are newly allocated
and not uptodate, and they are always cleared here.

panfrost and panthor already rely on this too, they never clear new
objects. There is even a comment about it in should_map_wc() in both
drivers:

     /* We can't do uncached mappings if the device is coherent,
     * because the zeroing done by the shmem layer at page allocation
     * time happens on a cached mapping which isn't CPU-flushed ...

For pvr there is no problem with that: coherent devices always get
PVR_BO_CPU_CACHED, and on non-coherent ones the zeroes are flushed by
dma_map_sgtable() and by the dma_sync_sgtable_for_device() already done
in pvr_gem_object_create().

> Since the driver would now rely on it, could you spell out in the
> commit message where the zeroing happens and why it can be relied on?
>
i will add these detail in commit message in v2 if it look ok for you.

Regards
Guillaume


      reply	other threads:[~2026-11-23 13:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  9:43 Guillaume La Roque
2026-11-22  7:55 ` Gyeyoung Baek
2026-11-23 13:55   ` Guillaume La Roque [this message]

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=5278036d-c939-4726-a591-91c7dbedd431@baylibre.com \
    --to=glaroque@baylibre.com \
    --cc=airlied@gmail.com \
    --cc=alessio.belle@imgtec.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gye976@gmail.com \
    --cc=imagination@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=luigi.santivetti@imgtec.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=simona@ffwll.ch \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®