diff mbox

[2/3,v3] resource: Add new flag IORESOURCE_MEM_WARN

Message ID 54EC38CA.6050607@plexistor.com (mailing list archive)
State New, archived
Headers show

Commit Message

Boaz Harrosh Feb. 24, 2015, 8:39 a.m. UTC
Resource providers set this flag if they want
that request_region_XXX will print a warning in dmesg
if this particular resource is locked by a driver.

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

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

Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
 arch/x86/kernel/e820.c | 3 +++
 include/linux/ioport.h | 2 +-
 kernel/resource.c      | 7 ++++++-
 3 files changed, 10 insertions(+), 2 deletions(-)

Comments

Boaz Harrosh Feb. 24, 2015, 8:44 a.m. UTC | #1
On 02/24/2015 10:39 AM, Boaz Harrosh wrote:
> 
> Resource providers set this flag if they want
> that request_region_XXX will print a warning in dmesg
> if this particular resource is locked by a driver.
> 
> Thous acting as a Protocol Police about experimental
> devices that did not pass a comity approval.
> 
> The Only user of  this flag is x86/kernel/e820.c that
> wants to WARN about UNKNOWN memory types.
> 

Hi Ingo

So I slept on it and I think this simple version is safe and
does what we need. It is more simple than the wrappers thing

Who can push such a patch, can you push it through your tree or
is there another maintainer that needs to push this?

Who can we ask about the safeness of these flags?

> Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
<>

Thanks
Boaz
Ingo Molnar Feb. 24, 2015, 9:06 a.m. UTC | #2
* Boaz Harrosh <boaz@plexistor.com> wrote:

> --- a/include/linux/ioport.h
> +++ b/include/linux/ioport.h
> @@ -255,6 +256,5 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2)
>         return (r1->start <= r2->end && r1->end >= r2->start);
>  }
>  
> -
>  #endif /* __ASSEMBLY__ */

While the newline is spurious, it should probably not be 
removed in this patch.

Thanks,

	Ingo
Ingo Molnar Feb. 24, 2015, 9:07 a.m. UTC | #3
* Boaz Harrosh <boaz@plexistor.com> wrote:

> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -1075,8 +1075,13 @@ struct resource * __request_region(struct resource *parent,
>  			break;
>  		if (conflict != parent) {
>  			parent = conflict;
> -			if (!(conflict->flags & IORESOURCE_BUSY))
> +			if (!(conflict->flags & IORESOURCE_BUSY)) {
> +				if (conflict->flags & IORESOURCE_MEM_WARN)
> +					pr_warn("request unknown region [mem %#010llx-%#010llx] %s\n",
> +						conflict->start, conflict->end,
> +						conflict->name);

Maybe:

   'request region with unknown memory type [mem ...]'?

The driver (we hope!) very well knows about the region so 
it's not totally unknown.

Thanks,

	Ingo
Boaz Harrosh Feb. 24, 2015, 9:08 a.m. UTC | #4
On 02/24/2015 11:06 AM, Ingo Molnar wrote:
> 
> * Boaz Harrosh <boaz@plexistor.com> wrote:
> 
>> --- a/include/linux/ioport.h
>> +++ b/include/linux/ioport.h
>> @@ -255,6 +256,5 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2)
>>         return (r1->start <= r2->end && r1->end >= r2->start);
>>  }
>>  
>> -
>>  #endif /* __ASSEMBLY__ */
> 
> While the newline is spurious, it should probably not be 
> removed in this patch.
> 

Rrrr you are right. thanks. I did not notice that I did this.

I will resend.

Boaz
Boaz Harrosh Feb. 24, 2015, 9:09 a.m. UTC | #5
On 02/24/2015 11:07 AM, Ingo Molnar wrote:
> 
> * Boaz Harrosh <boaz@plexistor.com> wrote:
> 
>> --- a/kernel/resource.c
>> +++ b/kernel/resource.c
>> @@ -1075,8 +1075,13 @@ struct resource * __request_region(struct resource *parent,
>>  			break;
>>  		if (conflict != parent) {
>>  			parent = conflict;
>> -			if (!(conflict->flags & IORESOURCE_BUSY))
>> +			if (!(conflict->flags & IORESOURCE_BUSY)) {
>> +				if (conflict->flags & IORESOURCE_MEM_WARN)
>> +					pr_warn("request unknown region [mem %#010llx-%#010llx] %s\n",
>> +						conflict->start, conflict->end,
>> +						conflict->name);
> 
> Maybe:
> 
>    'request region with unknown memory type [mem ...]'?
> 
> The driver (we hope!) very well knows about the region so 
> it's not totally unknown.
> 

OK makes sense I will fix that too

> Thanks,
> 
> 	Ingo
>
diff mbox

Patch

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..183af93 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)
@@ -255,6 +256,5 @@  static inline bool resource_overlaps(struct resource *r1, struct resource *r2)
        return (r1->start <= r2->end && r1->end >= r2->start);
 }
 
-
 #endif /* __ASSEMBLY__ */
 #endif	/* _LINUX_IOPORT_H */
diff --git a/kernel/resource.c b/kernel/resource.c
index 19f2357..fca23ff 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1075,8 +1075,13 @@  struct resource * __request_region(struct resource *parent,
 			break;
 		if (conflict != parent) {
 			parent = conflict;
-			if (!(conflict->flags & IORESOURCE_BUSY))
+			if (!(conflict->flags & IORESOURCE_BUSY)) {
+				if (conflict->flags & IORESOURCE_MEM_WARN)
+					pr_warn("request unknown region [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);