From patchwork Thu Dec 1 12:32:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 28352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp234589wrr; Thu, 1 Dec 2022 04:35:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf50Z8AyU5Suv97Kp2IEwiiusZTeI2nPVG9q5hImOifNuO/7IjzJva/a1JLLqyQ6AtFbX/Ic X-Received: by 2002:a17:90a:b38b:b0:214:1328:ac8f with SMTP id e11-20020a17090ab38b00b002141328ac8fmr69771958pjr.198.1669898109843; Thu, 01 Dec 2022 04:35:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669898109; cv=none; d=google.com; s=arc-20160816; b=XLzTr18Lsjdf4WXu3RAleRWdLMAFHxdrdBWE0NeMdvxDlbyhh6aQ87qD+OL+wXXNCM J1v4nYvMcpeZKy9sXYCIOsJqIpEr03S+gb7A8txmLRvxSH2bSbRZ0b6y+l+WokagIaDP OVuBZV3zPd+1zVwx5qL+tTLkD9ZiQqBsB2DwQ6gPcdkDhCKBbGnCiKq8WSm0ziGPiyes RC8FDgQktWRjhtmH7vlZLo2mo4ZBek4MJjez4AMWH6Hb8Y2WZCSe1l5xXF8d5K+HAIrp NOeq4aSXE8HLJPl5LgIKecpZgHc8M+eNtvSYptlwpq9g2nV47RsUKeAmXbQ2njWOQtdb jsNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=rxYO2D/duDTveT8UliOU98iB3EyI7Vm8KopYwhqNzi4=; b=l2rPpLX+z8fLOszvyXc7qvzSDhg2+rri8OCrxaAM4TkH/WxL0TwMTawHg81a2Zpq7e AiUzFvEqdrtSrwKTe5sJtS6N6IVFuT84wdQ1kKPV8+PxigHXFcHOFrWAvWoU/nazLrMs h80dHtMzLMtA0MIb5evlD55tPixYmMSUhzjbNMTOesWsLjRghBP+N0F/0mFYU8yfliRh dZd76umPaRnpHidZV2AEIPWCvLb+PzO580l0ul/A2C/AP45feSdAnsbiTRRiXxCd8UGQ n4v70KndkMc7Z1qrP2krHn+dSIHCToffzWUpUTJ90WUrMCVjm7vowAg+fZ6RicIFOnkH vJhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=JX5Wqrcf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u62-20020a638541000000b0046086f8f5d0si4403877pgd.537.2022.12.01.04.34.53; Thu, 01 Dec 2022 04:35:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=JX5Wqrcf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231354AbiLAMcQ (ORCPT + 99 others); Thu, 1 Dec 2022 07:32:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbiLAMcO (ORCPT ); Thu, 1 Dec 2022 07:32:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB556B68FE for ; Thu, 1 Dec 2022 04:32:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 44E7561FD1 for ; Thu, 1 Dec 2022 12:32:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A22E1C433D6; Thu, 1 Dec 2022 12:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669897931; bh=+hmnjpr/Mlwxdk1qNwkNqCTb5PWqCusX1qRO0Wh9xU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JX5WqrcfGPbgBTYLbS/MtXQN4eaFNXChoo8YmYNuinsqcpOSWATS190roek0LUoPT glYcZGXCwcVWkkQ3mC27kP0fnxeSTwRFlW0cnvAxAWtGCiemHhshajqQc2lRjIr8Am WiPafsfrS0ByGqttXp2KzSkCbJVh+KCfX8yYc7EqWAakrCzHV0bjROzklsVzKPZYmI zzogpYkPtWaa2QysomMawvGNs2gzQ2TDCfss15rfsZ8SfWz2ACgSaRhpRqHDRH7TuZ IPuQHAoNaY6HU9dzwr69vUAzPInMUAJUrCAHzlf56/qtYXvnzh2AKQsIfb2wF7kDOZ V5BPo0no7I7hw== Received: from mchehab by mail.kernel.org with local (Exim 4.96) (envelope-from ) id 1p0ijY-00FYFJ-37; Thu, 01 Dec 2022 12:32:08 +0000 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , "Jason A. Donenfeld" , =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8?= =?utf-8?q?rgensen?= , Andi Shyti , Chuck Lever , Daniel Vetter , David Airlie , Jani Nikula , Joonas Lahtinen , Matt Roper , Rodrigo Vivi , Tvrtko Ursulin , Yury Norov , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] drm/i915: place selftest preparation on a separate function Date: Thu, 1 Dec 2022 12:32:05 +0000 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751015080012595745?= X-GMAIL-MSGID: =?utf-8?q?1751015080012595745?= The selftest preparation logic should also be used by KUnit. So, place it on a separate function and export it. Signed-off-by: Mauro Carvalho Chehab --- To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover. See [PATCH 0/3] at: https://lore.kernel.org/all/cover.1669897668.git.mchehab@kernel.org/ drivers/gpu/drm/i915/i915_selftest.h | 2 ++ .../gpu/drm/i915/selftests/i915_selftest.c | 22 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_selftest.h b/drivers/gpu/drm/i915/i915_selftest.h index bdf3e22c0a34..cd0065033ed9 100644 --- a/drivers/gpu/drm/i915/i915_selftest.h +++ b/drivers/gpu/drm/i915/i915_selftest.h @@ -44,6 +44,7 @@ struct i915_selftest { extern struct i915_selftest i915_selftest; +void i915_prepare_selftests(const char *name); int i915_mock_selftests(void); int i915_live_selftests(struct pci_dev *pdev); int i915_perf_selftests(struct pci_dev *pdev); @@ -113,6 +114,7 @@ int __i915_subtests(const char *caller, #else /* !IS_ENABLED(CONFIG_DRM_I915_SELFTEST) */ +static inline void i915_prepare_selftests(const char *) {}; static inline int i915_mock_selftests(void) { return 0; } static inline int i915_live_selftests(struct pci_dev *pdev) { return 0; } static inline int i915_perf_selftests(struct pci_dev *pdev) { return 0; } diff --git a/drivers/gpu/drm/i915/selftests/i915_selftest.c b/drivers/gpu/drm/i915/selftests/i915_selftest.c index 39da0fb0d6d2..bc85dac4eb15 100644 --- a/drivers/gpu/drm/i915/selftests/i915_selftest.c +++ b/drivers/gpu/drm/i915/selftests/i915_selftest.c @@ -127,13 +127,8 @@ static void set_default_test_all(struct selftest *st, unsigned int count) st[i].enabled = true; } -static int __run_selftests(const char *name, - struct selftest *st, - unsigned int count, - void *data) +void i915_prepare_selftests(const char *name) { - int err = 0; - while (!i915_selftest.random_seed) i915_selftest.random_seed = get_random_u32(); @@ -142,10 +137,21 @@ static int __run_selftests(const char *name, msecs_to_jiffies_timeout(i915_selftest.timeout_ms) : MAX_SCHEDULE_TIMEOUT; - set_default_test_all(st, count); - pr_info(DRIVER_NAME ": Performing %s selftests with st_random_seed=0x%x st_timeout=%u\n", name, i915_selftest.random_seed, i915_selftest.timeout_ms); +} +EXPORT_SYMBOL_NS_GPL(i915_prepare_selftests, I915_SELFTEST); + +static int __run_selftests(const char *name, + struct selftest *st, + unsigned int count, + void *data) +{ + int err = 0; + + i915_prepare_selftests(name); + + set_default_test_all(st, count); /* Tests are listed in order in i915_*_selftests.h */ for (; count--; st++) { From patchwork Thu Dec 1 12:32:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 28356 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp239507wrr; Thu, 1 Dec 2022 04:46:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf7J/PG6qPueEx0BntYMwABiB3fMVoFCpf1AqfFQGwkAlnZO6AI7y67yRE8b8OpY/GF1uwPc X-Received: by 2002:a17:90a:a08:b0:219:7ec6:8f4a with SMTP id o8-20020a17090a0a0800b002197ec68f4amr1541533pjo.184.1669898776668; Thu, 01 Dec 2022 04:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669898776; cv=none; d=google.com; s=arc-20160816; b=L9aeWi9ZY0XzQ+CjezVWk/kvskw+ZU3axYw+Dio6zY4wVrYTTXcnztEOzw0AbTPiIg AleD+g9I37rF8N6S0cjPYbnZh5v88HZOUmPSlew/XRaXSPDrsYQmoeDRPEv6X2lGU22W cNt1kCNbeihQX5+U3BC2neKdfwV0/h+hzWFtUgznEufHtJ9RY/PwDzjykufbTTaCT7S5 BdAP2UY55Pb9b7xRt8r5g5Ed3bxTq0F7gSlkqzzOmuoVsKEXiR43lgWFZ5z4AzG93QET f9mk4TBzA/A97OrVK3rVkfBmu6gcEntp+b1C9NKZ8zrTrZvsKVLB6wRZiiatMIDzJsLv KQ2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=mqlrj6hB5dbdYRwEEf9n8PJoQbqkdTVAk/nJLK8iSU4=; b=SvaVFtP3KbFNNN+oniZy2W5npZHyO7c1+z6WUqBNJl9TnC4yh/+wi1MIlvYQcxeZEf WYYF9qhmpdGotb8aWMJWYOIm6SGkxYs7gEqCWtd3glwMBJUh3KLettGgdsMTAx/9dYuK Ex5BoQ5JOxFBcNefTSj62CygwjPhuTa+AohPCXBdT7EVhUdrERgzO4WFb/kqtj41DLHw 5oJTKI/QJxNeQMXq9l9MQiNewNnR2VWLu1HZtbpIaQlg2X+DCcuqz/5fPfn23TIXIk5h YbduSgOmRsF4aLwV78nerwqWsUQRH9mAgzUYhNUcdvNH+Ua2m364CK1CJnBiiyYERJZS DY0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=hwMCScF9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a63d448000000b00477c498cca3si4293092pgj.55.2022.12.01.04.46.02; Thu, 01 Dec 2022 04:46:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=hwMCScF9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231437AbiLAMc0 (ORCPT + 99 others); Thu, 1 Dec 2022 07:32:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbiLAMcS (ORCPT ); Thu, 1 Dec 2022 07:32:18 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C77FBA0A6 for ; Thu, 1 Dec 2022 04:32:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id DAE03CE1C78 for ; Thu, 1 Dec 2022 12:32:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5F6EC433B5; Thu, 1 Dec 2022 12:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669897931; bh=cyq5kIRv82DEDlrrKEjscpNYjNg7wkLn5qZtpqQLPDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hwMCScF9Rw+XyaDy5ow4vQgD3EQfqQYLkKlojLHUk2T7qmDxfQR3etHzaUPbIP6mT /e/uFkoFEsT+9mxLYMApnoDEq01ctopUcmYzxXdSQkAqZ5lI8tPM2sPYjJ/kd8Jw9v SV7ra4o0yDVSuj+Zsl2Azo9mmPYmDWwYH/e2V5DvzFXCPwP7fBPaWQofIVxy8K5w5l 4yWCyT/nLSdhZ/0lCyF98b1EzQ6nE/IAZpl8H0cSYWGLCNy5qvoJidzB28UOLCuHtF uiYVy7IHer5V7oNErrv2SXSWin+V2LQ8XHhyElyUV8C8pabSbGgrf7EpwNoHIT8zWY rF1hoglFLqt8g== Received: from mchehab by mail.kernel.org with local (Exim 4.96) (envelope-from ) id 1p0ijZ-00FYFM-0H; Thu, 01 Dec 2022 12:32:09 +0000 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , =?utf-8?q?Christian_K=C3=B6n?= =?utf-8?q?ig?= , "Jason A. Donenfeld" , "Michael J. Ruhl" , =?utf-8?q?Micha=C5=82_Winiars?= =?utf-8?q?ki?= , =?utf-8?q?Thomas_Hellstr=C3=B6?= =?utf-8?q?m?= , =?utf-8?q?Toke_H=C3=B8ila?= =?utf-8?q?nd-J=C3=B8rgensen?= , =?utf-8?b?VmlsbGUgU3lyasOk?= =?utf-8?b?bMOk?= , Alan Previn , Andi Shyti , Andrzej Hajda , Arunpravin , Daniel Vetter , David Airlie , Dmitry Osipenko , Harish Chegondi , Jan Kara , Jani Nikula , John Harrison , Joonas Lahtinen , Kees Cook , Lionel Landwerlin , Lucas De Marchi , Maarten Lankhorst , Matt Atwood , Matt Roper , Matthew Auld , Matthew Brost , Niranjana Vishwanathapura , Nirmoy Das , Robert Beckett , Rodrigo Vivi , Sujaritha Sundaresan , Tvrtko Ursulin , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] drm/i915: export all mock selftest functions Date: Thu, 1 Dec 2022 12:32:06 +0000 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751015779618493209?= X-GMAIL-MSGID: =?utf-8?q?1751015779618493209?= In order to prepare for a new KUnit module that will run selftests, export all mock selftest functions to I915_SELFTEST namespace. No functional changes. Signed-off-by: Mauro Carvalho Chehab --- To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover. See [PATCH 0/3] at: https://lore.kernel.org/all/cover.1669897668.git.mchehab@kernel.org/ drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 1 + drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c | 1 + drivers/gpu/drm/i915/gem/selftests/i915_gem_object.c | 1 + drivers/gpu/drm/i915/gem/selftests/i915_gem_phys.c | 1 + drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 1 + drivers/gpu/drm/i915/gt/selftest_ring.c | 1 + drivers/gpu/drm/i915/gt/selftest_timeline.c | 1 + drivers/gpu/drm/i915/gt/st_shmem_utils.c | 1 + drivers/gpu/drm/i915/selftests/i915_gem_evict.c | 1 + drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 1 + drivers/gpu/drm/i915/selftests/i915_request.c | 1 + drivers/gpu/drm/i915/selftests/i915_selftest.c | 1 + drivers/gpu/drm/i915/selftests/i915_sw_fence.c | 1 + drivers/gpu/drm/i915/selftests/i915_syncmap.c | 1 + drivers/gpu/drm/i915/selftests/i915_vma.c | 1 + drivers/gpu/drm/i915/selftests/intel_memory_region.c | 1 + drivers/gpu/drm/i915/selftests/intel_uncore.c | 1 + drivers/gpu/drm/i915/selftests/scatterlist.c | 1 + 18 files changed, 18 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c index beaf27e09e8a..954d37552681 100644 --- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c +++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c @@ -1944,6 +1944,7 @@ int i915_gem_huge_page_mock_selftests(void) mock_destroy_device(dev_priv); return err; } +EXPORT_SYMBOL_NS_GPL(i915_gem_huge_page_mock_selftests, I915_SELFTEST); int i915_gem_huge_page_live_selftests(struct drm_i915_private *i915) { diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c index e57f9390076c..2f6422eb9801 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c @@ -543,6 +543,7 @@ int i915_gem_dmabuf_mock_selftests(void) mock_destroy_device(i915); return err; } +EXPORT_SYMBOL_NS_GPL(i915_gem_dmabuf_mock_selftests, I915_SELFTEST); int i915_gem_dmabuf_live_selftests(struct drm_i915_private *i915) { diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_object.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_object.c index bdf5bb40ccf1..4c50be935462 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_object.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_object.c @@ -88,6 +88,7 @@ int i915_gem_object_mock_selftests(void) mock_destroy_device(i915); return err; } +EXPORT_SYMBOL_NS_GPL(i915_gem_object_mock_selftests, I915_SELFTEST); int i915_gem_object_live_selftests(struct drm_i915_private *i915) { diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_phys.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_phys.c index d43d8dae0f69..03cd27066153 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_phys.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_phys.c @@ -85,3 +85,4 @@ int i915_gem_phys_mock_selftests(void) mock_destroy_device(i915); return err; } +EXPORT_SYMBOL_NS_GPL(i915_gem_phys_mock_selftests, I915_SELFTEST); diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c index 881b64f3e7b9..e3e4918b3f9e 100644 --- a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c +++ b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c @@ -437,3 +437,4 @@ int intel_engine_cs_mock_selftests(void) return i915_subtests(tests, NULL); } +EXPORT_SYMBOL_NS_GPL(intel_engine_cs_mock_selftests, I915_SELFTEST); diff --git a/drivers/gpu/drm/i915/gt/selftest_ring.c b/drivers/gpu/drm/i915/gt/selftest_ring.c index 2a8c534dc125..6590c9c504b9 100644 --- a/drivers/gpu/drm/i915/gt/selftest_ring.c +++ b/drivers/gpu/drm/i915/gt/selftest_ring.c @@ -108,3 +108,4 @@ int intel_ring_mock_selftests(void) return i915_subtests(tests, NULL); } +EXPORT_SYMBOL_NS_GPL(intel_ring_mock_selftests, I915_SELFTEST); diff --git a/drivers/gpu/drm/i915/gt/selftest_timeline.c b/drivers/gpu/drm/i915/gt/selftest_timeline.c index 522d0190509c..fcf044c9feea 100644 --- a/drivers/gpu/drm/i915/gt/selftest_timeline.c +++ b/drivers/gpu/drm/i915/gt/selftest_timeline.c @@ -450,6 +450,7 @@ int intel_timeline_mock_selftests(void) return i915_subtests(tests, NULL); } +EXPORT_SYMBOL_NS_GPL(intel_timeline_mock_selftests, I915_SELFTEST); static int emit_ggtt_store_dw(struct i915_request *rq, u32 addr, u32 value) { diff --git a/drivers/gpu/drm/i915/gt/st_shmem_utils.c b/drivers/gpu/drm/i915/gt/st_shmem_utils.c index b279fe88b70e..46c9d4fca1f8 100644 --- a/drivers/gpu/drm/i915/gt/st_shmem_utils.c +++ b/drivers/gpu/drm/i915/gt/st_shmem_utils.c @@ -61,3 +61,4 @@ int shmem_utils_mock_selftests(void) return i915_subtests(tests, NULL); } +EXPORT_SYMBOL_NS_GPL(shmem_utils_mock_selftests, I915_SELFTEST); diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c index 8c6517d29b8e..5461ecc9b6a2 100644 --- a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c +++ b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c @@ -555,6 +555,7 @@ int i915_gem_evict_mock_selftests(void) mock_destroy_device(i915); return err; } +EXPORT_SYMBOL_NS_GPL(i915_gem_evict_mock_selftests, I915_SELFTEST); int i915_gem_evict_live_selftests(struct drm_i915_private *i915) { diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c index eae7d947d7de..0a4c1a061a0c 100644 --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c @@ -1935,6 +1935,7 @@ int i915_gem_gtt_mock_selftests(void) mock_destroy_device(i915); return err; } +EXPORT_SYMBOL_NS_GPL(i915_gem_gtt_mock_selftests, I915_SELFTEST); static int context_sync(struct intel_context *ce) { diff --git a/drivers/gpu/drm/i915/selftests/i915_request.c b/drivers/gpu/drm/i915/selftests/i915_request.c index 0daa8669181d..fda88361619e 100644 --- a/drivers/gpu/drm/i915/selftests/i915_request.c +++ b/drivers/gpu/drm/i915/selftests/i915_request.c @@ -563,6 +563,7 @@ int i915_request_mock_selftests(void) return err; } +EXPORT_SYMBOL_NS_GPL(i915_request_mock_selftests, I915_SELFTEST); static int live_nop_request(void *arg) { diff --git a/drivers/gpu/drm/i915/selftests/i915_selftest.c b/drivers/gpu/drm/i915/selftests/i915_selftest.c index bc85dac4eb15..69941d5a6a31 100644 --- a/drivers/gpu/drm/i915/selftests/i915_selftest.c +++ b/drivers/gpu/drm/i915/selftests/i915_selftest.c @@ -39,6 +39,7 @@ int i915_mock_sanitycheck(void) pr_info(DRIVER_NAME ": %s() - ok!\n", __func__); return 0; } +EXPORT_SYMBOL_NS_GPL(i915_mock_sanitycheck, I915_SELFTEST); int i915_live_sanitycheck(struct drm_i915_private *i915) { diff --git a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c index daa985e5a19b..deccd30fed12 100644 --- a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c +++ b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c @@ -755,3 +755,4 @@ int i915_sw_fence_mock_selftests(void) return i915_subtests(tests, NULL); } +EXPORT_SYMBOL_NS_GPL(i915_sw_fence_mock_selftests, I915_SELFTEST); diff --git a/drivers/gpu/drm/i915/selftests/i915_syncmap.c b/drivers/gpu/drm/i915/selftests/i915_syncmap.c index 47f4ae18a1ef..09b04f280e73 100644 --- a/drivers/gpu/drm/i915/selftests/i915_syncmap.c +++ b/drivers/gpu/drm/i915/selftests/i915_syncmap.c @@ -614,3 +614,4 @@ int i915_syncmap_mock_selftests(void) return i915_subtests(tests, NULL); } +EXPORT_SYMBOL_NS_GPL(i915_syncmap_mock_selftests, I915_SELFTEST); diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c index 71b52d5efef4..ae25bd6c58cd 100644 --- a/drivers/gpu/drm/i915/selftests/i915_vma.c +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c @@ -949,6 +949,7 @@ int i915_vma_mock_selftests(void) mock_destroy_device(i915); return err; } +EXPORT_SYMBOL_NS_GPL(i915_vma_mock_selftests, I915_SELFTEST); static int igt_vma_remapped_gtt(void *arg) { diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c index 3b18e5905c86..91cfd5d5cad2 100644 --- a/drivers/gpu/drm/i915/selftests/intel_memory_region.c +++ b/drivers/gpu/drm/i915/selftests/intel_memory_region.c @@ -1376,6 +1376,7 @@ int intel_memory_region_mock_selftests(void) mock_destroy_device(i915); return err; } +EXPORT_SYMBOL_NS_GPL(intel_memory_region_mock_selftests, I915_SELFTEST); int intel_memory_region_live_selftests(struct drm_i915_private *i915) { diff --git a/drivers/gpu/drm/i915/selftests/intel_uncore.c b/drivers/gpu/drm/i915/selftests/intel_uncore.c index e4281508d580..2b61377d4b60 100644 --- a/drivers/gpu/drm/i915/selftests/intel_uncore.c +++ b/drivers/gpu/drm/i915/selftests/intel_uncore.c @@ -138,6 +138,7 @@ int intel_uncore_mock_selftests(void) return 0; } +EXPORT_SYMBOL_NS_GPL(intel_uncore_mock_selftests, I915_SELFTEST); static int live_forcewake_ops(void *arg) { diff --git a/drivers/gpu/drm/i915/selftests/scatterlist.c b/drivers/gpu/drm/i915/selftests/scatterlist.c index d599186d5b71..d29aa7303b16 100644 --- a/drivers/gpu/drm/i915/selftests/scatterlist.c +++ b/drivers/gpu/drm/i915/selftests/scatterlist.c @@ -378,3 +378,4 @@ int scatterlist_mock_selftests(void) return i915_subtests(tests, NULL); } +EXPORT_SYMBOL_NS_GPL(scatterlist_mock_selftests, I915_SELFTEST); From patchwork Thu Dec 1 12:32:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 28355 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp239388wrr; Thu, 1 Dec 2022 04:46:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf5/X3vJktEa6AQgduvEo9dylQoCXvta9GGhi1T/9hGDXyD6SdPWvq69XoxGdkLI9GiX2QIZ X-Received: by 2002:a17:902:db09:b0:186:def0:4886 with SMTP id m9-20020a170902db0900b00186def04886mr50784296plx.152.1669898763567; Thu, 01 Dec 2022 04:46:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669898763; cv=none; d=google.com; s=arc-20160816; b=JBtu4v+KK+mvgMhj1VnzzsaC3VAsUY2NWov7N0TKQiBmHuvvM/CKCXCaGyq/1D5x9y kHMgolmgh7eE1KZZzFKrTGimxqWk4GaTij2pUq10/Dk82a0d8sjGliy5bH8UnJ5R6D9+ qmkeltzMqkh5mqo5mg031ELDAKcAlepV0kHn41xjPA+5T7iyhvbP795s6l6UEOsnlPJA d5FNhbS0eN5FEa8oeReCXUBY9rY8a8Kc6QWHWiErB9/dOgVi6FNrKxtIG4utMjG8BzVp P+atpxKSO2J3LyrT/K7cHQJBl4R3z/A48BVqNY1eFNytnEMIvT/V9CHCnze7oSJWkYrU bn4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=TPFQEzL04ntMgjHEpKst2SHzPNGuHe+Qgw3ae2rcJ7Q=; b=h3wG724yJUCJ2rvE1AW2cDxKXDQ9ev5H4NrfwHf8Wx/xEcpDhKjjZj7izaHAXS67Mu e7dYeLfdBPpm7XSMOaiYTresHkcaKP4dOIKt/89BgXIs2ylFQIYNVJXu8CvTtxJdV/tI +K/ttmRAGGhY5MCAOs+Zp09FtMLFdlA1g9IFXQ3GE7hfP7npz/nMtm1Puwp8E+WLqkNI DucP/rwrGjpcQJlRxsG6XblY1AwDGUALWd14EGxJO2qslXvnR6MJLtlzt57bfGMtV43q 1ECdhK8xL985GI7ykHJiZYTKolgfEUBMxVvWnMkG8KIzaexrbqCKoD0XRTV2Y456u+jR rh8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=Wmgd0uoX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020a170903230c00b00172f32450b7si4813128plh.197.2022.12.01.04.45.49; Thu, 01 Dec 2022 04:46:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=Wmgd0uoX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231444AbiLAMca (ORCPT + 99 others); Thu, 1 Dec 2022 07:32:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231404AbiLAMcS (ORCPT ); Thu, 1 Dec 2022 07:32:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7721BA0A2 for ; Thu, 1 Dec 2022 04:32:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9E0E861FD5 for ; Thu, 1 Dec 2022 12:32:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CEDFC433C1; Thu, 1 Dec 2022 12:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669897932; bh=bE3kFjU2neWH8m1GKlO5MsjUkp5lf/NUzTJKXV9Lmd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wmgd0uoXnmAnoUuOqJsAuQgC9dooF2H2ZivnFw1R/wbWaEF2Y3QpMAT6YNf9MjENO CDHVGtpRiqCL9IC3DyH+prBocl9qlnoY51xC1fL/NXsM5ibMxZs8BXOayPhAwuKx7F miLFQ30wfHBwzr7YuMnIG/66LSwYREhJ8Wjjbpqdex7G0YrcUQkDrC+aurezFnufL5 4WBdB39PPoiSScTnbWsi7bmolsbMa9pj9bjUdXR+pkwSca4M55w9LAz9fjtMSdDouz cxPwbYHXz4dPnv+5a9ktJ3K3ZXhV0QNfn3g7uebgrbXgd3loINMcx1HT52vyCpnKaW 8xXGig7HjZFbQ== Received: from mchehab by mail.kernel.org with local (Exim 4.96) (envelope-from ) id 1p0ijZ-00FYFR-0X; Thu, 01 Dec 2022 12:32:09 +0000 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Daniel Vetter , David Airlie , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] drm/i915: allow running mock selftests via Kunit Date: Thu, 1 Dec 2022 12:32:07 +0000 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751015765674363715?= X-GMAIL-MSGID: =?utf-8?q?1751015765674363715?= The mock selftests don't require any hardware to run. They can easily run via kunit with qemu or bare metal. Add support for it. With this change, mock selftest can now run in qemu with: $ ./tools/testing/kunit/kunit.py run --arch=x86_64 \ --kunitconfig=drivers/gpu/drm/i915/selftests [16:50:24] Configuring KUnit Kernel ... [16:50:24] Building KUnit Kernel ... Populating config with: $ make ARCH=x86_64 O=.kunit olddefconfig Building with: $ make ARCH=x86_64 O=.kunit --jobs=8 [16:50:32] Starting KUnit Kernel (1/1)... [16:50:32] ============================================================ Running tests with: $ qemu-system-x86_64 -nodefaults -m 1024 -kernel .kunit/arch/x86/boot/bzImage -append 'kunit.enable=1 console=ttyS0 kunit_shutdown=reboot' -no-reboot -nographic -serial stdio [16:50:33] ============ i915 mock selftests (18 subtests) ============= [16:50:33] [PASSED] mock_sanitycheck [16:50:33] [PASSED] mock_shmem [16:50:37] [PASSED] mock_fence [16:50:38] [PASSED] mock_scatterlist [16:50:39] [PASSED] mock_syncmap [16:50:39] [PASSED] mock_uncore [16:50:39] [PASSED] mock_ring [16:50:39] [PASSED] mock_engine [16:50:43] [PASSED] mock_timelines [16:50:45] [PASSED] mock_requests [16:50:45] [PASSED] mock_objects [16:50:45] [PASSED] mock_phys [16:50:45] [PASSED] mock_dmabuf [16:50:50] [PASSED] mock_vma [16:50:51] [PASSED] mock_evict [16:50:53] [PASSED] mock_gtt [16:50:54] [PASSED] mock_hugepages [16:50:55] [PASSED] mock_memory_region [16:50:55] =============== [PASSED] i915 mock selftests =============== [16:50:55] ============================================================ [16:50:55] Testing complete. Ran 18 tests: passed: 18 [16:50:55] Elapsed time: 31.530s total, 0.003s configuring, 8.512s building, 22.974s running It is also possible to run the tests on a bare metal machine, and even collect code coverage data with: $ sudo lcov -z && sudo modprobe test-i915 && sudo rmmod test-i915 && sudo IGT_KERNEL_TREE=~/linux ~/freedesktop-igt/scripts/code_cov_capture mock_selftest Auto-detecting gcov kernel support. Found upstream gcov kernel support at /sys/kernel/debug/gcov Resetting kernel execution counters Done. [627.14] Code coverage wrote to mock_selftest.info The KTAP and Kernel logs will be similar to: [ 596.382685] # Subtest: i915 mock selftests [ 596.382688] 1..18 [ 596.387744] i915: i915_mock_sanitycheck() - ok! [ 596.395423] ok 1 - mock_sanitycheck [ 596.395495] i915: Running shmem_utils_mock_selftests/igt_shmem_basic [ 596.406650] ok 2 - mock_shmem [ 596.406737] i915: Running i915_sw_fence_mock_selftests/test_self [ 596.416868] i915: Running i915_sw_fence_mock_selftests/test_dag [ 596.423220] i915: Running i915_sw_fence_mock_selftests/test_AB [ 596.429585] i915: Running i915_sw_fence_mock_selftests/test_ABC [ 596.435921] i915: Running i915_sw_fence_mock_selftests/test_AB_C [ 596.442293] i915: Running i915_sw_fence_mock_selftests/test_C_AB [ 596.448671] i915: Running i915_sw_fence_mock_selftests/test_chain [ 596.485336] i915: Running i915_sw_fence_mock_selftests/test_ipc [ 596.492984] i915: Running i915_sw_fence_mock_selftests/test_timer [ 602.484395] i915: Running i915_sw_fence_mock_selftests/test_dma_fence [ 603.876315] Asynchronous wait on fence mock:mock:0 timed out (hint:fence_notify [i915]) [ 603.886148] ok 3 - mock_fence [ 603.886377] i915: Running scatterlist_mock_selftests/igt_sg_alloc [ 604.398052] sg_alloc_table timed out [ 604.401979] i915: Running scatterlist_mock_selftests/igt_sg_trim [ 604.909003] i915_sg_trim timed out [ 604.912850] ok 4 - mock_scatterlist [ 604.912987] i915: Running i915_syncmap_mock_selftests/igt_syncmap_init [ 604.924092] i915: Running i915_syncmap_mock_selftests/igt_syncmap_one [ 605.430961] i915: Running i915_syncmap_mock_selftests/igt_syncmap_join_above [ 605.438458] i915: Running i915_syncmap_mock_selftests/igt_syncmap_join_below [ 605.446670] i915: Running i915_syncmap_mock_selftests/igt_syncmap_neighbours [ 606.736462] i915: Running i915_syncmap_mock_selftests/igt_syncmap_compact [ 606.744342] i915: Running i915_syncmap_mock_selftests/igt_syncmap_random [ 607.266569] ok 5 - mock_syncmap [ 607.266771] ok 6 - mock_uncore [ 607.271144] i915: Running intel_ring_mock_selftests/igt_ring_direction [ 607.281872] ok 7 - mock_ring [ 607.282142] i915: Running intel_engine_cs_mock_selftests/intel_mmio_bases_check [ 607.293531] ok 8 - mock_engine [ 607.293654] i915: Running intel_timeline_mock_selftests/mock_hwsp_freelist [ 607.305034] mock: [drm] Using Transparent Hugepages [ 607.310389] mock: [drm] Incompatible option enable_guc=3 - GuC is not supported! [ 607.318223] mock: [drm] Incompatible option enable_guc=3 - HuC is not supported! [ 607.326040] mock: [drm] Incompatible option enable_guc=3 - GuC submission is N/A [ 608.689291] i915: Running intel_timeline_mock_selftests/igt_sync [ 608.698029] i915: Running intel_timeline_mock_selftests/bench_sync [ 608.906628] bench_sync: 53196 random insertions, 1895ns/insert [ 608.915839] bench_sync: 53196 random lookups, 53ns/lookup [ 609.155603] bench_sync: 1048321 in-order insertions, 96ns/insert [ 609.164592] bench_sync: 1048321 in-order lookups, 2ns/lookup [ 609.387580] bench_sync: 7925741 repeated insert/lookups, 9ns/op [ 609.494570] bench_sync: 22777779 cyclic/1 insert/lookups, 4ns/op [ 609.601560] bench_sync: 22764130 cyclic/2 insert/lookups, 4ns/op [ 609.708550] bench_sync: 20866721 cyclic/3 insert/lookups, 4ns/op [ 609.815540] bench_sync: 18824730 cyclic/5 insert/lookups, 5ns/op [ 609.922530] bench_sync: 18970181 cyclic/8 insert/lookups, 5ns/op [ 610.029521] bench_sync: 6831382 cyclic/13 insert/lookups, 14ns/op [ 610.151510] bench_sync: 64217 cyclic/21 insert/lookups, 1563ns/op [ 610.282616] ok 9 - mock_timelines [ 610.283053] mock: [drm] Using Transparent Hugepages [ 610.292383] mock: [drm] Incompatible option enable_guc=3 - GuC is not supported! [ 610.300224] mock: [drm] Incompatible option enable_guc=3 - HuC is not supported! [ 610.308041] mock: [drm] Incompatible option enable_guc=3 - GuC submission is N/A [ 610.316016] i915: Running i915_request_mock_selftests/igt_add_request [ 610.322822] i915: Running i915_request_mock_selftests/igt_wait_request [ 610.844362] i915: Running i915_request_mock_selftests/igt_fence_wait [ 611.363857] i915: Running i915_request_mock_selftests/igt_request_rewind [ 611.371805] i915: Running i915_request_mock_selftests/mock_breadcrumbs_smoketest [ 612.250735] Completed 165 waits for 104816 fence across 16 cpus [ 612.462006] ok 10 - mock_requests [ 612.462987] mock: [drm] Using Transparent Hugepages [ 612.472754] mock: [drm] Incompatible option enable_guc=3 - GuC is not supported! [ 612.480545] mock: [drm] Incompatible option enable_guc=3 - HuC is not supported! [ 612.488383] mock: [drm] Incompatible option enable_guc=3 - GuC submission is N/A [ 612.496394] i915: Running i915_gem_object_mock_selftests/igt_gem_object [ 612.539886] ok 11 - mock_objects [ 612.540722] mock: [drm] Using Transparent Hugepages [ 612.550497] mock: [drm] Incompatible option enable_guc=3 - GuC is not supported! [ 612.558586] mock: [drm] Incompatible option enable_guc=3 - HuC is not supported! [ 612.566459] mock: [drm] Incompatible option enable_guc=3 - GuC submission is N/A [ 612.574445] i915: Running i915_gem_phys_mock_selftests/mock_phys_object [ 612.619821] ok 12 - mock_phys [ 612.620708] mock: [drm] Using Transparent Hugepages [ 612.630193] mock: [drm] Incompatible option enable_guc=3 - GuC is not supported! [ 612.638335] mock: [drm] Incompatible option enable_guc=3 - HuC is not supported! [ 612.646137] mock: [drm] Incompatible option enable_guc=3 - GuC submission is N/A [ 612.654080] i915: Running i915_gem_dmabuf_mock_selftests/igt_dmabuf_export [ 612.661326] i915: Running i915_gem_dmabuf_mock_selftests/igt_dmabuf_import_self [ 612.669021] i915: Running i915_gem_dmabuf_mock_selftests/igt_dmabuf_import [ 612.676285] i915: Running i915_gem_dmabuf_mock_selftests/igt_dmabuf_import_ownership [ 612.688485] i915: Running i915_gem_dmabuf_mock_selftests/igt_dmabuf_export_vmap [ 612.696350] ok 13 - mock_dmabuf [ 612.696939] mock: [drm] Using Transparent Hugepages [ 612.706117] mock: [drm] Incompatible option enable_guc=3 - GuC is not supported! [ 612.714044] mock: [drm] Incompatible option enable_guc=3 - HuC is not supported! [ 612.721922] mock: [drm] Incompatible option enable_guc=3 - GuC submission is N/A [ 612.729895] i915: Running i915_vma_mock_selftests/igt_vma_create [ 613.237460] igt_vma_create timed out: after 41 objects in 43 contexts [ 613.245661] i915: Running i915_vma_mock_selftests/igt_vma_pin1 [ 613.252146] i915: Running i915_vma_mock_selftests/igt_vma_rotate_remap [ 615.995098] i915: Running i915_vma_mock_selftests/igt_vma_partial [ 618.518421] ok 14 - mock_vma [ 618.519367] mock: [drm] Using Transparent Hugepages [ 618.528625] mock: [drm] Incompatible option enable_guc=3 - GuC is not supported! [ 618.536467] mock: [drm] Incompatible option enable_guc=3 - HuC is not supported! [ 618.544330] mock: [drm] Incompatible option enable_guc=3 - GuC submission is N/A [ 618.552318] i915: Running i915_gem_evict_mock_selftests/igt_evict_something [ 618.697340] i915: Running i915_gem_evict_mock_selftests/igt_evict_for_vma [ 618.836366] i915: Running i915_gem_evict_mock_selftests/igt_evict_for_cache_color [ 618.849926] i915: Running i915_gem_evict_mock_selftests/igt_evict_vm [ 618.992647] i915: Running i915_gem_evict_mock_selftests/igt_overcommit [ 619.170384] ok 15 - mock_evict [ 619.171566] mock: [drm] Using Transparent Hugepages [ 619.181351] mock: [drm] Incompatible option enable_guc=3 - GuC is not supported! [ 619.189520] mock: [drm] Incompatible option enable_guc=3 - HuC is not supported! [ 619.197366] mock: [drm] Incompatible option enable_guc=3 - GuC submission is N/A [ 619.205322] i915: Running i915_gem_gtt_mock_selftests/igt_mock_drunk [ 619.712643] drunk_hole timed out after 41097/524288 [ 619.717987] i915: Running i915_gem_gtt_mock_selftests/igt_mock_walk [ 620.225588] walk_hole timed out at a692000 [ 620.230687] i915: Running i915_gem_gtt_mock_selftests/igt_mock_pot [ 620.976730] pot_hole timed out after 19/33 [ 620.981596] i915: Running i915_gem_gtt_mock_selftests/igt_mock_fill [ 621.491729] fill_hole timed out (npages=1, prime=257) [ 621.497424] i915: Running i915_gem_gtt_mock_selftests/igt_gtt_reserve [ 621.620470] i915: Running i915_gem_gtt_mock_selftests/igt_gtt_insert [ 621.891015] ok 16 - mock_gtt [ 621.892018] mock: [drm] Using Transparent Hugepages [ 621.901620] mock: [drm] Incompatible option enable_guc=3 - GuC is not supported! [ 621.909449] mock: [drm] Incompatible option enable_guc=3 - HuC is not supported! [ 621.917347] mock: [drm] Incompatible option enable_guc=3 - GuC submission is N/A [ 621.925497] i915: Running i915_gem_huge_page_mock_selftests/igt_mock_exhaust_device_supported_pages [ 621.937541] i915: Running i915_gem_huge_page_mock_selftests/igt_mock_memory_region_huge_pages [ 621.947479] i915: Running i915_gem_huge_page_mock_selftests/igt_mock_ppgtt_misaligned_dma [ 622.032179] i915: Running i915_gem_huge_page_mock_selftests/igt_mock_ppgtt_huge_fill [ 622.540726] igt_mock_ppgtt_huge_fill timed out at size 61313024 [ 622.547707] i915: Running i915_gem_huge_page_mock_selftests/igt_mock_ppgtt_64K [ 622.944941] ok 17 - mock_hugepages [ 622.945866] mock: [drm] Using Transparent Hugepages [ 622.956054] mock: [drm] Incompatible option enable_guc=3 - GuC is not supported! [ 622.963891] mock: [drm] Incompatible option enable_guc=3 - HuC is not supported! [ 622.971705] mock: [drm] Incompatible option enable_guc=3 - GuC submission is N/A [ 622.979664] i915: Running intel_memory_region_mock_selftests/igt_mock_reserve [ 623.006381] i915: Running intel_memory_region_mock_selftests/igt_mock_fill [ 623.057022] i915: Running intel_memory_region_mock_selftests/igt_mock_contiguous [ 624.040905] i915: Running intel_memory_region_mock_selftests/igt_mock_splintered_region [ 624.075553] i915: Running intel_memory_region_mock_selftests/igt_mock_max_segment [ 624.108598] i915: Running intel_memory_region_mock_selftests/igt_mock_io_size [ 624.116097] igt_mock_io_size with ps=1000, io_size=a7823000, total=1b5fee000 [ 624.133227] igt_mock_io_size mappable theft=(632MiB/2680MiB), total=7007MiB [ 624.204955] ok 18 - mock_memory_region [ 624.204964] # i915 mock selftests: pass:18 fail:0 skip:0 total:18 [ 624.209921] # Totals: pass:18 fail:0 skip:0 total:18 [ 624.216762] ok 1 - i915 mock selftests. They could be parsed with kunit.py with: echo "[ 0.000000] TAP version 14" >logs dmesg >>logs ./tools/testing/kunit/kunit.py parse logs Note: kunit.py is currently broken with modules, not producing any results if "TAP version xx" is not found. It also shows the results duplicated. Signed-off-by: Mauro Carvalho Chehab --- To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover. See [PATCH 0/3] at: https://lore.kernel.org/all/cover.1669897668.git.mchehab@kernel.org/ drivers/gpu/drm/i915/Kconfig | 15 ++++ drivers/gpu/drm/i915/Makefile | 5 ++ drivers/gpu/drm/i915/selftests/.kunitconfig | 12 +++ drivers/gpu/drm/i915/selftests/i915_kunit.c | 95 +++++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 drivers/gpu/drm/i915/selftests/.kunitconfig create mode 100644 drivers/gpu/drm/i915/selftests/i915_kunit.c diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig index 3efce05d7b57..323c63af72d8 100644 --- a/drivers/gpu/drm/i915/Kconfig +++ b/drivers/gpu/drm/i915/Kconfig @@ -53,6 +53,21 @@ config DRM_I915 If "M" is selected, the module will be called i915. +config DRM_I915_KUNIT_TESTS + tristate "KUnit tests for Intel 8xx/9xx/G3x/G4x/HD Graphics" if !KUNIT_ALL_TESTS + depends on DRM_I915 && KUNIT + default KUNIT_ALL_TESTS + help + Builds unit tests for i915 driver. This option is not useful for + distributions or general kernels, but only for kernel + developers working on i915 DRM driver. + + For more information on KUnit and unit tests in general, + please refer to the KUnit documentation in + Documentation/dev-tools/kunit/. + + If in doubt, say "N". + config DRM_I915_FORCE_PROBE string "Force probe driver for selected new Intel hardware" depends on DRM_I915 diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 01974b82d205..26b7437218f2 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -344,6 +344,11 @@ i915-$(CONFIG_DRM_I915_SELFTEST) += \ selftests/igt_spinner.o \ selftests/librapl.o +test-i915-y += selftests/i915_kunit.o +ifneq ($(CONFIG_DRM_I915_SELFTEST),) + obj-$(CONFIG_DRM_I915_KUNIT_TESTS) += test-i915.o +endif + # virtual gpu code i915-y += i915_vgpu.o diff --git a/drivers/gpu/drm/i915/selftests/.kunitconfig b/drivers/gpu/drm/i915/selftests/.kunitconfig new file mode 100644 index 000000000000..98600bbde6b3 --- /dev/null +++ b/drivers/gpu/drm/i915/selftests/.kunitconfig @@ -0,0 +1,12 @@ +# i915 dependencies +CONFIG_KUNIT=y +CONFIG_PCI=y +CONFIG_DRM=y +CONFIG_DRM_I915=y + +# Needed by selftest +CONFIG_EXPERT=y +# PREEMPT_RT is not set + +CONFIG_DRM_I915_SELFTEST=y +CONFIG_DRM_I915_KUNIT_TESTS=y diff --git a/drivers/gpu/drm/i915/selftests/i915_kunit.c b/drivers/gpu/drm/i915/selftests/i915_kunit.c new file mode 100644 index 000000000000..731b84a1fdc3 --- /dev/null +++ b/drivers/gpu/drm/i915/selftests/i915_kunit.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Unit tests for i915 + * + * Copyright © 2022 Intel Corporation + * Author: Mauro Carvalho Chehab + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include "i915_selftest.h" + +/* + * Test run logic, similar to what i915 selftest does + */ + +static void run_mock_test(struct kunit *test, + int (*f)(void)) +{ + int ret; + + cond_resched(); + if (signal_pending(current)) + return; + + pr_info("Running %s\n", test->name); + ret = f(); + + if (ret == -EINTR && !signal_pending(current)) + ret = 0; + + if (WARN(ret > 0 || ret == -ENOTTY, + "%s returned %d, conflicting with selftest's magic values!\n", + test->name, ret)) + ret = -EINVAL; + + KUNIT_EXPECT_EQ(test, ret, 0); +} + +/* + * Test initialization + */ +static int initialize_i915_selftests(struct kunit *test) +{ + i915_prepare_selftests(test->name); + + pr_notice("Setting dangerous option KUnit %s - tainting kernel\n", + test->name); + add_taint(TAINT_USER, LOCKDEP_STILL_OK); + + return 0; +} + +/* + * Test suite 1: mock selftests + */ + +/* Declare selftest functions */ +#define selftest(x, __y) int __y(void); +#include "i915_mock_selftests.h" +#undef selftest + +/* Create selftest functions */ +#define selftest(__x, __y) \ + static void mock_##__x(struct kunit *test) { \ + run_mock_test(test, __y); \ + } +#include "i915_mock_selftests.h" +#undef selftest + +/* Fill tests array */ +#define selftest(__x, __y) KUNIT_CASE(mock_##__x), +static struct kunit_case i915_mock_tests[] = { +#include "i915_mock_selftests.h" + {} +}; +#undef selftest + +/* + * Declare test suites + */ + +static struct kunit_suite i915_test_suites[] = { + { + .name = "i915 mock selftests", + .test_cases = i915_mock_tests, + .init = initialize_i915_selftests, + }, +}; + +kunit_test_suites(i915_test_suites); + +MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(I915_SELFTEST);