ACPI: FPDT: expose FBPT and S3PT subtables via sysfs
v3 cover ACPI: FPDT: expose FBPT and S3PT subtables via sysfs
The ACPI Firmware Performance Data Table (FPDT) can contain two subtables:
1. Firmware Basic Boot Performance Table (FBPT)
2. S3 Performance Table (S3PT)
The existing /sys/firmware/acpi/tables/FPDT sysfs entry only exposes the top-level FPDT header, not the subtables themselves.
This series adds sysfs attributes at /sys/firmware/acpi/fpdt/FBPT and /sys/firmware/acpi/fpdt/S3PT that expose the raw contents of these subtables. This mirrors the model used by /sys/firmware/dmi/tables/DMI for DMI/SMBIOS data, and allows userspace tools to parse newer FPDT record types defined in recent ACPI specifications[1] (e.g. String Event Records, Microcontroller Boot Performance Data Records, etc.) without requiring kernel changes for each new record type.
---
Changes in v3:
- changed sysfs_create_bin_file() error handling to a non-fatal warning
Changes in v2:
- removed the intermediate /sys/firmware/acpi/tables/ subdirectory
- tightened file permissions for FBPT and S3PT from 0444 to 0400
- added documentation to Documentation/ABI/testing/sysfs-firmware-acpi
---
Nate DeSimone (2):
ACPI: FPDT: expose FBPT and S3PT subtables via sysfs
Documentation: ABI: add FBPT and S3PT entries to sysfs-firmware-acpi
Documentation/ABI/testing/sysfs-firmware-acpi | 6 ++++ drivers/acpi/acpi_fpdt.c | 28 +++++++++++++++++++ 2 files changed, 34 insertions(+)
base-commit: 24f9515de8778410e4b84c85b196c9850d2c1e18
Signature · 1 line
2.34.1
PATCH v3 1/2 ACPI: FPDT: expose FBPT and S3PT subtables via sysfs
Add sysfs files at /sys/firmware/acpi/fpdt/FBPT and /sys/firmware/acpi/fpdt/S3PT that expose the raw contents of the FPDT subtables. Note that /sys/firmware/acpi/tables/FPDT only provides the top level table, not the subtables. Adding access to the subtables enables a usage model similar to /sys/firmware/dmi/tables/DMI, allowing userspace tools to interpret newer record types (e.g. String Event Records, Microcontroller Boot Performance Data Records, etc.) defined in recent ACPI specifications[1] without requiring kernel changes.
--- drivers/acpi/acpi_fpdt.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/acpi/acpi_fpdt.c +28 -0
@@ -141,6 +141,9 @@ static const struct attribute_group boot_attr_group = { .name = "boot", }; +static BIN_ATTR(FBPT, 0400, sysfs_bin_attr_simple_read, NULL, 0); +static BIN_ATTR(S3PT, 0400, sysfs_bin_attr_simple_read, NULL, 0); +static struct kobject *fpdt_kobj;#if definedCONFIG_X86 && definedCONFIG_PHYS_ADDR_T_64BIT
@@ -254,9 +257,34 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type)break ; } } + +if (subtable_type ==SUBTABLE_FBPT ) { + bin_attr_FBPT.private = subtable_header; + bin_attr_FBPT.size = length; + result =sysfs_create_bin_file (fpdt_kobj, &bin_attr_FBPT); +if (result) +pr_warn ("Failed to create FBPT sysfs attribute.\n" ); + }else if (subtable_type ==SUBTABLE_S3PT ) { + bin_attr_S3PT.private = subtable_header; + bin_attr_S3PT.size = length; + result =sysfs_create_bin_file (fpdt_kobj, &bin_attr_S3PT); +if (result) +pr_warn ("Failed to create S3PT sysfs attribute.\n" ); + } +return 0 ; err: +if (bin_attr_FBPT.private) { +sysfs_remove_bin_file (fpdt_kobj, &bin_attr_FBPT); + bin_attr_FBPT.private =NULL ; + } + +if (bin_attr_S3PT.private) { +sysfs_remove_bin_file (fpdt_kobj, &bin_attr_S3PT); + bin_attr_S3PT.private =NULL ; + } +if (record_boot)sysfs_remove_group (fpdt_kobj, &boot_attr_group);
Signature · 1 line
2.34.1
Rafael J. Wysocki
maintainerQuoted 58 lines · Nate DeSimone
Add sysfs files at
/sys/firmware/acpi/fpdt/FBPTand/sys/firmware/acpi/fpdt/S3PTthat expose the raw contents of the FPDT subtables. Note that/sys/firmware/acpi/tables/FPDTonly provides the top level table, not the subtables. Adding access to the subtables enables a usage model similar to/sys/firmware/dmi/tables/DMI, allowing userspace tools to interpret newer record types (e.g. String Event Records, Microcontroller Boot Performance Data Records, etc.) defined in recent ACPI specifications[1] without requiring kernel changes.Signed-off-by Nate DeSimone <[email protected]>--- drivers/acpi/acpi_fpdt.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/acpi/acpi_fpdt.c +22
-0@@ -141,6 +141,9 @@ static const struct attribute_group boot_attr_group = { .name = "boot", }; +static BIN_ATTR(FBPT, 0400, sysfs_bin_attr_simple_read, NULL, 0); +static BIN_ATTR(S3PT, 0400, sysfs_bin_attr_simple_read, NULL, 0); +static struct kobject *fpdt_kobj;#if definedCONFIG_X86 && definedCONFIG_PHYS_ADDR_T_64BIT @@ -254,9 +257,34 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type)break ; } } + +if (subtable_type ==SUBTABLE_FBPT ) { + bin_attr_FBPT.private = subtable_header; + bin_attr_FBPT.size = length; + result =sysfs_create_bin_file (fpdt_kobj, &bin_attr_FBPT); +if (result) +pr_warn ("Failed to create FBPT sysfs attribute.\n" ); + }else if (subtable_type ==SUBTABLE_S3PT ) { + bin_attr_S3PT.private = subtable_header; + bin_attr_S3PT.size = length; + result =sysfs_create_bin_file (fpdt_kobj, &bin_attr_S3PT); +if (result) +pr_warn ("Failed to create S3PT sysfs attribute.\n" ); + } +return 0 ; err: +if (bin_attr_FBPT.private) { +sysfs_remove_bin_file (fpdt_kobj, &bin_attr_FBPT); + bin_attr_FBPT.private =NULL ; + }
drivers/acpi/acpi_fpdt.c static int fpdt_process_subtable(u64 address, u32 subtable_type)
Quoted 10 lines
drivers/acpi/acpi_fpdt.c +6
-1+ +if (bin_attr_S3PT.private) { +sysfs_remove_bin_file (fpdt_kobj, &bin_attr_S3PT); + bin_attr_S3PT.private =NULL ; + } +if (record_boot)sysfs_remove_group (fpdt_kobj, &boot_attr_group); --
Both patches applied as 7.1 material, thanks!
PATCH v3 2/2 Documentation: ABI: add FBPT and S3PT entries to sysfs-firmware-acpi
In reply to Nate DeSimoneDocument the FBPT and S3PT sysfs attributes under/sys/firmware/acpi/fpdt/
--- Documentation/ABI/testing/sysfs-firmware-acpi | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/ABI/testing/sysfs-firmware-acpi +6 -0
@@ -41,6 +41,12 @@ Description: platform runtime firmware S3 resume, just prior to handoff to the OS waking vector. In nanoseconds. + FBPT: The raw binary contents of the Firmware Basic Boot + Performance Table (FBPT) subtable. + + S3PT: The raw binary contents of the S3 Performance Table + (S3PT) subtable. + What: /sys/firmware/acpi/bgrt/ Date: January 2012 Contact: Matthew Garrett <[email protected]>
Signature · 1 line
2.34.1