From patchwork Tue Jan 12 06:49:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 8014071 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BFF62BEEE5 for ; Tue, 12 Jan 2016 06:55:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC15F20379 for ; Tue, 12 Jan 2016 06:55:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 14A5C201F4 for ; Tue, 12 Jan 2016 06:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932646AbcALGv2 (ORCPT ); Tue, 12 Jan 2016 01:51:28 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:38813 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761405AbcALGuZ (ORCPT ); Tue, 12 Jan 2016 01:50:25 -0500 Received: by mail-wm0-f50.google.com with SMTP id b14so303602643wmb.1 for ; Mon, 11 Jan 2016 22:50:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=99bC2mdkCIajOpN7pyaSHqlLz3cHBZblb/Q9RSrSSx4=; b=Xqz2mXMmm8UmbsndVvmgFhE0L5e4VB9IYM+WWzG3nZnbVqy1lWSEmsXqyKUYEUO2Pg 2psiQBs1cIYuhltKhVlbkNrI3EIcOAntaDlLReatdBkxhfTkzgH+Z3t63Rx02jFffqQS o8EYofPF42ndIfs4gxgOZmFAk2PJ0LytmzJpk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=99bC2mdkCIajOpN7pyaSHqlLz3cHBZblb/Q9RSrSSx4=; b=ZgR2ZNrwIueLZBSl+NQt5NakjZr+ojs+sy3Fc0YNjg9gciwld5YldYkY0KTSwyIMal eiQJVSlRfQoSxg7jMEPBRtvF7zjHD9W3MUF2BM6CxoI3Fe1is/OYw/lwQlRAlPzdA6M1 LFxk98f/sdYuZoJGoq811Vto0V+VBhv5+cQgCeBdvfbFJoPQGHkpLpMKowhnYrWuZiJO hM1uwzD8kvuSb241wmaEPst0iQly84mt8Y5NkxmOQ/P2IzPimIUJ4sBmUWyf++MH6iKt jCVDCcjoBCgHc77AHDlb2zLOGgQRApc/pgzK/9h/6DBH36panglLFcIcB0sO5JEUXMGo S89g== X-Gm-Message-State: ALoCoQmTi57jGkcoREtSqS4CSeY38XrJusl/7ooFgRYJmrHC84IWeTXGDbIxYuKuOhUD/vQKu/xEP4sgU2LplFRQqy7Ik6hrZg== X-Received: by 10.28.224.212 with SMTP id x203mr18263467wmg.29.1452581424870; Mon, 11 Jan 2016 22:50:24 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id yz5sm70776886wjc.36.2016.01.11.22.50.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Jan 2016 22:50:24 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 24/25] lightnvm: use system block for mm initialization Date: Tue, 12 Jan 2016 07:49:38 +0100 Message-Id: <1452581379-18162-25-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452581379-18162-1-git-send-email-m@bjorling.me> References: <1452581379-18162-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use system block information to register the appropriate media manager. This enables the LightNVM subsystem to instantiate a media manager selected by the user, instead of relying on automatic detection by each media manager loaded in the kernel. A device must now be initialized before it can proceed to initialize its media manager. Upon initialization, the configured media manager is automatically initialized as well. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 25 +++++++++++++++++++++++-- include/linux/lightnvm.h | 3 +++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index ee08fac..9e5712d 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -106,6 +106,9 @@ struct nvmm_type *nvm_init_mgr(struct nvm_dev *dev) lockdep_assert_held(&nvm_lock); list_for_each_entry(mt, &nvm_mgrs, list) { + if (strncmp(dev->sb.mmtype, mt->name, NVM_MMTYPE_LEN)) + continue; + ret = mt->register_mgr(dev); if (ret < 0) { pr_err("nvm: media mgr failed to init (%d) on dev %s\n", @@ -569,9 +572,16 @@ int nvm_register(struct request_queue *q, char *disk_name, } } + ret = nvm_get_sysblock(dev, &dev->sb); + if (!ret) + pr_err("nvm: device not initialized.\n"); + else if (ret < 0) + pr_err("nvm: err (%d) on device initialization\n", ret); + /* register device with a supported media manager */ down_write(&nvm_lock); - dev->mt = nvm_init_mgr(dev); + if (ret > 0) + dev->mt = nvm_init_mgr(dev); list_add(&dev->devices, &nvm_devices); up_write(&nvm_lock); @@ -1030,6 +1040,7 @@ static long __nvm_ioctl_dev_init(struct nvm_ioctl_dev_init *init) { struct nvm_dev *dev; struct nvm_sb_info info; + int ret; down_write(&nvm_lock); dev = nvm_find_nvm_dev(init->dev); @@ -1044,7 +1055,17 @@ static long __nvm_ioctl_dev_init(struct nvm_ioctl_dev_init *init) strncpy(info.mmtype, init->mmtype, NVM_MMTYPE_LEN); info.fs_ppa.ppa = -1; - return nvm_init_sysblock(dev, &info); + ret = nvm_init_sysblock(dev, &info); + if (ret) + return ret; + + memcpy(&dev->sb, &info, sizeof(struct nvm_sb_info)); + + down_write(&nvm_lock); + dev->mt = nvm_init_mgr(dev); + up_write(&nvm_lock); + + return 0; } static long nvm_ioctl_dev_init(struct file *file, void __user *arg) diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 7ad22d3..02f36bd 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -301,6 +301,9 @@ struct nvm_dev { struct nvmm_type *mt; void *mp; + /* System blocks */ + struct nvm_sb_info sb; + /* Device information */ int nr_chnls; int nr_planes;