From 03f9d7a97e8bbec46b2cbd3386774295e48a8387 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 11 Jun 2020 14:57:30 +1000 Subject: [PATCH] tests/xics: Fix assumption that interrupts happen immediately Currently the test writes to the XICS and then checks that the expected interrupt has happened. This turns into a stbcix instruction followed immediately by a load from the variable that indicates whether an interrupt has happened. It is possible for it to take a few cycles for the store to reach the XICS and the interrupt request signal to come back to the core, particularly with improvements to the load/store unit and dcache. This therefore adds a delay between storing to the XICS and checking for the occurrence of an interrupt, so as to give the signals time to propagate. The delay loop does an arbitrary 10 iterations, and each iteration does two loads and one store to (cacheable) memory. Signed-off-by: Paul Mackerras --- tests/test_xics.bin | Bin 12384 -> 12384 bytes tests/xics/xics.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/tests/test_xics.bin b/tests/test_xics.bin index 6dd993ce0af3fd582dcb3d1914ca85dcf8b48a1b..327f98f64e2bb62ea1ca48f98456b1dae59799f6 100755 GIT binary patch literal 12384 zcmeHMeP~9}x?1N^Bop^0P9~4sBwE9SP_d8El z_Os$ND{N?x_u%Q?d+xdCoZs)n)4Qz-uwh4VU1x-yG;m~qBLf^6;K%?+1~@XnkpYejaAbia z3mjSC$O1rNF!tn3n?cQea++#bPs_36+eU(8)q43!N->)0Pk&s9G?MObp!KasKKNbYK{^nEt@br^K+|q)!1HQ^Iwes!yffG0x{j#AxQ?Nj1)xhm3#vQ3B(Jd|Ce8I+<_SsKMAZu)*WY{ciy) zQ7}#9X@3fsgm}91&`89)R$}-%>E1s`8^=+fhd#?rOBw5*hyHa-dkXEpmHqO!E%?^p zo8!0o-XVP>FRfPJN99=dvrX1dpdOaKAGP>m-@}$R`~IeEo8Q&oJ1Oq;ebMAQn08k9 z{*oNazW-cX;_h|SuS1_@zm>8w?)NNh_B}7#W#62yO57~#K+cge+`;^fq9ylAW$sm( zdtMJTpw(2Bx7D{i7|;7w^`a8vro1;W(Ch8 zC6hsywh$o-9OX5cpPjakk_q+!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|y`8-t{amj0W z{?s>r@R_xt_6bXtza0%#Ma^#w-sc)Kzl-vooA(^9o2+4UAFsgyX#0`1{`h%?d49dV z8PC|CnEUk5h83nJ;Lwn`i)A2n?fQ|~hPr~gw(j1xYxmYV+jzBY{B?8O0jQ4N6Z{9q zQ@++V>_MsB_w2LWa=fo$$Nog#P1Q9zJT03#wlebDn_AotFVx|KM&_Ztu!%}SKCNnz zX4+5#wC3+ZJTCo=<9?gP_9(^%&Q93c&{9i<{srHQEfv&UhL038jvwt1{P+#PJUGs7 zoFlO5rX`QthyE{ZxFfLr)`DYY#&Mp7Z9iIivfM|$S4xkR9CZ#mj%k?NSJD3c3i5q8 zb>%OY%^Y~%k8oDs6yhwe4PP_tSYJ_R;vFMM_QR<%pAHwO)7e`>+(t`n6?KTmVIAET zOdWh9p9taNSQbo=#5BU(0nAHTAu=4NnR7hkI=tZJvU@UZuJAj07FN(YGuJ;~x>)9W z2yoVCKdx)c39$ryK3MnT(pGsV<~^*9u#Ci{IR+o|t?A<1Le%HoCXQpTfsI=}_*w&J zo6Xh%TPJMHj}OLe$2n+;SB-HP=QwQbXsN~2`k3~lsbw?RVrA~~JPyeFmU;M+;!#wf zs6bJHq5?$)iV74JC@N4?pr}AmfuaIM1&Rv%_X=#6KML^A7JS6zST?j@b@J{xf2+Tk PH_gZ&CI0%Qdm;Y<^ycm; diff --git a/tests/xics/xics.c b/tests/xics/xics.c index 2ff4c54..a2db3a5 100644 --- a/tests/xics/xics.c +++ b/tests/xics/xics.c @@ -9,6 +9,14 @@ #undef DEBUG //#define DEBUG 1 +void delay(void) +{ + static volatile int i; + + for (i = 0; i < 10; ++i) + ; +} + void print_number(unsigned int i) // only for i = 0-999 { unsigned int j, k, m; @@ -148,14 +156,17 @@ int xics_test_0(void) xics_write8(XICS_MFRR, 0x05); // cause 0x500 interrupt // still masked, so shouldn't happen yet + delay(); assert(isrs_run == 0); // unmask IPI only xics_write8(XICS_XIRR, 0x40); + delay(); assert(isrs_run == ISR_IPI); // unmask UART xics_write8(XICS_XIRR, 0xc0); + delay(); assert(isrs_run == (ISR_IPI | ISR_UART)); // cleanup @@ -174,12 +185,14 @@ int xics_test_1(void) xics_write8(XICS_XIRR, 0xff); // allow all interrupts // should be none pending + delay(); assert(isrs_run == 0); // trigger both potato_uart_irq_en(); // cause 0x500 interrupt xics_write8(XICS_MFRR, 0x05); // cause 0x500 interrupt + delay(); assert(isrs_run == (ISR_IPI | ISR_UART)); // cleanup @@ -208,9 +221,11 @@ int xics_test_2(void) // trigger an IPI xics_write8(XICS_MFRR, 0x05); // cause 0x500 interrupt + delay(); assert(isrs_run == 0); mtmsrd(0x9000000000008003); // EE on + delay(); assert(isrs_run == ISR_IPI); // cleanup -- 2.30.2