All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
To: <hdegoede@redhat.com>, <markgross@kernel.org>
Cc: <platform-driver-x86@vger.kernel.org>, <Patil.Reddy@amd.com>,
	"Shyam Sundar S K" <Shyam-sundar.S-k@amd.com>
Subject: [PATCH v2 RESEND 04/11] platform/x86/amd/pmf: Add debugfs information
Date: Thu, 28 Jul 2022 23:50:21 +0530	[thread overview]
Message-ID: <20220728182028.2082096-5-Shyam-sundar.S-k@amd.com> (raw)
In-Reply-To: <20220728182028.2082096-1-Shyam-sundar.S-k@amd.com>

Add debugfs support to the PMF driver so that using this interface the
live counters from the PMFW can be queried to see if the power parameters
are getting set properly when a certain power mode change happens.

Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
 drivers/platform/x86/amd/pmf/core.c | 36 +++++++++++++++++++++++++++++
 drivers/platform/x86/amd/pmf/pmf.h  |  1 +
 2 files changed, 37 insertions(+)

diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
index b6006e8ee1a1..4ce69864879a 100644
--- a/drivers/platform/x86/amd/pmf/core.c
+++ b/drivers/platform/x86/amd/pmf/core.c
@@ -8,6 +8,7 @@
  * Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
  */
 
+#include <linux/debugfs.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -46,6 +47,39 @@
 #define DELAY_MIN_US	2000
 #define DELAY_MAX_US	3000
 
+static int current_power_limits_show(struct seq_file *seq, void *unused)
+{
+	struct amd_pmf_dev *dev = seq->private;
+	struct amd_pmf_static_slider_granular table;
+	int mode, src = 0;
+
+	mode = amd_pmf_get_pprof_modes(dev);
+	src = amd_pmf_get_power_source();
+	amd_pmf_update_slider(dev, SLIDER_OP_GET, mode, &table);
+	seq_printf(seq, "spl:%u fppt:%u sppt:%u sppt_apu_only:%u stt_min:%u stt[APU]:%u stt[HS2]: %u\n",
+		   table.prop[src][mode].spl,
+		   table.prop[src][mode].fppt,
+		   table.prop[src][mode].sppt,
+		   table.prop[src][mode].sppt_apu_only,
+		   table.prop[src][mode].stt_min,
+		   table.prop[src][mode].stt_skin_temp[STT_TEMP_APU],
+		   table.prop[src][mode].stt_skin_temp[STT_TEMP_HS2]);
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(current_power_limits);
+
+static void amd_pmf_dbgfs_unregister(struct amd_pmf_dev *dev)
+{
+	debugfs_remove_recursive(dev->dbgfs_dir);
+}
+
+static void amd_pmf_dbgfs_register(struct amd_pmf_dev *dev)
+{
+	dev->dbgfs_dir = debugfs_create_dir("amd_pmf", NULL);
+	debugfs_create_file("current_power_limits", 0644, dev->dbgfs_dir, dev,
+			    &current_power_limits_fops);
+}
+
 int amd_pmf_get_power_source(void)
 {
 	if (power_supply_is_system_supplied() > 0)
@@ -231,6 +265,7 @@ static int amd_pmf_probe(struct platform_device *pdev)
 	apmf_acpi_init(dev);
 	platform_set_drvdata(pdev, dev);
 	amd_pmf_init_features(dev);
+	amd_pmf_dbgfs_register(dev);
 
 	mutex_init(&dev->lock);
 	dev_info(dev->dev, "registered PMF device successfully\n");
@@ -244,6 +279,7 @@ static int amd_pmf_remove(struct platform_device *pdev)
 
 	mutex_destroy(&dev->lock);
 	amd_pmf_deinit_features(dev);
+	amd_pmf_dbgfs_unregister(dev);
 	kfree(dev->buf);
 	return 0;
 }
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 30740a5cd30d..de8dbd5e04e8 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -100,6 +100,7 @@ struct amd_pmf_dev {
 	enum platform_profile_option current_profile;
 	struct platform_profile_handler pprof;
 	struct mutex lock; /* protects the PMF interface */
+	struct dentry *dbgfs_dir;
 };
 
 struct apmf_sps_prop_granular {
-- 
2.25.1


  parent reply	other threads:[~2022-07-28 18:21 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28 18:20 [PATCH v2 RESEND 00/11] platform/x86/amd/pmf: Introduce AMD PMF Driver Shyam Sundar S K
2022-07-28 18:20 ` [PATCH v2 RESEND 01/11] platform/x86/amd/pmf: Add support for PMF core layer Shyam Sundar S K
2022-08-01 11:16   ` Hans de Goede
2022-07-28 18:20 ` [PATCH v2 RESEND 02/11] platform/x86/amd/pmf: Add support for PMF APCI layer Shyam Sundar S K
2022-08-01 11:24   ` Hans de Goede
2022-08-01 12:48   ` Hans de Goede
2022-08-01 13:18     ` Hans de Goede
2022-07-28 18:20 ` [PATCH v2 RESEND 03/11] platform/x86/amd/pmf: Add support SPS PMF feature Shyam Sundar S K
2022-08-01 11:30   ` Hans de Goede
2022-08-01 12:50   ` Hans de Goede
2022-07-28 18:20 ` Shyam Sundar S K [this message]
2022-08-01 11:35   ` [PATCH v2 RESEND 04/11] platform/x86/amd/pmf: Add debugfs information Hans de Goede
2022-07-28 18:20 ` [PATCH v2 RESEND 05/11] platform/x86/amd/pmf: Add heartbeat signal support Shyam Sundar S K
2022-08-01 11:38   ` Hans de Goede
2022-07-28 18:20 ` [PATCH v2 RESEND 06/11] platform/x86/amd/pmf: Add fan control support Shyam Sundar S K
2022-08-01 11:40   ` Hans de Goede
2022-08-01 12:51   ` Hans de Goede
2022-07-28 18:20 ` [PATCH v2 RESEND 07/11] platform/x86/amd/pmf: Get performance metrics from PMFW Shyam Sundar S K
2022-07-28 21:02   ` Limonciello, Mario
2022-07-29 17:43     ` Shyam Sundar S K
2022-08-01 11:50   ` Hans de Goede
2022-07-28 18:20 ` [PATCH v2 RESEND 08/11] platform/x86/amd/pmf: Add support for Auto mode feature Shyam Sundar S K
2022-08-01 12:55   ` Hans de Goede
2022-08-01 13:20     ` Hans de Goede
2022-07-28 18:20 ` [PATCH v2 RESEND 09/11] platform/x86/amd/pmf: Handle AMT and CQL events for Auto mode Shyam Sundar S K
2022-08-01 13:55   ` Hans de Goede
2022-08-02 11:22     ` Shyam Sundar S K
2022-08-02 12:20       ` Hans de Goede
2022-08-01 14:01   ` Hans de Goede
2022-07-28 18:20 ` [PATCH v2 RESEND 10/11] platform/x86/amd/pmf: Force load driver on older supported platforms Shyam Sundar S K
2022-08-01 13:58   ` Hans de Goede
2022-07-28 18:20 ` [PATCH v2 RESEND 11/11] MAINTAINERS: Add AMD PMF driver entry Shyam Sundar S K
2022-08-01 13:58   ` Hans de Goede

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=20220728182028.2082096-5-Shyam-sundar.S-k@amd.com \
    --to=shyam-sundar.s-k@amd.com \
    --cc=Patil.Reddy@amd.com \
    --cc=hdegoede@redhat.com \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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.