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 329A2C352A1 for ; Wed, 7 Dec 2022 05:32:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E60DD10E357; Wed, 7 Dec 2022 05:32:51 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id A492610E357 for ; Wed, 7 Dec 2022 05:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670391168; x=1701927168; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=az4Y7qLl1RWh5nTlN1B3sGygUDwiYpvKNjsS+pcM20g=; b=OAKcUH2YxvO1WIHcidYmQl+TXnTm/ErAPM4ICqlEEjjRxaZDcltho2zp uMWpwEtaOAX/DbC5YYRR1ctAv9WlLFIFixYapAFcHiq3ase2ZKzEho/gq 8fcpS+vkJfl7xc4r/McoU+LvRP2tKLZVkm+om1eh3FEExq+zlqC8K4cqw UUaWlmvdi6FO2ojFjyaDXkP4kUBwfgE56Q77HcawUzmGahuRREUY5Ee3j n2HQT0+3G7+0TXEWq+9+PtRqkjljLkqpRup9GPFLtBc+mYVhIu4Ef3Bad pUqA+wCosO4WQSRWaFBPCiRf1ltGRgDaUPA5oQUb/QAjwgtCr0f/19ppA g==; X-IronPort-AV: E=McAfee;i="6500,9779,10553"; a="403081609" X-IronPort-AV: E=Sophos;i="5.96,223,1665471600"; d="scan'208";a="403081609" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2022 21:32:47 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10553"; a="640125434" X-IronPort-AV: E=Sophos;i="5.96,223,1665471600"; d="scan'208";a="640125434" Received: from adixit-mobl.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.209.85.73]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2022 21:32:47 -0800 Date: Tue, 06 Dec 2022 21:26:26 -0800 Message-ID: <871qpbeqd9.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Riana Tauro In-Reply-To: <20221207051747.3212925-3-riana.tauro@intel.com> References: <20221207051747.3212925-1-riana.tauro@intel.com> <20221207051747.3212925-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 v6 2/3] drm/i915/hwmon: Add hwmon support in libpower for dgfx 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, 06 Dec 2022 21:17:46 -0800, Riana Tauro wrote: > > diff --git a/drivers/gpu/drm/i915/selftests/libpower.c b/drivers/gpu/drm/i915/selftests/libpower.c > index c66e993c5f85..3d4d2dc74a54 100644 > --- a/drivers/gpu/drm/i915/selftests/libpower.c > +++ b/drivers/gpu/drm/i915/selftests/libpower.c > @@ -6,29 +6,28 @@ > #include > > #include "i915_drv.h" > +#include "i915_hwmon.h" > #include "libpower.h" > > -bool libpower_supported(const struct drm_i915_private *i915) > -{ > - /* Discrete cards require hwmon integration */ > - if (IS_DGFX(i915)) > - return false; > - > - return libpower_get_energy_uJ(); > -} > - > -u64 libpower_get_energy_uJ(void) > +u64 libpower_get_energy_uJ(struct intel_gt *gt) Hi Riana, Sorry, we can't do this otherwise the build breaks at this commit which we can't do. Note that the callers of libpower_get_energy_uJ are still using the version without any args (see Patch 3). That is why I had R-b'd patch 3 so that we don't have to do this. It's not really needed. If you really want to do this we'll need to port the version without the gt arg to Patch 2 and then convert everything to the version with gt arg in Patch 3. I really don't think it is worth it. Maybe just go back to the previous version of the series and modify Patch 2 and we'll be done. Thanks. -- Ashutosh > { > unsigned long long power; > u32 units; > + long energy_uJ = 0; > > - if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) > - return 0; > + if (IS_DGFX(gt->i915)) { > + if (i915_hwmon_get_energy(gt, &energy_uJ)) > + return 0; > + } else { > + if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power)) > + return 0; > > - units = (power & 0x1f00) >> 8; > + units = (power & 0x1f00) >> 8; > > - if (rdmsrl_safe(MSR_PP1_ENERGY_STATUS, &power)) > - return 0; > + if (rdmsrl_safe(MSR_PP1_ENERGY_STATUS, &power)) > + return 0; > > - return (1000000 * power) >> units; /* convert to uJ */ > + energy_uJ = (1000000 * power) >> units; /* convert to uJ */ > + } > + return energy_uJ; > } > diff --git a/drivers/gpu/drm/i915/selftests/libpower.h b/drivers/gpu/drm/i915/selftests/libpower.h > index 5352981eb946..e4410a886654 100644 > --- a/drivers/gpu/drm/i915/selftests/libpower.h > +++ b/drivers/gpu/drm/i915/selftests/libpower.h > @@ -8,10 +8,12 @@ > > #include > > -struct drm_i915_private; > +struct intel_gt; > > -bool libpower_supported(const struct drm_i915_private *i915); > - > -u64 libpower_get_energy_uJ(void); > +u64 libpower_get_energy_uJ(struct intel_gt *gt); > > +static inline bool libpower_supported(struct intel_gt *gt) > +{ > + return libpower_get_energy_uJ(gt); > +} > #endif /* SELFTEST_LIBPOWER_H */ > -- > 2.25.1 >