From patchwork Wed Feb 21 09:26:42 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: 10231679 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 A913960209 for ; Wed, 21 Feb 2018 09:32:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0DEE28AAA for ; Wed, 21 Feb 2018 09:32:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A59FD28AAF; Wed, 21 Feb 2018 09:32:21 +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=unavailable 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 3112528AAA for ; Wed, 21 Feb 2018 09:32:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932258AbeBUJcJ (ORCPT ); Wed, 21 Feb 2018 04:32:09 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:40469 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753121AbeBUJ1P (ORCPT ); Wed, 21 Feb 2018 04:27:15 -0500 Received: by mail-wr0-f195.google.com with SMTP id o76so2432564wrb.7 for ; Wed, 21 Feb 2018 01:27:14 -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=bpGrdM4dVr0YJoxiiyQzLpCPhaJHB8xO8C/iowO17kw=; b=YXiDL//fGpoFB+ZUpcXT8FJTIm0Q+3/sSXs/RCpps69pG8HEgDcNYN+NpOKQkEwQxV sAdaBQYrsIGdBMfZLLMJX3V8cp8fzqUHRBelJ2ICbP9v5LWtuGMa9i4fpAFNlrOS9rng lHPmzHTKi+vdMmxgNeskD1ejamuPLpP4QlTI+hNCfD8RUEjZImW8KiIYN8MnY0VnUpRB CGOblKKkpwDzQgOmBrj67q+TdNnOhvsycYZ+LJxb46ZSH/a0jXz/nWDAP5Fj5GyEY4kE ZtpF8rGWIfgvYLqY8s1FXJjN6QXziyal8cA1YiZW15q6AAvvigjWfaNTdIo1cv7XBqCh IlHQ== 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=bpGrdM4dVr0YJoxiiyQzLpCPhaJHB8xO8C/iowO17kw=; b=c9giYq4iq0DqYss62PKyjDYbn9ZSs0gllSs2/lJlslKriDpsFjvFnHFeaozm8i8h1n DjTFqJvgixMS5yLWq6buY1f/8hgoYk8I3StNZtetw8ZsbZXdyYW+jKnKEkVwI+TXfuJg qcR04R6fZzPWfItZg5bX59GqPUMjInDIv1pkywp0b+nzVkLuv8uGo3rIqMnvbySy+2Yc IFLpds6xy1wL1uX+7UsD0lorGxztAAUSiBOeJMDl4juxCwkC0QgoX/7QTw1qluMOI+qU 9i8imwcLxNshtoujJwPCTK7pzzHHTu8vWeDkCMzWykAgxF81UHcYYD5MTNfdh2h/CkRZ ifKA== X-Gm-Message-State: APf1xPDM0LdsywnURwc8IoznT+0OEUwNOnwOkjDmtgj6j7wBXsDapNY0 waQqXDrNVCESLVNmRTTkYUB+6g== X-Google-Smtp-Source: AH8x224Z5a+Yypqaa5RKUsbsWOg29+zoDzQ7zWJ5z1mTWl30tE8ETLkvUfpj7BXisz72w6qIZXwH8Q== X-Received: by 10.80.182.245 with SMTP id f50mr4055158ede.157.1519205233990; Wed, 21 Feb 2018 01:27:13 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id a17sm3389955eda.42.2018.02.21.01.27.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Feb 2018 01:27:13 -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 04/20] lightnvm: add minor version to generic geometry Date: Wed, 21 Feb 2018 10:26:42 +0100 Message-Id: <1519205218-26994-5-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519205218-26994-1-git-send-email-javier@cnexlabs.com> References: <1519205218-26994-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. Also, add a "subversion" entry to sysfs to expose the minor version without breaking user space. 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 42596afdf64c..dc9ec6baff45 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -897,8 +897,8 @@ static int nvm_init(struct nvm_dev *dev) goto err; } - pr_debug("nvm: ver:%u nvm_vendor:%x\n", - dev_geo->ver_id, + pr_debug("nvm: ver:%u.%u nvm_vendor:%x\n", + dev_geo->major_ver_id, dev_geo->minor_ver_id, dev_geo->c.vmnt); ret = nvm_core_init(dev); diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index 598abba66f52..71b4ac57a668 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -296,7 +296,8 @@ static int nvme_nvm_setup_12(struct nvme_nvm_id12 *id, } /* 1.2 spec. only reports a single version id - unfold */ - dev_geo->ver_id = id->ver_id; + dev_geo->major_ver_id = id->ver_id; + dev_geo->minor_ver_id = 2; dev_geo->nr_chnls = src->num_ch; dev_geo->nr_luns = src->num_lun; @@ -377,7 +378,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_dev_geo *dev_geo) { - dev_geo->ver_id = id->mjr; + dev_geo->major_ver_id = id->mjr; + dev_geo->minor_ver_id = id->mnr; + + if (!(dev_geo->major_ver_id == 2 && dev_geo->minor_ver_id == 0)) { + pr_err("nvm: OCSSD version not supported (v%d.%d)\n", + dev_geo->major_ver_id, dev_geo->minor_ver_id); + return -EINVAL; + } dev_geo->nr_chnls = le16_to_cpu(id->num_grp); dev_geo->nr_luns = le16_to_cpu(id->num_pu); @@ -913,7 +921,11 @@ 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", dev_geo->ver_id); + return scnprintf(page, PAGE_SIZE, "%u\n", + dev_geo->major_ver_id); + } else if (strcmp(attr->name, "subversion") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", + dev_geo->minor_ver_id); } else if (strcmp(attr->name, "media_capabilities") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.mccap); } else if (strcmp(attr->name, "read_typ") == 0) { @@ -1055,6 +1067,7 @@ static ssize_t nvm_dev_attr_show_20(struct device *dev, /* general attributes */ static NVM_DEV_ATTR_RO(version); +static NVM_DEV_ATTR_RO(subversion); static NVM_DEV_ATTR_RO(media_capabilities); static NVM_DEV_ATTR_RO(read_typ); @@ -1085,6 +1098,7 @@ static NVM_DEV_ATTR_12_RO(max_phys_secs); static struct attribute *nvm_dev_attrs_12[] = { &dev_attr_version.attr, + &dev_attr_subversion.attr, &dev_attr_media_capabilities.attr, &dev_attr_vendor_opcode.attr, @@ -1134,6 +1148,7 @@ static NVM_DEV_ATTR_20_RO(reset_max); static struct attribute *nvm_dev_attrs_20[] = { &dev_attr_version.attr, + &dev_attr_subversion.attr, &dev_attr_media_capabilities.attr, &dev_attr_groups.attr, @@ -1167,7 +1182,7 @@ int nvme_nvm_register_sysfs(struct nvme_ns *ns) if (!ndev) return -EINVAL; - switch (dev_geo->ver_id) { + switch (dev_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_dev_geo *dev_geo = &ndev->dev_geo; - switch (dev_geo->ver_id) { + switch (dev_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 18e3751b1632..5af0b8837095 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -242,7 +242,8 @@ struct nvm_common_geo { /* Device identified geometry */ struct nvm_dev_geo { /* device reported version */ - u8 ver_id; + u8 major_ver_id; + u8 minor_ver_id; /* full device geometry */ u16 nr_chnls;