Re: [PATCH 2/2] crypto: mxs_dcp: Use sg_mapping_iter to copy data

From
Sean Anderson <hidden>
Date
2021-06-24 14:58:58
Also in
linux-arm-kernel
Reply to
Herbert Xu, 2021-06-24

On 6/24/21 2:56 AM, Herbert Xu wrote:
On Fri, Jun 18, 2021 at 05:14:11PM -0400, Sean Anderson wrote:
quoted
This uses the sg_miter_*() functions to copy data, instead of doing it
ourselves. Using sg_copy_buffer() would be better, but this way we don't
have to keep traversing the beginning of the scatterlist every time we
do another copy.

In addition to reducing code size, this fixes the following oops
resulting from failing to kmap the page:
Thanks for the patch.  Just a minor nit:
quoted
@@ -365,25 +364,13 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)

 				out_tmp = out_buf;
 				last_out_len = actx->fill;
-				while (dst && actx->fill) {
-					if (!split) {
-						dst_buf = sg_virt(dst);
-						dst_off = 0;
-					}
-					rem = min(sg_dma_len(dst) - dst_off,
-						  actx->fill);
-
-					memcpy(dst_buf + dst_off, out_tmp, rem);
+
+				while (sg_miter_next(&dst_iter) && actx->fill) {
+					rem = min(dst_iter.length, actx->fill);
This comparison generates a sparse warning due to conflicting types,
please fix this and resubmit.
What exactly is the warning here? dst_iter.length is a size_t, and
actx->fill is a u32. So fill will be converted to a size_t before the
comparison, which is lossless.

--Sean
Thread (9 messages) 9 messages, 2 authors, last reply 2021-06-28
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help