Received: by 10.213.65.68 with SMTP id h4csp2147513imn; Sun, 8 Apr 2018 20:57:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Y9xFGicuQO4cOkPzREW8Xzqn4f44JvOG16g0rycdRqBrSt4ff8DfOElyhwCQOIlFCUY6m X-Received: by 10.101.98.151 with SMTP id f23mr23931397pgv.98.1523246228925; Sun, 08 Apr 2018 20:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523246228; cv=none; d=google.com; s=arc-20160816; b=QLbYSigiASf+xsTQtxlPiBp22UPx5QnIiaP1/ntfd7m2xxXDY6EdEoV1x22RwbxcMT 1ABe5OMS6FEOf76jV6ogtF25X0qUtU0sCI22ySky8CYK1DhNLhL/8njvwW4vnyIZx+Tu 30OGWk9jHxFAOHjUj0xjJB8nbYa7V+BsNbR4dVZwzb4Ve9inbXm7YXK9xLmnaPl/mGdQ jhZ6I5LbxAYe51x9VQjYtGS+7rN1RyBPwtaSaRHAjCyXAioKqh5uuo6/0FMNoy0khxNy 30o1bnA+HOrYE9IizeqgeHAGbv/fx1/vWOKjzwNOjg9Hv0pLrBwQjEyHqPlVOuT4f0f7 P2zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=SWqTPX1rt9376VONxeFPrQPvqBOSZMFbPc5kKouacU8=; b=Nj/wt3xhyMHZg2xw9RIGiKRsgOoU8phR/CymiA8iZ1JbXz1r579Z4WsV+66KVla7V9 z1gijc7S43OlegCkDu5HG9SB0WJS22YYEexVBkjbw8ukNcEqb0t47mmCer4JO4ONaVdt gGFw/jDm89GqRTs+gZVEDI9sr6MoRRn5b7YdNcAhB/+hJxZ2S3H2BL0sc8cRoLAiR09C MmBwuaajNG0Ei0PC1f18tkb9JvXFbK9j3My+ecyAf+yKujC1348AT5rMkBeMXU5yPNi3 AzNOonrTPZW8upMVZOUMPWmHYCVKGw0KGHfO2+5hziWr21maJao5Ud4gWEeckfsQElhE qoIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=boCFXyG7; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p125si10539911pga.396.2018.04.08.20.56.31; Sun, 08 Apr 2018 20:57:08 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=boCFXyG7; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752944AbeDIDvY (ORCPT + 99 others); Sun, 8 Apr 2018 23:51:24 -0400 Received: from mail-bn3nam01on0100.outbound.protection.outlook.com ([104.47.33.100]:20288 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753957AbeDIAT1 (ORCPT ); Sun, 8 Apr 2018 20:19:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=SWqTPX1rt9376VONxeFPrQPvqBOSZMFbPc5kKouacU8=; b=boCFXyG7ENBdiMsHfivUP3ajy/O4cSqREYybdFfCcaOJTpSMN3+rsjrgW8r+IxntSKfeSpt/syG1AaGLmCKhb4sh+ju6HHhedjP+YXa9EEWPwrM/Xr+9g0Q0SOLqhFnU3E3TSCfH/bK0+gY082g9U72v6nRFK6A53ZlxNn3b7uI= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1063.namprd21.prod.outlook.com (52.132.128.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:19:22 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:19:22 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Doug Meyer , Jon Mason , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 104/189] NTB: ntb_hw_switchtec: Fix peer BAR bug in switchtec_ntb_init_shared_mw Thread-Topic: [PATCH AUTOSEL for 4.15 104/189] NTB: ntb_hw_switchtec: Fix peer BAR bug in switchtec_ntb_init_shared_mw Thread-Index: AQHTz5g8U/5tsiCOwEWMmq7/drdrJQ== Date: Mon, 9 Apr 2018 00:18:08 +0000 Message-ID: <20180409001637.162453-104-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1063;7:eH40CuusS7QX2yXsQrAiGLCtHIRdMGJcGgtF+3rJbGdk45+nGaKYpg+ZrJSppQHiB2JgRF/4/9U9tKGeiw6NpX36n53mKdgqhPNKoeXagJOI+8jM8CME7Pa5+13yqj22oiNE1b8HhocYGLwGJZmoBdDVJ/uofS+HB5YFqEgcPEQFUyQND9CQ3eEh4jrP1I7aQFGFcWAUX75Frvio2Z/hQZwP+Usmng2NCC7dbUyhaVPvV0SYTAeVGYHy8EgBkvmQ;20:EmVLMJcpBvQ020d3+jAzlpA4ky0H2mYQEQehMuWp1dZu+UNM3LshxxHdngOx3CtM3YDcdrXVZTxV9lxCVhXzLE+J+HMZ8Z4lhR9YZVmHSoDR8cTd1qsnv8GH15GOsT4NXAcrMuRS0N79F2wc40Exwyau7jlj4mhFgWu0Iu/XbMA= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: b040eeff-78f9-456b-acf6-08d59daf8b13 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1063; x-ms-traffictypediagnostic: DM5PR2101MB1063: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB1063;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1063; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39380400002)(39860400002)(376002)(396003)(366004)(189003)(199004)(2900100001)(6436002)(7736002)(10090500001)(102836004)(3660700001)(6506007)(76176011)(305945005)(4326008)(5250100002)(97736004)(26005)(25786009)(6512007)(2906002)(81166006)(106356001)(107886003)(68736007)(14454004)(86612001)(66066001)(10290500003)(59450400001)(6666003)(5660300001)(81156014)(478600001)(476003)(486006)(6486002)(72206003)(3280700002)(99286004)(105586002)(36756003)(1076002)(2616005)(11346002)(53936002)(446003)(8676002)(186003)(3846002)(54906003)(6116002)(2501003)(8936002)(316002)(110136005)(86362001)(22452003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1063;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: d8eiddq1DKwMeMZHzr+3KdYEegAc7LObhETLeE5yT41g/ugn7hOGf1/lTdAbBE0XwhZsldl6A8yjuEJiV8yU1hLYLGlOFgBznV2MQ5EODmDFcbPubFlJisStFDbj+Ij5bctfIktjFfnast6deIgvwpDZr/DYEezDfJITIHmRm6SDV5FbVY73EzBeqXUf318KYzlayNJhJDt810iSsQw1c+uYMWEplr7ql16FMPZwLlNzcoaZgkqJIPAdHe1928EqyskvFIGKm99gWnOhjrIuRARb42L3nBkkNMya1o9yGoEWLLjlRssFRBc4AIJ3x/Z1wy7LCQtbm2hFi6M3+3MuB39/3o8kn3FJ65lNkPAUFyk9WJXcP028qD+61oHhR32KQXPQ8Q/bgIgo3uSILcUSipgoQ1AHjF08y2HD3YbNb2A= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: b040eeff-78f9-456b-acf6-08d59daf8b13 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:18:08.1626 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1063 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Doug Meyer [ Upstream commit 140eb5227767c6754742020a16d2691222b9c19b ] 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 Fixes: 678784a44ae8 ("NTB: switchtec_ntb: Initialize hardware for memory wi= ndows") Signed-off-by: Jon Mason Signed-off-by: Sasha Levin --- 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/n= tb_hw_switchtec.c index afe8ed6f3b23..ca0334a6b759 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 =3D sndev->mmio_peer_ctrl; - int bar =3D sndev->direct_mw_to_bar[0]; + int self_bar =3D sndev->direct_mw_to_bar[0]; + int peer_bar =3D sndev->peer_direct_mw_to_bar[0]; u32 ctl_val; int rc; =20 @@ -985,12 +986,12 @@ static int switchtec_ntb_init_shared_mw(struct switch= tec_ntb *sndev) if (rc) goto unalloc_and_exit; =20 - ctl_val =3D ioread32(&ctl->bar_entry[bar].ctl); + ctl_val =3D ioread32(&ctl->bar_entry[peer_bar].ctl); ctl_val &=3D 0xFF; ctl_val |=3D NTB_CTRL_BAR_LUT_WIN_EN; ctl_val |=3D ilog2(LUT_SIZE) << 8; ctl_val |=3D (sndev->nr_lut_mw - 1) << 14; - iowrite32(ctl_val, &ctl->bar_entry[bar].ctl); + iowrite32(ctl_val, &ctl->bar_entry[peer_bar].ctl); =20 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 switch= tec_ntb *sndev) goto unalloc_and_exit; } =20 - sndev->peer_shared =3D pci_iomap(sndev->stdev->pdev, bar, LUT_SIZE); + sndev->peer_shared =3D pci_iomap(sndev->stdev->pdev, self_bar, LUT_SIZE); if (!sndev->peer_shared) { rc =3D -ENOMEM; goto unalloc_and_exit; --=20 2.15.1