[PATCH] pcie: aspm: add aspm option and detect if the "PCIe ASPM Controls" bit is set in FADT.
Colin Ian King
colin.king at canonical.com
Wed Dec 7 09:17:56 UTC 2011
On 07/12/11 08:48, Alex Hung wrote:
> Signed-off-by: Alex Hung<alex.hung at canonical.com>
> ---
> doc/fwts.1 | 3 ++
> src/lib/include/fwts.h | 1 +
> src/lib/include/fwts_acpi.h | 6 ++++
> src/lib/include/fwts_aspm.h | 28 +++++++++++++++++
> src/lib/src/Makefile.am | 3 +-
> src/lib/src/fwts_aspm.c | 68 ++++++++++++++++++++++++++++++++++++++++++
> src/lib/src/fwts_framework.c | 4 ++
> 7 files changed, 112 insertions(+), 1 deletions(-)
> create mode 100644 src/lib/include/fwts_aspm.h
> create mode 100644 src/lib/src/fwts_aspm.c
>
> diff --git a/doc/fwts.1 b/doc/fwts.1
> index bf1ddf1..7d2dae3 100644
> --- a/doc/fwts.1
> +++ b/doc/fwts.1
> @@ -257,6 +257,9 @@ specify tests to skip over and not run. List must be comma separated.
> .B \-\-stdout\-summary
> output SUCCESS or FAILED to stdout at end of tests.
> .TP
> +.B \-\-aspm
> +verify PCIE ASPM configuration from firmware.
> +.TP
> .B \-t, \-\-table\-path=path
> specify the path containing ACPI tables. These tables need to be named in the format: tablename.dat,
> for example DSDT.dat, for example, as extracted using acpidump or fwts \-\-dump and then acpixtract.
> diff --git a/src/lib/include/fwts.h b/src/lib/include/fwts.h
> index f5602ea..abea55a 100644
> --- a/src/lib/include/fwts.h
> +++ b/src/lib/include/fwts.h
> @@ -75,5 +75,6 @@
> #include "fwts_ac_adapter.h"
> #include "fwts_battery.h"
> #include "fwts_button.h"
> +#include "fwts_aspm.h"
>
> #endif
> diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h
> index 9cd6acd..393f6f1 100644
> --- a/src/lib/include/fwts_acpi.h
> +++ b/src/lib/include/fwts_acpi.h
> @@ -22,6 +22,12 @@
>
> #define FWTS_ACPI_TABLES_PATH "/sys/firmware/acpi/tables"
>
> +#define FWTS_FACP_IAPC_BOOT_ARCH_LEGACY_DEVICES (0x0001)
> +#define FWTS_FACP_IAPC_BOOT_ARCH_8042 (0x0002)
> +#define FWTS_FACP_IAPC_BOOT_ARCH_VGA_NOT_PRESENT (0x0004)
> +#define FWTS_FACP_IAPC_BOOT_ARCH_MSI_NOT_SUPPORTED (0x0008)
> +#define FWTS_FACP_IAPC_BOOT_ARCH_PCIE_ASPM_CONTROLS (0x0010)
> +
> #include "fwts_types.h"
> #include "fwts_framework.h"
> #include "fwts_log.h"
> diff --git a/src/lib/include/fwts_aspm.h b/src/lib/include/fwts_aspm.h
> new file mode 100644
> index 0000000..91437fa
> --- /dev/null
> +++ b/src/lib/include/fwts_aspm.h
> @@ -0,0 +1,28 @@
> +/*
> + * Copyright (C) 2011 Canonical
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
> + *
> + */
> +
> +#ifndef __FWTS_ASPM_H__
> +#define __FWTS_ASPM_H__
> +
> +#include "fwts_acpi.h"
> +
> +
> +int fwts_aspm_check_configuration(fwts_framework *fw);
> +
> +#endif
> diff --git a/src/lib/src/Makefile.am b/src/lib/src/Makefile.am
> index 2aac13e..d76d4cd 100644
> --- a/src/lib/src/Makefile.am
> +++ b/src/lib/src/Makefile.am
> @@ -56,4 +56,5 @@ libfwts_la_SOURCES = \
> fwts_wakealarm.c \
> fwts_ac_adapter.c \
> fwts_battery.c \
> - fwts_button.c
> + fwts_button.c \
> + fwts_aspm.c
> diff --git a/src/lib/src/fwts_aspm.c b/src/lib/src/fwts_aspm.c
> new file mode 100644
> index 0000000..a6ee1b7
> --- /dev/null
> +++ b/src/lib/src/fwts_aspm.c
> @@ -0,0 +1,68 @@
> +/*
> + * Copyright (C) 2011 Canonical
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
> + *
> + */
> +#include<stdlib.h>
> +#include<stdio.h>
> +#include<errno.h>
> +#include<sys/types.h>
> +#include<sys/stat.h>
> +#include<sys/wait.h>
> +#include<unistd.h>
> +#include<string.h>
> +#include<fcntl.h>
> +#include<limits.h>
> +#include<linux/pci.h>
> +
> +#include "fwts.h"
> +
> +int fwts_facp_get_aspm_control(fwts_framework *fw, int *aspm)
> +{
> + fwts_acpi_table_info *table;
> + fwts_acpi_table_fadt *fadt;
> +
> + if (fwts_acpi_find_table(fw, "FACP", 0,&table) != FWTS_OK) {
> + return FWTS_ERROR;
> + }
> + fadt = (fwts_acpi_table_fadt*)table->data;
> +
> + if ((fadt->iapc_boot_arch& FWTS_FACP_IAPC_BOOT_ARCH_PCIE_ASPM_CONTROLS) == 0) {
> + *aspm = 1;
> + fwts_log_info(fw, "PCIE ASPM is controlled by Linux kernel.");
> + } else {
> + *aspm = 0;
> + fwts_log_info(fw, "PCIE ASPM is not controlled by Linux kernel.");
> + }
> +
> + return FWTS_OK;
> +}
> +
> +int fwts_aspm_check_configuration(fwts_framework *fw)
> +{
> + int ret;
> + int aspm_facp;
> +
> + ret = fwts_facp_get_aspm_control(fw,&aspm_facp);
> + if (ret == FWTS_ERROR) {
> + fwts_log_info(fw, "No valid FACP information present: cannot test aspm.");
> + return FWTS_ERROR;
> + }
> +
> + return ret;
> +}
> +
> +
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 9898537..7064c44 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -76,6 +76,7 @@ static fwts_option fwts_framework_options[] = {
> { "json-data-path", "j:", 1, "Specify path to fwts json data files - default is /usr/share/fwts." },
> { "lp-tags-log", "", 0, "Output LaunchPad bug tags in results log." },
> { "disassemble-aml", "", 0, "Disassemble AML from DSDT and SSDT tables." },
> + { "aspm", "", 0, "Test ASPM configuration." },
> { NULL, NULL, 0, NULL }
> };
>
> @@ -967,6 +968,9 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
> case 31: /* --disassemble-aml */
> fwts_iasl_disassemble_all_to_file(fw);
> return FWTS_COMPLETE;
> + case 32: /* --aspm */
> + fwts_aspm_check_configuration(fw);
> + return FWTS_COMPLETE;
> }
> break;
> case 'a': /* --all */
Looks good to me, ACK
More information about the fwts-devel
mailing list