From patchwork Tue Oct 9 11:11:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10632255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26DCD15E8 for ; Tue, 9 Oct 2018 11:13:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 071D222B26 for ; Tue, 9 Oct 2018 11:13:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFE1725EF7; Tue, 9 Oct 2018 11:13:29 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 8D97122B26 for ; Tue, 9 Oct 2018 11:13:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726925AbeJIS3y (ORCPT ); Tue, 9 Oct 2018 14:29:54 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39999 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726882AbeJIS3y (ORCPT ); Tue, 9 Oct 2018 14:29:54 -0400 Received: by mail-pf1-f193.google.com with SMTP id s5-v6so672137pfj.7 for ; Tue, 09 Oct 2018 04:13:28 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=QBiCuSqsQ6+WNR8FSQ49WJsMpNMaJzrhxrzA2Q/GNME=; b=BlG1+qpffgM7kMthTojQIdEQPtFLTeu0V2EPszpeVWWFUvj3VUfV1SYOSM842Z588o a9qbdxea1eGGy5/nfYnmPj6oGwVV7iMPj3fWqO5NoQEtyhvu/C62uOoDgJ7b+chcem3b U7I3wQS1mYvyx3d2X6dBJL44Ya2b9jWFpygzh7hiotfXsStZP1QZoqj3FHsn+89CQO7b 8D1TESN3NALLMA2/YLggPdt4m32M/8pUbFp5YQS0FoyKZPkldweTeGmXAB1wNF6hfWx5 9EFXdaO2jtwuwPFoJyF9za8jLUDAMvceUI5oVFUZaRTkROSbNt9SGUJ8eAnddtuB0Rze morA== 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=QBiCuSqsQ6+WNR8FSQ49WJsMpNMaJzrhxrzA2Q/GNME=; b=eos6MK+PYsoqTkJ3hJPKt1FdkA+tf5hQhTkcJA6CUiL8xtPAzyN2LycgW/RM8X5IH4 aHC09wdqBu9WRPFlC09QUERHS8ecfKfWgWsIS22TIhuBUF7SgsrHiGHRGs76IVsu4dcR v9Uf1q8lKWasUZMGrnm5cGrXTpLfX3r5p80d2burcVWT8JOusu6SbLIkBxocRK1K3VoX QEWe0S7f/CBy4RogUL6vy0Keof/rDCUwg8XrGXC11/DY80xQrPbbyTl6hGOF1jgUCrQ1 n3I0mITuK8AoMn83mGM+6fHMbgz8re3nDxKrvoadijtCqBLPP8Dkn0zMgMFBXz8DFl/y up0w== X-Gm-Message-State: ABuFfogozOycm61bTcCXiJZgFjmOFQPojAOy5v2KA4zlLcWcKxwMXYbe XJaCZ/oT2wJe+D6MZjNDdyALENTl2L+BCQ== X-Google-Smtp-Source: ACcGV600mZpP5F098LsD2ceh3xX9/sZeD7IOkgKVb5Y3F9S7UxFa2L8eBfoCJNRc2+VYUMfGP41ZfQ== X-Received: by 2002:a62:3047:: with SMTP id w68-v6mr5073292pfw.19.1539083607605; Tue, 09 Oct 2018 04:13:27 -0700 (PDT) Received: from skyninja.hgst.com (rap-us.hgst.com. [199.255.44.250]) by smtp.gmail.com with ESMTPSA id p1-v6sm25342380pff.128.2018.10.09.04.13.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 04:13:26 -0700 (PDT) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Mat?= =?utf-8?q?ias_Bj=C3=B8rling?= Subject: [GIT PULL 04/45] lightnvm: move device L2P detection to core Date: Tue, 9 Oct 2018 13:11:34 +0200 Message-Id: <20181009111215.7653-5-mb@lightnvm.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181009111215.7653-1-mb@lightnvm.io> References: <20181009111215.7653-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 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 537e98f2b24a..039f62d05e84 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -1210,13 +1210,6 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, return ERR_PTR(-EINVAL); } - 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;