Skip to contentSkip to conversation

device-drivers/acpi: skip certain tests for HW-reduced ACPI

PATCH New Stanislav Kholmanskikh 2 participants 6 messages Aug 17, 2018 – Oct 3, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 device-drivers/acpi: skip certain tests for HW-reduced ACPI

The "4.1 Hardware-Reduced ACPI" of the ACPI specification details that for Hardware-reduced platforms the ACPI Fixed Hardware interface is not implemented, so related test cases fail.
To avoid that, we skip these test cases if HW-reduced mode is detected.

One example of such systems is the aarch64 server platform.

---
 .../kernel/device-drivers/acpi/ltp_acpi_cmds.c     |   25 +++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c +24 -1
index 6e8f051..2733753 100644
@@ -231,14 +231,25 @@ static int acpi_traverse_from_root(void)
 
 /* first found device with _STR */
 static acpi_handle dev_handle;
+static int acpi_hw_reduced;
 
 static int acpi_init(void)
 {
 	acpi_status status;
 	acpi_handle parent_handle;
-
+	struct acpi_table_fadt *fadt;
+	struct acpi_table_header *table;
 	struct acpi_device_info *dev_info;
 
+	status = acpi_get_table(ACPI_SIG_FADT, 0, &table);
+	if (ACPI_SUCCESS(status)) {
+		fadt = (struct acpi_table_fadt *)table;
+		if (fadt->flags & ACPI_FADT_HW_REDUCED)
+			acpi_hw_reduced = 1;
+	}
+	if (acpi_hw_reduced)
+		prk_alert("Detected the Hardware-reduced ACPI mode");
+
 	prk_alert("TEST -- acpi_get_handle ");
 	status = acpi_get_handle(NULL, "\\_SB", &parent_handle);
 	if (acpi_failure(status, "acpi_get_handle"))
@@ -312,6 +323,10 @@ static int acpi_test_event_handler(void)
 	acpi_status status;
 
 	prk_alert("TEST -- acpi_install_fixed_event_handler");
+	if (acpi_hw_reduced) {
+		prk_alert("Skipped due to the HW-reduced mode");
+		return 0;
+	}
 	status = acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
 		ltp_test_power_button_ev_handler, NULL);
 
@@ -352,6 +367,10 @@ static int acpi_global_lock(void)
 	u32 global_lock = 0;
 
 	prk_alert("TEST -- acpi_acquire_global_lock ");
+	if (acpi_hw_reduced) {
+		prk_alert("Skipped due to the HW-reduced mode");
+		return 0;
+	}
 	status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &global_lock);
 	if (acpi_failure(status, "acpi_acquire_global_lock"))
 		return 1;
@@ -448,6 +467,10 @@ static int acpi_test_register(void)
 	acpi_status status;
 
 	prk_alert("TEST -- acpi_read_bit_register");
+	if (acpi_hw_reduced) {
+		prk_alert("Skipped due to the HW-reduced mode");
+		return 0;
+	}
 	/*
 	 * ACPICA: Remove obsolete Flags parameter.
 	 * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 device-drivers/acpi: skip certain tests for HW-reduced ACPI

Hi!

Could anybody have a look at this, please?

Thanks.

Quoted 77 lines · Stanislav Kholmanskikh

The "4.1 Hardware-Reduced ACPI" of the ACPI specification details that for Hardware-reduced platforms the ACPI Fixed Hardware interface is not implemented, so related test cases fail.
To avoid that, we skip these test cases if HW-reduced mode is detected.

One example of such systems is the aarch64 server platform.

---
 .../kernel/device-drivers/acpi/ltp_acpi_cmds.c     |   25 +++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c +24 -1
index 6e8f051..2733753 100644
@@ -231,14 +231,25 @@ static int acpi_traverse_from_root(void)
 
 /* first found device with _STR */
 static acpi_handle dev_handle;
+static int acpi_hw_reduced;
 
 static int acpi_init(void)
 {
 	acpi_status status;
 	acpi_handle parent_handle;
-
+	struct acpi_table_fadt *fadt;
+	struct acpi_table_header *table;
 	struct acpi_device_info *dev_info;
 
+	status = acpi_get_table(ACPI_SIG_FADT, 0, &table);
+	if (ACPI_SUCCESS(status)) {
+		fadt = (struct acpi_table_fadt *)table;
+		if (fadt->flags & ACPI_FADT_HW_REDUCED)
+			acpi_hw_reduced = 1;
+	}
+	if (acpi_hw_reduced)
+		prk_alert("Detected the Hardware-reduced ACPI mode");
+
 	prk_alert("TEST -- acpi_get_handle ");
 	status = acpi_get_handle(NULL, "\\_SB", &parent_handle);
 	if (acpi_failure(status, "acpi_get_handle"))
@@ -312,6 +323,10 @@ static int acpi_test_event_handler(void)
 	acpi_status status;
 
 	prk_alert("TEST -- acpi_install_fixed_event_handler");
+	if (acpi_hw_reduced) {
+		prk_alert("Skipped due to the HW-reduced mode");
+		return 0;
+	}
 	status = acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
 		ltp_test_power_button_ev_handler, NULL);
 
@@ -352,6 +367,10 @@ static int acpi_global_lock(void)
 	u32 global_lock = 0;
 
 	prk_alert("TEST -- acpi_acquire_global_lock ");
+	if (acpi_hw_reduced) {
+		prk_alert("Skipped due to the HW-reduced mode");
+		return 0;
+	}
 	status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &global_lock);
 	if (acpi_failure(status, "acpi_acquire_global_lock"))
 		return 1;
@@ -448,6 +467,10 @@ static int acpi_test_register(void)
 	acpi_status status;
 
 	prk_alert("TEST -- acpi_read_bit_register");
+	if (acpi_hw_reduced) {
+		prk_alert("Skipped due to the HW-reduced mode");
+		return 0;
+	}
 	/*
 	 * ACPICA: Remove obsolete Flags parameter.
 	 * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;
#2 lore raw

PATCH 1/1 device-drivers/acpi: skip certain tests for HW-reduced ACPI

Hi!

Quoted 1 line

Could anybody have a look at this, please?

Looks OK, I haven't checked the ACPI calls used to get the reduced flag are correct though.

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

PATCH 1/1 device-drivers/acpi: skip certain tests for HW-reduced ACPI

Hi!

Quoted 6 lines · Cyril Hrubis

Hi!

Quoted 1 line

Could anybody have a look at this, please?

Looks OK, I haven't checked the ACPI calls used to get the reduced flag are correct though.

Thank you. They work for me.

On an aarch64 box with the ACPI reduced flag set:

[root@bma002-ps ~]# acpixtract -a acpidump.out
<...>
[root@bma002-ps ~]# iasl -d facp.dat
<...>
[root@bma002-ps ~]# less facp.dsl
[root@bma002-ps ~]# grep -i reduced facp.dsl
Hardware Reduced (V5) : 1
[root@bma002-ps ~]#

without the patch the test reports:

ltp_acpi    2  TPASS  :  Test-case '1'
ltp_acpi    3  TPASS  :  Test-case '2'
ltp_acpi    4  TFAIL  :  ltp_acpi.c:139: Test-case '3'
ltp_acpi    5  TFAIL  :  ltp_acpi.c:139: Test-case '4'
ltp_acpi    6  TPASS  :  Test-case '5'
ltp_acpi    7  TPASS  :  Test-case '6'
ltp_acpi    8  TPASS  :  Test-case '7'
ltp_acpi    9  TFAIL  :  ltp_acpi.c:139: Test-case '8'
ltp_acpi   10  TPASS  :  Test-case '9'

<<<execution_status>>>

In contrast, here is the output from the same machine with the patch:

ltp_acpi    2  TPASS  :  Test-case '1'
ltp_acpi    3  TPASS  :  Test-case '2'
ltp_acpi    4  TPASS  :  Test-case '3'
ltp_acpi    5  TPASS  :  Test-case '4'
ltp_acpi    6  TPASS  :  Test-case '5'
ltp_acpi    7  TPASS  :  Test-case '6'
ltp_acpi    8  TPASS  :  Test-case '7'
ltp_acpi    9  TPASS  :  Test-case '8'
ltp_acpi   10  TPASS  :  Test-case '9'

<<<execution_status>>>

and the new string in dmesg:

[28580.729499] LTP: starting kernel_misc:ltp_acpi (ltp_acpi)
[28580.738129] ltp_acpi_test: Starting module
[28580.742241] ltp_acpi_test: device registered
[28580.746950] ltp_acpi_test: test-case 0
[28580.750707] ltp_acpi_test: Detected the Hardware-reduced ACPI mode
[28580.756882] ltp_acpi_test: TEST -- acpi_get_handle
[28580.761785] ltp_acpi_test: ACPI object name CP00, type 6

On my x86_64 desktop, where the flag is not set, I see no difference in test output and dmesg before and after applying the patch.

I.e. everything seems to be working as expected.

Am I applying the patch then?

#4 lore raw

PATCH 1/1 device-drivers/acpi: skip certain tests for HW-reduced ACPI

Hi!

Quoted 1 line

Am I applying the patch then?

Yes please.

Signature · 2 lines
Cyril Hrubis
[email protected]
#5 lore raw

PATCH 1/1 device-drivers/acpi: skip certain tests for HW-reduced ACPI

Quoted 5 lines · Cyril Hrubis

Hi!

Quoted 1 line

Am I applying the patch then?

Yes please.

Committed. Thank you.