2021-08-23 12:26:22 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause
|
2016-02-15 04:44:34 +08:00
|
|
|
/*
|
2018-06-21 00:29:08 +08:00
|
|
|
* Copyright(c) 2016 - 2018 Intel Corporation.
|
2016-02-15 04:44:34 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "hfi.h"
|
|
|
|
#include "verbs_txreq.h"
|
|
|
|
#include "qp.h"
|
|
|
|
#include "trace.h"
|
|
|
|
|
|
|
|
#define TXREQ_LEN 24
|
|
|
|
|
|
|
|
void hfi1_put_txreq(struct verbs_txreq *tx)
|
|
|
|
{
|
|
|
|
struct hfi1_ibdev *dev;
|
|
|
|
struct rvt_qp *qp;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int seq;
|
|
|
|
struct hfi1_qp_priv *priv;
|
|
|
|
|
|
|
|
qp = tx->qp;
|
|
|
|
dev = to_idev(qp->ibqp.device);
|
|
|
|
|
|
|
|
if (tx->mr)
|
|
|
|
rvt_put_mr(tx->mr);
|
|
|
|
|
|
|
|
sdma_txclean(dd_from_dev(dev), &tx->txreq);
|
|
|
|
|
|
|
|
/* Free verbs_txreq and return to slab cache */
|
|
|
|
kmem_cache_free(dev->verbs_txreq_cache, tx);
|
|
|
|
|
|
|
|
do {
|
2016-10-10 21:14:28 +08:00
|
|
|
seq = read_seqbegin(&dev->txwait_lock);
|
2016-02-15 04:44:34 +08:00
|
|
|
if (!list_empty(&dev->txwait)) {
|
|
|
|
struct iowait *wait;
|
|
|
|
|
2016-10-10 21:14:28 +08:00
|
|
|
write_seqlock_irqsave(&dev->txwait_lock, flags);
|
2016-02-15 04:44:34 +08:00
|
|
|
wait = list_first_entry(&dev->txwait, struct iowait,
|
|
|
|
list);
|
|
|
|
qp = iowait_to_qp(wait);
|
|
|
|
priv = qp->priv;
|
|
|
|
list_del_init(&priv->s_iowait.list);
|
|
|
|
/* refcount held until actual wake up */
|
2016-10-10 21:14:28 +08:00
|
|
|
write_sequnlock_irqrestore(&dev->txwait_lock, flags);
|
2016-02-15 04:44:34 +08:00
|
|
|
hfi1_qp_wakeup(qp, RVT_S_WAIT_TX);
|
|
|
|
break;
|
|
|
|
}
|
2016-10-10 21:14:28 +08:00
|
|
|
} while (read_seqretry(&dev->txwait_lock, seq));
|
2016-02-15 04:44:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct verbs_txreq *__get_txreq(struct hfi1_ibdev *dev,
|
|
|
|
struct rvt_qp *qp)
|
2016-06-18 10:17:49 +08:00
|
|
|
__must_hold(&qp->s_lock)
|
2016-02-15 04:44:34 +08:00
|
|
|
{
|
2018-06-21 00:29:08 +08:00
|
|
|
struct verbs_txreq *tx = NULL;
|
2016-02-15 04:44:34 +08:00
|
|
|
|
2016-10-10 21:14:28 +08:00
|
|
|
write_seqlock(&dev->txwait_lock);
|
2016-02-15 04:44:34 +08:00
|
|
|
if (ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK) {
|
|
|
|
struct hfi1_qp_priv *priv;
|
|
|
|
|
IB/hfi1: Silence txreq allocation warnings
The following warning can happen when a memory shortage
occurs during txreq allocation:
[10220.939246] SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
[10220.939246] Hardware name: Intel Corporation S2600WT2R/S2600WT2R, BIOS SE5C610.86B.01.01.0018.C4.072020161249 07/20/2016
[10220.939247] cache: mnt_cache, object size: 384, buffer size: 384, default order: 2, min order: 0
[10220.939260] Workqueue: hfi0_0 _hfi1_do_send [hfi1]
[10220.939261] node 0: slabs: 1026568, objs: 43115856, free: 0
[10220.939262] Call Trace:
[10220.939262] node 1: slabs: 820872, objs: 34476624, free: 0
[10220.939263] dump_stack+0x5a/0x73
[10220.939265] warn_alloc+0x103/0x190
[10220.939267] ? wake_all_kswapds+0x54/0x8b
[10220.939268] __alloc_pages_slowpath+0x86c/0xa2e
[10220.939270] ? __alloc_pages_nodemask+0x2fe/0x320
[10220.939271] __alloc_pages_nodemask+0x2fe/0x320
[10220.939273] new_slab+0x475/0x550
[10220.939275] ___slab_alloc+0x36c/0x520
[10220.939287] ? hfi1_make_rc_req+0x90/0x18b0 [hfi1]
[10220.939299] ? __get_txreq+0x54/0x160 [hfi1]
[10220.939310] ? hfi1_make_rc_req+0x90/0x18b0 [hfi1]
[10220.939312] __slab_alloc+0x40/0x61
[10220.939323] ? hfi1_make_rc_req+0x90/0x18b0 [hfi1]
[10220.939325] kmem_cache_alloc+0x181/0x1b0
[10220.939336] hfi1_make_rc_req+0x90/0x18b0 [hfi1]
[10220.939348] ? hfi1_verbs_send_dma+0x386/0xa10 [hfi1]
[10220.939359] ? find_prev_entry+0xb0/0xb0 [hfi1]
[10220.939371] hfi1_do_send+0x1d9/0x3f0 [hfi1]
[10220.939372] process_one_work+0x171/0x380
[10220.939374] worker_thread+0x49/0x3f0
[10220.939375] kthread+0xf8/0x130
[10220.939377] ? max_active_store+0x80/0x80
[10220.939378] ? kthread_bind+0x10/0x10
[10220.939379] ret_from_fork+0x35/0x40
[10220.939381] SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC)
The shortage is handled properly so the message isn't needed. Silence by
adding the no warn option to the slab allocation.
Fixes: 45842abbb292 ("staging/rdma/hfi1: move txreq header code")
Cc: <stable@vger.kernel.org>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2019-06-15 00:32:32 +08:00
|
|
|
tx = kmem_cache_alloc(dev->verbs_txreq_cache, VERBS_TXREQ_GFP);
|
2016-02-15 04:44:34 +08:00
|
|
|
if (tx)
|
|
|
|
goto out;
|
|
|
|
priv = qp->priv;
|
|
|
|
if (list_empty(&priv->s_iowait.list)) {
|
|
|
|
dev->n_txwait++;
|
|
|
|
qp->s_flags |= RVT_S_WAIT_TX;
|
|
|
|
list_add_tail(&priv->s_iowait.list, &dev->txwait);
|
2016-10-10 21:14:28 +08:00
|
|
|
priv->s_iowait.lock = &dev->txwait_lock;
|
2016-02-15 04:44:34 +08:00
|
|
|
trace_hfi1_qpsleep(qp, RVT_S_WAIT_TX);
|
2016-09-06 19:34:35 +08:00
|
|
|
rvt_get_qp(qp);
|
2016-02-15 04:44:34 +08:00
|
|
|
}
|
|
|
|
qp->s_flags &= ~RVT_S_BUSY;
|
|
|
|
}
|
|
|
|
out:
|
2016-10-10 21:14:28 +08:00
|
|
|
write_sequnlock(&dev->txwait_lock);
|
2016-02-15 04:44:34 +08:00
|
|
|
return tx;
|
|
|
|
}
|
|
|
|
|
|
|
|
int verbs_txreq_init(struct hfi1_ibdev *dev)
|
|
|
|
{
|
|
|
|
char buf[TXREQ_LEN];
|
|
|
|
struct hfi1_devdata *dd = dd_from_dev(dev);
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "hfi1_%u_vtxreq_cache", dd->unit);
|
|
|
|
dev->verbs_txreq_cache = kmem_cache_create(buf,
|
|
|
|
sizeof(struct verbs_txreq),
|
|
|
|
0, SLAB_HWCACHE_ALIGN,
|
2017-08-22 09:26:45 +08:00
|
|
|
NULL);
|
2016-02-15 04:44:34 +08:00
|
|
|
if (!dev->verbs_txreq_cache)
|
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void verbs_txreq_exit(struct hfi1_ibdev *dev)
|
|
|
|
{
|
|
|
|
kmem_cache_destroy(dev->verbs_txreq_cache);
|
|
|
|
dev->verbs_txreq_cache = NULL;
|
|
|
|
}
|