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++) {