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 C98A6C4332F for ; Fri, 2 Dec 2022 22:12:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A52D510E177; Fri, 2 Dec 2022 22:12:53 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B3C810E177 for ; Fri, 2 Dec 2022 22:12:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670019170; x=1701555170; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=BmIwgWPyUX5xvFFanPqC8cZ+d5o9dsFhcgqDpGMju3o=; b=U5wcEif1adQH7GPyKxLAC8ujoBVnzGzWNQhKrykNCrkB8pCfasHECDCt erqylQLwXH9HJ+jnuS3QhIi51Osd03eN2tLxRIcfUvts2Jx9CrVBRY0jD wEDuvxl6wJwF+x8cNOvAOa8rrf5CAaQN6Lx/rnhtWPgBVMhwmkK5sonRw WHxxGkXDWWuDFyoJCE5PV+u7Sw8BBNgrNpoAMcXvpxjZES5jb3BF+Ybxf pz9oO9d4tOC22XnHjUodfxdx9HfjnN0ltBk4XykF2uyrfnqw7h+xCSEqH 3Cs5SnV43Wo+6kBd9F6kdDjCo1E4BGkWtE1yTeDOUT2vWbwQF8mQvibga w==; X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="314763824" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="314763824" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 14:12:49 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="677751513" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="677751513" Received: from adixit-mobl.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.212.164.213]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 14:12:49 -0800 Date: Fri, 02 Dec 2022 14:12:48 -0800 Message-ID: <87a6455uan.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Riana Tauro In-Reply-To: <20221130053427.2207600-3-riana.tauro@intel.com> References: <20221130053427.2207600-1-riana.tauro@intel.com> <20221130053427.2207600-3-riana.tauro@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] [PATCH v5 2/3] drm/i915/hwmon: Add helper function to obtain energy values 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: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Tue, 29 Nov 2022 21:34:26 -0800, Riana Tauro wrote: > Hi Riana, Mostly looks good but I have a little nit below. > diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c > index c588a17f97e9..57d4e96d5c72 100644 > --- a/drivers/gpu/drm/i915/i915_hwmon.c > +++ b/drivers/gpu/drm/i915/i915_hwmon.c > @@ -442,6 +442,34 @@ hwm_energy_read(struct hwm_drvdata *ddat, u32 attr, long *val) > } > } > > +/** > + * i915_hwmon_get_energy - obtains energy value > + * @gt: intel_gt structure > + * @energy: pointer to store energy in uJ > + * > + * This function checks for the validity of the underlying energy > + * hardware register and obtains the per-gt/package level energy Do we every use this function to find real package level energy? I don't see it. I think what we mean here is that package level energy if there's only one gt and gt level energy is not available, correct? So I think we should make this explicit in the code below. Also change the comment above to say only per-gt level energy. > + * values. > + * > + * Return: 0 on success, -EOPNOTSUPP if register is invalid > + */ > +int > +i915_hwmon_get_energy(struct intel_gt *gt, long *energy) > +{ > + struct i915_hwmon *hwmon = gt->i915->hwmon; > + struct hwm_drvdata *ddat = &hwmon->ddat; > + struct hwm_drvdata *ddat_gt = hwmon->ddat_gt + gt->info.id; > + > + if (hwm_energy_is_visible(ddat_gt, hwmon_energy_input)) > + hwm_energy(ddat_gt, energy); > + else if (hwm_energy_is_visible(ddat, hwmon_energy_input)) So if we get here and we are finding gt level energy there must be only one gt, correct? So probably we need to do something like (maybe in intel_gt.h?): static inline int intel_num_gt(struct drm_i915_private *i915) { struct intel_gt *gt; int num_gt = 0, i; for_each_gt(gt, i915, i) num_gt++; return num_gt; } And then the above check becomes: else if (intel_num_gt() == 1 && hwm_energy_is_visible(ddat, hwmon_energy_input)) So this way we are basically always returning gt level energy from i915_hwmon_get_energy. If ever we need package level energy in the future we can add a new function which takes a 'struct drm_i915_private *i915' arg (and uses i915->hwmon->ddat). Thanks. -- Ashutosh > + hwm_energy(ddat, energy); > + else > + return -EOPNOTSUPP; > + > + return 0; > +} > + > static umode_t > hwm_curr_is_visible(const struct hwm_drvdata *ddat, u32 attr) > { > diff --git a/drivers/gpu/drm/i915/i915_hwmon.h b/drivers/gpu/drm/i915/i915_hwmon.h > index 7ca9cf2c34c9..1c38cfdbb7e9 100644 > --- a/drivers/gpu/drm/i915/i915_hwmon.h > +++ b/drivers/gpu/drm/i915/i915_hwmon.h > @@ -8,13 +8,16 @@ > #define __I915_HWMON_H__ > > struct drm_i915_private; > +struct intel_gt; > > #if IS_REACHABLE(CONFIG_HWMON) > void i915_hwmon_register(struct drm_i915_private *i915); > void i915_hwmon_unregister(struct drm_i915_private *i915); > +int i915_hwmon_get_energy(struct intel_gt *gt, long *energy); > #else > static inline void i915_hwmon_register(struct drm_i915_private *i915) { }; > static inline void i915_hwmon_unregister(struct drm_i915_private *i915) { }; > +static inline int i915_hwmon_get_energy(struct intel_gt *gt, long *energy) { return -EOPNOTSUPP; } > #endif > > #endif /* __I915_HWMON_H__ */ > -- > 2.25.1 >