From patchwork Fri Aug 3 08:54:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10554781 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 714E115A6 for ; Fri, 3 Aug 2018 08:55:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EFE92C24C for ; Fri, 3 Aug 2018 08:55:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5321B2C252; Fri, 3 Aug 2018 08:55:07 +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 4E0BF2C251 for ; Fri, 3 Aug 2018 08:55:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727866AbeHCKuX (ORCPT ); Fri, 3 Aug 2018 06:50:23 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:43468 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728525AbeHCKuW (ORCPT ); Fri, 3 Aug 2018 06:50:22 -0400 Received: by mail-lf1-f68.google.com with SMTP id f135-v6so3507355lfg.10 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=OtmI9ZF7KDDDfknrDKxdnptad3aarGTlWo+y11w+cHSQuwLwXi8uY5pTk1vAoNQg17 EX44x8jYYpI31fRzMm6HLDN6gp2w+YfW0m0XAUFg2Z4P79hPzL0Bj2fvuAg7G7+ZJI4t 0yjpIYuTDFZuR13f2Qxeeag/RzI5sO8L4qWBnNsbOL8gtDUF8CGKXQaWM5USrAE2Ja3d D1vLA+LQ3QMSZ8J1EgKyzJmH22VJnoEZU23RdeLvfbBDJw361StZMCxmfMMhKa4d7fhe aFmhvR2E+cc942KEjRxuGaL5WjA3/kqaXnr/uuDPERV1PNa7Tehi3zOzNtvcQfwAPKj+ JM/w== X-Gm-Message-State: AOUpUlHL1JTW7KCDTPAQsAdkh5nAn8yEIJveAiLqLjcaMw27FEd7Mayv +2Z6TD/i6Lz3N9Dsw4cG7MpIvg== X-Google-Smtp-Source: AAOMgpdF5LGp/rHQQshnviHojTc+NyeNnNSnWi91VBkjqH3+g14UkXj6J1FEjQIVkJCFTxEtdYoQsQ== 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_Bj=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?Mat?= =?utf-8?q?ias_Bj=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 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 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;