Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp381360imw; Thu, 14 Jul 2022 03:13:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1swwJMko2I3Sq9BtM0KSMc9SJCjS9YmX9fhzsusaza5Y+rxmos3mvKDtAbTh5oAZQOM6e5q X-Received: by 2002:a63:4d61:0:b0:412:6081:4bbf with SMTP id n33-20020a634d61000000b0041260814bbfmr6915188pgl.109.1657793588650; Thu, 14 Jul 2022 03:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657793588; cv=none; d=google.com; s=arc-20160816; b=JqFrcZ5glfujXFxnBPWl+zKKOrom33IXMxd0iZojDO5EjHpNzTptfeQQDRx09UAWY1 oyzgtAQzb34rtKE/EKHwEYxLe1j6/IrEyU+ur809kiea8qFvg4hxyIxJtPuf6rYxPJkH 7mItqPFvogSrVNTqdFhP0wu1a590bQSZHr5CxlaFlsOIYfcz9rZYbz/bs61bWHr68CnL 7g82bFuugeyFPPhmb9VSXMAfMoQg31FhoyV+moP7A0bmsWSmYYLqBq8dExhw/VBBOD1M 7CW4Q5IfCeWPNmfDP6stS2h8O3gS/wSb8yiYv8/r51emTzg+cJR793xjBuZgOA0+niHI cUnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=ICTPoLWKUL6dd0xTItfyKdU8ndlEuJ09ay934IHma3c=; b=VzQfB348wIiEOLrZDjqlb2RPCmVOXD9JE+xDu6WBnETfM83xbLhSzMxMfxhm1zeyoH enhOTNVGctmSCLnWiDtAnQbBRobp1LqrhQRka0bdNChpQykdbc8CGQqQgRTLW4KrDra9 FKT8Rr8aZUDk+w8fBDt0fhl1OhGc9guF/l22u5hOBGRCm+UWwu3hMnt9dObuLsN1mUhH 2D+2DkApDl8M1vtSwPXMA33nCw8adj+O976wpuIhBhi9PEmkYjX4JB93ZVsV/5O8qI6Y 2k5xiKv+2YzxAyuY0GL2/41gZ8lUxqDsphhfp9fBkgtheim3A844Ts84i8Rq08zG6gZ5 P9Sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a170902d55000b0016b8a75244bsi1394897plf.62.2022.07.14.03.12.55; Thu, 14 Jul 2022 03:13:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238394AbiGNJpC (ORCPT + 99 others); Thu, 14 Jul 2022 05:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238429AbiGNJoq (ORCPT ); Thu, 14 Jul 2022 05:44:46 -0400 Received: from out199-5.us.a.mail.aliyun.com (out199-5.us.a.mail.aliyun.com [47.90.199.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABBD72125F; Thu, 14 Jul 2022 02:44:43 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R601e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VJIcptN_1657791854; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0VJIcptN_1657791854) by smtp.aliyun-inc.com; Thu, 14 Jul 2022 17:44:38 +0800 From: Wen Gu To: kgraul@linux.ibm.com, wenjia@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 1/6] net/smc: remove redundant dma sync ops Date: Thu, 14 Jul 2022 17:44:00 +0800 Message-Id: <1657791845-1060-2-git-send-email-guwen@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1657791845-1060-1-git-send-email-guwen@linux.alibaba.com> References: <1657791845-1060-1-git-send-email-guwen@linux.alibaba.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guangguan Wang 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 --- net/smc/af_smc.c | 2 -- net/smc/smc_core.c | 22 ---------------------- net/smc/smc_core.h | 2 -- net/smc/smc_rx.c | 2 -- net/smc/smc_tx.c | 1 - 5 files changed, 29 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 433bb5a7..9497a3b 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -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; } diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index f40f6ed..1faa0cb 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -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, diff --git a/net/smc/smc_core.h b/net/smc/smc_core.h index 4cb03e9..c441dfe 100644 --- a/net/smc/smc_core.h +++ b/net/smc/smc_core.h @@ -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); diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c index 338b9ef..00ad004 100644 --- a/net/smc/smc_rx.c +++ b/net/smc/smc_rx.c @@ -413,7 +413,6 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg, if (rc < 0) { if (!read_done) read_done = -EFAULT; - smc_rmb_sync_sg_for_device(conn); goto out; } } @@ -427,7 +426,6 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg, 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)) { diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c index 805a546..ca0d5f5 100644 --- a/net/smc/smc_tx.c +++ b/net/smc/smc_tx.c @@ -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); -- 1.8.3.1