hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/net/9p/trans_rdma.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/fs/9p/trans_rdma.c
34 *
....@@ -8,22 +9,6 @@
89 * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net>
910 * Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com>
1011 * Copyright (C) 1997-2002 by Ron Minnich <rminnich@sarnoff.com>
11
- *
12
- * This program is free software; you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public License version 2
14
- * as published by the Free Software Foundation.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program; if not, write to:
23
- * Free Software Foundation
24
- * 51 Franklin Street, Fifth Floor
25
- * Boston, MA 02111-1301 USA
26
- *
2712 */
2813
2914 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -109,14 +94,15 @@
10994 struct completion cm_done;
11095 };
11196
97
+struct p9_rdma_req;
98
+
11299 /**
113
- * p9_rdma_context - Keeps track of in-process WR
100
+ * struct p9_rdma_context - Keeps track of in-process WR
114101 *
115102 * @busa: Bus address to unmap when the WR completes
116103 * @req: Keeps track of requests (send)
117104 * @rc: Keepts track of replies (receive)
118105 */
119
-struct p9_rdma_req;
120106 struct p9_rdma_context {
121107 struct ib_cqe cqe;
122108 dma_addr_t busa;
....@@ -127,7 +113,7 @@
127113 };
128114
129115 /**
130
- * p9_rdma_opts - Collection of mount options
116
+ * struct p9_rdma_opts - Collection of mount options
131117 * @port: port of connection
132118 * @sq_depth: The requested depth of the SQ. This really doesn't need
133119 * to be any deeper than the number of threads used in the client
....@@ -400,6 +386,7 @@
400386 struct p9_trans_rdma *rdma = client->trans;
401387 struct ib_recv_wr wr;
402388 struct ib_sge sge;
389
+ int ret;
403390
404391 c->busa = ib_dma_map_single(rdma->cm_id->device,
405392 c->rc.sdata, client->msize,
....@@ -417,7 +404,12 @@
417404 wr.wr_cqe = &c->cqe;
418405 wr.sg_list = &sge;
419406 wr.num_sge = 1;
420
- return ib_post_recv(rdma->qp, &wr, NULL);
407
+
408
+ ret = ib_post_recv(rdma->qp, &wr, NULL);
409
+ if (ret)
410
+ ib_dma_unmap_single(rdma->cm_id->device, c->busa,
411
+ client->msize, DMA_FROM_DEVICE);
412
+ return ret;
421413
422414 error:
423415 p9_debug(P9_DEBUG_ERROR, "EIO\n");
....@@ -514,7 +506,7 @@
514506
515507 if (down_interruptible(&rdma->sq_sem)) {
516508 err = -EINTR;
517
- goto send_error;
509
+ goto dma_unmap;
518510 }
519511
520512 /* Mark request as `sent' *before* we actually send it,
....@@ -524,11 +516,14 @@
524516 req->status = REQ_STATUS_SENT;
525517 err = ib_post_send(rdma->qp, &wr, NULL);
526518 if (err)
527
- goto send_error;
519
+ goto dma_unmap;
528520
529521 /* Success */
530522 return 0;
531523
524
+dma_unmap:
525
+ ib_dma_unmap_single(rdma->cm_id->device, c->busa,
526
+ c->req->tc.size, DMA_TO_DEVICE);
532527 /* Handle errors that happened during or while preparing the send: */
533528 send_error:
534529 req->status = REQ_STATUS_ERROR;
....@@ -700,9 +695,9 @@
700695 goto error;
701696
702697 /* Create the Completion Queue */
703
- rdma->cq = ib_alloc_cq(rdma->cm_id->device, client,
704
- opts.sq_depth + opts.rq_depth + 1,
705
- 0, IB_POLL_SOFTIRQ);
698
+ rdma->cq = ib_alloc_cq_any(rdma->cm_id->device, client,
699
+ opts.sq_depth + opts.rq_depth + 1,
700
+ IB_POLL_SOFTIRQ);
706701 if (IS_ERR(rdma->cq))
707702 goto error;
708703