Skip to content

Commit d3f24bf

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

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

arch/powerpc/include/asm/plpar_wrappers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ static inline long htm_call(unsigned long flags, unsigned long target,
8181
param1, param2, param3);
8282
}
8383

84-
static inline long htm_hcall_wrapper(unsigned long nodeindex,
84+
static inline long htm_hcall_wrapper(unsigned long flags, unsigned long nodeindex,
8585
unsigned long nodalchipindex, unsigned long coreindexonchip,
8686
unsigned long type, unsigned long htm_op, unsigned long param1, unsigned long param2,
8787
unsigned long param3)
8888
{
89-
return htm_call(H_HTM_FLAGS_HARDWARE_TARGET,
89+
return htm_call(H_HTM_FLAGS_HARDWARE_TARGET | flags,
9090
H_HTM_TARGET_NODE_INDEX(nodeindex) |
9191
H_HTM_TARGET_NODAL_CHIP_INDEX(nodalchipindex) |
9292
H_HTM_TARGET_CORE_INDEX_ON_CHIP(coreindexonchip),

arch/powerpc/platforms/pseries/htmdump.c

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ static u32 htmtype;
2121
static u32 htmconfigure;
2222
static u32 htmstart;
2323
static u32 htmsetup;
24+
static u64 htmflags;
2425

2526
static struct dentry *htmdump_debugfs_dir;
2627
#define HTM_ENABLE 1
2728
#define HTM_DISABLE 0
29+
#define HTM_NOWRAP 1
30+
#define HTM_WRAP 0
2831

2932
/*
3033
* Check the return code for H_HTM hcall.
@@ -94,7 +97,7 @@ static ssize_t htmdump_read(struct file *filp, char __user *ubuf,
9497
* - operation as htm dump (H_HTM_OP_DUMP_DATA)
9598
* - last three values are address, size and offset
9699
*/
97-
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
100+
rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
98101
htmtype, H_HTM_OP_DUMP_DATA, virt_to_phys(htm_buf),
99102
PAGE_SIZE, page);
100103

@@ -119,6 +122,7 @@ static const struct file_operations htmdump_fops = {
119122
static int htmconfigure_set(void *data, u64 val)
120123
{
121124
long rc, ret;
125+
unsigned long param1 = -1, param2 = -1;
122126

123127
/*
124128
* value as 1 : configure HTM.
@@ -129,17 +133,25 @@ static int htmconfigure_set(void *data, u64 val)
129133
/*
130134
* Invoke H_HTM call with:
131135
* - operation as htm configure (H_HTM_OP_CONFIGURE)
136+
* - If htmflags is set, param1 and param2 will be -1
137+
* which is an indicator to use default htm mode reg mask
138+
* and htm mode reg value.
132139
* - last three values are unused, hence set to zero
133140
*/
134-
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
135-
htmtype, H_HTM_OP_CONFIGURE, 0, 0, 0);
141+
if (!htmflags) {
142+
param1 = 0;
143+
param2 = 0;
144+
}
145+
146+
rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
147+
htmtype, H_HTM_OP_CONFIGURE, param1, param2, 0);
136148
} else if (val == HTM_DISABLE) {
137149
/*
138150
* Invoke H_HTM call with:
139151
* - operation as htm deconfigure (H_HTM_OP_DECONFIGURE)
140152
* - last three values are unused, hence set to zero
141153
*/
142-
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
154+
rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
143155
htmtype, H_HTM_OP_DECONFIGURE, 0, 0, 0);
144156
} else
145157
return -EINVAL;
@@ -177,7 +189,7 @@ static int htmstart_set(void *data, u64 val)
177189
* - operation as htm start (H_HTM_OP_START)
178190
* - last three values are unused, hence set to zero
179191
*/
180-
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
192+
rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
181193
htmtype, H_HTM_OP_START, 0, 0, 0);
182194

183195
} else if (val == HTM_DISABLE) {
@@ -186,7 +198,7 @@ static int htmstart_set(void *data, u64 val)
186198
* - operation as htm stop (H_HTM_OP_STOP)
187199
* - last three values are unused, hence set to zero
188200
*/
189-
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
201+
rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
190202
htmtype, H_HTM_OP_STOP, 0, 0, 0);
191203
} else
192204
return -EINVAL;
@@ -223,7 +235,7 @@ static ssize_t htmstatus_read(struct file *filp, char __user *ubuf,
223235
* - operation as htm status (H_HTM_OP_STATUS)
224236
* - last three values as addr, size and offset
225237
*/
226-
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
238+
rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
227239
htmtype, H_HTM_OP_STATUS, virt_to_phys(htm_status_buf),
228240
PAGE_SIZE, 0);
229241

@@ -269,7 +281,7 @@ static ssize_t htminfo_read(struct file *filp, char __user *ubuf,
269281
* - operation as htm status (H_HTM_OP_STATUS)
270282
* - last three values as addr, size and offset
271283
*/
272-
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
284+
rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
273285
htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, virt_to_phys(htm_info_buf),
274286
PAGE_SIZE, 0);
275287

@@ -311,7 +323,7 @@ static int htmsetup_set(void *data, u64 val)
311323
* - parameter 1 set to input value.
312324
* - last two values are unused, hence set to zero
313325
*/
314-
rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip,
326+
rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip,
315327
htmtype, H_HTM_OP_SETUP, val, 0, 0);
316328

317329
ret = htm_return_check(rc);
@@ -332,9 +344,35 @@ static int htmsetup_get(void *data, u64 *val)
332344
return 0;
333345
}
334346

347+
static int htmflags_set(void *data, u64 val)
348+
{
349+
/*
350+
* Input value:
351+
* Currently supported flag value is to enable/disable
352+
* HTM buffer wrap. wrap is used along with "configure"
353+
* to prevent HTM buffer from wrapping.
354+
* Writing 1 will set noWrap while configuring HTM
355+
*/
356+
if (val == HTM_NOWRAP)
357+
htmflags = H_HTM_FLAGS_NOWRAP;
358+
else if (val == HTM_WRAP)
359+
htmflags = 0;
360+
else
361+
return -EINVAL;
362+
363+
return 0;
364+
}
365+
366+
static int htmflags_get(void *data, u64 *val)
367+
{
368+
*val = htmflags;
369+
return 0;
370+
}
371+
335372
DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
336373
DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n");
337374
DEFINE_SIMPLE_ATTRIBUTE(htmsetup_fops, htmsetup_get, htmsetup_set, "%llu\n");
375+
DEFINE_SIMPLE_ATTRIBUTE(htmflags_fops, htmflags_get, htmflags_set, "%llu\n");
338376

339377
static int htmdump_init_debugfs(void)
340378
{
@@ -363,6 +401,7 @@ static int htmdump_init_debugfs(void)
363401
debugfs_create_file("htmconfigure", 0600, htmdump_debugfs_dir, NULL, &htmconfigure_fops);
364402
debugfs_create_file("htmstart", 0600, htmdump_debugfs_dir, NULL, &htmstart_fops);
365403
debugfs_create_file("htmsetup", 0600, htmdump_debugfs_dir, NULL, &htmsetup_fops);
404+
debugfs_create_file("htmflags", 0600, htmdump_debugfs_dir, NULL, &htmflags_fops);
366405

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

0 commit comments

Comments
 (0)