diff mbox series

[1/2,V2] lib: fwts_acpi_tables: add option for dump acpi table from sysfs

Message ID 20200616112017.7928-2-ivan.hu@canonical.com
State Accepted
Headers show
Series make the acpi logs from fwts can be used acpica debugging | expand

Commit Message

Ivan Hu June 16, 2020, 11:20 a.m. UTC
Currently, fwts acpi table acpidumping first read from /dev/mem/,
it is the same as acpidump -c off, it will missing some customized tables.
Add --dump-acpi-from-sysfs option for user to first dump acpi tables
from sysfs, which sync up with acpidump tool and keep the flexibilty.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/lib/include/fwts_framework.h |  4 +++-
 src/lib/src/fwts_acpi_tables.c   | 20 +++++++++++++++-----
 src/lib/src/fwts_framework.c     |  4 ++++
 3 files changed, 22 insertions(+), 6 deletions(-)

Comments

Alex Hung June 16, 2020, 10:02 p.m. UTC | #1
On 2020-06-16 5:20 a.m., Ivan Hu wrote:
> Currently, fwts acpi table acpidumping first read from /dev/mem/,
> it is the same as acpidump -c off, it will missing some customized tables.
> Add --dump-acpi-from-sysfs option for user to first dump acpi tables
> from sysfs, which sync up with acpidump tool and keep the flexibilty.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/lib/include/fwts_framework.h |  4 +++-
>  src/lib/src/fwts_acpi_tables.c   | 20 +++++++++++++++-----
>  src/lib/src/fwts_framework.c     |  4 ++++
>  3 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
> index dddc2fda..eb8278b8 100644
> --- a/src/lib/include/fwts_framework.h
> +++ b/src/lib/include/fwts_framework.h
> @@ -63,7 +63,9 @@ typedef enum {
>  	FWTS_FLAG_TEST_COMPLIANCE_ACPI		= 0x00800000,
>  	FWTS_FLAG_TEST_SBBR			= 0x01000000,
>  	FWTS_FLAG_TEST_EBBR			= 0x02000000,
> -	FWTS_FLAG_TEST_XBBR			= FWTS_FLAG_TEST_SBBR | FWTS_FLAG_TEST_EBBR
> +	FWTS_FLAG_TEST_XBBR			= FWTS_FLAG_TEST_SBBR | FWTS_FLAG_TEST_EBBR,
> +	FWTS_FLAG_DUMP_ACPI_FROM_SYSFS		= 0x08000000,
> +
>  } fwts_framework_flags;
>  
>  #define FWTS_FLAG_TEST_MASK		\
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 3b1d7887..90d4a50d 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -1214,12 +1214,22 @@ int fwts_acpi_load_tables(fwts_framework *fw)
>  		ret = fwts_acpi_load_tables_from_acpidump(fw);
>  		require_fixup = true;
>  	} else if (fwts_check_root_euid(fw, true) == FWTS_OK) {
> -		ret = fwts_acpi_load_tables_from_firmware(fw);
> -
> -		/* Load from memory failed (e.g. no /dev/mem), so try sysfs */
> -		if (ret != FWTS_OK) {
> +		if (!(fw->flags & FWTS_FLAG_DUMP_ACPI_FROM_SYSFS)) {
> +			ret = fwts_acpi_load_tables_from_firmware(fw);
> +
> +			/* Load from memory failed (e.g. no /dev/mem), so try sysfs */
> +			if (ret != FWTS_OK) {
> +				ret = fwts_acpi_load_tables_from_sysfs(fw);
> +				require_fixup = true;
> +			}			
			^^^^^^^^^^ trailing whitespaces here but this can be fixed when applying


> +		} else {
> +			/* Load from sysfs */
>  			ret = fwts_acpi_load_tables_from_sysfs(fw);
> -			require_fixup = true;
> +			if (ret != FWTS_OK) {
> +				/* Load from sysfs failed, try from mem(e.g. /dev/mem) */
> +				ret = fwts_acpi_load_tables_from_firmware(fw);
> +			} else
> +				require_fixup = true;
>  		}
>  	} else {
>  		ret = FWTS_ERROR_NO_PRIV;
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index e1e896bb..424092f1 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -139,6 +139,7 @@ static fwts_option fwts_framework_options[] = {
>  	{ "ifv",		"",   0, "Run tests in firmware-vendor modes." },
>  	{ "clog",		"",   1, "Specify a coreboot logfile dump" },
>  	{ "ebbr",		"",   0, "Run ARM EBBR tests." },
> +	{ "dump-acpi-from-sysfs","",  0, "Specify dumping acpi table log default from sysfs." },
>  	{ NULL, NULL, 0, NULL }
>  };
>  
> @@ -1347,6 +1348,9 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>  		case 49: /* --ebbr */
>  			fw->flags |= FWTS_FLAG_TEST_EBBR;
>  			break;
> +		case 50: /* --dump-acpi-from-sysfs */
> +			fw->flags |= FWTS_FLAG_DUMP_ACPI_FROM_SYSFS;
> +			break;
dump-acpi-from-sysfs needs to be updated in doc/fwts.1 like 28fd85aad0cc


>  		}
>  		break;
>  	case 'a': /* --all */
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Colin Ian King June 18, 2020, 11:24 a.m. UTC | #2
On 16/06/2020 12:20, Ivan Hu wrote:
> Currently, fwts acpi table acpidumping first read from /dev/mem/,
> it is the same as acpidump -c off, it will missing some customized tables.
> Add --dump-acpi-from-sysfs option for user to first dump acpi tables
> from sysfs, which sync up with acpidump tool and keep the flexibilty.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/lib/include/fwts_framework.h |  4 +++-
>  src/lib/src/fwts_acpi_tables.c   | 20 +++++++++++++++-----
>  src/lib/src/fwts_framework.c     |  4 ++++
>  3 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
> index dddc2fda..eb8278b8 100644
> --- a/src/lib/include/fwts_framework.h
> +++ b/src/lib/include/fwts_framework.h
> @@ -63,7 +63,9 @@ typedef enum {
>  	FWTS_FLAG_TEST_COMPLIANCE_ACPI		= 0x00800000,
>  	FWTS_FLAG_TEST_SBBR			= 0x01000000,
>  	FWTS_FLAG_TEST_EBBR			= 0x02000000,
> -	FWTS_FLAG_TEST_XBBR			= FWTS_FLAG_TEST_SBBR | FWTS_FLAG_TEST_EBBR
> +	FWTS_FLAG_TEST_XBBR			= FWTS_FLAG_TEST_SBBR | FWTS_FLAG_TEST_EBBR,
> +	FWTS_FLAG_DUMP_ACPI_FROM_SYSFS		= 0x08000000,
> +
>  } fwts_framework_flags;
>  
>  #define FWTS_FLAG_TEST_MASK		\
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 3b1d7887..90d4a50d 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -1214,12 +1214,22 @@ int fwts_acpi_load_tables(fwts_framework *fw)
>  		ret = fwts_acpi_load_tables_from_acpidump(fw);
>  		require_fixup = true;
>  	} else if (fwts_check_root_euid(fw, true) == FWTS_OK) {
> -		ret = fwts_acpi_load_tables_from_firmware(fw);
> -
> -		/* Load from memory failed (e.g. no /dev/mem), so try sysfs */
> -		if (ret != FWTS_OK) {
> +		if (!(fw->flags & FWTS_FLAG_DUMP_ACPI_FROM_SYSFS)) {
> +			ret = fwts_acpi_load_tables_from_firmware(fw);
> +
> +			/* Load from memory failed (e.g. no /dev/mem), so try sysfs */
> +			if (ret != FWTS_OK) {
> +				ret = fwts_acpi_load_tables_from_sysfs(fw);
> +				require_fixup = true;
> +			}			
> +		} else {
> +			/* Load from sysfs */
>  			ret = fwts_acpi_load_tables_from_sysfs(fw);
> -			require_fixup = true;
> +			if (ret != FWTS_OK) {
> +				/* Load from sysfs failed, try from mem(e.g. /dev/mem) */
> +				ret = fwts_acpi_load_tables_from_firmware(fw);
> +			} else
> +				require_fixup = true;
>  		}
>  	} else {
>  		ret = FWTS_ERROR_NO_PRIV;
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index e1e896bb..424092f1 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -139,6 +139,7 @@ static fwts_option fwts_framework_options[] = {
>  	{ "ifv",		"",   0, "Run tests in firmware-vendor modes." },
>  	{ "clog",		"",   1, "Specify a coreboot logfile dump" },
>  	{ "ebbr",		"",   0, "Run ARM EBBR tests." },
> +	{ "dump-acpi-from-sysfs","",  0, "Specify dumping acpi table log default from sysfs." },


Please send an update to the manual as a separate patch, then I'll ack this.

>  	{ NULL, NULL, 0, NULL }
>  };
>  
> @@ -1347,6 +1348,9 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>  		case 49: /* --ebbr */
>  			fw->flags |= FWTS_FLAG_TEST_EBBR;
>  			break;
> +		case 50: /* --dump-acpi-from-sysfs */
> +			fw->flags |= FWTS_FLAG_DUMP_ACPI_FROM_SYSFS;
> +			break;
>  		}
>  		break;
>  	case 'a': /* --all */
>
Colin Ian King June 22, 2020, 2:12 p.m. UTC | #3
On 16/06/2020 12:20, Ivan Hu wrote:
> Currently, fwts acpi table acpidumping first read from /dev/mem/,
> it is the same as acpidump -c off, it will missing some customized tables.
> Add --dump-acpi-from-sysfs option for user to first dump acpi tables
> from sysfs, which sync up with acpidump tool and keep the flexibilty.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/lib/include/fwts_framework.h |  4 +++-
>  src/lib/src/fwts_acpi_tables.c   | 20 +++++++++++++++-----
>  src/lib/src/fwts_framework.c     |  4 ++++
>  3 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
> index dddc2fda..eb8278b8 100644
> --- a/src/lib/include/fwts_framework.h
> +++ b/src/lib/include/fwts_framework.h
> @@ -63,7 +63,9 @@ typedef enum {
>  	FWTS_FLAG_TEST_COMPLIANCE_ACPI		= 0x00800000,
>  	FWTS_FLAG_TEST_SBBR			= 0x01000000,
>  	FWTS_FLAG_TEST_EBBR			= 0x02000000,
> -	FWTS_FLAG_TEST_XBBR			= FWTS_FLAG_TEST_SBBR | FWTS_FLAG_TEST_EBBR
> +	FWTS_FLAG_TEST_XBBR			= FWTS_FLAG_TEST_SBBR | FWTS_FLAG_TEST_EBBR,
> +	FWTS_FLAG_DUMP_ACPI_FROM_SYSFS		= 0x08000000,
> +
>  } fwts_framework_flags;
>  
>  #define FWTS_FLAG_TEST_MASK		\
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 3b1d7887..90d4a50d 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -1214,12 +1214,22 @@ int fwts_acpi_load_tables(fwts_framework *fw)
>  		ret = fwts_acpi_load_tables_from_acpidump(fw);
>  		require_fixup = true;
>  	} else if (fwts_check_root_euid(fw, true) == FWTS_OK) {
> -		ret = fwts_acpi_load_tables_from_firmware(fw);
> -
> -		/* Load from memory failed (e.g. no /dev/mem), so try sysfs */
> -		if (ret != FWTS_OK) {
> +		if (!(fw->flags & FWTS_FLAG_DUMP_ACPI_FROM_SYSFS)) {
> +			ret = fwts_acpi_load_tables_from_firmware(fw);
> +
> +			/* Load from memory failed (e.g. no /dev/mem), so try sysfs */
> +			if (ret != FWTS_OK) {
> +				ret = fwts_acpi_load_tables_from_sysfs(fw);
> +				require_fixup = true;
> +			}			
> +		} else {
> +			/* Load from sysfs */
>  			ret = fwts_acpi_load_tables_from_sysfs(fw);
> -			require_fixup = true;
> +			if (ret != FWTS_OK) {
> +				/* Load from sysfs failed, try from mem(e.g. /dev/mem) */
> +				ret = fwts_acpi_load_tables_from_firmware(fw);
> +			} else
> +				require_fixup = true;
>  		}
>  	} else {
>  		ret = FWTS_ERROR_NO_PRIV;
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index e1e896bb..424092f1 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -139,6 +139,7 @@ static fwts_option fwts_framework_options[] = {
>  	{ "ifv",		"",   0, "Run tests in firmware-vendor modes." },
>  	{ "clog",		"",   1, "Specify a coreboot logfile dump" },
>  	{ "ebbr",		"",   0, "Run ARM EBBR tests." },
> +	{ "dump-acpi-from-sysfs","",  0, "Specify dumping acpi table log default from sysfs." },
>  	{ NULL, NULL, 0, NULL }
>  };
>  
> @@ -1347,6 +1348,9 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>  		case 49: /* --ebbr */
>  			fw->flags |= FWTS_FLAG_TEST_EBBR;
>  			break;
> +		case 50: /* --dump-acpi-from-sysfs */
> +			fw->flags |= FWTS_FLAG_DUMP_ACPI_FROM_SYSFS;
> +			break;
>  		}
>  		break;
>  	case 'a': /* --all */
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
diff mbox series

Patch

diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
index dddc2fda..eb8278b8 100644
--- a/src/lib/include/fwts_framework.h
+++ b/src/lib/include/fwts_framework.h
@@ -63,7 +63,9 @@  typedef enum {
 	FWTS_FLAG_TEST_COMPLIANCE_ACPI		= 0x00800000,
 	FWTS_FLAG_TEST_SBBR			= 0x01000000,
 	FWTS_FLAG_TEST_EBBR			= 0x02000000,
-	FWTS_FLAG_TEST_XBBR			= FWTS_FLAG_TEST_SBBR | FWTS_FLAG_TEST_EBBR
+	FWTS_FLAG_TEST_XBBR			= FWTS_FLAG_TEST_SBBR | FWTS_FLAG_TEST_EBBR,
+	FWTS_FLAG_DUMP_ACPI_FROM_SYSFS		= 0x08000000,
+
 } fwts_framework_flags;
 
 #define FWTS_FLAG_TEST_MASK		\
diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
index 3b1d7887..90d4a50d 100644
--- a/src/lib/src/fwts_acpi_tables.c
+++ b/src/lib/src/fwts_acpi_tables.c
@@ -1214,12 +1214,22 @@  int fwts_acpi_load_tables(fwts_framework *fw)
 		ret = fwts_acpi_load_tables_from_acpidump(fw);
 		require_fixup = true;
 	} else if (fwts_check_root_euid(fw, true) == FWTS_OK) {
-		ret = fwts_acpi_load_tables_from_firmware(fw);
-
-		/* Load from memory failed (e.g. no /dev/mem), so try sysfs */
-		if (ret != FWTS_OK) {
+		if (!(fw->flags & FWTS_FLAG_DUMP_ACPI_FROM_SYSFS)) {
+			ret = fwts_acpi_load_tables_from_firmware(fw);
+
+			/* Load from memory failed (e.g. no /dev/mem), so try sysfs */
+			if (ret != FWTS_OK) {
+				ret = fwts_acpi_load_tables_from_sysfs(fw);
+				require_fixup = true;
+			}			
+		} else {
+			/* Load from sysfs */
 			ret = fwts_acpi_load_tables_from_sysfs(fw);
-			require_fixup = true;
+			if (ret != FWTS_OK) {
+				/* Load from sysfs failed, try from mem(e.g. /dev/mem) */
+				ret = fwts_acpi_load_tables_from_firmware(fw);
+			} else
+				require_fixup = true;
 		}
 	} else {
 		ret = FWTS_ERROR_NO_PRIV;
diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index e1e896bb..424092f1 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -139,6 +139,7 @@  static fwts_option fwts_framework_options[] = {
 	{ "ifv",		"",   0, "Run tests in firmware-vendor modes." },
 	{ "clog",		"",   1, "Specify a coreboot logfile dump" },
 	{ "ebbr",		"",   0, "Run ARM EBBR tests." },
+	{ "dump-acpi-from-sysfs","",  0, "Specify dumping acpi table log default from sysfs." },
 	{ NULL, NULL, 0, NULL }
 };
 
@@ -1347,6 +1348,9 @@  int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
 		case 49: /* --ebbr */
 			fw->flags |= FWTS_FLAG_TEST_EBBR;
 			break;
+		case 50: /* --dump-acpi-from-sysfs */
+			fw->flags |= FWTS_FLAG_DUMP_ACPI_FROM_SYSFS;
+			break;
 		}
 		break;
 	case 'a': /* --all */