From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5343EEB64D8 for ; Thu, 22 Jun 2023 17:35:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C5C510E59E; Thu, 22 Jun 2023 17:35:19 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 570D910E5A3; Thu, 22 Jun 2023 17:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687455317; x=1718991317; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=qQvuCjvsoem96rKY3S4Dt47cQLOLV1Vhki8UyWDWIg0=; b=WxGK+eX9o14OHUDjN2oKWF4ISg2FgIcPTqqoLQnpWAnJZEtj46lDLjId 4FeiLPSvXuz1/BN/GI95udDNODRq9/jQbpmTA74g+UpJN030vwnTZ2OkD tAf3eyDxBPLNrBV+XfR49eosh5ghjc+BwhQxkv8+FI62zUReYUnD1IyzK w1lWAKwsCpQayFVLty1XVBEsnE1fTFn/mVubal/Dxp5pmhl95ZuP3lZH7 jixtxFMfyjfxpF4rQTgzRIvHTTEy7GmsYrXpRvtWLaSIXcN5ZvSVrwGi3 71oE0ryfUcpdTTOoFQ6z1Lg2WJbG+wkF7NnB0jqgQXf6YnFondAJHv3ey Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="364006606" X-IronPort-AV: E=Sophos;i="6.01,149,1684825200"; d="scan'208";a="364006606" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 10:35:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="718183652" X-IronPort-AV: E=Sophos;i="6.01,149,1684825200"; d="scan'208";a="718183652" Received: from adixit-mobl.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.209.104.164]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 10:35:00 -0700 Date: Thu, 22 Jun 2023 10:33:36 -0700 Message-ID: <87sfajs8pb.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Vinay Belgaumkar In-Reply-To: <20230616155048.1013239-1-vinay.belgaumkar@intel.com> References: <20230616155048.1013239-1-vinay.belgaumkar@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Subject: Re: [Intel-gfx] [igt-dev] [PATCH v3 i-g-t] tests/i915_pm_freq_api: Add a suspend subtest X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Fri, 16 Jun 2023 08:50:48 -0700, Vinay Belgaumkar wrote: > > Verify that SLPC API works as expected after a suspend. Added > another subtest that does multiple GT resets and checks freq api > works as expected after each one. > > We now check requested frequency instead of soft min/max after a > reset or suspend. That ensures the soft limits got applied > correctly at init. Also, disable efficient freq before starting the > test which allows current freq to be consistent with SLPC min freq. > Reviewed-by: Ashutosh Dixit > v2: Restore freq in exit handler (Ashutosh) > v3: Free the allocated stash arrays > > Signed-off-by: Vinay Belgaumkar > --- > tests/i915/i915_pm_freq_api.c | 92 +++++++++++++++++++++++++++-------- > 1 file changed, 71 insertions(+), 21 deletions(-) > > diff --git a/tests/i915/i915_pm_freq_api.c b/tests/i915/i915_pm_freq_api.c > index 9005cd220..522abee35 100644 > --- a/tests/i915/i915_pm_freq_api.c > +++ b/tests/i915/i915_pm_freq_api.c > @@ -18,6 +18,12 @@ > * > * SUBTEST: freq-reset > * Description: Test basic freq API works after a reset > + * > + * SUBTEST: freq-reset-multiple > + * Description: Test basic freq API works after multiple resets > + * > + * SUBTEST: freq-suspend > + * Description: Test basic freq API works after a runtime suspend > */ > > IGT_TEST_DESCRIPTION("Test SLPC freq API"); > @@ -49,7 +55,6 @@ static void test_freq_basic_api(int dirfd, int gt) > rpn = get_freq(dirfd, RPS_RPn_FREQ_MHZ); > rp0 = get_freq(dirfd, RPS_RP0_FREQ_MHZ); > rpe = get_freq(dirfd, RPS_RP1_FREQ_MHZ); > - igt_info("System min freq: %dMHz; max freq: %dMHz\n", rpn, rp0); > > /* > * Negative bound tests > @@ -79,31 +84,66 @@ static void test_freq_basic_api(int dirfd, int gt) > > } > > -static void test_reset(int i915, int dirfd, int gt) > +static void test_reset(int i915, int dirfd, int gt, int count) > { > uint32_t rpn = get_freq(dirfd, RPS_RPn_FREQ_MHZ); > int fd; > > + for (int i = 0; i < count; i++) { > + igt_assert_f(set_freq(dirfd, RPS_MIN_FREQ_MHZ, rpn) > 0, > + "Failed after %d good cycles\n", i); > + igt_assert_f(set_freq(dirfd, RPS_MAX_FREQ_MHZ, rpn) > 0, > + "Failed after %d good cycles\n", i); > + usleep(ACT_FREQ_LATENCY_US); > + igt_assert_f(get_freq(dirfd, RPS_CUR_FREQ_MHZ) == rpn, > + "Failed after %d good cycles\n", i); > + > + /* Manually trigger a GT reset */ > + fd = igt_debugfs_gt_open(i915, gt, "reset", O_WRONLY); > + igt_require(fd >= 0); > + igt_ignore_warn(write(fd, "1\n", 2)); > + > + igt_assert_f(get_freq(dirfd, RPS_CUR_FREQ_MHZ) == rpn, > + "Failed after %d good cycles\n", i); > + } > + close(fd); > +} > + > +static void test_suspend(int i915, int dirfd, int gt) > +{ > + uint32_t rpn = get_freq(dirfd, RPS_RPn_FREQ_MHZ); > + > igt_assert(set_freq(dirfd, RPS_MIN_FREQ_MHZ, rpn) > 0); > igt_assert(set_freq(dirfd, RPS_MAX_FREQ_MHZ, rpn) > 0); > usleep(ACT_FREQ_LATENCY_US); > - igt_assert(get_freq(dirfd, RPS_MIN_FREQ_MHZ) == rpn); > + igt_assert(get_freq(dirfd, RPS_CUR_FREQ_MHZ) == rpn); > > - /* Manually trigger a GT reset */ > - fd = igt_debugfs_gt_open(i915, gt, "reset", O_WRONLY); > - igt_require(fd >= 0); > - igt_ignore_warn(write(fd, "1\n", 2)); > - close(fd); > + /* Manually trigger a suspend */ > + igt_system_suspend_autoresume(SUSPEND_STATE_S3, > + SUSPEND_TEST_NONE); > > - igt_assert(get_freq(dirfd, RPS_MIN_FREQ_MHZ) == rpn); > - igt_assert(get_freq(dirfd, RPS_MAX_FREQ_MHZ) == rpn); > + igt_assert(get_freq(dirfd, RPS_CUR_FREQ_MHZ) == rpn); > } > > -igt_main > +int i915 = -1; > +uint32_t *stash_min, *stash_max; > + > +static void restore_sysfs_freq(int sig) > { > - int i915 = -1; > - uint32_t *stash_min, *stash_max; > + int dirfd, gt; > + /* Restore frequencies */ > + for_each_sysfs_gt_dirfd(i915, dirfd, gt) { > + igt_pm_ignore_slpc_efficient_freq(i915, dirfd, false); > + igt_assert(set_freq(dirfd, RPS_MAX_FREQ_MHZ, stash_max[gt]) > 0); > + igt_assert(set_freq(dirfd, RPS_MIN_FREQ_MHZ, stash_min[gt]) > 0); > + } > + free(stash_min); > + free(stash_max); > + close(i915); > +} > > +igt_main > +{ > igt_fixture { > int num_gts, dirfd, gt; > > @@ -122,7 +162,9 @@ igt_main > for_each_sysfs_gt_dirfd(i915, dirfd, gt) { > stash_min[gt] = get_freq(dirfd, RPS_MIN_FREQ_MHZ); > stash_max[gt] = get_freq(dirfd, RPS_MAX_FREQ_MHZ); > + igt_pm_ignore_slpc_efficient_freq(i915, dirfd, true); > } > + igt_install_exit_handler(restore_sysfs_freq); > } > > igt_describe("Test basic API for controlling min/max GT frequency"); > @@ -140,16 +182,24 @@ igt_main > > for_each_sysfs_gt_dirfd(i915, dirfd, gt) > igt_dynamic_f("gt%u", gt) > - test_reset(i915, dirfd, gt); > + test_reset(i915, dirfd, gt, 1); > } > > - igt_fixture { > + igt_describe("Test basic freq API works after multiple resets"); > + igt_subtest_with_dynamic_f("freq-reset-multiple") { > int dirfd, gt; > - /* Restore frequencies */ > - for_each_sysfs_gt_dirfd(i915, dirfd, gt) { > - igt_assert(set_freq(dirfd, RPS_MAX_FREQ_MHZ, stash_max[gt]) > 0); > - igt_assert(set_freq(dirfd, RPS_MIN_FREQ_MHZ, stash_min[gt]) > 0); > - } > - close(i915); > + > + for_each_sysfs_gt_dirfd(i915, dirfd, gt) > + igt_dynamic_f("gt%u", gt) > + test_reset(i915, dirfd, gt, 50); > + } > + > + igt_describe("Test basic freq API works after suspend"); > + igt_subtest_with_dynamic_f("freq-suspend") { > + int dirfd, gt; > + > + for_each_sysfs_gt_dirfd(i915, dirfd, gt) > + igt_dynamic_f("gt%u", gt) > + test_suspend(i915, dirfd, gt); > } > } > -- > 2.38.1 >