Skip to content

Commit 78fb17a

Browse files
Athira Rajeevmaddy-kerneldev
authored andcommitted
powerpc/pseries/htmdump: Add htm setup support to htmdump module
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 <[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 dea7384 commit 78fb17a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

arch/powerpc/platforms/pseries/htmdump.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ static u32 coreindexonchip;
2020
static u32 htmtype;
2121
static u32 htmconfigure;
2222
static u32 htmstart;
23+
static u32 htmsetup;
24+
2325
static struct dentry *htmdump_debugfs_dir;
2426
#define HTM_ENABLE 1
2527
#define HTM_DISABLE 0
@@ -296,8 +298,43 @@ static const struct file_operations htminfo_fops = {
296298
.open = simple_open,
297299
};
298300

301+
static int htmsetup_set(void *data, u64 val)
302+
{
303+
long rc, ret;
304+
305+
/*
306+
* Input value: HTM buffer size in the power of 2
307+
* example: hex value 0x21 ( decimal: 33 ) is for
308+
* 8GB
309+
* Invoke H_HTM call with:
310+
* - operation as htm start (H_HTM_OP_SETUP)
311+
* - parameter 1 set to input value.
312+
* - last two values are unused, hence set to zero
313+
*/
314+
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
315+
htmtype, H_HTM_OP_SETUP, val, 0, 0);
316+
317+
ret = htm_return_check(rc);
318+
if (ret <= 0) {
319+
pr_debug("H_HTM hcall failed for op: H_HTM_OP_SETUP, returning %ld\n", ret);
320+
return ret;
321+
}
322+
323+
/* Set htmsetup if H_HTM_OP_SETUP operation succeeds */
324+
htmsetup = val;
325+
326+
return 0;
327+
}
328+
329+
static int htmsetup_get(void *data, u64 *val)
330+
{
331+
*val = htmsetup;
332+
return 0;
333+
}
334+
299335
DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
300336
DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n");
337+
DEFINE_SIMPLE_ATTRIBUTE(htmsetup_fops, htmsetup_get, htmsetup_set, "%llu\n");
301338

302339
static int htmdump_init_debugfs(void)
303340
{
@@ -325,6 +362,7 @@ static int htmdump_init_debugfs(void)
325362
*/
326363
debugfs_create_file("htmconfigure", 0600, htmdump_debugfs_dir, NULL, &htmconfigure_fops);
327364
debugfs_create_file("htmstart", 0600, htmdump_debugfs_dir, NULL, &htmstart_fops);
365+
debugfs_create_file("htmsetup", 0600, htmdump_debugfs_dir, NULL, &htmsetup_fops);
328366

329367
/* Debugfs interface file to present status of HTM */
330368
htm_status_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);

0 commit comments

Comments
 (0)