From: "José Expósito" <jose.exposito89@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com,
simona@ffwll.ch, boris.brezillon@collabora.com, kees@kernel.org,
"José Expósito" <jose.exposito@redhat.com>
Subject: Re: [PATCH v3] drm/tests: shmem: Set DMA mask to 64-bit in drm_gem_shmem
Date: Thu, 23 Jul 2026 11:51:03 +0200 [thread overview]
Message-ID: <amHkBwhcNaUPQqd7@fedora> (raw)
In-Reply-To: <20260703150808.3832-1-jose.exposito89@gmail.com>
On Fri, Jul 03, 2026 at 05:07:43PM +0200, José Expósito wrote:
> From: José Expósito <jose.exposito@redhat.com>
>
> drm_gem_shmem_test_purge [1] and drm_gem_shmem_test_get_pages_sgt [2]
> intermittently fail on ppc64le and s390x CI systems with a DMA address
> overflow:
>
> DMA addr 0x0000000100307000+4096 overflow (mask ffffffff, bus limit 0)
> WARNING: kernel/dma/direct.h:114 dma_direct_map_sg+0x778/0x920
>
> drm_gem_shmem_test_purge: ASSERTION FAILED at
> drivers/gpu/drm/tests/drm_gem_shmem_test.c:330
> Expected sgt is not error, but is: -5
>
> The call chain leading to the failure is:
>
> drm_gem_shmem_test_purge() / drm_gem_shmem_test_get_pages_sgt()
> drm_gem_shmem_get_pages_sgt()
> drm_gem_shmem_get_pages_sgt_locked() [drm_gem_shmem_helper.c]
> dma_map_sgtable() [mapping.c]
> __dma_map_sg_attrs()
> dma_direct_map_sg() [direct.c]
> dma_direct_map_phys() [kernel/dma/direct.h]
> dma_capable() Checks addr against DMA mask
> -> FAILS: addr > 0xFFFFFFFF
>
> The root cause is that KUnit devices are initialized with a 32-bit DMA
> mask (DMA_BIT_MASK(32)) in lib/kunit/device.c. On ppc64le and s390x
> systems with physical memory above 4GB, page allocations can land at
> addresses that exceed this mask. When drm_gem_shmem_get_pages_sgt()
> attempts to DMA-map these pages via dma_map_sgtable(), the DMA layer
> rejects the mapping because the physical address overflows the 32-bit
> mask.
>
> The failure is intermittent because pages may or may not be allocated
> above 4GB on any given run depend on memory pressure.
>
> Fix by setting a 64-bit DMA mask on the device before calling
> drm_gem_shmem_get_pages_sgt() for all tests, following the same pattern
> already used in drm_gem_shmem_test_obj_create_private().
>
> [1] https://s3.amazonaws.com/arr-cki-prod-trusted-artifacts/trusted-artifacts/2643976103/test_s390x/15128551935/artifacts/jobwatch/logs/recipes/21561049/tasks/220716793/results/1014626315/logs/dmesg.log
> [2] https://s3.amazonaws.com/arr-cki-prod-trusted-artifacts/trusted-artifacts/2643976103/test_ppc64le/15128551933/artifacts/jobwatch/logs/recipes/21561041/tasks/220716705/results/1014628163/logs/dmesg.log
>
> Fixes: 93032ae634d4 ("drm/test: add a test suite for GEM objects backed by shmem")
> Closes: https://datawarehouse.cki-project.org/issue/5345
> Closes: https://datawarehouse.cki-project.org/issue/3184
> Assisted-by: Claude:claude-4.6-opus
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: José Expósito <jose.exposito@redhat.com>
Applied to drm-misc-fixes, thanks a lot for your review Thomas.
Jose
> ---
>
> v2:
>
> - Move fix to drm_gem_shmem_test_init() (Thomas Zimmermann)
> - Link to v1: https://lore.kernel.org/dri-devel/20260703063517.6346-1-jose.exposito89@gmail.com/
>
> v3:
>
> - Improve comments (Sashiko Bot)
> - Link to v2: https://lore.kernel.org/dri-devel/20260703142749.4099-1-jose.exposito89@gmail.com/
> ---
> drivers/gpu/drm/tests/drm_gem_shmem_test.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/tests/drm_gem_shmem_test.c b/drivers/gpu/drm/tests/drm_gem_shmem_test.c
> index 44a190109249..5e69ff1d1ad6 100644
> --- a/drivers/gpu/drm/tests/drm_gem_shmem_test.c
> +++ b/drivers/gpu/drm/tests/drm_gem_shmem_test.c
> @@ -95,13 +95,9 @@ static void drm_gem_shmem_test_obj_create_private(struct kunit *test)
> sg_init_one(sgt->sgl, buf, TEST_SIZE);
>
> /*
> - * Set the DMA mask to 64-bits and map the sgtables
> - * otherwise drm_gem_shmem_free will cause a warning
> - * on debug kernels.
> + * Map the sgtables otherwise drm_gem_shmem_free will cause a warning on
> + * debug kernels.
> */
> - ret = dma_set_mask(drm_dev->dev, DMA_BIT_MASK(64));
> - KUNIT_ASSERT_EQ(test, ret, 0);
> -
> ret = dma_map_sgtable(drm_dev->dev, sgt, DMA_BIDIRECTIONAL, 0);
> KUNIT_ASSERT_EQ(test, ret, 0);
>
> @@ -352,11 +348,19 @@ static int drm_gem_shmem_test_init(struct kunit *test)
> {
> struct device *dev;
> struct drm_device *drm_dev;
> + int ret;
>
> /* Allocate a parent device */
> dev = drm_kunit_helper_alloc_device(test);
> KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
>
> + /*
> + * Set the DMA mask to 64-bits to avoid intermittent failures calling
> + * drm_gem_shmem_get_pages_sgt().
> + */
> + ret = dma_set_mask(dev, DMA_BIT_MASK(64));
> + KUNIT_ASSERT_EQ(test, ret, 0);
> +
> /*
> * The DRM core will automatically initialize the GEM core and create
> * a DRM Memory Manager object which provides an address space pool
> --
> 2.54.0
>
prev parent reply other threads:[~2026-07-23 9:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 15:07 [PATCH v3] drm/tests: shmem: Set DMA mask to 64-bit in drm_gem_shmem José Expósito
2026-07-23 9:51 ` José Expósito [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=amHkBwhcNaUPQqd7@fedora \
--to=jose.exposito89@gmail.com \
--cc=airlied@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jose.exposito@redhat.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@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 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.