linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Hu Mingkai-B21284 <B21284@freescale.com>
Cc: linuxppc-dev@ozlabs.org, Zang Roy-R61911 <R61911@freescale.com>
Subject: Re: [PATCH 4/6] mtd: m25p80: change the read function to read page by page
Date: Mon, 26 Jul 2010 01:55:08 -0600	[thread overview]
Message-ID: <AANLkTi=ehyX-u=5OwpY1AxMjDCc2LZaAfdSdLtuO3hYM@mail.gmail.com> (raw)
In-Reply-To: <73839B4A0818E747864426270AC332C305400642@zmy16exm20.fsl.freescale.net>

On Mon, Jul 26, 2010 at 1:33 AM, Hu Mingkai-B21284 <B21284@freescale.com> w=
rote:
>
>
>> -----Original Message-----
>> From: Grant Likely [mailto:glikely@secretlab.ca] On Behalf Of
>> Grant Likely
>> Sent: Monday, July 26, 2010 8:30 AM
>> To: Hu Mingkai-B21284
>> Cc: linuxppc-dev@ozlabs.org; galak@kernel.crashing.org; Zang
>> Roy-R61911
>> Subject: Re: [PATCH 4/6] mtd: m25p80: change the read
>> function to read page by page
>>
>> On Tue, Jul 20, 2010 at 10:08:23AM +0800, Mingkai Hu wrote:
>> > For Freescale's eSPI controller, the max transaction length
>> one time
>> > is limitted by the SPCOM[TRANSLEN] field which is 0x10000. When used
>> > mkfs.ext2 command to create ext2 filesystem on the flash, the read
>> > length will exceed the max value of the SPCOM[TRANSLEN] field, so
>> > change the read function to read page by page.
>> >
>> > For other SPI flash driver, also needed to change the read
>> function if
>> > used the eSPI controller.
>> >
>> > Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
>> > ---
>> > =A0drivers/mtd/devices/m25p80.c | =A0 18 ++++++++++++++----
>> > =A01 files changed, 14 insertions(+), 4 deletions(-)
>> >
>> > diff --git a/drivers/mtd/devices/m25p80.c
>> > b/drivers/mtd/devices/m25p80.c index 81e49a9..6cbe6b1 100644
>> > --- a/drivers/mtd/devices/m25p80.c
>> > +++ b/drivers/mtd/devices/m25p80.c
>> > @@ -317,6 +317,7 @@ static int m25p80_read(struct mtd_info
>> *mtd, loff_t from, size_t len,
>> > =A0 =A0 struct m25p *flash =3D mtd_to_m25p(mtd);
>> > =A0 =A0 struct spi_transfer t[2];
>> > =A0 =A0 struct spi_message m;
>> > + =A0 u32 i, page_size =3D 0;
>> >
>> > =A0 =A0 DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %zd\n",
>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_name(&flash->spi->dev), __=
func__,
>> "from", @@ -341,7 +342,6 @@
>> > static int m25p80_read(struct mtd_info *mtd, loff_t from,
>> size_t len,
>> > =A0 =A0 spi_message_add_tail(&t[0], &m);
>> >
>> > =A0 =A0 t[1].rx_buf =3D buf;
>> > - =A0 t[1].len =3D len;
>> > =A0 =A0 spi_message_add_tail(&t[1], &m);
>> >
>> > =A0 =A0 /* Byte count starts at zero. */
>> > @@ -364,11 +364,21 @@ static int m25p80_read(struct mtd_info *mtd,
>> > loff_t from, size_t len,
>> >
>> > =A0 =A0 /* Set up the write data buffer. */
>> > =A0 =A0 flash->command[0] =3D OPCODE_READ;
>> > - =A0 m25p_addr2cmd(flash, from, flash->command);
>> >
>> > - =A0 spi_sync(flash->spi, &m);
>> > + =A0 for (i =3D page_size; i < len; i +=3D page_size) {
>> > + =A0 =A0 =A0 =A0 =A0 page_size =3D len - i;
>> > + =A0 =A0 =A0 =A0 =A0 if (page_size > flash->page_size)
>> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 page_size =3D flash->page_size;
>> >
>> > - =A0 *retlen =3D m.actual_length - m25p_cmdsz(flash) -
>> FAST_READ_DUMMY_BYTE;
>> > + =A0 =A0 =A0 =A0 =A0 m25p_addr2cmd(flash, from + i, flash->command);
>> > + =A0 =A0 =A0 =A0 =A0 t[1].len =3D page_size;
>> > + =A0 =A0 =A0 =A0 =A0 t[1].rx_buf =3D buf + i;
>> > +
>> > + =A0 =A0 =A0 =A0 =A0 spi_sync(flash->spi, &m);
>> > +
>> > + =A0 =A0 =A0 =A0 =A0 *retlen +=3D m.actual_length - m25p_cmdsz(flash)
>> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 - FAST_READ_DUMMY_BYTE;
>> > + =A0 }
>>
>> This patch seems to cripple all users just because eSPI
>> cannot handle it. =A0Am I reading it wrong?
>>
>
> You're right, this will cripple all users.
>
> At first, I want to contain this specific code with CONFIG_SPI_FSL_ESPI
> option,
> or register a specific read function like:
>
> #ifdef CONFIG_SPI_FSL_ESPI
> =A0 =A0 =A0 =A0flash->mtd.read =3D m25p80_read_espi;
> #endif
>
> but this will make the code looks arguly,

And it is multiplatform-unfriendly.

> are there other ways?

You need to select the correct transfer behaviour at driver probe
time.  You'll need a way to indicate that the spi_master isn't able to
handle your transfer request.  I'd need to think about it more to come
up with a concrete suggestion.

g.

  reply	other threads:[~2010-07-26  7:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-20  2:08 [PATCH 0/6] refactor spi_mpc8xxx.c and add eSPI controller support Mingkai Hu
2010-07-20  2:08 ` [PATCH 1/6] spi/mpc8xxx: refactor the common code for SPI/eSPI controller Mingkai Hu
2010-07-20  2:08   ` [PATCH 2/6] eSPI: add eSPI controller support Mingkai Hu
2010-07-20  2:08     ` [PATCH 3/6] of/spi: add support to parse the SPI flash's partitions Mingkai Hu
2010-07-20  2:08       ` [PATCH 4/6] mtd: m25p80: change the read function to read page by page Mingkai Hu
2010-07-20  2:08         ` [PATCH 5/6] powerpc/of: add eSPI controller dts bindings Mingkai Hu
2010-07-20  2:08           ` [PATCH 6/6] DTS: add SPI flash(s25fl128p01) support on p4080ds and mpc8536ds board Mingkai Hu
2010-07-26  0:35             ` Grant Likely
2010-07-26  7:39               ` Hu Mingkai-B21284
2010-07-26  7:59                 ` Grant Likely
2010-07-26  0:33           ` [PATCH 5/6] powerpc/of: add eSPI controller dts bindings Grant Likely
2010-07-26  7:35             ` Hu Mingkai-B21284
2010-07-26  0:30         ` [PATCH 4/6] mtd: m25p80: change the read function to read page by page Grant Likely
2010-07-26  7:33           ` Hu Mingkai-B21284
2010-07-26  7:55             ` Grant Likely [this message]
2010-07-26  0:28       ` [PATCH 3/6] of/spi: add support to parse the SPI flash's partitions Grant Likely
2010-07-26  7:25         ` Hu Mingkai-B21284
2010-07-26  7:52           ` Grant Likely
2010-07-26  8:20             ` Hu Mingkai-B21284
2010-07-27 19:24               ` Grant Likely
2010-07-26  0:25     ` [PATCH 2/6] eSPI: add eSPI controller support Grant Likely
2010-07-26  7:02       ` Hu Mingkai-B21284
2010-07-26  0:14   ` [PATCH 1/6] spi/mpc8xxx: refactor the common code for SPI/eSPI controller Grant Likely
2010-07-26  6:18     ` Hu Mingkai-B21284
2010-07-26  6:48       ` Grant Likely
2010-07-26  7:07     ` Zang Roy-R61911
2010-07-26  7:45       ` Grant Likely
2010-07-26  0:36 ` [PATCH 0/6] refactor spi_mpc8xxx.c and add eSPI controller support Grant Likely
2010-07-26  5:52   ` Hu Mingkai-B21284

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='AANLkTi=ehyX-u=5OwpY1AxMjDCc2LZaAfdSdLtuO3hYM@mail.gmail.com' \
    --to=grant.likely@secretlab.ca \
    --cc=B21284@freescale.com \
    --cc=R61911@freescale.com \
    --cc=linuxppc-dev@ozlabs.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).