net/smc: remove redundant dma sync ops
authorGuangguan Wang <guangguan.wang@linux.alibaba.com>
Thu, 14 Jul 2022 09:44:00 +0000 (17:44 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 Jul 2022 10:19:16 +0000 (11:19 +0100)
smc_ib_sync_sg_for_cpu/device are the ops used for dma memory cache
consistency. Smc sndbufs are dma buffers, where CPU writes data to
it and PCIE device reads data from it. So for sndbufs,
smc_ib_sync_sg_for_device is needed and smc_ib_sync_sg_for_cpu is
redundant as PCIE device will not write the buffers. Smc rmbs
are dma buffers, where PCIE device write data to it and CPU read
data from it. So for rmbs, smc_ib_sync_sg_for_cpu is needed and
smc_ib_sync_sg_for_device is redundant as CPU will not write the buffers.

Signed-off-by: Guangguan Wang <guangguan.wang@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/af_smc.c
net/smc/smc_core.c
net/smc/smc_core.h
net/smc/smc_rx.c
net/smc/smc_tx.c

index 433bb5a7df31e24472fa86c0aa271cc0956e0230..9497a3b9ad096a6053fae0cf8a8bf5d8dae93e9e 100644 (file)
@@ -1226,7 +1226,6 @@ static int smc_connect_rdma(struct smc_sock *smc,
                        goto connect_abort;
                }
        }
-       smc_rmb_sync_sg_for_device(&smc->conn);
 
        if (aclc->hdr.version > SMC_V1) {
                struct smc_clc_msg_accept_confirm_v2 *clc_v2 =
@@ -2113,7 +2112,6 @@ static int smc_listen_rdma_reg(struct smc_sock *new_smc, bool local_first)
                if (smcr_lgr_reg_rmbs(conn->lnk, conn->rmb_desc))
                        return SMC_CLC_DECL_ERR_REGRMB;
        }
-       smc_rmb_sync_sg_for_device(&new_smc->conn);
 
        return 0;
 }
index f40f6ed0fbdb4450a17a5f9fab4117ac8aa78b38..1faa0cb661e4160e985be08f488dd7e5cb646550 100644 (file)
@@ -2290,14 +2290,6 @@ static int __smc_buf_create(struct smc_sock *smc, bool is_smcd, bool is_rmb)
        return 0;
 }
 
-void smc_sndbuf_sync_sg_for_cpu(struct smc_connection *conn)
-{
-       if (!smc_conn_lgr_valid(conn) || conn->lgr->is_smcd ||
-           !smc_link_active(conn->lnk))
-               return;
-       smc_ib_sync_sg_for_cpu(conn->lnk, conn->sndbuf_desc, DMA_TO_DEVICE);
-}
-
 void smc_sndbuf_sync_sg_for_device(struct smc_connection *conn)
 {
        if (!smc_conn_lgr_valid(conn) || conn->lgr->is_smcd ||
@@ -2320,20 +2312,6 @@ void smc_rmb_sync_sg_for_cpu(struct smc_connection *conn)
        }
 }
 
-void smc_rmb_sync_sg_for_device(struct smc_connection *conn)
-{
-       int i;
-
-       if (!smc_conn_lgr_valid(conn) || conn->lgr->is_smcd)
-               return;
-       for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) {
-               if (!smc_link_active(&conn->lgr->lnk[i]))
-                       continue;
-               smc_ib_sync_sg_for_device(&conn->lgr->lnk[i], conn->rmb_desc,
-                                         DMA_FROM_DEVICE);
-       }
-}
-
 /* create the send and receive buffer for an SMC socket;
  * receive buffers are called RMBs;
  * (even though the SMC protocol allows more than one RMB-element per RMB,
index 4cb03e94236481508c7b072e70bcc34cf4894a21..c441dfeefa02303409c9a81919fae1dd051cd0ec 100644 (file)
@@ -513,10 +513,8 @@ void smc_rtoken_set(struct smc_link_group *lgr, int link_idx, int link_idx_new,
                    __be32 nw_rkey_known, __be64 nw_vaddr, __be32 nw_rkey);
 void smc_rtoken_set2(struct smc_link_group *lgr, int rtok_idx, int link_id,
                     __be64 nw_vaddr, __be32 nw_rkey);
-void smc_sndbuf_sync_sg_for_cpu(struct smc_connection *conn);
 void smc_sndbuf_sync_sg_for_device(struct smc_connection *conn);
 void smc_rmb_sync_sg_for_cpu(struct smc_connection *conn);
-void smc_rmb_sync_sg_for_device(struct smc_connection *conn);
 int smc_vlan_by_tcpsk(struct socket *clcsock, struct smc_init_info *ini);
 
 void smc_conn_free(struct smc_connection *conn);
index 338b9ef806e8202c7b41a3294cf5e8ce72e4f9f8..00ad004835e64bf2b4ad5364b356eaf2d716be82 100644 (file)
@@ -413,7 +413,6 @@ copy:
                                if (rc < 0) {
                                        if (!read_done)
                                                read_done = -EFAULT;
-                                       smc_rmb_sync_sg_for_device(conn);
                                        goto out;
                                }
                        }
@@ -427,7 +426,6 @@ copy:
                        chunk_len_sum += chunk_len;
                        chunk_off = 0; /* modulo offset in recv ring buffer */
                }
-               smc_rmb_sync_sg_for_device(conn);
 
                /* update cursors */
                if (!(flags & MSG_PEEK)) {
index 805a546e8c04fd3be8899704d95ebf25ff104cdd..ca0d5f57908ca6c55b86fd3d166a0bf8f4853abc 100644 (file)
@@ -246,7 +246,6 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
                                  tx_cnt_prep);
                chunk_len_sum = chunk_len;
                chunk_off = tx_cnt_prep;
-               smc_sndbuf_sync_sg_for_cpu(conn);
                for (chunk = 0; chunk < 2; chunk++) {
                        rc = memcpy_from_msg(sndbuf_base + chunk_off,
                                             msg, chunk_len);