All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] acpi/einj: Convert EINJ_PFX to proper pr_fmt
@ 2016-05-23  8:28 Borislav Petkov
  2016-05-23  8:28 ` [PATCH 2/2] acpi/einj: Make error paths more talkative Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2016-05-23  8:28 UTC (permalink / raw)
  To: linux-acpi; +Cc: Rafael J. Wysocki, Tony Luck

From: Borislav Petkov <bp@suse.de>

... and remove it from the pr_* calls.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 drivers/acpi/apei/einj.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index 559c1173de1c..4ba41855799f 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -33,7 +33,8 @@
 
 #include "apei-internal.h"
 
-#define EINJ_PFX "EINJ: "
+#undef pr_fmt
+#define pr_fmt(fmt) "EINJ: " fmt
 
 #define SPIN_UNIT		100			/* 100ns */
 /* Firmware should respond within 1 milliseconds */
@@ -179,8 +180,7 @@ static int einj_get_available_error_type(u32 *type)
 static int einj_timedout(u64 *t)
 {
 	if ((s64)*t < SPIN_UNIT) {
-		pr_warning(FW_WARN EINJ_PFX
-			   "Firmware does not respond in time\n");
+		pr_warning(FW_WARN "Firmware does not respond in time\n");
 		return 1;
 	}
 	*t -= SPIN_UNIT;
@@ -307,8 +307,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 	r = request_mem_region(trigger_paddr, sizeof(*trigger_tab),
 			       "APEI EINJ Trigger Table");
 	if (!r) {
-		pr_err(EINJ_PFX
-	"Can not request [mem %#010llx-%#010llx] for Trigger table\n",
+		pr_err("Can not request [mem %#010llx-%#010llx] for Trigger table\n",
 		       (unsigned long long)trigger_paddr,
 		       (unsigned long long)trigger_paddr +
 			    sizeof(*trigger_tab) - 1);
@@ -316,13 +315,12 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 	}
 	trigger_tab = ioremap_cache(trigger_paddr, sizeof(*trigger_tab));
 	if (!trigger_tab) {
-		pr_err(EINJ_PFX "Failed to map trigger table!\n");
+		pr_err("Failed to map trigger table!\n");
 		goto out_rel_header;
 	}
 	rc = einj_check_trigger_header(trigger_tab);
 	if (rc) {
-		pr_warning(FW_BUG EINJ_PFX
-			   "The trigger error action table is invalid\n");
+		pr_warning(FW_BUG "Invalid trigger error action table.\n");
 		goto out_rel_header;
 	}
 
@@ -336,8 +334,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 			       table_size - sizeof(*trigger_tab),
 			       "APEI EINJ Trigger Table");
 	if (!r) {
-		pr_err(EINJ_PFX
-"Can not request [mem %#010llx-%#010llx] for Trigger Table Entry\n",
+		pr_err("Can not request [mem %#010llx-%#010llx] for Trigger Table Entry\n",
 		       (unsigned long long)trigger_paddr + sizeof(*trigger_tab),
 		       (unsigned long long)trigger_paddr + table_size - 1);
 		goto out_rel_header;
@@ -345,7 +342,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 	iounmap(trigger_tab);
 	trigger_tab = ioremap_cache(trigger_paddr, table_size);
 	if (!trigger_tab) {
-		pr_err(EINJ_PFX "Failed to map trigger table!\n");
+		pr_err("Failed to map trigger table!\n");
 		goto out_rel_entry;
 	}
 	trigger_entry = (struct acpi_whea_header *)
@@ -704,13 +701,13 @@ static int __init einj_init(void)
 		return -ENODEV;
 	else if (ACPI_FAILURE(status)) {
 		const char *msg = acpi_format_exception(status);
-		pr_err(EINJ_PFX "Failed to get table, %s\n", msg);
+		pr_err("Failed to get table, %s\n", msg);
 		return -EINVAL;
 	}
 
 	rc = einj_check_table(einj_tab);
 	if (rc) {
-		pr_warning(FW_BUG EINJ_PFX "EINJ table is invalid\n");
+		pr_warning(FW_BUG "EINJ table is invalid\n");
 		return -EINVAL;
 	}
 
@@ -787,7 +784,7 @@ static int __init einj_init(void)
 			goto err_unmap;
 	}
 
-	pr_info(EINJ_PFX "Error INJection is initialized.\n");
+	pr_info("Error INJection is initialized.\n");
 
 	return 0;
 
-- 
2.7.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] acpi/einj: Make error paths more talkative
  2016-05-23  8:28 [PATCH 1/2] acpi/einj: Convert EINJ_PFX to proper pr_fmt Borislav Petkov
@ 2016-05-23  8:28 ` Borislav Petkov
  2016-05-23 16:01   ` Luck, Tony
  0 siblings, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2016-05-23  8:28 UTC (permalink / raw)
  To: linux-acpi; +Cc: Rafael J. Wysocki, Tony Luck

From: Borislav Petkov <bp@suse.de>

It is absolutely unfriendly when one sees this:

  # modprobe einj
  modprobe: ERROR: could not insert 'einj': No such device

without anything in dmesg to tell one why the load failed.

Beef up the error handling of the init function to be more user-friendly
when the load fails.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 drivers/acpi/apei/einj.c | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index 4ba41855799f..eebb7e39c49c 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -692,34 +692,42 @@ static int __init einj_init(void)
 	struct dentry *fentry;
 	struct apei_exec_context ctx;
 
-	if (acpi_disabled)
+	if (acpi_disabled) {
+		pr_warn("ACPI disabled.\n");
 		return -ENODEV;
+	}
 
 	status = acpi_get_table(ACPI_SIG_EINJ, 0,
 				(struct acpi_table_header **)&einj_tab);
-	if (status == AE_NOT_FOUND)
+	if (status == AE_NOT_FOUND) {
+		pr_warn("EINJ table not found.\n");
 		return -ENODEV;
+	}
 	else if (ACPI_FAILURE(status)) {
-		const char *msg = acpi_format_exception(status);
-		pr_err("Failed to get table, %s\n", msg);
+		pr_err("Failed to get EINJ table: %s\n",
+				acpi_format_exception(status));
 		return -EINVAL;
 	}
 
 	rc = einj_check_table(einj_tab);
 	if (rc) {
-		pr_warning(FW_BUG "EINJ table is invalid\n");
+		pr_warn(FW_BUG "Invalid EINJ table.n");
 		return -EINVAL;
 	}
 
 	rc = -ENOMEM;
 	einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
-	if (!einj_debug_dir)
+	if (!einj_debug_dir) {
+		pr_err("Error creating debugfs node.\n");
 		goto err_cleanup;
+	}
+
 	fentry = debugfs_create_file("available_error_type", S_IRUSR,
 				     einj_debug_dir, NULL,
 				     &available_error_type_fops);
 	if (!fentry)
 		goto err_cleanup;
+
 	fentry = debugfs_create_file("error_type", S_IRUSR | S_IWUSR,
 				     einj_debug_dir, NULL, &error_type_fops);
 	if (!fentry)
@@ -732,14 +740,22 @@ static int __init einj_init(void)
 	apei_resources_init(&einj_resources);
 	einj_exec_ctx_init(&ctx);
 	rc = apei_exec_collect_resources(&ctx, &einj_resources);
-	if (rc)
+	if (rc) {
+		pr_err("Error collecting EINJ resources.\n");
 		goto err_fini;
+	}
+
 	rc = apei_resources_request(&einj_resources, "APEI EINJ");
-	if (rc)
+	if (rc) {
+		pr_err("Error requesting memory/port resources.\n");
 		goto err_fini;
+	}
+
 	rc = apei_exec_pre_map_gars(&ctx);
-	if (rc)
+	if (rc) {
+		pr_err("Error pre-mapping GARs.\n");
 		goto err_release;
+	}
 
 	rc = -ENOMEM;
 	einj_param = einj_get_parameter_address();
@@ -795,6 +811,7 @@ err_unmap:
 			sizeof(struct einj_parameter);
 
 		acpi_os_unmap_iomem(einj_param, size);
+		pr_err("Error creating param extension debugfs nodes.\n");
 	}
 	apei_exec_post_unmap_gars(&ctx);
 err_release:
@@ -802,6 +819,7 @@ err_release:
 err_fini:
 	apei_resources_fini(&einj_resources);
 err_cleanup:
+	pr_err("Error creating primary debugfs nodes.\n");
 	debugfs_remove_recursive(einj_debug_dir);
 
 	return rc;
-- 
2.7.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH 2/2] acpi/einj: Make error paths more talkative
  2016-05-23  8:28 ` [PATCH 2/2] acpi/einj: Make error paths more talkative Borislav Petkov
@ 2016-05-23 16:01   ` Luck, Tony
  2016-06-24 13:36     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Luck, Tony @ 2016-05-23 16:01 UTC (permalink / raw)
  To: Borislav Petkov, linux-acpi; +Cc: Rafael J. Wysocki

> It is absolutely unfriendly when one sees this:
>
>   # modprobe einj
>   modprobe: ERROR: could not insert 'einj': No such device
>
> without anything in dmesg to tell one why the load failed.
>
> Beef up the error handling of the init function to be more user-friendly
> when the load fails.

Yes, yes. 1000 times yes.

Acked-by: Tony Luck <tony.luck@intel.com>

-Tony

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] acpi/einj: Make error paths more talkative
  2016-05-23 16:01   ` Luck, Tony
@ 2016-06-24 13:36     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2016-06-24 13:36 UTC (permalink / raw)
  To: Luck, Tony, Borislav Petkov; +Cc: linux-acpi

On Monday, May 23, 2016 04:01:00 PM Luck, Tony wrote:
> > It is absolutely unfriendly when one sees this:
> >
> >   # modprobe einj
> >   modprobe: ERROR: could not insert 'einj': No such device
> >
> > without anything in dmesg to tell one why the load failed.
> >
> > Beef up the error handling of the init function to be more user-friendly
> > when the load fails.
> 
> Yes, yes. 1000 times yes.
> 
> Acked-by: Tony Luck <tony.luck@intel.com>

Both [1-2/2] applied, thanks!


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-24 13:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-23  8:28 [PATCH 1/2] acpi/einj: Convert EINJ_PFX to proper pr_fmt Borislav Petkov
2016-05-23  8:28 ` [PATCH 2/2] acpi/einj: Make error paths more talkative Borislav Petkov
2016-05-23 16:01   ` Luck, Tony
2016-06-24 13:36     ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.