{"id":2221942,"url":"http://patchwork.ozlabs.org/api/patches/2221942/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260410-sdxi-base-v1-5-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-5-1d184cb5c60a@amd.com>","list_archive_url":null,"date":"2026-04-10T13:07:15","name":"[05/23] dmaengine: sdxi: Configure context tables","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"a839218a7903dea080632bde9336d13c679eb5b3","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-5-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/2221942/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221942/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-pci+bounces-52317-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=F62tMkB3;\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-52317-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=\"F62tMkB3\"","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 4fsccC0Hnqz1yGS\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 23:10:35 +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 79F473051BDA\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 13:07:56 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 81CC53A75B0;\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 17CD0342C9E;\n\tFri, 10 Apr 2026 13:07:50 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPS id C76BFC2BCB5;\n\tFri, 10 Apr 2026 13:07:49 +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 BEB36F44858;\n\tFri, 10 Apr 2026 13:07:49 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775826470; cv=none;\n b=vBAVQ/fEs9etIRGWcXpRRq1/beFz9eN4WfxmV4Xiw9ti853s2sleWDXmqB3u6eXXR8hCXxw0gBcxjFxPLxEfJIhO7/b6hdd7La9UXjI2WEVeiMbcJDP2/eJNSwXnBZPzm+vl/1gdzg3Z1p0Six/qCcyzWtC05iC3Hg2nDgPv/Bg=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775826470; c=relaxed/simple;\n\tbh=sgltKFJ5VdN3vW+isXcC1TZCEf2m0b2YAmQ1UJNjxsk=;\n\th=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:\n\t In-Reply-To:To:Cc;\n b=sk09woMw1i1S8HybvZmVd5lwW9R26MsZ5l35nww9jKIoNecHMvwteTbY+W86OlERUNFHkVGbM1x/kT0dNKGN0THmfZj3/eFkBS68C2KRa0uK0ILgzwgVzE1EIBbeNp/jyMhvv/TcBd1nd3lXrFqN1XueuAEPOwUA8fQHxtFXOag=","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=F62tMkB3; 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=1775826469;\n\tbh=sgltKFJ5VdN3vW+isXcC1TZCEf2m0b2YAmQ1UJNjxsk=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From;\n\tb=F62tMkB3fGtmFGakEeX0YalCHFkWiGEUaYpe4wZcAtoUv3XEIcVMaw4U7z6sW2fU7\n\t thh2DE7hztp1bXyH3M9kbc7HFE47lUIfFvZrNDmmru37Zfs7nsXuqkb29TC3C8/a/3\n\t s9Zm+bz52Sx59SuF0kxk83uh9UaZexpXhVbYnEl4CnPxP+TEFDm1reinhx/CYVz3C2\n\t JQuMhDrQvaQDLjIy5t3IkmJwzBuqAQFAEOs55rpGsNxyl36Lv1+AOVI7EUPyGnshBJ\n\t Qe8Tw20ufzrVEwaTdqtdzQ8+5hNDm4C2Ue4wQ/WErv5K9A/61pnlg8cyiYhMOh5012\n\t EGcAyE928dFqQ==","From":"Nathan Lynch via B4 Relay <devnull+nathan.lynch.amd.com@kernel.org>","Date":"Fri, 10 Apr 2026 08:07:15 -0500","Subject":"[PATCH 05/23] dmaengine: sdxi: Configure context tables","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-5-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=6822;\n i=nathan.lynch@amd.com; s=20260410; h=from:subject:message-id;\n bh=Zoq8VnkuwOO4eUQgVv+ADI1U5B7YsdpNi3XIpPjoUyQ=;\n b=eiX3CHjsjpXNYgDae34bwdmMk/1Im07HeB6UhGhBwp2oVcFBp7Bq1qAfPf8Iw8JSuHsIUWx9U\n JGP83swnWfODyMBgKKP3OmEDs3dFhka+uRvs6bWCWvrByBbzkxW+kL4","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\nSDXI uses a two-level table hierarchy to track contexts. There is a\nsingle level 2 table per function which enumerates up to 512 level 1\ntables. Each level 1 table enumerates up to 128 contexts.\n\nAllocate and install the L2 table and a single L1 table, enough for\ncontext IDs 0-127 (i.e. the admin context with reserved id 0, plus 127\nclient contexts). For now, to avoid dynamic management of additional\nL1 tables, cap ctl2.max_cxt to 127.\n\nSince the table allocations are devres-managed, there is no\ncorresponding cleanup code required.\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/device.c | 40 +++++++++++++++++++++++++++++--\n drivers/dma/sdxi/hw.h     | 61 +++++++++++++++++++++++++++++++++++++++++++++++\n drivers/dma/sdxi/mmio.h   |  6 +++++\n drivers/dma/sdxi/sdxi.h   |  5 ++++\n 4 files changed, 110 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/dma/sdxi/device.c b/drivers/dma/sdxi/device.c\nindex 1083fdddd72f..7e772ce81365 100644\n--- a/drivers/dma/sdxi/device.c\n+++ b/drivers/dma/sdxi/device.c\n@@ -8,8 +8,11 @@\n #include <linux/bitfield.h>\n #include <linux/delay.h>\n #include <linux/device.h>\n+#include <linux/dma-mapping.h>\n+#include <linux/log2.h>\n #include <linux/slab.h>\n \n+#include \"hw.h\"\n #include \"mmio.h\"\n #include \"sdxi.h\"\n \n@@ -113,7 +116,8 @@ static int sdxi_dev_stop(struct sdxi_dev *sdxi)\n  */\n static int sdxi_fn_activate(struct sdxi_dev *sdxi)\n {\n-\tu64 version, cap0, cap1, ctl2;\n+\tu64 version, cap0, cap1, ctl2, cxt_l2, lv01_ptr;\n+\tstruct sdxi_cxt_L2_ent *L2_ent;\n \tint err;\n \n \t/*\n@@ -137,7 +141,13 @@ static int sdxi_fn_activate(struct sdxi_dev *sdxi)\n \n \tcap1 = sdxi_read64(sdxi, SDXI_MMIO_CAP1);\n \tsdxi->op_grp_cap = FIELD_GET(SDXI_MMIO_CAP1_OPB_000_CAP, cap1);\n-\tsdxi->max_cxtid = FIELD_GET(SDXI_MMIO_CAP1_MAX_CXT, cap1);\n+\n+\t/*\n+\t * Constrain the number of client contexts supported by the\n+\t * driver to what fits in a single L1 table.\n+\t */\n+\tsdxi->max_cxtid = min(SDXI_L1_TABLE_ENTRIES - 1,\n+\t\t\t      FIELD_GET(SDXI_MMIO_CAP1_MAX_CXT, cap1));\n \n \t/* Apply our configuration. */\n \tctl2 = FIELD_PREP(SDXI_MMIO_CTL2_MAX_CXT, sdxi->max_cxtid);\n@@ -149,6 +159,32 @@ static int sdxi_fn_activate(struct sdxi_dev *sdxi)\n \t\t\t   FIELD_GET(SDXI_MMIO_CAP1_OPB_000_CAP, cap1));\n \tsdxi_write64(sdxi, SDXI_MMIO_CTL2, ctl2);\n \n+\t/* SDXI 1.0 4.1.8.2 Context Level 2 Table Setup */\n+\tsdxi->L2_table = dmam_alloc_coherent(sdxi_to_dev(sdxi),\n+\t\t\t\t\t     sizeof(*sdxi->L2_table),\n+\t\t\t\t\t     &sdxi->L2_dma, GFP_KERNEL);\n+\tif (!sdxi->L2_table)\n+\t\treturn -ENOMEM;\n+\n+\tcxt_l2 = FIELD_PREP(SDXI_MMIO_CXT_L2_PTR, sdxi->L2_dma >> ilog2(SZ_4K));\n+\tsdxi_write64(sdxi, SDXI_MMIO_CXT_L2, cxt_l2);\n+\n+\t/* SDXI 1.0 4.1.8.3 Context Level 1 Table Setup */\n+\tsdxi->L1_table = dmam_alloc_coherent(sdxi_to_dev(sdxi),\n+\t\t\t\t\t     sizeof(*sdxi->L1_table),\n+\t\t\t\t\t     &sdxi->L1_dma, GFP_KERNEL);\n+\tif (!sdxi->L1_table)\n+\t\treturn -ENOMEM;\n+\t/*\n+\t * SDXI 1.0 4.1.8.3.c: Initialize the Context level 2 table to\n+\t * point to the Context Level 1 [table].\n+\t */\n+\tL2_ent = &sdxi->L2_table->entry[0];\n+\tlv01_ptr = FIELD_PREP(SDXI_CXT_L2_ENT_VL, 1);\n+\tlv01_ptr |= FIELD_PREP(SDXI_CXT_L2_ENT_LV01_PTR,\n+\t\t\t       sdxi->L1_dma >> ilog2(SZ_4K));\n+\tL2_ent->lv01_ptr = cpu_to_le64(lv01_ptr);\n+\n \treturn 0;\n }\n \ndiff --git a/drivers/dma/sdxi/hw.h b/drivers/dma/sdxi/hw.h\nnew file mode 100644\nindex 000000000000..df520ca7792b\n--- /dev/null\n+++ b/drivers/dma/sdxi/hw.h\n@@ -0,0 +1,61 @@\n+/* SPDX-License-Identifier: GPL-2.0-only */\n+/* Copyright Advanced Micro Devices, Inc. */\n+\n+/*\n+ * Control structures and constants defined in the SDXI specification,\n+ * with low-level accessors. The ordering of the structures here\n+ * follows the order of their definitions in the SDXI spec.\n+ *\n+ * Names of structures, members, and subfields (bit ranges within\n+ * members) are written to match the spec, generally. E.g. struct\n+ * sdxi_cxt_L2_ent corresponds to CXT_L2_ENT in the spec.\n+ *\n+ * Note: a member can have a subfield whose name is identical to the\n+ * member's name. E.g. CXT_L2_ENT's lv01_ptr.\n+ *\n+ * All reserved fields and bits (usually named \"rsvd\" or some\n+ * variation) must be set to zero by the driver unless otherwise\n+ * specified.\n+ */\n+\n+#ifndef DMA_SDXI_HW_H\n+#define DMA_SDXI_HW_H\n+\n+#include <linux/bits.h>\n+#include <linux/build_bug.h>\n+#include <linux/types.h>\n+#include <asm/byteorder.h>\n+\n+/* SDXI 1.0 Table 3-2: Context Level 2 Table Entry (CXT_L2_ENT) */\n+struct sdxi_cxt_L2_ent {\n+\t__le64 lv01_ptr;\n+#define SDXI_CXT_L2_ENT_VL       BIT_ULL(0)\n+#define SDXI_CXT_L2_ENT_LV01_PTR GENMASK_ULL(63, 12)\n+} __packed;\n+static_assert(sizeof(struct sdxi_cxt_L2_ent) == 8);\n+\n+/* SDXI 1.0 3.2.1 Context Level 2 Table */\n+#define SDXI_L2_TABLE_ENTRIES 512\n+struct sdxi_cxt_L2_table {\n+\tstruct sdxi_cxt_L2_ent entry[SDXI_L2_TABLE_ENTRIES];\n+};\n+static_assert(sizeof(struct sdxi_cxt_L2_table) == 4096);\n+\n+/* SDXI 1.0 Table 3-3: Context Level 1 Table Entry (CXT_L1_ENT) */\n+struct sdxi_cxt_L1_ent {\n+\t__le64 cxt_ctl_ptr;\n+\t__le64 akey_ptr;\n+\t__le32 misc0;\n+\t__le32 opb_000_enb;\n+\t__u8 rsvd_0[8];\n+} __packed;\n+static_assert(sizeof(struct sdxi_cxt_L1_ent) == 32);\n+\n+/* SDXI 1.0 3.2.2 Context Level 1 Table */\n+#define SDXI_L1_TABLE_ENTRIES 128\n+struct sdxi_cxt_L1_table {\n+\tstruct sdxi_cxt_L1_ent entry[SDXI_L1_TABLE_ENTRIES];\n+};\n+static_assert(sizeof(struct sdxi_cxt_L1_table) == 4096);\n+\n+#endif /* DMA_SDXI_HW_H */\ndiff --git a/drivers/dma/sdxi/mmio.h b/drivers/dma/sdxi/mmio.h\nindex c9a11c3f2f76..d8d631849938 100644\n--- a/drivers/dma/sdxi/mmio.h\n+++ b/drivers/dma/sdxi/mmio.h\n@@ -19,6 +19,9 @@ enum sdxi_reg {\n \tSDXI_MMIO_CAP0       = 0x00200,\n \tSDXI_MMIO_CAP1       = 0x00208,\n \tSDXI_MMIO_VERSION    = 0x00210,\n+\n+\t/* SDXI 1.0 9.2 Context and RKey Table Registers */\n+\tSDXI_MMIO_CXT_L2     = 0x10000,\n };\n \n /* SDXI 1.0 Table 9-2: MMIO_CTL0 */\n@@ -48,4 +51,7 @@ enum sdxi_reg {\n #define SDXI_MMIO_VERSION_MINOR GENMASK_ULL(7, 0)\n #define SDXI_MMIO_VERSION_MAJOR GENMASK_ULL(23, 16)\n \n+/* SDXI 1.0 Table 9-9: MMIO_CXT_L2 */\n+#define SDXI_MMIO_CXT_L2_PTR GENMASK_ULL(63, 12)\n+\n #endif  /* DMA_SDXI_MMIO_H */\ndiff --git a/drivers/dma/sdxi/sdxi.h b/drivers/dma/sdxi/sdxi.h\nindex 427118e60aa6..185f58b725da 100644\n--- a/drivers/dma/sdxi/sdxi.h\n+++ b/drivers/dma/sdxi/sdxi.h\n@@ -41,6 +41,11 @@ struct sdxi_dev {\n \tu16 max_cxtid;\t\t\t/* Maximum context ID allowed. */\n \tu32 op_grp_cap;\t\t\t/* supported operation group cap */\n \n+\tstruct sdxi_cxt_L2_table *L2_table;\n+\tdma_addr_t L2_dma;\n+\tstruct sdxi_cxt_L1_table *L1_table;\n+\tdma_addr_t L1_dma;\n+\n \tconst struct sdxi_bus_ops *bus_ops;\n };\n \n","prefixes":["05/23"]}