[PATCH 08/11] NTB: perf: Reject grouped memory windows

Koichiro Den <[email protected]>
Newsgroups gmane.linux.kernel.pci,gmane.linux.documentation,gmane.linux.kernel
Message-ID <[email protected]>
NTB perf configures one MW per peer through the per-MW translation API.
It cannot configure one member of a larger translation group.

Reject such layouts at probe. Otherwise, link setup cannot complete and
a performance test waits indefinitely.

Signed-off-by: Koichiro Den <[email protected]>
---
 drivers/ntb/test/ntb_perf.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index dfd175f79e8f..50bfbec1e251 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -1436,7 +1436,7 @@ static int perf_setup_peer_mw(struct perf_peer *peer)
 static int perf_init_peers(struct perf_ctx *perf)
 {
 	struct perf_peer *peer;
-	int pidx, lport, ret;
+	int first, count, pidx, lport, ret;
 
 	lport = ntb_port_number(perf->ntb);
 	perf->gidx = -1;
@@ -1469,7 +1469,19 @@ static int perf_init_peers(struct perf_ctx *perf)
 	}
 
 	for (pidx = 0; pidx < perf->pcnt; pidx++) {
-		ret = perf_setup_peer_mw(&perf->peers[pidx]);
+		peer = &perf->peers[pidx];
+		ret = ntb_mw_get_trans_group(perf->ntb, peer->pidx,
+					     peer->gidx, &first, &count);
+		if (ret)
+			return ret;
+		if (first != peer->gidx || count != 1) {
+			dev_err(&perf->ntb->dev,
+				"Peer %d MW %d is not a standalone window\n",
+				peer->pidx, peer->gidx);
+			return -EOPNOTSUPP;
+		}
+
+		ret = perf_setup_peer_mw(peer);
 		if (ret)
 			return ret;
 	}
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.