{"id":2221932,"url":"http://patchwork.ozlabs.org/api/patches/2221932/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260410-sdxi-base-v1-17-1d184cb5c60a@amd.com/","project":{"id":28,"url":"http://patchwork.ozlabs.org/api/projects/28/?format=json","name":"Linux PCI development","link_name":"linux-pci","list_id":"linux-pci.vger.kernel.org","list_email":"linux-pci@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260410-sdxi-base-v1-17-1d184cb5c60a@amd.com>","list_archive_url":null,"date":"2026-04-10T13:07:27","name":"[17/23] dmaengine: sdxi: Add completion status block API","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"c203a4ec18dc1eeb2ec7f31e34f4a2e3e83489fe","submitter":{"id":91626,"url":"http://patchwork.ozlabs.org/api/people/91626/?format=json","name":"Nathan Lynch via B4 Relay","email":"devnull+nathan.lynch.amd.com@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260410-sdxi-base-v1-17-1d184cb5c60a@amd.com/mbox/","series":[{"id":499458,"url":"http://patchwork.ozlabs.org/api/series/499458/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/list/?series=499458","date":"2026-04-10T13:07:10","name":"dmaengine: Smart Data Accelerator Interface (SDXI) basic support","version":1,"mbox":"http://patchwork.ozlabs.org/series/499458/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221932/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221932/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-pci+bounces-52326-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=GpMG9T/i;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-pci+bounces-52326-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"GpMG9T/i\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fscYQ74D1z1yGb\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 23:08:10 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 32C8D30181BB\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 13:08:05 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 175A73BFE25;\n\tFri, 10 Apr 2026 13:07:51 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id B952A3BAD9C;\n\tFri, 10 Apr 2026 13:07:50 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPS id 9AF83C2BC87;\n\tFri, 10 Apr 2026 13:07:50 +0000 (UTC)","from aws-us-west-2-korg-lkml-1.web.codeaurora.org\n (localhost.localdomain [127.0.0.1])\n\tby smtp.lore.kernel.org (Postfix) with ESMTP id 95093F44860;\n\tFri, 10 Apr 2026 13:07:50 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775826470; cv=none;\n b=dnXordN3K6rRKmiTGeGNjFVLOjCtb/Iu/VP+CRT7ws3+tY06ly33cW5LKfs4aXlmKz6HIp1cfNBWLzm0YpyEExoanApS7Q3aWc3iPL8vY5+wIOcOk701goVqAlh2AqqHTgDa+JJiscpUT2I9MVEbIKMzbUpaKw5OvzefnK5d58U=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775826470; c=relaxed/simple;\n\tbh=pdL8gmnInQhr+OkRchs9HrRcYzy7ntT2qg2zGNwakHY=;\n\th=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:\n\t In-Reply-To:To:Cc;\n b=eqgsDLVnG9+sDkjIdjB91ZxRSAhBu3XqXqZ5lYCF3T4HZIvYU9JgBKT9FTROgH/BI6yH5hvmDyRa6z2hXn2fbmZlqXPYTgkq9M0yWReZiXbYMYpKBiOcVlrMF/4j3LdKoYibp72XkdHlW9skxUSfAaF64Dagb9P0ZLdKp5NYr1g=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=GpMG9T/i; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1775826470;\n\tbh=pdL8gmnInQhr+OkRchs9HrRcYzy7ntT2qg2zGNwakHY=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From;\n\tb=GpMG9T/ipSZYV/Tmajx+YOhTe3l9Wgukq5txazMossGOsl/JIUYs4rpjz1sOaOURM\n\t aCVp+AU0BIevWFgUFl05DWzGCW5zF6pdBHsWvfRqYvhll6OCkGOu0uTrR4Ol9+8jaz\n\t 3XupsXxOX5IjyKZ+snp+fz64UbHETkjZ5lWSZE3rmMQmQXR4+xELa9Xfw4fXivLzbs\n\t TGV9k6n1zRfWGGfL4kMr0pCcjSK689D70Vt2YpDOSM08NCbGWJI86cqjzuiqNQLHEk\n\t fj6Qak0i049tjJuwvNeM8vTrb7Tv6ymJAtBUlnwKItwiW8LvS3tMw/T8eiOSrd0eYJ\n\t s6oaYmjKtZGOA==","From":"Nathan Lynch via B4 Relay <devnull+nathan.lynch.amd.com@kernel.org>","Date":"Fri, 10 Apr 2026 08:07:27 -0500","Subject":"[PATCH 17/23] dmaengine: sdxi: Add completion status block API","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20260410-sdxi-base-v1-17-1d184cb5c60a@amd.com>","References":"<20260410-sdxi-base-v1-0-1d184cb5c60a@amd.com>","In-Reply-To":"<20260410-sdxi-base-v1-0-1d184cb5c60a@amd.com>","To":"Vinod Koul <vkoul@kernel.org>","Cc":"Wei Huang <wei.huang2@amd.com>,\n Mario Limonciello <mario.limonciello@amd.com>,\n Bjorn Helgaas <bhelgaas@google.com>,\n Jonathan Cameron <jonathan.cameron@huawei.com>,\n Stephen Bates <Stephen.Bates@amd.com>, PradeepVineshReddy.Kodamati@amd.com,\n John.Kariuki@amd.com, linux-pci@vger.kernel.org,\n linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,\n Nathan Lynch <nathan.lynch@amd.com>","X-Mailer":"b4 0.15.2","X-Developer-Signature":"v=1; a=ed25519-sha256; t=1775826467; l=5294;\n i=nathan.lynch@amd.com; s=20260410; h=from:subject:message-id;\n bh=T6jw1oPuUOWQrLSHLeiikyAfky0tAEzNv9gn5QH5NPY=;\n b=8JlPMftwgxsCVvBorROVYsRdlgrUpWJTxL+8rpQtNutL0O2d0lHmb/qDfgDHaI/Xyw+a0mPEI\n snDlSkfS62fB4b4n2HPNLsb9gqkpoPhxQ7bVAAfTUYTCywj0G9p5EXW","X-Developer-Key":"i=nathan.lynch@amd.com; a=ed25519;\n pk=PK4ozhq+/z9/2Jl5rgDmvHa9raVomv79qM8p1RAFpEw=","X-Endpoint-Received":"by B4 Relay for nathan.lynch@amd.com/20260410 with\n auth_id=728","X-Original-From":"Nathan Lynch <nathan.lynch@amd.com>","Reply-To":"nathan.lynch@amd.com"},"content":"From: Nathan Lynch <nathan.lynch@amd.com>\n\nIntroduce an API for managing completion status blocks. These are\nDMA-coherent buffers that may be optionally attached to SDXI\ndescriptors to signal completion. The SDXI implementation clears the\nsignal field (initialized to 1) upon completion, setting an\nerror bit in the flags field if problems were encountered executing\nthe descriptor.\n\nCallers allocate completion blocks from a per-device DMA pool via\nsdxi_completion_alloc(). sdxi_completion_attach() associates a\ncompletion with a descriptor by encoding the completion's DMA address\ninto the descriptor's csb_ptr field.\n\nsdxi_completion_poll() busy-waits until the signal field is cleared by\nthe implementation, and is intended for descriptors that are expected\nto execute quickly.\n\nsdxi_completion_signaled() and sdxi_completion_errored() query the\nsignal field and error flag of the completion, respectively.\n\nstruct sdxi_completion is kept opaque to callers. A DEFINE_FREE\ncleanup handler is provided.\n\nCo-developed-by: Wei Huang <wei.huang2@amd.com>\nSigned-off-by: Wei Huang <wei.huang2@amd.com>\nSigned-off-by: Nathan Lynch <nathan.lynch@amd.com>\n---\n drivers/dma/sdxi/Makefile     |  1 +\n drivers/dma/sdxi/completion.c | 79 +++++++++++++++++++++++++++++++++++++++++++\n drivers/dma/sdxi/completion.h | 24 +++++++++++++\n drivers/dma/sdxi/hw.h         |  1 +\n 4 files changed, 105 insertions(+)","diff":"diff --git a/drivers/dma/sdxi/Makefile b/drivers/dma/sdxi/Makefile\nindex 372f793c15b1..dd08f4a5f723 100644\n--- a/drivers/dma/sdxi/Makefile\n+++ b/drivers/dma/sdxi/Makefile\n@@ -2,6 +2,7 @@\n obj-$(CONFIG_SDXI) += sdxi.o\n \n sdxi-objs += \\\n+\tcompletion.o  \\\n \tcontext.o     \\\n \tdevice.o      \\\n \tring.o\ndiff --git a/drivers/dma/sdxi/completion.c b/drivers/dma/sdxi/completion.c\nnew file mode 100644\nindex 000000000000..859c8334f0e7\n--- /dev/null\n+++ b/drivers/dma/sdxi/completion.c\n@@ -0,0 +1,79 @@\n+// SPDX-License-Identifier: GPL-2.0-only\n+/*\n+ * SDXI Descriptor Completion Status Block handling.\n+ *\n+ * Copyright Advanced Micro Devices, Inc.\n+ */\n+#include <linux/cleanup.h>\n+#include <linux/dma-mapping.h>\n+#include <linux/dmapool.h>\n+#include <linux/slab.h>\n+\n+#include \"completion.h\"\n+#include \"descriptor.h\"\n+#include \"hw.h\"\n+\n+struct sdxi_completion {\n+\tstruct sdxi_dev *sdxi;\n+\tstruct sdxi_cst_blk *cst_blk;\n+\tdma_addr_t cst_blk_dma;\n+};\n+\n+struct sdxi_completion *sdxi_completion_alloc(struct sdxi_dev *sdxi)\n+{\n+\tstruct sdxi_cst_blk *cst_blk;\n+\tdma_addr_t cst_blk_dma;\n+\n+\t/*\n+\t * Assume callers can't tolerate GFP_KERNEL and use\n+\t * GFP_NOWAIT. Add a gfp_t flags parameter if that changes.\n+\t */\n+\tstruct sdxi_completion *sc __free(kfree) = kmalloc(sizeof(*sc), GFP_NOWAIT);\n+\tif (!sc)\n+\t\treturn NULL;\n+\n+\tcst_blk = dma_pool_zalloc(sdxi->cst_blk_pool, GFP_NOWAIT, &cst_blk_dma);\n+\tif (!cst_blk)\n+\t\treturn NULL;\n+\n+\tcst_blk->signal = cpu_to_le64(1);\n+\n+\t*sc = (typeof(*sc)) {\n+\t\t.sdxi        = sdxi,\n+\t\t.cst_blk     = cst_blk,\n+\t\t.cst_blk_dma = cst_blk_dma,\n+\t};\n+\n+\treturn_ptr(sc);\n+}\n+\n+void sdxi_completion_free(struct sdxi_completion *sc)\n+{\n+\tdma_pool_free(sc->sdxi->cst_blk_pool, sc->cst_blk, sc->cst_blk_dma);\n+\tkfree(sc);\n+}\n+\n+void sdxi_completion_poll(const struct sdxi_completion *sc)\n+{\n+\twhile (READ_ONCE(sc->cst_blk->signal) != 0)\n+\t\tcpu_relax();\n+}\n+\n+bool sdxi_completion_signaled(const struct sdxi_completion *sc)\n+{\n+\tdma_rmb();\n+\treturn (sc->cst_blk->signal == 0);\n+}\n+\n+bool sdxi_completion_errored(const struct sdxi_completion *sc)\n+{\n+\tdma_rmb();\n+\treturn FIELD_GET(SDXI_CST_BLK_ER_BIT, le32_to_cpu(sc->cst_blk->flags));\n+}\n+\n+\n+void sdxi_completion_attach(struct sdxi_desc *desc,\n+\t\t\t    const struct sdxi_completion *cs)\n+{\n+\tsdxi_desc_set_csb(desc, cs->cst_blk_dma);\n+}\ndiff --git a/drivers/dma/sdxi/completion.h b/drivers/dma/sdxi/completion.h\nnew file mode 100644\nindex 000000000000..b3b2b85796ad\n--- /dev/null\n+++ b/drivers/dma/sdxi/completion.h\n@@ -0,0 +1,24 @@\n+/* SPDX-License-Identifier: GPL-2.0-only */\n+/* Copyright Advanced Micro Devices, Inc. */\n+#ifndef DMA_SDXI_COMPLETION_H\n+#define DMA_SDXI_COMPLETION_H\n+\n+#include \"sdxi.h\"\n+\n+/*\n+ * Polled completion status block that can be attached to a\n+ * descriptor.\n+ */\n+struct sdxi_completion;\n+struct sdxi_desc;\n+struct sdxi_completion *sdxi_completion_alloc(struct sdxi_dev *sdxi);\n+void sdxi_completion_free(struct sdxi_completion *sc);\n+void sdxi_completion_poll(const struct sdxi_completion *sc);\n+void sdxi_completion_attach(struct sdxi_desc *desc,\n+\t\t\t    const struct sdxi_completion *sc);\n+bool sdxi_completion_signaled(const struct sdxi_completion *sc);\n+bool sdxi_completion_errored(const struct sdxi_completion *sc);\n+\n+DEFINE_FREE(sdxi_completion, struct sdxi_completion *, if (_T) sdxi_completion_free(_T))\n+\n+#endif /* DMA_SDXI_COMPLETION_H */\ndiff --git a/drivers/dma/sdxi/hw.h b/drivers/dma/sdxi/hw.h\nindex cb1bed2f83f2..178161588bd0 100644\n--- a/drivers/dma/sdxi/hw.h\n+++ b/drivers/dma/sdxi/hw.h\n@@ -125,6 +125,7 @@ static_assert(sizeof(struct sdxi_akey_ent) == 16);\n struct sdxi_cst_blk {\n \t__le64 signal;\n \t__le32 flags;\n+#define SDXI_CST_BLK_ER_BIT BIT(31)\n \t__u8 rsvd_0[20];\n } __packed;\n static_assert(sizeof(struct sdxi_cst_blk) == 32);\n","prefixes":["17/23"]}