Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1458851imm; Fri, 8 Jun 2018 17:09:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIhjcaqjcG6zw/8iJPwIgUYF2/SKJn+K7uxRjfUdHowM5fAKQeoeK2Nudi89qtEhMEPJfgM X-Received: by 2002:a63:ad46:: with SMTP id y6-v6mr6928139pgo.10.1528502973844; Fri, 08 Jun 2018 17:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528502973; cv=none; d=google.com; s=arc-20160816; b=zDnCZtY0MHoSbQRnurLLZtqHi4/oTBTvl5+0PmMryydX3ZF1EURDnlvbKq16DDzZCT aMy7AVcExcfSLu5dJQw4c7pWXKkUTCB8hRJGLNB7qWWpUPZMQTDJ73aRrjZpK6oOCqIb bMWX9suq8SJg7IFYxpEU7gKSPkqjNhPlCeJpcMXvcXzivYsU2SyPpCcg+sXKJ/2bPgmr dJmIzAedb5DP2LtdNkr/pqLP5Oiat7V5QoCbErqmVoMB44QcHUvvKjvAhAyg0sqO8dag Xs0KXfmFhM+XknFc0ygZ+Cgv0StSXlWZ25MgHmjDeXTfkJ/j/R++3k2K1ZT94ZDIPGEH i8jQ== 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=rouxAZie26apMbo4bfAs1a9LGQygUTDpCA+cr9qJ950wcfn7FPkG2xz2ea1DueRdFh kraXDaNdid7ONwd9ldCy6I6wmKbiIbHuhskoYGCuyRl/+cm3fZd9WhFMUmg/PXEaY6LH pWr1rSOogFIe6j6+rbMtrEn/JIe5su8GjDCT8LPmSruzoffQuQiEl2JiijtoDoeNRxfy /OBKTHLnfsAP1RkE9ulGWDjteJHaoF4kVxIP9emOPNNWUpAK6jGLuY1XJvtn9+wJpzIY zt0lHkzUC3USNh3kjwIqypqDmbgrv/VngUz7R3B6tglelFrnF33C4asLwTlZBPA7W69B LMwQ== 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 j78-v6si32337125pfe.187.2018.06.08.17.09.19; Fri, 08 Jun 2018 17:09:33 -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 S932092AbeFIAIb (ORCPT + 99 others); Fri, 8 Jun 2018 20:08:31 -0400 Received: from ale.deltatee.com ([207.54.116.67]:60546 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752946AbeFIAI1 (ORCPT ); Fri, 8 Jun 2018 20:08:27 -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 1fRRQd-00043q-2R; Fri, 08 Jun 2018 18:08:25 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1fRRQb-0003cw-T2; Fri, 08 Jun 2018 18:08:21 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com Cc: Jon Mason , Dave Jiang , Allen Hubbe , Serge Semin , Shyam Sundar S K , Shuah Khan , Logan Gunthorpe Date: Fri, 8 Jun 2018 18:08:14 -0600 Message-Id: <20180609000819.13883-5-logang@deltatee.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180609000819.13883-1-logang@deltatee.com> References: <20180609000819.13883-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, dave.jiang@intel.com, allenbh@gmail.com, fancer.lancer@gmail.com, Shyam-sundar.S-k@amd.com, shuah@kernel.org, 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 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