All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bradley Morgan <bradley.morgan@linux.dev>
To: Josef Schlehofer <pepe.schlehofer@gmail.com>,
	u-boot@lists.u-boot-project.org
Cc: Tom Rini <trini@konsulko.com>,
	"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
Subject: Re: [PATCH 4/6] powerpc: mpc8xxx: Avoid a 64-bit division in get_win_cnt()
Date: Wed, 25 Nov 2026 15:53:36 +0000	[thread overview]
Message-ID: <C41DA0FF-2B86-4CD4-8C07-87E896617605@linux.dev> (raw)
In-Reply-To: <20261125124259.95636-5-pepe.schlehofer@gmail.com>

On 25 November 2026 12:42:57 GMT, Josef Schlehofer
<pepe.schlehofer@gmail.com> wrote:
>GCC turns the u64 division in get_win_cnt() into a call to __udivdi3(),
>which U-Boot's private libgcc does not provide.
>
>Compare size with the product of win_cnt and PAMU_PAGE_SIZE instead.
>For a non-zero win_cnt, size / win_cnt < PAMU_PAGE_SIZE holds exactly
>when size < win_cnt * PAMU_PAGE_SIZE, and the product is at most
>128 * 4096.
>
>Suggested-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
>Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
>Cc: Bradley Morgan <bradley.morgan@linux.dev>

Acked-by: Bradley Morgan <bradley.morgan@linux.dev> # PowerPC


>Cc: Tom Rini <trini@konsulko.com>
>---
> arch/powerpc/cpu/mpc8xxx/fsl_pamu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/arch/powerpc/cpu/mpc8xxx/fsl_pamu.c b/arch/powerpc/cpu/mpc8xxx/fsl_pamu.c
>index 638c3a6fee5..b6f8552d7d8 100644
>--- a/arch/powerpc/cpu/mpc8xxx/fsl_pamu.c
>+++ b/arch/powerpc/cpu/mpc8xxx/fsl_pamu.c
>@@ -364,7 +364,7 @@ static uint32_t get_win_cnt(uint64_t size)
> {
> 	uint32_t win_cnt = DEFAULT_NUM_SUBWINDOWS;
> 
>-	while (win_cnt && (size/win_cnt) < PAMU_PAGE_SIZE)
>+	while (win_cnt && size < (uint64_t)win_cnt * PAMU_PAGE_SIZE)
> 		win_cnt >>= 1;
> 
> 	return win_cnt;
>

--- Thanks!

  reply	other threads:[~2026-11-25 15:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 12:42 [PATCH 0/6] Avoid 64-bit divisions that need __udivdi3() or __umoddi3() Josef Schlehofer
2026-11-25 12:42 ` [PATCH 1/6] fs: btrfs: Avoid a 64-bit modulo in __btrfs_devread() Josef Schlehofer
2026-11-25 20:11   ` Qu Wenruo
2026-11-25 12:42 ` [PATCH 2/6] fs/squashfs: Avoid 64-bit divisions Josef Schlehofer
2026-11-25 12:42 ` [PATCH 3/6] mmc: Use div_u64() in mmc_berase() Josef Schlehofer
2026-11-26  2:10   ` Peng Fan (OSS)
2026-11-25 12:42 ` [PATCH 4/6] powerpc: mpc8xxx: Avoid a 64-bit division in get_win_cnt() Josef Schlehofer
2026-11-25 15:53   ` Bradley Morgan [this message]
2026-11-25 12:42 ` [PATCH 5/6] fs: btrfs: Remove the unused dev.c Josef Schlehofer
2026-11-25 20:14   ` Qu Wenruo
2026-11-26  9:15     ` Josef Schlehofer
2026-11-26  9:20       ` Qu Wenruo
2026-11-25 12:42 ` [PATCH 6/6] fs: btrfs: Avoid the remaining 64-bit divisions Josef Schlehofer
2026-11-25 20:15   ` Qu Wenruo
2026-11-25 15:45 ` [PATCH 0/6] Avoid 64-bit divisions that need __udivdi3() or __umoddi3() Bradley Morgan
2026-11-25 15:51   ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C41DA0FF-2B86-4CD4-8C07-87E896617605@linux.dev \
    --to=bradley.morgan@linux.dev \
    --cc=chleroy@kernel.org \
    --cc=pepe.schlehofer@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.