From patchwork Thu Jan 28 08:52:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 43854 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 2FD6CB7F3A for ; Thu, 28 Jan 2010 19:56:02 +1100 (EST) Received: by ozlabs.org (Postfix) id A2717B7CF4; Thu, 28 Jan 2010 19:55:51 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from gw1.transmode.se (gw1.transmode.se [213.115.205.20]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D8AEBB7CF8 for ; Thu, 28 Jan 2010 19:55:50 +1100 (EST) Received: from sesr04.transmode.se (sesr04.transmode.se [192.168.201.15]) by gw1.transmode.se (Postfix) with ESMTP id 2BE88650001; Thu, 28 Jan 2010 09:55:46 +0100 (CET) In-Reply-To: <20100127170536.23634cdf.akpm@linux-foundation.org> References: <20100112022150.GE12666@kryten> <20100112140136.c8ccc357.sfr@canb.auug.org.au> <1263412963.724.223.camel@pasglop> <1263459431.724.352.camel@pasglop> <20100127170536.23634cdf.akpm@linux-foundation.org> Subject: Re: [PATCH]: powerpc: Fix build breakage due to incorrect location of autoconf.h X-KeepSent: 871F5B59:C2574563-C12576B9:00300E39; type=4; name=$KeepSent To: Andrew Morton X-Mailer: Lotus Notes Release 8.5.1 September 28, 2009 Message-ID: From: Joakim Tjernlund Date: Thu, 28 Jan 2010 09:52:41 +0100 X-MIMETrack: Serialize by Router on sesr04/Transmode(Release 8.5.1|September 28, 2009) at 2010-01-28 09:55:46 MIME-Version: 1.0 Cc: Stephen Rothwell , Roel Kluin , "linuxppc-dev@ozlabs.org list" , Richard Purdie , Anton Blanchard , David Woodhouse X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Andrew Morton wrote on 2010/01/28 02:05:36: > > On Mon, 25 Jan 2010 09:19:59 +0100 > Joakim Tjernlund wrote: > > > Commit 6846ee5ca68d81e6baccf0d56221d7a00c1be18b made the > > new optimized inflate only available on arch's that > > define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS. This > > fixes it by defining our own endian independent versions > > of unaligned access. > > (I hope I picked up the right version of > whatever-it-was-i-was-supposed-to-pick-up - I wasn't paying attention). It was the right one. > > The changelog sucks. You say the patch fixes "it", but what is "it"? > Is "it" a build error? If so, what? Or is "it" a > make-optimized-inflate-available-on-ppc patch, in which case it's a > "feature"? Here is a new version with a somewhat better commit msg and checkpatch fixes. Jocke BTW, I get duplicate mails from your patch handling tools, one to Joakim.Tjernlund@transmode.se and one to joakim.tjernlund@transmode.se From 612bfb4cc6cc55243c2a4f536ae2ae71065b57b0 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Sun, 24 Jan 2010 11:12:56 +0100 Subject: [PATCH] zlib: Make new optimized inflate endian independent Commit 6846ee5ca68d81e6baccf0d56221d7a00c1be18b made the new optimized inflate only available on arch's that define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS. This will again enable the optimization for all arch's by by defining our own endian independent version of unaligned access. As an added bonus, arch's that define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS do a plain load instead. Signed-off-by: Joakim Tjernlund --- v2: - fix checkpatch complaints. - Improve commit msg. lib/zlib_inflate/inffast.c | 70 +++++++++++++++++++------------------------- 1 files changed, 30 insertions(+), 40 deletions(-) -- 1.6.4.4 diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c index 215447c..fa62fc7 100644 --- a/lib/zlib_inflate/inffast.c +++ b/lib/zlib_inflate/inffast.c @@ -8,21 +8,6 @@ #include "inflate.h" #include "inffast.h" -/* Only do the unaligned "Faster" variant when - * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set - * - * On powerpc, it won't be as we don't include autoconf.h - * automatically for the boot wrapper, which is intended as - * we run in an environment where we may not be able to deal - * with (even rare) alignment faults. In addition, we do not - * define __KERNEL__ for arch/powerpc/boot unlike x86 - */ - -#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS -#include -#include -#endif - #ifndef ASMINF /* Allow machine dependent optimization for post-increment or pre-increment. @@ -36,14 +21,31 @@ - Pentium III (Anderson) - M68060 (Nikl) */ +union uu { + unsigned short us; + unsigned char b[2]; +}; + +/* Endian independed version */ +static inline unsigned short +get_unaligned16(const unsigned short *p) +{ + union uu mm; + unsigned char *b = (unsigned char *)p; + + mm.b[0] = b[0]; + mm.b[1] = b[1]; + return mm.us; +} + #ifdef POSTINC # define OFF 0 # define PUP(a) *(a)++ -# define UP_UNALIGNED(a) get_unaligned((a)++) +# define UP_UNALIGNED(a) get_unaligned16((a)++) #else # define OFF 1 # define PUP(a) *++(a) -# define UP_UNALIGNED(a) get_unaligned(++(a)) +# define UP_UNALIGNED(a) get_unaligned16(++(a)) #endif /* @@ -256,7 +258,6 @@ void inflate_fast(z_streamp strm, unsigned start) } } else { -#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS unsigned short *sout; unsigned long loops; @@ -274,7 +275,11 @@ void inflate_fast(z_streamp strm, unsigned start) sfrom = (unsigned short *)(from - OFF); loops = len >> 1; do +#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + PUP(sout) = PUP(sfrom); +#else PUP(sout) = UP_UNALIGNED(sfrom); +#endif while (--loops); out = (unsigned char *)sout + OFF; from = (unsigned char *)sfrom + OFF; @@ -282,14 +287,13 @@ void inflate_fast(z_streamp strm, unsigned start) unsigned short pat16; pat16 = *(sout-2+2*OFF); - if (dist == 1) -#if defined(__BIG_ENDIAN) - pat16 = (pat16 & 0xff) | ((pat16 & 0xff) << 8); -#elif defined(__LITTLE_ENDIAN) - pat16 = (pat16 & 0xff00) | ((pat16 & 0xff00) >> 8); -#else -#error __BIG_ENDIAN nor __LITTLE_ENDIAN is defined -#endif + if (dist == 1) { + union uu mm; + /* copy one char pattern to both bytes */ + mm.us = pat16; + mm.b[0] = mm.b[1]; + pat16 = mm.us; + } loops = len >> 1; do PUP(sout) = pat16; @@ -298,20 +302,6 @@ void inflate_fast(z_streamp strm, unsigned start) } if (len & 1) PUP(out) = PUP(from); -#else /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */ - from = out - dist; /* copy direct from output */ - do { /* minimum length is three */ - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } while (len > 2); - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } -#endif /* !CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */ } } else if ((op & 64) == 0) { /* 2nd level distance code */