Received: by 10.213.65.68 with SMTP id h4csp2111825imn; Sun, 8 Apr 2018 20:01:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx48WgIAZqMe2hAceZvNa4n1C/1T7hC1bsjIyAJpxsMdVLaqLnPac7mgV/nZCPphmfZ3dLOxv X-Received: by 10.101.102.69 with SMTP id z5mr23761634pgv.438.1523242876864; Sun, 08 Apr 2018 20:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523242876; cv=none; d=google.com; s=arc-20160816; b=VulngZ1Mvb4YmafkcFIDB6Jjanwmo7oF5h6JpTWE3xf1cckuGriCYZs8BnenX2j0Mf hJYPUoOCpBr2NEf0tq1PnFRnPCkFa0ErTbrM0xTlqE4vKaMoWpk82Bco4/sgVImI9LyH qYFF5grFAx6XigXvVGomESjrxSlDtxo9WpxEfWsONPp7Cii5K80yVsNMFpIxyfrEXvuN /T3CWRZgSAYxbhnnZZ1Ppfz0d89/4nJi4blZhoXUQh+1sr5llyzJz9m+ph3jDYiNFiNN /whzxUpWxCa7qR/s1LTg+bEMKa/aLprXi+OZyPQoI5FCgPsFpngFqb6BKywI92bTo+Yh 0puw== 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=KKU/jjtRloSpph+AsuUeQJauVAPR6pTH3xvJ+b3/s2I=; b=NnOJX5RaKOkcPE+InjUvgq8ZM8zjHZFuwsf/oIlAcTlpApkPfS3bf49LBrYKj7HC2Z FKd65UHFTzLzkcfYCKqHU/WbqgAoNwESKykkMj1kxk57nXxKn+18jr3Z6ZR8FLcHOcns Q+uRDGKpi9FG4X6lez+mnf85RZUiAtXOdtOSdro7KxvrNzqTh6xgv7+brQn1sTGup5Dt 1PS3izxJls3pg8MjHs09qGjCNV2WKqk+zrPX11XMjvGMEte+dA6u8V2U+71z/DvwLTRQ FeZ1b9P+qxWDtr97XrJrWz3l0/bZ8kW/TfDkN0+h/c5Jk6mCtvGShcwuby1sjv88WxiQ oVQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Lrz/V6bS; 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 ay8-v6si12896926plb.554.2018.04.08.20.00.40; Sun, 08 Apr 2018 20:01:16 -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=Lrz/V6bS; 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 S1754078AbeDIATc (ORCPT + 99 others); Sun, 8 Apr 2018 20:19:32 -0400 Received: from mail-by2nam03on0122.outbound.protection.outlook.com ([104.47.42.122]:11088 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753783AbeDIAT2 (ORCPT ); Sun, 8 Apr 2018 20:19:28 -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=KKU/jjtRloSpph+AsuUeQJauVAPR6pTH3xvJ+b3/s2I=; b=Lrz/V6bS/wjBC5WpQNqs6tu+d8VPIUE11ix7Nf7O86VCK35E0WUdkTgYAXckOlkALNb990qpWw/bTR+5GGTuDVZVhcscJvhRJG6pMOUE371wR80lOm6Mnzq9Kp6SQq7GHui24zbavtt50UGgd+a8SpQeBdpZhqw1mfy4zqEDSrk= 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: Logan Gunthorpe , Dave Jiang , Jon Mason , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 105/189] ntb_transport: Fix bug with max_mw_size parameter Thread-Topic: [PATCH AUTOSEL for 4.15 105/189] ntb_transport: Fix bug with max_mw_size parameter Thread-Index: AQHTz5g8cGeKKzTzckukxK206PAZTg== Date: Mon, 9 Apr 2018 00:18:08 +0000 Message-ID: <20180409001637.162453-105-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:5iyv+SaS4k08RiJoXcQZmm+USivVCyrHv9ZRI4EEfa+KdGMj3roMYLazjEbz5GIoglGqQl+x3+INRCLeMSaCuKLDVMecVUJTYKwW6dKQ1oZ7FkMsAY4hHiLNQgDrSQExat8mi1G7t+faacPOEdo1yljtbXqET4AlFfgCriyVRaboOjfDPhd4LImdHupHnje+o7dgyaFLGmZcFx36gIffMuGel6oOqKgyRJadJOVLGrlEJ7HIAT4iEa2MkXLlV+iD;20:bZemVuLnAmFSPFCbjlRi7MWqpLQJG7JIG2x/M3JkBAvMJM89VEFYgbtLnIjhCysPnTetPd0aPNNMHbC5bPN4o98zVE8CEtXBjEjqewwLvSbJZjOd2q5jmoQvFWMRknni3GE+0qA5cJfsIa2+Z0hNk+fYg3+wgsPIy8apL0n0Wn4= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 5d64402e-161d-4225-cecb-08d59daf8b77 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)(56004941905204)(228905959029699); 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: oxZLeuSF45zqlGBcQPx4dpg1JvE1kLj6p1sbahuzulz1iO2BqF82gkJDvhNYyqVLBwIvcsRjpkJG3e+V0uKPYcK5MJLhFmubYpinro+brmotB0vG6FA1LfA8p0sDJMJjPrnkcnQ3kfK8xRPfdSvR0iNcS1v8OXdfecQ8xajlIpWaQSxhXVp+AkuaATok3g2/r9IhTgEVSikNVP4wOMHbGpYnDchDYBdyAXdoKTuNnyFeNGWfyF68bLRQ4iGoCjtOrm9Mwpq2nauYA0EqpLYDKRejFiaCwxWxMsaXLKzIsN8raQZ7zJxOVx3gsVCB99JbTvBb3k0E907Ds5LFl6UKQi4pyDAqIbre4ucj5j7xQvtNjV2ITkODrZk6ZuhH7qDBtnW3SKg2VuInaEz88TatREIJIcrY6ckP7Oj/KxWj9EI= 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: 5d64402e-161d-4225-cecb-08d59daf8b77 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:18:08.9750 (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: 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 045e3dd4750e..9878c48826e3 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -1003,6 +1003,9 @@ static int ntb_transport_init_queue(struct ntb_transp= ort_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