From patchwork Tue Feb 13 14:06:02 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: 10216401 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 C32A160329 for ; Tue, 13 Feb 2018 14:07:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1252287E8 for ; Tue, 13 Feb 2018 14:07:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5F3A28D12; Tue, 13 Feb 2018 14:07:04 +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 AB536287E8 for ; Tue, 13 Feb 2018 14:07:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965029AbeBMOHB (ORCPT ); Tue, 13 Feb 2018 09:07:01 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:40931 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965010AbeBMOGU (ORCPT ); Tue, 13 Feb 2018 09:06:20 -0500 Received: by mail-wm0-f67.google.com with SMTP id v123so16240073wmd.5 for ; Tue, 13 Feb 2018 06:06:19 -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=F0lRsS1gQZjua+XNIA3hiG453FFDq0w6IhSlMrLKOwc=; b=FkEQeAUqCFESOPpu0/K6h/GBCtVkDQwephcvR1+YlrWHmY0LZeSrFDTySIhddx7bbd eWRh+dKEMF41aBmsuPRm0ELuBo2Bg/OnEs6NhQk5QBCoIWVh1YIyzGokyKCLejzMNVzX f0yAAUpjusstTjT0Mh61kUBxxtIWFb6w42YDW/FAf1/ZYWAFHsVnHfdpOxbl698e0SIx WpFFIh0UHL8b2OrddJtpR2NOcgq4/poWvE+iB/AD1gPUa2yoH5nOwa6SYXs/dBQivjSx sMYs6XA681Icb41ytn7lyR79u9UWEv9NKjT+mqXSom5we+mEbnMtHFST8MguVLemDmH2 cV2g== 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=F0lRsS1gQZjua+XNIA3hiG453FFDq0w6IhSlMrLKOwc=; b=S8xAEclmVx/9avtI4J/PYesIxTSEBJGSmE2bAfWr1XFbv5Q/OoztFblNB1Yh9TLT4W GDWJw6N39DhX0ENO9W6N99mKHgrZDOvD1yU1t1mhZTy3wiAHzdfX93aw9Rlf+0X1c2jz PnwEyraV1bXecnXshDbSdf16I1LTARXq3CmyjeMX/84ukhAQHSO7LdO1kqJ8d55gd3TU /4H1m6mQGwwRBaFoTH1qulBOVB5hH46ZMVZF6DFi46vqkMxTnTBCDwisNvk6iOa0jQae +2F8Ha4RDHiRtWRscxrw7q7i6ri4USbxvX8PDvQ2Lpc2Eun/JENb17QSXR+fWXT0xUhB 7rgg== X-Gm-Message-State: APf1xPCS9Ra/izYkyNzviRfKGTYTt3thI6LRJ7wiRTZ486sdhj9ABsk6 91PlnAD+DTZUztY8JWpTeQ49ag== X-Google-Smtp-Source: AH8x227lHuDYVjOW7IZFu7TC9BWaGhsVTVunGNyaaFakSuDE/S4saIDpJyIDYrXw+sjm4yuWYFrYWQ== X-Received: by 10.80.151.106 with SMTP id d39mr2290306edb.79.1518530779178; Tue, 13 Feb 2018 06:06:19 -0800 (PST) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id k11sm6658850eda.22.2018.02.13.06.06.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 06:06:18 -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?= , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH 2/8] lightnvm: show generic geometry in sysfs Date: Tue, 13 Feb 2018 15:06:02 +0100 Message-Id: <1518530768-20956-3-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518530768-20956-1-git-send-email-javier@cnexlabs.com> References: <1518530768-20956-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 From: Javier González Apart from showing the geometry returned by the different identify commands, provide the generic geometry too, as this is the geometry that targets will use to describe the device. Signed-off-by: Javier González --- drivers/nvme/host/lightnvm.c | 146 ++++++++++++++++++++++++++++--------------- 1 file changed, 97 insertions(+), 49 deletions(-) diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index 97739e668602..7bc75182c723 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -944,8 +944,27 @@ static ssize_t nvm_dev_attr_show(struct device *dev, 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, "clba") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.clba); + } else if (strcmp(attr->name, "csecs") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.csecs); + } else if (strcmp(attr->name, "sos") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.sos); + } else if (strcmp(attr->name, "ws_min") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.ws_min); + } else if (strcmp(attr->name, "ws_opt") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.ws_opt); + } else if (strcmp(attr->name, "maxoc") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.maxoc); + } else if (strcmp(attr->name, "maxocpu") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.maxocpu); + } else if (strcmp(attr->name, "mw_cunits") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.mw_cunits); + } else if (strcmp(attr->name, "media_capabilities") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.mccap); + } else if (strcmp(attr->name, "max_phys_secs") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", + ndev->ops->max_phys_sect); } else if (strcmp(attr->name, "read_typ") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.trdt); } else if (strcmp(attr->name, "read_max") == 0) { @@ -984,19 +1003,8 @@ static ssize_t nvm_dev_attr_show_12(struct device *dev, attr = &dattr->attr; - if (strcmp(attr->name, "vendor_opcode") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.vmnt); - } else if (strcmp(attr->name, "device_mode") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.dom); - /* kept for compatibility */ - } else if (strcmp(attr->name, "media_manager") == 0) { - return scnprintf(page, PAGE_SIZE, "%s\n", "gennvm"); - } else if (strcmp(attr->name, "ppa_format") == 0) { + if (strcmp(attr->name, "ppa_format") == 0) { return nvm_dev_attr_show_ppaf((void *)&dev_geo->c.addrf, page); - } else if (strcmp(attr->name, "media_type") == 0) { /* u8 */ - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.mtype); - } else if (strcmp(attr->name, "flash_media_type") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.fmtype); } else if (strcmp(attr->name, "num_channels") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->num_ch); } else if (strcmp(attr->name, "num_luns") == 0) { @@ -1011,8 +1019,6 @@ static ssize_t nvm_dev_attr_show_12(struct device *dev, return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.fpg_sz); } else if (strcmp(attr->name, "hw_sector_size") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.csecs); - } else if (strcmp(attr->name, "oob_sector_size") == 0) {/* u32 */ - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.sos); } else if (strcmp(attr->name, "prog_typ") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.tprt); } else if (strcmp(attr->name, "prog_max") == 0) { @@ -1021,13 +1027,21 @@ static ssize_t nvm_dev_attr_show_12(struct device *dev, return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.tbet); } else if (strcmp(attr->name, "erase_max") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.tbem); + } else if (strcmp(attr->name, "vendor_opcode") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.vmnt); + } else if (strcmp(attr->name, "device_mode") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.dom); + /* kept for compatibility */ + } else if (strcmp(attr->name, "media_manager") == 0) { + return scnprintf(page, PAGE_SIZE, "%s\n", "gennvm"); + } else if (strcmp(attr->name, "capabilities") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.cap); + } else if (strcmp(attr->name, "media_type") == 0) { /* u8 */ + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.mtype); + } else if (strcmp(attr->name, "flash_media_type") == 0) { + return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.fmtype); } else if (strcmp(attr->name, "multiplane_modes") == 0) { return scnprintf(page, PAGE_SIZE, "0x%08x\n", dev_geo->c.mpos); - } else if (strcmp(attr->name, "media_capabilities") == 0) { - return scnprintf(page, PAGE_SIZE, "0x%08x\n", dev_geo->c.mccap); - } else if (strcmp(attr->name, "max_phys_secs") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", - ndev->ops->max_phys_sect); } else { return scnprintf(page, PAGE_SIZE, "Unhandled attr(%s) in `nvm_dev_attr_show_12`\n", @@ -1035,6 +1049,17 @@ static ssize_t nvm_dev_attr_show_12(struct device *dev, } } +static ssize_t nvm_dev_attr_show_lbaf(struct nvm_addr_format *lbaf, + char *page) +{ + return scnprintf(page, PAGE_SIZE, + "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", + lbaf->ch_offset, lbaf->ch_len, + lbaf->lun_offset, lbaf->lun_len, + lbaf->chk_offset, lbaf->chk_len, + lbaf->sec_offset, lbaf->sec_len); +} + static ssize_t nvm_dev_attr_show_20(struct device *dev, struct device_attribute *dattr, char *page) { @@ -1048,20 +1073,14 @@ static ssize_t nvm_dev_attr_show_20(struct device *dev, attr = &dattr->attr; - if (strcmp(attr->name, "groups") == 0) { + if (strcmp(attr->name, "lba_format") == 0) { + return nvm_dev_attr_show_lbaf((void *)&dev_geo->c.addrf, page); + } else if (strcmp(attr->name, "groups") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->num_ch); } else if (strcmp(attr->name, "punits") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->num_lun); } else if (strcmp(attr->name, "chunks") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.num_chk); - } else if (strcmp(attr->name, "clba") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.clba); - } else if (strcmp(attr->name, "ws_min") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.ws_min); - } else if (strcmp(attr->name, "ws_opt") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.ws_opt); - } else if (strcmp(attr->name, "mw_cunits") == 0) { - return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.mw_cunits); } else if (strcmp(attr->name, "write_typ") == 0) { return scnprintf(page, PAGE_SIZE, "%u\n", dev_geo->c.tprt); } else if (strcmp(attr->name, "write_max") == 0) { @@ -1086,7 +1105,19 @@ static ssize_t nvm_dev_attr_show_20(struct device *dev, /* general attributes */ static NVM_DEV_ATTR_RO(version); -static NVM_DEV_ATTR_RO(capabilities); + +static NVM_DEV_ATTR_RO(ws_min); +static NVM_DEV_ATTR_RO(ws_opt); +static NVM_DEV_ATTR_RO(mw_cunits); +static NVM_DEV_ATTR_RO(maxoc); +static NVM_DEV_ATTR_RO(maxocpu); + +static NVM_DEV_ATTR_RO(media_capabilities); +static NVM_DEV_ATTR_RO(max_phys_secs); + +static NVM_DEV_ATTR_RO(clba); +static NVM_DEV_ATTR_RO(csecs); +static NVM_DEV_ATTR_RO(sos); static NVM_DEV_ATTR_RO(read_typ); static NVM_DEV_ATTR_RO(read_max); @@ -1105,42 +1136,53 @@ static NVM_DEV_ATTR_12_RO(num_blocks); static NVM_DEV_ATTR_12_RO(num_pages); static NVM_DEV_ATTR_12_RO(page_size); static NVM_DEV_ATTR_12_RO(hw_sector_size); -static NVM_DEV_ATTR_12_RO(oob_sector_size); static NVM_DEV_ATTR_12_RO(prog_typ); static NVM_DEV_ATTR_12_RO(prog_max); static NVM_DEV_ATTR_12_RO(erase_typ); static NVM_DEV_ATTR_12_RO(erase_max); static NVM_DEV_ATTR_12_RO(multiplane_modes); -static NVM_DEV_ATTR_12_RO(media_capabilities); -static NVM_DEV_ATTR_12_RO(max_phys_secs); +static NVM_DEV_ATTR_12_RO(capabilities); static struct attribute *nvm_dev_attrs_12[] = { &dev_attr_version.attr, - &dev_attr_capabilities.attr, - - &dev_attr_vendor_opcode.attr, - &dev_attr_device_mode.attr, - &dev_attr_media_manager.attr, &dev_attr_ppa_format.attr, - &dev_attr_media_type.attr, - &dev_attr_flash_media_type.attr, + &dev_attr_num_channels.attr, &dev_attr_num_luns.attr, &dev_attr_num_planes.attr, &dev_attr_num_blocks.attr, &dev_attr_num_pages.attr, &dev_attr_page_size.attr, + &dev_attr_hw_sector_size.attr, - &dev_attr_oob_sector_size.attr, + + &dev_attr_clba.attr, + &dev_attr_csecs.attr, + &dev_attr_sos.attr, + + &dev_attr_ws_min.attr, + &dev_attr_ws_opt.attr, + &dev_attr_maxoc.attr, + &dev_attr_maxocpu.attr, + &dev_attr_mw_cunits.attr, + + &dev_attr_media_capabilities.attr, + &dev_attr_max_phys_secs.attr, + &dev_attr_read_typ.attr, &dev_attr_read_max.attr, &dev_attr_prog_typ.attr, &dev_attr_prog_max.attr, &dev_attr_erase_typ.attr, &dev_attr_erase_max.attr, + + &dev_attr_vendor_opcode.attr, + &dev_attr_device_mode.attr, + &dev_attr_media_manager.attr, + &dev_attr_capabilities.attr, + &dev_attr_media_type.attr, + &dev_attr_flash_media_type.attr, &dev_attr_multiplane_modes.attr, - &dev_attr_media_capabilities.attr, - &dev_attr_max_phys_secs.attr, NULL, }; @@ -1152,12 +1194,9 @@ static const struct attribute_group nvm_dev_attr_group_12 = { /* 2.0 values */ static NVM_DEV_ATTR_20_RO(groups); +static NVM_DEV_ATTR_20_RO(lba_format); static NVM_DEV_ATTR_20_RO(punits); static NVM_DEV_ATTR_20_RO(chunks); -static NVM_DEV_ATTR_20_RO(clba); -static NVM_DEV_ATTR_20_RO(ws_min); -static NVM_DEV_ATTR_20_RO(ws_opt); -static NVM_DEV_ATTR_20_RO(mw_cunits); static NVM_DEV_ATTR_20_RO(write_typ); static NVM_DEV_ATTR_20_RO(write_max); static NVM_DEV_ATTR_20_RO(reset_typ); @@ -1165,16 +1204,25 @@ static NVM_DEV_ATTR_20_RO(reset_max); static struct attribute *nvm_dev_attrs_20[] = { &dev_attr_version.attr, - &dev_attr_capabilities.attr, + &dev_attr_lba_format.attr, &dev_attr_groups.attr, &dev_attr_punits.attr, &dev_attr_chunks.attr, + &dev_attr_clba.attr, + &dev_attr_csecs.attr, + &dev_attr_sos.attr, + &dev_attr_ws_min.attr, &dev_attr_ws_opt.attr, + &dev_attr_maxoc.attr, + &dev_attr_maxocpu.attr, &dev_attr_mw_cunits.attr, + &dev_attr_media_capabilities.attr, + &dev_attr_max_phys_secs.attr, + &dev_attr_read_typ.attr, &dev_attr_read_max.attr, &dev_attr_write_typ.attr,