From patchwork Fri Jan 8 18:14:36 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: 7988601 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 055579F38D for ; Fri, 8 Jan 2016 18:16:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 32A8E201CE for ; Fri, 8 Jan 2016 18:16:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 47CFC201ED for ; Fri, 8 Jan 2016 18:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754394AbcAHSO5 (ORCPT ); Fri, 8 Jan 2016 13:14:57 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34551 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932609AbcAHSOx (ORCPT ); Fri, 8 Jan 2016 13:14:53 -0500 Received: by mail-wm0-f68.google.com with SMTP id b14so17109405wmb.1 for ; Fri, 08 Jan 2016 10:14:53 -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=WWeI9v86kAdZL+YNBTf/pbEVn/a3grGasX/aMRtQwAMKO5/I+6E0naHNVAYfHHjuUD XKnGTA+/bHYXs5i9gKUxXYZvmcMcPHbaF4E9RT/ZnDEaC3OeC8RpOGXAfHqd7p+LucA+ pkuXETrbqxzgoSlKgUtMGh3/ZI5Xymaeb9rPE= 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=Zj4F59Inmiy3TTVM8TpBBcNqnioyVDE1U0c8mNrFzwKowxZbw1QG8HENcOWtKipDtA pKuXJWP432zkloxTVzhY68LY0CESc5pbPcRroAfx1qJxdfZsXbNB7VZt589qDeuzBSgA fcQ7RaeqhTDeUijg0xhJIjTeZ6TBKNG1GvZvqyHDbF1oRJYSQIVeIaefBQvD/Um9qSr2 dewC7dWENtHrIcLSUOpZEXS1FlGuhWFrqCMQYOb5qdF8NbJF2KGlkVxzXukNvJIYRpr9 E7U1KWPwlhsu01CJj4QRBlCZxQODT94lf5M3O19WPOVtAVD3GwtPlvUiao74MtECY0+z 43Lg== X-Gm-Message-State: ALoCoQlPqS8KtteV2iej7uIxdOoB86DQD3DKQCy4S27QdbKJ5+HstKV0n+TORtKFnvweUJAUX69pMhOI+fjyDF9OvXpfcUk5Uw== X-Received: by 10.194.110.65 with SMTP id hy1mr16235412wjb.104.1452276892561; Fri, 08 Jan 2016 10:14:52 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id t9sm52713200wjf.33.2016.01.08.10.14.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jan 2016 10:14:51 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 6/7] lightnvm: use system block for mm initialization Date: Fri, 8 Jan 2016 19:14:36 +0100 Message-Id: <1452276877-390-6-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452276877-390-1-git-send-email-m@bjorling.me> References: <1452276877-390-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;