linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI / watchdog: Fix init failure with overlapping register regions
@ 2017-07-15 21:48 Ryan Kennedy
  2017-07-24 20:37 ` Rafael J. Wysocki
  0 siblings, 1 reply; 5+ messages in thread
From: Ryan Kennedy @ 2017-07-15 21:48 UTC (permalink / raw)
  To: linux-acpi; +Cc: rjw, lenb, Ryan Kennedy

Partially overlapping regions cause platform device creation
to fail. The latter of two overlapping resources will fail to be
reserved. Fix this by merging overlapping resource ranges while
enumerating WDAT table entries.

Signed-off-by: Ryan Kennedy <ryan5544@gmail.com>
---
 drivers/acpi/acpi_watchdog.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c
index 8c4e0a1..bf22c29 100644
--- a/drivers/acpi/acpi_watchdog.c
+++ b/drivers/acpi/acpi_watchdog.c
@@ -86,7 +86,12 @@ void __init acpi_watchdog_init(void)
 
 		found = false;
 		resource_list_for_each_entry(rentry, &resource_list) {
-			if (resource_contains(rentry->res, &res)) {
+			if (rentry->res->flags == res.flags &&
+			    resource_overlaps(rentry->res, &res)) {
+				if (res.start < rentry->res->start)
+					rentry->res->start = res.start;
+				if (res.end > rentry->res->end)
+					rentry->res->end = res.end;
 				found = true;
 				break;
 			}
-- 
2.9.4


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

* Re: [PATCH] ACPI / watchdog: Fix init failure with overlapping register regions
  2017-07-15 21:48 [PATCH] ACPI / watchdog: Fix init failure with overlapping register regions Ryan Kennedy
@ 2017-07-24 20:37 ` Rafael J. Wysocki
  2017-07-25  9:37   ` Mika Westerberg
  0 siblings, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2017-07-24 20:37 UTC (permalink / raw)
  To: Ryan Kennedy, Mika Westerberg; +Cc: linux-acpi, lenb

On Saturday, July 15, 2017 05:48:18 PM Ryan Kennedy wrote:
> Partially overlapping regions cause platform device creation
> to fail. The latter of two overlapping resources will fail to be
> reserved. Fix this by merging overlapping resource ranges while
> enumerating WDAT table entries.
> 
> Signed-off-by: Ryan Kennedy <ryan5544@gmail.com>
> ---
>  drivers/acpi/acpi_watchdog.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c
> index 8c4e0a1..bf22c29 100644
> --- a/drivers/acpi/acpi_watchdog.c
> +++ b/drivers/acpi/acpi_watchdog.c
> @@ -86,7 +86,12 @@ void __init acpi_watchdog_init(void)
>  
>  		found = false;
>  		resource_list_for_each_entry(rentry, &resource_list) {
> -			if (resource_contains(rentry->res, &res)) {
> +			if (rentry->res->flags == res.flags &&
> +			    resource_overlaps(rentry->res, &res)) {
> +				if (res.start < rentry->res->start)
> +					rentry->res->start = res.start;
> +				if (res.end > rentry->res->end)
> +					rentry->res->end = res.end;
>  				found = true;
>  				break;
>  			}
> 

Mika, can you have a look at this, please?


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

* Re: [PATCH] ACPI / watchdog: Fix init failure with overlapping register regions
  2017-07-24 20:37 ` Rafael J. Wysocki
@ 2017-07-25  9:37   ` Mika Westerberg
  2017-07-25 13:13     ` Mika Westerberg
  0 siblings, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2017-07-25  9:37 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Ryan Kennedy, linux-acpi, lenb

On Mon, Jul 24, 2017 at 10:37:17PM +0200, Rafael J. Wysocki wrote:
> On Saturday, July 15, 2017 05:48:18 PM Ryan Kennedy wrote:
> > Partially overlapping regions cause platform device creation
> > to fail. The latter of two overlapping resources will fail to be
> > reserved. Fix this by merging overlapping resource ranges while
> > enumerating WDAT table entries.
> > 
> > Signed-off-by: Ryan Kennedy <ryan5544@gmail.com>
> > ---
> >  drivers/acpi/acpi_watchdog.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c
> > index 8c4e0a1..bf22c29 100644
> > --- a/drivers/acpi/acpi_watchdog.c
> > +++ b/drivers/acpi/acpi_watchdog.c
> > @@ -86,7 +86,12 @@ void __init acpi_watchdog_init(void)
> >  
> >  		found = false;
> >  		resource_list_for_each_entry(rentry, &resource_list) {
> > -			if (resource_contains(rentry->res, &res)) {
> > +			if (rentry->res->flags == res.flags &&
> > +			    resource_overlaps(rentry->res, &res)) {
> > +				if (res.start < rentry->res->start)
> > +					rentry->res->start = res.start;
> > +				if (res.end > rentry->res->end)
> > +					rentry->res->end = res.end;
> >  				found = true;
> >  				break;
> >  			}
> > 
> 
> Mika, can you have a look at this, please?

I wonder why we need to do this?

+                           if (res.start < rentry->res->start)
+                                   rentry->res->start = res.start;
+                           if (res.end > rentry->res->end)
+                                   rentry->res->end = res.end;

IIRC we don't use rentry for anything else when we go out of the loop.
Tuning those limits seems unnecessary.

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

* Re: [PATCH] ACPI / watchdog: Fix init failure with overlapping register regions
  2017-07-25  9:37   ` Mika Westerberg
@ 2017-07-25 13:13     ` Mika Westerberg
  2017-07-26 18:57       ` Rafael J. Wysocki
  0 siblings, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2017-07-25 13:13 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Ryan Kennedy, linux-acpi, lenb

On Tue, Jul 25, 2017 at 12:37:31PM +0300, Mika Westerberg wrote:
> I wonder why we need to do this?
> 
> +                           if (res.start < rentry->res->start)
> +                                   rentry->res->start = res.start;
> +                           if (res.end > rentry->res->end)
> +                                   rentry->res->end = res.end;
> 
> IIRC we don't use rentry for anything else when we go out of the loop.
> Tuning those limits seems unnecessary.

OK, Ryan pointed out that the later code then uses the adjusted rentry
so this is indeed needed.

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

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

* Re: [PATCH] ACPI / watchdog: Fix init failure with overlapping register regions
  2017-07-25 13:13     ` Mika Westerberg
@ 2017-07-26 18:57       ` Rafael J. Wysocki
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2017-07-26 18:57 UTC (permalink / raw)
  To: Mika Westerberg, Ryan Kennedy; +Cc: linux-acpi, lenb

On Tuesday, July 25, 2017 04:13:41 PM Mika Westerberg wrote:
> On Tue, Jul 25, 2017 at 12:37:31PM +0300, Mika Westerberg wrote:
> > I wonder why we need to do this?
> > 
> > +                           if (res.start < rentry->res->start)
> > +                                   rentry->res->start = res.start;
> > +                           if (res.end > rentry->res->end)
> > +                                   rentry->res->end = res.end;
> > 
> > IIRC we don't use rentry for anything else when we go out of the loop.
> > Tuning those limits seems unnecessary.
> 
> OK, Ryan pointed out that the later code then uses the adjusted rentry
> so this is indeed needed.
> 
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

OK, patch applied, thanks!


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

end of thread, other threads:[~2017-07-26 19:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-15 21:48 [PATCH] ACPI / watchdog: Fix init failure with overlapping register regions Ryan Kennedy
2017-07-24 20:37 ` Rafael J. Wysocki
2017-07-25  9:37   ` Mika Westerberg
2017-07-25 13:13     ` Mika Westerberg
2017-07-26 18:57       ` 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).