Re: [PATCH] rapidio: use a reference count for struct mport_dma_req

From: Alex Bounine
Date: Mon Apr 09 2018 - 15:39:52 EST



On 2018-04-05 04:33 PM, Ioan Nicu wrote:
Once the dma request is passed to the DMA engine, the DMA
subsystem would hold a pointer to this structure and could
call the completion callback after do_dma_request() has
timed out.

The current code deals with this by putting timed out SYNC
requests to a pending list and freeing them later, when the
mport cdev device is released. But this still does not
guarantee that the DMA subsystem is really done with those
transfers, so in theory dma_xfer_callback/dma_req_free
could be called after mport_cdev_release_dma and could
potentially access already freed memory.

This patch simplifies the current handling by using a kref
in the mport dma request structure, so that it gets freed
only when nobody uses it anymore.

This also simplifies the code a bit, as FAF transfers are
now handled in the same way as SYNC and ASYNC transfers.
There is no need anymore for the pending list and for the
dma workqueue which was used in case of FAF transfers, so
we remove them both.

Signed-off-by: Ioan Nicu <ioan.nicu.ext@xxxxxxxxx>
---
drivers/rapidio/devices/rio_mport_cdev.c | 122 +++++--------------------------
1 file changed, 18 insertions(+), 104 deletions(-)

Acked-by: Alexandre Bounine <alex.bou9@xxxxxxxxx>