From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C11193FE363 for ; Thu, 23 Jul 2026 09:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784800269; cv=none; b=g6TIoBbwGXmnoNECB+ULd3GSxkZqLrl/V1rWhqUDNBNwAHAK3WpctV1E97VMvUyNCoZjjtsyHkYpH83SrtWNd7zAJ+XXZEPhf6Xjfcy+69C933MlK948/cgiKDE948nHXnesbD0sRitKXyGnnLcrm4pLI5EaBl93OBNE467qxtI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784800269; c=relaxed/simple; bh=gLnmaqwgXkQ9rRY5IK26Mz6rL4Aqq/nHA7/nz7I0rY4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=n+DZ/wBYsRKRJviJV4rx90XJriQSCyc/IymAru12diCRK4foDWZsLqzHtYkK+1E4/FZpTQAamN0K1H7srOLCHOZZ/pZuiFPuV/ntwH9wPmXXi1msEtQ3ifwqnlrhgWKSpuO/+bIf+hNUyVZj1iPeWDD9d/9WGj/d+qSDSvgGEoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=R9+syWby; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R9+syWby" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-493f6de72faso2285705e9.0 for ; Thu, 23 Jul 2026 02:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784800266; x=1785405066; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=h9FrgNeXvQXeP5ztByoZ2RKg2y/qZdfAkNQeX3ODWAs=; b=R9+syWby8VrjmAfzC939krJH9XJtOg/CbhnLV9ng9E4oQpGYzGfXUs8yscigq2JxaF XR+f2gXNbR02LR0wVjCV33c+aZJu83DOiupp5j2avEvkMOVTWuomCPWRiEzXwNQ/V5ub EA+FivyVeCeCPGEtK9SNTbBa0k4TKEN7nEmFhgNfDZyxwS0YbZj3lcKGJ+I3L4043gyw HjD9P3HGh3kS0LKtSePrXIjbzVn+tvUQnnGtQwhDzYEVwjf9ao5+E8EK892z3fbbqYKT LlcDhqOM2ugUUBhnUBJ7FXAMYYMp2S/23llAcw3zuAno3JMRiQYcBQSqCdvsQgKpBKrV LW5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784800266; x=1785405066; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=h9FrgNeXvQXeP5ztByoZ2RKg2y/qZdfAkNQeX3ODWAs=; b=j7zlxHOWH+102D9R6z1bH2+eqz+t6C+oCeUC5jBQ3KAt7hppZwgywQL3jBStcr5zh2 F+o6R2GK8pqmu+KeJ+oPrh9TBF4ZzavvbH7wTXTZNedzZ8yIBr7cqlb+dM9hf8H+w85K tGJVmWNWJuthx+CfjU247Ys/Yrzj4pah694r8DKSfs6uh2iaMoY8pMF7cGP6djIBHstY gBFp8wBuntNwP7oG94qr9XjDvkox7Cicv4RYXCKf+9qwGkse3njCfBIvvOAOJ+AEGC8a CJC/XXiypFGogTFx6zt3EPfSDGsSoOKW1nUKpgF1Uu3W5ulomIlmiQMfLqQtM1VFUdzz Ow9Q== X-Gm-Message-State: AOJu0Yz7WPov4pGpUbHfKpYrZuAxZO21HgXZyATkkjm3kajHbuH0QHPV 5acZTwwdk2s9Zc00fzXG5eDMdohTWTAixeZJtSv7DGVXBhJ+tNR8RAq5 X-Gm-Gg: AR+sD10iYyjl+1mPWyKi39vsyhIshMPoiDt3l+YMEfBHhq+zQsU4Mxz6SYnwlws9UVG MHwrd9asNAAEzThUGWzWErFnl+wM3zjNdi8Baq1BrGhKad5uFHlIQLe+BIytOJCw33VF31IavM+ WPYIAL1A/L/iBs0bUAdRy+RqQW5Ztbf+2HY9UfAcF/5P3Epq6XtVgHY/IT+GYFlnQew5KIL16M5 HRQ3pc0TMO4PqIYOB1fDpx+bjYZ145HvH+J3JnwsyPVVGUi5b4YF4C4GriDKHbfITCUKDne3/6o F2GT3onHTq+2fjpjxOXftvCdVynlZFNTvUzO4YLk09p92bjJqNAqk3cSJN+miBb1sM4T3zgbFu6 8Sc/XhSVzW5hNu2OPyLcEBatGzZ87BW2auKS4SL/3Pu6pMVs9E6o9UIITXihFnsLh8JYZnVQ60e v9 X-Received: by 2002:a05:600c:4684:b0:48f:e230:29f5 with SMTP id 5b1f17b1804b1-495745ac56cmr20876415e9.16.1784800265223; Thu, 23 Jul 2026 02:51:05 -0700 (PDT) Received: from fedora ([94.73.45.171]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-495765e3f3dsm16288645e9.2.2026.07.23.02.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 02:51:04 -0700 (PDT) Date: Thu, 23 Jul 2026 11:51:03 +0200 From: =?iso-8859-1?Q?Jos=E9_Exp=F3sito?= 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, =?iso-8859-1?Q?Jos=E9_Exp=F3sito?= Subject: Re: [PATCH v3] drm/tests: shmem: Set DMA mask to 64-bit in drm_gem_shmem Message-ID: References: <20260703150808.3832-1-jose.exposito89@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 > > 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 > Signed-off-by: José Expósito 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 >