On 2020/1/29 3:56, Jason Gunthorpe wrote: > On Wed, Jan 15, 2020 at 05:49:13PM +0800, Yixian Liu wrote: >> - if (ret) { >> - spin_unlock_irqrestore(&qp->sq.lock, flags); >> - *bad_wr = wr; >> - return ret; >> + if (atomic_read(&qp->flush_cnt) == 0) { >> + atomic_set(&qp->flush_cnt, 1); >> + init_flush_work(hr_dev, qp); >> + } else { >> + atomic_inc(&qp->flush_cnt); >> } > > Surely this should be written using atomic_add_return ?? > > Jason Hi Jason, Thanks very much for your good suggestion! The code then can be simplified as: if (atomic_add_return(1, &qp->flush_cnt) == 1) init_flush_work(hr_dev, qp); > >