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 3CA95CDB484 for ; Wed, 18 Oct 2023 13:06:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8062010E3EB; Wed, 18 Oct 2023 13:06:21 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D1A110E08E; Wed, 18 Oct 2023 09:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697619653; x=1729155653; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=Bz4RQKoB2bOF4jPSwqa+tusF8wmGmJ55+wiIyaWo9o4=; b=O8uyFyH3chwvrJ5molauAbx95kDgiUoBYBMlhrrMywnQTTOnzYRl+Cxx TkTvuzgtWmA5OMUQhHh2R6gfD5ohDHthawO59VqKE3a6YLF3nf1nb36Av AJYDIZIp4XKX69Ro44WmzZULVkCoiajXD/ypvwF3iejRzpCQGvpqu+AR9 b3pyp3xCb1uaaNXIyyFNKHe6EahK9QtKiKc/7vIbRbse51gvifGr08gtX hYs4uRSj9D9vDGp27bZZLwStDcxgJxJLOn2yOKgSejN/oemi1f8r4Y+s6 PH2Quv7TqwWEEpWkGIdxh8iRDTwCLOfycSOeVR8JbIsTmW2g0w9Sw3hk/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="384852898" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="384852898" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 02:00:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="760147861" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="760147861" Received: from gruberda-mobl1.ger.corp.intel.com ([10.252.62.52]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 02:00:46 -0700 Date: Wed, 18 Oct 2023 12:00:44 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Shyam Sundar S K Subject: Re: [PATCH v4 10/17] platform/x86/amd/pmf: Add facility to dump TA inputs In-Reply-To: <20231018070241.2041529-11-Shyam-sundar.S-k@amd.com> Message-ID: References: <20231018070241.2041529-1-Shyam-sundar.S-k@amd.com> <20231018070241.2041529-11-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Mailman-Approved-At: Wed, 18 Oct 2023 13:06:18 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xinhui.Pan@amd.com, Patil.Reddy@amd.com, basavaraj.natikar@amd.com, dri-devel@lists.freedesktop.org, jikos@kernel.org, amd-gfx@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, markgross@kernel.org, Hans de Goede , benjamin.tissoires@redhat.com, mario.limonciello@amd.com, daniel@ffwll.ch, linux-input@vger.kernel.org, alexander.deucher@amd.com, airlied@gmail.com, christian.koenig@amd.com Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" On Wed, 18 Oct 2023, Shyam Sundar S K wrote: > PMF driver sends constant inputs to TA which its gets via the other > subsystems in the kernel. To debug certain TA issues knowing what inputs > being sent to TA becomes critical. Add debug facility to the driver which > can isolate Smart PC and TA related issues. > > Also, make source_as_str() as non-static function as this helper is > required outside of sps.c file. > > Reviewed-by: Mario Limonciello > Signed-off-by: Shyam Sundar S K > --- > drivers/platform/x86/amd/pmf/pmf.h | 3 +++ > drivers/platform/x86/amd/pmf/spc.c | 37 +++++++++++++++++++++++++++ > drivers/platform/x86/amd/pmf/tee-if.c | 1 + > 3 files changed, 41 insertions(+) > > diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h > index 216a9f795436..593930519039 100644 > --- a/drivers/platform/x86/amd/pmf/pmf.h > +++ b/drivers/platform/x86/amd/pmf/pmf.h > @@ -602,6 +602,7 @@ bool is_pprof_balanced(struct amd_pmf_dev *pmf); > int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev); > const char *amd_pmf_source_as_str(unsigned int state); > > +const char *amd_pmf_source_as_str(unsigned int state); > > int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx); > int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf); > @@ -632,4 +633,6 @@ int apmf_check_smart_pc(struct amd_pmf_dev *pmf_dev); > > /* Smart PC - TA interfaces */ > void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); > +void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); > + > #endif /* PMF_H */ > diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c > index bd5061fdfdbe..512e0c66efdc 100644 > --- a/drivers/platform/x86/amd/pmf/spc.c > +++ b/drivers/platform/x86/amd/pmf/spc.c > @@ -14,6 +14,43 @@ > #include > #include "pmf.h" > > +#ifdef CONFIG_AMD_PMF_DEBUG > +static const char *ta_slider_as_str(unsigned int state) > +{ > + switch (state) { > + case TA_BEST_PERFORMANCE: > + return "PERFORMANCE"; > + case TA_BETTER_PERFORMANCE: > + return "BALANCED"; > + case TA_BEST_BATTERY: > + return "POWER_SAVER"; > + default: > + return "Unknown TA Slider State"; > + } > +} > + > +void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) > +{ > + dev_dbg(dev->dev, "==== TA inputs START ====\n"); > + dev_dbg(dev->dev, "Slider State : %s\n", ta_slider_as_str(in->ev_info.power_slider)); > + dev_dbg(dev->dev, "Power Source : %s\n", amd_pmf_source_as_str(in->ev_info.power_source)); > + dev_dbg(dev->dev, "Battery Percentage : %u\n", in->ev_info.bat_percentage); > + dev_dbg(dev->dev, "Designed Battery Capacity : %u\n", in->ev_info.bat_design); > + dev_dbg(dev->dev, "Fully Charged Capacity : %u\n", in->ev_info.full_charge_capacity); > + dev_dbg(dev->dev, "Drain Rate : %d\n", in->ev_info.drain_rate); > + dev_dbg(dev->dev, "Socket Power : %u\n", in->ev_info.socket_power); > + dev_dbg(dev->dev, "Skin Temperature : %u\n", in->ev_info.skin_temperature); > + dev_dbg(dev->dev, "Avg C0 Residency : %u\n", in->ev_info.avg_c0residency); > + dev_dbg(dev->dev, "Max C0 Residency : %u\n", in->ev_info.max_c0residency); > + dev_dbg(dev->dev, "GFX Busy : %u\n", in->ev_info.gfx_busy); > + dev_dbg(dev->dev, "Connected Display Count : %u\n", in->ev_info.monitor_count); > + dev_dbg(dev->dev, "LID State : %s\n", in->ev_info.lid_state ? "Close" : "Open"); "open" / "closed" is generic enough that I think it would warrant adding include/linux/string_choices.h helper for it (it should be lowercase there but that difference probably is not an issue for these debug prints). I'd also remove that extra space before :. -- i. > + dev_dbg(dev->dev, "==== TA inputs END ====\n"); > +} > +#else > +void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) {} > +#endif > + > static void amd_pmf_get_smu_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) > { > u16 max, avg = 0; > diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c > index d48f980fb1db..0eba258f4040 100644 > --- a/drivers/platform/x86/amd/pmf/tee-if.c > +++ b/drivers/platform/x86/amd/pmf/tee-if.c > @@ -182,6 +182,7 @@ static int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev) > } > > if (ta_sm->pmf_result == TA_PMF_TYPE_SUCCESS && out->actions_count) { > + amd_pmf_dump_ta_inputs(dev, in); > dev_dbg(dev->dev, "action count:%u result:%x\n", out->actions_count, > ta_sm->pmf_result); > amd_pmf_apply_policies(dev, out); > 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77894CDB482 for ; Wed, 18 Oct 2023 09:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229557AbjJRJAz (ORCPT ); Wed, 18 Oct 2023 05:00:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229594AbjJRJAy (ORCPT ); Wed, 18 Oct 2023 05:00:54 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFB51FF; Wed, 18 Oct 2023 02:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697619652; x=1729155652; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=Bz4RQKoB2bOF4jPSwqa+tusF8wmGmJ55+wiIyaWo9o4=; b=nhLrEBhP4+tC6gV4GCIjcP2BoFoiUt3QgEgmIll1b4u+P4Wl45P3yR6y Ic3+Mx1/VQxsgBcuEPHTyh6IvNpqj0qUUfNsFTNCdK2XIrXpRX5IQpFCP VCsGf4Dej8qYm8dEOaGpLGPFxC+IHL3EgHschAKBR84bMzgqvOERKY26I Y0dths7mnSUIUoWzk8YfRUxX4QFGk+AozRIAJOOjq8lfKJMKpNFdDSQOQ oF0hm3h0WK5rJ5ylBNfzHCs+0VERtbn+HMc9E3H9jrhMVKRQOzqEUp0O9 PPAkzVvBF/l4dmxUmuT8FDRnfrl+maHBNKE4YrmGasF4oXwx9advudG6/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="384852895" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="384852895" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 02:00:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="760147861" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="760147861" Received: from gruberda-mobl1.ger.corp.intel.com ([10.252.62.52]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 02:00:46 -0700 Date: Wed, 18 Oct 2023 12:00:44 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Shyam Sundar S K cc: Hans de Goede , markgross@kernel.org, basavaraj.natikar@amd.com, jikos@kernel.org, benjamin.tissoires@redhat.com, alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, Patil.Reddy@amd.com, mario.limonciello@amd.com, platform-driver-x86@vger.kernel.org, linux-input@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH v4 10/17] platform/x86/amd/pmf: Add facility to dump TA inputs In-Reply-To: <20231018070241.2041529-11-Shyam-sundar.S-k@amd.com> Message-ID: References: <20231018070241.2041529-1-Shyam-sundar.S-k@amd.com> <20231018070241.2041529-11-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On Wed, 18 Oct 2023, Shyam Sundar S K wrote: > PMF driver sends constant inputs to TA which its gets via the other > subsystems in the kernel. To debug certain TA issues knowing what inputs > being sent to TA becomes critical. Add debug facility to the driver which > can isolate Smart PC and TA related issues. > > Also, make source_as_str() as non-static function as this helper is > required outside of sps.c file. > > Reviewed-by: Mario Limonciello > Signed-off-by: Shyam Sundar S K > --- > drivers/platform/x86/amd/pmf/pmf.h | 3 +++ > drivers/platform/x86/amd/pmf/spc.c | 37 +++++++++++++++++++++++++++ > drivers/platform/x86/amd/pmf/tee-if.c | 1 + > 3 files changed, 41 insertions(+) > > diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h > index 216a9f795436..593930519039 100644 > --- a/drivers/platform/x86/amd/pmf/pmf.h > +++ b/drivers/platform/x86/amd/pmf/pmf.h > @@ -602,6 +602,7 @@ bool is_pprof_balanced(struct amd_pmf_dev *pmf); > int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev); > const char *amd_pmf_source_as_str(unsigned int state); > > +const char *amd_pmf_source_as_str(unsigned int state); > > int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx); > int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf); > @@ -632,4 +633,6 @@ int apmf_check_smart_pc(struct amd_pmf_dev *pmf_dev); > > /* Smart PC - TA interfaces */ > void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); > +void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); > + > #endif /* PMF_H */ > diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c > index bd5061fdfdbe..512e0c66efdc 100644 > --- a/drivers/platform/x86/amd/pmf/spc.c > +++ b/drivers/platform/x86/amd/pmf/spc.c > @@ -14,6 +14,43 @@ > #include > #include "pmf.h" > > +#ifdef CONFIG_AMD_PMF_DEBUG > +static const char *ta_slider_as_str(unsigned int state) > +{ > + switch (state) { > + case TA_BEST_PERFORMANCE: > + return "PERFORMANCE"; > + case TA_BETTER_PERFORMANCE: > + return "BALANCED"; > + case TA_BEST_BATTERY: > + return "POWER_SAVER"; > + default: > + return "Unknown TA Slider State"; > + } > +} > + > +void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) > +{ > + dev_dbg(dev->dev, "==== TA inputs START ====\n"); > + dev_dbg(dev->dev, "Slider State : %s\n", ta_slider_as_str(in->ev_info.power_slider)); > + dev_dbg(dev->dev, "Power Source : %s\n", amd_pmf_source_as_str(in->ev_info.power_source)); > + dev_dbg(dev->dev, "Battery Percentage : %u\n", in->ev_info.bat_percentage); > + dev_dbg(dev->dev, "Designed Battery Capacity : %u\n", in->ev_info.bat_design); > + dev_dbg(dev->dev, "Fully Charged Capacity : %u\n", in->ev_info.full_charge_capacity); > + dev_dbg(dev->dev, "Drain Rate : %d\n", in->ev_info.drain_rate); > + dev_dbg(dev->dev, "Socket Power : %u\n", in->ev_info.socket_power); > + dev_dbg(dev->dev, "Skin Temperature : %u\n", in->ev_info.skin_temperature); > + dev_dbg(dev->dev, "Avg C0 Residency : %u\n", in->ev_info.avg_c0residency); > + dev_dbg(dev->dev, "Max C0 Residency : %u\n", in->ev_info.max_c0residency); > + dev_dbg(dev->dev, "GFX Busy : %u\n", in->ev_info.gfx_busy); > + dev_dbg(dev->dev, "Connected Display Count : %u\n", in->ev_info.monitor_count); > + dev_dbg(dev->dev, "LID State : %s\n", in->ev_info.lid_state ? "Close" : "Open"); "open" / "closed" is generic enough that I think it would warrant adding include/linux/string_choices.h helper for it (it should be lowercase there but that difference probably is not an issue for these debug prints). I'd also remove that extra space before :. -- i. > + dev_dbg(dev->dev, "==== TA inputs END ====\n"); > +} > +#else > +void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) {} > +#endif > + > static void amd_pmf_get_smu_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) > { > u16 max, avg = 0; > diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c > index d48f980fb1db..0eba258f4040 100644 > --- a/drivers/platform/x86/amd/pmf/tee-if.c > +++ b/drivers/platform/x86/amd/pmf/tee-if.c > @@ -182,6 +182,7 @@ static int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev) > } > > if (ta_sm->pmf_result == TA_PMF_TYPE_SUCCESS && out->actions_count) { > + amd_pmf_dump_ta_inputs(dev, in); > dev_dbg(dev->dev, "action count:%u result:%x\n", out->actions_count, > ta_sm->pmf_result); > amd_pmf_apply_policies(dev, out); > 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 0B739CDB47E for ; Wed, 18 Oct 2023 09:00:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 594F310E08E; Wed, 18 Oct 2023 09:00:55 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D1A110E08E; Wed, 18 Oct 2023 09:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697619653; x=1729155653; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=Bz4RQKoB2bOF4jPSwqa+tusF8wmGmJ55+wiIyaWo9o4=; b=O8uyFyH3chwvrJ5molauAbx95kDgiUoBYBMlhrrMywnQTTOnzYRl+Cxx TkTvuzgtWmA5OMUQhHh2R6gfD5ohDHthawO59VqKE3a6YLF3nf1nb36Av AJYDIZIp4XKX69Ro44WmzZULVkCoiajXD/ypvwF3iejRzpCQGvpqu+AR9 b3pyp3xCb1uaaNXIyyFNKHe6EahK9QtKiKc/7vIbRbse51gvifGr08gtX hYs4uRSj9D9vDGp27bZZLwStDcxgJxJLOn2yOKgSejN/oemi1f8r4Y+s6 PH2Quv7TqwWEEpWkGIdxh8iRDTwCLOfycSOeVR8JbIsTmW2g0w9Sw3hk/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="384852898" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="384852898" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 02:00:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="760147861" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="760147861" Received: from gruberda-mobl1.ger.corp.intel.com ([10.252.62.52]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 02:00:46 -0700 Date: Wed, 18 Oct 2023 12:00:44 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Shyam Sundar S K Subject: Re: [PATCH v4 10/17] platform/x86/amd/pmf: Add facility to dump TA inputs In-Reply-To: <20231018070241.2041529-11-Shyam-sundar.S-k@amd.com> Message-ID: References: <20231018070241.2041529-1-Shyam-sundar.S-k@amd.com> <20231018070241.2041529-11-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xinhui.Pan@amd.com, Patil.Reddy@amd.com, basavaraj.natikar@amd.com, dri-devel@lists.freedesktop.org, jikos@kernel.org, amd-gfx@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, markgross@kernel.org, Hans de Goede , benjamin.tissoires@redhat.com, mario.limonciello@amd.com, linux-input@vger.kernel.org, alexander.deucher@amd.com, christian.koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Wed, 18 Oct 2023, Shyam Sundar S K wrote: > PMF driver sends constant inputs to TA which its gets via the other > subsystems in the kernel. To debug certain TA issues knowing what inputs > being sent to TA becomes critical. Add debug facility to the driver which > can isolate Smart PC and TA related issues. > > Also, make source_as_str() as non-static function as this helper is > required outside of sps.c file. > > Reviewed-by: Mario Limonciello > Signed-off-by: Shyam Sundar S K > --- > drivers/platform/x86/amd/pmf/pmf.h | 3 +++ > drivers/platform/x86/amd/pmf/spc.c | 37 +++++++++++++++++++++++++++ > drivers/platform/x86/amd/pmf/tee-if.c | 1 + > 3 files changed, 41 insertions(+) > > diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h > index 216a9f795436..593930519039 100644 > --- a/drivers/platform/x86/amd/pmf/pmf.h > +++ b/drivers/platform/x86/amd/pmf/pmf.h > @@ -602,6 +602,7 @@ bool is_pprof_balanced(struct amd_pmf_dev *pmf); > int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev); > const char *amd_pmf_source_as_str(unsigned int state); > > +const char *amd_pmf_source_as_str(unsigned int state); > > int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx); > int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf); > @@ -632,4 +633,6 @@ int apmf_check_smart_pc(struct amd_pmf_dev *pmf_dev); > > /* Smart PC - TA interfaces */ > void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); > +void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); > + > #endif /* PMF_H */ > diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c > index bd5061fdfdbe..512e0c66efdc 100644 > --- a/drivers/platform/x86/amd/pmf/spc.c > +++ b/drivers/platform/x86/amd/pmf/spc.c > @@ -14,6 +14,43 @@ > #include > #include "pmf.h" > > +#ifdef CONFIG_AMD_PMF_DEBUG > +static const char *ta_slider_as_str(unsigned int state) > +{ > + switch (state) { > + case TA_BEST_PERFORMANCE: > + return "PERFORMANCE"; > + case TA_BETTER_PERFORMANCE: > + return "BALANCED"; > + case TA_BEST_BATTERY: > + return "POWER_SAVER"; > + default: > + return "Unknown TA Slider State"; > + } > +} > + > +void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) > +{ > + dev_dbg(dev->dev, "==== TA inputs START ====\n"); > + dev_dbg(dev->dev, "Slider State : %s\n", ta_slider_as_str(in->ev_info.power_slider)); > + dev_dbg(dev->dev, "Power Source : %s\n", amd_pmf_source_as_str(in->ev_info.power_source)); > + dev_dbg(dev->dev, "Battery Percentage : %u\n", in->ev_info.bat_percentage); > + dev_dbg(dev->dev, "Designed Battery Capacity : %u\n", in->ev_info.bat_design); > + dev_dbg(dev->dev, "Fully Charged Capacity : %u\n", in->ev_info.full_charge_capacity); > + dev_dbg(dev->dev, "Drain Rate : %d\n", in->ev_info.drain_rate); > + dev_dbg(dev->dev, "Socket Power : %u\n", in->ev_info.socket_power); > + dev_dbg(dev->dev, "Skin Temperature : %u\n", in->ev_info.skin_temperature); > + dev_dbg(dev->dev, "Avg C0 Residency : %u\n", in->ev_info.avg_c0residency); > + dev_dbg(dev->dev, "Max C0 Residency : %u\n", in->ev_info.max_c0residency); > + dev_dbg(dev->dev, "GFX Busy : %u\n", in->ev_info.gfx_busy); > + dev_dbg(dev->dev, "Connected Display Count : %u\n", in->ev_info.monitor_count); > + dev_dbg(dev->dev, "LID State : %s\n", in->ev_info.lid_state ? "Close" : "Open"); "open" / "closed" is generic enough that I think it would warrant adding include/linux/string_choices.h helper for it (it should be lowercase there but that difference probably is not an issue for these debug prints). I'd also remove that extra space before :. -- i. > + dev_dbg(dev->dev, "==== TA inputs END ====\n"); > +} > +#else > +void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) {} > +#endif > + > static void amd_pmf_get_smu_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) > { > u16 max, avg = 0; > diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c > index d48f980fb1db..0eba258f4040 100644 > --- a/drivers/platform/x86/amd/pmf/tee-if.c > +++ b/drivers/platform/x86/amd/pmf/tee-if.c > @@ -182,6 +182,7 @@ static int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev) > } > > if (ta_sm->pmf_result == TA_PMF_TYPE_SUCCESS && out->actions_count) { > + amd_pmf_dump_ta_inputs(dev, in); > dev_dbg(dev->dev, "action count:%u result:%x\n", out->actions_count, > ta_sm->pmf_result); > amd_pmf_apply_policies(dev, out); >