From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796134769; b=q8dGKLxctyuWiGWtdQLEDyusBRQvF04yGBJEAFcQAPvgQ8Td5x6e5daXNNpbYlVEcS2E 1UQU59KwsfJG5+KRp1ooanngVt7BgC2adNQDHKSUd0IMCQXWuaFiJVXGHfaYJn5JQmcIM XeI/Scwp+XlhubPuthRiPLeWkC3upS4Di1onVG55+EG5jjJ6CrIeIixd58BaBchrxqsV6 +uTMIdjDTRglEBbNn7NMHFRw3+4DQtY5DnWOnQy9VUEzG9vAwgIeG0Bq4TrxUOi0MKhI1 DZ9ysGjhch70XbMkuMcAk9RTS/Njsmz3QuVYN4+75IRjDX3VTcsqeVZ0/WkwuYcaRVw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796134769; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=6kC3qxWa1FJWx+f5n4x6sfgjtbnFibG+4s5S8pxUeKM=; b=Bu6rJXCIkBQQmMLNqTjUhCjesUjq+SzsDhD7ogXyZP88ktQt+4HqHHjiJwNaRpiopt0a 8649Z6ZxxV83qeJFui65Ku0EAESUfdyA1tNtjbXdMDhcym/F61MFx06JJG8FFHzMqLyw7 rBzwCsxBJGhS9pqwDyjuf8/qbHiyh7h71xXf271NCyivYC6g8D+kKfacO+upVMzTy668B RhX09uBDn3v/SG9OX6IjINDECfsYFVGlaxD7JoinjKMl3Pz+0bt8Bizt3xFTmglJVVStL 1FFi4SBeFNywcK+GgM+v1PxiHfTgNqCvuaI+enBO9tPj7WxfRFtSXtDwI+eoRSCl7wA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b="N3UjlG/Q"; arc=none smtp.remote-ip=198.175.65.18 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22CCE60A2623; Tue, 1 Dec 2026 14:19:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 22CCE60A2623 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=N3UjlG/Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796134770; x=1827670770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6kC3qxWa1FJWx+f5n4x6sfgjtbnFibG+4s5S8pxUeKM=; b=N3UjlG/Q5tDVCr2GQYb+kyZe9g+Y9gL3Zn7oQNeXEui/WBeyCjq+//io w6rTcWr3kIvBChWoyXkhkY2z8qLqpLGBONUnojxqUGVY61jniOy/DUhsb 6cyWgOzWtxsX0hZXykK/WB+bLNbL/rwKb3y5akahwO9xTuZs4BcV+Mvfv lzPZGdpHc0KiEqvtDsLJI5ZE/mM+o3dhSEOByaziQ8dreJUiUgouK9lkg ycDfiFdfn4LOKrUkdZx+7ps92GOAztbZJ2YR9CPo3WtuxUPYNnZUiozIc qOLbHm3BFTAibc3zdZgDDe4wivgbDKLDYXAdLL3+R1ZV8EtFxkpRL0if8 Q==; X-CSE-ConnectionGUID: Dcu+uOFtSTez+JHwbMFvaA== X-CSE-MsgGUID: plkuvgQeQWGo9RwhWiN1oA== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5019313" X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="5019313" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 06:19:25 -0800 X-CSE-ConnectionGUID: Y9z86HFhTmOAozUMZAV39A== X-CSE-MsgGUID: bIocVzeLR8WDyRy5NG5G1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="13380755" Received: from jf5300-15a101203tc.jf.intel.com (HELO meta-crater2c.jf.intel.com) ([10.54.113.49]) by fmviesa005.fm.intel.com with ESMTP; 01 Dec 2026 06:19:23 -0800 From: Daniel Byrne To: Shivank Garg , Ravi Jonnalagadda Cc: Andrew Morton , David Hildenbrand , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Karim Manaouil , Frank van der Linden , Teja Vojjala , Pravin Tamkhane , Kinsey Ho , Wei Xu , Matthew Wilcox , Davidlohr Bueso , Vinod Koul , Bharata B Rao , SeongJae Park , David Rientjes , Xuezheng Chu , Yiannis Nikolakopoulos , Dave Hansen , Johannes Weiner , John Hubbard , Peter Xu , Rik van Riel , Shakeel Butt , Tejun Heo , Fan Ni , Jonathan Cameron , "Aneesh Kumar K.V" , Nathan Lynch , Frank Li , Dan Williams , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Day , dmaengine@vger.kernel.org, Vinicius Costa Gomes , Frank Li , Dave Jiang , Daniel Byrne Subject: [RFC PATCH 08/10] dmaengine: reintroduce DMA_MEMCPY_SG Date: Tue, 1 Dec 2026 06:12:57 -0800 Message-ID: <20261201141259.2124188-9-daniel1.byrne@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261201141259.2124188-1-daniel1.byrne@intel.com> References: <20261201141259.2124188-1-daniel1.byrne@intel.com> X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Reintroduce the DMA_MEMCPY_SG transaction type and device_prep_dma_memcpy_sg(), removed by commit 0cae04373b77 ("dmaengine: remove DMA_MEMCPY_SG once again") when the last in-tree user went away. The migration copy offload added later in this series is the new user. It hands the provider a scatter/gather memcpy in one call so that batch-capable engines such as DSA can turn the operation into a single hardware batch descriptor. The transfer copies min(src, dst) total bytes. Signed-off-by: Daniel Byrne --- The cover letter of RFC v6 lists this hook as a follow-up. This is the dmaengine core part. No provider implements it in this series. .../driver-api/dmaengine/provider.rst | 10 ++++++++++ drivers/dma/dmaengine.c | 1 + include/linux/dmaengine.h | 20 +++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/Documentation/driver-api/dmaengine/provider.rst b/Documentation/driver-api/dmaengine/provider.rst index be47852e5a0f..e844c7c0fce0 100644 --- a/Documentation/driver-api/dmaengine/provider.rst +++ b/Documentation/driver-api/dmaengine/provider.rst @@ -162,6 +162,16 @@ Currently, the types available are: - The device is able to do memory to memory copies +- DMA_MEMCPY_SG + + - The device supports memory to memory scatter-gather transfers. + + - Even though a plain memcpy can look like a particular case of a + scatter-gather transfer, with a single chunk to copy, it's a distinct + transaction type in the mem2mem transfer case. This is because some very + simple devices might be able to do contiguous single-chunk memory copies, + but have no support for more complex SG transfers. + - No matter what the overall size of the combined chunks for source and destination is, only as many bytes as the smallest of the two will be transmitted. That means the number and size of the scatter-gather buffers in diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 34be53487a21..bed2a80cb538 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -1219,6 +1219,7 @@ int dma_async_device_register(struct dma_device *device) } CHECK_CAP(dma_memcpy, DMA_MEMCPY); + CHECK_CAP(dma_memcpy_sg, DMA_MEMCPY_SG); CHECK_CAP(dma_xor, DMA_XOR); CHECK_CAP(dma_xor_val, DMA_XOR_VAL); CHECK_CAP(dma_pq, DMA_PQ); diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 805668fbe437..5df4bfc000a6 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -50,6 +50,7 @@ enum dma_status { */ enum dma_transaction_type { DMA_MEMCPY, + DMA_MEMCPY_SG, DMA_XOR, DMA_PQ, DMA_XOR_VAL, @@ -860,6 +861,7 @@ struct dma_filter { * @device_router_config: optional callback for DMA router configuration * @device_free_chan_resources: release DMA channel's resources * @device_prep_dma_memcpy: prepares a memcpy operation + * @device_prep_dma_memcpy_sg: prepares a memcpy_sg operation * @device_prep_dma_xor: prepares a xor operation * @device_prep_dma_xor_val: prepares a xor validation operation * @device_prep_dma_pq: prepares a pq operation @@ -940,6 +942,11 @@ struct dma_device { struct dma_async_tx_descriptor *(*device_prep_dma_memcpy)( struct dma_chan *chan, dma_addr_t dst, dma_addr_t src, size_t len, unsigned long flags); + struct dma_async_tx_descriptor *(*device_prep_dma_memcpy_sg)( + struct dma_chan *chan, + struct scatterlist *dst_sg, unsigned int dst_nents, + struct scatterlist *src_sg, unsigned int src_nents, + unsigned long flags); struct dma_async_tx_descriptor *(*device_prep_dma_xor)( struct dma_chan *chan, dma_addr_t dst, dma_addr_t *src, unsigned int src_cnt, size_t len, unsigned long flags); @@ -1246,6 +1253,19 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_memcpy( len, flags); } +static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_memcpy_sg( + struct dma_chan *chan, + struct scatterlist *dst_sg, unsigned int dst_nents, + struct scatterlist *src_sg, unsigned int src_nents, + unsigned long flags) +{ + if (!chan || !chan->device || !chan->device->device_prep_dma_memcpy_sg) + return NULL; + + return chan->device->device_prep_dma_memcpy_sg(chan, dst_sg, dst_nents, + src_sg, src_nents, flags); +} + /** * dmaengine_get_max_xor - get the maximum number of XOR sources for a channel * @chan: DMA channel -- 2.43.0