2015-12-01 23:13:18

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v5 08/10] spi: expose master transfer size limitation.

On Tue, Dec 01, 2015 at 04:51:06PM -0000, Michal Suchanek wrote:

> +static inline size_t
> +spi_max_transfer_size(struct spi_device *spi)
> +{
> + struct spi_master *master = spi->master;
> + if (!master->max_transfer_size)
> + return 0;
> + return master->max_transfer_size(spi);
> +}

Can we change this to return SIZE_MAX instead (ie, the maximum value for
a size_t)? That way callers don't need to worry if there is a limit, if
they want to handle it they can just unconditionally assume that a limit
will be provided.


Attachments:
(No filename) (526.00 B)
signature.asc (473.00 B)
Download all attachments

2015-12-02 09:39:40

by Michal Suchanek

[permalink] [raw]
Subject: Re: [PATCH v5 08/10] spi: expose master transfer size limitation.

On 2 December 2015 at 00:12, Mark Brown <[email protected]> wrote:
> On Tue, Dec 01, 2015 at 04:51:06PM -0000, Michal Suchanek wrote:
>
>> +static inline size_t
>> +spi_max_transfer_size(struct spi_device *spi)
>> +{
>> + struct spi_master *master = spi->master;
>> + if (!master->max_transfer_size)
>> + return 0;
>> + return master->max_transfer_size(spi);
>> +}
>
> Can we change this to return SIZE_MAX instead (ie, the maximum value for
> a size_t)? That way callers don't need to worry if there is a limit, if
> they want to handle it they can just unconditionally assume that a limit
> will be provided.

Yes, that sounds reasonable.

Thanks

Michal

2015-12-04 14:30:55

by Martin Sperl

[permalink] [raw]
Subject: Re: [PATCH v5 08/10] spi: expose master transfer size limitation.


> On 02.12.2015, at 00:12, Mark Brown <[email protected]> wrote:
>
> On Tue, Dec 01, 2015 at 04:51:06PM -0000, Michal Suchanek wrote:
>
>> +static inline size_t
>> +spi_max_transfer_size(struct spi_device *spi)
>> +{
>> + struct spi_master *master = spi->master;
>> + if (!master->max_transfer_size)
>> + return 0;
>> + return master->max_transfer_size(spi);
>> +}
>
> Can we change this to return SIZE_MAX instead (ie, the maximum value for
> a size_t)? That way callers don't need to worry if there is a limit, if
> they want to handle it they can just unconditionally assume that a limit
> will be provided.

As I just came across: spi_master.max_dma_len, so I wonder how this
value would differ from the proposed spi_master.max_transfer_size
on specific HW?

For all practical purposes I would assume both are identical.

Martin

2015-12-04 16:46:13

by Michal Suchanek

[permalink] [raw]
Subject: Re: [PATCH v5 08/10] spi: expose master transfer size limitation.

On 4 December 2015 at 15:30, Martin Sperl <[email protected]> wrote:
>
>> On 02.12.2015, at 00:12, Mark Brown <[email protected]> wrote:
>>
>> On Tue, Dec 01, 2015 at 04:51:06PM -0000, Michal Suchanek wrote:
>>
>>> +static inline size_t
>>> +spi_max_transfer_size(struct spi_device *spi)
>>> +{
>>> + struct spi_master *master = spi->master;
>>> + if (!master->max_transfer_size)
>>> + return 0;
>>> + return master->max_transfer_size(spi);
>>> +}
>>
>> Can we change this to return SIZE_MAX instead (ie, the maximum value for
>> a size_t)? That way callers don't need to worry if there is a limit, if
>> they want to handle it they can just unconditionally assume that a limit
>> will be provided.
>
> As I just came across: spi_master.max_dma_len, so I wonder how this
> value would differ from the proposed spi_master.max_transfer_size
> on specific HW?
>
> For all practical purposes I would assume both are identical.

They aren't.

Some SPI masters don't use DMA. Some SPI master drivers can drive CS
manually so they can glue multiple DMA (or whatever) transfers into
single logical SPI transfer transparently. And some cannot. Hence this
limit.

That said I don't know what is the purpose of spi_master.max_dma_len.
It is seldom used. It seems to be used as a hint for the DMA buffer
size in spi.c only.

It is set in 3 drivers.

Thanks

Michal

2015-12-07 20:18:58

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v5 08/10] spi: expose master transfer size limitation.

On Fri, Dec 04, 2015 at 03:30:50PM +0100, Martin Sperl wrote:
> > On 02.12.2015, at 00:12, Mark Brown <[email protected]> wrote:

> > Can we change this to return SIZE_MAX instead (ie, the maximum value for
> > a size_t)? That way callers don't need to worry if there is a limit, if
> > they want to handle it they can just unconditionally assume that a limit
> > will be provided.

> As I just came across: spi_master.max_dma_len, so I wonder how this
> value would differ from the proposed spi_master.max_transfer_size
> on specific HW?

> For all practical purposes I would assume both are identical.

Yeah, we should probably just remove the DMA specific one in time though
it may be useful for some devices with built in DMA engines if they're
oddly limited I'm not sure how practical their DMA would be if it
differed from the overall transfer length.


Attachments:
(No filename) (861.00 B)
signature.asc (473.00 B)
Download all attachments