• Jon Hunter's avatar
    of: dma: fix potential deadlock when requesting a slave channel · 5ca7c109
    Jon Hunter authored
    In the latest version of the OF dma handlers I added support (rather hastily)
    to exhaustively search for an available dma slave channel, for the use-case
    where we have alternative slave channels that can be used. In the current
    implementation a deadlock scenario can occur causing the CPU to loop forever.
    The scenario is as follows ...
    
    1. There are alternative channels avaialble
    2. The first channel that is found by calling of_dma_find_channel() is not
       available and so the call to the xlate function returns NULL. In this case
       we will call of_dma_find_channel() again but we will return the same channel
       that we found the first time and hence, again the xlate will return NULL and
       we will loop here forever.
    
    Fix this potential deadlock by just using a single for-loop and not a for-loop
    nested in a do-while loop. This change also replaces the function
    of_dma_find_channel() with of_dma_match_channel() which performs a simple check
    to see if a DMA channel matches the name specified.
    
    I have tested this implementation on an OMAP4 panda board by adding a dummy
    DMA specifier, that will cause the xlate function to return NULL, to the
    beginning of a list of DMA specifiers for a DMA client.
    
    Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
    Cc: Benoit Cousson <b-cousson@ti.com>
    Cc: Stephen Warren <swarren@nvidia.com>
    Cc: Grant Likely <grant.likely@secretlab.ca>
    Cc: Russell King <linux@arm.linux.org.uk>
    Cc: Rob Herring <rob.herring@calxeda.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Vinod Koul <vinod.koul@intel.com>
    Cc: Dan Williams <djbw@fb.com>
    Signed-off-by: default avatarJon Hunter <jon-hunter@ti.com>
    Signed-off-by: default avatarVinod Koul <vinod.koul@linux.intel.com>
    5ca7c109
dma.c 5.72 KB