From: Or Har-Toov <ohartoov@xxxxxxxxxx> Remove the done list, which has become unnecessary with the introduction of the `state` parameter. Previously, the done list was used to ensure that MADs removed from the wait list would still be in some list, preventing failures in the call to `list_del` in `ib_mad_complete_send_wr`. However, with the new state management, we can mark a MAD as done when it is completed and simply not delete those MADs. Removing the done list eliminates unnecessary memory usage and simplifies the code. Signed-off-by: Or Har-Toov <ohartoov@xxxxxxxxxx> Reviewed-by: Maher Sanalla <msanalla@xxxxxxxxxx> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx> --- drivers/infiniband/core/mad.c | 13 ++++++------- drivers/infiniband/core/mad_priv.h | 1 - 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index 9b101f91ca3e..e16bc396f6bc 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c @@ -391,7 +391,6 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, spin_lock_init(&mad_agent_priv->lock); INIT_LIST_HEAD(&mad_agent_priv->send_list); INIT_LIST_HEAD(&mad_agent_priv->wait_list); - INIT_LIST_HEAD(&mad_agent_priv->done_list); INIT_LIST_HEAD(&mad_agent_priv->rmpp_list); INIT_DELAYED_WORK(&mad_agent_priv->timed_work, timeout_sends); INIT_LIST_HEAD(&mad_agent_priv->local_list); @@ -1772,13 +1771,11 @@ ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv, void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr) { mad_send_wr->timeout = 0; - if (mad_send_wr->state == IB_MAD_STATE_WAIT_RESP) { + list_del(&mad_send_wr->agent_list); + if (mad_send_wr->state == IB_MAD_STATE_WAIT_RESP) mad_send_wr->state = IB_MAD_STATE_DONE; - list_move_tail(&mad_send_wr->agent_list, - &mad_send_wr->mad_agent_priv->done_list); - } else { + else mad_send_wr->state = IB_MAD_STATE_EARLY_RESP; - } } static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, @@ -2249,7 +2246,9 @@ void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr, } /* Remove send from MAD agent and notify client of completion */ - list_del(&mad_send_wr->agent_list); + if (mad_send_wr->state == IB_MAD_STATE_SEND_START) + list_del(&mad_send_wr->agent_list); + adjust_timeout(mad_agent_priv); spin_unlock_irqrestore(&mad_agent_priv->lock, flags); diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h index cc2de81ea6f6..4af63c1664c2 100644 --- a/drivers/infiniband/core/mad_priv.h +++ b/drivers/infiniband/core/mad_priv.h @@ -96,7 +96,6 @@ struct ib_mad_agent_private { spinlock_t lock; struct list_head send_list; struct list_head wait_list; - struct list_head done_list; struct delayed_work timed_work; unsigned long timeout; struct list_head local_list; -- 2.47.0