From patchwork Thu Feb 11 11:36:29 2016 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: 8277941 Return-Path: X-Original-To: patchwork-linux-block@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 A8776BEEE5 for ; Thu, 11 Feb 2016 11:37:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C061C20351 for ; Thu, 11 Feb 2016 11:37:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D117D2034C for ; Thu, 11 Feb 2016 11:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752172AbcBKLhO (ORCPT ); Thu, 11 Feb 2016 06:37:14 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38841 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752170AbcBKLgy (ORCPT ); Thu, 11 Feb 2016 06:36:54 -0500 Received: by mail-wm0-f53.google.com with SMTP id p63so64305418wmp.1 for ; Thu, 11 Feb 2016 03:36:54 -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=NWLgVoWGMfmBgfKmtcjL8oLnUlilb9aQWnYi3dGOQAc=; b=LLbD0DuEqcoH9taLf/SboNAETxPEGzzePSpX2jNtKxIul5QXZLSk3Ugvl3LE1s3fkp i0asHkhGclRgHE76Z3xT2n2G/zqo/EtoRoB05ztB/I+OMYiJFx977Bj8N3XdTSenNuHM D35zAXDiPQy1IQMnii2hqDyMocTSzsJ1tyjeM= 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=NWLgVoWGMfmBgfKmtcjL8oLnUlilb9aQWnYi3dGOQAc=; b=BSBLTR6nh3tsRMhHmtpI+N5UVM9PQFedEPWsZjyvuYOD5aWKLWZa5WGaZuRbHjYrot fl7jzvKXIJMeOoAtMfJFJ/y+4qLI9t6NZjLwL/oDNs1Ziwde4+0C9n5SttMF26Yoa6Gv mChTizYOfclX/2Iq/ewHrnNxdvHAKljVTPNHWoGHRup+TUkWftFyhmwVt57pgajP3QWp scZ+3KNQnzdst4CdKoLyH6zuFoMkl/ihqK+YblPIPNtSCn6zbJM9F/H2UWOr5uLET9MR si7NPYlL6FP194j+Don/XBiSLI48nX2hC7XRWZ755HtocewFdBSLJ3evrqC3aCQpSYce f4vg== X-Gm-Message-State: AG10YOQc/jOkbRNYXjskXZVoo+9qD6tI0wl2/K6h4re5/4X1VVUSEY/cgWQdUTPArfDCPQ== X-Received: by 10.194.117.68 with SMTP id kc4mr45193748wjb.111.1455190613520; Thu, 11 Feb 2016 03:36:53 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id w80sm26656643wme.17.2016.02.11.03.36.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Feb 2016 03:36:52 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, hch@lst.de Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH] nvme: lightnvm: return ppa completion status Date: Thu, 11 Feb 2016 12:36:29 +0100 Message-Id: <1455190589-20016-2-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455190589-20016-1-git-send-email-m@bjorling.me> References: <1455190589-20016-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=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 PPAs sent to device is separately acknowledge in a 64bit status variable. The status is stored in DW0 and DW1 of the completion queue entry. Store this status inside the nvm_rq for further processing. This can later be used to implement retry techniques for failed writes and reads. Signed-off-by: Matias Bjørling Reviewed-by: Christoph Hellwig --- drivers/nvme/host/lightnvm.c | 17 +++++++++++++++-- include/linux/lightnvm.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index 55dab93..bbb1dbf 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -146,6 +146,14 @@ struct nvme_nvm_command { }; }; +struct nvme_nvm_completion { + __le64 result; /* Used by LightNVM to return ppa completions */ + __le16 sq_head; /* how much of this queue may be reclaimed */ + __le16 sq_id; /* submission queue that generated this entry */ + __u16 command_id; /* of the command which completed */ + __le16 status; /* did the command fail, and if so, why? */ +}; + #define NVME_NVM_LP_MLC_PAIRS 886 struct nvme_nvm_lp_mlc { __u16 num_pairs; @@ -471,6 +479,10 @@ static inline void nvme_nvm_rqtocmd(struct request *rq, struct nvm_rq *rqd, static void nvme_nvm_end_io(struct request *rq, int error) { struct nvm_rq *rqd = rq->end_io_data; + struct nvme_nvm_completion *cqe = rq->special; + + if (cqe) + rqd->ppa_status = le64_to_cpu(cqe->result); nvm_end_io(rqd, error); @@ -490,7 +502,8 @@ static int nvme_nvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd) if (IS_ERR(rq)) return -ENOMEM; - cmd = kzalloc(sizeof(struct nvme_nvm_command), GFP_KERNEL); + cmd = kzalloc(sizeof(struct nvme_nvm_command) + + sizeof(struct nvme_nvm_completion), GFP_KERNEL); if (!cmd) { blk_mq_free_request(rq); return -ENOMEM; @@ -509,7 +522,7 @@ static int nvme_nvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd) rq->cmd = (unsigned char *)cmd; rq->cmd_len = sizeof(struct nvme_nvm_command); - rq->special = (void *)0; + rq->special = cmd + 1; rq->end_io_data = rqd; diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 0fb3745..201b2a3 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -242,6 +242,7 @@ struct nvm_rq { uint16_t nr_pages; uint16_t flags; + u64 ppa_status; /* ppa media status */ int error; };