Received: by 10.223.185.116 with SMTP id b49csp3742966wrg; Mon, 26 Feb 2018 05:25:43 -0800 (PST) X-Google-Smtp-Source: AH8x225eQi2BH0wpPCGxXa5CqSKcpumwer2MgScwEFeXLXKIV+3UIZT03vqKKrCZTJuILgnqJjk9 X-Received: by 10.98.65.198 with SMTP id g67mr10541863pfd.127.1519651543743; Mon, 26 Feb 2018 05:25:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519651543; cv=none; d=google.com; s=arc-20160816; b=pHq7wRobNSMr0cRo7xMz2Fi+trYeYnFfj/nJytPpyfqe/5XjQF6q079HU4EakznaVv d7evNV9sin9z11mr+OxEX4okISHYwFeFoLCuSMDujDH4p4E7KF7H1qdBPHTKWYH9sW3H gNgfn9ROJSzWW+vTe+OsBDj0pOsKc5GTSqPS3k1C8yIsPUiOLZgQYcTifR0utG49w0Xy QPNlIO+K9PqNiE4uOmqvZqd5yLNnQjBYNbJxICs53bcYCXgyd5KAys3xmqaaV12VLrjY fwNFLqRm2LcBRPZO8ORldfLklQdjLn1RhQJYJK8COoslC+MdtpoTts09UmrNuWOwBl3p zEpA== 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=pZBfqlXSX9RaFDX9f48Loc6PmPaQRpV35L34KTGl5RQ=; b=ZSSEDH8HJUKcnMP4+WCAREPpXHGy8LVd4qJxRt7yDc+NBKzyuHFJ5U4MhWya0FHSUs g1lC0GSfZ4ip8zS+YmY4cvqLebV5FCd5TJLz9qpmFO/u1RjVn24dlesGNvju1pNN4mGF WmkxPRGwT48MiX7OWl7fndhL0L+FlCl8x9+HRMTI12QQY6rJ2MSHkKQoziqZwhBz6bY2 EuK9c6LRp29xeJ/id27My33peyZKTHAw9aIG/r5Z0GtpX+iKHcfdEGQGckSz1Iji9Z1w xS0TyByN25OvPvtXROuycHIR2LS7kjDL8xQnN2dp6lx+mWPfbjDnBx0c9t4sVDXaPLL9 nPEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=MERxZoyD; 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 r59-v6si4469972plb.69.2018.02.26.05.25.29; Mon, 26 Feb 2018 05:25:43 -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=MERxZoyD; 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 S1753613AbeBZNX6 (ORCPT + 99 others); Mon, 26 Feb 2018 08:23:58 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:38004 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753078AbeBZNRa (ORCPT ); Mon, 26 Feb 2018 08:17:30 -0500 Received: by mail-wm0-f65.google.com with SMTP id z9so17091935wmb.3 for ; Mon, 26 Feb 2018 05:17:30 -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=pZBfqlXSX9RaFDX9f48Loc6PmPaQRpV35L34KTGl5RQ=; b=MERxZoyDpt6eemJI0Kjj4SKXrycn2Qj483Yob4WofSIT1bppVMp+CU7ECOi1Oq56VS gwcMa4ZpLmJt4ohBtBr1tg0DUuxseJ0zuOajP5umBpXQZhhBu3kkYeZo/i0YOP3T6W67 6ipk5ATTNmKbVTYc+r43azqHbZtGZ14mHU9dXo/iNYlKvW/wA3czqvNIOsfVfuvHNd+H EETH7xF7g/TFA0cDmEs8NgSlZB/ET1t0k7VWnzVrCIz1oc7OftHY72tQFbwnPTZ2HrHO EqxGPnV0p257UUr+IpFwSaZrGvOZSO0VtJtl5C2QGty/pnamvcODGsvHyRxq+kaml5ag S+xg== 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=pZBfqlXSX9RaFDX9f48Loc6PmPaQRpV35L34KTGl5RQ=; b=H21BXXMh1o/by+Mx3AakDU+Vjt5ViPA/w8R/IN/Eyw+XG+ZSlc2tS+Hye0lSf5KSvQ GZ1dLhs+yCzuTy3N1Q1C9B2LYmYhbBag7X5g78teiSMp13DnAGNoB7Qo6IrVvQOAddV8 M/Anfg+lwjOWp9JJkjwqP3FYoe7nzxiNLvCdHxf6l58hVo1qeOAArpOCwvmXBqsvH5vQ cgqyMSGgwDqAruPvQJo9m4zcmE6VXZ//ovDRK6oebj0Xoo7evvCVg8//D1QyS7QpwIMu C196yU8rdLyn8RDexun1pdIwMjrsF/BGNpoCLSLDoTSnZx6WbCsRfYtDzzfN3WuCggQ5 /f8A== X-Gm-Message-State: APf1xPASAYmOvsWFDY6ibs0yXb7I/b3VkU1XIZscgFyZtDA/d+BYCxJ6 HqK05cjOBXYyfCbb3GjuCM2ScA== X-Received: by 10.80.219.139 with SMTP id p11mr14789110edk.192.1519651049699; Mon, 26 Feb 2018 05:17:29 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id g59sm7097451ede.19.2018.02.26.05.17.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 05:17:29 -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/19] lightnvm: add minor version to generic geometry Date: Mon, 26 Feb 2018 14:17:02 +0100 Message-Id: <1519651038-16845-4-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519651038-16845-1-git-send-email-javier@cnexlabs.com> References: <1519651038-16845-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 43e3d6bb5be6..96f4e62d383b 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 10392a664b50..8befb60eeacb 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; } - dev_geo->ver_id = id->ver_id; + /* 1.2 spec. only reports a single version id - unfold */ + 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; @@ -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 *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); @@ -920,7 +929,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", dev_geo->ver_id); + if (dev_geo->major_ver_id == 1) + return scnprintf(page, PAGE_SIZE, "%u\n", + dev_geo->major_ver_id); + else + return scnprintf(page, PAGE_SIZE, "%u.%u\n", + dev_geo->major_ver_id, + dev_geo->minor_ver_id); } else if (strcmp(attr->name, "capabilities") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.cap); } else if (strcmp(attr->name, "read_typ") == 0) { @@ -1174,7 +1189,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); @@ -1191,7 +1206,7 @@ void nvme_nvm_unregister_sysfs(struct nvme_ns *ns) struct nvm_dev *ndev = ns->ndev; struct nvm_geo *dev_geo = &ndev->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 42704c4ca9af..ccaf8a30202d 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -309,7 +309,8 @@ struct nvm_common_geo { /* 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