On Fri, Sep 01, 2023 at 11:22:47AM -0600, Jeffrey Hugo wrote:
> From: Pranjal Ramajor Asha Kanojiya <[email protected]>
>
> Once a BO is attached with slicing configuration that BO can only be used
> for that particular setting. With this new feature user can detach slicing
> configuration off an already sliced BO and attach new slicing configuration
> using QAIC_ATTACH_SLICE_BO.
>
> This will support BO recycling.
>
> detach_slice_bo() detaches slicing configuration from a BO. This new
> helper function can also be used in release_dbc() as we are doing the
> exact same thing.
>
> Signed-off-by: Pranjal Ramajor Asha Kanojiya <[email protected]>
> Reviewed-by: Jeffrey Hugo <[email protected]>
> [jhugo: add documentation for new ioctl]
> Signed-off-by: Jeffrey Hugo <[email protected]>
<snip>
> + /* Check if BO is committed to H/W for DMA */
> + spin_lock_irqsave(&dbc->xfer_lock, flags);
> + if (bo->queued) {
> + spin_unlock_irqrestore(&dbc->xfer_lock, flags);
> + ret = -EBUSY;
> + goto unlock_ch_srcu;
> + }
> + spin_unlock_irqrestore(&dbc->xfer_lock, flags);
This looks like race condition. If some other thread will take the xfer_lock
and set bo->queued (HERE just after _unlock()) we will not return -EBUSY.
Something seems to be missing here or xfer_lock is not needed to protect
bo->queued.
Regards
Stanislaw