* [PATCH 0/2] ACPI, APEI, EINJ injection parameters support
@ 2010-05-12 8:40 Huang Ying
2010-05-12 8:40 ` [PATCH 1/2] Add x64 support to debugfs Huang Ying
2010-05-12 8:40 ` [PATCH 2/2] ACPI, APEI, EINJ injection parameters support Huang Ying
0 siblings, 2 replies; 6+ messages in thread
From: Huang Ying @ 2010-05-12 8:40 UTC (permalink / raw)
To: lenb; +Cc: linux-kernel, ying.huang, andi, linux-acpi
This patch queue is based on acpi-test.git.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] Add x64 support to debugfs
2010-05-12 8:40 [PATCH 0/2] ACPI, APEI, EINJ injection parameters support Huang Ying
@ 2010-05-12 8:40 ` Huang Ying
2010-05-12 21:47 ` Greg KH
2010-05-12 8:40 ` [PATCH 2/2] ACPI, APEI, EINJ injection parameters support Huang Ying
1 sibling, 1 reply; 6+ messages in thread
From: Huang Ying @ 2010-05-12 8:40 UTC (permalink / raw)
To: lenb; +Cc: linux-kernel, ying.huang, andi, linux-acpi, Andi Kleen, Greg KH
Add debugfs_create_x64. This is needed by ACPI APEI EINJ parameters support.
Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
CC: Greg KH <greg@kroah.com>
---
fs/debugfs/file.c | 21 ++++++++++++++++++++-
include/linux/debugfs.h | 2 ++
2 files changed, 22 insertions(+), 1 deletion(-)
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -277,8 +277,10 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_x32, debugf
DEFINE_SIMPLE_ATTRIBUTE(fops_x32_ro, debugfs_u32_get, NULL, "0x%08llx\n");
DEFINE_SIMPLE_ATTRIBUTE(fops_x32_wo, NULL, debugfs_u32_set, "0x%08llx\n");
+DEFINE_SIMPLE_ATTRIBUTE(fops_x64, debugfs_u64_get, debugfs_u64_set, "0x%016llx\n");
+
/*
- * debugfs_create_x{8,16,32} - create a debugfs file that is used to read and write an unsigned {8,16,32}-bit value
+ * debugfs_create_x{8,16,32,64} - create a debugfs file that is used to read and write an unsigned {8,16,32,64}-bit value
*
* These functions are exactly the same as the above functions (but use a hex
* output for the decimal challenged). For details look at the above unsigned
@@ -357,6 +359,23 @@ struct dentry *debugfs_create_x32(const
}
EXPORT_SYMBOL_GPL(debugfs_create_x32);
+/**
+ * debugfs_create_x64 - create a debugfs file that is used to read and write an unsigned 64-bit value
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have
+ * @parent: a pointer to the parent dentry for this file. This should be a
+ * directory dentry if set. If this parameter is %NULL, then the
+ * file will be created in the root of the debugfs filesystem.
+ * @value: a pointer to the variable that the file should read to and write
+ * from.
+ */
+struct dentry *debugfs_create_x64(const char *name, mode_t mode,
+ struct dentry *parent, u64 *value)
+{
+ return debugfs_create_file(name, mode, parent, value, &fops_x64);
+}
+EXPORT_SYMBOL_GPL(debugfs_create_x64);
+
static int debugfs_size_t_set(void *data, u64 val)
{
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -63,6 +63,8 @@ struct dentry *debugfs_create_x16(const
struct dentry *parent, u16 *value);
struct dentry *debugfs_create_x32(const char *name, mode_t mode,
struct dentry *parent, u32 *value);
+struct dentry *debugfs_create_x64(const char *name, mode_t mode,
+ struct dentry *parent, u64 *value);
struct dentry *debugfs_create_size_t(const char *name, mode_t mode,
struct dentry *parent, size_t *value);
struct dentry *debugfs_create_bool(const char *name, mode_t mode,
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] ACPI, APEI, EINJ injection parameters support
2010-05-12 8:40 [PATCH 0/2] ACPI, APEI, EINJ injection parameters support Huang Ying
2010-05-12 8:40 ` [PATCH 1/2] Add x64 support to debugfs Huang Ying
@ 2010-05-12 8:40 ` Huang Ying
1 sibling, 0 replies; 6+ messages in thread
From: Huang Ying @ 2010-05-12 8:40 UTC (permalink / raw)
To: lenb; +Cc: linux-kernel, ying.huang, andi, linux-acpi, Andi Kleen
Some hardware error injection needs parameters, for example, it is
useful to specify memory address and memory address mask for memory
errors.
Some BIOSes allow parameters to be specified via an unpublished
extension. This patch adds support to it. The parameters will be
ignored on machines without necessary BIOS support.
Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
drivers/acpi/apei/einj.c | 99 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 94 insertions(+), 5 deletions(-)
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -7,7 +7,7 @@
* For more information about EINJ, please refer to ACPI Specification
* version 4.0, section 17.5.
*
- * Copyright 2009 Intel Corp.
+ * Copyright 2009-2010 Intel Corp.
* Author: Huang Ying <ying.huang@intel.com>
*
* This program is free software; you can redistribute it and/or
@@ -41,6 +41,20 @@
/* Firmware should respond within 1 miliseconds */
#define FIRMWARE_TIMEOUT (1 * NSEC_PER_MSEC)
+/*
+ * Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the
+ * EINJ table through an unpublished extension. Use with caution as
+ * most will ignore the parameter and make their own choice of address
+ * for error injection.
+ */
+struct einj_parameter {
+ u64 type;
+ u64 reserved1;
+ u64 reserved2;
+ u64 param1;
+ u64 param2;
+};
+
#define EINJ_OP_BUSY 0x1
#define EINJ_STATUS_SUCCESS 0x0
#define EINJ_STATUS_FAIL 0x1
@@ -84,6 +98,8 @@ static struct apei_exec_ins_type einj_in
*/
static DEFINE_MUTEX(einj_mutex);
+static struct einj_parameter *einj_param;
+
static void einj_exec_ctx_init(struct apei_exec_context *ctx)
{
apei_exec_ctx_init(ctx, einj_ins_type, ARRAY_SIZE(einj_ins_type),
@@ -129,6 +145,26 @@ static int einj_timedout(u64 *t)
return 0;
}
+static u64 einj_get_parameter_address(void)
+{
+ int i;
+ u64 paddr = 0;
+ struct acpi_whea_header *entry;
+
+ entry = EINJ_TAB_ENTRY(einj_tab);
+ for (i = 0; i < einj_tab->entries; i++) {
+ if (entry->action == ACPI_EINJ_SET_ERROR_TYPE &&
+ entry->instruction == ACPI_EINJ_WRITE_REGISTER &&
+ entry->register_region.space_id ==
+ ACPI_ADR_SPACE_SYSTEM_MEMORY)
+ memcpy(&paddr, &entry->register_region.address,
+ sizeof(paddr));
+ entry++;
+ }
+
+ return paddr;
+}
+
/* do sanity check to trigger table */
static int einj_check_trigger_header(struct acpi_einj_trigger *trigger_tab)
{
@@ -232,7 +268,7 @@ out:
return rc;
}
-static int __einj_error_inject(u32 type)
+static int __einj_error_inject(u32 type, u64 param1, u64 param2)
{
struct apei_exec_context ctx;
u64 val, trigger_paddr, timeout = FIRMWARE_TIMEOUT;
@@ -247,6 +283,10 @@ static int __einj_error_inject(u32 type)
rc = apei_exec_run(&ctx, ACPI_EINJ_SET_ERROR_TYPE);
if (rc)
return rc;
+ if (einj_param) {
+ writeq(param1, &einj_param->param1);
+ writeq(param2, &einj_param->param2);
+ }
rc = apei_exec_run(&ctx, ACPI_EINJ_EXECUTE_OPERATION);
if (rc)
return rc;
@@ -280,18 +320,32 @@ static int __einj_error_inject(u32 type)
}
/* Inject the specified hardware error */
-static int einj_error_inject(u32 type)
+static int einj_error_inject(u32 type, u64 param1, u64 param2)
{
int rc;
mutex_lock(&einj_mutex);
- rc = __einj_error_inject(type);
+ rc = __einj_error_inject(type, param1, param2);
+ mutex_unlock(&einj_mutex);
+
+ return rc;
+}
+
+static int einj_error_uninject(u32 type, u64 param1, u64 param2)
+{
+ int rc;
+
+ type |= (1U << 31);
+ mutex_lock(&einj_mutex);
+ rc = __einj_error_inject(type, param1, param2);
mutex_unlock(&einj_mutex);
return rc;
}
static u32 error_type;
+static u64 error_param1;
+static u64 error_param2;
static struct dentry *einj_debug_dir;
static int available_error_type_show(struct seq_file *m, void *v)
@@ -375,12 +429,23 @@ static int error_inject_set(void *data,
if (!error_type)
return -EINVAL;
- return einj_error_inject(error_type);
+ return einj_error_inject(error_type, error_param1, error_param2);
}
DEFINE_SIMPLE_ATTRIBUTE(error_inject_fops, NULL,
error_inject_set, "%llu\n");
+static int error_uninject_set(void *data, u64 val)
+{
+ if (!error_type)
+ return -EINVAL;
+
+ return einj_error_uninject(error_type, error_param1, error_param2);
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(error_uninject_fops, NULL,
+ error_uninject_set, "%llu\n");
+
static int einj_check_table(struct acpi_table_einj *einj_tab)
{
if (einj_tab->header_length != sizeof(struct acpi_table_einj))
@@ -398,6 +463,7 @@ static int einj_check_table(struct acpi_
static int __init einj_init(void)
{
int rc;
+ u64 param_paddr;
acpi_status status;
struct dentry *fentry;
struct apei_exec_context ctx;
@@ -435,10 +501,22 @@ static int __init einj_init(void)
einj_debug_dir, NULL, &error_type_fops);
if (!fentry)
goto err_cleanup;
+ fentry = debugfs_create_x64("param1", S_IRUSR | S_IWUSR,
+ einj_debug_dir, &error_param1);
+ if (!fentry)
+ goto err_cleanup;
+ fentry = debugfs_create_x64("param2", S_IRUSR | S_IWUSR,
+ einj_debug_dir, &error_param2);
+ if (!fentry)
+ goto err_cleanup;
fentry = debugfs_create_file("error_inject", S_IWUSR,
einj_debug_dir, NULL, &error_inject_fops);
if (!fentry)
goto err_cleanup;
+ fentry = debugfs_create_file("error_uninject", S_IWUSR, einj_debug_dir,
+ NULL, &error_uninject_fops);
+ if (!fentry)
+ goto err_cleanup;
apei_resources_init(&einj_resources);
einj_exec_ctx_init(&ctx);
@@ -451,11 +529,20 @@ static int __init einj_init(void)
rc = apei_exec_pre_map_gars(&ctx);
if (rc)
goto err_release;
+ param_paddr = einj_get_parameter_address();
+ if (param_paddr) {
+ einj_param = ioremap(param_paddr, sizeof(*einj_param));
+ rc = -ENOMEM;
+ if (!einj_param)
+ goto err_unmap;
+ }
pr_info(EINJ_PFX "Error INJection is initialized.\n");
return 0;
+err_unmap:
+ apei_exec_post_unmap_gars(&ctx);
err_release:
apei_resources_release(&einj_resources);
err_fini:
@@ -470,6 +557,8 @@ static void __exit einj_exit(void)
{
struct apei_exec_context ctx;
+ if (einj_param)
+ iounmap(einj_param);
einj_exec_ctx_init(&ctx);
apei_exec_post_unmap_gars(&ctx);
apei_resources_release(&einj_resources);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Add x64 support to debugfs
2010-05-12 8:40 ` [PATCH 1/2] Add x64 support to debugfs Huang Ying
@ 2010-05-12 21:47 ` Greg KH
2010-05-13 0:25 ` Huang Ying
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2010-05-12 21:47 UTC (permalink / raw)
To: Huang Ying; +Cc: lenb, linux-kernel, andi, linux-acpi, Andi Kleen
On Wed, May 12, 2010 at 04:40:40PM +0800, Huang Ying wrote:
> Add debugfs_create_x64. This is needed by ACPI APEI EINJ parameters support.
>
> Signed-off-by: Huang Ying <ying.huang@intel.com>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> CC: Greg KH <greg@kroah.com>
Do you want me to take this through my tree? Or should it go through
the acpi one as you depend on it?
If so, that's fine with me, feel free to add:
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
to the patch then.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Add x64 support to debugfs
2010-05-12 21:47 ` Greg KH
@ 2010-05-13 0:25 ` Huang Ying
2010-05-13 5:51 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Huang Ying @ 2010-05-13 0:25 UTC (permalink / raw)
To: Greg KH
Cc: lenb@kernel.org, linux-kernel@vger.kernel.org,
andi@firstfloor.org, linux-acpi@vger.kernel.org, Andi Kleen
On Thu, 2010-05-13 at 05:47 +0800, Greg KH wrote:
> On Wed, May 12, 2010 at 04:40:40PM +0800, Huang Ying wrote:
> > Add debugfs_create_x64. This is needed by ACPI APEI EINJ parameters support.
> >
> > Signed-off-by: Huang Ying <ying.huang@intel.com>
> > Signed-off-by: Andi Kleen <ak@linux.intel.com>
> > CC: Greg KH <greg@kroah.com>
>
> Do you want me to take this through my tree? Or should it go through
> the acpi one as you depend on it?
>
> If so, that's fine with me, feel free to add:
> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
> to the patch then.
Thank you very much for you kindness. Cross tree merging is pain, so I
want to go through the ACPI tree to make it easier.
Thanks,
Huang Ying
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Add x64 support to debugfs
2010-05-13 0:25 ` Huang Ying
@ 2010-05-13 5:51 ` Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2010-05-13 5:51 UTC (permalink / raw)
To: Huang Ying
Cc: lenb@kernel.org, linux-kernel@vger.kernel.org,
andi@firstfloor.org, linux-acpi@vger.kernel.org, Andi Kleen
On Thu, May 13, 2010 at 08:25:27AM +0800, Huang Ying wrote:
> On Thu, 2010-05-13 at 05:47 +0800, Greg KH wrote:
> > On Wed, May 12, 2010 at 04:40:40PM +0800, Huang Ying wrote:
> > > Add debugfs_create_x64. This is needed by ACPI APEI EINJ parameters support.
> > >
> > > Signed-off-by: Huang Ying <ying.huang@intel.com>
> > > Signed-off-by: Andi Kleen <ak@linux.intel.com>
> > > CC: Greg KH <greg@kroah.com>
> >
> > Do you want me to take this through my tree? Or should it go through
> > the acpi one as you depend on it?
> >
> > If so, that's fine with me, feel free to add:
> > Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
> > to the patch then.
>
> Thank you very much for you kindness. Cross tree merging is pain, so I
> want to go through the ACPI tree to make it easier.
Great, Len, feel free to take this through your tree.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-05-13 5:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-12 8:40 [PATCH 0/2] ACPI, APEI, EINJ injection parameters support Huang Ying
2010-05-12 8:40 ` [PATCH 1/2] Add x64 support to debugfs Huang Ying
2010-05-12 21:47 ` Greg KH
2010-05-13 0:25 ` Huang Ying
2010-05-13 5:51 ` Greg KH
2010-05-12 8:40 ` [PATCH 2/2] ACPI, APEI, EINJ injection parameters support Huang Ying
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).