From patchwork Thu Mar 29 22:05:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10316473 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 8C61D60383 for ; Thu, 29 Mar 2018 22:07:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76A972A531 for ; Thu, 29 Mar 2018 22:07:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B4E52A533; Thu, 29 Mar 2018 22:07:31 +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 C31972A531 for ; Thu, 29 Mar 2018 22:07:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752653AbeC2WH3 (ORCPT ); Thu, 29 Mar 2018 18:07:29 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34812 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752634AbeC2WHZ (ORCPT ); Thu, 29 Mar 2018 18:07:25 -0400 Received: by mail-lf0-f66.google.com with SMTP id c78-v6so10371398lfh.1 for ; Thu, 29 Mar 2018 15:07:24 -0700 (PDT) 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=ZgTovLlbeWYtaHDB2cz3eveI8inWFb+tut6w+ASBxt0=; b=c+88LJYmXQXnPe0iklzW4H9eieOrzYN69Gvj9i8yJjcNu/IF+8qI7HuTX+E9jkLm4R kHXreQhMFPeZ3Vlmiy4z7HzeiQEK9l9SpRv17uxviTgiOZbX4IB/otalQB968gdqKg5i 3SZ16Z6je1hc50s/y0kihavypuofj422kx8rwxXK/WeTHOm3neCd6wTVju/rRLcAb9+v /gQcUvnzjblRql659IWh5IJBqhCU7w4cDDN0v/6+8i697P3ejOvd2A2luAv+LwkUD63f KwdODQc5MlM8NTDzUFMMiBSbOWJlwUq1roFcmpcuWaBWVe+fKFqvjLQ3zOZrH4S+xuLP 8HJA== 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=ZgTovLlbeWYtaHDB2cz3eveI8inWFb+tut6w+ASBxt0=; b=i98unQJ8LaEHOWH0HRc1UOAUiowhEfXBNDd9P+d7nL77UoGnwB/jN+ycxj9KwPqsXu /wq3Us7HSWrj5z/kJJjYQOtfPLHUP+QyiH0BUrkAob9ntXe8PuCQZqe3sq5GQ0ncylK6 g3cNo/LGJkUSUigc6EZY5emNJeQ0ZU1ug5LR2ZBnaXcXRmJMR827b0jDQ0oJ0XuDSujW ikyISqLzcUEACqENuULFnvyypYn+DhWVdCKDs0bYpaqaRAjxsAykU0NvkxKUiLZCM90A MqACDVYQmr5XkRAw9vKJfgLbKfSfEannQXQazJRNV3okBzHPmxKLLGXzBoV1w60IsfPO wMtQ== X-Gm-Message-State: AElRT7FoE54Lxi7LspZsVMZkmp2hs0sS+rivsDDuf8clz7EvVb2X+hFi B7O0LiTrCAyghtimNtH8+pv5bQ== X-Google-Smtp-Source: AIpwx49erdACYldst2EsaJNrEVuiMZLlaR7/3oTs4Du9iYhzWIVnV8pjAPT6A2dodXwsL9ML8SOPXA== X-Received: by 2002:a19:519a:: with SMTP id g26-v6mr6252716lfl.50.1522361243715; Thu, 29 Mar 2018 15:07:23 -0700 (PDT) Received: from Macroninja.cnexlabs.com (x1-6-a4-08-f5-18-3c-3a.cpe.webspeed.dk. [188.176.29.198]) by smtp.gmail.com with ESMTPSA id i89-v6sm1365508lfk.12.2018.03.29.15.07.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 15:07:22 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, keith.busch@intel.com, javier@cnexlabs.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 24/37] lightnvm: add minor version to generic geometry Date: Fri, 30 Mar 2018 00:05:11 +0200 Message-Id: <20180329220524.30363-25-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180329220524.30363-1-mb@lightnvm.io> References: <20180329220524.30363-1-mb@lightnvm.io> 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 From: Javier González 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 Signed-off-by: Matias Bjørling --- 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 9dec936ac1dc..103e0ad9622c 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 29c8f44eb25b..de4105544956 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; @@ -379,7 +381,14 @@ static void nvme_nvm_set_addr_20(struct nvm_addrf *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); @@ -914,7 +923,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) { @@ -1167,7 +1182,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); @@ -1184,7 +1199,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 6e650563b379..7ed8b92d6744 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;