#2148 closed defect (fixed)

Blackfin doesn't switch tasks, resets dispatch_necessary before querying it

Reported by: Kolja Waschk Owned by: Joel Sherrill
Priority: highest Milestone: 4.11
Component: score Version: 4.11
Severity: normal Keywords:
Cc: sebastian.huber@… Blocked By:
Blocking:

Description (last modified by Joel Sherrill)

Problem xperienced with bf537Stamp BSP on real hardware (a board with ADSP-BF537 and just SDRAM and flash attached, only PLL, SDRAM, and UART are initialized):

The ticker sample starts its three tasks, but all stall forever in rtems_task_wake_after(x) for any x greater than 1. Only the Idle task runs.

The clockISR and rtems_clock_tick are executed and clock count is incremented.

Debugging via JTAG with breakpoint at _Thread_Delay_ends made me discover that:

  1. _Thread_Dispatch_necessary = true is set by _Scheduler_priority_unblock
  1. Then it is cleared in cpukit/score/cpu/bfin/cpu_asm.S:480 (doDispatch) by writing 0 to DISPATCH_NEEDED
  1. Finally _Thread_Dispatch, called by _ISR15_Handler, doesn't do any Context_Switch because per_cpu->dispatch_necessary (the very same byte) is zero.

As a workaround, removing the two lines after doDispatch in cpu_asm.S leads to a running ticker sample.

doDispatch:

/* r0 = 0: */
/* B[p0] = r0; */
raise 15;

I have not tried other tests yet. I suspect some more inconsistencies. This doesn't appear like it ever worked...?

Also see discussion here:
http://www.rtems.org/pipermail/rtems-users/2013-October/012038.html

Another occurence with similar outcome, maybe for the same reason:
http://www.rtems.org/pipermail/rtems-users/2013-May/011544.html

Probably in RTEMS since 2008, with background e.g. discussed here:
http://www.rtems.org/pipermail/rtems-users/2008-April/003129.html

Change History (7)

comment:1 Changed on Oct 16, 2013 at 6:30:08 AM by Sebastian Huber

Cc: Sebastian Huber added

comment:2 Changed on Aug 20, 2014 at 4:47:08 AM by Sebastian Huber

The general interrupt with thread dispatch sequence is depicted here:

http://www.rtems.org/wiki/index.php?title=SMP#Thread_Restart

comment:3 Changed on Nov 22, 2014 at 4:17:16 PM by Joel Sherrill

Description: modified (diff)

I have no recollection of a patch being submitted. Does anyone else?

Also the URLs for mail point to the old mhonarc archives so I am having trouble finding what they are talking about.

comment:4 Changed on Nov 24, 2014 at 10:34:10 AM by Kolja Waschk

There is no patch yet. We produce devices that are running very stable now, with the modification as noted in the issue description (commenting out the two lines in cpu_asm.S). But I have not been able to correctly identify all possible side effects nor run all tests (due to other problems).

Updates for the links:

Also see discussion here ("ticker hangs on bf537Stamp"):
http://lists.rtems.org/pipermail/users/2013-October/027186.html

Another occurence with similar outcome, maybe for the same reason ("bfin simulator problems"):
http://lists.rtems.org/pipermail/users/2013-May/026692.html

Probably in RTEMS since 2008, with background e.g. discussed here ("Problems with the blackfin port"):
http://lists.rtems.org/pipermail/users/2008-April/018266.html

comment:5 Changed on Nov 24, 2014 at 6:58:28 PM by Gedare Bloom

Version: HEAD4.11

Replace Version=HEAD with Version=4.11 for the tickets with Milestone >= 4.11

comment:6 Changed on Dec 19, 2014 at 5:06:18 AM by Gedare Bloom

Priority: normalhighest

Bump priority to highest for tickets with a fix attached or seemingly simple fix proposed in the description or comments.

comment:7 Changed on Feb 19, 2015 at 8:50:38 PM by Gedare Bloom <gedare@…>

Resolution: fixed
Status: newclosed

In 7f1bb40aa1b87bc346bd07b893ebdd5c35e10410/rtems:

bfin: do not reset dispatch needed

Closes #2148

Fix suggested in above ticket. On examination, the assembly
appears to be clearing the DISPATCH_NEEDED flag before jumping
to _Thread_Dispatch.

Note: See TracTickets for help on using tickets.