🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26757

[PATCH net v2] net/smc: unmap the sg table when a DMA map coalesces entries

#26757
From: Mahanta Jambigi
Date: Fri, 04 Dec 2026 05:56
67 lines
14449 bytes
When a device coalesces the entries of a virtually contiguous buffer,
ib_dma_map_sg() maps fewer entries than requested. smcr_buf_map_link()
fails the link with -EAGAIN but only frees the sg table, leaving the DMA
mapping behind.

Unmap the partial mapping in smc_ib_buf_map_sg() and return 0 or an
error, so the caller only has to free the table on failure.

Fixes: b8d199451c99 ("net/smc: Allow virtually contiguous sndbufs or RMBs for SMC-R")
Signed-off-by: Mahanta Jambigi <mjambigi@linux.ibm.com>
---
Changes in v2:
- Unmap a coalesced DMA map inside smc_ib_buf_map_sg(), which now
  returns 0 or an error, so smcr_buf_map_link() only frees the sg
  table on failure.  This follows Dust Li's review.

 net/smc/smc_core.c |  3 +--
 net/smc/smc_ib.c   | 14 +++++++++-----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index a3164201c142..555fae1f33d6 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -2223,8 +2223,7 @@ static int smcr_buf_map_link(struct smc_buf_desc *buf_desc, bool is_rmb,
 	/* map sg table to DMA address */
 	rc = smc_ib_buf_map_sg(lnk, buf_desc,
 			       is_rmb ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
-	/* SMC protocol depends on mapping to one DMA address only */
-	if (rc != nents) {
+	if (rc) {
 		rc = -EAGAIN;
 		goto free_table;
 	}
diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c
index daaa8a72da90..41cfa1b7a353 100644
--- a/net/smc/smc_ib.c
+++ b/net/smc/smc_ib.c
@@ -818,16 +818,20 @@ int smc_ib_buf_map_sg(struct smc_link *lnk,
 		      struct smc_buf_desc *buf_slot,
 		      enum dma_data_direction data_direction)
 {
+	struct scatterlist *sgl = buf_slot->sgt[lnk->link_idx].sgl;
+	int nents = buf_slot->sgt[lnk->link_idx].orig_nents;
 	int mapped_nents;
 
-	mapped_nents = ib_dma_map_sg(lnk->smcibdev->ibdev,
-				     buf_slot->sgt[lnk->link_idx].sgl,
-				     buf_slot->sgt[lnk->link_idx].orig_nents,
+	mapped_nents = ib_dma_map_sg(lnk->smcibdev->ibdev, sgl, nents,
 				     data_direction);
 	if (!mapped_nents)
 		return -ENOMEM;
-
-	return mapped_nents;
+	/* SMC protocol depends on mapping to one DMA address only */
+	if (mapped_nents != nents) {
+		smc_ib_buf_unmap_sg(lnk, buf_slot, data_direction);
+		return -EAGAIN;
+	}
+	return 0;
 }
 
 void smc_ib_buf_unmap_sg(struct smc_link *lnk,
-- 
2.50.1 (Apple Git-155)
Technical Details
Message-ID: <20261204055639.228261-1-mjambigi@linux.ibm.com>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377089-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377089-linux-kernel-netdev=dewy.ru
From: mjambigi@linux.ibm.com (Mahanta Jambigi)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2] net/smc: unmap the sg table when a DMA map coalesces entries
Date: Fri,  4 Dec 2026 06:56:39 +0100
Organization: Usenet Network
Message-ID: <20261204055639.228261-1-mjambigi@linux.ibm.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2686936"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:iTHN5WjGodswawW1NL0mDzngy6w= sha256:2T2lF3hEDcPLnKyf9MtPLlwOv3m+SP7gwW2O5V+2YEE=
	sha1:k5kk766AQV8sHsbwT7433oXznvM= sha256:zrNDZaWKfQy4OaO4w9oQUrGb6c7qrvlJFXwoxcX4XyE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D0619117B18; Fri,  4 Dec 2026 08:57:21 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.199
X-Spam-Status: No, score=-3.199 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.001, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=ibm.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id D2uB7dLy9Ia9;
	Fri,  4 Dec 2026 08:57:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-377089-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=linux.ibm.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id AE471117AA4; Fri,  4 Dec 2026 08:57:09 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id BA699215D4; Fri,  4 Dec 2026 05:57:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796363825;
	b=P4IN8n9/U85L5X9g8uIUQjmOuccZrM3L2EdcRToyk0SglnYmwLePSFWcPllXvq8KCPVU
	 ajnUq1A7AsG174QmNznzJ+p/IrnQCHGF9CtaSdg2Ab0FARMNvc8g2jbMCAGo9blQW6Mnx
	 y+tKh96J9iSJkftnLsTTiHm/Nq4B/cwzEwjQJ311vkwdmGd2JWqgBx3XZPIWcDR7gTw0B
	 In7MQHY3v+SbPmnOqdSdbqon+IznCWE0XNGg9/c0RMqd3AolK4cS4S/q3PNKdBFzV8eHA
	 /EyPTB+mqgSHkHGsFkiCwBf7awzQsGfBmlXtqhjltu3zZvP4waLTbfKR7g6SeZuYbtQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796363825;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:Received:
	 Received:Received:Received:Received:Received:Received:Received:From:
	 To:Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Transfer-Encoding:X-TM-AS-GCONF:
	 X-Proofpoint-Reinject:X-Authority-Analysis:X-Proofpoint-Spam-Info:
	 X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Details-Enc:
	 X-Proofpoint-GUID:X-Proofpoint-Virus-Version:
	 X-Proofpoint-Spam-Details;
	bh=DdGpkT+KmVgje9EBjDtv2mJPkxFa70QZeWHXw0t8Ovw=;
	b=tk2BlQTAx8OrMwNe7bGhespPL11Wq0PGuloF0mgSBnQDjLOniVKFaQHH0PVgWGhRkphY
	 c9xsBqvIGRQ6cZPCrE3IBCSqumPIs0v42WIL0EXiOzjiMT5XPOXQ1v9AlvHRulxDJddbF
	 3jDaziSkqk2Qw0lCXp1Tb7omV3rxCDZSKJ0Y1cLxofK+kA4X7XE66K4cVCmeemiZSYotb
	 gvmqW4f1ffpx2NUitiM2KwCm87ytjIWIVNcCC02dhqlTmLA/ca0jY6ZRGEd8UO8PVHu29
	 s7M5H0ku1OlZQA+KJCAFAY/nZEpNTJCpnK4U6h1l+Eon2lwZr/AA4d7uP1DT5sZsw7A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=IuG5CVzD;
	dmarc=pass header.from=linux.ibm.com;
	spf=pass smtp.mailfrom=linux.ibm.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 21ADB606A335;
	Fri,  4 Dec 2026 05:57:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=IuG5CVzD
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.158.5
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796363814;
	b=gd01Saxu015+nxKPbi4BKuBZFUBUrnYQtFa6j0TBGF7++z9Q06uliiLweax2cQ6LHrT5
	 nPlVMxQkSvQRfbbNabVBubeXQ0zmsM+XtiK7v5nla90qKZAnb+cYUtA/Q73aJ0sal3XhE
	 tVqfOPBLGmF+18qV63bdEetpSnpLIYrtbz9xTaL3po1bMcB71CgvNZ5Pnfa4put4EgRNX
	 dH3v/G39SnGyN5fxn55lO18vaNCCcEkgb8LlALnA27j/lcksOQ5RQofQqoQScNs+JFjOL
	 U6PBbuTh7/CVD8Yod1zWNpViJD/wnxIIptmRsliBvlqUrwK98vA6wzfWlIR2cJ/4Glg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796363814;
	h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received:
	 Received:Received:Received:Received:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding:
	 X-TM-AS-GCONF:X-Proofpoint-Reinject:X-Authority-Analysis:
	 X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID:
	 X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID:
	 X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details;
	bh=DdGpkT+KmVgje9EBjDtv2mJPkxFa70QZeWHXw0t8Ovw=;
	b=OC+Gix+RSPcLgw7cZZlnYCZYZ5JGU0kCNZx/twufbZhyxzxEhRqPankxKb5GO8kyvOns
	 aCy+1f1NBrvSQOojd2KPtYYuk4GScLhDAJRSBsex2P2S65hn3rq0P4Mn6jvfDugSx7iM4
	 6/i1kKTMyWury7L+ncykNKAXkhGxg5L/78i9o/Wc5xYu4ix9bfTq0/70C76kcti3xP6Fa
	 vK90ykVHX7B/vmENoqA32K/oe2EP5yu9/y207EOCnbqo1jghQk4BhFJe6QF93qKkCrhM1
	 znhfHw1rhRhrz/bkNnTNVLcaFDhxsNx7BOIDcwkB8ODivX6OHg1xkG8NP0St/E7eabQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.ibm.com;
	spf=pass smtp.mailfrom=linux.ibm.com;
	dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=IuG5CVzD;
	arc=none smtp.remote-ip=148.163.158.5
X-Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C158B606A322;
	Fri,  4 Dec 2026 05:56:53 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C158B606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com
X-Received: from pps.filterd (m0353725.ppops.net [127.0.0.1])
	by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B45ZSrO002567;
	Fri, 4 Dec 2026 05:56:46 GMT
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc
	:content-transfer-encoding:date:from:message-id:mime-version
	:subject:to; s=pp1; bh=DdGpkT+KmVgje9EBjDtv2mJPkxFa70QZeWHXw0t8O
	vw=; b=IuG5CVzDtV8anyeQthpPY59DJuyy5KJxWeEt35Kl70JK8CyDYwMMbGGWh
	Yjcs/UXqf5Dl3GR4w0O8oVU244k3syiKtFmPUg1N/4vJVn62VPw2hVj79Rj8K54U
	RuKhGenoPpdTG7QssDH28L3hP79aPhH0nuQKG0ro7mel2S+TRtqTY1PDydzTY/PP
	knxjuU+dhQuTucKzppjoGQ8BLEO2ohI/2NYtdvbpa96vSoqSHiXKy0FzPwNJalMl
	7FuzYlWa6rJmzo0Vo6XURQJwONFE6NyMsKJjMrE7UopbrIPV5G3+8Zq2kp1dA5Bi
	QIhr85gJXr0ItuapPbzRPJf31uO9w==
X-Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92])
	by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4jbqghr1sp-1
	(version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);
	Fri, 04 Dec 2026 05:56:46 +0000 (GMT)
X-Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1])
	by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B40nPjL609966;
	Fri, 4 Dec 2026 05:56:45 GMT
X-Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9])
	by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4jaajshd4q-1
	(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);
	Fri, 04 Dec 2026 05:56:45 +0000 (GMT)
X-Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102])
	by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B45ui4k56426960
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);
	Fri, 4 Dec 2026 05:56:44 GMT
X-Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1])
	by IMSVA (Postfix) with ESMTP id 6564C58063;
	Fri,  4 Dec 2026 05:56:44 +0000 (GMT)
X-Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1])
	by IMSVA (Postfix) with ESMTP id 368CA5805A;
	Fri,  4 Dec 2026 05:56:44 +0000 (GMT)
X-Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9])
	by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTPS;
	Fri,  4 Dec 2026 05:56:44 +0000 (GMT)
X-Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 56341)
	id 01DE81610DF; Fri, 04 Dec 2026 06:56:43 +0100 (CET)
X-Cc: hidayath@linux.ibm.com, pasic@linux.ibm.com, horms@kernel.org,
        tonylu@linux.alibaba.com, guwen@linux.alibaba.com,
        netdev@vger.kernel.org, linux-s390@vger.kernel.org,
        linux-rdma@vger.kernel.org, stable@vger.kernel.org,
        Mahanta Jambigi <mjambigi@linux.ibm.com>
X-Mailer: git-send-email 2.53.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-TM-AS-GCONF: 00
X-Proofpoint-Reinject: loops=2 maxloops=12
X-Authority-Analysis: v=2.4 cv=eYyo7LEH c=1 sm=1 tr=0 ts=6b12561e cx=c_pps
 a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17
 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22
 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=qAXq9g4nlgxYKIDFqXsA:9
X-Proofpoint-Spam-Info: AW1haW4tMjYxMjA0MDAyMiBTYWx0ZWRfX6EkxD3hfSft0
 PwtOKocmn7J679mV9qMSEXqLDHFp3higbz+23VXssgp3Zwi1rlDzkXBlfB5HVLoGR3Vhk3vgQBo
 ALh+LHlA+vst9aCtr5+hnlmLDUOCtA8=
X-Proofpoint-ORIG-GUID: 5O1IS0qyBdbW-uhbpv_lv0kwS1VTooPB
X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjA0MDAyMiBTYWx0ZWRfX/+J9ha6M7qmI
 f2nHwCssHWd0HargQjV6DW4ORwd1bUDDHoTvmAXjUyg469sy3o5NC9bqcAdEXHFZH8iKfG1IsPj
 tiX9s61gaUwimlBOad37wTt0f1tutWxN5fBpyeyOvBC4b/yyKx/TtKFRKWkFQSgApMzYt5kXWGX
 GtF0SOQD+aNbuekUuj9fmABiIvxDu+8yTdm9CTJsWsJ5T/gbDJfQ6fBkb+vXBQfIUo5EarFczCl
 AVJo0L5UVRZQ6GscxB12voOMzsj52idrTghIqppXAa8wYmLXYkOk0L+Wn23Rks3rS7WUZVzyLpG
 9+QRNoXXynq/enfMnOxBVpVY7D1m5Cl7Tm7ILjo4nMGlaQtDRDSL+uEKCDY1oXiMCXvA/iSx/Zq
 Kpgns6AXwXDDm/XZIr0/QURrnKdHcMZgG/MM3FLW4qM/lDK4CyIcMEZp5bmqIf2YEHbD4HETf/P
 I5BzSNBzSeuMKMAXUYA==
X-Proofpoint-GUID: qwicdHdtRbHBQFufv6qe0R_UrTSvNkXc
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49
 definitions=2026-12-04_01,2026-12-03_04,2025-10-01_01
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0
 lowpriorityscore=0 bulkscore=0 spamscore=0 malwarescore=0 suspectscore=0
 adultscore=0 impostorscore=0 priorityscore=1501 phishscore=0 clxscore=1015
 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0
 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612040022