From: <shao.mingyin@zte.com.cn>
To: <william.zhang@broadcom.com>
Cc: <broonie@kernel.org>, <shao.mingyin@zte.com.cn>,
<linux-spi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-riscv@lists.infradead.org>, <pjw@kernel.org>,
<samuel.holland@sifive.com>, <kursad.oney@broadcom.com>,
<jonas.gorski@gmail.com>, <bcm-kernel-feedback-list@broadcom.com>,
<anand.gore@broadcom.com>, <florian.fainelli@broadcom.com>,
<rafal@milecki.pl>, <linux-arm-kernel@lists.infradead.org>,
<sven@kernel.org>, <j@jannau.net>, <neal@gompa.dev>,
<asahi@lists.linux.dev>, <ryan.wanner@microchip.com>,
<nicolas.ferre@microchip.com>, <alexandre.belloni@bootlin.com>,
<claudiu.beznea@tuxon.dev>
Subject: Re: [PATCH v2 3/5] spi: bcmbca-hsspi: fix division by zero for devices without a max speed
Date: Sat, 14 Nov 2026 14:07:57 +0800 (CST) [thread overview]
Message-ID: <20261114140757347tqYOa2IkTGVulSwLrw2Mf@zte.com.cn> (raw)
In-Reply-To: <CAHi4H7FCOxcXnYkNfXNa_iO9KFZRSC96urJthPkgoem7C52ppg@mail.gmail.com>
On Sat, Nov 14, 2026 at 09:13:59AM +0800, William Zhang wrote:
> In that case, Mingyin, please update the patch to ensure FCW >=1
I need to correct my previous reply: I incorrectly agreed that the clamp
gives FCW = 0 with a 200 MHz base clock. Sorry for the confusion.
The applied code in both drivers is
hz = max_t(int, hz, 1);
reg = DIV_ROUND_UP(2048, DIV_ROUND_UP(bs->speed_hz, hz));
For a zero-speed request, the clamp sets hz to 1. With the 200 MHz base
clock, the calculation is
DIV_ROUND_UP(200000000, 1) = 200000000
FCW = DIV_ROUND_UP(2048, 200000000) = 1
The outer division rounds up, which I missed in my previous reply.
The same calculation gives FCW = 1 for 24 MHz and 400 MHz base clocks.
With the 200 MHz base, FCW = 1 corresponds to about 97.7 kHz
(base / 2048), the minimum rate. The 1 Hz value is an input to the
divider calculation; it does not mean the SPI bus runs at 1 Hz.
For this case, the applied code already selects the minimum FCW.
Mark, understood about the difficulty of handling zero speeds in the
core. For the 200 MHz case above, the applied driver code already
selects the minimum FCW; any further adjustment would be incremental.
If you would still like an explicit FCW lower bound in both drivers,
I can prepare an incremental patch on top of the applied commits.
Thanks,
Shao
next prev parent reply other threads:[~2026-11-14 6:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 15:34 [PATCH v2 0/5] spi: fix division by zero with a zero transfer speed shao.mingyin
2026-11-10 15:34 ` [PATCH v2 1/5] spi: sifive: clamp the clock divider to the register range shao.mingyin
2026-11-10 15:34 ` [PATCH v2 2/5] spi: bcm63xx-hsspi: fix division by zero for devices without a max speed shao.mingyin
2026-11-10 15:34 ` [PATCH v2 3/5] spi: bcmbca-hsspi: " shao.mingyin
2026-11-10 20:30 ` William Zhang
2026-11-11 9:36 ` shao.mingyin
2026-11-14 0:51 ` Mark Brown
2026-11-14 1:13 ` William Zhang
2026-11-14 6:07 ` shao.mingyin [this message]
2026-11-14 14:14 ` Mark Brown
2026-11-10 15:35 ` [PATCH v2 4/5] spi: apple: fix division by zero in clock divisor calculation shao.mingyin
2026-11-10 15:35 ` [PATCH v2 5/5] spi: atmel: use the maximum divider for an unspecified speed shao.mingyin
2026-11-10 16:14 ` [PATCH v2 0/5] spi: fix division by zero with a zero transfer speed Mark Brown
2026-11-11 9:36 ` shao.mingyin
2026-11-13 22:07 ` Mark Brown
2026-11-14 0:39 ` William Zhang
2026-11-14 0:57 ` Mark Brown
2026-11-14 1:11 ` William Zhang
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=20261114140757347tqYOa2IkTGVulSwLrw2Mf@zte.com.cn \
--to=shao.mingyin@zte.com.cn \
--cc=alexandre.belloni@bootlin.com \
--cc=anand.gore@broadcom.com \
--cc=asahi@lists.linux.dev \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=broonie@kernel.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=florian.fainelli@broadcom.com \
--cc=j@jannau.net \
--cc=jonas.gorski@gmail.com \
--cc=kursad.oney@broadcom.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=neal@gompa.dev \
--cc=nicolas.ferre@microchip.com \
--cc=pjw@kernel.org \
--cc=rafal@milecki.pl \
--cc=ryan.wanner@microchip.com \
--cc=samuel.holland@sifive.com \
--cc=sven@kernel.org \
--cc=william.zhang@broadcom.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®