Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp200700imm; Fri, 3 Aug 2018 01:56:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdCXF7Uvm/CY5GQfT02kjxe7tordYxvjORc9AX/mSyytiUg7PWuLrwhVqF+oDVKoc3egECg X-Received: by 2002:a63:ca09:: with SMTP id n9-v6mr2749392pgi.287.1533286581491; Fri, 03 Aug 2018 01:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533286581; cv=none; d=google.com; s=arc-20160816; b=FVSAcZhqEM7n+fXWV0U+tPuU/+N3KanAIqaaktcOl8/Qo4n8ciyJV70QD1ILeIqDsc 7ajGDtS+ZELdZFn/0cKkcjJa8vKUiDy1zlzuOuRF59X07Tc+Vr2oaoBDCXvdtLoNK2mR NasJbZLNcr/pEIPvVxvxB8QPsmoZuDPipHfsZkvbuj8oGYWDtE76eGLaXsTW+bVZ4I5o EC+eOZC8tOOYuuNjx4YKbAuhpeeaFm77/pCkqWfis9DFvd86xVILFo0RfL/3Nr12huoR z5FgxUg8rUb8wkulbOD2gJd0oHhKmvITGAF8AUPBeKJuiEzWkPSNJeRpNfZ8uPbMYp1v Jynw== 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 :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=OhWG67qTTauUONHtvYIKHt5AVpM/AdhgRLjS8xMeBnY=; b=TteCD/7ywSbivco5jsBkfDSWHmM6/XoHtKi2z+SLiUASeJSb3inNDIFZCc9GbkC4+9 f4gI0fgV51UfT0fK7F1r2snId3zk1s/6iBR9/cdvoowRTKp5KfBzHqBuHrvFgwU7npAY ivOkpSrnXnUh82ToUmU5wRCZyIxVfON+afG5+xtYjIbEoYPhWlYFbsDCDgReVbzZfgry dhsRoPOiNah4pcTyCBSnjtIoaXXo6Yd7MQal8u2Jzz3LvWu+8U4M7aycMQNWoD0YKGnC bJNujMoHvQAnAXkGhpTByxca/XcTNA4mBbn8nxZpmXrfZ9QHi78Kxw06zjWTgMJeIlQ0 hBLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b="1XLrwi/u"; 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 b2-v6si3179579plr.382.2018.08.03.01.56.06; Fri, 03 Aug 2018 01:56:21 -0700 (PDT) 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="1XLrwi/u"; 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 S1732219AbeHCKuW (ORCPT + 99 others); Fri, 3 Aug 2018 06:50:22 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:44448 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727866AbeHCKuW (ORCPT ); Fri, 3 Aug 2018 06:50:22 -0400 Received: by mail-lf1-f68.google.com with SMTP id g6-v6so3502598lfb.11 for ; Fri, 03 Aug 2018 01:55:02 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=OhWG67qTTauUONHtvYIKHt5AVpM/AdhgRLjS8xMeBnY=; b=1XLrwi/uegYCGxVBMBiNLyGw92Z6t7NKrniTiqtVfdLM4feT2EaI5DSWS/1TTp1lxo hypHGgMPdEC0SjpvdhvuBE02yIiugm6lRrAciVwmKonM8BDVhGNA+eFsfWIg3i4i4niO 9eQG2kzKFw1A6+rRqCdpou6RAA4vJ3FZRarqf02LdCzzjQ+7NAz2ghEteUVn2QfUM377 CW5HW+Oh7v8vV3CnbnEasee7R/s59Mwex504AXFpk3FJp5KGu3qZPTgc6vOCGBpHuIh5 v0XiLva9QzQAm/7R+H2Zvi7WkYEvfn9Xlhv73fOc6v3YAjWHGZiO/s8UvY1Qw4PTtwiy iHRA== 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:mime-version :content-transfer-encoding; bh=OhWG67qTTauUONHtvYIKHt5AVpM/AdhgRLjS8xMeBnY=; b=I2OD+h/E/UDwGZ9vhYZjoyh1fz/JGbT8OPfCiOfITt69un0fHdeH7HK18aT647ZnKc Pdw7LnQ2VSz792qPGPQX/5QhbE3mOm7bEmv0CY+/gXeR47gASiK+U1u4OriYyTx8IZeY v7iLVuXWImpTytGakFib4PZWjf6oRK7pPy3gr/2XAZG7xAJFRdxD6JHC+bFWVVoAoR8M H1PVMNghX/qcsQ6tcd1Tr6cD8eqe1ZkOuoWx1VUKh+ti4k2CapsLTcTF2SLs613UgGLm ++O7n8q0ygVHywBTlmJdcHapU2ftmdgXsDcUBk9t4DVWpqERL9OmRWObH3/K6MHj4/dq 2zHQ== X-Gm-Message-State: AOUpUlHT4xHqJ2CpoiXqYgaMh73IUzZoKIilCn2KSfJjvUzH0N9dKQ1I zXsWNM4ISvFRodTWK3dDTiz8rQ== X-Received: by 2002:a19:988f:: with SMTP id a137-v6mr4322123lfe.128.1533286501229; Fri, 03 Aug 2018 01:55:01 -0700 (PDT) Received: from localhost.localdomain (95-166-82-66-cable.dk.customer.tdc.net. [95.166.82.66]) by smtp.gmail.com with ESMTPSA id a140-v6sm637345lfb.21.2018.08.03.01.54.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Aug 2018 01:55:00 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: igor.j.konopko@intel.com, marcin.dziegielewski@intel.com, javier@cnexlabs.com, hans.holmberg@cnexlabs.com, hlitz@ucsc.edu, youngtack.jin@circuitblvd.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH] lightnvm: move device L2P detection to core Date: Fri, 3 Aug 2018 10:54:49 +0200 Message-Id: <20180803085449.3436-1-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 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 A 1.2 device is able to manage the logical to physical mapping table internally or leave it to the host. A target only supports one of those approaches, and therefore must check on initialization. Move this check to core to avoid each target implement the check. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 5 +++++ drivers/lightnvm/pblk-init.c | 7 ------- include/linux/lightnvm.h | 6 ++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 68553c7ae937..964352720a03 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -355,6 +355,11 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) return -EINVAL; } + if ((tt->flags & NVM_TGT_F_HOST_L2P) != (dev->geo.dom & NVM_RSP_L2P)) { + pr_err("nvm: device is incompatible with target L2P type.\n"); + return -EINVAL; + } + if (nvm_target_exists(create->tgtname)) { pr_err("nvm: target name already exists (%s)\n", create->tgtname); diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index e9e2fedff387..cc8a59e3c240 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -1202,13 +1202,6 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, pblk->state = PBLK_STATE_RUNNING; pblk->gc.gc_enabled = 0; - if (geo->version == NVM_OCSSD_SPEC_12 && geo->dom & NVM_RSP_L2P) { - pblk_err(pblk, "host-side L2P table not supported. (%x)\n", - geo->dom); - kfree(pblk); - return ERR_PTR(-EINVAL); - } - spin_lock_init(&pblk->resubmit_lock); spin_lock_init(&pblk->trans_lock); spin_lock_init(&pblk->lock); diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 8acc2fe277d6..f4a84694e5e2 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -495,9 +495,15 @@ typedef void (nvm_tgt_exit_fn)(void *, bool); typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *); typedef void (nvm_tgt_sysfs_exit_fn)(struct gendisk *); +enum { + NVM_TGT_F_DEV_L2P = 0, + NVM_TGT_F_HOST_L2P = 1 << 0, +}; + struct nvm_tgt_type { const char *name; unsigned int version[3]; + int flags; /* target entry points */ nvm_tgt_make_rq_fn *make_rq; -- 2.11.0