Re: [PATCH v3 2/3] platform/x86/intel/tpmi: Add debugfs interface
From: Andy Shevchenko
Date: Thu Jul 13 2023 - 12:48:22 EST
On Wed, Jul 12, 2023 at 03:59:49PM -0700, Srinivas Pandruvada wrote:
> Add debugfs interface for debugging TPMI configuration and register
> contents. This shows PFS (PM Feature structure) for each TPMI device.
>
> For each feature, show full register contents and allow to modify
> register at an offset.
>
> This debugfs interface is not present on locked down kernel with no
> DEVMEM access and without CAP_SYS_RAWIO permission.
...
> + for (i = 0; i < tpmi_info->feature_count; ++i) {
As I explained in the discussion in previous version the preincrement is rising
unneeded attention when there is nothing special about it.
> + pfs = &tpmi_info->tpmi_features[i];
> + ret = tpmi_read_feature_status(tpmi_info, pfs->pfs_header.tpmi_id, &locked,
> + &disabled);
> + if (ret) {
> + locked = 'U';
> + disabled = 'U';
> + } else {
> + disabled = disabled ? 'Y' : 'N';
> + locked = locked ? 'Y' : 'N';
> + }
> + seq_printf(s, "0x%02x\t\t0x%02x\t\t0x%04x\t\t0x%04x\t\t0x%02x\t\t0x%08x\t%c\t%c\n",
> + pfs->pfs_header.tpmi_id, pfs->pfs_header.num_entries,
> + pfs->pfs_header.entry_size, pfs->pfs_header.cap_offset,
> + pfs->pfs_header.attribute, pfs->vsec_offset, locked, disabled);
> + }
...
> + for (count = 0; count < pfs->pfs_header.num_entries; ++count) {
Ditto.
> + seq_printf(s, "TPMI Instance:%d offset:0x%x\n", count, off);
> +
> + mem = ioremap(off, size);
> + if (!mem) {
> + ret = -ENOMEM;
> + break;
> + }
> +
> + memcpy_fromio(buffer, mem, size);
> +
> + seq_hex_dump(s, " ", DUMP_PREFIX_OFFSET, row_size, sizeof(u32), buffer, size,
> + false);
> +
> + iounmap(mem);
> +
> + off += size;
> + }
...
> + for (i = 0; i < tpmi_info->feature_count; ++i) {
Ditto.
> + struct intel_tpmi_pm_feature *pfs;
> + struct dentry *dir;
> +
> + pfs = &tpmi_info->tpmi_features[i];
> + snprintf(name, sizeof(name), "tpmi-id-%02x", pfs->pfs_header.tpmi_id);
> + dir = debugfs_create_dir(name, tpmi_info->dbgfs_dir);
> +
> + debugfs_create_file("mem_dump", 0444, dir, pfs, &tpmi_mem_dump_fops);
> + debugfs_create_file("mem_write", 0644, dir, pfs, &mem_write_ops);
> + }
> +}
--
With Best Regards,
Andy Shevchenko