All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Jonas Gorski <jonas.gorski@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>,
	Herve Codina <herve.codina@bootlin.com>,
	Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>,
	"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH] spi: Raise limit on number of chip selects
Date: Tue, 23 Jan 2024 09:47:17 -0800	[thread overview]
Message-ID: <801eecbe-4bf9-4bb8-9de0-1a7ca6673ddf@roeck-us.net> (raw)
In-Reply-To: <CAOiHx==FzSyyqP3NzLTeOSVxUQYy3ZhypZrDLsc-OjGCdSzvUA@mail.gmail.com>

On 1/23/24 08:50, Jonas Gorski wrote:
> Hi,
> 
> On Tue, 23 Jan 2024 at 14:56, Mark Brown <broonie@kernel.org> wrote:
>>
>> On Tue, Jan 23, 2024 at 01:26:04PM +0000, Christophe Leroy wrote:
>>> Le 23/01/2024 à 14:18, Mark Brown a écrit :
>>>> On Tue, Jan 23, 2024 at 12:04:30PM +0100, Herve Codina wrote:
>>
>>>>> Moving the SPI_CS_CNT_MAX value from 4 to 8 is not enough to handle my case.
>>>>> Tested moving SPI_CS_CNT_MAX to 16 and it was ok.
>>
>>>> OK, I've also heard 12 as a number which this would cover.
>>
>>> By the way the comment in include/linux/spi/spi.h is confusing. This
>>> SPI_CS_CNT_MAX is really not the max number of CS supported per SPI
>>> device but the max number of CS supported per SPI controller.
>>
>> Well, it's a combination of the comment being confusing and the
>> implementation being a bit broken - we simply shouldn't be limiting the
>> number of chip selects per controller, the per device limit is much more
>> reasonable.  So ideally the code would be changed to reflect the
>> comment.
> 
> At a first glance at all places using SPI_CS_CNT_MAX I don't see
> anything being broken / reading out of bounds if a controller has more
> chipselects than SPI_CS_CNT_MAX.
> 
> So I think the check of ctrl->num_chipselect in of_spi_parse_dt() is
> bogus/unnecessary and is in the wrong place, as this is for parsing a
> spi device node and not a controller node. The following check for the
> amount of chip selects defined for the spi device should just check
> against SPI_CS_CNT_MAX instead of ctrl->num_chipselects.
> __spi_add_device() later will ensure that any chip selects are valid
> chip selects, so no need for of_spi_parse_dt() to check that either.
> 
> But I didn't do a very thorough read, or even tested it, so I might
> have easily missed something.
> 

struct spi_controller {
	...
	char                            last_cs[SPI_CS_CNT_MAX];

does introduce the limit for controllers.

Guenter


  reply	other threads:[~2024-01-23 17:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22  1:21 [PATCH] spi: Raise limit on number of chip selects Mark Brown
2024-01-22 22:07 ` Mark Brown
2024-01-23 11:04 ` Herve Codina
2024-01-23 13:18   ` Mark Brown
2024-01-23 13:26     ` Christophe Leroy
2024-01-23 13:53       ` Mark Brown
2024-01-23 16:50         ` Jonas Gorski
2024-01-23 17:47           ` Guenter Roeck [this message]
2024-01-24 13:41             ` Jonas Gorski
2024-01-24 14:35               ` David Laight
2024-01-24 14:59               ` Mark Brown
2024-01-24 15:28                 ` Christophe Leroy
2024-01-24 16:08                   ` Mark Brown

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=801eecbe-4bf9-4bb8-9de0-1a7ca6673ddf@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=amit.kumar-mahapatra@amd.com \
    --cc=broonie@kernel.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=herve.codina@bootlin.com \
    --cc=jonas.gorski@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.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 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.