Skip to content

Commit e03e4b1

Browse files
Athira Rajeevmaddy-kerneldev
authored andcommitted
powerpc/pseries/htmdump: Add htm start support to htmdump module
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 <[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 c6edd03 commit e03e4b1

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

arch/powerpc/platforms/pseries/htmdump.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ static u32 nodalchipindex;
1717
static u32 coreindexonchip;
1818
static u32 htmtype;
1919
static u32 htmconfigure;
20+
static u32 htmstart;
2021
static struct dentry *htmdump_debugfs_dir;
2122
#define HTM_ENABLE 1
2223
#define HTM_DISABLE 0
@@ -157,7 +158,55 @@ static int htmconfigure_get(void *data, u64 *val)
157158
return 0;
158159
}
159160

161+
static int htmstart_set(void *data, u64 val)
162+
{
163+
long rc, ret;
164+
165+
/*
166+
* value as 1: start HTM
167+
* value as 0: stop HTM
168+
* Return -EINVAL for other values.
169+
*/
170+
if (val == HTM_ENABLE) {
171+
/*
172+
* Invoke H_HTM call with:
173+
* - operation as htm start (H_HTM_OP_START)
174+
* - last three values are unused, hence set to zero
175+
*/
176+
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
177+
htmtype, H_HTM_OP_START, 0, 0, 0);
178+
179+
} else if (val == HTM_DISABLE) {
180+
/*
181+
* Invoke H_HTM call with:
182+
* - operation as htm stop (H_HTM_OP_STOP)
183+
* - last three values are unused, hence set to zero
184+
*/
185+
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
186+
htmtype, H_HTM_OP_STOP, 0, 0, 0);
187+
} else
188+
return -EINVAL;
189+
190+
ret = htm_return_check(rc);
191+
if (ret <= 0) {
192+
pr_debug("H_HTM hcall failed, returning %ld\n", ret);
193+
return ret;
194+
}
195+
196+
/* Set htmstart if H_HTM_OP_START/H_HTM_OP_STOP operation succeeds */
197+
htmstart = val;
198+
199+
return 0;
200+
}
201+
202+
static int htmstart_get(void *data, u64 *val)
203+
{
204+
*val = htmstart;
205+
return 0;
206+
}
207+
160208
DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
209+
DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n");
161210

162211
static int htmdump_init_debugfs(void)
163212
{
@@ -184,6 +233,7 @@ static int htmdump_init_debugfs(void)
184233
* Debugfs interface files to control HTM operations:
185234
*/
186235
debugfs_create_file("htmconfigure", 0600, htmdump_debugfs_dir, NULL, &htmconfigure_fops);
236+
debugfs_create_file("htmstart", 0600, htmdump_debugfs_dir, NULL, &htmstart_fops);
187237

188238
return 0;
189239
}

0 commit comments

Comments
 (0)