* Re: [PATCH for-next] spi: bcm53xx: add spi_flash_read callback for MMIO-based reads
[not found] ` <20160418112457.GU3217@sirena.org.uk>
@ 2016-04-18 11:38 ` Rafał Miłecki
2016-04-18 11:57 ` Mark Brown
2016-04-18 13:48 ` Vignesh R
0 siblings, 2 replies; 3+ messages in thread
From: Rafał Miłecki @ 2016-04-18 11:38 UTC (permalink / raw)
To: Mark Brown, linux-mtd@lists.infradead.org, Vignesh R,
Brian Norris
Cc: open list:SPI SUBSYSTEM, open list
On 18 April 2016 at 13:24, Mark Brown <broonie@kernel.org> wrote:
> On Mon, Apr 18, 2016 at 01:10:43PM +0200, Rafał Miłecki wrote:
>
>> +static int bcm53xxspi_flash_read(struct spi_device *spi,
>> + struct spi_flash_read_message *msg)
>> +{
>> + struct bcm53xxspi *b53spi = spi_master_get_devdata(spi->master);
>> + int ret = 0;
>> +
>> + bcm53xxspi_enable_bspi(b53spi);
>> + memcpy_fromio(msg->buf, b53spi->mmio_base + msg->from, msg->len);
>> + msg->retlen = msg->len;
>
> There's no bounds check here but...
That's true, I was looking at ti_qspi_spi_flash_read and somehow
incorrectly (!) assumed there is a check above. Of course there isn't
one and there can't be, I'll simply fix this code. I guess we should
fix ti_qspi_spi_flash_read in ti-qspi driver as well.
I also realized there wasn't any fallback introduced in:
mtd: devices: m25p80: add support for mmap read request
http://git.infradead.org/l2-mtd.git/commitdiff/08922f644878c9163ada8df3ef9def89be1d5e90
What shall we do if spi_flash_read fails? Should we always fallback to
the standard SPI flash read? Or should we standarize error codes
returned by spi_flash_read and fallback on some particular error code
only?
>> + if (core->addr_s[0])
>> + b53spi->mmio_base = devm_ioremap(dev, core->addr_s[0], SZ_32M);
>
> ...we only mapped 32M here. What if something tries to do a larger
> read? It's also a bit surprising that we're mapping a specific size
> here rather than the entire resource.
This is based on what I found in Broadcom's SDK (they don't release
any real specifications):
#define SI_NS_FLASH_WINDOW 0x02000000 /* Flash XIP Window */
--
Rafał
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH for-next] spi: bcm53xx: add spi_flash_read callback for MMIO-based reads
2016-04-18 11:38 ` [PATCH for-next] spi: bcm53xx: add spi_flash_read callback for MMIO-based reads Rafał Miłecki
@ 2016-04-18 11:57 ` Mark Brown
2016-04-18 13:48 ` Vignesh R
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2016-04-18 11:57 UTC (permalink / raw)
To: Rafał Miłecki
Cc: linux-mtd@lists.infradead.org, Vignesh R, Brian Norris,
open list:SPI SUBSYSTEM, open list
[-- Attachment #1: Type: text/plain, Size: 347 bytes --]
On Mon, Apr 18, 2016 at 01:38:28PM +0200, Rafał Miłecki wrote:
> What shall we do if spi_flash_read fails? Should we always fallback to
> the standard SPI flash read? Or should we standarize error codes
> returned by spi_flash_read and fallback on some particular error code
> only?
I'm not sure, probably just fall back all the time.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH for-next] spi: bcm53xx: add spi_flash_read callback for MMIO-based reads
2016-04-18 11:38 ` [PATCH for-next] spi: bcm53xx: add spi_flash_read callback for MMIO-based reads Rafał Miłecki
2016-04-18 11:57 ` Mark Brown
@ 2016-04-18 13:48 ` Vignesh R
1 sibling, 0 replies; 3+ messages in thread
From: Vignesh R @ 2016-04-18 13:48 UTC (permalink / raw)
To: Rafał Miłecki, Mark Brown,
linux-mtd@lists.infradead.org, Brian Norris
Cc: open list:SPI SUBSYSTEM, open list
On 04/18/2016 05:08 PM, Rafał Miłecki wrote:
> On 18 April 2016 at 13:24, Mark Brown <broonie@kernel.org> wrote:
>> On Mon, Apr 18, 2016 at 01:10:43PM +0200, Rafał Miłecki wrote:
>>
>>> +static int bcm53xxspi_flash_read(struct spi_device *spi,
>>> + struct spi_flash_read_message *msg)
>>> +{
>>> + struct bcm53xxspi *b53spi = spi_master_get_devdata(spi->master);
>>> + int ret = 0;
>>> +
>>> + bcm53xxspi_enable_bspi(b53spi);
>>> + memcpy_fromio(msg->buf, b53spi->mmio_base + msg->from, msg->len);
>>> + msg->retlen = msg->len;
>>
>> There's no bounds check here but...
>
> That's true, I was looking at ti_qspi_spi_flash_read and somehow
> incorrectly (!) assumed there is a check above. Of course there isn't
> one and there can't be, I'll simply fix this code. I guess we should
> fix ti_qspi_spi_flash_read in ti-qspi driver as well.
My assumption was controller will provide ability to map entire flash
under memory mapped region either in oneshot or in parts. It would be
odd to have some parts of flash accessible under memory mapped mode and
some only under SPI mode. Therefore there is no bound check in case of
ti-qspi(but I see is no harm in adding one. I will fix it up).
>
> I also realized there wasn't any fallback introduced in:
> mtd: devices: m25p80: add support for mmap read request
> http://git.infradead.org/l2-mtd.git/commitdiff/08922f644878c9163ada8df3ef9def89be1d5e90
>
> What shall we do if spi_flash_read fails? Should we always fallback to
> the standard SPI flash read? Or should we standarize error codes
> returned by spi_flash_read and fallback on some particular error code
> only?
>
spi_flash_read() can return error for incorrect protocol format
(opcode/data/address_nbits), this will fail anyways for normal SPI mode
as well. Else, its the error code returned by master->spi_flash_read()
callback (individual driver dependent). Not sure what can be
standardized here.
I think fallback would be to try SPI mode when ret!=-EINVAL.
--
Regards
Vignesh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-18 13:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1460977843-9426-1-git-send-email-zajec5@gmail.com>
[not found] ` <20160418112457.GU3217@sirena.org.uk>
2016-04-18 11:38 ` [PATCH for-next] spi: bcm53xx: add spi_flash_read callback for MMIO-based reads Rafał Miłecki
2016-04-18 11:57 ` Mark Brown
2016-04-18 13:48 ` Vignesh R
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).