From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.10 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796332926; b=uGeCZ+GFDdCaf+D77OTIceb5kI+JU4Zr2N51Am/grGMItHRLibIpeGKt+oMnbusdjWEp 2E+qgqjk6VrLVTHveWF5P0+xZpSMlEIplHcBJbSCa75qh6mJatCK1V+TgRjGqcg4FWFCQ LmyLNlUd+8KLealxvLAePfMgB9I9VBlxw5H72bakOCdnGH8ZPSQ7TMvtiaFQc293wQ5d4 VZh2brI4MjsDaNkXvnJzheptevRKAfAHvU8erB/5WF6ImLuYklnUSayMVwyIVI4tilB3z pXdjnyXoljSV0ngJSC80m6Jr0cKhb/MqVXrzNhAsokAlz2lHH8xOR7jVR2qtKtz32EQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796332926; 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=/Dfr309PJPVKd2zeZJhB7/c6i3XmqHvnRITImPTLFPI=; b=qGwWHboC1w4sxDWhytW63YP59bQ5Q+yJiUKCssDHMPDGfqYpF8U0Gur688y6DS7yJIuz tSnjECJXh1LIcXnyT3J84904tW4c/LbDBLvCjn82DG/U2eIPrcZ0rmvxNWXCoIwUWLIPy 8nHICgNR1fYdBwPiTrN4YIk8qgUnlx7H/GgJue9cmwyavszPBSHFzgWsxmbmrpD6KOYNo COtVw92+86cnPmszjrmNLr0VhBsji37dtApb0MUj+7icxnbiJH+8bl9T1JK2KNm0mQdLr S9q+sechybxQbclX9Dh67z1kmYBXk46DgzCnDR9IZemWJcb0LAbZfCpQB8v/W40OmOw== 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=QRI7o8lT; arc=none smtp.remote-ip=198.175.65.10 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 14FDC606A322; Thu, 3 Dec 2026 21:22:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 14FDC606A322 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=QRI7o8lT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796332925; x=1827868925; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/Dfr309PJPVKd2zeZJhB7/c6i3XmqHvnRITImPTLFPI=; b=QRI7o8lTipQgsolxlw+ER2elad2zMIhWcaajrTli7tjWZgwkM1Ri3EMg rZkSrF3RNA+iKieueruVJDIyT02y937l/IRQ8tTEMHc8IXNJcl09gUrdl VuR5zjsEvSDynkJufVYgIWR2YO93vg+7aCqDX0Ep5cqchNVfaOgoeWn83 EGh9/axefewC+JyzDZRqkorBofQ6Je0fGPt4xttzZbXc7fWYHurq3/0ql wT8HtHr0PjE1UUqYut9/d2fN7T3n1/fFsGyt0OAoKT4UvpTjupqEVKWVZ aog3P+bFNsgq2Hbj63TRXxskFO61zGbsf38mZ4nB50/3kiFSeMekDgMVn w==; X-CSE-ConnectionGUID: nm8aU+5LRlOYiZmcTdD+AQ== X-CSE-MsgGUID: m1cYHx8TQ92/+geRgnmNPw== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5245212" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5245212" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 13:22:04 -0800 X-CSE-ConnectionGUID: 4kE91rjTQNCBxVQmogjUTg== X-CSE-MsgGUID: B31+N9vDTu+cqTr41z1LeQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="14484204" Received: from jf5300-15a101203tc.jf.intel.com (HELO meta-crater2c.jf.intel.com) ([10.54.113.49]) by fmviesa010.fm.intel.com with ESMTP; 03 Dec 2026 13:22:05 -0800 From: Daniel Byrne To: Frank Li Cc: Daniel Byrne , Vinod Koul , Shivank Garg , Ravi Jonnalagadda , dmaengine@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 08/10] dmaengine: reintroduce DMA_MEMCPY_SG Date: Thu, 3 Dec 2026 13:15:42 -0800 Message-ID: <20261203211542.2877574-1-daniel1.byrne@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: <20261201141259.2124188-1-daniel1.byrne@intel.com> <20261201141259.2124188-9-daniel1.byrne@intel.com> X-Mailing-List: linux-kernel@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 (cc trimmed to the lists.) On Tue, 1 Dec 2026 19:51:13 +0000, Frank Li wrote: > The key is how resolve src_nents != dst_ndents case. and each sg is miss > matched, for example: Hi Frank, Thanks for taking a look at this. I kept the rule that provider.rst still has for this type: 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 both lists need not be the same, and that the operation functionally is equivalent to a strncpy where the count argument equals the smallest total size of the two scatter-gather list buffers. So the transfer ends where the shorter of the two lists ends. The way I handle a mismatch is that the provider walks both lists together. Each piece is as long as what is left of the current source entry or of the current destination entry, whichever is smaller, and then the entry that ran out moves on to the next one. That gives at most src_nents + dst_nents - 1 pieces, so 7 for the 3 and 5 entries in your example. If a provider cannot do the whole transfer, it returns NULL from the prep call and the client falls back to the CPU. Since there isn't a provider in this series, the patch doesn't show this. I have an idxd implementation that builds one DSA batch descriptor with one copy per piece. It is not posted yet because it depends on idxd fixes that are not all posted, but I would be happy to share it. This is the general idea: dst_avail = sg_dma_len(dst_sg); src_avail = sg_dma_len(src_sg); for (i = 0; i < batch_max; i++) { dma_dst = sg_dma_address(dst_sg) + sg_dma_len(dst_sg) - dst_avail; dma_src = sg_dma_address(src_sg) + sg_dma_len(src_sg) - src_avail; len = min_t(size_t, dst_avail, src_avail); /* one MEMMOVE element of the batch: dma_src, dma_dst, len */ /* a list moves to its next entry when this one is used up */ dst_nents -= fetch_sg_and_pos(&dst_sg, &dst_avail, len); src_nents -= fetch_sg_and_pos(&src_sg, &src_avail, len); /* Stop when either scatter list is consumed. */ if (!dst_nents || !src_nents || !min_t(size_t, dst_avail, src_avail)) break; } I can send the whole patch as well if that helps. The client in patch 10 does not rely on mismatched lists either. Its two lists have one entry per folio, with the same length on both sides. Thanks, Daniel