diff options
author | Karsten Graul <kgraul@linux.ibm.com> | 2021-10-07 17:14:40 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-10-08 19:00:16 +0300 |
commit | 95f7f3e7dc6bd2e735cb5de11734ea2222b1e05a (patch) | |
tree | 1c4e9cea0b14fd5318202c0ef6dd8512df6989e6 /net/smc/smc_wr.h | |
parent | 097657c9a478df029e1d9b3602c3351e28927043 (diff) | |
download | linux-95f7f3e7dc6bd2e735cb5de11734ea2222b1e05a.tar.xz |
net/smc: improved fix wait on already cleared link
Commit 8f3d65c16679 ("net/smc: fix wait on already cleared link")
introduced link refcounting to avoid waits on already cleared links.
This patch extents and improves the refcounting to cover all
remaining possible cases for this kind of error situation.
Fixes: 15e1b99aadfb ("net/smc: no WR buffer wait for terminating link group")
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/smc/smc_wr.h')
-rw-r--r-- | net/smc/smc_wr.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/net/smc/smc_wr.h b/net/smc/smc_wr.h index 423b8709f1c9..2bc626f230a5 100644 --- a/net/smc/smc_wr.h +++ b/net/smc/smc_wr.h @@ -60,6 +60,20 @@ static inline void smc_wr_tx_set_wr_id(atomic_long_t *wr_tx_id, long val) atomic_long_set(wr_tx_id, val); } +static inline bool smc_wr_tx_link_hold(struct smc_link *link) +{ + if (!smc_link_usable(link)) + return false; + atomic_inc(&link->wr_tx_refcnt); + return true; +} + +static inline void smc_wr_tx_link_put(struct smc_link *link) +{ + if (atomic_dec_and_test(&link->wr_tx_refcnt)) + wake_up_all(&link->wr_tx_wait); +} + static inline void smc_wr_wakeup_tx_wait(struct smc_link *lnk) { wake_up_all(&lnk->wr_tx_wait); |