From: <Tudor.Ambarus@microchip.com>
To: <geert@linux-m68k.org>, <broonie@kernel.org>
Cc: <linux-spi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] spi: Limit the spi device max speed to controller's max speed
Date: Wed, 16 Dec 2020 08:25:04 +0000 [thread overview]
Message-ID: <b1b385eb-15f7-8347-a5e2-0a711937c879@microchip.com> (raw)
In-Reply-To: <CAMuHMdU+heMQKLZR15g5s5Ad-H8cDeFeM+7Wh=45PFqQhyfjOA@mail.gmail.com>
On 12/15/20 4:24 PM, Geert Uytterhoeven wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> Hi Mark, Tudor,
Hi, Geert,
>
> On Fri, Dec 11, 2020 at 8:02 PM Mark Brown <broonie@kernel.org> wrote:
>> On Wed, 9 Dec 2020 19:35:14 +0200, Tudor Ambarus wrote:
>>> Make sure the max_speed_hz of spi_device does not override
>>> the max_speed_hz of controller.
>>
>> Applied to
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
>>
>> Thanks!
>>
>> [1/1] spi: Limit the spi device max speed to controller's max speed
>> commit: 9326e4f1e5dd1a4410c429638d3c412b6fc17040
>
>> - if (!spi->max_speed_hz)
>> + if (!spi->max_speed_hz ||
>> + spi->max_speed_hz > spi->controller->max_speed_hz)
>> spi->max_speed_hz = spi->controller->max_speed_hz;
>
> If spi->controller->max_speed_hz is zero, a non-zero spi->max_speed_hz
> will be overwritten by zero.
>
oh, yes, you're right.
> Hence this broke spi-sh-msiof, which has the following check in
> sh_msiof_spi_set_clk_regs():
>
> if (!spi_hz || !parent_rate) {
> WARN(1, "Invalid clock rate parameters %lu and %u\n",
> parent_rate, spi_hz);
> return;
> }
>
> Without this, the driver would trigger a division-by-zero later...
>
> Arguably all SPI controller drivers should fill in
> spi_controller.{min,max}_speed_hz, but as long as that is not the case,
> I think this patch should be reverted, or the check should be enhanced
> to make sure spi->controller->max_speed_hz is non-zero.
>
I'm fine both ways, since this should be improved anyway. Will send a patch
with the non-zero check and add your Reported-by, Suggested-by tags, in case
Mark decides to keep it.
Cheers,
ta
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
>
prev parent reply other threads:[~2020-12-16 8:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-09 17:35 [PATCH] spi: Limit the spi device max speed to controller's max speed Tudor Ambarus
2020-12-09 19:46 ` Serge Semin
2020-12-09 19:54 ` Mark Brown
2020-12-09 20:15 ` Serge Semin
2020-12-09 20:25 ` Mark Brown
2020-12-09 20:30 ` Serge Semin
2020-12-10 8:58 ` Tudor.Ambarus
2020-12-10 15:33 ` Mark Brown
2020-12-10 16:32 ` Tudor.Ambarus
2020-12-10 18:16 ` Mark Brown
2020-12-11 17:51 ` Mark Brown
2020-12-15 14:24 ` Geert Uytterhoeven
2020-12-16 8:25 ` Tudor.Ambarus [this message]
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=b1b385eb-15f7-8347-a5e2-0a711937c879@microchip.com \
--to=tudor.ambarus@microchip.com \
--cc=broonie@kernel.org \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).