Received: by 10.192.165.148 with SMTP id m20csp554924imm; Wed, 25 Apr 2018 04:11:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo2Ime4Cbnst3T17wjoibN+JNBsA5ycjHCniluGARNfEi7Zca3s7WUurQ6iV49c1kLNNnQu X-Received: by 10.99.170.1 with SMTP id e1mr105751pgf.331.1524654674740; Wed, 25 Apr 2018 04:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524654674; cv=none; d=google.com; s=arc-20160816; b=evfNFD86anatwchhXloEiZtSJYP4HRkiSNgY4GjOH5JocAsq6FWUlEZRGHfXXbDI8T WFxp7u2RCgRKRI02Od3Pslj8L/SsTG2p3CED+m9bDHi9EXwZxd43Ezw4kXB2ahtT9Y6e TvqzAY4JtX5kDHuv1Omg+J+QoAPU1knVzkTM9hqFzOiZh3rJd1vqlSextaFRJ4O6/HO+ YykulD5HC56Sr27zxeVpqf4UegQIjDYgSumOXLk5cqpGaJ7rn1GGjRPg3lul6+cg84Za MXoNhlFLGjMUZ1x2N6j/7RdwYWh8ajggsxYsNWLjKdl6Si6MgtCswC7T6YeHg6lPl3zX Ww6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2AFFkBbtcOm8I0Ox4shl404ObyF2eoLuBKSZBgVuxeo=; b=gkAb1Kj/c0a0oD1aLYFa9Y6h3U3FQ2OT9DTB12mlY0WxSuz71RlpLAQqVn7bezDa7x YP+kxncRtoYZFkOJZx2sNSF13CJYwkxmx+wD4kREfd1pURKlOUY5YxJnojjPQDrGvoJw 9kxHV2f/xBidpDKJRFt99UQhnV3cYHIk323B1H442F3gB+OAT6veayCppkB8HU4FD2oK /554y5T0ER0odW5qKGM/kO69xQ2DjDQnWum/MQOrmzl7lEpuEDym2xKqGHvclf6h38ss P1kFkutQAxK4QHEGi8laZBArTVQVvq1riAEw+MLvvh3TfFohqv9mPOdnDsdBO99NFkMP 0W+g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s85si16014687pfk.369.2018.04.25.04.11.00; Wed, 25 Apr 2018 04:11:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753962AbeDYKlW (ORCPT + 99 others); Wed, 25 Apr 2018 06:41:22 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52320 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752074AbeDYKlP (ORCPT ); Wed, 25 Apr 2018 06:41:15 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8DA5E272; Wed, 25 Apr 2018 10:41:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Logan Gunthorpe , Allen Hubbe , Dave Jiang , Jon Mason , Sasha Levin Subject: [PATCH 4.14 100/183] ntb_transport: Fix bug with max_mw_size parameter Date: Wed, 25 Apr 2018 12:35:20 +0200 Message-Id: <20180425103246.483618554@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/ntb/ntb_transport.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -998,6 +998,9 @@ static int ntb_transport_init_queue(stru mw_base = nt->mw_vec[mw_num].phys_addr; mw_size = nt->mw_vec[mw_num].phys_size; + if (max_mw_size && mw_size > max_mw_size) + mw_size = max_mw_size; + tx_size = (unsigned int)mw_size / num_qps_mw; qp_offset = tx_size * (qp_num / mw_count);