Message ID | 20240224121528.1972719-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-79633-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1115959dyb; Sat, 24 Feb 2024 04:15:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWoi7uUWymIGty1MFo/xJYtnAyXvGdhcC9QjvGJmGbDoKQVtKfh5BrLxHs6vJphFOL/CjNyz1AQ0uEFizxRGxoA8hMRdg== X-Google-Smtp-Source: AGHT+IEmcm9L6mIfCin/jiLPSddjN295/GFB7rTWf0UAxZfaBwjmKO7xy9rdU+HSxCAUQxLs7cUe X-Received: by 2002:a5e:830c:0:b0:7c7:98d8:a3cd with SMTP id x12-20020a5e830c000000b007c798d8a3cdmr2775814iom.16.1708776950391; Sat, 24 Feb 2024 04:15:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708776950; cv=pass; d=google.com; s=arc-20160816; b=Y4q2Sm3EnN9QOVrq/3ViQ6NSjyCKzFIOl/jgKLKwVbeWMRw2YmCC2BvaptrZE737XR v6grJHusm6esccb+nOX02+MTxUO42Y0Jb9c8W6EhXOaSejV5Loa+wAgQkhd7MknISaO5 DIYDwXVaNRvXSOZsKJH6bZmpBw74rqNgZ1Lc+Hh/3rELCcHxWRMx0IEpfu2V+3GRyt3A B+/ZCocvI7SQT5SnYzzCPCn6wWf0O8za19JRqPGDWsAs1/S5zb0pu4vmg75XAb3BuP7o 4JCDmf3WZTDyCIi7FQ/IoemYlxum3PSePbbLfoQ7lF2kbGTvsLGF6dwQ6DrhPOhtydsQ Vtsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=DRjEENqe86blp0i8w9og/XE7mh2loQyOSTQJkig/Tu4=; fh=c3a3etaS65PU8IWZhyKENzsI54TWfb9/F2pSjAAmJuI=; b=ZgPT+9kb/VLYP+ly73R1jOGBwD7YfveNUaiEhWE7sobZzSfxc1wOJNfqdLreXNQPce 0I+UZuMO3H6kRsoOamwUGP3rj4JR51JvCj8nSFdLckacIs1S486M8zo1n5wHn74YbHTu GrKZQOnce+3DdJI+nzXBxybHF3XXb43vQ0nceDZ1ZgA7THemU1RhP/3ZaBuXQnSFZtMb sqt4YRwhGlgoWIVJ0Q1FUg5GzSLmVPk895WApoMH071wSkex6cUJ/J01iRohxCfCvGjK +pyiVLKySvnw+Sp6HD7DqF2NWjb89SLlqv3ir6wdD0gYj4l5TIGhM+5REice04aiEUxE NxDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PRUsTOnO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79633-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79633-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9-20020a631d09000000b005e27218564asi849217pgd.157.2024.02.24.04.15.50 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 04:15:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79633-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PRUsTOnO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79633-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79633-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 335BA283C5D for <ouuuleilei@gmail.com>; Sat, 24 Feb 2024 12:15:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 245863F9DE; Sat, 24 Feb 2024 12:15:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PRUsTOnO" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57EF63DB89 for <linux-kernel@vger.kernel.org>; Sat, 24 Feb 2024 12:15:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708776936; cv=none; b=ZtWEOka4gr4AH4O6qFAe+CjTmrXIZVtheQLo2dLDFZ9AupllDxlLRkD28kfV/LwtiABwVrgVLMUTrvp1FUZO6UHSjg2mOi59pWZh1rldQHDJLu33VrZLygrsk2UG6KFagCCh8uu0md8oLdcOPNPD/4jTn1+TXyRZ9E3lUx1R5us= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708776936; c=relaxed/simple; bh=GNq+evKLQVdJDM94sIz8nN00faZ597yvTUdvqvR4sM0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Z8dhgxW38MH27yNzvqLpHLMJs2WZ6CZ7NoqCbJmSxeBe0Z5tbtamLOBrpqxFSqq1kDnFbm+GxTRJVgCzsrpdloLjcXbv97rpSSy8NUcBsQUFIhzNVhd+e+pj/OPd5dNuDqO84Qu3NxgeYFAtqmz2THsqO6w8Ob5sMmrM7V6Si+I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PRUsTOnO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 468BBC433C7; Sat, 24 Feb 2024 12:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708776935; bh=GNq+evKLQVdJDM94sIz8nN00faZ597yvTUdvqvR4sM0=; h=From:To:Cc:Subject:Date:From; b=PRUsTOnOixxCx6+PhkNqgR6u7CrHGxeKdMmu0HhuiPwo8HX6cv+nHUn/nK/5AgwWZ qGWygkErblxxAjS9Znim/qclXfJGMDBUc8aQ0CNojOT6m/bU6Q2wonJlaCoD73YFOS u3l3ZiBiGeyCHT8imaBNwhyNW2oXV04YhilqCkZkfhfmNYpRIjrnveq/k53sKT7yu7 RHBRCafGsQQUcAkDy1BQY4Sm4tbyoqF1fD8XQBHXktLZoII/pogUvICy0mdH5y9jyw LKYX+yMqZeeyU1ksrLEeOBN4rBk6Rb87rM+upgv+WgowiHWxe03rKJs585KZt9iDdj WWUKYA7ZA4cWg== From: Arnd Bergmann <arnd@kernel.org> To: Lucas De Marchi <lucas.demarchi@intel.com>, Oded Gabbay <ogabbay@kernel.org>, =?utf-8?q?Thomas_Hellstr=C3=B6m?= <thomas.hellstrom@linux.intel.com> Cc: Arnd Bergmann <arnd@arndb.de>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Matthew Brost <matthew.brost@intel.com>, Francois Dugast <francois.dugast@intel.com>, Jani Nikula <jani.nikula@intel.com>, Tejas Upadhyay <tejas.upadhyay@intel.com>, Matthew Auld <matthew.auld@intel.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michal Wajdeczko <michal.wajdeczko@intel.com>, Matt Roper <matthew.d.roper@intel.com>, Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] drm/xe/kunit: fix link failure with built-in xe Date: Sat, 24 Feb 2024 13:14:59 +0100 Message-Id: <20240224121528.1972719-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791782499735767411 X-GMAIL-MSGID: 1791782499735767411 |
Series |
[1/3] drm/xe/kunit: fix link failure with built-in xe
|
|
Commit Message
Arnd Bergmann
Feb. 24, 2024, 12:14 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> When the driver is built-in but the tests are in loadable modules, the helpers don't actually get put into the driver: ERROR: modpost: "xe_kunit_helper_alloc_xe_device" [drivers/gpu/drm/xe/tests/xe_test.ko] undefined! Change the Makefile to ensure they are always part of the driver even when the rest of the kunit tests are in loadable modules. The tests/xe_kunit_helpers.c file depends on DRM_KUNIT_TEST_HELPERS, so this has to always be selected by the main XE module now, rather than the actual tests. In turn, the "depends on (m || (y && KUNIT=y))" doesn't really do what it tried and can just be removed. Fixes: 5095d13d758b ("drm/xe/kunit: Define helper functions to allocate fake xe device") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/gpu/drm/xe/Kconfig | 3 ++- drivers/gpu/drm/xe/Kconfig.debug | 1 - drivers/gpu/drm/xe/Makefile | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-)
Comments
On Sat, Feb 24, 2024 at 01:14:59PM +0100, Arnd Bergmann wrote: >From: Arnd Bergmann <arnd@arndb.de> > >When the driver is built-in but the tests are in loadable modules, >the helpers don't actually get put into the driver: > >ERROR: modpost: "xe_kunit_helper_alloc_xe_device" [drivers/gpu/drm/xe/tests/xe_test.ko] undefined! > >Change the Makefile to ensure they are always part of the driver >even when the rest of the kunit tests are in loadable modules. > >The tests/xe_kunit_helpers.c file depends on DRM_KUNIT_TEST_HELPERS, >so this has to always be selected by the main XE module now, rather >than the actual tests. In turn, the "depends on (m || (y && KUNIT=y))" >doesn't really do what it tried and can just be removed. it actually did, which was to workaround issues prior to the commit you are pointing out. What it did was to make sure xe.ko is m, or if it's built-in, kunit is also built-in. Apparently the problem here is that the xe_test.ko is missing the symbols. See commit 08987a8b6820 ("drm/xe: Fix build with KUNIT=m"). I'm happy to remove it though if it's indeed not needed anymore. Lucas De Marchi > >Fixes: 5095d13d758b ("drm/xe/kunit: Define helper functions to allocate fake xe device") >Signed-off-by: Arnd Bergmann <arnd@arndb.de> >--- > drivers/gpu/drm/xe/Kconfig | 3 ++- > drivers/gpu/drm/xe/Kconfig.debug | 1 - > drivers/gpu/drm/xe/Makefile | 6 ++++-- > 3 files changed, 6 insertions(+), 4 deletions(-) > >diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig >index 6d4428b19a4c..2948650680e1 100644 >--- a/drivers/gpu/drm/xe/Kconfig >+++ b/drivers/gpu/drm/xe/Kconfig >@@ -1,7 +1,7 @@ > # SPDX-License-Identifier: GPL-2.0-only > config DRM_XE > tristate "Intel Xe Graphics" >- depends on DRM && PCI && MMU && (m || (y && KUNIT=y)) >+ depends on DRM && PCI && MMU > depends on ACPI_VIDEO || !ACPI > select INTERVAL_TREE > # we need shmfs for the swappable backing store, and in particular >@@ -11,6 +11,7 @@ config DRM_XE > select DRM_BUDDY > select DRM_EXEC > select DRM_KMS_HELPER >+ select DRM_KUNIT_TEST_HELPERS if DRM_XE_KUNIT_TEST != n > select DRM_PANEL > select DRM_SUBALLOC_HELPER > select DRM_DISPLAY_DP_HELPER >diff --git a/drivers/gpu/drm/xe/Kconfig.debug b/drivers/gpu/drm/xe/Kconfig.debug >index 549065f57a78..df02e5d17d26 100644 >--- a/drivers/gpu/drm/xe/Kconfig.debug >+++ b/drivers/gpu/drm/xe/Kconfig.debug >@@ -76,7 +76,6 @@ config DRM_XE_KUNIT_TEST > depends on DRM_XE && KUNIT && DEBUG_FS > default KUNIT_ALL_TESTS > select DRM_EXPORT_FOR_TESTS if m >- select DRM_KUNIT_TEST_HELPERS > help > Choose this option to allow the driver to perform selftests under > the kunit framework >diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile >index 4c6ffe4b2172..b596e4482a9b 100644 >--- a/drivers/gpu/drm/xe/Makefile >+++ b/drivers/gpu/drm/xe/Makefile >@@ -158,8 +158,10 @@ xe-$(CONFIG_PCI_IOV) += \ > xe_lmtt_2l.o \ > xe_lmtt_ml.o > >-xe-$(CONFIG_DRM_XE_KUNIT_TEST) += \ >- tests/xe_kunit_helpers.o >+# include helpers for tests even when XE is built-in >+ifdef CONFIG_DRM_XE_KUNIT_TEST >+xe-y += tests/xe_kunit_helpers.o >+endif > > # i915 Display compat #defines and #includes > subdir-ccflags-$(CONFIG_DRM_XE_DISPLAY) += \ >-- >2.39.2 >
On Sun, Feb 25, 2024 at 09:42:06PM -0600, Lucas De Marchi wrote: > On Sat, Feb 24, 2024 at 01:14:59PM +0100, Arnd Bergmann wrote: > > From: Arnd Bergmann <arnd@arndb.de> > > > > When the driver is built-in but the tests are in loadable modules, > > the helpers don't actually get put into the driver: > > > > ERROR: modpost: "xe_kunit_helper_alloc_xe_device" [drivers/gpu/drm/xe/tests/xe_test.ko] undefined! > > > > Change the Makefile to ensure they are always part of the driver > > even when the rest of the kunit tests are in loadable modules. > > > > The tests/xe_kunit_helpers.c file depends on DRM_KUNIT_TEST_HELPERS, > > so this has to always be selected by the main XE module now, rather > > than the actual tests. In turn, the "depends on (m || (y && KUNIT=y))" > > doesn't really do what it tried and can just be removed. > > it actually did, which was to workaround issues prior to the commit you > are pointing out. What it did was to make sure xe.ko is m, or if it's > built-in, kunit is also built-in. Apparently the problem here is that > the xe_test.ko is missing the symbols. > > See commit 08987a8b6820 ("drm/xe: Fix build with KUNIT=m"). > > I'm happy to remove it though if it's indeed not needed anymore. I think the main issue with that original patch is that it keeps the direct include of the test files. I assume it was done to allow kunit tests of static functions, but now that VISIBLE_IF_KUNIT and EXPORT_SYMBOL_IF_KUNIT are a thing, you don't have the need for that include, and you can build your tests in a module while the code is builtin. And the conversion should be pretty minimal. Maxime
On Mon, Feb 26, 2024, at 04:42, Lucas De Marchi wrote: > On Sat, Feb 24, 2024 at 01:14:59PM +0100, Arnd Bergmann wrote: >>From: Arnd Bergmann <arnd@arndb.de> >> >>When the driver is built-in but the tests are in loadable modules, >>the helpers don't actually get put into the driver: >> >>ERROR: modpost: "xe_kunit_helper_alloc_xe_device" [drivers/gpu/drm/xe/tests/xe_test.ko] undefined! >> >>Change the Makefile to ensure they are always part of the driver >>even when the rest of the kunit tests are in loadable modules. >> >>The tests/xe_kunit_helpers.c file depends on DRM_KUNIT_TEST_HELPERS, >>so this has to always be selected by the main XE module now, rather >>than the actual tests. In turn, the "depends on (m || (y && KUNIT=y))" >>doesn't really do what it tried and can just be removed. > > it actually did, which was to workaround issues prior to the commit you > are pointing out. What it did was to make sure xe.ko is m, or if it's > built-in, kunit is also built-in. Apparently the problem here is that > the xe_test.ko is missing the symbols. Ah, I misunderstood the intention, as I was thrown off by the redundant 'y &&' which sounds like it was trying to force XE to be built-in rather than modular when Kunit is !=m. The more common way to write this is 'depends on KUNIT || !KUNIT', with some drivers writing it as 'depends on m || KUNIT!=m'. I double-checked now and found that the dependency is indeed still needed: WARNING: unmet direct dependencies detected for DRM_KUNIT_TEST_HELPERS Depends on [m]: HAS_IOMEM [=y] && DRM [=y] && KUNIT [=m] Selected by [y]: - DRM_XE [=y] && HAS_IOMEM [=y] && DRM [=y] && PCI [=y] && MMU [=y] && (ACPI_VIDEO [=y] || !ACPI [=y]) && DRM_XE_KUNIT_TEST [=m]!=n Selected by [m]: - DRM_KUNIT_TEST [=m] && HAS_IOMEM [=y] && DRM [=y] && KUNIT [=m] && MMU [=y] > See commit 08987a8b6820 ("drm/xe: Fix build with KUNIT=m"). > > I'm happy to remove it though if it's indeed not needed anymore. Ideally the xe.ko module should not depend on anything exported by lib/kunit, but for the moment, the tests/xe_kunit_helpers.o file is still included in xe.ko and in turn depends on kunit. Changing this is probably a little more complicated than my patch, so I'll just send a v2 without the incorrect line. Arnd
diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig index 6d4428b19a4c..2948650680e1 100644 --- a/drivers/gpu/drm/xe/Kconfig +++ b/drivers/gpu/drm/xe/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config DRM_XE tristate "Intel Xe Graphics" - depends on DRM && PCI && MMU && (m || (y && KUNIT=y)) + depends on DRM && PCI && MMU depends on ACPI_VIDEO || !ACPI select INTERVAL_TREE # we need shmfs for the swappable backing store, and in particular @@ -11,6 +11,7 @@ config DRM_XE select DRM_BUDDY select DRM_EXEC select DRM_KMS_HELPER + select DRM_KUNIT_TEST_HELPERS if DRM_XE_KUNIT_TEST != n select DRM_PANEL select DRM_SUBALLOC_HELPER select DRM_DISPLAY_DP_HELPER diff --git a/drivers/gpu/drm/xe/Kconfig.debug b/drivers/gpu/drm/xe/Kconfig.debug index 549065f57a78..df02e5d17d26 100644 --- a/drivers/gpu/drm/xe/Kconfig.debug +++ b/drivers/gpu/drm/xe/Kconfig.debug @@ -76,7 +76,6 @@ config DRM_XE_KUNIT_TEST depends on DRM_XE && KUNIT && DEBUG_FS default KUNIT_ALL_TESTS select DRM_EXPORT_FOR_TESTS if m - select DRM_KUNIT_TEST_HELPERS help Choose this option to allow the driver to perform selftests under the kunit framework diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile index 4c6ffe4b2172..b596e4482a9b 100644 --- a/drivers/gpu/drm/xe/Makefile +++ b/drivers/gpu/drm/xe/Makefile @@ -158,8 +158,10 @@ xe-$(CONFIG_PCI_IOV) += \ xe_lmtt_2l.o \ xe_lmtt_ml.o -xe-$(CONFIG_DRM_XE_KUNIT_TEST) += \ - tests/xe_kunit_helpers.o +# include helpers for tests even when XE is built-in +ifdef CONFIG_DRM_XE_KUNIT_TEST +xe-y += tests/xe_kunit_helpers.o +endif # i915 Display compat #defines and #includes subdir-ccflags-$(CONFIG_DRM_XE_DISPLAY) += \