|
14 | 14 | static void *htm_buf;
|
15 | 15 | static void *htm_status_buf;
|
16 | 16 | static void *htm_info_buf;
|
| 17 | +static void *htm_caps_buf; |
17 | 18 | static u32 nodeindex;
|
18 | 19 | static u32 nodalchipindex;
|
19 | 20 | static u32 coreindexonchip;
|
@@ -304,12 +305,43 @@ static ssize_t htminfo_read(struct file *filp, char __user *ubuf,
|
304 | 305 | return simple_read_from_buffer(ubuf, count, ppos, htm_info_buf, to_copy);
|
305 | 306 | }
|
306 | 307 |
|
| 308 | +static ssize_t htmcaps_read(struct file *filp, char __user *ubuf, |
| 309 | + size_t count, loff_t *ppos) |
| 310 | +{ |
| 311 | + void *htm_caps_buf = filp->private_data; |
| 312 | + long rc, ret; |
| 313 | + |
| 314 | + /* |
| 315 | + * Invoke H_HTM call with: |
| 316 | + * - operation as htm capabilities (H_HTM_OP_CAPABILITIES) |
| 317 | + * - last three values as addr, size (0x80 for Capabilities Output Buffer |
| 318 | + * and zero |
| 319 | + */ |
| 320 | + rc = htm_hcall_wrapper(htmflags, nodeindex, nodalchipindex, coreindexonchip, |
| 321 | + htmtype, H_HTM_OP_CAPABILITIES, virt_to_phys(htm_caps_buf), |
| 322 | + 0x80, 0); |
| 323 | + |
| 324 | + ret = htm_return_check(rc); |
| 325 | + if (ret <= 0) { |
| 326 | + pr_debug("H_HTM hcall failed for op: H_HTM_OP_CAPABILITIES, returning %ld\n", ret); |
| 327 | + return ret; |
| 328 | + } |
| 329 | + |
| 330 | + return simple_read_from_buffer(ubuf, count, ppos, htm_caps_buf, 0x80); |
| 331 | +} |
| 332 | + |
307 | 333 | static const struct file_operations htminfo_fops = {
|
308 | 334 | .llseek = NULL,
|
309 | 335 | .read = htminfo_read,
|
310 | 336 | .open = simple_open,
|
311 | 337 | };
|
312 | 338 |
|
| 339 | +static const struct file_operations htmcaps_fops = { |
| 340 | + .llseek = NULL, |
| 341 | + .read = htmcaps_read, |
| 342 | + .open = simple_open, |
| 343 | +}; |
| 344 | + |
313 | 345 | static int htmsetup_set(void *data, u64 val)
|
314 | 346 | {
|
315 | 347 | long rc, ret;
|
@@ -417,8 +449,16 @@ static int htmdump_init_debugfs(void)
|
417 | 449 | return -ENOMEM;
|
418 | 450 | }
|
419 | 451 |
|
| 452 | + /* Debugfs interface file to present HTM capabilities */ |
| 453 | + htm_caps_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 454 | + if (!htm_caps_buf) { |
| 455 | + pr_err("Failed to allocate htm caps buf\n"); |
| 456 | + return -ENOMEM; |
| 457 | + } |
| 458 | + |
420 | 459 | debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);
|
421 | 460 | debugfs_create_file("htminfo", 0400, htmdump_debugfs_dir, htm_info_buf, &htminfo_fops);
|
| 461 | + debugfs_create_file("htmcaps", 0400, htmdump_debugfs_dir, htm_caps_buf, &htmcaps_fops); |
422 | 462 |
|
423 | 463 | return 0;
|
424 | 464 | }
|
|
0 commit comments