@@ -492,9 +492,6 @@ static void enable_tx(QTestState *qts, const EMCModule *mod,
492492 mcmdr |= REG_MCMDR_TXON ;
493493 emc_write (qts , mod , REG_MCMDR , mcmdr );
494494 }
495-
496- /* Prod the device to send the packet. */
497- emc_write (qts , mod , REG_TSDR , 1 );
498495}
499496
500497static 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,
558555 enable_tx (qts , mod , & desc [0 ], NUM_TX_DESCRIPTORS , desc_addr ,
559556 with_irq ? REG_MIEN_ENTXINTR : 0 );
560557
558+ /* Prod the device to send the packet. */
559+ emc_write (qts , mod , REG_TSDR , 1 );
560+
561561 /*
562562 * It's problematic to observe the interrupt for each packet.
563563 * Instead just wait until all the packets go out.
@@ -643,13 +643,10 @@ static void enable_rx(QTestState *qts, const EMCModule *mod,
643643 mcmdr |= REG_MCMDR_RXON | mcmdr_flags ;
644644 emc_write (qts , mod , REG_MCMDR , mcmdr );
645645 }
646-
647- /* Prod the device to accept a packet. */
648- emc_write (qts , mod , REG_RSDR , 1 );
649646}
650647
651648static void emc_recv_verify (QTestState * qts , const EMCModule * mod , int fd ,
652- bool with_irq )
649+ bool with_irq , bool pump_rsdr )
653650{
654651 NPCM7xxEMCRxDesc desc [NUM_RX_DESCRIPTORS ];
655652 uint32_t desc_addr = DESC_ADDR ;
@@ -679,6 +676,15 @@ static void emc_recv_verify(QTestState *qts, const EMCModule *mod, int fd,
679676 enable_rx (qts , mod , & desc [0 ], NUM_RX_DESCRIPTORS , desc_addr ,
680677 with_irq ? REG_MIEN_ENRXINTR : 0 , 0 );
681678
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+
682688 /* Send test packet to device's socket. */
683689 ret = iov_send (fd , iov , 2 , 0 , sizeof (len ) + sizeof (test ));
684690 g_assert_cmpint (ret , = = , sizeof (test ) + sizeof (len ));
@@ -826,8 +832,14 @@ static void test_rx(gconstpointer test_data)
826832
827833 qtest_irq_intercept_in (qts , "/machine/soc/a9mpcore/gic" );
828834
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);
831843 emc_test_ptle (qts , td -> module , test_sockets [0 ]);
832844
833845 qtest_quit (qts );
0 commit comments