xilinx_spips dummy bytes fix
v2 cover xilinx_spips dummy bytes fix
For zynq-7000 boards, we saw issues when u-boot/linux accessing the qspi.
Issue is due to wrong dummy byte transfers for few of un-handled commands ex: 0x9F, 0x6, 0xe9, 0x4, 0x18, etc There are many unhandled commands which do not require dummy bytes but they can be followed by address cycles.
To fix this issue for above commands, the next upcoming tx bytes are not considered dummies rather sent to slave directly.
Changes for V2:
Fixed commit message
Reordered to code, to avoid code duplication.
Sai Pavan Boddu (1):
xilinx_spips: send dummy cycles only if cmd requires it
hw/ssi/xilinx_spips.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/1 xilinx_spips: send dummy cycles only if cmd requires it
For all the commands, which do not have an entry in xilinx_spips_num_dummies, present logic sends dummy cycles when ever we are in SNOOP_NONE state, fix it to only send dummy cycles if the cmd requires them.
SNOOP_NONE state handle is moved above (previously its part of default else case), as its same as SNOOP_STRIPPING during data cycles.
---
TODO: Maybe we could delete the SNOOP_NONE state as it seems to be same as SNOOP_STRIPPING
hw/ssi/xilinx_spips.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/ssi/xilinx_spips.c +4 -2
@@ -616,7 +616,8 @@ static void xilinx_spips_flush_txfifo(XilinxSPIPS *s)if (fifo8_is_empty (&s->tx_fifo)) {xilinx_spips_update_ixr (s);return ; - }else if (s->snoop_state ==SNOOP_STRIPING ) { + }else if (s->snoop_state ==SNOOP_STRIPING || + s->snoop_state ==SNOOP_NONE ) {for (i =0 ; i <num_effective_busses (s); ++i) { tx_rx[i] =fifo8_pop (&s->tx_fifo); }
@@ -626,11 +627,12 @@ static void xilinx_spips_flush_txfifo(XilinxSPIPS *s)for (i =0 ; i <num_effective_busses (s); ++i) { tx_rx[i] = tx; } - }else { + }else if (s->cmd_dummies >0 ) {/* Extract a dummy byte and generate dummy cycles according to the * link state */ tx =fifo8_pop (&s->tx_fifo); dummy_cycles =8 / s->link_state; + s->cmd_dummies--; }for (i =0 ; i <num_effective_busses (s); ++i) {
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 1/1] xilinx_spips: send dummy cycles only if cmd requires it
Hi Sai,
About the subject, what do you think about changing it to below?xilinx_spips: Correct SNOOP_NONE state when flushing the txfifo
Quoted 6 lines · Sai Pavan Boddu
For all the commands, which do not have an entry in
xilinx_spips_num_dummies, present logic sends dummy cycles when ever we are inSNOOP_NONEstate, fix it to only send dummy cycles if the cmd requires them.It feels like below sentence goes together with the 'fix' above so maybe
it could come directly after? (i.e. no new section but maybe with an 'also' after 'handle is')
Quoted 2 lines
SNOOP_NONEstate handle is moved above (previously its part of default else
s/above/above in the if ladder/
s/its part of default/it was part of the default/
Quoted 1 line
case), as its same as
SNOOP_STRIPPINGduring data cycles.
s/its/it's/
Quoted 2 lines
Quoted 3 lines
---
TODO: Maybe we could delete theSNOOP_NONEstate as it seems to be same asSNOOP_STRIPPING
I agree that a cleanup commit later on could be considered, but I think it's better not to include the todo in the commit message of this one so could we remove it?
Quoted 19 lines
hw/ssi/xilinx_spips.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)hw/ssi/xilinx_spips.c +2
-1@@ -616,7 +616,8 @@ static void xilinx_spips_flush_txfifo(XilinxSPIPS *s)if (fifo8_is_empty (&s->tx_fifo)) {xilinx_spips_update_ixr (s);return ; - }else if (s->snoop_state ==SNOOP_STRIPING ) { + }else if (s->snoop_state ==SNOOP_STRIPING || + s->snoop_state ==SNOOP_NONE ) {for (i =0 ; i <num_effective_busses (s); ++i) { tx_rx[i] =fifo8_pop (&s->tx_fifo); }
hw/ssi/xilinx_spips.c static void xilinx_spips_flush_txfifo(XilinxSPIPS · line 632
Quoted 7 lines
hw/ssi/xilinx_spips.c +1
-1@@ -626,11 +627,12 @@ static void xilinx_spips_flush_txfifo(XilinxSPIPS *s)for (i =0 ; i <num_effective_busses (s); ++i) { tx_rx[i] = tx; } - }else { + }else if (s->cmd_dummies >0 ) {
The variable snoop_state already keeps track of the dummy cycles, the same the 'else' to 'else if' change above together with the 'cmd_dummies' decrementation below does, could we undo these two changes since it is already handled?
Thank you!
Best regards,
Francisco Iglesias
/* Extract a dummy byte and generate dummy cycles according to
Quoted 13 lines
the
* link state */ tx = fifo8_pop(&s->tx_fifo); dummy_cycles = 8 / s->link_state; + s->cmd_dummies--; } for (i = 0; i < num_effective_busses(s); ++i) {--
2.7.4
Re: [Qemu-devel] [PATCH v2 1/1] xilinx_spips: send dummy cycles only if cmd requires it
HI Franciso,
From: francisco iglesias [mailto:[email protected]]
Sent: Thursday, April 19, 2018 3:39 AM
To: Sai Pavan Boddu <[email protected]>
Cc: [email protected]; Peter Crosthwaite <[email protected]>; Peter Maydell <[email protected]>; Edde <[email protected]>; [email protected] Developers <[email protected]>
Subject: Re: [Qemu-devel] [PATCH v2 1/1] xilinx_spips: send dummy cycles only if cmd requires it
Hi Sai,
About the subject, what do you think about changing it to below?xilinx_spips: Correct SNOOP_NONE state when flushing the txfifo
On 18 April 2018 at 09:41, Sai Pavan Boddu <[email protected]<mailto:[email protected]>> wrote:
For all the commands, which do not have an entry inxilinx_spips_num_dummies, present logic sends dummy cycles when ever we
are in SNOOP_NONE state, fix it to only send dummy cycles if the cmd
requires them.
It feels like below sentence goes together with the 'fix' above so maybe it could come directly after? (i.e. no new section but maybe with an 'also' after 'handle is') SNOOP_NONE state handle is moved above (previously its part of default else
s/above/above in the if ladder/
s/its part of default/it was part of the default/
case), as its same as SNOOP_STRIPPING during data cycles.
s/its/it's/
---
TODO: Maybe we could delete the SNOOP_NONE state as it seems to be
same as SNOOP_STRIPPING
I agree that a cleanup commit later on could be considered, but I think it's better not to include the todo in the commit message of this one so could we remove it?
hw/ssi/xilinx_spips.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/ssi/xilinx_spips.c +3 -2
@@ -616,7 +616,8 @@ static void xilinx_spips_flush_txfifo(XilinxSPIPS *s)if (fifo8_is_empty (&s->tx_fifo)) {xilinx_spips_update_ixr (s);return ; - }else if (s->snoop_state ==SNOOP_STRIPING ) { + }else if (s->snoop_state ==SNOOP_STRIPING || + s->snoop_state ==SNOOP_NONE ) {for (i =0 ; i <num_effective_busses (s); ++i) { tx_rx[i] =fifo8_pop (&s->tx_fifo); }
@@ -626,11 +627,12 @@ static void xilinx_spips_flush_txfifo(XilinxSPIPS *s)for (i =0 ; i <num_effective_busses (s); ++i) { tx_rx[i] = tx; } - }else { + }else if (s->cmd_dummies >0 ) {
The variable snoop_state already keeps track of the dummy cycles, the same the 'else' to 'else if' change above together with the 'cmd_dummies' decrementation below does, could we undo these two changes since it is already handled? [Sai Pavan Boddu] Yes, you are right. After we moved SNOOP_NONE above. We don’t need an of these changes here. Wonderful that it patch got minimized to single line now.
Regards,
Sai Pavan
Thank you!
Best regards,
Francisco Iglesias
/* Extract a dummy byte and generate dummy cycles according to the
* link state */
tx = fifo8_pop(&s->tx_fifo);
dummy_cycles = 8 / s->link_state;
+ s->cmd_dummies--;
}
for (i = 0; i < num_effective_busses(s); ++i) {--
2.7.4