From patchwork Tue Oct 17 20:22:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dmeyer@gigaio.com X-Patchwork-Id: 10012811 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C3C46600CC for ; Tue, 17 Oct 2017 20:23:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4E2028A11 for ; Tue, 17 Oct 2017 20:23:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8FCB28A17; Tue, 17 Oct 2017 20:23:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D00BD28A11 for ; Tue, 17 Oct 2017 20:23:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760221AbdJQUXM (ORCPT ); Tue, 17 Oct 2017 16:23:12 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:56788 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759972AbdJQUXL (ORCPT ); Tue, 17 Oct 2017 16:23:11 -0400 Received: by mail-pg0-f65.google.com with SMTP id m18so2312491pgd.13 for ; Tue, 17 Oct 2017 13:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gigaio-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=A8tI1u2tL0DQhRw039PWOkyeltpgX9jnSfc9J36C0dY=; b=r9gu1pwi2BLLbTnQIG3AT9Tgl4zV3GEc1k9mXsC1XbejA/37OvBeFbcvn4r6G5TKdO I/Cb91kELw4Xq71G0gvbILy++n2V2JTDX/hhZY7g7aGOf7QLcNhF7b1Y72qw5IoTP40j LivNS58qJqGScGZlgCM9sII3AQaX794u0faMDvuM+afUJl0/+qb0ssQwobJlav3ldGa+ /kQg0KwTeZ/4hVw84N8G7f72tQj5iHY4MleJw/EvS0MFNzAExxovEnjna2EQZco+oEy9 HCTjtwlc/DOJUumas+VZbTIyt5cVYYH7nMv8Z4xI+sWzpaby/zoAwcoGTdBYFXHhiMQ2 3VyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=A8tI1u2tL0DQhRw039PWOkyeltpgX9jnSfc9J36C0dY=; b=ObjS9Ehnrb+yotYQW6YvZ4S5W3FJRvQKn0bVfQWUCvlnZ9oxk5Ybn4NP9pm8ksZAqd OBGl7ahM64nHqPrYvTEKxhN0GDYwzzTWcehxMjJ1XhUYGVSq9PBPs3cl3bV7EBWzPRbx fbZJA4lOytH1l4W3MlJND1ZB6gg3O/7ults0MDrevVp7pu8cObWGZV4so6TOAUPBp8w3 Qv+alov+MndKERfoFWiTNJU54L4SfLfTsZ3aLiUBP24oz3AXNhXvKFrXzbBS1ckhtPId ohK1N6inE0U2GvC28o8R/sS/lwlo6mmrZWlZawqrPfQ45Pxf/AThLihen5yboexNmPTH UFBA== X-Gm-Message-State: AMCzsaWdO1Z4mVcrIKND1/Fzi1iwGFxbVqwHrQSC6JFi1jikmcxRnqpi 3uV9540yBm1481aVSzWuSXizhQ== X-Google-Smtp-Source: AOwi7QCMUMKMirvRknnpZ1IkZ0ev89pvnWGqkOaG530EUs0x7UuPPIta9rBDcYScBNSNMrgxCYmOxw== X-Received: by 10.98.70.78 with SMTP id t75mr12723496pfa.6.1508271791056; Tue, 17 Oct 2017 13:23:11 -0700 (PDT) Received: from msi1.evonexus.local ([69.43.204.50]) by smtp.gmail.com with ESMTPSA id h1sm8585429pfg.143.2017.10.17.13.23.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 13:23:10 -0700 (PDT) From: dmeyer@gigaio.com To: kurt.schwemmer@microsemi.com, stephen.bates@microsemi.com, logang@deltatee.com Cc: jdmason@kudzu.us, dave.jiang@intel.com, Allen.Hubbe@emc.com, linux-pci@vger.kernel.org, linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org, Doug Meyer Subject: [PATCH] NTB: ntb_hw_switchtec: Fix peer BAR bug in switchtec_ntb_init_shared_mw Date: Tue, 17 Oct 2017 13:22:53 -0700 Message-Id: <1508271773-17827-1-git-send-email-dmeyer@gigaio.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Doug Meyer This resolves a bug which may incorrectly configure the peer host's LUT for shared memory window access. The code was using the local host's first BAR number, rather than the peer hosts's first BAR number, to determine what peer NT control register to program. The bug will cause the Switchtec NTB link to work only if both peers have the same first NTB BAR configured. In all other configurations, the link will not come up, failing silently. When both hosts have the same first BAR, the configuration works only because the first BAR numbers happent to be the same. When the hosts do not have the same first BAR, then the LUT translation will not be configured in the correct peer LUT and will not give the peer the shared memory window access required for the link to operate. Signed-off-by: Doug Meyer Reviewed-by: Logan Gunthorpe --- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c index afe8ed6..ca0334a 100644 --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c @@ -964,7 +964,8 @@ static void switchtec_ntb_init_shared(struct switchtec_ntb *sndev) static int switchtec_ntb_init_shared_mw(struct switchtec_ntb *sndev) { struct ntb_ctrl_regs __iomem *ctl = sndev->mmio_peer_ctrl; - int bar = sndev->direct_mw_to_bar[0]; + int self_bar = sndev->direct_mw_to_bar[0]; + int peer_bar = sndev->peer_direct_mw_to_bar[0]; u32 ctl_val; int rc; @@ -985,12 +986,12 @@ static int switchtec_ntb_init_shared_mw(struct switchtec_ntb *sndev) if (rc) goto unalloc_and_exit; - ctl_val = ioread32(&ctl->bar_entry[bar].ctl); + ctl_val = ioread32(&ctl->bar_entry[peer_bar].ctl); ctl_val &= 0xFF; ctl_val |= NTB_CTRL_BAR_LUT_WIN_EN; ctl_val |= ilog2(LUT_SIZE) << 8; ctl_val |= (sndev->nr_lut_mw - 1) << 14; - iowrite32(ctl_val, &ctl->bar_entry[bar].ctl); + iowrite32(ctl_val, &ctl->bar_entry[peer_bar].ctl); iowrite64((NTB_CTRL_LUT_EN | (sndev->self_partition << 1) | sndev->self_shared_dma), @@ -1009,7 +1010,7 @@ static int switchtec_ntb_init_shared_mw(struct switchtec_ntb *sndev) goto unalloc_and_exit; } - sndev->peer_shared = pci_iomap(sndev->stdev->pdev, bar, LUT_SIZE); + sndev->peer_shared = pci_iomap(sndev->stdev->pdev, self_bar, LUT_SIZE); if (!sndev->peer_shared) { rc = -ENOMEM; goto unalloc_and_exit;