PCI: generic: Fix address window calculation for non-zero starting bus.
PATCH 1/1 PCI: generic: Fix address window calculation for non-zero starting bus.
From: David Daney <[email protected]>
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.
---
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(-)
Documentation/devicetree/bindings/pci/host-generic-pci.txt +3 -2
@@ -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:
drivers/pci/host/pci-host-generic.c +2 -2
@@ -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 ;
Signature · 1 line
1.9.1
Quoted 11 lines · On Thursday 08 October 2015 12:54:16 David Daney wrote:
From: David Daney <[email protected]>
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 <[email protected]>
Thanks a lot!
Quoted 10 lines · David Daney
From: David Daney <[email protected]>
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 <[email protected]>
Quoted 57 lines
---
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(-)Documentation/devicetree/bindings/pci/host-generic-pci.txt +3
-2@@ -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:drivers/pci/host/pci-host-generic.c +2
-3@@ -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
Bjorn Helgaas
AppliedQuoted 10 lines · David Daney
From: David Daney <[email protected]>
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 <[email protected]>
Applied to pci/host-generic for v4.4 with Reviewed-by and Acked-by from Arnd and Rob, thanks David!
Bjorn
Quoted 61 lines
---
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(-)Documentation/devicetree/bindings/pci/host-generic-pci.txt +3
-2@@ -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:drivers/pci/host/pci-host-generic.c +2
-2@@ -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 ;Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html