From patchwork Thu Feb 15 13:12:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10221181 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 3C4266055C for ; Thu, 15 Feb 2018 13:12:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E28D286CB for ; Thu, 15 Feb 2018 13:12:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22D092882C; Thu, 15 Feb 2018 13:12:36 +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 AABE2286CB for ; Thu, 15 Feb 2018 13:12:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031968AbeBONMc (ORCPT ); Thu, 15 Feb 2018 08:12:32 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:38910 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032208AbeBONM1 (ORCPT ); Thu, 15 Feb 2018 08:12:27 -0500 Received: by mail-lf0-f65.google.com with SMTP id g72so33969535lfg.5 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=LsBjcMLHQU+zFDh4QzvBOt3Ykju26AMK97BwQSj4Vo0TrIud0+7yLwuiL372phfJu6 jck5wziueXfC64erbSEtSIc8/Jb8hm5RVKnfO9RVn8cjbDjlsxVi9bMoHkyGChfJYQuK rvZ2X49bsJlYPDExkM/Q8ktuYA0GGo8B25YhQrHz3zDIoqH5/eUTQ+yLTXxeWeOiOvJa Bg0PppLHqXlr6ymr2GAj3Q60XxV9GcieTlrdivCvu5y+6MB9PUWxREegVGCKkR7vREg4 KFZUTEJai7cEbSmO9vwfUZdTn/HX5zoMDAD91NW01Q4OIIUurlxJPuIUJ9b4RWoNPF01 VMpQ== X-Gm-Message-State: APf1xPDKC2hB/lvtdIFc+rH8NM8w3pyjsCUUlYx+dMlrXyFVLUDg8lCD hMn+wdr9SQbp3AbS9yI4ac/0OJzC X-Google-Smtp-Source: AH8x226g9FlM0rew8nlChMowJpilZmsOtaXIGX2CWdTjqFfJneJ/GSQt2zGnCb0X6Ojcc38uBQbL/g== 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 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 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) {