From patchwork Wed Feb 28 15:49:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 10248829 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E06860365 for ; Wed, 28 Feb 2018 17:12:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF2332876A for ; Wed, 28 Feb 2018 17:12:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E40E3288B7; Wed, 28 Feb 2018 17:12:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 760132876A for ; Wed, 28 Feb 2018 17:12:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933535AbeB1RMf (ORCPT ); Wed, 28 Feb 2018 12:12:35 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:53191 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752870AbeB1Ptv (ORCPT ); Wed, 28 Feb 2018 10:49:51 -0500 Received: by mail-wm0-f65.google.com with SMTP id t3so5886871wmc.2 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=KKfgjrOIPaE3R7eOQwKucrDLZUsfNux26x27HUhccVExmqBbIvIdE3fqP35F9OL4/w BiX+k8OTw6zcvlEweIok7QWtz2vrVIsEtIWSk+g5Xx5lWswiEDS8wt6mDEOfHgox+VNs DzhMcaFM8uWYezcpa8+b1I1TALIqSSazdJwBA6JVUIbGtKqK0+0o1SM8urCHpVocfKmH ELfwgQNXMi4ILxWpVlpBh37HuEu+p8+6K8y/kd9xUFX+4CyjMmrzBs0OLiv/O6mU8pm0 4Ax3pqJvsd1RYaBfr46FtwAr1OkysYJ9vvWHVO0kaO+cmp9R99JHr1L60igUqYxPEkc9 mNBw== X-Gm-Message-State: APf1xPCSrJpKWsOPfgPgGHjRN7C4fiQywyDYHJgfJftqeFISpkGZ1KB0 bsO5IUEsW6caANC8EvbrffO6/Q== X-Google-Smtp-Source: AH8x227so8mIlHv3/MfzGue3MgqE+0AzGRitdr3qgr54BgsgV+RoVMMMHLm/J8w2PtrDyh6eUaQSgQ== 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 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;