From patchwork Thu Apr 10 06:35:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 3959931 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D6243BFF02 for ; Thu, 10 Apr 2014 06:36:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 126A320621 for ; Thu, 10 Apr 2014 06:36:52 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0F17220616 for ; Thu, 10 Apr 2014 06:36:51 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WY8b3-0007cX-BH; Thu, 10 Apr 2014 06:36:25 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WY8b0-00032Q-8V; Thu, 10 Apr 2014 06:36:22 +0000 Received: from 1wt.eu ([62.212.114.60]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WY8am-00031U-Nj for linux-arm-kernel@lists.infradead.org; Thu, 10 Apr 2014 06:36:10 +0000 Received: (from willy@localhost) by mail.home.local (8.14.4/8.14.4/Submit) id s3A6ZeOJ025319; Thu, 10 Apr 2014 08:35:40 +0200 Date: Thu, 10 Apr 2014 08:35:40 +0200 From: Willy Tarreau To: Jason Gunthorpe Subject: Re: [PATCH v2] bus: mvebu-mbus: Avoid setting an undefined window size Message-ID: <20140410063540.GA25198@1wt.eu> References: <1397000654-10849-1-git-send-email-jgunthorpe@obsidianresearch.com> <20140409061128.GC16465@1wt.eu> <20140409162040.GA19743@obsidianresearch.com> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140409162040.GA19743@obsidianresearch.com> User-Agent: Mutt/1.4.2.3i X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140410_023609_154856_609DDFD9 X-CRM114-Status: GOOD ( 22.58 ) X-Spam-Score: -2.2 (--) Cc: Thomas Petazzoni , Matthew Minter , Jason Cooper , linux-kernel@vger.kernel.org, Neil Greatorex , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Jason, On Wed, Apr 09, 2014 at 10:20:40AM -0600, Jason Gunthorpe wrote: > On Wed, Apr 09, 2014 at 08:11:29AM +0200, Willy Tarreau wrote: > > > OK I just got it by adding two printk() in pci-mvebu.c. Both functions > > mvebu_pcie_handle_iobase_change() and mvebu_pcie_handle_membase_change() > > do pass a size which is in fact a mask (size - 1) and not the real size. > > So the mbus is fed with an incorrect size which is off by one : > > Yes, that is right. I tested my patch here and didn't see any problem, > but I realize now that the mbus code is bailing early due to this: > > kernel: mvebu_mbus: cannot add window '4:e8', conflicts with another window > > Which I've never got around to fixing.. (whole other story there) > > Your patch looks fine, and it obviously needs to be sequenced before > mine. (Thomas/Jason C: how do you want to do this?) > > Reviewed-By: Jason Gunthorpe OK, thank you. I've updated the attached patch with your better description. Cheers, Willy From f90886f625d95781a3302bbc025304635dd97e9c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 9 Apr 2014 08:05:09 +0200 Subject: pci: mvebu: fix off-by-one in the computed size of the mbus windows mvebu_pcie_handle_membase_change() and mvebu_pcie_handle_iobase_change() do not correctly compute the window size. PCI uses an inclusive start/end address pair, which requires a +1 when converting to size. This only worked because a bug in the mbus driver allowed it to silently accept and round up bogus sizes. Fix this by adding one to the computed size. Signed-off-by: Willy Tarreau Reviewed-By: Jason Gunthorpe --- drivers/pci/host/pci-mvebu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 0e79665..eff0ab5 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -329,7 +329,7 @@ static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port) port->iowin_base = port->pcie->io.start + iobase; port->iowin_size = ((0xFFF | ((port->bridge.iolimit & 0xF0) << 8) | (port->bridge.iolimitupper << 16)) - - iobase); + iobase) + 1; mvebu_mbus_add_window_remap_by_id(port->io_target, port->io_attr, port->iowin_base, port->iowin_size, @@ -362,7 +362,7 @@ static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port) port->memwin_base = ((port->bridge.membase & 0xFFF0) << 16); port->memwin_size = (((port->bridge.memlimit & 0xFFF0) << 16) | 0xFFFFF) - - port->memwin_base; + port->memwin_base + 1; mvebu_mbus_add_window_by_id(port->mem_target, port->mem_attr, port->memwin_base, port->memwin_size);