Re: [PATCH v3 04/19] crypto: scatterwalk - add new functions for copying data

Herbert Xu
2025-03-03T02:39:18Z

On Sun, Mar 02, 2025 at 01:37:42PM -0800, Eric Biggers wrote:
>
> The new functions are much better than the lib/scatterlist.c ones: they have a
> much better implementation that is faster and doesn't use atomic kmaps, and
> (like scatterwalk_map_and_copy() which they are replacing first) they don't
> require the unhelpful 'nents' parameter. My tentative plan is to move them into
> lib/scatterlist.c, reimplement sg_copy_buffer() et al on top of them, then
> eventually update the callers to use the new functions directly.

Sounds good.

> However, the 'nents' parameter that sg_copy_buffer() et al take will make the
> unification a bit difficult. Currently those functions copy the minimum of
> 'buflen' bytes and the first 'nents' scatterlist elements. I'd like to remove
> the 'nents' parameter and just have 'buflen' (or rather 'nbytes'), like the
> crypto/scatterwalk.c functions. I suspect that nearly all callers are passing
> in enough 'nents' to cover their 'buflen'. But there may be some exceptions,
> which we'll need to check for.

Yes this duality of sg_nents vs. total length was always annoying
even within the Crypto API as the driver authors would often get
mixed up.

If we could settle on one of the two it would be great. Of course
I don't know how much work that's going to be and it could be
prohibitive.

Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt