From patchwork Mon Dec 14 13:17:06 2015 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: 7844511 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 5708D9F350 for ; Mon, 14 Dec 2015 13:18:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B4D3203AE for ; Mon, 14 Dec 2015 13:18:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E599203AB for ; Mon, 14 Dec 2015 13:18:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932517AbbLNNS2 (ORCPT ); Mon, 14 Dec 2015 08:18:28 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:36638 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932395AbbLNNRf (ORCPT ); Mon, 14 Dec 2015 08:17:35 -0500 Received: by mail-wm0-f50.google.com with SMTP id n186so117867359wmn.1 for ; Mon, 14 Dec 2015 05:17:34 -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=Z63StPxZDkkwDri7n4PsE3vhJuTZkUyA/sFAvC9yWJA=; b=CAXg2rdslQkUZ7RXUlfRaLGQxcXQXKYLrxn24xKNRLELC1lBzGcTT/9exU6UceYyXr o7IH/OgL0Hv5KeYRBXGCPWyFg9iZzTNJae9RpuUDuQ03sMYRFxz8daktkAW5bgGhb+Sh NGscy8zwZLHkarCv/h55uLE3/k6OxYRq/BJc4= 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=Z63StPxZDkkwDri7n4PsE3vhJuTZkUyA/sFAvC9yWJA=; b=EgChtnynqknrg9OXWYUXLZh1YW1jguGDAgqq3hHaKhw9VGsb4inWPC9903nWmAROoW 1Byxd5uch5Piasfeo33IiUlJHYt8xga8CIEMSKOOb7iIwCae6P6bD1R34qBknmM6grth uxw9pQsyXByHtofQ1Uk+xT2zC+iFcOv18xuWzIq8fJ8GJAtz/ZNejBKYyIjQdsbomLRC bWqQSfhG3cbvOi8DHjtmEnj5izj7aLpbCKLquGp22BduouKSW5PSzXuU3chE0nhH5AtU yeAMm3q7UbW7KQrJn+1yUGzqK3XQnQaDSzbpVB3hbWCbPC5qF8i96O+tk9c3zgin6DR7 avjw== X-Gm-Message-State: ALoCoQk/h0pgHbI9v6PHhW/K3qmoui9iswvCHOitf2xOpFUP6lWVqAdQMzt0A5Sn839o2o/12ZnF0jSfiJ61jkOXa5aqpMrpfQ== X-Received: by 10.194.116.97 with SMTP id jv1mr9619629wjb.38.1450099054030; Mon, 14 Dec 2015 05:17:34 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id u139sm16080298wmu.22.2015.12.14.05.17.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Dec 2015 05:17:33 -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 RFC 4/5] lightnvm: introduce nvm_submit_ppa Date: Mon, 14 Dec 2015 14:17:06 +0100 Message-Id: <1450099027-24745-5-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1450099027-24745-1-git-send-email-m@bjorling.me> References: <1450099027-24745-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,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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 Internal logic for both core and media managers, does not have a backing bio for issuing I/Os. Introduce nvm_submit_ppa to allow raw I/Os to be submitted to the underlying device driver. The function request the device, ppa, data buffer and its length and will submit the I/O synchronously to the device. The return value may therefore be used to detect any errors regarding the issued I/O. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 31 +++++++++++++++++++++++++++++++ include/linux/lightnvm.h | 1 + 2 files changed, 32 insertions(+) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 081b0f5..77a9907 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -288,6 +288,37 @@ int nvm_erase_ppa(struct nvm_dev *dev, struct ppa_addr ppa) } EXPORT_SYMBOL(nvm_erase_ppa); +int nvm_submit_ppa(struct nvm_dev *dev, struct ppa_addr ppa, int opcode, + void *buf, int len) +{ + struct nvm_rq rqd; + struct bio *bio; + int ret; + + bio = bio_map_kern(dev->q, buf, len, GFP_KERNEL); + if (IS_ERR_OR_NULL(bio)) + return -ENOMEM; + + memset(&rqd, 0, sizeof(struct nvm_rq)); + ret = nvm_set_rqd_ppalist(dev, &rqd, &ppa, 1); + if (ret) { + bio_put(bio); + return ret; + } + + rqd.opcode = opcode; + rqd.flags = NVM_IO_F_SYNC; + rqd.bio = bio; + nvm_generic_to_addr_mode(dev, &rqd); + + ret = dev->ops->submit_io(dev, &rqd); + + nvm_free_rqd_ppalist(dev, &rqd); + + return ret; +} +EXPORT_SYMBOL(nvm_submit_ppa); + static int nvm_core_init(struct nvm_dev *dev) { struct nvm_id *id = &dev->identity; diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 770278a..0017d55 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -437,6 +437,7 @@ extern int nvm_set_rqd_ppalist(struct nvm_dev *, struct nvm_rq *, extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *); extern int nvm_erase_ppa(struct nvm_dev *, struct ppa_addr); extern int nvm_erase_blk(struct nvm_dev *, struct nvm_block *); +extern int nvm_submit_ppa(struct nvm_dev *, struct ppa_addr, int, void *, int); #else /* CONFIG_NVM */ struct nvm_dev_ops;