diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index 734898cc..05292396 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -165,6 +165,7 @@ static inline int icc_send_irq(int ue) // send interrupt to ue do { + NOP1; tmp=ReadConfigReg(addr); } while(tmp & 2); tmp |= 2; @@ -194,29 +195,32 @@ int icc_halt(void) return 0; } +static volatile uint64_t ping_start = 0; +static icc_header_t ping_request = {ICC_TYPE_PINGREQUEST, 0, 0}; +static icc_header_t ping_response = {ICC_TYPE_PINGRESPONSE, 0, 0}; + int icc_ping(int ue) { - icc_header_t ping_header = {ICC_TYPE_PINGREQUEST, 0, sizeof(uint64_t)}; - uint64_t tsc; uint32_t flags; - iRCCE_SEND_REQUEST send_request; if (BUILTIN_EXPECT(ue == my_ue, 0)) return -EINVAL; if (BUILTIN_EXPECT((ue < 0) || (ue >= num_ues), 0)) return -EINVAL; - tsc = rdtsc(); + while(ping_start) { + NOP8; + } + + ping_start = rdtsc(); // iRCCE is not thread save => disable interrupts flags = irq_nested_disable(); - iRCCE_isend((char*) &ping_header, sizeof(icc_header_t), ue, NULL); - iRCCE_isend((char*) &tsc, sizeof(uint64_t), ue, &send_request); + iRCCE_isend((char*) &ping_request, sizeof(icc_header_t), ue, NULL); - // waiting for the completion - while(iRCCE_isend_test(&send_request, NULL) != iRCCE_SUCCESS) - icc_check(); // oh, we have time to check incoming requests + // wait some time + NOP8; // wake up receiver icc_send_irq(ue); @@ -233,30 +237,19 @@ static void interpret_header(icc_header_t* header, int recv_ue) switch(header->type) { case ICC_TYPE_PINGREQUEST: { - icc_header_t response = {ICC_TYPE_PINGRESPONSE, 0, sizeof(uint64_t)}; - iRCCE_RECV_REQUEST recv_req; - uint64_t tsc; - iRCCE_isend((char*) &response, sizeof(icc_header_t), recv_ue, NULL); - if (iRCCE_irecv((char*) &tsc, sizeof(uint64_t), recv_ue, &recv_req) != iRCCE_SUCCESS) - iRCCE_irecv_wait(&recv_req); + iRCCE_isend((char*) &ping_response, sizeof(icc_header_t), recv_ue, NULL); - iRCCE_isend((char*) &tsc, sizeof(uint64_t), recv_ue, NULL); - if (iRCCE_isend_push() == iRCCE_PENDING) - iRCCE_isend_push(); + // wait some time + NOP8; + // wake up remote core icc_send_irq(recv_ue); } break; - case ICC_TYPE_PINGRESPONSE: { - uint64_t start, end; - iRCCE_RECV_REQUEST recv_req; - - if (iRCCE_irecv((char*) &start, sizeof(uint64_t), recv_ue, &recv_req) != iRCCE_SUCCESS) - iRCCE_irecv_wait(&recv_req); - end = rdtsc(); - kprintf("Receive ping response. Ticks: %d\n", end-start); - } + case ICC_TYPE_PINGRESPONSE: + kprintf("Receive ping response. Ticks: %d\n", rdtsc()-ping_start); + ping_start = 0; break; default: kprintf("Receive unknown ICC message (%d)\n", header->type); @@ -286,7 +279,6 @@ void icc_check(void) } // pushes the progress of non-blocking communication requests - iRCCE_isend_push(); iRCCE_irecv_push(); for(i=0; i