From 570b559b5e188ac9137f18adec37ccbb11de5572 Mon Sep 17 00:00:00 2001 From: Simon Pickartz Date: Tue, 7 Jun 2011 12:38:35 +0200 Subject: [PATCH 1/3] add mail_ping interrupt test-scenario --- arch/x86/scc/icc.c | 52 ++++++++++++++++++++++++++++++++-------- include/metalsvm/tasks.h | 3 ++- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index 40a07199..cd2c3b50 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -235,30 +235,46 @@ int icc_ping(int ue) int icc_mail_ping( void ) { uint32_t flags; + uint64_t timer; int remote_rank = (my_ue+1)%2; - - kprintf( "#### Hello from icc_mail_ping\n" ); + + if( !my_rank ) { + return 0; + } + // iRCCE is not thread save => disable interrupts flags = irq_nested_disable(); - // send mail - iRCCE_mail_send( 0, my_ue, 0, NULL, remote_rank ); - kprintf( "### Message sent ...\n" ); + // start timer + timer = rdtsc(); - // wait for mail from remote rank + iRCCE_mail_send( 0, 1, 0, NULL, remote_rank ); + kprintf( "Sent pingrequest to %d ...\n", remote_rank ); + + // wait for response iRCCE_MAIL_HEADER* mail; do { iRCCE_mail_recv( &mail ); } while( !mail ); - // show content - iRCCE_mailbox_print_header( mail ); - + // stop timer + timer = rdtsc() - timer; + + if( mail->tag == 2 ) { + kprintf( "Response received in %d ticks!\n", timer ); + } + else { + krpintf( "Response didn't arrive!\n" ); + } + + + irq_nested_enable(flags); - + return 0; } + static void interpret_header(icc_header_t* header, int recv_ue) { //kprintf("Got ICC message %d from %d\n", header->type, recv_ue); @@ -325,4 +341,20 @@ void icc_check(void) iRCCE_isend_push(); } +void icc_mail_check(void) +{ + iRCCE_MAIL_HEADER* header; + int res; + + // empty mailbox and interpret headers + do { + res = iRCCE_mail_recv( &header ); + if( header->tag == 1 ) { + iRCCE_mail_send( 0, 2, 0, NULL, header->source ); + } + + iRCCE_mail_release( &header ); + } while( res == iRCCE_SUCCESS ); +} + #endif diff --git a/include/metalsvm/tasks.h b/include/metalsvm/tasks.h index 5329fc61..ec6ed665 100644 --- a/include/metalsvm/tasks.h +++ b/include/metalsvm/tasks.h @@ -143,7 +143,8 @@ static inline void check_workqueues(void) uint32_t flags = irq_nested_disable(); #ifdef CONFIG_ROCKCREEK - icc_check(); + //icc_check(); + icc_mail_check(); #endif irq_nested_enable(flags); From 262e9f085aa4b4c0a3b2bd69d91f609f30f32e70 Mon Sep 17 00:00:00 2001 From: Generic account for RWTHAachen Students Date: Tue, 7 Jun 2011 03:53:37 -0700 Subject: [PATCH 2/3] bug fix --- arch/x86/include/asm/icc.h | 1 + arch/x86/scc/icc.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/icc.h b/arch/x86/include/asm/icc.h index f08bd07c..b02be40e 100644 --- a/arch/x86/include/asm/icc.h +++ b/arch/x86/include/asm/icc.h @@ -53,6 +53,7 @@ typedef struct { int icc_init(void); int icc_ping(int ue); void icc_check(void); +void icc_mail_check(void); int icc_halt(void); int icc_mail_ping(void); diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index 02c8b80a..9c94a600 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -238,7 +238,7 @@ int icc_mail_ping( void ) uint64_t timer; int remote_rank = (my_ue+1)%2; - if( !my_rank ) { + if( !my_ue ) { return 0; } @@ -268,7 +268,7 @@ int icc_mail_ping( void ) kprintf( "Response received in %d ticks!\n", timer ); } else { - krpintf( "Response didn't arrive!\n" ); + kprintf( "Response didn't arrive!\n" ); } From bba87c8e2726a25da41ea46504a428f268057f75 Mon Sep 17 00:00:00 2001 From: Generic account for RWTHAachen Students Date: Tue, 7 Jun 2011 05:53:16 -0700 Subject: [PATCH 3/3] bug fix in mail_ping --- arch/x86/kernel/irq.c | 2 +- arch/x86/scc/icc.c | 17 +++++++++++------ include/metalsvm/tasks.h | 2 +- kernel/mailbox.c | 1 - kernel/main.c | 3 ++- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 3c4b621f..9e8ca5e8 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -235,7 +235,7 @@ void irq_handler(struct state *s) void (*handler) (struct state * s); // at first, we check our work queues - check_workqueues(); + if( s->int_no == 124 ) check_workqueues(); /* * Find out if we have a custom handler to run for this diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index 9c94a600..d0ff8bb2 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -238,7 +238,7 @@ int icc_mail_ping( void ) uint64_t timer; int remote_rank = (my_ue+1)%2; - if( !my_ue ) { + if( my_ue ) { return 0; } @@ -251,15 +251,16 @@ int icc_mail_ping( void ) iRCCE_mail_send( 0, 1, 0, NULL, remote_rank ); kprintf( "Sent pingrequest to %d ...\n", remote_rank ); + + // wake up receiver + icc_send_irq( remote_rank ); + // wait for response iRCCE_MAIL_HEADER* mail; do { iRCCE_mail_recv( &mail ); } while( !mail ); - timer = timer - rdtsc(); - - kprintf( "Received mail in %d ticks!\n", timer ); // stop timer timer = rdtsc() - timer; @@ -347,16 +348,20 @@ void icc_check(void) void icc_mail_check(void) { + if( !my_ue ) return ; + iRCCE_MAIL_HEADER* header; int res; - + + kprintf( "Hello from icc_mail_check() \n" ); // empty mailbox and interpret headers do { res = iRCCE_mail_recv( &header ); if( header->tag == 1 ) { + kprintf( "Received mail_ping request ...\n" ); iRCCE_mail_send( 0, 2, 0, NULL, header->source ); } - + iRCCE_mail_release( &header ); } while( res == iRCCE_SUCCESS ); } diff --git a/include/metalsvm/tasks.h b/include/metalsvm/tasks.h index ec6ed665..b8822dfa 100644 --- a/include/metalsvm/tasks.h +++ b/include/metalsvm/tasks.h @@ -143,7 +143,7 @@ static inline void check_workqueues(void) uint32_t flags = irq_nested_disable(); #ifdef CONFIG_ROCKCREEK - //icc_check(); +// icc_check(); icc_mail_check(); #endif diff --git a/kernel/mailbox.c b/kernel/mailbox.c index 8b7a8b78..e20e9e36 100644 --- a/kernel/mailbox.c +++ b/kernel/mailbox.c @@ -40,7 +40,6 @@ int STDCALL mail_ping(void* arg) { int mailbox_test_init(void) { char* argv[] = {"/bin/mailbox", NULL}; - kprintf( "### Hello from mailbox_test_init\n" ); create_kernel_task(NULL, mail_ping, argv); return 0; diff --git a/kernel/main.c b/kernel/main.c index f3b7d36f..50894054 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -114,13 +114,14 @@ int main(void) sleep(5); list_root(); - //test_init(); +// test_init(); kprintf( "calling mailbox test ... \n" ); mailbox_test_init(); kprintf( "mailbox test succeded!\n" ); per_core(current_task)->status = TASK_IDLE; reschedule(); + while(1) { #ifdef CONFIG_ROCKCREEK icc_halt();