Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752264AbbBWMnc (ORCPT ); Mon, 23 Feb 2015 07:43:32 -0500 Received: from mail-we0-f176.google.com ([74.125.82.176]:46869 "EHLO mail-we0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752032AbbBWMnb (ORCPT ); Mon, 23 Feb 2015 07:43:31 -0500 Message-ID: <54EB206E.4010009@plexistor.com> Date: Mon, 23 Feb 2015 14:43:26 +0200 From: Boaz Harrosh User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Ingo Molnar , Ross Zwisler , x86@kernel.org, linux-kernel , "Roger C. Pao" , Dan Williams , Thomas Gleixner , Linus Torvalds , linux-nvdimm , "H. Peter Anvin" , Matthew Wilcox , Andy Lutomirski , Christoph Hellwig , Andrew Morton , Vivek Goyal Subject: [PATCH 2/3] resource: Add new flag IORESOURCE_WARN (64bit) References: <54EB1D33.3050107@plexistor.com> In-Reply-To: <54EB1D33.3050107@plexistor.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4916 Lines: 143 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 warn print looks like this: [Feb22 19:59] resource: request unknown region [mem 0x100000000-0x1ffffffff] unkown-12 Where the unkown-12 is taken from the res->name The Only user of this flag is x86/kernel/e820.c that wants to WARN about UNKNOWN memory types. NOTE: This patch looks very simple, a bit flag communicates between a resource provider ie e820.c that a warning should be printed, and resource.c prints such a message, when the resource is locked for use. BUT the basic flaw here is that we have run out of flags for a 32-bit long. My route here is to create wrappers that at 32-bit do nothing. Since only current user is e820.c for DDR3-NvDIMMs, this should be fine, because DDR3-NvDIMMs are not very useful with 32-bit ARCHES. In fact the smallest chip I know is 4G, and NvDIMM is not currently supported as highmem (nor are there any plans to support it) OR: Maybe there is an extra bit that can be used at: /* PnP memory I/O specific bits */ @@ -92,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 used by drivers */ /* PnP I/O specific bits (IORESOURCE_BITS) */ #define IORESOURCE_IO_16BIT_ADDR (1<<0) And get rid of the wrappers, Please advise ? CC: Thomas Gleixner CC: Ingo Molnar CC: "H. Peter Anvin" CC: x86@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 | 23 +++++++++++++++++++++++ kernel/resource.c | 7 ++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 1a8a1c3..18a9850 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)) + resource_set_warn_on_use(res, true); + /* * 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..9a51738 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -54,6 +54,8 @@ struct resource { #define IORESOURCE_UNSET 0x20000000 /* No address assigned yet */ #define IORESOURCE_AUTO 0x40000000 #define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ +/* Flags only on 64bit */ +#define IORESOURCE_WARN 0x100000000 /* Use with wrapper Only */ /* PnP IRQ specific bits (IORESOURCE_BITS) */ #define IORESOURCE_IRQ_HIGHEDGE (1<<0) @@ -255,6 +257,27 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2) return (r1->start <= r2->end && r1->end >= r2->start); } +static inline void resource_set_warn_on_use(struct resource *r, bool warn) +{ + if (sizeof(r->flags) > sizeof(u32)) { + if (warn) + r->flags |= IORESOURCE_WARN; + else + r->flags &= ~IORESOURCE_WARN; + } + /* I'm not doing any prints here for the else case because I do not want + * to add the extra chain of includes this needs. This is a pretty low + * level Header + */ +} + +static inline bool resource_warn_on_use(struct resource *r) +{ + if (sizeof(r->flags) > sizeof(u32)) + return (r->flags & IORESOURCE_WARN) != 0; + else + return false; +} #endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */ diff --git a/kernel/resource.c b/kernel/resource.c index 19f2357..eca6920 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 (resource_warn_on_use(conflict)) + 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); -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/