From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796167013; b=E9kANuKatK8mf5fNMxOk2mNXm2ekTiqMeg94BwCBTbs/uLkh8cTgOn90CmhLWhiZg9k7 Aa6YK/CLDD6elxMjjLvbfPhsxXFvuTJmIzgTmvR830TMIW+o+b8WNxSHyy74Q3LJIouaW FeA6tX+5fU9eWG1+CTqq0ZInfPqbd4pMizVxv6AzH6jcFPaH50CDv7LtYUymgx20wj1Uj cy/VVBO//PjmwT56rrXr5NTrnYsH6d/WRXnFtwNNUrBrkyIUIT4RDGL5vLrtbW3r/Xi+e y8hEHsCwadCgr+0Hl6gQ0VXwO1710YtC4CU3B+RdQthxdRnadpPtOkpfnF/Biaem2ng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796167013; h=Received:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc: References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=N6RGsdzehr7pXyejaq+vXQ9o8jnzM/iqO1MMWMU1r8s=; b=3SUIkFuqX30Apyxxe9gsQeTjAeVI8Rp/33pGuvkFSGWY9s7WHAasHwQL6ceVqSLMp7nZ nlppdtN7PZSUFoXsXC6qp+og2ohJW6qDzEtL4pBb5+zb0VQbNENUBBJkTxNrUVf7f+5BK C74Q6CrbIH562zc3i3G2OSUmh9RtwnIa94CAsGRmB8HqAFEEVIjGYCZnh/Ec427J8fk+l ++5mCfsFTQM2lsfwhQAnEJsE1voou/DsummSxuFdULKQk7aqQrKWplSIToC1abu8TcVHm +EiSi7FZfKIlBMYS5tM0N7zJZQPHSvg7w7f50sxHmguW14Q/tV0PZJDPmG8JJBhWEyg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7EC8606A31A; Tue, 1 Dec 2026 23:16:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFB821F00893; Tue, 1 Dec 2026 23:16:50 +0000 (UTC) Message-ID: Date: Wed, 2 Dec 2026 09:16:47 +1000 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] m68k: coldfire: Use the builtin fls() and __fls() on ISA_A+ and ISA_C To: adureghello@baylibre.com, Tzu-Ching Yang Cc: Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Jean-Michel Hautbois , Yury Norov , Rasmus Villemoes , Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261123131101.639643-1-shingekinocore@gmail.com> Content-Language: en-US From: Greg Ungerer In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Angelo, On 30/11/26 17:54, adureghello@baylibre.com wrote: > Hi Tzu-Ching, > > it works on mcf54415/stanmrk2 board. > > Tested-by: Angelo Dureghello Thanks for testing and confirming. > With your patch > Loading Environment from SPIFlash... SF: Detected is25lp128 with page > size 256 Bytes, erase size 4 KiB, total 16 MiB > OK > In: uart@fc060000 > Out: uart@fc060000 > Err: uart@fc060000 > Hit any key to stop autoboot: 0 > 3117512 bytes read in 528 ms (5.6 MiB/s) > 789901 bytes read in 140 ms (5.4 MiB/s) > ## Booting kernel from Legacy Image at 42000000 ... > Image Name: mainline kernel > Created: 2026-11-30 7:36:30 UTC > Image Type: M68K Linux Kernel Image (uncompressed) > Data Size: 3117448 Bytes = 3 MiB > Load Address: 40001000 > Entry Point: 40001000 > Verifying Checksum ... OK > > > Without the patch > Loading Environment from SPIFlash... SF: Detected is25lp128 with page > size 256 Bytes, erase size 4 KiB, total 16 MiB > OK > In: uart@fc060000 > Out: uart@fc060000 > Err: uart@fc060000 > Hit any key to stop autoboot: 0 > 3125704 bytes read in 530 ms (5.6 MiB/s) > 789901 bytes read in 140 ms (5.4 MiB/s) > ## Booting kernel from Legacy Image at 42000000 ... > Image Name: mainline kernel > Created: 2026-11-30 7:38:38 UTC > Image Type: M68K Linux Kernel Image (uncompressed) > Data Size: 3125640 Bytes = 3 MiB > Load Address: 40001000 > Entry Point: 40001000 > Verifying Checksum ... OK > > @Greg: > > i am currently working on: > - dma global pool on mcf54415 + MMU, right now seems working, > - edma and dspi changes to be tested depending on global pool. > > Working all over your last readX/writeX changes (including your edma > and dspi changes). > So got some patches ready, but still have the dspi tx timeout issue > to solve. Sounds good, thanks for the update. Regards Greg > Regards, > angelo > > On Mon, Nov 23, 2026 at 09:11:01PM +0800, Tzu-Ching Yang wrote: >> Let fls() and __fls() use the ff1 instruction on ColdFire ISA_A+ and >> ISA_C cores instead of the generic binary search in C, as __ffs() and >> ffs() already do. GCC emits ff1 for __builtin_clz() on exactly the cores >> for which it defines __mcfisaaplus__ or __mcfisac__, the macros that >> already select the ff1 versions of __ffs() and ffs(), so no new >> condition is needed. Commit a6260ef84103 ("m68knommu: add ffs and __ffs >> plattform which support ISA A+ or ISA C") added the ff1 versions of >> __ffs() and ffs() in 2008 and kept the generic fls(); the generic >> __fls() followed in 2009. >> >> Use the asm-generic builtin versions of fls() and __fls() when >> __mcfisaaplus__ or __mcfisac__ is defined, and keep the generic C >> versions for ISA_A, ISA_B and 68000. The bitrev/ff1 asm of __ffs() and >> ffs() stays, as this asm is shorter than the code GCC generates for >> the builtin versions of __ffs() and ffs(). >> >> With GCC 12 to 16, fls() shrinks from 28 instructions to 8 or 9 and >> __fls() from 24 to 6. With GCC 8 to 16, the functions of each ISA_A+ or >> ISA_C defconfig kernel shrink in total by at least 8676 and at most >> 13266 bytes (scripts/bloat-o-meter -t), depending on the defconfig and >> the compiler. In lib/find_bit.c, only _find_last_bit() changes, from 55 >> to 35 instructions for m5208evb with GCC 16. >> >> fls(0) still returns 0, and __fls() still returns unsigned int. >> __fls(0), which is undefined, now returns ~0 instead of 0. For other >> CPUs, the preprocessed source changes only in its line numbers. >> >> Suggested-by: Arnd Bergmann >> Link: https://lore.kernel.org/all/dbb44e92-0bc5-449d-9e43-1f93362aa6c3@app.fastmail.com/ >> Signed-off-by: Tzu-Ching Yang >> --- >> I have no ColdFire hardware. On QEMU mcf5208evb (ISA_A+), the ffs and >> bitops KUnit tests pass before and after with GCC 8.3 to 16.2. In >> find_bit_benchmark on that machine, with the bitmaps drawn from a fixed >> seed so that the kernels before and after use the same bitmaps, and the >> executed instructions counted by a TCG plugin, find_last_bit goes from >> 52.3 to 38.3 instructions per iteration on the random bitmap with GCC >> 16, and bitmap_find_next_zero_area_off, which calls find_last_bit(), >> from 3302 to 2864; the tests of the other helpers do not change. The >> ISA_C kernels were only built, as QEMU has no ISA_C machine. >> >> Under QEMU user mode, with the kernel's flags for -mcpu=5208, 532x and >> 54455 and each GCC at -O2 and -Os, old and new fls(), __fls() and >> fls64() agree on all 2^32 inputs (fls64() in either 32-bit half) >> except the undefined __fls(0). >> >> The seven ISA_A+ and ISA_C defconfigs (m5208evb, m5235evb, m5275evb, >> m5282evb, m5329evb, m54418evb and stmark2) were built with GCC 8.3 to >> 16.2 before and after, with the same .config before and after. A W=1 >> build of these seven and of twenty other ColdFire and m68k defconfigs, >> each with at least GCC 8.3, 12.5 and 16.2, has no new warning. >> >> The new out-of-line fls() for m5208evb with GCC 16.2: >> >> movel %sp@(4),%d0 >> tstl %d0 >> beqs 1f >> movel %d0,%d1 >> ff1 %d1 >> moveq #32,%d0 >> subl %d1,%d0 >> 1: rts >> >> Against v7.4-rc1; also applies to the m68knommu and m68k for-next >> branches and to next-20261113. >> >> arch/m68k/include/asm/bitops.h | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/arch/m68k/include/asm/bitops.h b/arch/m68k/include/asm/bitops.h >> index e9639e48c6c3c..81923a9fa4494 100644 >> --- a/arch/m68k/include/asm/bitops.h >> +++ b/arch/m68k/include/asm/bitops.h >> @@ -506,13 +506,14 @@ static inline __attribute_const__ int ffs(int x) >> return __ffs(x) + 1; >> } >> >> +#include >> +#include >> #else >> #include >> #include >> -#endif >> - >> #include >> #include >> +#endif >> >> #else >> >> >> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 >> -- >> 2.34.1 >> >