From patchwork Mon Feb 23 12:48:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 5865381 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 63914BF440 for ; Mon, 23 Feb 2015 12:49:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A4D720640 for ; Mon, 23 Feb 2015 12:49:25 +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 90AAF2063C for ; Mon, 23 Feb 2015 12:49:24 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 86C9481302; Mon, 23 Feb 2015 04:49:24 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-we0-x233.google.com (mail-we0-x233.google.com [IPv6:2a00:1450:400c:c03::233]) (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 3BF1181302 for ; Mon, 23 Feb 2015 04:49:23 -0800 (PST) Received: by wevm14 with SMTP id m14so17768158wev.8 for ; Mon, 23 Feb 2015 04:48:36 -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=3ct3WmTfYvzAqhig53S5DamQsZqJ9yCSQqAfCwRFkoM=; b=Y4be+uX3V91zcXf3xrN+f0OJ/xiojxQrp7WljGSNa0dcXJV9ngnRjf+SUILOoE/kba P5jB7WFt8Sf1/cD4swhyRim+KiLxtUf5yO3/2shHaYGALhllU9B3q2qQ9eM56i/o1CB5 V64RaWzHkqgQ74WDSdid5QmohOZSaG9oD43cByea8ydHC2WtDgQXUIv7GGiCxKKb+eTO pYyr0A9KKe+jffQapQwDOHYwkAuE0OZSBvNM5Kr8l4RiC3hMPMDbqnl/u2ZSm9BZyLBy ienKzBTjFe0qvioVaP3urRVMZ9u98pU5QmHcGAx2Nb4w7hA5mnOaEkMGX6oceuKP/ncy QQKA== X-Gm-Message-State: ALoCoQlxtEBUtnMuuL2IL2cufta6vwU00Y4Xy9IoZYc29+T8Rfdk7eI1k4nQSip2WN7hw+53VQlv X-Received: by 10.194.61.100 with SMTP id o4mr22175312wjr.28.1424695713570; Mon, 23 Feb 2015 04:48:33 -0800 (PST) Received: from [10.0.0.5] ([207.232.55.62]) by mx.google.com with ESMTPSA id j9sm55443101wjy.18.2015.02.23.04.48.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Feb 2015 04:48:33 -0800 (PST) Message-ID: <54EB219F.5050706@plexistor.com> Date: Mon, 23 Feb 2015 14:48:31 +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 References: <54EB1D33.3050107@plexistor.com> In-Reply-To: <54EB1D33.3050107@plexistor.com> Subject: [Linux-nvdimm] [PATCH 3B/3 fat] e820: dynamic unknown-xxx names (for DDR3-NvDIMM) 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 There are multiple vendors of DDR3 NvDIMMs out in the market today. At various stages of development/production. It is estimated that there are already more the 100ds of thousands chips sold to testers and sites. All the BIOS vendors I know of, tagged these chips at e820 table as type-12 memory. Now the ACPI comity, as far as I know, did not yet define a standard type for NvDIMM. Also, as far as I know any NvDIMM standard will only be defined for DDR4. So DDR3 NvDIMM is probably stuck with this none STD type. I Wish and call the ACPI comity to Define that NvDIMM is type-12. Also for DDR4 In this patch I dynamically sprintf names into a static buffer (max two unknown names) of the form "unknown-XXX" where XXX is the type number. This is so we can return static string to caller. If there are too many types or type is bigger than 999 we name the unknown region as "unknown-xxx" I hope this patch is not accepted and that the simple patch that just names above as "unknown-12" is. KISS right? Signed-off-by: Boaz Harrosh --- arch/x86/include/uapi/asm/e820.h | 1 - arch/x86/kernel/e820.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h index d993e33..1f11303 100644 --- a/arch/x86/include/uapi/asm/e820.h +++ b/arch/x86/include/uapi/asm/e820.h @@ -33,7 +33,6 @@ #define E820_NVS 4 #define E820_UNUSABLE 5 - /* * reserved RAM used by kernel itself * if CONFIG_INTEL_TXT is enabled, memory of this type will be diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 18a9850..3e06bab 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -919,6 +919,33 @@ void __init finish_e820_parsing(void) } } +static const char *_unknown_name(uint e820_type) +{ + enum { + MAX_UNKNOWN_TYPES = 1, + UNKNOWN_NAME_SIZE = 16, /* unknown-xxx\0 */ + }; + static struct __unknown_name__ { + int type; + char name[UNKNOWN_NAME_SIZE]; + } names[MAX_UNKNOWN_TYPES]; + static int num_names; + + int i; + + for (i = 0; i < num_names; ++i) + if (e820_type == names[i].type) + return names[i].name; + + if ((num_names == MAX_UNKNOWN_TYPES) || (e820_type > 999)) + return "unknown-xxx"; + + snprintf(names[++num_names].name, UNKNOWN_NAME_SIZE, + "unknown-%03d", e820_type); + names[num_names].type = e820_type; + return names[num_names].name; +} + static inline const char *e820_type_to_string(int e820_type) { switch (e820_type) { @@ -928,7 +955,7 @@ static inline const char *e820_type_to_string(int e820_type) case E820_NVS: return "ACPI Non-volatile Storage"; case E820_UNUSABLE: return "Unusable memory"; case E820_RESERVED: return "reserved"; - default: return "reserved-unkown"; + default: return _unknown_name(e820_type); } }