Skip to content

Commit

Permalink
fix DMA deadlock size <= 0
Browse files Browse the repository at this point in the history
When passed a size of 0 or less, spin__memcpy_nonblk will deadlock.
Fixed by adding a case distinction over the size. The expectation is, that the if statement nearly always evaluates to 1.
  • Loading branch information
clemenkl authored May 5, 2021
1 parent eed6346 commit 43f301b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sw/runtime/include/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ typedef struct spin_rw_lock {

static inline int spin_dma(void* source, void* dest, size_t size, int direction, int options, spin_dma_t* xfer)
{
*xfer = spin__memcpy_nonblk(source, dest, (uint32_t)size);
return SPIN_OK;
if (__builtin_expect(size>0, 1))
{
*xfer = spin__memcpy_nonblk(source, dest, (uint32_t)size);
return SPIN_OK;
} else
{
return SPIN_FAIL;
}
}

static inline int spin_dma_wait(spin_dma_t xfer)
Expand Down

0 comments on commit 43f301b

Please sign in to comment.