@@ -492,9 +492,6 @@ static void enable_tx(QTestState *qts, const EMCModule *mod,
492
492
mcmdr |= REG_MCMDR_TXON ;
493
493
emc_write (qts , mod , REG_MCMDR , mcmdr );
494
494
}
495
-
496
- /* Prod the device to send the packet. */
497
- emc_write (qts , mod , REG_TSDR , 1 );
498
495
}
499
496
500
497
static void emc_send_verify1 (QTestState * qts , const EMCModule * mod , int fd ,
@@ -558,6 +555,9 @@ static void emc_send_verify(QTestState *qts, const EMCModule *mod, int fd,
558
555
enable_tx (qts , mod , & desc [0 ], NUM_TX_DESCRIPTORS , desc_addr ,
559
556
with_irq ? REG_MIEN_ENTXINTR : 0 );
560
557
558
+ /* Prod the device to send the packet. */
559
+ emc_write (qts , mod , REG_TSDR , 1 );
560
+
561
561
/*
562
562
* It's problematic to observe the interrupt for each packet.
563
563
* Instead just wait until all the packets go out.
@@ -643,13 +643,10 @@ static void enable_rx(QTestState *qts, const EMCModule *mod,
643
643
mcmdr |= REG_MCMDR_RXON | mcmdr_flags ;
644
644
emc_write (qts , mod , REG_MCMDR , mcmdr );
645
645
}
646
-
647
- /* Prod the device to accept a packet. */
648
- emc_write (qts , mod , REG_RSDR , 1 );
649
646
}
650
647
651
648
static void emc_recv_verify (QTestState * qts , const EMCModule * mod , int fd ,
652
- bool with_irq )
649
+ bool with_irq , bool pump_rsdr )
653
650
{
654
651
NPCM7xxEMCRxDesc desc [NUM_RX_DESCRIPTORS ];
655
652
uint32_t desc_addr = DESC_ADDR ;
@@ -679,6 +676,15 @@ static void emc_recv_verify(QTestState *qts, const EMCModule *mod, int fd,
679
676
enable_rx (qts , mod , & desc [0 ], NUM_RX_DESCRIPTORS , desc_addr ,
680
677
with_irq ? REG_MIEN_ENRXINTR : 0 , 0 );
681
678
679
+ /*
680
+ * If requested, prod the device to accept a packet.
681
+ * This isn't necessary, the linux driver doesn't do this.
682
+ * Test doing/not-doing this for robustness.
683
+ */
684
+ if (pump_rsdr ) {
685
+ emc_write (qts , mod , REG_RSDR , 1 );
686
+ }
687
+
682
688
/* Send test packet to device's socket. */
683
689
ret = iov_send (fd , iov , 2 , 0 , sizeof (len ) + sizeof (test ));
684
690
g_assert_cmpint (ret , = = , sizeof (test ) + sizeof (len ));
@@ -826,8 +832,14 @@ static void test_rx(gconstpointer test_data)
826
832
827
833
qtest_irq_intercept_in (qts , "/machine/soc/a9mpcore/gic" );
828
834
829
- emc_recv_verify (qts , td -> module , test_sockets [0 ], /*with_irq=*/ false);
830
- emc_recv_verify (qts , td -> module , test_sockets [0 ], /*with_irq=*/ true);
835
+ emc_recv_verify (qts , td -> module , test_sockets [0 ], /*with_irq=*/ false,
836
+ /*pump_rsdr=*/ false);
837
+ emc_recv_verify (qts , td -> module , test_sockets [0 ], /*with_irq=*/ false,
838
+ /*pump_rsdr=*/ true);
839
+ emc_recv_verify (qts , td -> module , test_sockets [0 ], /*with_irq=*/ true,
840
+ /*pump_rsdr=*/ false);
841
+ emc_recv_verify (qts , td -> module , test_sockets [0 ], /*with_irq=*/ true,
842
+ /*pump_rsdr=*/ true);
831
843
emc_test_ptle (qts , td -> module , test_sockets [0 ]);
832
844
833
845
qtest_quit (qts );
0 commit comments