Received: by 10.213.65.68 with SMTP id h4csp2114245imn; Sun, 8 Apr 2018 20:04:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/dUUPM3+GN8lt1TtPfAdsjW3g2lLX1XkxmXEK0ewiW08kWaTSbz6TGMtpZi8WLIYktpd6z X-Received: by 10.98.163.68 with SMTP id s65mr27798915pfe.13.1523243066839; Sun, 08 Apr 2018 20:04:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243066; cv=none; d=google.com; s=arc-20160816; b=PCaIrJGp9NChq1s9u+M7f6rLPc0I3QP13lrPIAmw5C4raT8wEvIZbpOwAS9HgQgtZa 90AOzfHjWqlyRrGeRlG1l5jUs28twGs9izOCO+fbF2ZSVoTrLeQKpE1JC7CWF83VfpYj pzixNonn9dYdUZFSQFNCjEZYb0wAgLCILlYdC7eNh+ZpBpc/oIVuEVpB0SYEwG3lBSqd hDGB5aLF4+ecLPjVCjJhf726M+FsAAEM+N4fv3DhrtVgsPBHmvYeMe/KLtC86SM4oucU mAgLYM+KDUwSFzsDYIFou8vgZZ2/aive8JbNzphe6OcXvhSZlKKDllryrCmR+FQAzdJQ JzNA== 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=o6i6NxikyCYzG5gwDU3ArcqFn0amgAmUHa+4QIfGvY4=; b=ii7sVe45wgDmcWQZVOYPkoi2nB2Lq2UCsF5HmZ5F6cUhUFJhPgtTejwXwrXS2f9iGN zMH+paSGf197YqoSuDfvNTLTiLjV1R8gXtce39gzcQMqOBzkn+Sk99AS5HGYb8jUnHQT pPMzT5Psdr/yv6xJt0WEVmPJLGJ5SvhsXLZFj7mLLrVm/AOhLN7EriAkKiia/GoA/Smx LRlsSvzyXSpQG67MtkxK46D6NVwH61oS23NAOvVzLiwDlxY08+GEIv8kpm2AHae7pcZq QA5RQg4xaFG+u6+HBSQIzdH/ELmhQarhEdKzo+5KkMsZultHwWlKU/QdX0kb+wEuvSq+ Dk/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=BI9/XJRG; 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 91-v6si16115961ply.33.2018.04.08.20.03.50; Sun, 08 Apr 2018 20:04:26 -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=BI9/XJRG; 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 S932419AbeDIAeC (ORCPT + 99 others); Sun, 8 Apr 2018 20:34:02 -0400 Received: from mail-by2nam01on0130.outbound.protection.outlook.com ([104.47.34.130]:18358 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932333AbeDIAdt (ORCPT ); Sun, 8 Apr 2018 20:33:49 -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=o6i6NxikyCYzG5gwDU3ArcqFn0amgAmUHa+4QIfGvY4=; b=BI9/XJRG8FBwv0eLdVm75RolHVLxQ7vNisUIMkhDvTqREBgxMIc0DvplLgUBlCJl06AOGfcjs5DaNghyibuEI/8wPTvJwkaKveVNSYZt4YLVuPQ9RUZj5lOxMuL1Jh3qMH+VEmlilT6phlfOgK+EkNEzXD5XcXziOZitxNFJXqo= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0806.namprd21.prod.outlook.com (10.167.107.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:33:46 +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:33:46 +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.9 250/293] ntb_transport: Fix bug with max_mw_size parameter Thread-Topic: [PATCH AUTOSEL for 4.9 250/293] ntb_transport: Fix bug with max_mw_size parameter Thread-Index: AQHTz5la5tJSyZyLx0e/Em5sBnsPhg== Date: Mon, 9 Apr 2018 00:26:07 +0000 Message-ID: <20180409002239.163177-250-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0806;7:4fJK/EMTCoAB1duIEmARBb7DSvbFs6Y7WfA+t+OR3W6QMy4Vem1ZlekW9q1e6s0WHY6Mm6NhOqQZ1ppdYEn4NclzUhT5ekVEhAWirnaaEJAixkT7H9rVq3EYimMvAoQzvgxmsw9vg0qdlMhVYc/k4ymHiABADIpqy0VsSdZSxjp22uNqdBRM57pr54Bn3VRMW/XLaiPnd0O+qqNfP31M6dta/L6fnqXcpQ9/8Bi0THhHsZR84LUXHC14x+9vf5jk;20:AMlXcDHXGWOUEhMqJ6v2G76W9jLgwPyBY9RH4xsI/r001JiUIOHGNZQ6e4evKy3G1wFrEVFVxq/U71md9v+gx7k+XqBShOZE81/zK0q3TPK6SBkNisJgF6yoZa+1FQDVggBiTXnrriN02OG4gWMD6uuzN7EU1GPo7x8HBRVYP5k= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 5d6cb08b-f805-4699-1162-08d59db18e84 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0806; x-ms-traffictypediagnostic: DM5PR2101MB0806: 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)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0806;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0806; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(396003)(366004)(39380400002)(199004)(189003)(2906002)(25786009)(2501003)(10290500003)(476003)(11346002)(446003)(97736004)(5250100002)(68736007)(2616005)(102836004)(6506007)(59450400001)(3846002)(3660700001)(486006)(3280700002)(305945005)(6666003)(99286004)(5660300001)(76176011)(1076002)(186003)(26005)(7736002)(6116002)(81156014)(81166006)(86612001)(4326008)(105586002)(10090500001)(2900100001)(54906003)(22452003)(316002)(36756003)(110136005)(107886003)(8676002)(6436002)(478600001)(53936002)(66066001)(6486002)(6512007)(575784001)(86362001)(14454004)(72206003)(8936002)(106356001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0806;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: +dN448zINdQYl27dDlkILGioHugAuYhUAzydl+1v7+RUb9WMUxkUGMX428nVqN+44fXeu5bTYc/1QCYRe0kfiyMrIgh21ZWgEXyzTY+LycxvJuuSRVLPIUvwQTZ2YF4yWYyzy6x67gN6zIojFnIEEpEtVKzbvLpt4jz3Far0uICSGBs6X4qnlsd408nwhdZ3s9QXMziEM35LVcJqZ+O+Xi5BLoAOH0uWs8YEFjvAUIxSWbdI35jUbFjPy8Rb1b9i5Zqbpf5F26O9CJw7XrIXL8guHMA7D5GcXXDzvFnj67HrPYgmBfjDBOrcJMLBEgS9dXc5QkJ/hMe5dVKoYqHX9WzClVZ/5IGJ5fuU9AyS6Dajd2WPSGzV9tq56m74IyDolU+eJ6k+1dVlwyaeCpkWYccOXnGbJ5dN0U6pFvzH0Pw= 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: 5d6cb08b-f805-4699-1162-08d59db18e84 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:26:07.6600 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0806 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 24222a5d8df2..da95bd8f0f72 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -996,6 +996,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