From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753227AbbIWIBS (ORCPT ); Wed, 23 Sep 2015 04:01:18 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:60349 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752622AbbIWIBN (ORCPT ); Wed, 23 Sep 2015 04:01:13 -0400 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: David Daney , linux-kernel@vger.kernel.org, Bjorn Helgaas , linux-pci@vger.kernel.org, Will Deacon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , devicetree@vger.kernel.org, Marc Zyngier , David Daney Subject: Re: [PATCH v3 4/6] PCI: generic: Correct, and avoid overflow, in bus_max calculation. Date: Wed, 23 Sep 2015 10:01:01 +0200 Message-ID: <1496061.0ds89jTH75@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1442965757-12925-5-git-send-email-ddaney.cavm@gmail.com> References: <1442965757-12925-1-git-send-email-ddaney.cavm@gmail.com> <1442965757-12925-5-git-send-email-ddaney.cavm@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:WLnWUyLuqVXm3kIOE608a0AVgv9eX/EAGAu8IPvSGSRptX/Fn6W g5lanB/4BoG4HpS4YqQcHSvLhlrdc95Ncy/g8mU8qVb4qSbuttkPSJLm9KUuj/NrCOpbYfl Iia0b0BeRWVkJrZBcfQlKuZ/zVqUu/VccN7dXhEXnKUpLJ8uANXCxXHpIPxzpha5L1/+QdZ 2kSPmNFSfOarMJSMUKJNQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:/KJ3Q89UYZg=:HvYPsJSpdqC+0w7olR5ybU irTrtLQUINqD2dBarNVv1kjz98SPmMhi2tx+AwI/onwMvsFMadJrmgDRLsI0xjqviCQUNPaUZ C3npCK3I7Bzjr0qBkq47buOPdhM+VAd9EG4gmdyu+HG42Jo7Tyjc/XsFkQ3DT+DWem926RI1M RgvlAZjEt8qEBoq4894eRfYscNGqxBMUoErstoBojU61RmGyC5dR5p/jcLI7y83SLI1dm6T5t jI5QesQaRjdN9R52l00BCIQtfxJ+ZLUAZX/7W4krQ/+otBX5jige6izW81Q+TltD1GI8rxBaY hXSxBI+W5SRLO3+hNsZIegRFKZCAji9DtZa6qU9O4PIXd+Wxj/c61iDnZ7fxW7fyPHrs8Ert/ 3nSG+MyxCDNbbboMchimi3AvZ3DSmuKbbzL3TmoDLAWh+upYunsnU/aW5gr71bl2kalW4BgT5 gNQE+7rQHyGhISKeZcDbq0kS8xgGUsHf1OByNvf0f0nHdoVhYBMbKHPu5WcUBDJXOrwJXLZjR nJ5AwZFQ1+np1Km38qIBlla+ZoWSDAaGHIR32Wp+LzBWMtegPTe8IkzsDdm3SPdUbz/sI/Miz 1fyL9xqkSviDiYpci3B5n4IYnu5F+bwwg9SAYHDPApiy+yecVIrA/UBw0JqdWbZ+WgJNiHVsl t5SCr47IWi21IpqYnPS23Pehew5UBXzsFj1yTDRoN8udTiEGQFFiT1eLlIMCiH1D3v8Y6eJDa n/VWylWt+lEynABD Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 22 September 2015 16:49:15 David Daney wrote: > From: David Daney > > There are two problems with the bus_max calculation: > > 1) The u8 data type can overflow for large config space windows. > > 2) The calculation is incorrect for a bus range that doesn't start at > zero. > > Since the configuration space is relative to bus zero, make bus_max > just be the size of the config window scaled by bus_shift. Then clamp > it to a maximum of 255, per PCI. Use a data type of int to avoid > overflow problems. > > Update host-generic-pci.txt to clarify the semantics of the "reg" > property with respect to non-zero starting bus numbers. > > Signed-off-by: David Daney Not sure about this one > diff --git a/Documentation/devicetree/bindings/pci/host-generic-pci.txt b/Documentation/devicetree/bindings/pci/host-generic-pci.txt > index cf3e205..105a968 100644 > --- a/Documentation/devicetree/bindings/pci/host-generic-pci.txt > +++ b/Documentation/devicetree/bindings/pci/host-generic-pci.txt > @@ -34,7 +34,9 @@ Properties of the host controller node: > - #size-cells : Must be 2. > > - reg : The Configuration Space base address and size, as accessed > - from the parent bus. > + from the parent bus. The base address corresponds to > + bus zero, even though the "bus-range" property may specify > + a different starting bus number. This sounds like very unusual behavior. If you have a system with faked bus numbers where the registers only physically exist for a subset of the buses, this requires defining a reg property that contains MMIO space which is outside of the device and potentially contains other devices. What would break if we instead defined it the expected way and only list the registers for the bus numbers in the "bus-range" property? Arnd