Re: [PATCH] drm/imagination: drop redundant zeroing of new GEM objects

From: Gyeyoung Baek

Date: Wed Nov 25 2026 - 09:09:42 EST


Hi Guillaume,

On Mon, Nov 23, 2026 at 10:55 PM Guillaume La Roque
<glaroque@xxxxxxxxxxxx> wrote:

> > 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().

Thanks, that makes sense. Following the path through shmem was useful
for me as well.

> > 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.

Yes, please add it to the commit message in v2. Otherwise LGTM.

I also tested it on a BeagleY-AI (J722S, BXS-4-64): vkcube runs without issues.

Tested-by: Gyeyoung Baek <gye976@xxxxxxxxx>
Reviewed-by: Gyeyoung Baek <gye976@xxxxxxxxx>

--
Thanks,
Gyeyoung