From nobody Thu Apr 2 20:14:35 2026 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011058.outbound.protection.outlook.com [40.93.194.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FA3933F378; Thu, 12 Feb 2026 13:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770904349; cv=fail; b=SkwKuKIPkAtQr/Vsgfl7gtVCB1Dgr27GoUfMo+CeUSB6zYkQVm2erp2Uzte7zNUb1B5nXDkR6gAIBUMkEOBe4wqwqZJed8w6jZB6bOPIanJoqHkGOhvHyvx92ZbKesoULQtRki7sKVkKdlBgVKOmxSlQF93pyQcf2xtUBTTl+IE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770904349; c=relaxed/simple; bh=qtbkqhiklinBwMwlyf0ImoCTMruur0Mmq7ai4Evz7j0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kXC7Q9pGAvTDvxxsK846VRS4q5IbhQVp5ytUC7jDmVCKZLWLo+p++U9BTdjv2p7aSwRGUI/CLbESwP6y4XUj+bVlF60B/Ek1jHgn3rGxqOfQJ9UGJ5n2A65Lbzo5OMRa141OiJzRhtpmlcgrgGWD14PizuCULicy07eWHh+yEfA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=NSaGnrPQ; arc=fail smtp.client-ip=40.93.194.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="NSaGnrPQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OmV02xB2lNN7rZGah/OoAVOycThqDfgOPfGqGv6e30205EokNWjyRHkZ5o+UMBYWVGYzf5Ol0q0ADtufT8oETqlQO+qaKZkczU+ZOvb8Cg+ewAb9LPzyiyRUrHvEO3pVwgqJBdj3TMmNNlGRIWh2bG8cozJjNQVvzgqP9ADgB8Vtf+6e8D4jHAnyFYuw1yW7a5RDr+x7EAbnKSipxp/Rgtbe8AgfM4rrGwIr0CLHsDC95Hkp4f8GvZit8m+P9kfPJDzIOymqWf8F5aZdJ8u3YW+XhcR4AD9bsCJJ9FmfPkrKtNeoHbtNMKmo8Q+78lkpuaV5dqHH/g2D+2XpGSzF2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=euvZtQN0Mmh1HfRjV/8d66TwQcLyFpZ4EC4TyOHtYrc=; b=XkJfcXx349oSMVUjIEdA3JDo/YeVn/UCEaZbpNsZ5Fr13Ae1npbsP6xfoQpX8cSAyQ2o5F+d+dQx6FIiEaVuzNXQZ//zqx4usy/wDLE1BMk9fYguDizP5LIQRWQXSqMgzbyf+IXRXftfWLqsT2BC96duQN/Oob4wMFvypyzeWyVk7nsE4ftGG+phHVW4h1jX+4zIA0yQx1FFSlGqWcO5AztaKhnWlxLraAWQoIJ5iW07RKYXG60XFkMtHeFhKFfHn5LfFKrRtHXIpJ8B4/qyQwUwtkS8LvT1YqmY2pG25foRQ5r60AIHEjZC94Kg8GLm1U2mcg1y8b+0OJfg9pVtgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=euvZtQN0Mmh1HfRjV/8d66TwQcLyFpZ4EC4TyOHtYrc=; b=NSaGnrPQ+6O3iXkbN22hzJ0wNDWrBP6Nh9aZJWpBJt84APpfQ3Ek3e/45Bu8/25EnZkgPnXsTPXxfpLIAwiAl2c/j5tMuSbMTGecO6QX7Q0r/eLPjKASHYgQGVbqKlx8j5TNWAasy8fhgj3XygDt2/TUK88zloA2eN14BhL0FsY= Received: from DM6PR03CA0082.namprd03.prod.outlook.com (2603:10b6:5:333::15) by CH2PR12MB4038.namprd12.prod.outlook.com (2603:10b6:610:7b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9611.12; Thu, 12 Feb 2026 13:52:23 +0000 Received: from CH3PEPF00000011.namprd21.prod.outlook.com (2603:10b6:5:333:cafe::42) by DM6PR03CA0082.outlook.office365.com (2603:10b6:5:333::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9611.12 via Frontend Transport; Thu, 12 Feb 2026 13:52:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by CH3PEPF00000011.mail.protection.outlook.com (10.167.244.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9632.0 via Frontend Transport; Thu, 12 Feb 2026 13:52:23 +0000 Received: from satlexmb10.amd.com (10.181.42.219) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 12 Feb 2026 07:52:22 -0600 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb10.amd.com (10.181.42.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 12 Feb 2026 07:52:21 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Thu, 12 Feb 2026 07:52:17 -0600 From: Srinivas Neeli To: CC: , , , , , , , , , , , , , , , Subject: [PATCH 7/7] dmaengine: xilinx_dma: Add support for reporting transfer size to AXI DMA / MCDMA client when app fields are unavailable Date: Thu, 12 Feb 2026 19:21:46 +0530 Message-ID: <20260212135146.1185416-8-srinivas.neeli@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260212135146.1185416-1-srinivas.neeli@amd.com> References: <20260212135146.1185416-1-srinivas.neeli@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000011:EE_|CH2PR12MB4038:EE_ X-MS-Office365-Filtering-Correlation-Id: da0df808-64ef-4aa3-e1fd-08de6a3df2d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message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LI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nerXktBekIzuVqrRlOcaJE0nKkXra9nagH3Sdr0nN87YDK/v2YJPRmy8+CEwi23nBKmVjaEzi7YztxdtfBG320iKLHPSGLTO6QcEKzvdXI2vWkb52Vj4XNlhDpn1K3FBXQjjPmxBSW7h11KZbUrDTOiQz+rpdzMCs8wCmOEyhCjBuXmmrp2IiWHLwleopj7KlV8j+7/sPai1apOhaM/I5jM4xG4N+YlV7XTfo9V1wHbh4HC8TV1wbUs1jRwOnMUbO58nmp6TlT9lgn9TfvQgM0rbmnk2Sl+3tMZscK99wplCLZCJNyN2nFN0qkZ1JP5GOcQ8dt6pVFJL6AhAiz+RI1aeUt3i0EEbEFa56ZWDP8anl5VlG39mp1aYTzIzgVJy1iAgTEErmv1lmPx/mzIFVsCNdU4mjPXOnzmo77T4RdqENM3nP/qAgGnFmwGpYMyK X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2026 13:52:23.2114 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da0df808-64ef-4aa3-e1fd-08de6a3df2d2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000011.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4038 Content-Type: text/plain; charset="utf-8" From: Suraj Gupta The AXI4-stream status and control interface is optional in the AXI DMA / MCDMA IP design; when it is not present, app fields are not available in DMA descriptor. In such cases, the transferred byte count can be communicated to the client using the status field (bits 0-25) of AXI DMA / MCDMA descriptor. Add a xferred_bytes field to struct xilinx_dma_tx_descriptor to record the number of bytes transferred for each transaction. The value is calculated using the existing xilinx_dma_get_residue() function, which traverses all hardware descriptors associated with the async transaction descriptor, avoiding redundant traversal. The driver uses the xlnx,include-stscntrl-strm device tree property to determine if the status/control stream interface is present and selects the appropriate metadata source accordingly. Signed-off-by: Suraj Gupta --- drivers/dma/xilinx/xilinx_dma.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dm= a.c index 0fed6bb1b354..651a360a0afd 100644 --- a/drivers/dma/xilinx/xilinx_dma.c +++ b/drivers/dma/xilinx/xilinx_dma.c @@ -380,6 +380,8 @@ struct xilinx_cdma_tx_segment { * @cyclic: Check for cyclic transfers. * @err: Whether the descriptor has an error. * @residue: Residue of the completed descriptor + * @xferred_bytes: Number of bytes transferred by this transaction + * descriptor. */ struct xilinx_dma_tx_descriptor { struct xilinx_dma_chan *chan; @@ -389,6 +391,7 @@ struct xilinx_dma_tx_descriptor { bool cyclic; bool err; u32 residue; + u32 xferred_bytes; }; =20 /** @@ -515,6 +518,7 @@ struct xilinx_dma_config { * @mm2s_chan_id: DMA mm2s channel identifier * @max_buffer_len: Max buffer length * @has_axistream_connected: AXI DMA connected to AXI Stream IP + * @has_stsctrl_stream: AXI4-stream status and control interface is enabled */ struct xilinx_dma_device { void __iomem *regs; @@ -534,6 +538,7 @@ struct xilinx_dma_device { u32 mm2s_chan_id; u32 max_buffer_len; bool has_axistream_connected; + bool has_stsctrl_stream; }; =20 /* Macros */ @@ -672,8 +677,12 @@ static void *xilinx_dma_get_metadata_ptr(struct dma_as= ync_tx_descriptor *tx, struct xilinx_axidma_tx_segment, node); metadata_ptr =3D seg->hw.app; } - *max_len =3D *payload_len =3D sizeof(u32) * XILINX_DMA_NUM_APP_WORDS; - return metadata_ptr; + if (desc->chan->xdev->has_stsctrl_stream) { + *max_len =3D *payload_len =3D sizeof(u32) * XILINX_DMA_NUM_APP_WORDS; + return metadata_ptr; + } + *max_len =3D *payload_len =3D sizeof(desc->xferred_bytes); + return (void *)&desc->xferred_bytes; } =20 static struct dma_descriptor_metadata_ops xilinx_dma_metadata_ops =3D { @@ -864,6 +873,7 @@ xilinx_dma_alloc_tx_descriptor(struct xilinx_dma_chan *= chan) return NULL; =20 desc->chan =3D chan; + desc->xferred_bytes =3D 0; INIT_LIST_HEAD(&desc->segments); =20 return desc; @@ -1014,6 +1024,7 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_c= han *chan, struct xilinx_aximcdma_desc_hw *aximcdma_hw; struct list_head *entry; u32 residue =3D 0; + u32 xferred =3D 0; =20 list_for_each(entry, &desc->segments) { if (chan->xdev->dma_config->dmatype =3D=3D XDMA_TYPE_CDMA) { @@ -1031,25 +1042,32 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma= _chan *chan, axidma_hw =3D &axidma_seg->hw; residue +=3D (axidma_hw->control - axidma_hw->status) & chan->xdev->max_buffer_len; + xferred +=3D axidma_hw->status & chan->xdev->max_buffer_len; } else { aximcdma_seg =3D list_entry(entry, struct xilinx_aximcdma_tx_segment, node); aximcdma_hw =3D &aximcdma_seg->hw; - if (chan->direction =3D=3D DMA_DEV_TO_MEM) + if (chan->direction =3D=3D DMA_DEV_TO_MEM) { residue +=3D (aximcdma_hw->control - aximcdma_hw->s2mm_status) & chan->xdev->max_buffer_len; - else + xferred +=3D aximcdma_hw->s2mm_status & + chan->xdev->max_buffer_len; + } else { residue +=3D (aximcdma_hw->control - aximcdma_hw->mm2s_status) & chan->xdev->max_buffer_len; + xferred +=3D aximcdma_hw->mm2s_status & + chan->xdev->max_buffer_len; + } } } =20 + desc->xferred_bytes =3D xferred; return residue; } =20 @@ -3284,6 +3302,8 @@ static int xilinx_dma_probe(struct platform_device *p= dev) xdev->dma_config->dmatype =3D=3D XDMA_TYPE_AXIMCDMA) { xdev->has_axistream_connected =3D of_property_read_bool(node, "xlnx,axistream-connected"); + xdev->has_stsctrl_stream =3D + of_property_read_bool(node, "xlnx,include-stscntrl-strm"); } =20 if (xdev->dma_config->dmatype =3D=3D XDMA_TYPE_VDMA) { --=20 2.25.1