From patchwork Thu Dec 19 13:09:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 11303677 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C844C921 for ; Thu, 19 Dec 2019 14:07:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9CC92206D8 for ; Thu, 19 Dec 2019 14:07:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="IV+HsRqk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CC92206D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwSM-0001ON-Bk for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Dec 2019 09:07:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34443) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvYm-0001TQ-R9 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:09:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvYj-0006Jy-Rh for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:09:43 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:47846) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvYj-0006Fe-9z for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:09:41 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20191219130939euoutp0133952596f82501bf1f18008d2465205a~hx8HPkHna1327713277euoutp01y for ; Thu, 19 Dec 2019 13:09:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20191219130939euoutp0133952596f82501bf1f18008d2465205a~hx8HPkHna1327713277euoutp01y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1576760979; bh=FJgBsP4niZXtmHBkIg8Zp3iXBAnhFys7NaMTVC75fyo=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=IV+HsRqktv96pdYovhSyVl7w5hmJ30CyGYEp8ecekZysoy2zX4stmFfe82LLjXdEr iBcJ+gZrMkSIek7UaGEJNRAa47RqoazGnZjCT2auFAhQCy/NigyQJjxa2kKEu4TqGa RoXU/hxk8DbqQ7xDiM9YRk6jES+86+amQHt2heB8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20191219130939eucas1p24c6bf9e85fd1819348fc7d7f1cf2f099~hx8HHSpOZ0341303413eucas1p2v; Thu, 19 Dec 2019 13:09:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id D4.05.60679.3967BFD5; Thu, 19 Dec 2019 13:09:39 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20191219130939eucas1p2234cbe31c7a027e6ccf1b4ceafd19c30~hx8Gpv6A_1986019860eucas1p2E; Thu, 19 Dec 2019 13:09:39 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20191219130939eusmtrp238a61a1eb3309aa5fe1afc41ddaa2a3a~hx8GpKdQf3097130971eusmtrp2-; Thu, 19 Dec 2019 13:09:39 +0000 (GMT) X-AuditID: cbfec7f4-0e5ff7000001ed07-d1-5dfb76938fa2 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D2.4D.08375.3967BFD5; Thu, 19 Dec 2019 13:09:39 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20191219130939eusmtip250063af71795420badab1320ab0ca1cd~hx8GjFXZk2680126801eusmtip2Q; Thu, 19 Dec 2019 13:09:39 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Thu, 19 Dec 2019 13:09:38 +0000 Received: from apples.local (106.110.32.41) by CAMSVWEXC01.scsc.local (106.1.227.71) with Microsoft SMTP Server id 15.0.1320.4 via Frontend Transport; Thu, 19 Dec 2019 13:09:37 +0000 From: Klaus Jensen To: Subject: [PATCH v4 07/24] nvme: add support for the abort command Date: Thu, 19 Dec 2019 14:09:04 +0100 Message-ID: <20191219130921.309264-8-k.jensen@samsung.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219130921.309264-1-k.jensen@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01SaUwTYRD16263S2PL0pIwAaOmKEYM4BVThagkHjX6w98mRVZYgdgW0uUQ f3Ek5RKQArbWM3iAEDWcVgImVKQKhIpKIXKYYFGEKETuFEW2i4Z/M/Pem3kzGRKTmYT+ZIIu mdHraI2CEONNHUs9IaWpbvXuBds2ZX1xDlIabU6kfNDLKO98ClRafuYQSnuhFT9KqOqq8wjV kLOFULmc9QL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n/8sILaIgLRE+9VJrCANzALXGSUO/b4INlVY wFFi8/1jTCA2i4CqxPUn08EG8QpYSbyfc5wJYrO8xNZvn8Au4hSwltjSe5sRYpmVxOOfH1kg 6gUlTs58AmYzA9U3b53NDGFLSBx88YJ5AqPwLCRls5CUzUJStoCReRWjSGppcW56brGhXnFi bnFpXrpecn7uJkZghG079nPzDsZLG4MPMQpwMCrx8L5M/h0rxJpYVlyZe4hRgoNZSYT3dsfP WCHelMTKqtSi/Pii0pzU4kOMpkDPTWSWEk3OB0Z/Xkm8oamhuYWlobmxubGZhZI4b4fAwRgh gfTEktTs1NSC1CKYPiYOTqkGxtx1Bz9fD6y51js1b8+XiB9/eAIZ9k06GeMZsqlnu+FPkcoA 16SWoxpS/u9+bzGT3ru28u408WcVLF+/vF9dfyXlbMsv8YeztfZPUN/46lhGcuVSL6fsMJW4 o7XqOsVzTFqNXDic1/dNfdlWpLn7z6uvYlmv+nPmC+vvXj6vLfGWUn6eatAiDyWW4oxEQy3m ouJEAANtyzfGAgAA X-CMS-MailID: 20191219130939eucas1p2234cbe31c7a027e6ccf1b4ceafd19c30 X-Msg-Generator: CA X-RootMTR: 20191219130939eucas1p2234cbe31c7a027e6ccf1b4ceafd19c30 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20191219130939eucas1p2234cbe31c7a027e6ccf1b4ceafd19c30 References: <20191219130921.309264-1-k.jensen@samsung.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 210.118.77.11 X-Mailman-Approved-At: Thu, 19 Dec 2019 08:56:47 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Beata Michalska , qemu-devel@nongnu.org, Max Reitz , Keith Busch , Javier Gonzalez Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Required for compliance with NVMe revision 1.2.1. See NVM Express 1.2.1, Section 5.1 ("Abort command"). The Abort command is a best effort command; for now, the device always fails to abort the given command. Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index a41ebf578f04..d41ea5beab08 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -731,6 +731,18 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeCmd *cmd) } } +static uint16_t nvme_abort(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req) +{ + uint16_t sqid = le32_to_cpu(cmd->cdw10) & 0xffff; + + req->cqe.result = 1; + if (nvme_check_sqid(n, sqid)) { + return NVME_INVALID_FIELD | NVME_DNR; + } + + return NVME_SUCCESS; +} + static inline void nvme_set_timestamp(NvmeCtrl *n, uint64_t ts) { trace_nvme_dev_setfeat_timestamp(ts); @@ -848,6 +860,7 @@ static uint16_t nvme_set_feature(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req) trace_nvme_dev_err_invalid_setfeat(dw10); return NVME_INVALID_FIELD | NVME_DNR; } + return NVME_SUCCESS; } @@ -864,6 +877,8 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req) return nvme_create_cq(n, cmd); case NVME_ADM_CMD_IDENTIFY: return nvme_identify(n, cmd); + case NVME_ADM_CMD_ABORT: + return nvme_abort(n, cmd, req); case NVME_ADM_CMD_SET_FEATURES: return nvme_set_feature(n, cmd, req); case NVME_ADM_CMD_GET_FEATURES: @@ -1377,6 +1392,19 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) id->ieee[2] = 0xb3; id->ver = cpu_to_le32(NVME_SPEC_VER); id->oacs = cpu_to_le16(0); + + /* + * Because the controller always completes the Abort command immediately, + * there can never be more than one concurrently executing Abort command, + * so this value is never used for anything. Note that there can easily be + * many Abort commands in the queues, but they are not considered + * "executing" until processed by nvme_abort. + * + * The specification recommends a value of 3 for Abort Command Limit (four + * concurrently outstanding Abort commands), so lets use that though it is + * inconsequential. + */ + id->acl = 3; id->frmw = 7 << 1; id->lpa = 1 << 0; id->sqes = (0x6 << 4) | 0x6;