Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2221946/?format=api
{ "id": 2221946, "url": "http://patchwork.ozlabs.org/api/patches/2221946/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260410-sdxi-base-v1-11-1d184cb5c60a@amd.com/", "project": { "id": 28, "url": "http://patchwork.ozlabs.org/api/projects/28/?format=api", "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-11-1d184cb5c60a@amd.com>", "list_archive_url": null, "date": "2026-04-10T13:07:21", "name": "[11/23] dmaengine: sdxi: Add client context alloc and release APIs", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "2cc2eeea392c5586b6ae25de23b538397ffd28e9", "submitter": { "id": 91626, "url": "http://patchwork.ozlabs.org/api/people/91626/?format=api", "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-11-1d184cb5c60a@amd.com/mbox/", "series": [ { "id": 499458, "url": "http://patchwork.ozlabs.org/api/series/499458/?format=api", "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/2221946/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2221946/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-pci+bounces-52322-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=Mj+dDl5T;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-52322-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=\"Mj+dDl5T\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201" ], "Received": [ "from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsccR5YTqz1yGS\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 23:10:47 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id B546A3057747\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 13:07:57 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 9769A3A8757;\n\tFri, 10 Apr 2026 13:07:50 +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 6D69C3A6F0A;\n\tFri, 10 Apr 2026 13:07:50 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPS id 3BFF7C2BCAF;\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 2F83CF44858;\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=YaguefK5CB7AbYwm5Fw/48UEnqfAZlwYlUoxMg628ZYR6lo4/Ov3ZsfV64rusbAMLgGrg2Cjo7TDSyBdbpxANzr9e+0+Nv5QtEVC64orNlKnux7f75jEGIxtqIkVKn0/YKZyUtphPQEBabQs2uvlHKkC/W3CjEG4jisJ/ojC/5U=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775826470; c=relaxed/simple;\n\tbh=CwnH20nbnZeEx71kjJfqgW1Kkik5vXHnbnNTIzkpXZ8=;\n\th=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:\n\t In-Reply-To:To:Cc;\n b=dxFV59W2X3oVvV6D9601zBoK123HArRnaEhT4UUGVsfOjlvyaN6Lv5JUjZNWEhGvud5w7Voy8yC+1OwHVeQ+Pc2g9sM05pUP+CRZWxjnkM2HcoY/btLbHG/QGLLDRI4J4qCyOHiHrvmN8izDgKyYD3c0b1i5rkim/RMkY7vx2Pg=", "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=Mj+dDl5T; 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=CwnH20nbnZeEx71kjJfqgW1Kkik5vXHnbnNTIzkpXZ8=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From;\n\tb=Mj+dDl5TBDivPfUpl6elvcmNetF4UKH2FqDtF+qABbocSH5Gyx+bfFftG2amuNfn6\n\t zEqJQNJVYD1zAS0575K5p55jIzEC3Fgvgnoa1+fov5KtqNe1h5Z3ufuOt/3ozOkcNT\n\t FG/o6vHy9ne7iRGwzRETWYQVtNvH3eyRIObAAVZEjDfliP3h/CHfy0UDzC4+19BOOG\n\t 2+kzI4JWeTJ3Qif4wwlNfD2OHZsnjiMgnExZgmtA9PHa60EOYvvUFQDgCu92YSiLFj\n\t adE7sCQdAzzpd36ocEAL7UODFhAMkvKkwokRjTiEz50vzoohpY0qX88i5f6XrZCcko\n\t PV42hzeseWD1A==", "From": "Nathan Lynch via B4 Relay <devnull+nathan.lynch.amd.com@kernel.org>", "Date": "Fri, 10 Apr 2026 08:07:21 -0500", "Subject": "[PATCH 11/23] dmaengine: sdxi: Add client context alloc and\n release APIs", "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-11-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=7502;\n i=nathan.lynch@amd.com; s=20260410; h=from:subject:message-id;\n bh=L09ifU2t1M66vemGzv844gf5trJUsLLPkMvoKJ9/BWU=;\n b=1wnV9tnj4bjG+TusTQcZRbOfOcwafacenADlcgVb9vf+dMBelEbNHJutiK8mBDq5FrgtayL7e\n ee9XuJBASLiANTLPt64q12nZrouPjHd6BC0fpsloQuUxvtXK3JyRrYk", "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\nExpose sdxi_cxt_new() and sdxi_cxt_exit(), which are the rest of the\ndriver's entry points to creating and releasing SDXI contexts.\n\nTrack client contexts in a device-wide allocating xarray, mapping\ncontext ID to the context object. The admin context always has ID 0,\nso begin allocations at 1. Define a local class for ID allocation to\nfacilitate automatic release of an ID if an error is encountered when\n\"publishing\" a context to the L1 table.\n\nIntroduce new code to invalidate a context's entry in the L1 table on\ndeallocation.\n\nSupport for starting and stopping contexts will be added in changes to\nfollow.\n\nThe only expected user of sdxi_cxt_new() and sdxi_cxt_exit() at this\npoint is the DMA engine provider code where a client context per\nchannel will be created.\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/context.c | 111 +++++++++++++++++++++++++++++++++++++++++++++\n drivers/dma/sdxi/context.h | 13 ++++++\n drivers/dma/sdxi/device.c | 8 ++++\n drivers/dma/sdxi/sdxi.h | 2 +\n 4 files changed, 134 insertions(+)", "diff": "diff --git a/drivers/dma/sdxi/context.c b/drivers/dma/sdxi/context.c\nindex 934c487b4774..7cae140c0a20 100644\n--- a/drivers/dma/sdxi/context.c\n+++ b/drivers/dma/sdxi/context.c\n@@ -155,6 +155,16 @@ static int configure_cxt_ctl(struct sdxi_cxt_ctl *ctl, const struct sdxi_cxt_ctl\n \treturn 0;\n }\n \n+static void invalidate_cxtl_ctl(struct sdxi_cxt_ctl *ctl)\n+{\n+\tu64 ds_ring_ptr = le64_to_cpu(ctl->ds_ring_ptr);\n+\n+\tFIELD_MODIFY(SDXI_CXT_CTL_VL, &ds_ring_ptr, 0);\n+\tWRITE_ONCE(ctl->ds_ring_ptr, cpu_to_le64(ds_ring_ptr));\n+\tdma_wmb();\n+\t*ctl = (typeof(*ctl)) { 0 };\n+}\n+\n /*\n * Logical representation of CXT_L1_ENT subfields.\n */\n@@ -209,6 +219,16 @@ static int configure_L1_entry(struct sdxi_cxt_L1_ent *ent,\n \treturn 0;\n }\n \n+static void invalidate_L1_entry(struct sdxi_cxt_L1_ent *ent)\n+{\n+\tu64 cxt_ctl_ptr = le64_to_cpu(ent->cxt_ctl_ptr);\n+\n+\tFIELD_MODIFY(SDXI_CXT_L1_ENT_VL, &cxt_ctl_ptr, 0);\n+\tWRITE_ONCE(ent->cxt_ctl_ptr, cpu_to_le64(cxt_ctl_ptr));\n+\tdma_wmb();\n+\t*ent = (typeof(*ent)) { 0 };\n+}\n+\n /*\n * Make the context control structure hierarchy valid from the POV of\n * the SDXI implementation. This may eventually involve allocation of\n@@ -259,6 +279,17 @@ static int sdxi_publish_cxt(const struct sdxi_cxt *cxt)\n \t/* todo: need to send DSC_CXT_UPD to admin */\n }\n \n+/* Invalidate a context. */\n+static void sdxi_rescind_cxt(struct sdxi_cxt *cxt)\n+{\n+\tu8 l1_idx = ID_TO_L1_INDEX(cxt->id);\n+\tstruct sdxi_cxt_L1_ent *ent = &cxt->sdxi->L1_table->entry[l1_idx];\n+\n+\tinvalidate_L1_entry(ent);\n+\tinvalidate_cxtl_ctl(cxt->cxt_ctl);\n+\t/* todo: need to send DSC_CXT_UPD to admin */\n+}\n+\n void sdxi_cxt_push_doorbell(struct sdxi_cxt *cxt, u64 index)\n {\n \t/* Ensure preceding write index increment is visible. */\n@@ -266,6 +297,61 @@ void sdxi_cxt_push_doorbell(struct sdxi_cxt *cxt, u64 index)\n \tiowrite64(index, cxt->db);\n }\n \n+/* Enable automatic cleanup of an allocated context ID */\n+struct __class_sdxi_cxt_id {\n+\tstruct sdxi_dev *sdxi;\n+\ts32 id;\n+};\n+\n+#define sdxi_cxt_id_null ((struct __class_sdxi_cxt_id){ NULL, -1 })\n+#define take_sdxi_cxt_id(x) __get_and_null(x, sdxi_cxt_id_null)\n+\n+DEFINE_CLASS(sdxi_alloc_cxt_id, struct __class_sdxi_cxt_id,\n+\tif (_T.id >= 0)\n+\t\txa_erase(&_T.sdxi->client_cxts, _T.id),\n+\t((struct __class_sdxi_cxt_id){\n+\t\t.sdxi = sdxi,\n+\t\t.id = ({\n+\t\t\tstruct xa_limit limit = XA_LIMIT(1, sdxi->max_cxtid);\n+\t\t\tu32 id;\n+\t\t\tint err = xa_alloc(&sdxi->client_cxts, &id, cxt,\n+\t\t\t\t\t limit, GFP_KERNEL);\n+\t\t\terr ? err : id;\n+\t\t}),\n+\t}),\n+\tstruct sdxi_dev *sdxi, struct sdxi_cxt *cxt)\n+\n+/*\n+ * Allocate the context ID; link the context back to the device;\n+ * perform some final initialization of the context based on the ID\n+ * allocated; update the context tables.\n+ */\n+static int register_cxt(struct sdxi_dev *sdxi, struct sdxi_cxt *cxt)\n+{\n+\tint err;\n+\n+\tCLASS(sdxi_alloc_cxt_id, slot)(sdxi, cxt);\n+\tif (slot.id < 0)\n+\t\treturn slot.id;\n+\n+\tcxt->sdxi = sdxi;\n+\tcxt->id = slot.id;\n+\tcxt->db = sdxi->dbs + slot.id * sdxi->db_stride;\n+\n+\terr = sdxi_publish_cxt(cxt);\n+\tif (err)\n+\t\treturn err;\n+\n+\ttake_sdxi_cxt_id(slot);\n+\treturn 0;\n+}\n+\n+static void unregister_cxt(struct sdxi_cxt *cxt)\n+{\n+\tsdxi_rescind_cxt(cxt);\n+\txa_erase(&cxt->sdxi->client_cxts, cxt->id);\n+}\n+\n static void free_admin_cxt(void *ptr)\n {\n \tstruct sdxi_dev *sdxi = ptr;\n@@ -296,3 +382,28 @@ int sdxi_admin_cxt_init(struct sdxi_dev *sdxi)\n \n \treturn devm_add_action_or_reset(sdxi_to_dev(sdxi), free_admin_cxt, sdxi);\n }\n+\n+/*\n+ * Allocate a context for in-kernel use. Starting the context is the\n+ * caller's responsibility.\n+ */\n+struct sdxi_cxt *sdxi_cxt_new(struct sdxi_dev *sdxi)\n+{\n+\tstruct sdxi_cxt *cxt __free(sdxi_cxt) = sdxi_alloc_cxt(sdxi);\n+\tif (!cxt)\n+\t\treturn NULL;\n+\n+\tif (register_cxt(sdxi, cxt))\n+\t\treturn NULL;\n+\n+\treturn_ptr(cxt);\n+}\n+\n+void sdxi_cxt_exit(struct sdxi_cxt *cxt)\n+{\n+\tif (WARN_ON(sdxi_cxt_is_admin(cxt)))\n+\t\treturn;\n+\n+\tunregister_cxt(cxt);\n+\tsdxi_free_cxt(cxt);\n+}\ndiff --git a/drivers/dma/sdxi/context.h b/drivers/dma/sdxi/context.h\nindex c34acd730acb..5cd78e883c8d 100644\n--- a/drivers/dma/sdxi/context.h\n+++ b/drivers/dma/sdxi/context.h\n@@ -58,6 +58,19 @@ struct sdxi_cxt {\n \n int sdxi_admin_cxt_init(struct sdxi_dev *sdxi);\n \n+struct sdxi_cxt *sdxi_cxt_new(struct sdxi_dev *sdxi);\n+void sdxi_cxt_exit(struct sdxi_cxt *cxt);\n+\n+static inline struct sdxi_cxt *to_admin_cxt(const struct sdxi_cxt *cxt)\n+{\n+\treturn cxt->sdxi->admin_cxt;\n+}\n+\n+static inline bool sdxi_cxt_is_admin(const struct sdxi_cxt *cxt)\n+{\n+\treturn cxt == to_admin_cxt(cxt);\n+}\n+\n void sdxi_cxt_push_doorbell(struct sdxi_cxt *cxt, u64 index);\n \n #endif /* DMA_SDXI_CONTEXT_H */\ndiff --git a/drivers/dma/sdxi/device.c b/drivers/dma/sdxi/device.c\nindex 15f61d1ce490..aaff6b15325a 100644\n--- a/drivers/dma/sdxi/device.c\n+++ b/drivers/dma/sdxi/device.c\n@@ -12,6 +12,7 @@\n #include <linux/dmapool.h>\n #include <linux/log2.h>\n #include <linux/slab.h>\n+#include <linux/xarray.h>\n \n #include \"context.h\"\n #include \"hw.h\"\n@@ -302,6 +303,7 @@ int sdxi_register(struct device *dev, const struct sdxi_bus_ops *ops)\n \n \tsdxi->dev = dev;\n \tsdxi->bus_ops = ops;\n+\txa_init_flags(&sdxi->client_cxts, XA_FLAGS_ALLOC1);\n \tdev_set_drvdata(dev, sdxi);\n \n \terr = sdxi->bus_ops->init(sdxi);\n@@ -314,6 +316,12 @@ int sdxi_register(struct device *dev, const struct sdxi_bus_ops *ops)\n void sdxi_unregister(struct device *dev)\n {\n \tstruct sdxi_dev *sdxi = dev_get_drvdata(dev);\n+\tstruct sdxi_cxt *cxt;\n+\tunsigned long index;\n+\n+\txa_for_each(&sdxi->client_cxts, index, cxt)\n+\t\tsdxi_cxt_exit(cxt);\n+\txa_destroy(&sdxi->client_cxts);\n \n \tsdxi_dev_stop(sdxi);\n }\ndiff --git a/drivers/dma/sdxi/sdxi.h b/drivers/dma/sdxi/sdxi.h\nindex 426101875334..da33719735ab 100644\n--- a/drivers/dma/sdxi/sdxi.h\n+++ b/drivers/dma/sdxi/sdxi.h\n@@ -12,6 +12,7 @@\n #include <linux/dev_printk.h>\n #include <linux/io-64-nonatomic-lo-hi.h>\n #include <linux/types.h>\n+#include <linux/xarray.h>\n \n #include \"mmio.h\"\n \n@@ -61,6 +62,7 @@ struct sdxi_dev {\n \tstruct dma_pool *cst_blk_pool;\n \n \tstruct sdxi_cxt *admin_cxt;\n+\tstruct xarray client_cxts; /* context id -> (struct sdxi_cxt *) */\n \n \tconst struct sdxi_bus_ops *bus_ops;\n };\n", "prefixes": [ "11/23" ] }