All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	igt-dev@lists.freedesktop.org,
	Riana Tauro <riana.tauro@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t 1/2] i915/i915_power: Sanity check power measurement
Date: Thu, 26 Jan 2023 22:28:20 -0800	[thread overview]
Message-ID: <87pmb0fq4b.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20230125094018.rqgl6ggmfksqw3ge@kamilkon-desk1>

On Wed, 25 Jan 2023 01:40:18 -0800, Kamil Konieczny wrote:
>
> Hi,
>

Hi Kamil,

Not exactly what you said but pretty close. Please take a look at the
latest version:

https://patchwork.freedesktop.org/series/113412/

Thanks.
--
Ashutosh


> On 2023-01-24 at 10:01:35 -0800, Dixit, Ashutosh wrote:
> > On Tue, 24 Jan 2023 09:00:23 -0800, Kamil Konieczny wrote:
> > >
> > > Hi Ashutosh,
> > >
> > > one nit, see below.
> >
> > Hi Kamil,
> >
> > >
> > > On 2023-01-20 at 21:41:52 -0800, Ashutosh Dixit wrote:
> > > > Add a test to sanity check power measurement on integrated/discrete by
> > > > requiring power under load to be > 0 and >= idle power.
> > > >
> > > > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> > > > ---
> > > >  tests/i915/i915_power.c | 73 +++++++++++++++++++++++++++++++++++++++++
> > > >  tests/meson.build       |  1 +
> > > >  2 files changed, 74 insertions(+)
> > > >  create mode 100644 tests/i915/i915_power.c
> > > >
> > > > diff --git a/tests/i915/i915_power.c b/tests/i915/i915_power.c
> > > > new file mode 100644
> > > > index 00000000000..e7d5c32f1af
> > > > --- /dev/null
> > > > +++ b/tests/i915/i915_power.c
> > > > @@ -0,0 +1,73 @@
> > > > +// SPDX-License-Identifier: MIT
> > > > +/*
> > > > + * Copyright © 2022 Intel Corporation
> > > > + */
> > > > +
> > > > +#include "igt.h"
> > > > +#include "i915/gem.h"
> > > > +#include "igt_power.h"
> > > > +
> > > > +IGT_TEST_DESCRIPTION("i915 power measurement tests");
> > > > +
> > > > +static double power(int i915, const char *domain, bool load)
> -------------------------------------------------------- ^
> Maybe re-organize you test code and put this into sanity() function
> along with igt_require, context and spinner creation ?
>
> imho this function should be simple and it should return only
> power consumed.
>
> > > > +{
> > > > +	const intel_ctx_t *ctx = intel_ctx_create_all_physical(i915);
> > > > +	uint64_t ahnd = get_reloc_ahnd(i915, ctx->id);
> > > > +	struct power_sample sample[2];
> > > > +	int sleep_duration_sec = 2;
> -------------------------------- ^
> imho make it define or const
>
> > > > +	struct igt_power pwr;
> > > > +	igt_spin_t *spin;
> > > > +	double mW;
> > > > +
> > > > +	gem_quiescent_gpu(i915);
> > > > +	if (load) {
> > > > +		spin = igt_spin_new(i915, .ahnd = ahnd, .ctx = ctx,
> > > > +				    .engine = ALL_ENGINES,
> > > > +				    .flags = IGT_SPIN_POLL_RUN);
> > > > +		/* Wait till at least one spinner starts */
> > > > +		igt_spin_busywait_until_started(spin);
> > > > +	}
> > > > +
> > > > +	igt_require(!igt_power_open(i915, &pwr, domain));
> > >
> > > Please move this before igt_spin_new,
> >
> > Sure, I can move this to the top of the function.
> >
> > > also rewrite this so you will free context before
> >
> > Sorry, before what? I don't want to free the context before igt_free_spins
> > because that requires context persistence which is not fully supported on
> > GuC based systems.
> >
> > > or move context creation to igt_fixture and give it as param for this
> > > function.
> >
> > Here I consider the context internal to the power measurement so I prefer
> > to keep it in this function.
> >
> > But if you explain the reason why you are asking for these changes maybe I
> > can figure out what to do.
> >
> > Do you just want to create the context after igt_require?
>
> Yes this is what I mean, context and spinner should be created
> after check(s) for skip.
>
> > > > +	igt_power_get_energy(&pwr, &sample[0]);
> > > > +	usleep(sleep_duration_sec * USEC_PER_SEC);
> > > > +	igt_power_get_energy(&pwr, &sample[1]);
> > > > +
> > > > +	mW = igt_power_get_mW(&pwr, &sample[0], &sample[1]);
> > > > +	igt_info("Domain: %s, Load: %d, Measured power: %g mW\n", domain, load, mW);
>
> This print will be better placed in sanity() function.
>
> Regards,
> Kamil
>
> > > > +
> > > > +	igt_power_close(&pwr);
> > > > +	igt_free_spins(i915);
> > > > +	put_ahnd(ahnd);
> > > > +	intel_ctx_destroy(i915, ctx);
> > > > +
> > > > +	return mW;
> > > > +}
> > > > +
> > > > +static void sanity(int i915, const char *domain)
> > > > +{
> > > > +	double idle, busy;
> > > > +
> > > > +	idle = power(i915, domain, false);
> > > > +	busy = power(i915, domain, true);
> > > > +
> > > > +	igt_assert(busy > 0 && busy >= idle);
> > > > +}
> > > > +
> > > > +igt_main
> > > > +{
> > > > +	int i915;
> > > > +
> > > > +	igt_fixture {
> > > > +		i915 = drm_open_driver_master(DRIVER_INTEL);
> > > > +	}
> > > > +
> > > > +	igt_describe("Sanity check power measurement");
> > > > +	igt_subtest("sanity") {
> > > > +		sanity(i915, "gpu");
> > > > +	}
> > > > +
> > > > +	igt_fixture {
> > > > +		close(i915);
> > > > +	}
> > > > +}
> > > > diff --git a/tests/meson.build b/tests/meson.build
> > > > index e20a864035b..e0f41e9e6a1 100644
> > > > --- a/tests/meson.build
> > > > +++ b/tests/meson.build
> > > > @@ -212,6 +212,7 @@ i915_progs = [
> > > >	'i915_pm_dc',
> > > >	'i915_pm_rps',
> > > >	'i915_pm_sseu',
> > > > +	'i915_power',
> > > >	'i915_query',
> > > >	'i915_selftest',
> > > >	'i915_suspend',
> > > > --
> > > > 2.38.0
> > > >

  reply	other threads:[~2023-01-27  6:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21  5:41 [igt-dev] [PATCH i-g-t 0/2] i915/i915_power: Sanity check power measurement Ashutosh Dixit
2023-01-21  5:41 ` [igt-dev] [PATCH i-g-t 1/2] " Ashutosh Dixit
2023-01-24 12:59   ` Tauro, Riana
2023-01-24 17:00   ` Kamil Konieczny
2023-01-24 18:01     ` Dixit, Ashutosh
2023-01-25  9:40       ` Kamil Konieczny
2023-01-27  6:28         ` Dixit, Ashutosh [this message]
2023-01-21  5:41 ` [igt-dev] [PATCH i-g-t 2/2] HAX: Add i915_power@sanity to fast-feedback.testlist Ashutosh Dixit
2023-01-21  6:10 ` [igt-dev] ✓ Fi.CI.BAT: success for i915/i915_power: Sanity check power measurement Patchwork
2023-01-21 22:30 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2023-01-27  6:25 [igt-dev] [PATCH i-g-t 0/2] " Ashutosh Dixit
2023-01-27  6:25 ` [igt-dev] [PATCH i-g-t 1/2] " Ashutosh Dixit
2023-01-27 12:29   ` Kamil Konieczny
2023-01-27 16:13     ` Dixit, Ashutosh
2023-01-27 16:08 [igt-dev] [PATCH i-g-t 0/2] " Ashutosh Dixit
2023-01-27 16:08 ` [igt-dev] [PATCH i-g-t 1/2] " Ashutosh Dixit
2023-01-27 16:46   ` Kamil Konieczny
2023-01-27 16:55     ` Dixit, Ashutosh
2023-01-27 17:44       ` Kamil Konieczny
2023-01-27 18:12         ` Dixit, Ashutosh
2023-01-27 18:09 [igt-dev] [PATCH i-g-t 0/2] " Ashutosh Dixit
2023-01-27 18:09 ` [igt-dev] [PATCH i-g-t 1/2] " Ashutosh Dixit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmb0fq4b.wl-ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=riana.tauro@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.