Re: [PATCH 2/3 v4] resource: Add new flag IORESOURCE_MEM_WARN

2015-02-24 Thread Boaz Harrosh
On 02/24/2015 07:04 PM, Dan Williams wrote:
> On Tue, Feb 24, 2015 at 7:00 AM, Boaz Harrosh  wrote:
>>
>> Resource providers set this flag if they want
>> that request_region will print a warning in dmesg
>> if this particular memory resource is locked by a driver.
>>
>> Thous acting as a Protocol Police about experimental
>> devices that did not pass a committee approval.
>>
>> The Only user of  this flag is x86/kernel/e820.c that
>> wants to WARN about UNKNOWN memory types.
>>
>> NOTE: It would be preferred if I defined a general flag say
>>   IORESOURCE_WARN, where any kind of resource provider
>>   can WARN on use, but we have run out of flags in the
>>   32bit long systems. So I defined a free bit from the
>>   resource specific flags for mem resources. This is
>>   why I need to check if this is a memory resource first
>>   so not to conflict with other resource specific flags.
>>   (Though actually no one is using this specific bit)
>>
>> CC: Thomas Gleixner 
>> CC: Ingo Molnar 
>> CC: "H. Peter Anvin" 
>> CC: x...@kernel.org
>> CC: Dan Williams 
>> CC: Andrew Morton 
>> CC: Bjorn Helgaas 
>> CC: Vivek Goyal 
>> Signed-off-by: Boaz Harrosh 
>> ---
>>  arch/x86/kernel/e820.c | 3 +++
>>  include/linux/ioport.h | 1 +
>>  kernel/resource.c  | 9 -
>>  3 files changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
>> index 1a8a1c3..105bb37 100644
>> --- a/arch/x86/kernel/e820.c
>> +++ b/arch/x86/kernel/e820.c
>> @@ -961,6 +961,9 @@ void __init e820_reserve_resources(void)
>>
>> res->flags = IORESOURCE_MEM;
>>
>> +   if (_is_unknown_type(e820.map[i].type))
>> +   res->flags |= IORESOURCE_MEM_WARN;
>> +
>> /*
>>  * don't register the region that could be conflicted with
>>  * pci device BAR resource and insert them later in
>> diff --git a/include/linux/ioport.h b/include/linux/ioport.h
>> index 2c525022..f78972b 100644
>> --- a/include/linux/ioport.h
>> +++ b/include/linux/ioport.h
>> @@ -90,6 +90,7 @@ struct resource {
>>  #define IORESOURCE_MEM_32BIT   (3<<3)
>>  #define IORESOURCE_MEM_SHADOWABLE  (1<<5)  /* dup: 
>> IORESOURCE_SHADOWABLE */
>>  #define IORESOURCE_MEM_EXPANSIONROM(1<<6)
>> +#define IORESOURCE_MEM_WARN(1<<7)  /* WARN if requested by 
>> driver */
>>
>>  /* PnP I/O specific bits (IORESOURCE_BITS) */
>>  #define IORESOURCE_IO_16BIT_ADDR   (1<<0)
>> diff --git a/kernel/resource.c b/kernel/resource.c
>> index 19f2357..4bab16f 100644
>> --- a/kernel/resource.c
>> +++ b/kernel/resource.c
>> @@ -1075,8 +1075,15 @@ struct resource * __request_region(struct resource 
>> *parent,
>> break;
>> if (conflict != parent) {
>> parent = conflict;
>> -   if (!(conflict->flags & IORESOURCE_BUSY))
>> +   if (!(conflict->flags & IORESOURCE_BUSY)) {
>> +   if (unlikely(
> 
> No need for unlikely(), this isn't a hot path.
> 
>> +   (resource_type(conflict) == 
>> IORESOURCE_MEM)
>> +   && (conflict->flags & 
>> IORESOURCE_MEM_WARN)))
>> +   pr_warn("request region with unknown 
>> memory type [mem %#010llx-%#010llx] %s\n",
>> +   conflict->start, 
>> conflict->end,
>> +   conflict->name);
> 
> I think this should also dump the res->name to identify who is requesting it.
> 

OK Will send a version 4

Thanks
Boaz
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3 v4] resource: Add new flag IORESOURCE_MEM_WARN

2015-02-24 Thread Dan Williams
On Tue, Feb 24, 2015 at 7:00 AM, Boaz Harrosh  wrote:
>
> Resource providers set this flag if they want
> that request_region will print a warning in dmesg
> if this particular memory resource is locked by a driver.
>
> Thous acting as a Protocol Police about experimental
> devices that did not pass a committee approval.
>
> The Only user of  this flag is x86/kernel/e820.c that
> wants to WARN about UNKNOWN memory types.
>
> NOTE: It would be preferred if I defined a general flag say
>   IORESOURCE_WARN, where any kind of resource provider
>   can WARN on use, but we have run out of flags in the
>   32bit long systems. So I defined a free bit from the
>   resource specific flags for mem resources. This is
>   why I need to check if this is a memory resource first
>   so not to conflict with other resource specific flags.
>   (Though actually no one is using this specific bit)
>
> CC: Thomas Gleixner 
> CC: Ingo Molnar 
> CC: "H. Peter Anvin" 
> CC: x...@kernel.org
> CC: Dan Williams 
> CC: Andrew Morton 
> CC: Bjorn Helgaas 
> CC: Vivek Goyal 
> Signed-off-by: Boaz Harrosh 
> ---
>  arch/x86/kernel/e820.c | 3 +++
>  include/linux/ioport.h | 1 +
>  kernel/resource.c  | 9 -
>  3 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
> index 1a8a1c3..105bb37 100644
> --- a/arch/x86/kernel/e820.c
> +++ b/arch/x86/kernel/e820.c
> @@ -961,6 +961,9 @@ void __init e820_reserve_resources(void)
>
> res->flags = IORESOURCE_MEM;
>
> +   if (_is_unknown_type(e820.map[i].type))
> +   res->flags |= IORESOURCE_MEM_WARN;
> +
> /*
>  * don't register the region that could be conflicted with
>  * pci device BAR resource and insert them later in
> diff --git a/include/linux/ioport.h b/include/linux/ioport.h
> index 2c525022..f78972b 100644
> --- a/include/linux/ioport.h
> +++ b/include/linux/ioport.h
> @@ -90,6 +90,7 @@ struct resource {
>  #define IORESOURCE_MEM_32BIT   (3<<3)
>  #define IORESOURCE_MEM_SHADOWABLE  (1<<5)  /* dup: IORESOURCE_SHADOWABLE 
> */
>  #define IORESOURCE_MEM_EXPANSIONROM(1<<6)
> +#define IORESOURCE_MEM_WARN(1<<7)  /* WARN if requested by 
> driver */
>
>  /* PnP I/O specific bits (IORESOURCE_BITS) */
>  #define IORESOURCE_IO_16BIT_ADDR   (1<<0)
> diff --git a/kernel/resource.c b/kernel/resource.c
> index 19f2357..4bab16f 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -1075,8 +1075,15 @@ struct resource * __request_region(struct resource 
> *parent,
> break;
> if (conflict != parent) {
> parent = conflict;
> -   if (!(conflict->flags & IORESOURCE_BUSY))
> +   if (!(conflict->flags & IORESOURCE_BUSY)) {
> +   if (unlikely(

No need for unlikely(), this isn't a hot path.

> +   (resource_type(conflict) == 
> IORESOURCE_MEM)
> +   && (conflict->flags & 
> IORESOURCE_MEM_WARN)))
> +   pr_warn("request region with unknown 
> memory type [mem %#010llx-%#010llx] %s\n",
> +   conflict->start, 
> conflict->end,
> +   conflict->name);

I think this should also dump the res->name to identify who is requesting it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3 v4] resource: Add new flag IORESOURCE_MEM_WARN

2015-02-24 Thread Boaz Harrosh

Resource providers set this flag if they want
that request_region will print a warning in dmesg
if this particular memory resource is locked by a driver.

Thous acting as a Protocol Police about experimental
devices that did not pass a committee approval.

The Only user of  this flag is x86/kernel/e820.c that
wants to WARN about UNKNOWN memory types.

NOTE: It would be preferred if I defined a general flag say
  IORESOURCE_WARN, where any kind of resource provider
  can WARN on use, but we have run out of flags in the
  32bit long systems. So I defined a free bit from the
  resource specific flags for mem resources. This is
  why I need to check if this is a memory resource first
  so not to conflict with other resource specific flags.
  (Though actually no one is using this specific bit)

CC: Thomas Gleixner 
CC: Ingo Molnar 
CC: "H. Peter Anvin" 
CC: x...@kernel.org
CC: Dan Williams 
CC: Andrew Morton 
CC: Bjorn Helgaas 
CC: Vivek Goyal 
Signed-off-by: Boaz Harrosh 
---
 arch/x86/kernel/e820.c | 3 +++
 include/linux/ioport.h | 1 +
 kernel/resource.c  | 9 -
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 1a8a1c3..105bb37 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -961,6 +961,9 @@ void __init e820_reserve_resources(void)
 
res->flags = IORESOURCE_MEM;
 
+   if (_is_unknown_type(e820.map[i].type))
+   res->flags |= IORESOURCE_MEM_WARN;
+
/*
 * don't register the region that could be conflicted with
 * pci device BAR resource and insert them later in
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 2c525022..f78972b 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -90,6 +90,7 @@ struct resource {
 #define IORESOURCE_MEM_32BIT   (3<<3)
 #define IORESOURCE_MEM_SHADOWABLE  (1<<5)  /* dup: IORESOURCE_SHADOWABLE */
 #define IORESOURCE_MEM_EXPANSIONROM(1<<6)
+#define IORESOURCE_MEM_WARN(1<<7)  /* WARN if requested by driver 
*/
 
 /* PnP I/O specific bits (IORESOURCE_BITS) */
 #define IORESOURCE_IO_16BIT_ADDR   (1<<0)
diff --git a/kernel/resource.c b/kernel/resource.c
index 19f2357..4bab16f 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1075,8 +1075,15 @@ struct resource * __request_region(struct resource 
*parent,
break;
if (conflict != parent) {
parent = conflict;
-   if (!(conflict->flags & IORESOURCE_BUSY))
+   if (!(conflict->flags & IORESOURCE_BUSY)) {
+   if (unlikely(
+   (resource_type(conflict) == IORESOURCE_MEM)
+   && (conflict->flags & IORESOURCE_MEM_WARN)))
+   pr_warn("request region with unknown 
memory type [mem %#010llx-%#010llx] %s\n",
+   conflict->start, conflict->end,
+   conflict->name);
continue;
+   }
}
if (conflict->flags & flags & IORESOURCE_MUXED) {
add_wait_queue(_resource_wait, );
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3 v4] resource: Add new flag IORESOURCE_MEM_WARN

2015-02-24 Thread Boaz Harrosh

Resource providers set this flag if they want
that request_region will print a warning in dmesg
if this particular memory resource is locked by a driver.

Thous acting as a Protocol Police about experimental
devices that did not pass a committee approval.

The Only user of  this flag is x86/kernel/e820.c that
wants to WARN about UNKNOWN memory types.

NOTE: It would be preferred if I defined a general flag say
  IORESOURCE_WARN, where any kind of resource provider
  can WARN on use, but we have run out of flags in the
  32bit long systems. So I defined a free bit from the
  resource specific flags for mem resources. This is
  why I need to check if this is a memory resource first
  so not to conflict with other resource specific flags.
  (Though actually no one is using this specific bit)

CC: Thomas Gleixner t...@linutronix.de
CC: Ingo Molnar mi...@redhat.com
CC: H. Peter Anvin h...@zytor.com
CC: x...@kernel.org
CC: Dan Williams dan.j.willi...@intel.com
CC: Andrew Morton a...@linux-foundation.org
CC: Bjorn Helgaas bhelg...@google.com
CC: Vivek Goyal vgo...@redhat.com
Signed-off-by: Boaz Harrosh b...@plexistor.com
---
 arch/x86/kernel/e820.c | 3 +++
 include/linux/ioport.h | 1 +
 kernel/resource.c  | 9 -
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 1a8a1c3..105bb37 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -961,6 +961,9 @@ void __init e820_reserve_resources(void)
 
res-flags = IORESOURCE_MEM;
 
+   if (_is_unknown_type(e820.map[i].type))
+   res-flags |= IORESOURCE_MEM_WARN;
+
/*
 * don't register the region that could be conflicted with
 * pci device BAR resource and insert them later in
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 2c525022..f78972b 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -90,6 +90,7 @@ struct resource {
 #define IORESOURCE_MEM_32BIT   (33)
 #define IORESOURCE_MEM_SHADOWABLE  (15)  /* dup: IORESOURCE_SHADOWABLE */
 #define IORESOURCE_MEM_EXPANSIONROM(16)
+#define IORESOURCE_MEM_WARN(17)  /* WARN if requested by driver 
*/
 
 /* PnP I/O specific bits (IORESOURCE_BITS) */
 #define IORESOURCE_IO_16BIT_ADDR   (10)
diff --git a/kernel/resource.c b/kernel/resource.c
index 19f2357..4bab16f 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1075,8 +1075,15 @@ struct resource * __request_region(struct resource 
*parent,
break;
if (conflict != parent) {
parent = conflict;
-   if (!(conflict-flags  IORESOURCE_BUSY))
+   if (!(conflict-flags  IORESOURCE_BUSY)) {
+   if (unlikely(
+   (resource_type(conflict) == IORESOURCE_MEM)
+(conflict-flags  IORESOURCE_MEM_WARN)))
+   pr_warn(request region with unknown 
memory type [mem %#010llx-%#010llx] %s\n,
+   conflict-start, conflict-end,
+   conflict-name);
continue;
+   }
}
if (conflict-flags  flags  IORESOURCE_MUXED) {
add_wait_queue(muxed_resource_wait, wait);
-- 
1.9.3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3 v4] resource: Add new flag IORESOURCE_MEM_WARN

2015-02-24 Thread Dan Williams
On Tue, Feb 24, 2015 at 7:00 AM, Boaz Harrosh b...@plexistor.com wrote:

 Resource providers set this flag if they want
 that request_region will print a warning in dmesg
 if this particular memory resource is locked by a driver.

 Thous acting as a Protocol Police about experimental
 devices that did not pass a committee approval.

 The Only user of  this flag is x86/kernel/e820.c that
 wants to WARN about UNKNOWN memory types.

 NOTE: It would be preferred if I defined a general flag say
   IORESOURCE_WARN, where any kind of resource provider
   can WARN on use, but we have run out of flags in the
   32bit long systems. So I defined a free bit from the
   resource specific flags for mem resources. This is
   why I need to check if this is a memory resource first
   so not to conflict with other resource specific flags.
   (Though actually no one is using this specific bit)

 CC: Thomas Gleixner t...@linutronix.de
 CC: Ingo Molnar mi...@redhat.com
 CC: H. Peter Anvin h...@zytor.com
 CC: x...@kernel.org
 CC: Dan Williams dan.j.willi...@intel.com
 CC: Andrew Morton a...@linux-foundation.org
 CC: Bjorn Helgaas bhelg...@google.com
 CC: Vivek Goyal vgo...@redhat.com
 Signed-off-by: Boaz Harrosh b...@plexistor.com
 ---
  arch/x86/kernel/e820.c | 3 +++
  include/linux/ioport.h | 1 +
  kernel/resource.c  | 9 -
  3 files changed, 12 insertions(+), 1 deletion(-)

 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
 index 1a8a1c3..105bb37 100644
 --- a/arch/x86/kernel/e820.c
 +++ b/arch/x86/kernel/e820.c
 @@ -961,6 +961,9 @@ void __init e820_reserve_resources(void)

 res-flags = IORESOURCE_MEM;

 +   if (_is_unknown_type(e820.map[i].type))
 +   res-flags |= IORESOURCE_MEM_WARN;
 +
 /*
  * don't register the region that could be conflicted with
  * pci device BAR resource and insert them later in
 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
 index 2c525022..f78972b 100644
 --- a/include/linux/ioport.h
 +++ b/include/linux/ioport.h
 @@ -90,6 +90,7 @@ struct resource {
  #define IORESOURCE_MEM_32BIT   (33)
  #define IORESOURCE_MEM_SHADOWABLE  (15)  /* dup: IORESOURCE_SHADOWABLE 
 */
  #define IORESOURCE_MEM_EXPANSIONROM(16)
 +#define IORESOURCE_MEM_WARN(17)  /* WARN if requested by 
 driver */

  /* PnP I/O specific bits (IORESOURCE_BITS) */
  #define IORESOURCE_IO_16BIT_ADDR   (10)
 diff --git a/kernel/resource.c b/kernel/resource.c
 index 19f2357..4bab16f 100644
 --- a/kernel/resource.c
 +++ b/kernel/resource.c
 @@ -1075,8 +1075,15 @@ struct resource * __request_region(struct resource 
 *parent,
 break;
 if (conflict != parent) {
 parent = conflict;
 -   if (!(conflict-flags  IORESOURCE_BUSY))
 +   if (!(conflict-flags  IORESOURCE_BUSY)) {
 +   if (unlikely(

No need for unlikely(), this isn't a hot path.

 +   (resource_type(conflict) == 
 IORESOURCE_MEM)
 +(conflict-flags  
 IORESOURCE_MEM_WARN)))
 +   pr_warn(request region with unknown 
 memory type [mem %#010llx-%#010llx] %s\n,
 +   conflict-start, 
 conflict-end,
 +   conflict-name);

I think this should also dump the res-name to identify who is requesting it.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3 v4] resource: Add new flag IORESOURCE_MEM_WARN

2015-02-24 Thread Boaz Harrosh
On 02/24/2015 07:04 PM, Dan Williams wrote:
 On Tue, Feb 24, 2015 at 7:00 AM, Boaz Harrosh b...@plexistor.com wrote:

 Resource providers set this flag if they want
 that request_region will print a warning in dmesg
 if this particular memory resource is locked by a driver.

 Thous acting as a Protocol Police about experimental
 devices that did not pass a committee approval.

 The Only user of  this flag is x86/kernel/e820.c that
 wants to WARN about UNKNOWN memory types.

 NOTE: It would be preferred if I defined a general flag say
   IORESOURCE_WARN, where any kind of resource provider
   can WARN on use, but we have run out of flags in the
   32bit long systems. So I defined a free bit from the
   resource specific flags for mem resources. This is
   why I need to check if this is a memory resource first
   so not to conflict with other resource specific flags.
   (Though actually no one is using this specific bit)

 CC: Thomas Gleixner t...@linutronix.de
 CC: Ingo Molnar mi...@redhat.com
 CC: H. Peter Anvin h...@zytor.com
 CC: x...@kernel.org
 CC: Dan Williams dan.j.willi...@intel.com
 CC: Andrew Morton a...@linux-foundation.org
 CC: Bjorn Helgaas bhelg...@google.com
 CC: Vivek Goyal vgo...@redhat.com
 Signed-off-by: Boaz Harrosh b...@plexistor.com
 ---
  arch/x86/kernel/e820.c | 3 +++
  include/linux/ioport.h | 1 +
  kernel/resource.c  | 9 -
  3 files changed, 12 insertions(+), 1 deletion(-)

 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
 index 1a8a1c3..105bb37 100644
 --- a/arch/x86/kernel/e820.c
 +++ b/arch/x86/kernel/e820.c
 @@ -961,6 +961,9 @@ void __init e820_reserve_resources(void)

 res-flags = IORESOURCE_MEM;

 +   if (_is_unknown_type(e820.map[i].type))
 +   res-flags |= IORESOURCE_MEM_WARN;
 +
 /*
  * don't register the region that could be conflicted with
  * pci device BAR resource and insert them later in
 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
 index 2c525022..f78972b 100644
 --- a/include/linux/ioport.h
 +++ b/include/linux/ioport.h
 @@ -90,6 +90,7 @@ struct resource {
  #define IORESOURCE_MEM_32BIT   (33)
  #define IORESOURCE_MEM_SHADOWABLE  (15)  /* dup: 
 IORESOURCE_SHADOWABLE */
  #define IORESOURCE_MEM_EXPANSIONROM(16)
 +#define IORESOURCE_MEM_WARN(17)  /* WARN if requested by 
 driver */

  /* PnP I/O specific bits (IORESOURCE_BITS) */
  #define IORESOURCE_IO_16BIT_ADDR   (10)
 diff --git a/kernel/resource.c b/kernel/resource.c
 index 19f2357..4bab16f 100644
 --- a/kernel/resource.c
 +++ b/kernel/resource.c
 @@ -1075,8 +1075,15 @@ struct resource * __request_region(struct resource 
 *parent,
 break;
 if (conflict != parent) {
 parent = conflict;
 -   if (!(conflict-flags  IORESOURCE_BUSY))
 +   if (!(conflict-flags  IORESOURCE_BUSY)) {
 +   if (unlikely(
 
 No need for unlikely(), this isn't a hot path.
 
 +   (resource_type(conflict) == 
 IORESOURCE_MEM)
 +(conflict-flags  
 IORESOURCE_MEM_WARN)))
 +   pr_warn(request region with unknown 
 memory type [mem %#010llx-%#010llx] %s\n,
 +   conflict-start, 
 conflict-end,
 +   conflict-name);
 
 I think this should also dump the res-name to identify who is requesting it.
 

OK Will send a version 4

Thanks
Boaz
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/