Hello build bot (Jenkins), Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/40477
to look at the new patch set (#20).
Change subject: ft2232_spi.c: Add ft2232_spi_send_multicommand()
......................................................................
ft2232_spi.c: Add ft2232_spi_send_multicommand()
Pack WREN and op in one ftdi_write_data() call.
Pack RD cmd and deassertion of CS# in one ftdi_write_data() call.
Every ftdi_write_data() call is quite time consuming as the ftdi-chips
seems to take always 2-3ms to respond.
This leads to what the comment already says: Minimize USB transfers
to ftdi chip by packing as many commands as possible together.
So I packed the WREN command together with the following operation
which can be program or erase operation.
Furthermore the deassertion of CS# is no longer send seperately
from a read cmd.
This saves more than 1 minute when programming a 128MBit Flash
with my config!
Signed-off-by: Simon Buhrow <simon.buhrow(a)posteo.de>
Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a
---
M ft2232_spi.c
1 file changed, 91 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/77/40477/20
--
To view, visit https://review.coreboot.org/c/flashrom/+/40477
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a
Gerrit-Change-Number: 40477
Gerrit-PatchSet: 20
Gerrit-Owner: Simon Buhrow
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-CC: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: newpatchset
Simon Buhrow has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40477 )
Change subject: ft2232_spi.c: Add ft2232_spi_send_multicommand()
......................................................................
Patch Set 19:
> So, the correct way to do this is to implement `.multicommand`
> instead of `.command`. I would roughly do it as follows:
>
> Loop
> Put write part of command into buffer.
> If not last command and read part is empty,
> Continue with next loop iteration.
> Execute buffer.
> Execute read part if any.
> While not last command.
I uploaded PS18 with my first draft of ft2232_spi_send_multicommand().
Having Patch 40748 in mind, I decided to pack max one read cmd into one ftdi call.
This simplifies the readback pointer management as well (readarr).
Furthermore I think the majority (all?) calls of ft2232_spi_send_multicommand() will have at most one read cmd (correct me if I´m wrong).
(To be honest I´m not sure if ft2232_spi_send_multicommand() is ever called with read cmd in the current implementation)
I´m not sure if the loop condition is safe. It´s copied from default_spi_send_multicommand().
It´s untested!! I´ll do this the next week(s).
Comments are welcome.
--
To view, visit https://review.coreboot.org/c/flashrom/+/40477
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a
Gerrit-Change-Number: 40477
Gerrit-PatchSet: 19
Gerrit-Owner: Simon Buhrow
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-CC: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Comment-Date: Thu, 19 Nov 2020 16:08:00 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Hello build bot (Jenkins), Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/40477
to look at the new patch set (#19).
Change subject: ft2232_spi.c: Add ft2232_spi_send_multicommand()
......................................................................
ft2232_spi.c: Add ft2232_spi_send_multicommand()
Pack WREN and op in one ftdi_write_data() call.
Pack RD cmd and deassertion of CS# in one ftdi_write_data() call.
Every ftdi_write_data() call is quite time consuming as the ftdi-chips
seems to take always 2-3ms to respond.
This leads to what the comment already says: Minimize USB transfers
to ftdi chip by packing as many commands as possible together.
So I packed the WREN command together with the following operation
which can be program or erase operation.
Furthermore the deassertion of CS# is no longer send seperately
from a read cmd.
This saves more than 1 minute when programming a 128MBit Flash
with my config!
Signed-off-by: Simon Buhrow <simon.buhrow(a)posteo.de>
Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a
---
M ft2232_spi.c
1 file changed, 88 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/77/40477/19
--
To view, visit https://review.coreboot.org/c/flashrom/+/40477
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a
Gerrit-Change-Number: 40477
Gerrit-PatchSet: 19
Gerrit-Owner: Simon Buhrow
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-CC: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: newpatchset
Hello build bot (Jenkins), Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/40477
to look at the new patch set (#18).
Change subject: ft2232_spi.c: Pack WREN and op in one ftdi_write_data() call
......................................................................
ft2232_spi.c: Pack WREN and op in one ftdi_write_data() call
Every ftdi_write_data() call is quite time consuming as the ftdi-chips
seems to take always 2-3ms to respond.
This leads to what the comment already says: Minimize USB transfers
by packing as many commands as possible together.
So I packed the WREN command together with the following operation
which can be program or erase operation.
This saves about 1 minute when programming a 128MBit Flash with my
config!
I´m using ftdi-2232H chip. That´s why I put it at this place.
If anyone has a good overview about all programmers:
This could be implemented in spi_write_cmd() in case that it is
compatible to all programmers
or this principle could be transfered to other programmers which act
in a similar way.
Signed-off-by: Simon Buhrow <simon.buhrow(a)posteo.de>
Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a
---
M ft2232_spi.c
1 file changed, 88 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/77/40477/18
--
To view, visit https://review.coreboot.org/c/flashrom/+/40477
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a
Gerrit-Change-Number: 40477
Gerrit-PatchSet: 18
Gerrit-Owner: Simon Buhrow
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-CC: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: newpatchset
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40477 )
Change subject: ft2232_spi.c: Pack WREN and op in one ftdi_write_data() call
......................................................................
Patch Set 16:
(1 comment)
https://review.coreboot.org/c/flashrom/+/40477/16/ft2232_spi.c
File ft2232_spi.c:
https://review.coreboot.org/c/flashrom/+/40477/16/ft2232_spi.c@497
PS16, Line 497: bufsize = max(writecnt + 19, 261 + 19);
> What do you want to drop? Just the change from 260+9 to 261+19 or the whole max()-line?
I meant dropping the max(). Just `bufsize = writecnt + 9` (or `+ 19`) would
have worked to. The optimization is only that with the max(), you probably
get less realloc() calls. But the overhead of realloc() (so far my impres-
sion) is insignificant in a program that does USB transfers (which have
a much higher overhead). I don't know but assume that this max(), and the
fewer realloc() calls, save us about 1us per flashrom run, in the best
case. (If this were a compute intensive program, avoiding realloc() would
make sense.)
And yes, starting with 4K and only increasing the buffer on demand would
work well. But then again, realloc() really isn't that expensive.
PS. Looked at PS11 now, that would work too. But needs a check that we
never exceed the buffer ofc.
--
To view, visit https://review.coreboot.org/c/flashrom/+/40477
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a
Gerrit-Change-Number: 40477
Gerrit-PatchSet: 16
Gerrit-Owner: Simon Buhrow
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-CC: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Comment-Date: Thu, 12 Nov 2020 20:46:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Simon Buhrow
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: comment
Simon Buhrow has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40477 )
Change subject: ft2232_spi.c: Pack WREN and op in one ftdi_write_data() call
......................................................................
Patch Set 16:
(3 comments)
Thanks. Much better than no feedback!
I will work on this when I get time.
May be anyone (Nico?) can give a comment on ft2232_spi.c#497 meanwhile.
https://review.coreboot.org/c/flashrom/+/40477/16/ft2232_spi.c
File ft2232_spi.c:
https://review.coreboot.org/c/flashrom/+/40477/16/ft2232_spi.c@172
PS16, Line 172: .multicommand = default_spi_send_multicommand,
> You just need to implement this and will get both commands passed at once.
I got it. This looks much better than my suggested patch!
https://review.coreboot.org/c/flashrom/+/40477/16/ft2232_spi.c@497
PS16, Line 497: bufsize = max(writecnt + 19, 261 + 19);
> This assumes `i` is at most 10. But there is really no guarantee because […]
The optimization done in this change (to 261+19) was not due to USB-Transfer itself, but due to FTDI-Response time after every ftdi_write_data-call (which in this case is the some number as the number of USB-transfers). So this is a significant optimization.
But with the good idea of implementing spi_send_multicommand for ftdi I have to check what this does with bufsize of (261+19).
What do you want to drop? Just the change from 260+9 to 261+19 or the whole max()-line?
I would drop the whole line (see PS11).
IMHO the easiest and best way would be so set bufsize (to chunksize) to 4096.
Is there any benefit of saving ca. 3.8kByte of space on a PC to the cost of more complex code?
As Angel Pons suggested, this could be done in an extra patch.
https://review.coreboot.org/c/flashrom/+/40477/16/ft2232_spi.c@562
PS16, Line 562: if (writearr[0] == JEDEC_WREN) {
> What if the chip isn't JEDEC? 0x06 (WREN) could mean something very different. […]
You are right, I was assuming JEDEC_WREN in any case. Thank´s for that hint!
--
To view, visit https://review.coreboot.org/c/flashrom/+/40477
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a
Gerrit-Change-Number: 40477
Gerrit-PatchSet: 16
Gerrit-Owner: Simon Buhrow
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-CC: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Comment-Date: Thu, 12 Nov 2020 13:45:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: comment