Message ID | 20210825152721.2818305-2-robh@kernel.org |
---|---|
State | Accepted |
Headers | show |
Series | [1/3] Enable dt_sysinfo test for Power only | expand |
On 2021-08-25 9:27 a.m., Rob Herring wrote: > Currently, ACPI is assumed for UEFI based systems, but Arm based UEFI > systems may use ACPI or DT for hardware description. It's also possible > to have DT without UEFI or OPAL such as non-UEFI u-boot. > > Rework the feature detection to ignore the firmware type and just check > sysfs. As Arm systems always have a DT for boot parameters even with > ACPI, check for ACPI firmware first. > > Signed-off-by: Rob Herring <robh@kernel.org> > --- > src/lib/src/fwts_firmware.c | 21 +++++++-------------- > 1 file changed, 7 insertions(+), 14 deletions(-) > > diff --git a/src/lib/src/fwts_firmware.c b/src/lib/src/fwts_firmware.c > index ba0b939c09ba..b249f00a9917 100644 > --- a/src/lib/src/fwts_firmware.c > +++ b/src/lib/src/fwts_firmware.c > @@ -54,22 +54,15 @@ fwts_firmware_type fwts_firmware_detect(void) > int fwts_firmware_features(void) > { > int features = 0; > - struct stat ipmi_statbuf; > - > - switch (fwts_firmware_detect()) { > - case FWTS_FIRMWARE_BIOS: > - case FWTS_FIRMWARE_UEFI: > - features = FWTS_FW_FEATURE_ACPI; > - break; > - case FWTS_FIRMWARE_OPAL: > - features = FWTS_FW_FEATURE_DEVICETREE; > - break; > - default: > - break; > - } > + struct stat statbuf; > + > + if (!stat("/sys/firmware/acpi", &statbuf)) > + features |= FWTS_FW_FEATURE_ACPI; > + else if (!stat("/sys/firmware/devicetree/base", &statbuf)) > + features |= FWTS_FW_FEATURE_DEVICETREE; > > /* just check for IPMI device presence */ > - if (!stat("/dev/ipmi0", &ipmi_statbuf)) > + if (!stat("/dev/ipmi0", &statbuf)) > features |= FWTS_FW_FEATURE_IPMI; > > return features; > Acked-by: Alex Hung <alex.hung@canonical.com>
On 8/25/21 11:27 PM, Rob Herring wrote: > Currently, ACPI is assumed for UEFI based systems, but Arm based UEFI > systems may use ACPI or DT for hardware description. It's also possible > to have DT without UEFI or OPAL such as non-UEFI u-boot. > > Rework the feature detection to ignore the firmware type and just check > sysfs. As Arm systems always have a DT for boot parameters even with > ACPI, check for ACPI firmware first. > > Signed-off-by: Rob Herring <robh@kernel.org> > --- > src/lib/src/fwts_firmware.c | 21 +++++++-------------- > 1 file changed, 7 insertions(+), 14 deletions(-) > > diff --git a/src/lib/src/fwts_firmware.c b/src/lib/src/fwts_firmware.c > index ba0b939c09ba..b249f00a9917 100644 > --- a/src/lib/src/fwts_firmware.c > +++ b/src/lib/src/fwts_firmware.c > @@ -54,22 +54,15 @@ fwts_firmware_type fwts_firmware_detect(void) > int fwts_firmware_features(void) > { > int features = 0; > - struct stat ipmi_statbuf; > - > - switch (fwts_firmware_detect()) { > - case FWTS_FIRMWARE_BIOS: > - case FWTS_FIRMWARE_UEFI: > - features = FWTS_FW_FEATURE_ACPI; > - break; > - case FWTS_FIRMWARE_OPAL: > - features = FWTS_FW_FEATURE_DEVICETREE; > - break; > - default: > - break; > - } > + struct stat statbuf; > + > + if (!stat("/sys/firmware/acpi", &statbuf)) > + features |= FWTS_FW_FEATURE_ACPI; > + else if (!stat("/sys/firmware/devicetree/base", &statbuf)) > + features |= FWTS_FW_FEATURE_DEVICETREE; > > /* just check for IPMI device presence */ > - if (!stat("/dev/ipmi0", &ipmi_statbuf)) > + if (!stat("/dev/ipmi0", &statbuf)) > features |= FWTS_FW_FEATURE_IPMI; > > return features; > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/lib/src/fwts_firmware.c b/src/lib/src/fwts_firmware.c index ba0b939c09ba..b249f00a9917 100644 --- a/src/lib/src/fwts_firmware.c +++ b/src/lib/src/fwts_firmware.c @@ -54,22 +54,15 @@ fwts_firmware_type fwts_firmware_detect(void) int fwts_firmware_features(void) { int features = 0; - struct stat ipmi_statbuf; - - switch (fwts_firmware_detect()) { - case FWTS_FIRMWARE_BIOS: - case FWTS_FIRMWARE_UEFI: - features = FWTS_FW_FEATURE_ACPI; - break; - case FWTS_FIRMWARE_OPAL: - features = FWTS_FW_FEATURE_DEVICETREE; - break; - default: - break; - } + struct stat statbuf; + + if (!stat("/sys/firmware/acpi", &statbuf)) + features |= FWTS_FW_FEATURE_ACPI; + else if (!stat("/sys/firmware/devicetree/base", &statbuf)) + features |= FWTS_FW_FEATURE_DEVICETREE; /* just check for IPMI device presence */ - if (!stat("/dev/ipmi0", &ipmi_statbuf)) + if (!stat("/dev/ipmi0", &statbuf)) features |= FWTS_FW_FEATURE_IPMI; return features;
Currently, ACPI is assumed for UEFI based systems, but Arm based UEFI systems may use ACPI or DT for hardware description. It's also possible to have DT without UEFI or OPAL such as non-UEFI u-boot. Rework the feature detection to ignore the firmware type and just check sysfs. As Arm systems always have a DT for boot parameters even with ACPI, check for ACPI firmware first. Signed-off-by: Rob Herring <robh@kernel.org> --- src/lib/src/fwts_firmware.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)