|
13 | 13 |
|
14 | 14 | static void *htm_buf;
|
15 | 15 | static void *htm_status_buf;
|
| 16 | +static void *htm_info_buf; |
16 | 17 | static u32 nodeindex;
|
17 | 18 | static u32 nodalchipindex;
|
18 | 19 | static u32 coreindexonchip;
|
@@ -253,6 +254,48 @@ static const struct file_operations htmstatus_fops = {
|
253 | 254 | .open = simple_open,
|
254 | 255 | };
|
255 | 256 |
|
| 257 | +static ssize_t htminfo_read(struct file *filp, char __user *ubuf, |
| 258 | + size_t count, loff_t *ppos) |
| 259 | +{ |
| 260 | + void *htm_info_buf = filp->private_data; |
| 261 | + long rc, ret; |
| 262 | + u64 *num_entries; |
| 263 | + u64 to_copy; |
| 264 | + |
| 265 | + /* |
| 266 | + * Invoke H_HTM call with: |
| 267 | + * - operation as htm status (H_HTM_OP_STATUS) |
| 268 | + * - last three values as addr, size and offset |
| 269 | + */ |
| 270 | + rc = htm_hcall_wrapper(nodeindex, nodalchipindex, coreindexonchip, |
| 271 | + htmtype, H_HTM_OP_DUMP_SYSPROC_CONF, virt_to_phys(htm_info_buf), |
| 272 | + PAGE_SIZE, 0); |
| 273 | + |
| 274 | + ret = htm_return_check(rc); |
| 275 | + if (ret <= 0) { |
| 276 | + pr_debug("H_HTM hcall failed for op: H_HTM_OP_DUMP_SYSPROC_CONF, returning %ld\n", ret); |
| 277 | + return ret; |
| 278 | + } |
| 279 | + |
| 280 | + /* |
| 281 | + * HTM status buffer, start of buffer + 0x10 gives the |
| 282 | + * number of HTM entries in the buffer. Each entry of processor |
| 283 | + * is 16 bytes. |
| 284 | + * |
| 285 | + * So total count to copy is: |
| 286 | + * 32 bytes (for first 5 fields) + (number of HTM entries * entry size) |
| 287 | + */ |
| 288 | + num_entries = htm_info_buf + 0x10; |
| 289 | + to_copy = 32 + (be64_to_cpu(*num_entries) * 16); |
| 290 | + return simple_read_from_buffer(ubuf, count, ppos, htm_info_buf, to_copy); |
| 291 | +} |
| 292 | + |
| 293 | +static const struct file_operations htminfo_fops = { |
| 294 | + .llseek = NULL, |
| 295 | + .read = htminfo_read, |
| 296 | + .open = simple_open, |
| 297 | +}; |
| 298 | + |
256 | 299 | DEFINE_SIMPLE_ATTRIBUTE(htmconfigure_fops, htmconfigure_get, htmconfigure_set, "%llu\n");
|
257 | 300 | DEFINE_SIMPLE_ATTRIBUTE(htmstart_fops, htmstart_get, htmstart_set, "%llu\n");
|
258 | 301 |
|
@@ -290,7 +333,15 @@ static int htmdump_init_debugfs(void)
|
290 | 333 | return -ENOMEM;
|
291 | 334 | }
|
292 | 335 |
|
| 336 | + /* Debugfs interface file to present System Processor Configuration */ |
| 337 | + htm_info_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 338 | + if (!htm_info_buf) { |
| 339 | + pr_err("Failed to allocate htm info buf\n"); |
| 340 | + return -ENOMEM; |
| 341 | + } |
| 342 | + |
293 | 343 | debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);
|
| 344 | + debugfs_create_file("htminfo", 0400, htmdump_debugfs_dir, htm_info_buf, &htminfo_fops); |
294 | 345 |
|
295 | 346 | return 0;
|
296 | 347 | }
|
|
0 commit comments