Skip to content

Commit c6edd03

Browse files
Athira Rajeevmaddy-kerneldev
authored andcommitted
powerpc/pseries/htmdump: Add htm configure support to htmdump module
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 <[email protected]> Tested-by: Venkat Rao Bagalkote <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 6e204ef commit c6edd03

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

arch/powerpc/platforms/pseries/htmdump.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ static u32 nodeindex;
1616
static u32 nodalchipindex;
1717
static u32 coreindexonchip;
1818
static u32 htmtype;
19+
static u32 htmconfigure;
1920
static struct dentry *htmdump_debugfs_dir;
21+
#define HTM_ENABLE 1
22+
#define HTM_DISABLE 0
2023

2124
/*
2225
* Check the return code for H_HTM hcall.
@@ -108,6 +111,54 @@ static const struct file_operations htmdump_fops = {
108111
.open = simple_open,
109112
};
110113

114+
static int htmconfigure_set(void *data, u64 val)
115+
{
116+
long rc, ret;
117+
118+
/*
119+
* value as 1 : configure HTM.
120+
* value as 0 : deconfigure HTM. Return -EINVAL for
121+
* other values.
122+
*/
123+
if (val == HTM_ENABLE) {
124+
/*
125+
* Invoke H_HTM call with:
126+
* - operation as htm configure (H_HTM_OP_CONFIGURE)
127+
* - last three values are unused, hence set to zero
128+
*/
129+
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
130+
htmtype, H_HTM_OP_CONFIGURE, 0, 0, 0);
131+
} else if (val == HTM_DISABLE) {
132+
/*
133+
* Invoke H_HTM call with:
134+
* - operation as htm deconfigure (H_HTM_OP_DECONFIGURE)
135+
* - last three values are unused, hence set to zero
136+
*/
137+
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
138+
htmtype, H_HTM_OP_DECONFIGURE, 0, 0, 0);
139+
} else
140+
return -EINVAL;
141+
142+
ret = htm_return_check(rc);
143+
if (ret <= 0) {
144+
pr_debug("H_HTM hcall failed, returning %ld\n", ret);
145+
return ret;
146+
}
147+
148+
/* Set htmconfigure if operation succeeds */
149+
htmconfigure = val;
150+
151+
return 0;
152+
}
153+
154+
static int htmconfigure_get(void *data, u64 *val)
155+
{
156+
*val = htmconfigure;
157+
return 0;
158+
}
159+
160+
DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
161+
111162
static int htmdump_init_debugfs(void)
112163
{
113164
htm_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
@@ -129,6 +180,11 @@ static int htmdump_init_debugfs(void)
129180
htmdump_debugfs_dir, &htmtype);
130181
debugfs_create_file("trace", 0400, htmdump_debugfs_dir, htm_buf, &htmdump_fops);
131182

183+
/*
184+
* Debugfs interface files to control HTM operations:
185+
*/
186+
debugfs_create_file("htmconfigure", 0600, htmdump_debugfs_dir, NULL, &htmconfigure_fops);
187+
132188
return 0;
133189
}
134190

0 commit comments

Comments
 (0)