Skip to content

Commit

Permalink
IB/hfi1: Close PSM sdma_progress sleep window
Browse files Browse the repository at this point in the history
The call to sdma_progress() is called outside the wait lock.

In this case, there is a race condition where sdma_progress() can return
false and the sdma_engine can idle.  If that happens, there will be no
more sdma interrupts to cause the wakeup and the user_sdma xmit will hang.

Fix by moving the lock to enclose the sdma_progress() call.

Also, delete busycount. The need for this was removed by:
commit bcad291 ("IB/hfi1: Serve the most starved iowait entry first")

Cc: <[email protected]>
Fixes: 7724105 ("IB/hfi1: add driver files")
Reviewed-by: Gary Leshner <[email protected]>
Signed-off-by: Mike Marciniszyn <[email protected]>
Signed-off-by: Dennis Dalessandro <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
  • Loading branch information
mmarcini authored and jgunthorpe committed Jun 11, 2019
1 parent 5f90677 commit da9de5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
12 changes: 4 additions & 8 deletions drivers/infiniband/hw/hfi1/user_sdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,24 @@ static int defer_packet_queue(
{
struct hfi1_user_sdma_pkt_q *pq =
container_of(wait->iow, struct hfi1_user_sdma_pkt_q, busy);
struct user_sdma_txreq *tx =
container_of(txreq, struct user_sdma_txreq, txreq);

if (sdma_progress(sde, seq, txreq)) {
if (tx->busycount++ < MAX_DEFER_RETRY_COUNT)
goto eagain;
}
write_seqlock(&sde->waitlock);
if (sdma_progress(sde, seq, txreq))
goto eagain;
/*
* We are assuming that if the list is enqueued somewhere, it
* is to the dmawait list since that is the only place where
* it is supposed to be enqueued.
*/
xchg(&pq->state, SDMA_PKT_Q_DEFERRED);
write_seqlock(&sde->waitlock);
if (list_empty(&pq->busy.list)) {
iowait_get_priority(&pq->busy);
iowait_queue(pkts_sent, &pq->busy, &sde->dmawait);
}
write_sequnlock(&sde->waitlock);
return -EBUSY;
eagain:
write_sequnlock(&sde->waitlock);
return -EAGAIN;
}

Expand Down Expand Up @@ -804,7 +801,6 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, u16 maxpkts)

tx->flags = 0;
tx->req = req;
tx->busycount = 0;
INIT_LIST_HEAD(&tx->list);

/*
Expand Down
1 change: 0 additions & 1 deletion drivers/infiniband/hw/hfi1/user_sdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ struct user_sdma_txreq {
struct list_head list;
struct user_sdma_request *req;
u16 flags;
unsigned int busycount;
u16 seqnum;
};

Expand Down

0 comments on commit da9de5f

Please sign in to comment.