All of lore.kernel.org
 help / color / mirror / Atom feed
From: Athira Rajeev <atrajeev@linux.ibm.com>
To: maddy@linux.ibm.com, linuxppc-dev@lists.ozlabs.org
Cc: atrajeev@linux.ibm.com, disgoel@linux.vnet.ibm.com,
	hbathini@linux.vnet.ibm.com, Aditya.Bodkhe1@ibm.com,
	adubey@linux.ibm.com, skb99@linux.ibm.com, sshegde@linux.ibm.com,
	riteshh@linux.ibm.com, Tejas.Manhas1@ibm.com,
	venkat88@linux.ibm.com
Subject: [PATCH V3 7/9] powerpc/pseries/htmdump: Add htm flags support to htmdump module
Date: Sun, 20 Apr 2025 23:38:42 +0530	[thread overview]
Message-ID: <20250420180844.53128-8-atrajeev@linux.ibm.com> (raw)
In-Reply-To: <20250420180844.53128-1-atrajeev@linux.ibm.com>

Under debugfs folder, "/sys/kernel/debug/powerpc/htmdump", add file
"htmflags". Currently supported flag value is to enable/disable
HTM buffer wrap. wrap is used along with "configure" to prevent
HTM buffer from wrapping. Writing 1 will set noWrap while
configuring HTM

Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
---
 arch/powerpc/include/asm/plpar_wrappers.h |  4 +-
 arch/powerpc/platforms/pseries/htmdump.c  | 57 +++++++++++++++++++----
 2 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/plpar_wrappers.h b/arch/powerpc/include/asm/plpar_wrappers.h
index f3efa9946b3c..f2b6cc4341bb 100644
--- a/arch/powerpc/include/asm/plpar_wrappers.h
+++ b/arch/powerpc/include/asm/plpar_wrappers.h
@@ -81,12 +81,12 @@ static inline long htm_call(unsigned long flags, unsigned long target,
                                  param1, param2, param3);
 }
 
-static inline long htm_hcall_wrapper(unsigned long nodeindex,
+static inline long htm_hcall_wrapper(unsigned long flags, unsigned long nodeindex,
                unsigned long nodalchipindex, unsigned long coreindexonchip,
 	       unsigned long type, unsigned long htm_op, unsigned long param1, unsigned long param2,
 	       unsigned long param3)
 {
-       return htm_call(H_HTM_FLAGS_HARDWARE_TARGET,
+	return htm_call(H_HTM_FLAGS_HARDWARE_TARGET | flags,
                        H_HTM_TARGET_NODE_INDEX(nodeindex) |
                        H_HTM_TARGET_NODAL_CHIP_INDEX(nodalchipindex) |
                        H_HTM_TARGET_CORE_INDEX_ON_CHIP(coreindexonchip),
diff --git a/arch/powerpc/platforms/pseries/htmdump.c b/arch/powerpc/platforms/pseries/htmdump.c
index 39657e8655cb..dc5cdcd8c3c3 100644
--- a/arch/powerpc/platforms/pseries/htmdump.c
+++ b/arch/powerpc/platforms/pseries/htmdump.c
@@ -21,10 +21,13 @@ static u32 htmtype;
 static u32 htmconfigure;
 static u32 htmstart;
 static u32 htmsetup;
+static u64 htmflags;
 
 static struct dentry *htmdump_debugfs_dir;
 #define	HTM_ENABLE	1
 #define	HTM_DISABLE	0
+#define	HTM_NOWRAP	1
+#define	HTM_WRAP	0
 
 /*
  * Check the return code for H_HTM hcall.
@@ -94,7 +97,7 @@ static ssize_t htmdump_read(struct file *filp, char __user *ubuf,
 	 * - operation as htm dump (H_HTM_OP_DUMP_DATA)
 	 * - last three values are address, size and offset
 	 */
-	rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+	rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
 				   htmtype, H_HTM_OP_DUMP_DATA, virt_to_phys(htm_buf),
 				   PAGE_SIZE, page);
 
@@ -119,6 +122,7 @@ static const struct file_operations htmdump_fops = {
 static int  htmconfigure_set(void *data, u64 val)
 {
 	long rc, ret;
+	unsigned long param1 = -1, param2 = -1;
 
 	/*
 	 * value as 1 : configure HTM.
@@ -129,17 +133,25 @@ static int  htmconfigure_set(void *data, u64 val)
 		/*
 		 * Invoke H_HTM call with:
 		 * - operation as htm configure (H_HTM_OP_CONFIGURE)
+		 * - If htmflags is set, param1 and param2 will be -1
+		 *   which is an indicator to use default htm mode reg mask
+		 *   and htm mode reg value.
 		 * - last three values are unused, hence set to zero
 		 */
-		rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
-			   htmtype, H_HTM_OP_CONFIGURE, 0, 0, 0);
+		if (!htmflags) {
+			param1 = 0;
+			param2 = 0;
+		}
+
+		rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
+			   htmtype, H_HTM_OP_CONFIGURE, param1, param2, 0);
 	} else if (val == HTM_DISABLE) {
 		/*
 		 * Invoke H_HTM call with:
 		 * - operation as htm deconfigure (H_HTM_OP_DECONFIGURE)
 		 * - last three values are unused, hence set to zero
 		 */
-		rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+		rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
 				htmtype, H_HTM_OP_DECONFIGURE, 0, 0, 0);
 	} else
 		return -EINVAL;
@@ -177,7 +189,7 @@ static int  htmstart_set(void *data, u64 val)
 		 * - operation as htm start (H_HTM_OP_START)
 		 * - last three values are unused, hence set to zero
 		 */
-		rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+		rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
 			   htmtype, H_HTM_OP_START, 0, 0, 0);
 
 	} else if (val == HTM_DISABLE) {
@@ -186,7 +198,7 @@ static int  htmstart_set(void *data, u64 val)
 		 * - operation as htm stop (H_HTM_OP_STOP)
 		 * - last three values are unused, hence set to zero
 		 */
-		rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+		rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
 				htmtype, H_HTM_OP_STOP, 0, 0, 0);
 	} else
 		return -EINVAL;
@@ -223,7 +235,7 @@ static ssize_t htmstatus_read(struct file *filp, char __user *ubuf,
 	 * - operation as htm status (H_HTM_OP_STATUS)
 	 * - last three values as addr, size and offset
 	 */
-	rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+	rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
 				   htmtype, H_HTM_OP_STATUS, virt_to_phys(htm_status_buf),
 				   PAGE_SIZE, 0);
 
@@ -269,7 +281,7 @@ static ssize_t htminfo_read(struct file *filp, char __user *ubuf,
 	 * - operation as htm status (H_HTM_OP_STATUS)
 	 * - last three values as addr, size and offset
 	 */
-	rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+	rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
 				   htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, virt_to_phys(htm_info_buf),
 				   PAGE_SIZE, 0);
 
@@ -311,7 +323,7 @@ static int  htmsetup_set(void *data, u64 val)
 	 * - parameter 1 set to input value.
 	 * - last two values are unused, hence set to zero
 	 */
-	rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+	rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
 			htmtype, H_HTM_OP_SETUP, val, 0, 0);
 
 	ret = htm_return_check(rc);
@@ -332,9 +344,35 @@ static int htmsetup_get(void *data, u64 *val)
 	return 0;
 }
 
+static int  htmflags_set(void *data, u64 val)
+{
+	/*
+	 * Input value:
+	 * Currently supported flag value is to enable/disable
+	 * HTM buffer wrap. wrap is used along with "configure"
+	 * to prevent HTM buffer from wrapping.
+	 * Writing 1 will set noWrap while configuring HTM
+	 */
+	if (val == HTM_NOWRAP)
+		htmflags = H_HTM_FLAGS_NOWRAP;
+	else if (val == HTM_WRAP)
+		htmflags = 0;
+	else
+		return -EINVAL;
+
+	return 0;
+}
+
+static int htmflags_get(void *data, u64 *val)
+{
+	*val = htmflags;
+	return 0;
+}
+
 DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
 DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n");
 DEFINE_SIMPLE_ATTRIBUTE(htmsetup_fops, htmsetup_get, htmsetup_set, "%llu\n");
+DEFINE_SIMPLE_ATTRIBUTE(htmflags_fops, htmflags_get, htmflags_set, "%llu\n");
 
 static int htmdump_init_debugfs(void)
 {
@@ -363,6 +401,7 @@ static int htmdump_init_debugfs(void)
 	debugfs_create_file("htmconfigure", 0600, htmdump_debugfs_dir, NULL, &htmconfigure_fops);
 	debugfs_create_file("htmstart", 0600, htmdump_debugfs_dir, NULL, &htmstart_fops);
 	debugfs_create_file("htmsetup", 0600, htmdump_debugfs_dir, NULL, &htmsetup_fops);
+	debugfs_create_file("htmflags", 0600, htmdump_debugfs_dir, NULL, &htmflags_fops);
 
 	/* Debugfs interface file to present status of HTM */
 	htm_status_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-- 
2.43.0



  parent reply	other threads:[~2025-04-20 18:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-20 18:08 [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM) Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 1/9] powerpc/pseries/htmdump: Add htm_hcall_wrapper to integrate other htm operations Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 2/9] powerpc/pseries/htmdump: Add htm configure support to htmdump module Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 3/9] powerpc/pseries/htmdump: Add htm start " Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 4/9] powerpc/pseries/htmdump: Add htm status " Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 5/9] powerpc/pseries/htmdump: Add htm info " Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 6/9] powerpc/pseries/htmdump: Add htm setup " Athira Rajeev
2025-04-20 18:08 ` Athira Rajeev [this message]
2025-04-20 18:08 ` [PATCH V3 8/9] powerpc/pseries/htmdump: Add htm capabilities " Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 9/9] powerpc/pseries/htmdump: Add documentation for H_HTM debugfs interface Athira Rajeev
2025-05-14  4:03 ` [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM) Madhavan Srinivasan

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=20250420180844.53128-8-atrajeev@linux.ibm.com \
    --to=atrajeev@linux.ibm.com \
    --cc=Aditya.Bodkhe1@ibm.com \
    --cc=Tejas.Manhas1@ibm.com \
    --cc=adubey@linux.ibm.com \
    --cc=disgoel@linux.vnet.ibm.com \
    --cc=hbathini@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=riteshh@linux.ibm.com \
    --cc=skb99@linux.ibm.com \
    --cc=sshegde@linux.ibm.com \
    --cc=venkat88@linux.ibm.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.