Received: by 10.223.185.116 with SMTP id b49csp6428278wrg; Wed, 28 Feb 2018 09:14:12 -0800 (PST) X-Google-Smtp-Source: AH8x227GlSVFe4qQehdOxTcxbKzkFuCv+FazVj+VpqdnYjBcvIhhOgbvfZGEL53rB5PZiEpswkuv X-Received: by 10.98.135.76 with SMTP id i73mr18418652pfe.140.1519838052176; Wed, 28 Feb 2018 09:14:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519838052; cv=none; d=google.com; s=arc-20160816; b=TU/VM5hKFrwaQgHZHQgPE0QmhN03yXxowxNL9oqzLBqXrdhnMBqzbymm/RO5Y73wQz 6NHQbAJTGuVGw3RRpWxOq+UPaqzD6XMqsjrG4X5rGGkWJ89gDRvWRdYb9e+hGtGWZUQb sMEl2a63S+5BDxpZgof8nPp2SzEN0V2m4PbvCNAFOY3DkctybBNb3eS5xiTvedt9K9FR 1S2WY63OwYaoAVQSFdquYPtcjmIgL4vP6gmB2Tost3hIAMKDXbi/oUL8DE0HTzPAWZiU ZAeGKx/EVQmicfppP4KciyLeecy8vi5y0C4Q0+cTmrs5CciWPvQcdyTeBuDuk0Y25rLW sz1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=9mWBzYIeJskr1ULNf2Lf0LXkj6mRRAswJANm/ADvH3k=; b=tr1vyJeWG0v0sqPS0k9Jw52TBX3a+6jIkaiIJLctI8DR1E+vMJoIL+vWumqLVZ2ioO xzNvgEMYkT76YLzC1tc4mjM9jSBj4LuXWBE3Tw7+DTFZB3I6eK7Vu4Y4/fjzB2UWWqVp LbmbH2+Kv851dn+IrgOHmeL5499e6QM1t+EzYbLXzIIeEUTD1evZCTQ1WHFMiT8FNI8g 4ZdvU+mAfqqlVWnUUIHF8XA/dYMBtT7N+0EL2gbkLmzJXHNuGn83q6z5ffaDfdGSHI0z T5vbSZo1wCI9Ije3CAbMs3LbA3pMTHhHIzN/ceqi+hSda373g1ir9Xq/MOLc0dFue5mK XG1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=ERZMCjPs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si1232944pgv.476.2018.02.28.09.13.57; Wed, 28 Feb 2018 09:14:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=ERZMCjPs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933728AbeB1RMg (ORCPT + 99 others); Wed, 28 Feb 2018 12:12:36 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55819 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752869AbeB1Ptv (ORCPT ); Wed, 28 Feb 2018 10:49:51 -0500 Received: by mail-wm0-f66.google.com with SMTP id q83so5901091wme.5 for ; Wed, 28 Feb 2018 07:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9mWBzYIeJskr1ULNf2Lf0LXkj6mRRAswJANm/ADvH3k=; b=ERZMCjPsvWGu2+0IhNpUEsK4tLGo0JqKlVF+GuxwqKYyG50/Lm1Tzorf3HWaMCoQeL CT1uqPQV88Pha/dKLMCGpEs/UWZbmOgD1XlUin/a54PBJHbqpJ3AxGxESpCBwWgCMeo4 uO2DuHxcZLtBGIACGgLhxgsfYJuy0J0SrUrMBPwQN9a+MNne290QXhrpzdTFTqsRVXRs UEUB3/QiXnPwb9ohQpb6/wh9zn87686TJaJiuLM1zFBoCUc0N7CBqIDtDVNcrRX+Y3Gf 2Oc7KEXWiGyg3f6eYooL/JRl877tRpDysPfXsXxXOg34tP8GWQQUd39XGFKZ2KLEr0fp n8hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9mWBzYIeJskr1ULNf2Lf0LXkj6mRRAswJANm/ADvH3k=; b=cuX0KeQb2MDjLSyalVdwCQEnETHV1ZMxEtAF1jfnrtcnHf29S25/lOb/T0iyNNWmE4 r37q4lvH7JGOfg/rpPUHHA8P73HrNTMs+EK/lh9FHAqqo/n/GPgIKr5WIQ71ABg0e8r0 KwS3IZ4g3ZZ4+h3HBg3efOceF5i+v9kDLYs9goDVkIIsegGrRE2IbQvSK3Q66J0ktqKO KbkiHwtWET9E0UmpInQsHk9yxpU0nXq24q6sVPAGTc40+QW1raURyvbXkkn8KwqwLYfR D+bAeiL2+Uo4RHoX+5bh5Sw8TBEwyuXO5DaP2x2k/kG0M0cQnMIsmFQ92xJ2KVt0y5ni lhcQ== X-Gm-Message-State: APf1xPBqTO0ZXdWSGvFM+aXGwnQO+m4F263daMm54DExbkEJ4Gu6FOY+ OXmZ39nj7rqFnTFm55qazKxTSw== X-Received: by 10.80.133.200 with SMTP id q8mr23752321edh.286.1519832990403; Wed, 28 Feb 2018 07:49:50 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id n2sm1953056edb.62.2018.02.28.07.49.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Feb 2018 07:49:49 -0800 (PST) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH 03/15] lightnvm: add minor version to generic geometry Date: Wed, 28 Feb 2018 16:49:23 +0100 Message-Id: <1519832975-25432-4-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519832975-25432-1-git-send-email-javier@cnexlabs.com> References: <1519832975-25432-1-git-send-email-javier@cnexlabs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Separate the version between major and minor on the generic geometry and represent it through sysfs in the 2.0 path. The 1.2 path only shows the major version to preserve the existing user space interface. Signed-off-by: Javier González --- drivers/lightnvm/core.c | 4 ++-- drivers/nvme/host/lightnvm.c | 25 ++++++++++++++++++++----- include/linux/lightnvm.h | 3 ++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 9a417d9cdf0c..c4f72fbad2bf 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -890,8 +890,8 @@ static int nvm_init(struct nvm_dev *dev) goto err; } - pr_debug("nvm: ver:%u nvm_vendor:%x\n", - geo->ver_id, + pr_debug("nvm: ver:%u.%u nvm_vendor:%x\n", + geo->major_ver_id, geo->minor_ver_id, geo->vmnt); ret = nvm_core_init(dev); diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index 5b2024ebac76..a600e70b6e6b 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -295,7 +295,9 @@ static int nvme_nvm_setup_12(struct nvme_nvm_id12 *id, return -EINVAL; } - geo->ver_id = id->ver_id; + /* 1.2 spec. only reports a single version id - unfold */ + geo->major_ver_id = id->ver_id; + geo->minor_ver_id = 2; geo->nr_chnls = src->num_ch; geo->nr_luns = src->num_lun; @@ -380,7 +382,14 @@ static void nvme_nvm_set_addr_20(struct nvm_addr_format *dst, static int nvme_nvm_setup_20(struct nvme_nvm_id20 *id, struct nvm_geo *geo) { - geo->ver_id = id->mjr; + geo->major_ver_id = id->mjr; + geo->minor_ver_id = id->mnr; + + if (!(geo->major_ver_id == 2 && geo->minor_ver_id == 0)) { + pr_err("nvm: OCSSD version not supported (v%d.%d)\n", + geo->major_ver_id, geo->minor_ver_id); + return -EINVAL; + } geo->nr_chnls = le16_to_cpu(id->num_grp); geo->nr_luns = le16_to_cpu(id->num_pu); @@ -917,7 +926,13 @@ static ssize_t nvm_dev_attr_show(struct device *dev, attr = &dattr->attr; if (strcmp(attr->name, "version") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", geo->ver_id); + if (geo->major_ver_id == 1) + return scnprintf(page, PAGE_SIZE, "%u\n", + geo->major_ver_id); + else + return scnprintf(page, PAGE_SIZE, "%u.%u\n", + geo->major_ver_id, + geo->minor_ver_id); } else if (strcmp(attr->name, "capabilities") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", geo->cap); } else if (strcmp(attr->name, "read_typ") == 0) { @@ -1171,7 +1186,7 @@ int nvme_nvm_register_sysfs(struct nvme_ns *ns) if (!ndev) return -EINVAL; - switch (geo->ver_id) { + switch (geo->major_ver_id) { case 1: return sysfs_create_group(&disk_to_dev(ns->disk)->kobj, &nvm_dev_attr_group_12); @@ -1188,7 +1203,7 @@ void nvme_nvm_unregister_sysfs(struct nvme_ns *ns) struct nvm_dev *ndev = ns->ndev; struct nvm_geo *geo = &ndev->geo; - switch (geo->ver_id) { + switch (geo->major_ver_id) { case 1: sysfs_remove_group(&disk_to_dev(ns->disk)->kobj, &nvm_dev_attr_group_12); diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index b9f0d2070de9..4b2ecbf45fd9 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -263,7 +263,8 @@ enum { /* Instance geometry */ struct nvm_geo { /* device reported version */ - u8 ver_id; + u8 major_ver_id; + u8 minor_ver_id; /* instance specific geometry */ int nr_chnls; -- 2.7.4