Skip to contentSkip to conversation

Race condition in mpc52xx_psc_spi

DISCUSSION stefano babic 1 participant 1 message Dec 8, 2008 SPI

lore
Share & tools
lore
#0 lore raw

Hi,

I have found a race condition in the PSC driver for the MPC5200. The effect is that the processor let the RXFIFO interrupt pending and the interrupt handler is called as soon as the IRQ is enabled again, not after receiving the number of bytes set with the FIFO Alarm (~400).

In fact:

	   recv_at_once = in_be16(&fifo->rfnum);
                             ^---RFNUM is read only once
		[...]
                if (rx_buf) {
                    for (; recv_at_once; rb++, recv_at_once--)
			[FIFO wird gelesen] <-- now further bytes are coming

Enabling the traces, I can check that the driver writes only 20-30 Bytes into the FIFO instead of 400 as set by the Alarm.
Because the FIFO does not become empty, according to the MPC5200 manual the RXRDY/FFULL interrupt is not removed and a new interrupt is generated at the next iteration.
This causes a lot of interrupts, much more as expected, generating an higher CPU load as the usage of the RXFIFO really requires.

I will send a patch for review in short time to fix this issue.

Stefano

Signature · 11 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: [email protected]
=====================================================================

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/