Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3151678imm; Fri, 20 Jul 2018 11:01:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpftpsGlxx8TPvG/VYs/Eu2lJ9/XHhidHKQHyumgbHUa+Y+NfpNlUmhD7ByJNvWYxq5yWV8c X-Received: by 2002:a62:e813:: with SMTP id c19-v6mr3171477pfi.124.1532109713424; Fri, 20 Jul 2018 11:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532109713; cv=none; d=google.com; s=arc-20160816; b=CiXHbqQtG8p056AD0VabD8lWN2YCHib4tdBWrCerz6FQK7CU7Yq7Dw0waQvIkRHX+D Cy1vPq54951MsM2vM1WXe0MZPwmfwU3/rO5P7fpEahPtYtP9jM3QJ+BtsqyzcX76kNnr Y+l+wQSR6bk3CS54MYgeJ5W8VW8BZgGgKgGRTyZ6ri0Tq3Ks2VpH7XbQEe77EIkGfMq8 YgKyh2OdvMZvOMpBVgBI9EmgGOU24wVlVYDxt/xfIalDBFMvPSsW5XaSd/038GSKaYq7 hI9DtV0CVcPptoIorgeOwm1IrKqi9qIvpeg9xx8caUEzLFonk5DDlP+LYF8hredYqMWp ckpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=Eq9lVifFEcA8vLp0iaTkKIOUHnM3IpArFH0K7UkAqkM=; b=Z9QqOBdefATZ95WKkuzeEhmFbPjMiqG4pNTMvrnS2suq/t2JiDo9c5MAoEwU8VIW92 prdKPAMwhkOEqMlrtv3lUp5gXhC4m8xIcO5fwTRiR/QofOEvCzAzYwH2SMqHjhdAe14D gKqojekXlDkJVUyMbNBAc5irYWTFSfe2WK2pOW29qdRi2lU6hN8/DJzH3KXGDttV8oYQ K/WNxCcE2zmlGmoH+9yqu3B14UjgwzKpZBdwQbKqTyfyuzq16qiabKmVlgpkBNY1QAZi 6JZRbs/2qd2R9nz9jElPAUJhzY6wibSaT7ymZ2hnn7oPLTPT6wLf4IoYsWB+pfqGWcQd 0YkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u19-v6si2304666pgk.100.2018.07.20.11.01.38; Fri, 20 Jul 2018 11:01:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388463AbeGTSuS (ORCPT + 99 others); Fri, 20 Jul 2018 14:50:18 -0400 Received: from ale.deltatee.com ([207.54.116.67]:38414 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387950AbeGTSuH (ORCPT ); Fri, 20 Jul 2018 14:50:07 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fgZhn-0008E4-0V; Fri, 20 Jul 2018 12:00:44 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1fgZhl-00012w-3p; Fri, 20 Jul 2018 12:00:37 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com, Jon Mason Cc: Allen Hubbe , Serge Semin , Shyam Sundar S K , Shuah Khan , Doug Meyer , Logan Gunthorpe Date: Fri, 20 Jul 2018 12:00:30 -0600 Message-Id: <20180720180034.3964-5-logang@deltatee.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180720180034.3964-1-logang@deltatee.com> References: <20180720180034.3964-1-logang@deltatee.com> X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com, jdmason@kudzu.us, allenbh@gmail.com, fancer.lancer@gmail.com, Shyam-sundar.S-k@amd.com, shuah@kernel.org, dmeyer@gigaio.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT autolearn=ham autolearn_force=no version=3.4.1 Subject: [PATCH v2 4/8] NTB: ntb_pingpong: Choose doorbells based on port number X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit fixes pingpong support for existing drivers that do not implement ntb_default_port_number() and ntb_default_peer_port_number(). This is required for hardware (like the crosslink topology of switchtec) which cannot assign reasonable port numbers to each port due to its perfect symmetry. Instead of picking the doorbell to use based on the the index of the peer, we use the peer's port number. This is a bit clearer and easier to understand. Fixes: c7aeb0afdcc2 ("NTB: ntb_pp: Add full multi-port NTB API support") Signed-off-by: Logan Gunthorpe --- drivers/ntb/test/ntb_pingpong.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/ntb/test/ntb_pingpong.c b/drivers/ntb/test/ntb_pingpong.c index 65865e460ab8..18d00eec7b02 100644 --- a/drivers/ntb/test/ntb_pingpong.c +++ b/drivers/ntb/test/ntb_pingpong.c @@ -121,15 +121,14 @@ static int pp_find_next_peer(struct pp_ctx *pp) link = ntb_link_is_up(pp->ntb, NULL, NULL); /* Find next available peer */ - if (link & pp->nmask) { + if (link & pp->nmask) pidx = __ffs64(link & pp->nmask); - out_db = BIT_ULL(pidx + 1); - } else if (link & pp->pmask) { + else if (link & pp->pmask) pidx = __ffs64(link & pp->pmask); - out_db = BIT_ULL(pidx); - } else { + else return -ENODEV; - } + + out_db = BIT_ULL(ntb_peer_port_number(pp->ntb, pidx)); spin_lock(&pp->lock); pp->out_pidx = pidx; @@ -303,7 +302,7 @@ static void pp_init_flds(struct pp_ctx *pp) break; } - pp->in_db = BIT_ULL(pidx); + pp->in_db = BIT_ULL(lport); pp->pmask = GENMASK_ULL(pidx, 0) >> 1; pp->nmask = GENMASK_ULL(pcnt - 1, pidx); @@ -435,4 +434,3 @@ static void __exit pp_exit(void) debugfs_remove_recursive(pp_dbgfs_topdir); } module_exit(pp_exit); - -- 2.11.0