From f860c90bd6ce22c6a0a352cc16acc74fba3d628e Mon Sep 17 00:00:00 2001 From: Atsushi Nemoto Date: Wed, 13 Dec 2006 01:22:06 +0900 Subject: [MIPS] csum_partial and copy in parallel Implement optimized asm version of csum_partial_copy_nocheck, csum_partial_copy_from_user and csum_and_copy_to_user which can do calculate and copy in parallel, based on memcpy.S. Signed-off-by: Atsushi Nemoto Signed-off-by: Ralf Baechle --- include/asm-mips/checksum.h | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/asm-mips/checksum.h b/include/asm-mips/checksum.h index 9b768c3b96b..24cdcc6eaab 100644 --- a/include/asm-mips/checksum.h +++ b/include/asm-mips/checksum.h @@ -29,31 +29,38 @@ */ __wsum csum_partial(const void *buff, int len, __wsum sum); +__wsum __csum_partial_copy_user(const void *src, void *dst, + int len, __wsum sum, int *err_ptr); + /* * this is a new version of the above that records errors it finds in *errp, * but continues and zeros the rest of the buffer. */ -__wsum csum_partial_copy_from_user(const void __user *src, - void *dst, int len, - __wsum sum, int *errp); +static inline +__wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len, + __wsum sum, int *err_ptr) +{ + might_sleep(); + return __csum_partial_copy_user((__force void *)src, dst, + len, sum, err_ptr); +} /* * Copy and checksum to user */ #define HAVE_CSUM_COPY_USER -static inline __wsum csum_and_copy_to_user (const void *src, void __user *dst, - int len, __wsum sum, - int *err_ptr) +static inline +__wsum csum_and_copy_to_user(const void *src, void __user *dst, int len, + __wsum sum, int *err_ptr) { might_sleep(); - sum = csum_partial(src, len, sum); - - if (copy_to_user(dst, src, len)) { + if (access_ok(VERIFY_WRITE, dst, len)) + return __csum_partial_copy_user(src, (__force void *)dst, + len, sum, err_ptr); + if (len) *err_ptr = -EFAULT; - return (__force __wsum)-1; - } - return sum; + return (__force __wsum)-1; /* invalid checksum */ } /* -- cgit v1.2.3