From patchwork Fri Jun 5 12:54:23 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: 6553421 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 905A5C0020 for ; Fri, 5 Jun 2015 12:57:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93930206FF for ; Fri, 5 Jun 2015 12:57:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6E049206FE for ; Fri, 5 Jun 2015 12:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754740AbbFEM5d (ORCPT ); Fri, 5 Jun 2015 08:57:33 -0400 Received: from mail-lb0-f172.google.com ([209.85.217.172]:33964 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754424AbbFEMyt (ORCPT ); Fri, 5 Jun 2015 08:54:49 -0400 Received: by lbcmx3 with SMTP id mx3so45426411lbc.1 for ; Fri, 05 Jun 2015 05:54:48 -0700 (PDT) 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=kHAwOWz632GJV+kO9chmPzO8US9xQUvsNN7W1x/djls=; b=PsM0p9yn7NZSGqQQj0ZTbkpXj9yxWwhTshAtljQqeN2URk5FgB12yY8iD8nepNVtP7 JIVDOIUns+WxXLadnxMGG+rY7Hr5u0I7iv6iiVqIf3FQ82URdT39LwqHx50euzl0wla6 S3MXnkZRxH0jv/k6NfLaZFVMkynpHs7xtU3Us= 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=kHAwOWz632GJV+kO9chmPzO8US9xQUvsNN7W1x/djls=; b=X/FC5Gscz5YiiKzmQJ+TPqMBh7AkiUPUceBpijOvEw3sQ0EaZQ94/iR/TFCI5UaoUl IAvdDARCw1sJFqjfy3g/NONBEE7FJSruwhDVkMdLsuFrv+V7u3QeRVeiepli7rCxRAb2 /4uTGchqYPPpXl8nKd4kToj5Bu1hcExgL/Vg9LzS+1O0D4Rq2z1yu3zYqcZGA9heu4er FGApml3E8DqkjYiEoTDtu/AOuN9b2eSkFfziRIeYC0wJoa4Og9jBnDT1V+NgYdSKklx4 Am1UXsAxAzg5lG5WDw0lB7WSy6nNd+VCKUJihlLEakGRz1oANTb+7jCMrQEYslEtLYyu /Jqw== X-Gm-Message-State: ALoCoQmhLf7hKXZNTyF/8QlK4nZjxowQUtpW4skHumC51mdLE4cOME64SDoQ7h1C/4fTRuZQ0rKj X-Received: by 10.152.87.13 with SMTP id t13mr3334072laz.66.1433508888232; Fri, 05 Jun 2015 05:54:48 -0700 (PDT) Received: from macroninja.itu.dk ([130.226.133.111]) by mx.google.com with ESMTPSA id t15sm1751522lbk.0.2015.06.05.05.54.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jun 2015 05:54:47 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: hch@infradead.org, axboe@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Cc: javier@lightnvm.io, Stephen.Bates@pmcs.com, keith.busch@intel.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH v4 1/8] nvme: add special param for nvme_submit_sync_cmd Date: Fri, 5 Jun 2015 14:54:23 +0200 Message-Id: <1433508870-28251-2-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433508870-28251-1-git-send-email-m@bjorling.me> References: <1433508870-28251-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 In preparation for LightNVM, it requires a hook for internal commands to resolve its state on command completion. Use req->special for this and move the command result to req->sense. Signed-off-by: Matias Bjørling --- drivers/block/nvme-core.c | 19 ++++++++++--------- drivers/block/nvme-scsi.c | 4 ++-- include/linux/nvme.h | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 6ed1356..d2955fe 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c @@ -614,7 +614,7 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx, req->errors = 0; if (req->cmd_type == REQ_TYPE_DRV_PRIV) { u32 result = le32_to_cpup(&cqe->result); - req->special = (void *)(uintptr_t)result; + req->sense = (void *)(uintptr_t)result; } if (cmd_rq->aborted) @@ -998,7 +998,7 @@ static irqreturn_t nvme_irq_check(int irq, void *data) */ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, void *buffer, void __user *ubuffer, unsigned bufflen, - u32 *result, unsigned timeout) + u32 *result, unsigned timeout, void *special) { bool write = cmd->common.opcode & 1; struct bio *bio = NULL; @@ -1019,7 +1019,7 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, req->cmd = (unsigned char *)cmd; req->cmd_len = sizeof(struct nvme_command); - req->special = (void *)0; + req->special = special; if (buffer && bufflen) { ret = blk_rq_map_kern(q, req, buffer, bufflen, __GFP_WAIT); @@ -1036,7 +1036,7 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, if (bio) blk_rq_unmap_user(bio); if (result) - *result = (u32)(uintptr_t)req->special; + *result = (u32)(uintptr_t)req->sense; ret = req->errors; out: blk_mq_free_request(req); @@ -1046,7 +1046,8 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, void *buffer, unsigned bufflen) { - return __nvme_submit_sync_cmd(q, cmd, buffer, NULL, bufflen, NULL, 0); + return __nvme_submit_sync_cmd(q, cmd, buffer, NULL, bufflen, NULL, 0, + NULL); } static int nvme_submit_async_admin_req(struct nvme_dev *dev) @@ -1209,7 +1210,7 @@ int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid, c.features.fid = cpu_to_le32(fid); return __nvme_submit_sync_cmd(dev->admin_q, &c, NULL, NULL, 0, - result, 0); + result, 0, NULL); } int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11, @@ -1224,7 +1225,7 @@ int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11, c.features.dword11 = cpu_to_le32(dword11); return __nvme_submit_sync_cmd(dev->admin_q, &c, NULL, NULL, 0, - result, 0); + result, 0, NULL); } int nvme_get_log_page(struct nvme_dev *dev, struct nvme_smart_log **log) @@ -1787,7 +1788,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) c.rw.metadata = cpu_to_le64(meta_dma); status = __nvme_submit_sync_cmd(ns->queue, &c, NULL, - (void __user *)io.addr, length, NULL, 0); + (void __user *)io.addr, length, NULL, 0, NULL); unmap: if (meta) { if (status == NVME_SC_SUCCESS && !write) { @@ -1831,7 +1832,7 @@ static int nvme_user_cmd(struct nvme_dev *dev, struct nvme_ns *ns, status = __nvme_submit_sync_cmd(ns ? ns->queue : dev->admin_q, &c, NULL, (void __user *)cmd.addr, cmd.data_len, - &cmd.result, timeout); + &cmd.result, timeout, NULL); if (status >= 0) { if (put_user(cmd.result, &ucmd->result)) return -EFAULT; diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c index 8e6223e..ad35bb7 100644 --- a/drivers/block/nvme-scsi.c +++ b/drivers/block/nvme-scsi.c @@ -1297,7 +1297,7 @@ static int nvme_trans_send_download_fw_cmd(struct nvme_ns *ns, struct sg_io_hdr c.dlfw.offset = cpu_to_le32(offset/BYTES_TO_DWORDS); nvme_sc = __nvme_submit_sync_cmd(dev->admin_q, &c, NULL, - hdr->dxferp, tot_len, NULL, 0); + hdr->dxferp, tot_len, NULL, 0, NULL); return nvme_trans_status_code(hdr, nvme_sc); } @@ -1704,7 +1704,7 @@ static int nvme_trans_do_nvme_io(struct nvme_ns *ns, struct sg_io_hdr *hdr, break; } nvme_sc = __nvme_submit_sync_cmd(ns->queue, &c, NULL, - next_mapping_addr, unit_len, NULL, 0); + next_mapping_addr, unit_len, NULL, 0, NULL); if (nvme_sc) break; diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 986bf8a..fce2090 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -150,7 +150,7 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, void *buf, unsigned bufflen); int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, void *buffer, void __user *ubuffer, unsigned bufflen, - u32 *result, unsigned timeout); + u32 *result, unsigned timeout, void *special); int nvme_identify_ctrl(struct nvme_dev *dev, struct nvme_id_ctrl **id); int nvme_identify_ns(struct nvme_dev *dev, unsigned nsid, struct nvme_id_ns **id);