stlink: dequeue CSW write only if it doesn't change csw_default
commit22c76a4fd536ba53f563d72d2b3402c45f925f85
authorAntonio Borneo <borneo.antonio@gmail.com>
Thu, 29 Jul 2021 16:38:20 +0000 (29 18:38 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 5 Nov 2021 22:42:33 +0000 (5 22:42 +0000)
treece196ce7c30c546502ac7a351c36e3e1a8251f59
parent9a534c4bb2a88fdc2ddaf7d4356faddba59736ea
stlink: dequeue CSW write only if it doesn't change csw_default

The stlink commands for buffer read/write carry the associated CSW
value that has to be used. We can dequeue any CSW write request
and add the CSW in the following buffer read/write.

In preparation to next patch that uses stlink commands misc-rw
(commands that don't handle CSW value), let's dequeue only those
CSW write that don't change csw_default.

Keep a local cache of last csw_default.
Tag the queued CSW writes that change csw_default.
Dequeue only the un-tagged CSW writes.

On buffer read/write commands, limiting the dequeued CSW write
surely adds a performance penalty. But csw_default is not changed
often so the penalty is not significant.

Change-Id: I538d257fe3c434fc97587846d759951384327f02
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6606
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
src/jtag/drivers/stlink_usb.c