From patchwork Fri Feb 9 09:27:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10208525 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 0F564605F3 for ; Fri, 9 Feb 2018 09:28:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A3B2297BA for ; Fri, 9 Feb 2018 09:28:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EA5F2981D; Fri, 9 Feb 2018 09:28:31 +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 77B06297BA for ; Fri, 9 Feb 2018 09:28:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751144AbeBIJ2L (ORCPT ); Fri, 9 Feb 2018 04:28:11 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:44013 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752664AbeBIJ1s (ORCPT ); Fri, 9 Feb 2018 04:27:48 -0500 Received: by mail-lf0-f68.google.com with SMTP id a25so1025942lfg.10 for ; Fri, 09 Feb 2018 01:27:48 -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=U97oILC8DTeweFvsB4C8Vow5dEPcux4uoCzJxFBRrwo=; b=JrFuQWDtOvHgRTIlKcRBNQvl9o8PCctijJV5OmW6E2t314DE98ynsYGQeQHhjnFRoG wupVU1yL2ggVceRDyX+B/nEXkNEzhs5U8XHfYbDJ33i8Eqm5Svlu1KCSUc+EE7bDjIBy STafQRJsx23Ef4diwXRuIIvuwSCe5sQSV0KXKA45P6rGcV/qH2XnEhBzK69vBgIe5yUw 7eKdSYm1WP/2LfcE6usojnNj4kCrHdU3aoKvw6oJCpz5dXPVTjUUfCfBlUzeKBXu/p8O c9QNlu9OO/iQdrLaJpOizpqZkqzkob7le/aKQyKIMYGD88zPmwwSi66gjDRhUgZt7hWt m7YQ== 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=U97oILC8DTeweFvsB4C8Vow5dEPcux4uoCzJxFBRrwo=; b=QN16S+JpC1hHFQdqw+us7hjQxg2C080h4iiyZwSeuIa/x2HAqNif5K2cAbTFrXD41q fRAn9VbrNh8l+WSFg6x/NuIlWSIJK3TPFN6A1v5ish/D2KhXMuzYy8qhA1tBRV1chj4S RWWO40ai+COvlhviRV1Qq2j8BtuOoNjYRGbeXIELqlQEKp+8ej6REZTFsonBJtEb+2yE Yf211vkCuyYtjaT+B3kuepiXSlUZXFkceLnLftFdnu71wbLTOZ5ecmrAuhadmCWDP0Nc e78DlHZz6gqkX4stWQXSiUOYdXRlyUZG1PvDt7lfhs5/btr7IZOmGeZVV3Cn58O+5vRP DOeA== X-Gm-Message-State: APf1xPB6aLFyZOb7HpYJYVCM7BCcOrloST8wQZKG0Ghu4hfLkVHTb1hx oN/+Zl2W5YYXo3J7pIMXGYOjxKC3 X-Google-Smtp-Source: AH8x227K7g6Cgnn150xN7JFuei6ej0+vNW/UhGSrGFLVFHzdnEVteQNxGj+qUdbq4/bot6yZpRGWmw== X-Received: by 10.46.20.8 with SMTP id u8mr1551261ljd.12.1518168467138; Fri, 09 Feb 2018 01:27:47 -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 t23sm343963ljd.67.2018.02.09.01.27.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 01:27:46 -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 4/4] nvme: lightnvm: add late setup of block size and metadata Date: Fri, 9 Feb 2018 10:27:19 +0100 Message-Id: <20180209092719.10679-5-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180209092719.10679-1-mb@lightnvm.io> References: <20180209092719.10679-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/nvme/host/core.c | 2 ++ drivers/nvme/host/lightnvm.c | 8 ++++++++ drivers/nvme/host/nvme.h | 2 ++ 3 files changed, 12 insertions(+) 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 8b243af8a949..a19e85f0cbae 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -814,6 +814,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) {