From patchwork Mon Feb 23 12:43:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 5865331 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3CDBC9F169 for ; Mon, 23 Feb 2015 12:44:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 388E720640 for ; Mon, 23 Feb 2015 12:44:18 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 427E620643 for ; Mon, 23 Feb 2015 12:44:17 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 180E081309; Mon, 23 Feb 2015 04:44:17 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-wi0-x229.google.com (mail-wi0-x229.google.com [IPv6:2a00:1450:400c:c05::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 385DD81309 for ; Mon, 23 Feb 2015 04:44:16 -0800 (PST) Received: by mail-wi0-f169.google.com with SMTP id em10so19028866wid.0 for ; Mon, 23 Feb 2015 04:43:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=P735qBe47KePQC7IT0IOlPu8onOEOb+RbCUMUpc4xTg=; b=LDojki4TvgIrMVjyxnVIGw7rYOXlAY1NzqT1sV5cJl4ggUGuJdZiaQi9ol4S3JV3X0 0S0ta756P2cohEFxRWPaighiaXs/7k3qfkE0tsFJzfZOtaWsPoYB3f/7n4INY0Z+L6qP ohe+hbi9mlte83wwiHqcsRjX0lWN3x+VmmbacDJNLy9w051YNOzaoY7r11tcLUF/bacD drdmjn06YclgDkIZZ/hmF+NzCu/Muu/FHyZGe6qK4HN2NyOBJwOBd8Nm/GVkrrzIJJzi ySXgKaiAm3S8q+jCBujYckdhOAZisxrjpLYpphzQdn12h7SCJMTbqKw8vcHuQPYRsREj 6k+A== X-Gm-Message-State: ALoCoQligOl0IDeX2ZLy3cBbw7rIJ9n6L4lzDe4p15cEsrLkr6QkFDn3UT9zQePO+GAy75YHGgUW X-Received: by 10.194.78.72 with SMTP id z8mr22423787wjw.0.1424695409438; Mon, 23 Feb 2015 04:43:29 -0800 (PST) Received: from [10.0.0.5] ([207.232.55.62]) by mx.google.com with ESMTPSA id v6sm9503246wix.8.2015.02.23.04.43.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Feb 2015 04:43:28 -0800 (PST) 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 References: <54EB1D33.3050107@plexistor.com> In-Reply-To: <54EB1D33.3050107@plexistor.com> Subject: [Linux-nvdimm] [PATCH 2/3] resource: Add new flag IORESOURCE_WARN (64bit) X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);