Received: by 10.213.65.68 with SMTP id h4csp2122038imn; Sun, 8 Apr 2018 20:14:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Dg6ybm2YjrhPiwIaO78Be2FfKr8fC1NgA4gEG7fj9/wzGvjPEv2Hus214An4CjZbE4xDx X-Received: by 10.98.87.193 with SMTP id i62mr21934941pfj.219.1523243686169; Sun, 08 Apr 2018 20:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243686; cv=none; d=google.com; s=arc-20160816; b=tx/zi5wsrEZ/Qtr5hc/GxuQUZdb6Rj1aaFz+HNiZqqp3WgSCXi6ufy74I5lhefoTxG ksFOLqxJiM+5G0gtDlAcvyFDVOxzyw9MpbBGL1E0nF3Rh7pUen2MoEv+yAzFEdTUn2PS swm6tkTxFPwsjPzXrJtlYcPm783T+PeeX+wnuu1z+Gy1C5cUF+ez3geKV61CEf0yz1OA rfQ9nMeEbisG6EuwxCLjdbfV8MQnKRCgfoe8AG1ckI1JtA6F4tPZHfnJP/q5TqzDq3wl xfMqS5SUw7YnHHs9+xuXXCl1Qt8SEkKINYJvhk4qaBpSj88XzuLi/b8ZDEp31+kBoko6 CSnA== 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=5b91y7owPBxcL6wZuvPs3MlQGRvFwMxyC7tHm+/K4h0=; b=lyIgNKI0qECKexgr66hLIrnBPjeIJ1iXtt5aVHMTEf4g+JQpnnkp5SYjq+a+yLj6nD kra31xWBrcHINPsnMZ/4QbSVAgsM9sMjxQG5OZYrzsQQZQa0L5dkituTqBOK0C4AAm98 PuP1mRPV0SqEPVzm/yG8kH5xgM7RPT1m6BRiuzGrJCqb7YNRWFYNQTylS8eTSb89Kzvy fEgbEMdXnQ8rX4dOIiuGkdrDV6rrkmh9IN6hF0RTIWPdyt4/4m/0iOxt3MT3f7Iet7eV RtVwKxwKphKFyO4jE4h3UjjTBIQh385gT09GSsvwYgGb8bfJrY9iVOPm1X7aP5ezunH9 le2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=bcZsF6FV; 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 g18-v6si13920821plo.647.2018.04.08.20.14.09; Sun, 08 Apr 2018 20:14:46 -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=bcZsF6FV; 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 S1754520AbeDIDJZ (ORCPT + 99 others); Sun, 8 Apr 2018 23:09:25 -0400 Received: from mail-by2nam03on0117.outbound.protection.outlook.com ([104.47.42.117]:63840 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755068AbeDIAYd (ORCPT ); Sun, 8 Apr 2018 20:24:33 -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=5b91y7owPBxcL6wZuvPs3MlQGRvFwMxyC7tHm+/K4h0=; b=bcZsF6FVKeGH1SfxvXZg/K+eB9tvE+hg0hw2Gtr6VnmfOqlG8HI+2wx/0BgV/HDHGD0i6nYBQL+SkWtnSAsAoH64o2ovvmiN+YOz5Fa3OSGvBTVUuiyzqRlCH3u1Iv9f/I3antQTypW3xsi0lfulhNDqP7nTilKRrc6Nbw9/T6E= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0984.namprd21.prod.outlook.com (52.132.133.30) 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:24:30 +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:24:30 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Logan Gunthorpe , Dave Jiang , Jon Mason , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 088/161] ntb_transport: Fix bug with max_mw_size parameter Thread-Topic: [PATCH AUTOSEL for 4.14 088/161] ntb_transport: Fix bug with max_mw_size parameter Thread-Index: AQHTz5ihYFB4NEzZrUOsBE9sl0gmEg== Date: Mon, 9 Apr 2018 00:20:58 +0000 Message-ID: <20180409001936.162706-88-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB0984;7:OZq1A2WE0rMx3Xn1L/NVsty3o6DfRMFmuyXrarzH+agNoIc5xVRZQLpAluXp/S0ApcZ9KUAkvgUusV5kGASv2Bxbcw9kv+Lrq8Fyi2EHFF15J20Jfs1eVdusH85W7mNma9gigb27dKZYsgrO1FNnqM0PC4Cwh5hICoHK30kTB8nuEym3WVM3YYA/QhcoBqFfsaMAxQ4/pNrDmH2wvVH0dhO8SKrV/DBNjbtQDlGl7G7ik78I7h2wQVwQ5j6JnCyw;20:9GBPmcFdF1a7uDPKOIM7TYkhYaGptDZsfE4w5hJwoNlrwx2Svy/XKRV8w+Qkfstq2ik3INfm4FkEPCc7Hz9lMxkkacWB4XBP2i45zaYDxi8j4mtkqLYZJuOkwnmG0OpO/lvc7Ftm9Dnodbh9hiDKLZ85pgz7in2PqwMS7xTk+v0= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 72cabd42-d414-4211-3795-08d59db042c3 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0984; x-ms-traffictypediagnostic: DM5PR2101MB0984: 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)(56004941905204)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0984;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0984; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(376002)(366004)(39860400002)(396003)(189003)(199004)(5250100002)(2501003)(110136005)(54906003)(6116002)(6436002)(11346002)(1076002)(486006)(25786009)(105586002)(2900100001)(102836004)(86612001)(3846002)(68736007)(107886003)(316002)(10290500003)(5660300001)(86362001)(2616005)(305945005)(4326008)(446003)(6486002)(22452003)(7736002)(476003)(8676002)(81156014)(81166006)(8936002)(6512007)(10090500001)(186003)(3280700002)(106356001)(76176011)(2906002)(99286004)(26005)(97736004)(59450400001)(14454004)(6666003)(478600001)(53936002)(6506007)(36756003)(72206003)(66066001)(3660700001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0984;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: Y4AO6mwF7RT15hQmhjFE5NnbRtGP1PSxWTk1Lc3qq7OnOeHqWRiG1AVWm+YJ28jUwyUXYly18/gbnbMNTPl4yKk2pENRnLu6mh+Sr2NGexwPm/AXgKQa77kw1uaPkLRqpZgkoI25Tqutct31J3QyuNMQ5pzb5aa24KtBtcQcwpljvoq7Gk3S69p83nbIO2iKSzsLv9rY/PCR/WDkbP7uvTffz5re9Dd6KR37Wk3+GDCK9xIxJ3792XlR6Jwec2MmGgUgks18UV52MZ/sqoy7iRA+lWenYDQGLYAJ5845fGGhVE9xpG4qzP0m/DIzr1lOeddGDJRZ2Icc6z0nENS4cz9ACrKMOFhy8npf8E0UrZ9pwM2JQJqTLhp/9rTP4cnoMVWAMuWc7+0prHjaU2mF8ocCqVfnT+nOwa0Se2PmR6A= 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: 72cabd42-d414-4211-3795-08d59db042c3 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:20:58.4408 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0984 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Logan Gunthorpe [ Upstream commit cbd27448faff4843ac4b66cc71445a10623ff48d ] When using the max_mw_size parameter of ntb_transport to limit the size of the Memory windows, communication cannot be established and the queues freeze. This is because the mw_size that's reported to the peer is correctly limited but the size used locally is not. So the MW is initialized with a buffer smaller than the window but the TX side is using the full window. This means the TX side will be writing to a region of the window that points nowhere. This is easily fixed by applying the same limit to tx_size in ntb_transport_init_queue(). Fixes: e26a5843f7f5 ("NTB: Split ntb_hw_intel and ntb_transport drivers") Signed-off-by: Logan Gunthorpe Acked-by: Allen Hubbe Cc: Dave Jiang Signed-off-by: Jon Mason Signed-off-by: Sasha Levin --- drivers/ntb/ntb_transport.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index f58d8e305323..18339b7e88a4 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -998,6 +998,9 @@ static int ntb_transport_init_queue(struct ntb_transpor= t_ctx *nt, mw_base =3D nt->mw_vec[mw_num].phys_addr; mw_size =3D nt->mw_vec[mw_num].phys_size; =20 + if (max_mw_size && mw_size > max_mw_size) + mw_size =3D max_mw_size; + tx_size =3D (unsigned int)mw_size / num_qps_mw; qp_offset =3D tx_size * (qp_num / mw_count); =20 --=20 2.15.1