linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] ACPI: OSL: SImplify acpi_check_resource_confllict() and clean up printing messages
@ 2021-02-08 18:56 Rafael J. Wysocki
  2021-02-08 18:58 ` [PATCH v1 1/2] ACPI: OSL: Rework acpi_check_resource_conflict() Rafael J. Wysocki
  2021-02-08 18:59 ` [PATCH v1 2/2] ACPI: OSL: Clean up printing messages Rafael J. Wysocki
  0 siblings, 2 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2021-02-08 18:56 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hanjun Gou

Hi All,

These two patches clean up some code in osl.c.

The first one simplifies acpi_check_resource_confllict() and the second one deals with
message printing in this file.

See patch changelogs for details.

Thanks!




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

* [PATCH v1 1/2] ACPI: OSL: Rework acpi_check_resource_conflict()
  2021-02-08 18:56 [PATCH v1 0/2] ACPI: OSL: SImplify acpi_check_resource_confllict() and clean up printing messages Rafael J. Wysocki
@ 2021-02-08 18:58 ` Rafael J. Wysocki
  2021-02-08 18:59 ` [PATCH v1 2/2] ACPI: OSL: Clean up printing messages Rafael J. Wysocki
  1 sibling, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2021-02-08 18:58 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hanjun Gou

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Rearrange the code in acpi_check_resource_conflict() so as to drop
redundant checks and uneeded local variables from there and modify
the messages printed by that function to be more concise and
hopefully easier to understand.

While at it, replace direct printk() usage with pr_*().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/osl.c |   38 ++++++++++++++------------------------
 1 file changed, 14 insertions(+), 24 deletions(-)

Index: linux-pm/drivers/acpi/osl.c
===================================================================
--- linux-pm.orig/drivers/acpi/osl.c
+++ linux-pm/drivers/acpi/osl.c
@@ -1458,38 +1458,28 @@ __setup("acpi_enforce_resources=", acpi_
 int acpi_check_resource_conflict(const struct resource *res)
 {
 	acpi_adr_space_type space_id;
-	acpi_size length;
-	u8 warn = 0;
-	int clash = 0;
 
 	if (acpi_enforce_resources == ENFORCE_RESOURCES_NO)
 		return 0;
-	if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM))
-		return 0;
 
 	if (res->flags & IORESOURCE_IO)
 		space_id = ACPI_ADR_SPACE_SYSTEM_IO;
-	else
+	else if (res->flags & IORESOURCE_MEM)
 		space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
+	else
+		return 0;
+
+	if (!acpi_check_address_range(space_id, res->start, resource_size(res), 1))
+		return 0;
+
+	pr_info("Resource conflict; ACPI support missing from driver?\n");
+
+	if (acpi_enforce_resources == ENFORCE_RESOURCES_STRICT)
+		return -EBUSY;
+
+	if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX)
+		pr_notice("Resource conflict: System may be unstable or behave erratically\n");
 
-	length = resource_size(res);
-	if (acpi_enforce_resources != ENFORCE_RESOURCES_NO)
-		warn = 1;
-	clash = acpi_check_address_range(space_id, res->start, length, warn);
-
-	if (clash) {
-		if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) {
-			if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX)
-				printk(KERN_NOTICE "ACPI: This conflict may"
-				       " cause random problems and system"
-				       " instability\n");
-			printk(KERN_INFO "ACPI: If an ACPI driver is available"
-			       " for this device, you should use it instead of"
-			       " the native driver\n");
-		}
-		if (acpi_enforce_resources == ENFORCE_RESOURCES_STRICT)
-			return -EBUSY;
-	}
 	return 0;
 }
 EXPORT_SYMBOL(acpi_check_resource_conflict);




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

* [PATCH v1 2/2] ACPI: OSL: Clean up printing messages
  2021-02-08 18:56 [PATCH v1 0/2] ACPI: OSL: SImplify acpi_check_resource_confllict() and clean up printing messages Rafael J. Wysocki
  2021-02-08 18:58 ` [PATCH v1 1/2] ACPI: OSL: Rework acpi_check_resource_conflict() Rafael J. Wysocki
@ 2021-02-08 18:59 ` Rafael J. Wysocki
  2021-02-08 20:45   ` Joe Perches
  1 sibling, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2021-02-08 18:59 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hanjun Gou

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Replace the ACPI_DEBUG_PRINT() instance in osl.c unrelated to the
ACPICA debug with acpi_handle_debug(), add a pr_fmt() definition
to osl.c and replace direct printk() usage in that file with the
suitable pr_*() calls.

While at it, add a physical address value to the message in
acpi_os_map_iomem() and reword a couple of messages to avoid
using function names in them.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/osl.c |   35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

Index: linux-pm/drivers/acpi/osl.c
===================================================================
--- linux-pm.orig/drivers/acpi/osl.c
+++ linux-pm/drivers/acpi/osl.c
@@ -9,6 +9,8 @@
  *   Author: Matthew Wilcox <willy@linux.intel.com>
  */
 
+#define pr_fmt(fmt) "ACPI: OSL: " fmt
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
@@ -37,6 +39,7 @@
 #include "acpica/acnamesp.h"
 #include "internal.h"
 
+/* Definitions for ACPI_DEBUG_PRINT() */
 #define _COMPONENT		ACPI_OS_SERVICES
 ACPI_MODULE_NAME("osl");
 
@@ -327,7 +330,7 @@ void __iomem __ref
 	acpi_size pg_sz;
 
 	if (phys > ULONG_MAX) {
-		printk(KERN_ERR PREFIX "Cannot map memory that high\n");
+		pr_err("Cannot map memory that high: 0x%llx\n", phys);
 		return NULL;
 	}
 
@@ -528,13 +531,13 @@ acpi_os_predefined_override(const struct
 
 	*new_val = NULL;
 	if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
-		printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
+		pr_info("Overriding _OS definition to '%s'\n",
 		       acpi_os_name);
 		*new_val = acpi_os_name;
 	}
 
 	if (!memcmp(init_val->name, "_REV", 4) && acpi_rev_override) {
-		printk(KERN_INFO PREFIX "Overriding _REV return value to 5\n");
+		pr_info("Overriding _REV return value to 5\n");
 		*new_val = (char *)5;
 	}
 
@@ -575,7 +578,7 @@ acpi_os_install_interrupt_handler(u32 gs
 		return AE_ALREADY_ACQUIRED;
 
 	if (acpi_gsi_to_irq(gsi, &irq) < 0) {
-		printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
+		pr_err("SCI (ACPI GSI %d) not registered\n",
 		       gsi);
 		return AE_OK;
 	}
@@ -583,7 +586,7 @@ acpi_os_install_interrupt_handler(u32 gs
 	acpi_irq_handler = handler;
 	acpi_irq_context = context;
 	if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
-		printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
+		pr_err("SCI (IRQ%d) allocation failed\n", irq);
 		acpi_irq_handler = NULL;
 		return AE_NOT_ACQUIRED;
 	}
@@ -1071,7 +1074,7 @@ acpi_status acpi_os_execute(acpi_execute
 	if (type == OSL_DEBUGGER_MAIN_THREAD) {
 		ret = acpi_debugger_create_thread(function, context);
 		if (ret) {
-			pr_err("Call to kthread_create() failed.\n");
+			pr_err("Kernel thread creation failed\n");
 			status = AE_ERROR;
 		}
 		goto out_thread;
@@ -1121,8 +1124,7 @@ acpi_status acpi_os_execute(acpi_execute
 	 */
 	ret = queue_work_on(0, queue, &dpc->work);
 	if (!ret) {
-		printk(KERN_ERR PREFIX
-			  "Call to queue_work() failed.\n");
+		pr_err("Unable to queue work\n");
 		status = AE_ERROR;
 	}
 err_workqueue:
@@ -1165,9 +1167,9 @@ acpi_status acpi_hotplug_schedule(struct
 {
 	struct acpi_hp_work *hpw;
 
-	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
-		  "Scheduling hotplug event (%p, %u) for deferred execution.\n",
-		  adev, src));
+	acpi_handle_debug(adev->handle,
+			  "Scheduling hotplug event %u for deferred handling\n",
+			   src);
 
 	hpw = kmalloc(sizeof(*hpw), GFP_KERNEL);
 	if (!hpw)
@@ -1355,7 +1357,7 @@ acpi_status acpi_os_signal(u32 function,
 {
 	switch (function) {
 	case ACPI_SIGNAL_FATAL:
-		printk(KERN_ERR PREFIX "Fatal opcode executed\n");
+		pr_err("Fatal opcode executed\n");
 		break;
 	case ACPI_SIGNAL_BREAKPOINT:
 		/*
@@ -1407,7 +1409,7 @@ __setup("acpi_os_name=", acpi_os_name_se
 static int __init acpi_no_auto_serialize_setup(char *str)
 {
 	acpi_gbl_auto_serialize_methods = FALSE;
-	pr_info("ACPI: auto-serialization disabled\n");
+	pr_info("Auto-serialization disabled\n");
 
 	return 1;
 }
@@ -1712,7 +1714,7 @@ acpi_status acpi_os_release_object(acpi_
 static int __init acpi_no_static_ssdt_setup(char *s)
 {
 	acpi_gbl_disable_ssdt_table_install = TRUE;
-	pr_info("ACPI: static SSDT installation disabled\n");
+	pr_info("Static SSDT installation disabled\n");
 
 	return 0;
 }
@@ -1721,8 +1723,7 @@ early_param("acpi_no_static_ssdt", acpi_
 
 static int __init acpi_disable_return_repair(char *s)
 {
-	printk(KERN_NOTICE PREFIX
-	       "ACPI: Predefined validation mechanism disabled\n");
+	pr_notice("Predefined validation mechanism disabled\n");
 	acpi_gbl_disable_auto_repair = TRUE;
 
 	return 1;
@@ -1748,7 +1749,7 @@ acpi_status __init acpi_os_initialize(vo
 		void *rv;
 
 		rv = acpi_os_map_generic_address(&acpi_gbl_FADT.reset_register);
-		pr_debug(PREFIX "%s: map reset_reg %s\n", __func__,
+		pr_debug("%s: map reset_reg %s\n", __func__,
 			 rv ? "successful" : "failed");
 	}
 	acpi_os_initialized = true;




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

* Re: [PATCH v1 2/2] ACPI: OSL: Clean up printing messages
  2021-02-08 18:59 ` [PATCH v1 2/2] ACPI: OSL: Clean up printing messages Rafael J. Wysocki
@ 2021-02-08 20:45   ` Joe Perches
  2021-02-09 14:55     ` Rafael J. Wysocki
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2021-02-08 20:45 UTC (permalink / raw)
  To: Rafael J. Wysocki, Linux ACPI; +Cc: LKML, Hanjun Gou

On Mon, 2021-02-08 at 19:59 +0100, Rafael J. Wysocki wrote:
> Replace the ACPI_DEBUG_PRINT() instance in osl.c unrelated to the
> ACPICA debug with acpi_handle_debug(), add a pr_fmt() definition
> to osl.c and replace direct printk() usage in that file with the
> suitable pr_*() calls.
[]
> ===================================================================
> --- linux-pm.orig/drivers/acpi/osl.c
> +++ linux-pm/drivers/acpi/osl.c
[]
> @@ -528,13 +531,13 @@ acpi_os_predefined_override(const struct
>  
> 
>  	*new_val = NULL;
>  	if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
> -		printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
> +		pr_info("Overriding _OS definition to '%s'\n",
>  		       acpi_os_name);

If you do more of these, perhaps rewrap lines to 80 columns when possible.

		pr_info("Overriding _OS definition to '%s'\n", acpi_os_name);

etc...



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

* Re: [PATCH v1 2/2] ACPI: OSL: Clean up printing messages
  2021-02-08 20:45   ` Joe Perches
@ 2021-02-09 14:55     ` Rafael J. Wysocki
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2021-02-09 14:55 UTC (permalink / raw)
  To: Joe Perches; +Cc: Rafael J. Wysocki, Linux ACPI, LKML, Hanjun Gou

On Mon, Feb 8, 2021 at 9:49 PM Joe Perches <joe@perches.com> wrote:
>
> On Mon, 2021-02-08 at 19:59 +0100, Rafael J. Wysocki wrote:
> > Replace the ACPI_DEBUG_PRINT() instance in osl.c unrelated to the
> > ACPICA debug with acpi_handle_debug(), add a pr_fmt() definition
> > to osl.c and replace direct printk() usage in that file with the
> > suitable pr_*() calls.
> []
> > ===================================================================
> > --- linux-pm.orig/drivers/acpi/osl.c
> > +++ linux-pm/drivers/acpi/osl.c
> []
> > @@ -528,13 +531,13 @@ acpi_os_predefined_override(const struct
> >
> >
> >       *new_val = NULL;
> >       if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
> > -             printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
> > +             pr_info("Overriding _OS definition to '%s'\n",
> >                      acpi_os_name);
>
> If you do more of these, perhaps rewrap lines to 80 columns when possible.
>
>                 pr_info("Overriding _OS definition to '%s'\n", acpi_os_name);
>
> etc...

I've overlooked this one, will fix it up in the final commit.

Thanks!

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

end of thread, other threads:[~2021-02-09 14:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 18:56 [PATCH v1 0/2] ACPI: OSL: SImplify acpi_check_resource_confllict() and clean up printing messages Rafael J. Wysocki
2021-02-08 18:58 ` [PATCH v1 1/2] ACPI: OSL: Rework acpi_check_resource_conflict() Rafael J. Wysocki
2021-02-08 18:59 ` [PATCH v1 2/2] ACPI: OSL: Clean up printing messages Rafael J. Wysocki
2021-02-08 20:45   ` Joe Perches
2021-02-09 14:55     ` Rafael J. Wysocki

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).