* [PATCH] PCI: generic: Fix address window calculation for non-zero starting bus.
@ 2015-10-08 19:54 David Daney
2015-10-08 21:09 ` Arnd Bergmann
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: David Daney @ 2015-10-08 19:54 UTC (permalink / raw)
To: linux-kernel, Bjorn Helgaas, linux-pci, Will Deacon, Rob Herring,
Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
linux-arm-kernel, devicetree, Arnd Bergmann
Cc: David Daney
From: David Daney <david.daney@cavium.com>
Make the offset from the beginning of the "reg" property be from the
starting bus number, rather than zero. Hoist the invariant size
calculation out of the mapping for loop.
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 <david.daney@cavium.com>
---
This is a replacement for:
https://lkml.org/lkml/2015/10/2/653
Since that patch is getting too much push-back, this is the only other
option for fixing the driver to be internally consistent in its
treatment of the offset from "reg" to the first bus in the "bus-range"
property.
Documentation/devicetree/bindings/pci/host-generic-pci.txt | 5 +++--
drivers/pci/host/pci-host-generic.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/pci/host-generic-pci.txt b/Documentation/devicetree/bindings/pci/host-generic-pci.txt
index cf3e205..3f1d3fc 100644
--- a/Documentation/devicetree/bindings/pci/host-generic-pci.txt
+++ b/Documentation/devicetree/bindings/pci/host-generic-pci.txt
@@ -34,8 +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
+ the first bus in the "bus-range" property. If no
+ "bus-range" is specified, this will be bus 0 (the default).
Properties of the /chosen node:
diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
index fe9a81b..bb93346 100644
--- a/drivers/pci/host/pci-host-generic.c
+++ b/drivers/pci/host/pci-host-generic.c
@@ -169,6 +169,7 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
struct resource *bus_range;
struct device *dev = pci->host.dev.parent;
struct device_node *np = dev->of_node;
+ u32 sz = 1 << pci->cfg.ops->bus_shift;
err = of_address_to_resource(np, 0, &pci->cfg.res);
if (err) {
@@ -196,10 +197,9 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
bus_range = pci->cfg.bus_range;
for (busn = bus_range->start; busn <= bus_range->end; ++busn) {
u32 idx = busn - bus_range->start;
- u32 sz = 1 << pci->cfg.ops->bus_shift;
pci->cfg.win[idx] = devm_ioremap(dev,
- pci->cfg.res.start + busn * sz,
+ pci->cfg.res.start + idx * sz,
sz);
if (!pci->cfg.win[idx])
return -ENOMEM;
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: generic: Fix address window calculation for non-zero starting bus.
2015-10-08 19:54 [PATCH] PCI: generic: Fix address window calculation for non-zero starting bus David Daney
@ 2015-10-08 21:09 ` Arnd Bergmann
2015-10-08 22:05 ` Rob Herring
2015-10-09 23:21 ` Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2015-10-08 21:09 UTC (permalink / raw)
To: David Daney
Cc: linux-kernel, Bjorn Helgaas, linux-pci, Will Deacon, Rob Herring,
Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
linux-arm-kernel, devicetree, David Daney
On Thursday 08 October 2015 12:54:16 David Daney wrote:
> From: David Daney <david.daney@cavium.com>
>
> Make the offset from the beginning of the "reg" property be from the
> starting bus number, rather than zero. Hoist the invariant size
> calculation out of the mapping for loop.
>
> 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 <david.daney@cavium.com>
>
Thanks a lot!
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: generic: Fix address window calculation for non-zero starting bus.
2015-10-08 19:54 [PATCH] PCI: generic: Fix address window calculation for non-zero starting bus David Daney
2015-10-08 21:09 ` Arnd Bergmann
@ 2015-10-08 22:05 ` Rob Herring
2015-10-09 23:21 ` Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2015-10-08 22:05 UTC (permalink / raw)
To: David Daney
Cc: linux-kernel@vger.kernel.org, Bjorn Helgaas,
linux-pci@vger.kernel.org, Will Deacon, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
Arnd Bergmann, David Daney
On Thu, Oct 8, 2015 at 2:54 PM, David Daney <ddaney.cavm@gmail.com> wrote:
> From: David Daney <david.daney@cavium.com>
>
> Make the offset from the beginning of the "reg" property be from the
> starting bus number, rather than zero. Hoist the invariant size
> calculation out of the mapping for loop.
>
> 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 <david.daney@cavium.com>
Acked-by: Rob Herring <robh@kernel.org>
> ---
> This is a replacement for:
>
> https://lkml.org/lkml/2015/10/2/653
>
> Since that patch is getting too much push-back, this is the only other
> option for fixing the driver to be internally consistent in its
> treatment of the offset from "reg" to the first bus in the "bus-range"
> property.
>
> Documentation/devicetree/bindings/pci/host-generic-pci.txt | 5 +++--
> drivers/pci/host/pci-host-generic.c | 4 ++--
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/pci/host-generic-pci.txt b/Documentation/devicetree/bindings/pci/host-generic-pci.txt
> index cf3e205..3f1d3fc 100644
> --- a/Documentation/devicetree/bindings/pci/host-generic-pci.txt
> +++ b/Documentation/devicetree/bindings/pci/host-generic-pci.txt
> @@ -34,8 +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
> + the first bus in the "bus-range" property. If no
> + "bus-range" is specified, this will be bus 0 (the default).
>
> Properties of the /chosen node:
>
> diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
> index fe9a81b..bb93346 100644
> --- a/drivers/pci/host/pci-host-generic.c
> +++ b/drivers/pci/host/pci-host-generic.c
> @@ -169,6 +169,7 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
> struct resource *bus_range;
> struct device *dev = pci->host.dev.parent;
> struct device_node *np = dev->of_node;
> + u32 sz = 1 << pci->cfg.ops->bus_shift;
>
> err = of_address_to_resource(np, 0, &pci->cfg.res);
> if (err) {
> @@ -196,10 +197,9 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
> bus_range = pci->cfg.bus_range;
> for (busn = bus_range->start; busn <= bus_range->end; ++busn) {
> u32 idx = busn - bus_range->start;
> - u32 sz = 1 << pci->cfg.ops->bus_shift;
>
> pci->cfg.win[idx] = devm_ioremap(dev,
> - pci->cfg.res.start + busn * sz,
> + pci->cfg.res.start + idx * sz,
> sz);
> if (!pci->cfg.win[idx])
> return -ENOMEM;
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: generic: Fix address window calculation for non-zero starting bus.
2015-10-08 19:54 [PATCH] PCI: generic: Fix address window calculation for non-zero starting bus David Daney
2015-10-08 21:09 ` Arnd Bergmann
2015-10-08 22:05 ` Rob Herring
@ 2015-10-09 23:21 ` Bjorn Helgaas
2 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2015-10-09 23:21 UTC (permalink / raw)
To: David Daney
Cc: linux-kernel, Bjorn Helgaas, linux-pci, Will Deacon, Rob Herring,
Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
linux-arm-kernel, devicetree, Arnd Bergmann, David Daney
On Thu, Oct 08, 2015 at 12:54:16PM -0700, David Daney wrote:
> From: David Daney <david.daney@cavium.com>
>
> Make the offset from the beginning of the "reg" property be from the
> starting bus number, rather than zero. Hoist the invariant size
> calculation out of the mapping for loop.
>
> 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 <david.daney@cavium.com>
Applied to pci/host-generic for v4.4 with Reviewed-by and Acked-by from
Arnd and Rob, thanks David!
Bjorn
> ---
> This is a replacement for:
>
> https://lkml.org/lkml/2015/10/2/653
>
> Since that patch is getting too much push-back, this is the only other
> option for fixing the driver to be internally consistent in its
> treatment of the offset from "reg" to the first bus in the "bus-range"
> property.
>
> Documentation/devicetree/bindings/pci/host-generic-pci.txt | 5 +++--
> drivers/pci/host/pci-host-generic.c | 4 ++--
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/pci/host-generic-pci.txt b/Documentation/devicetree/bindings/pci/host-generic-pci.txt
> index cf3e205..3f1d3fc 100644
> --- a/Documentation/devicetree/bindings/pci/host-generic-pci.txt
> +++ b/Documentation/devicetree/bindings/pci/host-generic-pci.txt
> @@ -34,8 +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
> + the first bus in the "bus-range" property. If no
> + "bus-range" is specified, this will be bus 0 (the default).
>
> Properties of the /chosen node:
>
> diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
> index fe9a81b..bb93346 100644
> --- a/drivers/pci/host/pci-host-generic.c
> +++ b/drivers/pci/host/pci-host-generic.c
> @@ -169,6 +169,7 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
> struct resource *bus_range;
> struct device *dev = pci->host.dev.parent;
> struct device_node *np = dev->of_node;
> + u32 sz = 1 << pci->cfg.ops->bus_shift;
>
> err = of_address_to_resource(np, 0, &pci->cfg.res);
> if (err) {
> @@ -196,10 +197,9 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
> bus_range = pci->cfg.bus_range;
> for (busn = bus_range->start; busn <= bus_range->end; ++busn) {
> u32 idx = busn - bus_range->start;
> - u32 sz = 1 << pci->cfg.ops->bus_shift;
>
> pci->cfg.win[idx] = devm_ioremap(dev,
> - pci->cfg.res.start + busn * sz,
> + pci->cfg.res.start + idx * sz,
> sz);
> if (!pci->cfg.win[idx])
> return -ENOMEM;
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-10-09 23:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-08 19:54 [PATCH] PCI: generic: Fix address window calculation for non-zero starting bus David Daney
2015-10-08 21:09 ` Arnd Bergmann
2015-10-08 22:05 ` Rob Herring
2015-10-09 23:21 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).