Received: by 10.223.185.116 with SMTP id b49csp2008517wrg; Thu, 15 Feb 2018 05:13:58 -0800 (PST) X-Google-Smtp-Source: AH8x224Igr7Qd8HOZEsergcEUv/2+o9xdtG17cNQu/09sBPTGJwti2Tx4jTyJ7hy0wNtoP3qjHvQ X-Received: by 10.98.18.65 with SMTP id a62mr2639404pfj.115.1518700438495; Thu, 15 Feb 2018 05:13:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518700438; cv=none; d=google.com; s=arc-20160816; b=HV2ZvRUQZ4Y4+/lTN6nosM+9pCw4ZNrXnP9YNBPhgPOHONI8p/Hg4ZUsx/FP4h3ZBP Owx8+8b15c8ZwO/FRt0V0S9oGmOlokhAfXalDlcQyDWHVJOkYMecRePtK7ll5Ixjn/he wPSEN//BvUegCCr5RX+CUZKBOltardRwexMqdnUoNUFpu5XMuM3tJ81hl50sWc3i8YYJ GjK8MbN3gF96CwgEdkcAbXgB5h/O2xeiNPMOGaSicXeyJgecd+Nh/DYiVU3BgnG1FQtU IkdejH+fZV3Gw5DJww3ccYmJu9ShkS31wxYDkz/lAAu267r4vc4y8YhL8UOwbQUpwK6b hUHQ== 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=RFeYRo0is+JkZCldZYfagF459cRJjWvX0FjjgvTbis8=; b=bg8ZVp3ZYj20sZxq3HV+EOkLGeI+XQxyLCuODBcO8pP0S0dQGAVY5FgGu4xfxFB23z QdYYGmDYZCkGA8oKYOT1FDsqmw0vWbEnnmiX2ZAchibY8oryG6KrxaoWq5xzUZC36+4g HiWuipyFH6MyHQ8i6yGouQBHESCBrQJylorIxCRkbP+TEEO1IKtW1zIUnReESDMDK412 jueh71jeBMI0uwodNpwQeG2jTDhk1OIVfAM8hJIXbyqdSBGq4y6aDZvBxrE4RbLJnGau zYVblSlhu8me4sDGyCaOz50kPrcflqVFyRsajOHkwHOm8ft6TbFZQMly/8me2QgvyA8T D+aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=iK7JBKBD; 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 p9-v6si1550557plk.6.2018.02.15.05.13.43; Thu, 15 Feb 2018 05:13:58 -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=iK7JBKBD; 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 S1032765AbeBONMk (ORCPT + 99 others); Thu, 15 Feb 2018 08:12:40 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:39729 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032202AbeBONM1 (ORCPT ); Thu, 15 Feb 2018 08:12:27 -0500 Received: by mail-lf0-f66.google.com with SMTP id h78so26790965lfg.6 for ; Thu, 15 Feb 2018 05:12:26 -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=RFeYRo0is+JkZCldZYfagF459cRJjWvX0FjjgvTbis8=; b=iK7JBKBDsI28IYNpNXotsJkXe3hhOQIikjBB3K2Wf096uj0u1Hs63G2N7Y3FzpEQTk T+S+wimmc/Hzu2vcjyqKPE/FMBMQ8bIKdJkbQcHH4paRizsFCXv9uh1w1Rv20bcmMH/x KKy+P8+8bEeyg8VkG9EOud9GgWQjJv7I2Rj5HWiUgZkyCaR1y3m7nEuL4ytFdSnGNjtB WCtok+1qW1reIFqa9MqsRL1+B5+GvuO0nplpXXpzH1sallvW7/q976aD37OeJX2v2qcZ uK3wuJnieqbkSRYvCsQoVmeZ+0GWeqpPhoPn35WxzO+Ra8KGw7wwHE4q6ZWCvbcfyC/T i5YA== 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=RFeYRo0is+JkZCldZYfagF459cRJjWvX0FjjgvTbis8=; b=KFbYu2Qo7QByaPdJnfwUBnuCILUuUOXCx8c2Wysh+zU9SJdB2a/v83GURBWBchd0JM cHr/0TVkI11F+gMAFYuKzGH1uPxyOkf4UFGlMVBQzML12QuyZYKhe2rpvV9/PDbddE8j 9dOhl/Z2+MFdvGnIRQtvs240da3jj2VmRxrg2nYQK6FOmEZZI+c5vaM5B0aFNGcmcrMW +MV0ZYFtU/hpXtX6n33ZEEXlZwM1bDrsTFkOQnMoMUNs4otw6risISdaezauZjADJPue Wo3p8UmXtQb5wRM0uyAOGM4WFOwqXz3rH0uCsoef125m6nHNYK38k37KIZ6hM2vBgPM6 szow== X-Gm-Message-State: APf1xPCRUdvUK1gOVYxjBrQUj05ggYQJ/ew8r6uFcb3cLg5C6TvOqXcR Dx4Pw78/HkSf9tIWRoZDf0wEEw== X-Received: by 10.25.233.154 with SMTP id j26mr1873218lfk.30.1518700345512; Thu, 15 Feb 2018 05:12:25 -0800 (PST) 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 s7sm449295lfg.13.2018.02.15.05.12.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Feb 2018 05:12:24 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, javier@cnexlabs.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH v2 6/6] nvme: lightnvm: add late setup of block size and metadata Date: Thu, 15 Feb 2018 14:12:00 +0100 Message-Id: <20180215131200.3354-7-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180215131200.3354-1-mb@lightnvm.io> References: <20180215131200.3354-1-mb@lightnvm.io> 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 The nvme driver sets up the size of the nvme namespace in two steps. First it initializes the device with standard logical block and metadata sizes, and then sets the correct logical block and metadata size. Due to the OCSSD 2.0 specification relies on the namespace to expose these sizes for correct initialization, let it be updated appropriately on the LightNVM side as well. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 3 --- drivers/nvme/host/core.c | 2 ++ drivers/nvme/host/lightnvm.c | 8 ++++++++ drivers/nvme/host/nvme.h | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 782f381e4d61..689c97b97775 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -864,8 +864,6 @@ static int nvm_core_init(struct nvm_dev *dev) geo->ws_seq = id->ws_seq; geo->ws_per_chk = id->ws_per_chk; geo->nr_chks = id->num_chk; - geo->sec_size = id->csecs; - geo->oob_size = id->sos; geo->mccap = id->mccap; geo->sec_per_chk = id->clba; @@ -893,7 +891,6 @@ static int nvm_core_init(struct nvm_dev *dev) if (ret) goto err_fmtype; - blk_queue_logical_block_size(dev->q, geo->sec_size); return 0; err_fmtype: kfree(dev->lun_map); diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f837d666cbd4..740ceb28067c 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1379,6 +1379,8 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id) if (ns->noiob) nvme_set_chunk_size(ns); nvme_update_disk_info(disk, ns, id); + if (ns->ndev) + nvme_nvm_update_nvm_info(ns); #ifdef CONFIG_NVME_MULTIPATH if (ns->head->disk) nvme_update_disk_info(ns->head->disk, ns, id); diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index e38d835b15b5..839c0b96466a 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -812,6 +812,14 @@ int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg) } } +void nvme_nvm_update_nvm_info(struct nvme_ns *ns) +{ + struct nvm_dev *ndev = ns->ndev; + + ndev->identity.csecs = ndev->geo.sec_size = 1 << ns->lba_shift; + ndev->identity.sos = ndev->geo.oob_size = ns->ms; +} + int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node) { struct request_queue *q = ns->queue; diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index ea1aa5283e8e..1ca08f4993ba 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -451,12 +451,14 @@ static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns) #endif /* CONFIG_NVME_MULTIPATH */ #ifdef CONFIG_NVM +void nvme_nvm_update_nvm_info(struct nvme_ns *ns); int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node); void nvme_nvm_unregister(struct nvme_ns *ns); int nvme_nvm_register_sysfs(struct nvme_ns *ns); void nvme_nvm_unregister_sysfs(struct nvme_ns *ns); int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg); #else +static inline void nvme_nvm_update_nvm_info(struct nvme_ns *ns) {}; static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node) { -- 2.11.0