[U-Boot] [PATCH 2/2] EXYNOS: SPI: Support SPI_PREAMBLE mode
[the original patch removed] So, I spent some more time debugging a system which requires this patch: a system, where on a SPI interface a response to a command could come way later then the command data transmission completes. The original patch was trying to address many corner cases, but come to think of it, in this situation the slave does not care about extra data sent on the transmit interface, as otherwise there is no clock and no data could be transferred from the slave. Then, for this SPI interface we do not need to set the counter of clocks, and do not need to keep adding more clocks if the data has not been received yet, the clocks could be just free running. And then the patch becomes much simpler, what do you think: diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index c697db8..fff8310 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -211,10 +211,10 @@ static void spi_get_fifo_levels(struct exynos_spi *regs, */ static void spi_request_bytes(struct exynos_spi *regs, int count) { - assert(count && count < (1 << 16)); setbits_le32(®s->ch_cfg, SPI_CH_RST); clrbits_le32(®s->ch_cfg, SPI_CH_RST); - writel(count | SPI_PACKET_CNT_EN, ®s->pkt_cnt); + if (count) + writel(count | SPI_PACKET_CNT_EN, ®s->pkt_cnt); } static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, @@ -225,14 +225,20 @@ static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, const uchar *txp = *doutp; int rx_lvl, tx_lvl; uint out_bytes, in_bytes; - + int hunting; + + if (spi_slave->free_running_mode) { + spi_request_bytes(regs, 0); + hunting = 1; + } else { + hunting = 0; + spi_request_bytes(regs, todo); + } out_bytes = in_bytes = todo; - /* -* If there's something to send, do a software reset and set a -* transaction size. -*/ - spi_request_bytes(regs, todo); + /* Software reset the channel. */ + setbits_le32(®s->ch_cfg, SPI_CH_RST); + clrbits_le32(®s->ch_cfg, SPI_CH_RST); /* * Bytes are transmitted/received in pairs. Wait to receive all the @@ -243,13 +249,23 @@ static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, /* Keep the fifos full/empty. */ spi_get_fifo_levels(regs, &rx_lvl, &tx_lvl); - if (tx_lvl < spi_slave->fifo_size && out_bytes) { - temp = txp ? *txp++ : 0xff; + if (tx_lvl < spi_slave->fifo_size) { + if (txp && out_bytes) { + temp = *txp++; + out_bytes--; + } else { + temp = 0xff; + } writel(temp, ®s->tx_data); - out_bytes--; } if (rx_lvl > 0 && in_bytes) { temp = readl(®s->rx_data); + if (hunting) { + if ((temp & 0xff) != PREAMBLE_VALUE) + continue; + else + hunting = 0; + } if (rxp) *rxp++ = temp; in_bytes--; ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/2] EXYNOS: SPI: Support SPI_PREAMBLE mode
Support interfaces with a preamble before each received message. We handle this when the client has requested a SPI_XFER_END, meaning that we must close of the transaction. In this case we read until we see the preamble (or a timeout occurs), skipping all data before and including the preamble. The client will receive only data bytes after the preamble. Signed-off-by: Simon Glass Signed-off-by: Rajeshwari Shinde --- drivers/spi/exynos_spi.c | 62 -- 1 files changed, 54 insertions(+), 8 deletions(-) diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index be60ada..09e88d5 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -51,6 +51,7 @@ struct exynos_spi_slave { unsigned int mode; enum periph_id periph_id; /* Peripheral ID for this device */ unsigned int fifo_size; + int skip_preamble; }; static struct spi_bus *spi_get_bus(unsigned dev_index) @@ -107,6 +108,8 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs, else spi_slave->fifo_size = 256; + spi_slave->skip_preamble = 0; + spi_slave->freq = bus->frequency; if (max_hz) spi_slave->freq = min(max_hz, spi_slave->freq); @@ -219,17 +222,23 @@ static void spi_request_bytes(struct exynos_spi *regs, int count) writel(count | SPI_PACKET_CNT_EN, ®s->pkt_cnt); } -static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, - void **dinp, void const **doutp) +static int spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, + void **dinp, void const **doutp, unsigned long flags) { struct exynos_spi *regs = spi_slave->regs; uchar *rxp = *dinp; const uchar *txp = *doutp; int rx_lvl, tx_lvl; uint out_bytes, in_bytes; + int toread, preamable_count = 0; + unsigned start = get_timer(0); + int stopping; out_bytes = in_bytes = todo; + stopping = spi_slave->skip_preamble && (flags & SPI_XFER_END) && + !(spi_slave->mode & SPI_SLAVE); + /* * If there's something to send, do a software reset and set a * transaction size. @@ -240,6 +249,7 @@ static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, * Bytes are transmitted/received in pairs. Wait to receive all the * data because then transmission will be done as well. */ + toread = in_bytes; while (in_bytes) { int temp; @@ -252,13 +262,41 @@ static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, } if (rx_lvl > 0 && in_bytes) { temp = readl(®s->rx_data); - if (rxp) + if (!rxp && !stopping) { + in_bytes--; + } else if (spi_slave->skip_preamble) { + if (temp == SPI_PREAMBLE_END_BYTE) { + spi_slave->skip_preamble = 0; + stopping = 0; + } + } else { *rxp++ = temp; - in_bytes--; + in_bytes--; + } + toread--; + } + /* +* We have run out of input data, but haven't read enough +* bytes after the preamble yet. Read some more, and make +* sure that we transmit dummy bytes too, to keep things +* going. +*/ + else if (in_bytes && !toread) { + assert(!out_bytes); + toread = out_bytes = in_bytes; + txp = NULL; + spi_request_bytes(regs, toread); + } + if (spi_slave->skip_preamble && get_timer(start) > 100) { + printf("SPI timeout: in_bytes=%d, out_bytes=%d, ", + in_bytes, out_bytes); + printf("count = %d\n", preamable_count); + return -1; } } *dinp = rxp; *doutp = txp; + return 0; } /** @@ -278,6 +316,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, struct exynos_spi_slave *spi_slave = to_exynos_spi(slave); int upto, todo; int bytelen; + int ret = 0; /* spi core configured to do 8 bit transfers */ if (bitlen % 8) { @@ -291,16 +330,22 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, /* Exynos SPI limits each transfer to 65535 bytes */ bytelen = bitlen / 8; - for (upto = 0; upto < bytelen; upto += todo) { +
Re: [U-Boot] [PATCH 2/2] EXYNOS: SPI: Support SPI_PREAMBLE mode
On Thu, Mar 21, 2013 at 11:29 PM, Rajeshwari Shinde wrote: > Support interfaces with a preamble before each received message. > > We handle this when the client has requested a SPI_XFER_END, meaning > that we must close of the transaction. In this case we read until we > see the preamble (or a timeout occurs), skipping all data before and > including the preamble. The client will receive only data bytes after > the preamble. > > Signed-off-by: Simon Glass > Signed-off-by: Rajeshwari Shinde > --- > drivers/spi/exynos_spi.c | 62 > -- > 1 files changed, 54 insertions(+), 8 deletions(-) > > diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c > index be60ada..09e88d5 100644 > --- a/drivers/spi/exynos_spi.c > +++ b/drivers/spi/exynos_spi.c > @@ -51,6 +51,7 @@ struct exynos_spi_slave { > unsigned int mode; > enum periph_id periph_id; /* Peripheral ID for this device */ > unsigned int fifo_size; > + int skip_preamble; > }; > > static struct spi_bus *spi_get_bus(unsigned dev_index) > @@ -107,6 +108,8 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, > unsigned int cs, > else > spi_slave->fifo_size = 256; > > + spi_slave->skip_preamble = 0; > + > spi_slave->freq = bus->frequency; > if (max_hz) > spi_slave->freq = min(max_hz, spi_slave->freq); > @@ -219,17 +222,23 @@ static void spi_request_bytes(struct exynos_spi *regs, > int count) > writel(count | SPI_PACKET_CNT_EN, ®s->pkt_cnt); > } > > -static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, > - void **dinp, void const **doutp) > +static int spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, > + void **dinp, void const **doutp, unsigned long flags) > { > struct exynos_spi *regs = spi_slave->regs; > uchar *rxp = *dinp; > const uchar *txp = *doutp; > int rx_lvl, tx_lvl; > uint out_bytes, in_bytes; > + int toread, preamable_count = 0; preamable_count: the name is misspelled, and the variable is never modified. > + unsigned start = get_timer(0); > + int stopping; > > out_bytes = in_bytes = todo; > > + stopping = spi_slave->skip_preamble && (flags & SPI_XFER_END) && > + !(spi_slave->mode & SPI_SLAVE); > + > /* > * If there's something to send, do a software reset and set a > * transaction size. > @@ -240,6 +249,7 @@ static void spi_rx_tx(struct exynos_spi_slave *spi_slave, > int todo, > * Bytes are transmitted/received in pairs. Wait to receive all the > * data because then transmission will be done as well. > */ > + toread = in_bytes; > while (in_bytes) { > int temp; > > @@ -252,13 +262,41 @@ static void spi_rx_tx(struct exynos_spi_slave > *spi_slave, int todo, > } > if (rx_lvl > 0 && in_bytes) { > temp = readl(®s->rx_data); > - if (rxp) > + if (!rxp && !stopping) { > + in_bytes--; > + } else if (spi_slave->skip_preamble) { > + if (temp == SPI_PREAMBLE_END_BYTE) { > + spi_slave->skip_preamble = 0; > + stopping = 0; > + } > + } else { > *rxp++ = temp; > - in_bytes--; > + in_bytes--; > + } > + toread--; > + } > + /* > +* We have run out of input data, but haven't read enough > +* bytes after the preamble yet. Read some more, and make > +* sure that we transmit dummy bytes too, to keep things > +* going. > +*/ > + else if (in_bytes && !toread) { > + assert(!out_bytes); > + toread = out_bytes = in_bytes; > + txp = NULL; > + spi_request_bytes(regs, toread); > + } > + if (spi_slave->skip_preamble && get_timer(start) > 100) { > + printf("SPI timeout: in_bytes=%d, out_bytes=%d, ", > + in_bytes, out_bytes); > + printf("count = %d\n", preamable_count); > + return -1; > } > } > *dinp = rxp; > *doutp = txp; > + return 0; > } > > /** > @@ -278,6 +316,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int > bitlen, const void *dout, > struct exynos_spi_slave *spi_slave = to_exynos_spi(slave); > int upto, todo; > int
Re: [U-Boot] [PATCH 2/2] EXYNOS: SPI: Support SPI_PREAMBLE mode
[the original patch removed, re-sending from a registered address] So, I spent some more time debugging a system which requires this patch: a system, where on a SPI interface a response to a command could come way later then the command data transmission completes. The original patch was trying to address many corner cases, but come to think of it, in this situation the slave does not care about extra data sent on the transmit interface, as otherwise there is no clock and no data could be transferred from the slave. Then, for this SPI interface we do not need to set the counter of clocks, and do not need to keep adding more clocks if the data has not been received yet, the clocks could be just free running. And then the patch becomes much simpler, what do you think: diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index c697db8..fff8310 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -211,10 +211,10 @@ static void spi_get_fifo_levels(struct exynos_spi *regs, */ static void spi_request_bytes(struct exynos_spi *regs, int count) { - assert(count && count < (1 << 16)); setbits_le32(®s->ch_cfg, SPI_CH_RST); clrbits_le32(®s->ch_cfg, SPI_CH_RST); - writel(count | SPI_PACKET_CNT_EN, ®s->pkt_cnt); + if (count) + writel(count | SPI_PACKET_CNT_EN, ®s->pkt_cnt); } static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, @@ -225,14 +225,20 @@ static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, const uchar *txp = *doutp; int rx_lvl, tx_lvl; uint out_bytes, in_bytes; - + int hunting; + + if (spi_slave->free_running_mode) { + spi_request_bytes(regs, 0); + hunting = 1; + } else { + hunting = 0; + spi_request_bytes(regs, todo); + } out_bytes = in_bytes = todo; - /* -* If there's something to send, do a software reset and set a -* transaction size. -*/ - spi_request_bytes(regs, todo); + /* Software reset the channel. */ + setbits_le32(®s->ch_cfg, SPI_CH_RST); + clrbits_le32(®s->ch_cfg, SPI_CH_RST); /* * Bytes are transmitted/received in pairs. Wait to receive all the @@ -243,13 +249,23 @@ static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, /* Keep the fifos full/empty. */ spi_get_fifo_levels(regs, &rx_lvl, &tx_lvl); - if (tx_lvl < spi_slave->fifo_size && out_bytes) { - temp = txp ? *txp++ : 0xff; + if (tx_lvl < spi_slave->fifo_size) { + if (txp && out_bytes) { + temp = *txp++; + out_bytes--; + } else { + temp = 0xff; + } writel(temp, ®s->tx_data); - out_bytes--; } if (rx_lvl > 0 && in_bytes) { temp = readl(®s->rx_data); + if (hunting) { + if ((temp & 0xff) != PREAMBLE_VALUE) + continue; + else + hunting = 0; + } if (rxp) *rxp++ = temp; in_bytes--; ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] EXYNOS: SPI: Support SPI_PREAMBLE mode
Hi Vadim, On Thu, May 2, 2013 at 7:28 PM, Vadim Bendebury wrote: > On Thu, Mar 21, 2013 at 11:29 PM, Rajeshwari Shinde > wrote: >> Support interfaces with a preamble before each received message. >> >> We handle this when the client has requested a SPI_XFER_END, meaning >> that we must close of the transaction. In this case we read until we >> see the preamble (or a timeout occurs), skipping all data before and >> including the preamble. The client will receive only data bytes after >> the preamble. >> >> Signed-off-by: Simon Glass >> Signed-off-by: Rajeshwari Shinde >> --- >> drivers/spi/exynos_spi.c | 62 >> -- >> 1 files changed, 54 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c >> index be60ada..09e88d5 100644 >> --- a/drivers/spi/exynos_spi.c >> +++ b/drivers/spi/exynos_spi.c >> @@ -51,6 +51,7 @@ struct exynos_spi_slave { >> unsigned int mode; >> enum periph_id periph_id; /* Peripheral ID for this device */ >> unsigned int fifo_size; >> + int skip_preamble; >> }; >> >> static struct spi_bus *spi_get_bus(unsigned dev_index) >> @@ -107,6 +108,8 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, >> unsigned int cs, >> else >> spi_slave->fifo_size = 256; >> >> + spi_slave->skip_preamble = 0; >> + >> spi_slave->freq = bus->frequency; >> if (max_hz) >> spi_slave->freq = min(max_hz, spi_slave->freq); >> @@ -219,17 +222,23 @@ static void spi_request_bytes(struct exynos_spi *regs, >> int count) >> writel(count | SPI_PACKET_CNT_EN, ®s->pkt_cnt); >> } >> >> -static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, >> - void **dinp, void const **doutp) >> +static int spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, >> + void **dinp, void const **doutp, unsigned long flags) >> { >> struct exynos_spi *regs = spi_slave->regs; >> uchar *rxp = *dinp; >> const uchar *txp = *doutp; >> int rx_lvl, tx_lvl; >> uint out_bytes, in_bytes; >> + int toread, preamable_count = 0; > > preamable_count: the name is misspelled, and the variable is never modified. > >> + unsigned start = get_timer(0); >> + int stopping; >> >> out_bytes = in_bytes = todo; >> >> + stopping = spi_slave->skip_preamble && (flags & SPI_XFER_END) && >> + !(spi_slave->mode & SPI_SLAVE); >> + >> /* >> * If there's something to send, do a software reset and set a >> * transaction size. >> @@ -240,6 +249,7 @@ static void spi_rx_tx(struct exynos_spi_slave >> *spi_slave, int todo, >> * Bytes are transmitted/received in pairs. Wait to receive all the >> * data because then transmission will be done as well. >> */ >> + toread = in_bytes; >> while (in_bytes) { >> int temp; >> >> @@ -252,13 +262,41 @@ static void spi_rx_tx(struct exynos_spi_slave >> *spi_slave, int todo, >> } >> if (rx_lvl > 0 && in_bytes) { >> temp = readl(®s->rx_data); >> - if (rxp) >> + if (!rxp && !stopping) { >> + in_bytes--; >> + } else if (spi_slave->skip_preamble) { >> + if (temp == SPI_PREAMBLE_END_BYTE) { >> + spi_slave->skip_preamble = 0; >> + stopping = 0; >> + } >> + } else { >> *rxp++ = temp; >> - in_bytes--; >> + in_bytes--; >> + } >> + toread--; >> + } >> + /* >> +* We have run out of input data, but haven't read enough >> +* bytes after the preamble yet. Read some more, and make >> +* sure that we transmit dummy bytes too, to keep things >> +* going. >> +*/ >> + else if (in_bytes && !toread) { >> + assert(!out_bytes); >> + toread = out_bytes = in_bytes; >> + txp = NULL; >> + spi_request_bytes(regs, toread); >> + } >> + if (spi_slave->skip_preamble && get_timer(start) > 100) { >> + printf("SPI timeout: in_bytes=%d, out_bytes=%d, ", >> + in_bytes, out_bytes); >> + printf("count = %d\n", preamable_count); >> + return -1; >> } >> } >> *dinp = rxp; >> *doutp = txp; >> + return 0; >> } >> >> /** >> @@ -278,6 +316,
Re: [U-Boot] [PATCH 2/2] EXYNOS: SPI: Support SPI_PREAMBLE mode
HI Vadim, On Thu, May 2, 2013 at 11:12 PM, Vadim Bendebury wrote: > [the original patch removed, re-sending from a registered address] > > So, I spent some more time debugging a system which requires this > patch: a system, where on a SPI interface a response to a command > could come way later then the command data transmission completes. > > The original patch was trying to address many corner cases, but come > to think of it, in this situation the slave does not care about extra > data sent on the transmit interface, as otherwise there is no clock > and no data could be transferred from the slave. > > Then, for this SPI interface we do not need to set the counter of > clocks, and do not need to keep adding more clocks if the data has not > been received yet, the clocks could be just free running. And then the > patch becomes much simpler, what do you think: Does this deal with the performance problems that the old driver code had? There were a number of other patches sent upstream by Rajeshwari also. I wonder if it might be easier to do your improvement as a separate patch on top of those instead. Then it can be considered on its merits. Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] EXYNOS: SPI: Support SPI_PREAMBLE mode
On Mon, May 6, 2013 at 7:37 AM, Simon Glass wrote: > > HI Vadim, > > On Thu, May 2, 2013 at 11:12 PM, Vadim Bendebury wrote: > > [the original patch removed, re-sending from a registered address] > > > > So, I spent some more time debugging a system which requires this > > patch: a system, where on a SPI interface a response to a command > > could come way later then the command data transmission completes. > > > > The original patch was trying to address many corner cases, but come > > to think of it, in this situation the slave does not care about extra > > data sent on the transmit interface, as otherwise there is no clock > > and no data could be transferred from the slave. > > > > Then, for this SPI interface we do not need to set the counter of > > clocks, and do not need to keep adding more clocks if the data has not > > been received yet, the clocks could be just free running. And then the > > patch becomes much simpler, what do you think: > > Does this deal with the performance problems that the old driver code > had? There were a number of other patches sent upstream by Rajeshwari > also. I wonder if it might be easier to do your improvement as a > separate patch on top of those instead. Then it can be considered on > its merits. > Hi Simon, what performance problems are there? Do you mean that u-boot is not fast enough when polling the SPI interface? I thought about this - even when clocking at 50MHz (resulting in 6.125 MB/s transfer rate) with 64 byte FIFOs there should be no problem when serving the interface, especially when receive and transmit flows are split in time. Have there been any evidence of performance problems? Also, I noticed that the driver does not pay any respect to error conditions. I am planning to add error monitoring/processing code, as this would be a good way to know if there indeed are performance problems. cheers, --vb > Regards, > Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] EXYNOS: SPI: Support SPI_PREAMBLE mode
Hi, On Thu, May 2, 2013 at 7:28 PM, Vadim Bendebury wrote: > On Thu, Mar 21, 2013 at 11:29 PM, Rajeshwari Shinde > wrote: >> Support interfaces with a preamble before each received message. >> >> We handle this when the client has requested a SPI_XFER_END, meaning >> that we must close of the transaction. In this case we read until we >> see the preamble (or a timeout occurs), skipping all data before and >> including the preamble. The client will receive only data bytes after >> the preamble. >> >> Signed-off-by: Simon Glass >> Signed-off-by: Rajeshwari Shinde >> --- >> drivers/spi/exynos_spi.c | 62 >> -- >> 1 files changed, 54 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c >> index be60ada..09e88d5 100644 >> --- a/drivers/spi/exynos_spi.c >> +++ b/drivers/spi/exynos_spi.c >> @@ -51,6 +51,7 @@ struct exynos_spi_slave { >> unsigned int mode; >> enum periph_id periph_id; /* Peripheral ID for this device */ >> unsigned int fifo_size; >> + int skip_preamble; >> }; >> >> static struct spi_bus *spi_get_bus(unsigned dev_index) >> @@ -107,6 +108,8 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, >> unsigned int cs, >> else >> spi_slave->fifo_size = 256; >> >> + spi_slave->skip_preamble = 0; >> + >> spi_slave->freq = bus->frequency; >> if (max_hz) >> spi_slave->freq = min(max_hz, spi_slave->freq); >> @@ -219,17 +222,23 @@ static void spi_request_bytes(struct exynos_spi *regs, >> int count) >> writel(count | SPI_PACKET_CNT_EN, ®s->pkt_cnt); >> } >> >> -static void spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, >> - void **dinp, void const **doutp) >> +static int spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo, >> + void **dinp, void const **doutp, unsigned long flags) >> { >> struct exynos_spi *regs = spi_slave->regs; >> uchar *rxp = *dinp; >> const uchar *txp = *doutp; >> int rx_lvl, tx_lvl; >> uint out_bytes, in_bytes; >> + int toread, preamable_count = 0; > > preamable_count: the name is misspelled, and the variable is never modified. Yes, it is supposed to count the number of bytes before the preamble, in the event of an error, but it isn't really needed. I will resend the patch with it removed. Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] EXYNOS: SPI: Support SPI_PREAMBLE mode
Hi Vadim, On Mon, May 6, 2013 at 10:01 AM, Vadim Bendebury wrote: > On Mon, May 6, 2013 at 7:37 AM, Simon Glass wrote: >> >> HI Vadim, >> >> On Thu, May 2, 2013 at 11:12 PM, Vadim Bendebury >> wrote: >> > [the original patch removed, re-sending from a registered address] >> > >> > So, I spent some more time debugging a system which requires this >> > patch: a system, where on a SPI interface a response to a command >> > could come way later then the command data transmission completes. >> > >> > The original patch was trying to address many corner cases, but come >> > to think of it, in this situation the slave does not care about extra >> > data sent on the transmit interface, as otherwise there is no clock >> > and no data could be transferred from the slave. >> > >> > Then, for this SPI interface we do not need to set the counter of >> > clocks, and do not need to keep adding more clocks if the data has not >> > been received yet, the clocks could be just free running. And then the >> > patch becomes much simpler, what do you think: >> >> Does this deal with the performance problems that the old driver code >> had? There were a number of other patches sent upstream by Rajeshwari >> also. I wonder if it might be easier to do your improvement as a >> separate patch on top of those instead. Then it can be considered on >> its merits. >> > > Hi Simon, > > what performance problems are there? Do you mean that u-boot is not > fast enough when polling the SPI interface? I thought about this - > even when clocking at 50MHz (resulting in 6.125 MB/s transfer rate) > with 64 byte FIFOs there should be no problem when serving the > interface, especially when receive and transmit flows are split in > time. > > Have there been any evidence of performance problems? Also, I noticed > that the driver does not pay any respect to error conditions. I am > planning to add error monitoring/processing code, as this would be a > good way to know if there indeed are performance problems. The issue is not the hardware but the software. Yes the hardware is well able to keep up, but it does have some oddities. For example reading the FIFO level registers seems to take a while, as does reading/writing data to the FIFO. I did a bit of benchmarking comparing the original upstream driver with the driver after Rajeshwari's patches are applied. I posted that to the list earlier today, but roughly speaking it is 100x faster, and SPI boot time is reduced by about half a second. Unfortunately it is a bit more complicated, but it is reliable and the code is well tested with lots of units in the field :-) Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot