* [PATCH V3 1/9] powerpc/pseries/htmdump: Add htm_hcall_wrapper to integrate other htm operations
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 ` Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 2/9] powerpc/pseries/htmdump: Add htm configure support to htmdump module Athira Rajeev
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Athira Rajeev @ 2025-04-20 18:08 UTC (permalink / raw)
To: maddy, linuxppc-dev
Cc: atrajeev, disgoel, hbathini, Aditya.Bodkhe1, adubey, skb99,
sshegde, riteshh, Tejas.Manhas1, venkat88
H_HTM (Hardware Trace Macro) hypervisor call is an HCALL to export data
from Hardware Trace Macro (HTM) function. The debugfs interface to
export the HTM function data in an lpar currently supports only dumping
of HTM data in an lpar. To add support for setup, configuration and
control of HTM function via debugfs interface, update the hcall wrapper
function. Rename and update htm_get_dump_hardware to htm_hcall_wrapper()
so that it can be used for other HTM operations as well. Additionally
include parameter "htm_op". Update htmdump module to check the return
code of hcall in a separate function so that it can be reused for other
option too. Add check to disable the interface in guest environment.
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 | 18 +++++--
arch/powerpc/platforms/pseries/htmdump.c | 63 ++++++++++++++++++-----
2 files changed, 63 insertions(+), 18 deletions(-)
diff --git a/arch/powerpc/include/asm/plpar_wrappers.h b/arch/powerpc/include/asm/plpar_wrappers.h
index 91be7b885944..f3efa9946b3c 100644
--- a/arch/powerpc/include/asm/plpar_wrappers.h
+++ b/arch/powerpc/include/asm/plpar_wrappers.h
@@ -65,6 +65,14 @@ static inline long register_dtl(unsigned long cpu, unsigned long vpa)
return vpa_call(H_VPA_REG_DTL, cpu, vpa);
}
+/*
+ * Invokes H_HTM hcall with parameters passed from htm_hcall_wrapper.
+ * flags: Set to hardwareTarget.
+ * target: Specifies target using node index, nodal chip index and core index.
+ * operation : action to perform ie configure, start, stop, deconfigure, trace
+ * based on the HTM type.
+ * param1, param2, param3: parameters for each action.
+ */
static inline long htm_call(unsigned long flags, unsigned long target,
unsigned long operation, unsigned long param1,
unsigned long param2, unsigned long param3)
@@ -73,17 +81,17 @@ static inline long htm_call(unsigned long flags, unsigned long target,
param1, param2, param3);
}
-static inline long htm_get_dump_hardware(unsigned long nodeindex,
+static inline long htm_hcall_wrapper(unsigned long nodeindex,
unsigned long nodalchipindex, unsigned long coreindexonchip,
- unsigned long type, unsigned long addr, unsigned long size,
- unsigned long offset)
+ unsigned long type, unsigned long htm_op, unsigned long param1, unsigned long param2,
+ unsigned long param3)
{
return htm_call(H_HTM_FLAGS_HARDWARE_TARGET,
H_HTM_TARGET_NODE_INDEX(nodeindex) |
H_HTM_TARGET_NODAL_CHIP_INDEX(nodalchipindex) |
H_HTM_TARGET_CORE_INDEX_ON_CHIP(coreindexonchip),
- H_HTM_OP(H_HTM_OP_DUMP_DATA) | H_HTM_TYPE(type),
- addr, size, offset);
+ H_HTM_OP(htm_op) | H_HTM_TYPE(type),
+ param1, param2, param3);
}
extern void vpa_init(int cpu);
diff --git a/arch/powerpc/platforms/pseries/htmdump.c b/arch/powerpc/platforms/pseries/htmdump.c
index 57fc1700f604..604fde6a0559 100644
--- a/arch/powerpc/platforms/pseries/htmdump.c
+++ b/arch/powerpc/platforms/pseries/htmdump.c
@@ -18,20 +18,19 @@ static u32 coreindexonchip;
static u32 htmtype;
static struct dentry *htmdump_debugfs_dir;
-static ssize_t htmdump_read(struct file *filp, char __user *ubuf,
- size_t count, loff_t *ppos)
+/*
+ * Check the return code for H_HTM hcall.
+ * Return non-zero value (1) if either H_PARTIAL or H_SUCCESS
+ * is returned. For other return codes:
+ * Return zero if H_NOT_AVAILABLE.
+ * Return -EBUSY if hcall return busy.
+ * Return -EINVAL if any parameter or operation is not valid.
+ * Return -EPERM if HTM Virtualization Engine Technology code
+ * is not applied.
+ * Return -EIO if the HTM state is not valid.
+ */
+static ssize_t htm_return_check(long rc)
{
- void *htm_buf = filp->private_data;
- unsigned long page, read_size, available;
- loff_t offset;
- long rc;
-
- page = ALIGN_DOWN(*ppos, PAGE_SIZE);
- offset = (*ppos) % PAGE_SIZE;
-
- rc = htm_get_dump_hardware(nodeindex, nodalchipindex, coreindexonchip,
- htmtype, virt_to_phys(htm_buf), PAGE_SIZE, page);
-
switch (rc) {
case H_SUCCESS:
/* H_PARTIAL for the case where all available data can't be
@@ -65,6 +64,38 @@ static ssize_t htmdump_read(struct file *filp, char __user *ubuf,
return -EPERM;
}
+ /*
+ * Return 1 for H_SUCCESS/H_PARTIAL
+ */
+ return 1;
+}
+
+static ssize_t htmdump_read(struct file *filp, char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ void *htm_buf = filp->private_data;
+ unsigned long page, read_size, available;
+ loff_t offset;
+ long rc, ret;
+
+ page = ALIGN_DOWN(*ppos, PAGE_SIZE);
+ offset = (*ppos) % PAGE_SIZE;
+
+ /*
+ * Invoke H_HTM call with:
+ * - operation as htm dump (H_HTM_OP_DUMP_DATA)
+ * - last three values are address, size and offset
+ */
+ rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+ htmtype, H_HTM_OP_DUMP_DATA, virt_to_phys(htm_buf),
+ PAGE_SIZE, page);
+
+ ret = htm_return_check(rc);
+ if (ret <= 0) {
+ pr_debug("H_HTM hcall failed for op: H_HTM_OP_DUMP_DATA, returning %ld\n", ret);
+ return ret;
+ }
+
available = PAGE_SIZE;
read_size = min(count, available);
*ppos += read_size;
@@ -103,6 +134,12 @@ static int htmdump_init_debugfs(void)
static int __init htmdump_init(void)
{
+ /* Disable on kvm guest */
+ if (is_kvm_guest()) {
+ pr_info("htmdump not supported inside KVM guest\n");
+ return -EOPNOTSUPP;
+ }
+
if (htmdump_init_debugfs())
return -ENOMEM;
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH V3 2/9] powerpc/pseries/htmdump: Add htm configure support to htmdump module
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 ` Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 3/9] powerpc/pseries/htmdump: Add htm start " Athira Rajeev
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Athira Rajeev @ 2025-04-20 18:08 UTC (permalink / raw)
To: maddy, linuxppc-dev
Cc: atrajeev, disgoel, hbathini, Aditya.Bodkhe1, adubey, skb99,
sshegde, riteshh, Tejas.Manhas1, venkat88
Support configuring of Hardware Trace Macro (HTM) function
via debugfs interface. Under debugfs folder
"/sys/kernel/debug/powerpc/htmdump", add file "htmconfigure".
The interface allows configuring of htm via this file
by writing value "1". Allow deconfiguring of htm via this file
by writing value "0". Any other value returns -EINVAL.
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
---
arch/powerpc/platforms/pseries/htmdump.c | 56 ++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/htmdump.c b/arch/powerpc/platforms/pseries/htmdump.c
index 604fde6a0559..5c1eef1b827a 100644
--- a/arch/powerpc/platforms/pseries/htmdump.c
+++ b/arch/powerpc/platforms/pseries/htmdump.c
@@ -16,7 +16,10 @@ static u32 nodeindex;
static u32 nodalchipindex;
static u32 coreindexonchip;
static u32 htmtype;
+static u32 htmconfigure;
static struct dentry *htmdump_debugfs_dir;
+#define HTM_ENABLE 1
+#define HTM_DISABLE 0
/*
* Check the return code for H_HTM hcall.
@@ -108,6 +111,54 @@ static const struct file_operations htmdump_fops = {
.open = simple_open,
};
+static int htmconfigure_set(void *data, u64 val)
+{
+ long rc, ret;
+
+ /*
+ * value as 1 : configure HTM.
+ * value as 0 : deconfigure HTM. Return -EINVAL for
+ * other values.
+ */
+ if (val == HTM_ENABLE) {
+ /*
+ * Invoke H_HTM call with:
+ * - operation as htm configure (H_HTM_OP_CONFIGURE)
+ * - last three values are unused, hence set to zero
+ */
+ rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+ htmtype, H_HTM_OP_CONFIGURE, 0, 0, 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,
+ htmtype, H_HTM_OP_DECONFIGURE, 0, 0, 0);
+ } else
+ return -EINVAL;
+
+ ret = htm_return_check(rc);
+ if (ret <= 0) {
+ pr_debug("H_HTM hcall failed, returning %ld\n", ret);
+ return ret;
+ }
+
+ /* Set htmconfigure if operation succeeds */
+ htmconfigure = val;
+
+ return 0;
+}
+
+static int htmconfigure_get(void *data, u64 *val)
+{
+ *val = htmconfigure;
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
+
static int htmdump_init_debugfs(void)
{
htm_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
@@ -129,6 +180,11 @@ static int htmdump_init_debugfs(void)
htmdump_debugfs_dir, &htmtype);
debugfs_create_file("trace", 0400, htmdump_debugfs_dir, htm_buf, &htmdump_fops);
+ /*
+ * Debugfs interface files to control HTM operations:
+ */
+ debugfs_create_file("htmconfigure", 0600, htmdump_debugfs_dir, NULL, &htmconfigure_fops);
+
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH V3 3/9] powerpc/pseries/htmdump: Add htm start support to htmdump module
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 ` Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 4/9] powerpc/pseries/htmdump: Add htm status " Athira Rajeev
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Athira Rajeev @ 2025-04-20 18:08 UTC (permalink / raw)
To: maddy, linuxppc-dev
Cc: atrajeev, disgoel, hbathini, Aditya.Bodkhe1, adubey, skb99,
sshegde, riteshh, Tejas.Manhas1, venkat88
Support starting of Hardware Trace Macro (HTM) function
via debugfs interface. Under debugfs folder
"/sys/kernel/debug/powerpc/htmdump", add file "htmstart".
The interface allows starting of htm via this file by
writing value "1". Also allows stopping of htm tracing by
writing value "0" to this file. Any other value returns
-EINVAL.
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
---
arch/powerpc/platforms/pseries/htmdump.c | 50 ++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/htmdump.c b/arch/powerpc/platforms/pseries/htmdump.c
index 5c1eef1b827a..4dd077cc850b 100644
--- a/arch/powerpc/platforms/pseries/htmdump.c
+++ b/arch/powerpc/platforms/pseries/htmdump.c
@@ -17,6 +17,7 @@ static u32 nodalchipindex;
static u32 coreindexonchip;
static u32 htmtype;
static u32 htmconfigure;
+static u32 htmstart;
static struct dentry *htmdump_debugfs_dir;
#define HTM_ENABLE 1
#define HTM_DISABLE 0
@@ -157,7 +158,55 @@ static int htmconfigure_get(void *data, u64 *val)
return 0;
}
+static int htmstart_set(void *data, u64 val)
+{
+ long rc, ret;
+
+ /*
+ * value as 1: start HTM
+ * value as 0: stop HTM
+ * Return -EINVAL for other values.
+ */
+ if (val == HTM_ENABLE) {
+ /*
+ * Invoke H_HTM call with:
+ * - operation as htm start (H_HTM_OP_START)
+ * - last three values are unused, hence set to zero
+ */
+ rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+ htmtype, H_HTM_OP_START, 0, 0, 0);
+
+ } else if (val == HTM_DISABLE) {
+ /*
+ * Invoke H_HTM call with:
+ * - operation as htm stop (H_HTM_OP_STOP)
+ * - last three values are unused, hence set to zero
+ */
+ rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+ htmtype, H_HTM_OP_STOP, 0, 0, 0);
+ } else
+ return -EINVAL;
+
+ ret = htm_return_check(rc);
+ if (ret <= 0) {
+ pr_debug("H_HTM hcall failed, returning %ld\n", ret);
+ return ret;
+ }
+
+ /* Set htmstart if H_HTM_OP_START/H_HTM_OP_STOP operation succeeds */
+ htmstart = val;
+
+ return 0;
+}
+
+static int htmstart_get(void *data, u64 *val)
+{
+ *val = htmstart;
+ return 0;
+}
+
DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
+DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n");
static int htmdump_init_debugfs(void)
{
@@ -184,6 +233,7 @@ static int htmdump_init_debugfs(void)
* Debugfs interface files to control HTM operations:
*/
debugfs_create_file("htmconfigure", 0600, htmdump_debugfs_dir, NULL, &htmconfigure_fops);
+ debugfs_create_file("htmstart", 0600, htmdump_debugfs_dir, NULL, &htmstart_fops);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH V3 4/9] powerpc/pseries/htmdump: Add htm status support to htmdump module
2025-04-20 18:08 [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM) Athira Rajeev
` (2 preceding siblings ...)
2025-04-20 18:08 ` [PATCH V3 3/9] powerpc/pseries/htmdump: Add htm start " Athira Rajeev
@ 2025-04-20 18:08 ` Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 5/9] powerpc/pseries/htmdump: Add htm info " Athira Rajeev
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Athira Rajeev @ 2025-04-20 18:08 UTC (permalink / raw)
To: maddy, linuxppc-dev
Cc: atrajeev, disgoel, hbathini, Aditya.Bodkhe1, adubey, skb99,
sshegde, riteshh, Tejas.Manhas1, venkat88
Support dumping status of Hardware Trace Macro (HTM) function
via debugfs interface. Under debugfs folder
"/sys/kernel/debug/powerpc/htmdump", add file "htmstatus".
The interface allows only read of this file which will present the
content of HTM status buffer from the hcall. The 16th offset of HTM
status buffer has value for the number of HTM entries in the status
buffer. Each nest htm status entry is 0x6 bytes, where as core HTM
status entry is 0x8 bytes. Calculate the number of bytes to read
based on this detail.
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
---
arch/powerpc/platforms/pseries/htmdump.c | 57 ++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/htmdump.c b/arch/powerpc/platforms/pseries/htmdump.c
index 4dd077cc850b..be28391e6d1f 100644
--- a/arch/powerpc/platforms/pseries/htmdump.c
+++ b/arch/powerpc/platforms/pseries/htmdump.c
@@ -12,6 +12,7 @@
#include <asm/plpar_wrappers.h>
static void *htm_buf;
+static void *htm_status_buf;
static u32 nodeindex;
static u32 nodalchipindex;
static u32 coreindexonchip;
@@ -205,6 +206,53 @@ static int htmstart_get(void *data, u64 *val)
return 0;
}
+static ssize_t htmstatus_read(struct file *filp, char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ void *htm_status_buf = filp->private_data;
+ long rc, ret;
+ u64 *num_entries;
+ u64 to_copy;
+ int htmstatus_flag;
+
+ /*
+ * Invoke H_HTM call with:
+ * - operation as htm status (H_HTM_OP_STATUS)
+ * - last three values as addr, size and offset
+ */
+ rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+ htmtype, H_HTM_OP_STATUS, virt_to_phys(htm_status_buf),
+ PAGE_SIZE, 0);
+
+ ret = htm_return_check(rc);
+ if (ret <= 0) {
+ pr_debug("H_HTM hcall failed for op: H_HTM_OP_STATUS, returning %ld\n", ret);
+ return ret;
+ }
+
+ /*
+ * HTM status buffer, start of buffer + 0x10 gives the
+ * number of HTM entries in the buffer. Each nest htm status
+ * entry is 0x6 bytes where each core htm status entry is
+ * 0x8 bytes.
+ * So total count to copy is:
+ * 32 bytes (for first 7 fields) + (number of HTM entries * entry size)
+ */
+ num_entries = htm_status_buf + 0x10;
+ if (htmtype == 0x2)
+ htmstatus_flag = 0x8;
+ else
+ htmstatus_flag = 0x6;
+ to_copy = 32 + (be64_to_cpu(*num_entries) * htmstatus_flag);
+ return simple_read_from_buffer(ubuf, count, ppos, htm_status_buf, to_copy);
+}
+
+static const struct file_operations htmstatus_fops = {
+ .llseek = NULL,
+ .read = htmstatus_read,
+ .open = simple_open,
+};
+
DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n");
@@ -235,6 +283,15 @@ 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 interface file to present status of HTM */
+ htm_status_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!htm_status_buf) {
+ pr_err("Failed to allocate htmstatus buf\n");
+ return -ENOMEM;
+ }
+
+ debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);
+
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH V3 5/9] powerpc/pseries/htmdump: Add htm info support to htmdump module
2025-04-20 18:08 [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM) Athira Rajeev
` (3 preceding siblings ...)
2025-04-20 18:08 ` [PATCH V3 4/9] powerpc/pseries/htmdump: Add htm status " Athira Rajeev
@ 2025-04-20 18:08 ` Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 6/9] powerpc/pseries/htmdump: Add htm setup " Athira Rajeev
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Athira Rajeev @ 2025-04-20 18:08 UTC (permalink / raw)
To: maddy, linuxppc-dev
Cc: atrajeev, disgoel, hbathini, Aditya.Bodkhe1, adubey, skb99,
sshegde, riteshh, Tejas.Manhas1, venkat88
Support dumping system processor configuration from Hardware
Trace Macro (HTM) function via debugfs interface. Under
debugfs folder "/sys/kernel/debug/powerpc/htmdump", add
file "htminfo".
The interface allows only read of this file which will present the
content of HTM buffer from the hcall. The 16th offset of HTM
buffer has value for the number of entries for array of processors.
Use this information to copy data to the debugfs file
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
---
arch/powerpc/platforms/pseries/htmdump.c | 51 ++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/htmdump.c b/arch/powerpc/platforms/pseries/htmdump.c
index be28391e6d1f..3ba1114d3d19 100644
--- a/arch/powerpc/platforms/pseries/htmdump.c
+++ b/arch/powerpc/platforms/pseries/htmdump.c
@@ -13,6 +13,7 @@
static void *htm_buf;
static void *htm_status_buf;
+static void *htm_info_buf;
static u32 nodeindex;
static u32 nodalchipindex;
static u32 coreindexonchip;
@@ -253,6 +254,48 @@ static const struct file_operations htmstatus_fops = {
.open = simple_open,
};
+static ssize_t htminfo_read(struct file *filp, char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ void *htm_info_buf = filp->private_data;
+ long rc, ret;
+ u64 *num_entries;
+ u64 to_copy;
+
+ /*
+ * Invoke H_HTM call with:
+ * - operation as htm status (H_HTM_OP_STATUS)
+ * - last three values as addr, size and offset
+ */
+ rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+ htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, virt_to_phys(htm_info_buf),
+ PAGE_SIZE, 0);
+
+ ret = htm_return_check(rc);
+ if (ret <= 0) {
+ pr_debug("H_HTM hcall failed for op: H_HTM_OP_DUMP_SYSPROC_CONF, returning %ld\n", ret);
+ return ret;
+ }
+
+ /*
+ * HTM status buffer, start of buffer + 0x10 gives the
+ * number of HTM entries in the buffer. Each entry of processor
+ * is 16 bytes.
+ *
+ * So total count to copy is:
+ * 32 bytes (for first 5 fields) + (number of HTM entries * entry size)
+ */
+ num_entries = htm_info_buf + 0x10;
+ to_copy = 32 + (be64_to_cpu(*num_entries) * 16);
+ return simple_read_from_buffer(ubuf, count, ppos, htm_info_buf, to_copy);
+}
+
+static const struct file_operations htminfo_fops = {
+ .llseek = NULL,
+ .read = htminfo_read,
+ .open = simple_open,
+};
+
DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n");
@@ -290,7 +333,15 @@ static int htmdump_init_debugfs(void)
return -ENOMEM;
}
+ /* Debugfs interface file to present System Processor Configuration */
+ htm_info_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!htm_info_buf) {
+ pr_err("Failed to allocate htm info buf\n");
+ return -ENOMEM;
+ }
+
debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);
+ debugfs_create_file("htminfo", 0400, htmdump_debugfs_dir, htm_info_buf, &htminfo_fops);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH V3 6/9] powerpc/pseries/htmdump: Add htm setup support to htmdump module
2025-04-20 18:08 [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM) Athira Rajeev
` (4 preceding siblings ...)
2025-04-20 18:08 ` [PATCH V3 5/9] powerpc/pseries/htmdump: Add htm info " Athira Rajeev
@ 2025-04-20 18:08 ` Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 7/9] powerpc/pseries/htmdump: Add htm flags " Athira Rajeev
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Athira Rajeev @ 2025-04-20 18:08 UTC (permalink / raw)
To: maddy, linuxppc-dev
Cc: atrajeev, disgoel, hbathini, Aditya.Bodkhe1, adubey, skb99,
sshegde, riteshh, Tejas.Manhas1, venkat88
Add htm setup support to htmdump module. To use the
HTM (Hardware Trace Macro), HTM buffer has to be allocated.
Support setup of HTM buffers via debugfs interface. Under
debugfs folder, "/sys/kernel/debug/powerpc/htmdump", add file
"htmsetup". The interface allows setup of HTM buffer by writing
size of HTM buffer in power of 2 to the "htmsetup" file
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
---
arch/powerpc/platforms/pseries/htmdump.c | 38 ++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/htmdump.c b/arch/powerpc/platforms/pseries/htmdump.c
index 3ba1114d3d19..39657e8655cb 100644
--- a/arch/powerpc/platforms/pseries/htmdump.c
+++ b/arch/powerpc/platforms/pseries/htmdump.c
@@ -20,6 +20,8 @@ static u32 coreindexonchip;
static u32 htmtype;
static u32 htmconfigure;
static u32 htmstart;
+static u32 htmsetup;
+
static struct dentry *htmdump_debugfs_dir;
#define HTM_ENABLE 1
#define HTM_DISABLE 0
@@ -296,8 +298,43 @@ static const struct file_operations htminfo_fops = {
.open = simple_open,
};
+static int htmsetup_set(void *data, u64 val)
+{
+ long rc, ret;
+
+ /*
+ * Input value: HTM buffer size in the power of 2
+ * example: hex value 0x21 ( decimal: 33 ) is for
+ * 8GB
+ * Invoke H_HTM call with:
+ * - operation as htm start (H_HTM_OP_SETUP)
+ * - parameter 1 set to input value.
+ * - last two values are unused, hence set to zero
+ */
+ rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
+ htmtype, H_HTM_OP_SETUP, val, 0, 0);
+
+ ret = htm_return_check(rc);
+ if (ret <= 0) {
+ pr_debug("H_HTM hcall failed for op: H_HTM_OP_SETUP, returning %ld\n", ret);
+ return ret;
+ }
+
+ /* Set htmsetup if H_HTM_OP_SETUP operation succeeds */
+ htmsetup = val;
+
+ return 0;
+}
+
+static int htmsetup_get(void *data, u64 *val)
+{
+ *val = htmsetup;
+ 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");
static int htmdump_init_debugfs(void)
{
@@ -325,6 +362,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 interface file to present status of HTM */
htm_status_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH V3 7/9] powerpc/pseries/htmdump: Add htm flags support to htmdump module
2025-04-20 18:08 [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM) Athira Rajeev
` (5 preceding siblings ...)
2025-04-20 18:08 ` [PATCH V3 6/9] powerpc/pseries/htmdump: Add htm setup " Athira Rajeev
@ 2025-04-20 18:08 ` Athira Rajeev
2025-04-20 18:08 ` [PATCH V3 8/9] powerpc/pseries/htmdump: Add htm capabilities " Athira Rajeev
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Athira Rajeev @ 2025-04-20 18:08 UTC (permalink / raw)
To: maddy, linuxppc-dev
Cc: atrajeev, disgoel, hbathini, Aditya.Bodkhe1, adubey, skb99,
sshegde, riteshh, Tejas.Manhas1, venkat88
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
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH V3 8/9] powerpc/pseries/htmdump: Add htm capabilities support to htmdump module
2025-04-20 18:08 [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM) Athira Rajeev
` (6 preceding siblings ...)
2025-04-20 18:08 ` [PATCH V3 7/9] powerpc/pseries/htmdump: Add htm flags " Athira Rajeev
@ 2025-04-20 18:08 ` 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
9 siblings, 0 replies; 11+ messages in thread
From: Athira Rajeev @ 2025-04-20 18:08 UTC (permalink / raw)
To: maddy, linuxppc-dev
Cc: atrajeev, disgoel, hbathini, Aditya.Bodkhe1, adubey, skb99,
sshegde, riteshh, Tejas.Manhas1, venkat88
Support dumping HTM capabilities information from Hardware
Trace Macro (HTM) function via debugfs interface. Under
debugfs folder "/sys/kernel/debug/powerpc/htmdump", add
file "htmcaps".
The interface allows only read of this file which will present the
content of HTM buffer from the hcall.
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
---
arch/powerpc/platforms/pseries/htmdump.c | 40 ++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/htmdump.c b/arch/powerpc/platforms/pseries/htmdump.c
index dc5cdcd8c3c3..af15d50c924b 100644
--- a/arch/powerpc/platforms/pseries/htmdump.c
+++ b/arch/powerpc/platforms/pseries/htmdump.c
@@ -14,6 +14,7 @@
static void *htm_buf;
static void *htm_status_buf;
static void *htm_info_buf;
+static void *htm_caps_buf;
static u32 nodeindex;
static u32 nodalchipindex;
static u32 coreindexonchip;
@@ -304,12 +305,43 @@ static ssize_t htminfo_read(struct file *filp, char __user *ubuf,
return simple_read_from_buffer(ubuf, count, ppos, htm_info_buf, to_copy);
}
+static ssize_t htmcaps_read(struct file *filp, char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ void *htm_caps_buf = filp->private_data;
+ long rc, ret;
+
+ /*
+ * Invoke H_HTM call with:
+ * - operation as htm capabilities (H_HTM_OP_CAPABILITIES)
+ * - last three values as addr, size (0x80 for Capabilities Output Buffer
+ * and zero
+ */
+ rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
+ htmtype, H_HTM_OP_CAPABILITIES, virt_to_phys(htm_caps_buf),
+ 0x80, 0);
+
+ ret = htm_return_check(rc);
+ if (ret <= 0) {
+ pr_debug("H_HTM hcall failed for op: H_HTM_OP_CAPABILITIES, returning %ld\n", ret);
+ return ret;
+ }
+
+ return simple_read_from_buffer(ubuf, count, ppos, htm_caps_buf, 0x80);
+}
+
static const struct file_operations htminfo_fops = {
.llseek = NULL,
.read = htminfo_read,
.open = simple_open,
};
+static const struct file_operations htmcaps_fops = {
+ .llseek = NULL,
+ .read = htmcaps_read,
+ .open = simple_open,
+};
+
static int htmsetup_set(void *data, u64 val)
{
long rc, ret;
@@ -417,8 +449,16 @@ static int htmdump_init_debugfs(void)
return -ENOMEM;
}
+ /* Debugfs interface file to present HTM capabilities */
+ htm_caps_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!htm_caps_buf) {
+ pr_err("Failed to allocate htm caps buf\n");
+ return -ENOMEM;
+ }
+
debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);
debugfs_create_file("htminfo", 0400, htmdump_debugfs_dir, htm_info_buf, &htminfo_fops);
+ debugfs_create_file("htmcaps", 0400, htmdump_debugfs_dir, htm_caps_buf, &htmcaps_fops);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH V3 9/9] powerpc/pseries/htmdump: Add documentation for H_HTM debugfs interface
2025-04-20 18:08 [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM) Athira Rajeev
` (7 preceding siblings ...)
2025-04-20 18:08 ` [PATCH V3 8/9] powerpc/pseries/htmdump: Add htm capabilities " Athira Rajeev
@ 2025-04-20 18:08 ` Athira Rajeev
2025-05-14 4:03 ` [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM) Madhavan Srinivasan
9 siblings, 0 replies; 11+ messages in thread
From: Athira Rajeev @ 2025-04-20 18:08 UTC (permalink / raw)
To: maddy, linuxppc-dev
Cc: atrajeev, disgoel, hbathini, Aditya.Bodkhe1, adubey, skb99,
sshegde, riteshh, Tejas.Manhas1, venkat88
Documentation for HTM (Hardware Trace Macro) debugfs interface
and how it can be used to configure/control the HTM operations.
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
---
Documentation/arch/powerpc/htm.rst | 104 +++++++++++++++++++++++++++++
1 file changed, 104 insertions(+)
create mode 100644 Documentation/arch/powerpc/htm.rst
diff --git a/Documentation/arch/powerpc/htm.rst b/Documentation/arch/powerpc/htm.rst
new file mode 100644
index 000000000000..fcb4eb6306b1
--- /dev/null
+++ b/Documentation/arch/powerpc/htm.rst
@@ -0,0 +1,104 @@
+.. SPDX-License-Identifier: GPL-2.0
+.. _htm:
+
+===================================
+HTM (Hardware Trace Macro)
+===================================
+
+Athira Rajeev, 2 Mar 2025
+
+.. contents::
+ :depth: 3
+
+
+Basic overview
+==============
+
+H_HTM is used as an interface for executing Hardware Trace Macro (HTM)
+functions, including setup, configuration, control and dumping of the HTM data.
+For using HTM, it is required to setup HTM buffers and HTM operations can
+be controlled using the H_HTM hcall. The hcall can be invoked for any core/chip
+of the system from within a partition itself. To use this feature, a debugfs
+folder called "htmdump" is present under /sys/kernel/debug/powerpc.
+
+
+HTM debugfs example usage
+=========================
+
+.. code-block:: sh
+
+ # ls /sys/kernel/debug/powerpc/htmdump/
+ coreindexonchip htmcaps htmconfigure htmflags htminfo htmsetup
+ htmstart htmstatus htmtype nodalchipindex nodeindex trace
+
+Details on each file:
+
+* nodeindex, nodalchipindex, coreindexonchip specifies which partition to configure the HTM for.
+* htmtype: specifies the type of HTM. Supported target is hardwareTarget.
+* trace: is to read the HTM data.
+* htmconfigure: Configure/Deconfigure the HTM. Writing 1 to the file will configure the trace, writing 0 to the file will do deconfigure.
+* htmstart: start/Stop the HTM. Writing 1 to the file will start the tracing, writing 0 to the file will stop the tracing.
+* htmstatus: get the status of HTM. This is needed to understand the HTM state after each operation.
+* htmsetup: set the HTM buffer size. Size of HTM buffer is in power of 2
+* htminfo: provides the system processor configuration details. This is needed to understand the appropriate values for nodeindex, nodalchipindex, coreindexonchip.
+* htmcaps : provides the HTM capabilities like minimum/maximum buffer size, what kind of tracing the HTM supports etc.
+* htmflags : allows to pass flags to hcall. Currently supports controlling the wrapping of HTM buffer.
+
+To see the system processor configuration details:
+
+.. code-block:: sh
+
+ # cat /sys/kernel/debug/powerpc/htmdump/htminfo > htminfo_file
+
+The result can be interpreted using hexdump.
+
+To collect HTM traces for a partition represented by nodeindex as
+zero, nodalchipindex as 1 and coreindexonchip as 12
+
+.. code-block:: sh
+
+ # cd /sys/kernel/debug/powerpc/htmdump/
+ # echo 2 > htmtype
+ # echo 33 > htmsetup ( sets 8GB memory for HTM buffer, number is size in power of 2 )
+
+This requires a CEC reboot to get the HTM buffers allocated.
+
+.. code-block:: sh
+
+ # cd /sys/kernel/debug/powerpc/htmdump/
+ # echo 2 > htmtype
+ # echo 0 > nodeindex
+ # echo 1 > nodalchipindex
+ # echo 12 > coreindexonchip
+ # echo 1 > htmflags # to set noWrap for HTM buffers
+ # echo 1 > htmconfigure # Configure the HTM
+ # echo 1 > htmstart # Start the HTM
+ # echo 0 > htmstart # Stop the HTM
+ # echo 0 > htmconfigure # Deconfigure the HTM
+ # cat htmstatus # Dump the status of HTM entries as data
+
+Above will set the htmtype and core details, followed by executing respective HTM operation.
+
+Read the HTM trace data
+========================
+
+After starting the trace collection, run the workload
+of interest. Stop the trace collection after required period
+of time, and read the trace file.
+
+.. code-block:: sh
+
+ # cat /sys/kernel/debug/powerpc/htmdump/trace > trace_file
+
+This trace file will contain the relevant instruction traces
+collected during the workload execution. And can be used as
+input file for trace decoders to understand data.
+
+Benefits of using HTM debugfs interface
+=======================================
+
+It is now possible to collect traces for a particular core/chip
+from within any partition of the system and decode it. Through
+this enablement, a small partition can be dedicated to collect the
+trace data and analyze to provide important information for Performance
+analysis, Software tuning, or Hardware debug.
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM)
2025-04-20 18:08 [PATCH V3 0/9] Add support for configure and control of Hardware Trace Macro(HTM) Athira Rajeev
` (8 preceding siblings ...)
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 ` Madhavan Srinivasan
9 siblings, 0 replies; 11+ messages in thread
From: Madhavan Srinivasan @ 2025-05-14 4:03 UTC (permalink / raw)
To: linuxppc-dev, Athira Rajeev
Cc: disgoel, hbathini, Aditya.Bodkhe1, adubey, skb99, sshegde,
riteshh, Tejas.Manhas1, venkat88
On Sun, 20 Apr 2025 23:38:35 +0530, Athira Rajeev wrote:
> H_HTM (Hardware Trace Macro) hypervisor call is an HCALL to export
> data from Hardware Trace Macro (HTM) function. The debugfs interface
> to export the HTM function data in a partition currently supports only
> dumping of HTM data in an lpar. Patchset add support for configuration
> and control of HTM function via debugfs interface.
>
> With the patchset, after loading htmdump module,
> below files are present:
>
> [...]
Applied to powerpc/next.
[1/9] powerpc/pseries/htmdump: Add htm_hcall_wrapper to integrate other htm operations
https://git.kernel.org/powerpc/c/6e204ef3b73e41e46784fdd298c3d81caed84873
[2/9] powerpc/pseries/htmdump: Add htm configure support to htmdump module
https://git.kernel.org/powerpc/c/c6edd034e39f745feb9ad5298b92e0fec5bb9e9f
[3/9] powerpc/pseries/htmdump: Add htm start support to htmdump module
https://git.kernel.org/powerpc/c/e03e4b12dee95bb87507a50772f927d0eb152ca1
[4/9] powerpc/pseries/htmdump: Add htm status support to htmdump module
https://git.kernel.org/powerpc/c/627cf584f4c36acb52230ffc47403cf9469ec9d0
[5/9] powerpc/pseries/htmdump: Add htm info support to htmdump module
https://git.kernel.org/powerpc/c/dea7384e14e7f9429021544d0d710fbef8445def
[6/9] powerpc/pseries/htmdump: Add htm setup support to htmdump module
https://git.kernel.org/powerpc/c/78fb17ac68bf59e5e36212e34a2b05eec29a389f
[7/9] powerpc/pseries/htmdump: Add htm flags support to htmdump module
https://git.kernel.org/powerpc/c/d3f24bf27b2de2bbf35faae72ca3a81e23ac9e22
[8/9] powerpc/pseries/htmdump: Add htm capabilities support to htmdump module
https://git.kernel.org/powerpc/c/143a2584627cc02af81261c0201f9a69c08241a5
[9/9] powerpc/pseries/htmdump: Add documentation for H_HTM debugfs interface
https://git.kernel.org/powerpc/c/ab1456c5aa7a63d5145547fc644bd4580dd253f2
Thanks
^ permalink raw reply [flat|nested] 11+ messages in thread