* [PATCH v8 0/8] PCI: brcmstb: have portdrv turn on sub-device power
@ 2021-11-10 22:14 Jim Quinlan
2021-11-10 22:14 ` [PATCH v8 1/8] PCI: brcmstb: Change brcm_phy_stop() to return void Jim Quinlan
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Jim Quinlan @ 2021-11-10 22:14 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, jim2101024, james.quinlan
Cc: open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Jonathan Cameron, Keith Busch, Krzysztof Wilczyński,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
Qiuxu Zhuo, Saenz Julienne, Sean V Kelley
v8 -- Only the two binding commits and the "Change brcm_phy_stop()" commit
are unchanged.
-- The code has been moved to portdrv_pci.c and bus.c. The regulators
are placed in bus->dev.driver_data (bus->sysdata is already occupied
by the Broadcom PCIe). Two functions, pci_subdev_regulators_{add,remove}_bus()
are created to turn the regulators on/off. The pcie_portdriver also sets
its pci_driver methods suspend and resume when the condirtions are
right for this feature. (Robh for suggestions, although I probably
erred in following them).
-- Have the root complex return 0xffffffff on accesses even when
the link is down and the HW doesn't support such accesses (PaliR).
-- Just call devm_bulk_regulator_get() on standard supplies; don't
bother pre-scanning the DT for them (MarkB).
v7 -- RobH suggested putting the "vpcixxx-supply" property under the
bridge-node rather than the endpoint device node. Also, he said to
use the pci-ops add_bus/remove methods. Doing so simplifies the
code greatly and three commits were dropped. Thanks!
-- Rob also suggested (I think) having this patchset be a general
feature which is activated by an OF property under the bridge node.
I tried to do that but realized that our root complex driver
controls the regulators with its dev_pm_ops and there is no way to
transfer this control when using general mechanism. Note that
although the regulator core deals with suspend, our RC driver wants
the right to sometimes to preclude this for WOL scenarios.
-- One commit was added to change the response to the return value of
the pci_ops add_bus() method. Currently, an error causes a WARNING,
a dev_err(...), and continues to return the child bus. The
modification was, for returning -ENOLINK only, to skip WARNING &
dev_err() and return NULL. This is necessary for our RC HW, as if
the code continues on it will do a pci_read_config_dword() for the
vendor/id, and our HW flags a CPU abort (instead of returning
0xffffffff) when the is no pcie-link established.
[NOTE: MarkB, I did not add one of your two "Reviewed-by"s
because the commit had a decent amount of change.]
v6 -- Dropped the idea of a placeholder regulator
property (brcm-ep-a-supply). (MarkB)
-- device_initialize() now called once. Two
commits were added for this. (GKH)
-- In two cases, separated a single function
into two or more functions (MarkB)
-- "(void)foo();" => "foo()". Note that although
foo() returns an int, in this instance it is being
invoked within a function returning void, and foo()
already executes a dev_err() on error. (MarkB)
-- Added a commit to correct PCIe interrupts in YAML.
-- Removed "device_type = "pci";" for the EP node
in the YAML example.
-- Updated the URL related to the voltage regulator
names on GitHub. Note that I added vpciev3v3aux.
v5 [NOTE: It has been a while since v4. Sorry]
-- See "PCI: allow for callback to prepare nascent subdev"
commit message for the cornerstone of this patchset
and the reasons behind it. This is a new commit.
-- The RC driver now looks into its DT children and
turns on regulators for a sub-device, and this occurs
prior to PCIe link as it must.
-- Dropped commits not related to the focus of this patchset.
v4 [NOTE: I'm not sure this fixes RobH and MarkB constraints but I'd
like to use this pullreq as a basis for future discussion.]
[Commit: Add bindings for ...]
-- Fix syntax error in YAML bindings example (RobH)
-- {vpcie12v,vpcie3v3}-supply props are back in root complex DT node
(I believe RobH said this was okay)
[Commit: Add control of ..]
-- Do not do global search for regulator; now we look specifically
for the property {vpcie12v,vpcie3v3}-supply in the root complex
DT node and then call devm_regulator_bulk_get() (MarkB)
-- Use devm_regulator_bulk_get() (Bjorn)
-- s/EP/slot0 device/ (Bjorn)
-- Spelling, capitalization (Bjorn)
-- Have brcm_phy_stop() return a void (Bjorn)
[Commit: Do not turn off ...]
-- Capitalization (Bjorn)
[Commit: Check return value ...]
-- Commit message content (Bjorn)
-- Move 6/6 hunk to 2/6 where it belongs (Bjorn)
-- Move the rest of 6/6 before all other commits (Bjorn)
v3 -- Driver now searches for EP DT subnode for any regulators to turn on.
If present, these regulators have the property names
"vpcie12v-supply" and "vpcie3v3-supply". The existence of these
regulators in the EP subnode are currently pending as a pullreq
in pci-bus.yaml at
https://github.com/devicetree-org/dt-schema/pull/54
(MarkB, RobH).
-- Check return of brcm_set_regulators() (Florian)
-- Specify one regulator string per line for easier update (Florian)
-- Author/Committer/Signoff email changed from that of V2 from
'james.quinlan@broadcom.com' to 'jim2101024@gmail.com'.
v2 -- Use regulator bulk API rather than multiple calls (MarkB).
v1 -- Bindings are added for fixed regulators that may power the EP device.
-- The brcmstb RC driver is modified to control these regulators
during probe, suspend, and resume.
-- 7216 type SOCs have additional error reporting HW and a
panic handler is added to dump its info.
-- A missing return value check is added.
Jim Quinlan (8):
PCI: brcmstb: Change brcm_phy_stop() to return void
dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map.
dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators
PCI/portdrv: Create pcie_is_port_dev() func from existing code
PCI/portdrv: add mechanism to turn on subdev regulators
PCI/portdrv: Do not turn off subdev regulators if EP can wake up
PCI: brcmstb: Split brcm_pcie_setup() into two funcs
PCI: brcmstb: Add control of subdevice voltage regulators
.../bindings/pci/brcm,stb-pcie.yaml | 31 ++++-
drivers/pci/bus.c | 72 ++++++++++
drivers/pci/controller/pcie-brcmstb.c | 131 +++++++++++++-----
drivers/pci/pci.h | 11 ++
drivers/pci/pcie/portdrv_pci.c | 86 +++++++++++-
5 files changed, 292 insertions(+), 39 deletions(-)
base-commit: 8e37395c3a5dceff62a5010ebbbc107f4145935c
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v8 1/8] PCI: brcmstb: Change brcm_phy_stop() to return void
2021-11-10 22:14 [PATCH v8 0/8] PCI: brcmstb: have portdrv turn on sub-device power Jim Quinlan
@ 2021-11-10 22:14 ` Jim Quinlan
2021-11-11 21:57 ` Bjorn Helgaas
2021-11-10 22:14 ` [PATCH v8 2/8] dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map Jim Quinlan
` (3 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Jim Quinlan @ 2021-11-10 22:14 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, jim2101024, james.quinlan
Cc: Florian Fainelli, Lorenzo Pieralisi, Krzysztof Wilczyński,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list
We do not use the result of this function so make it void.
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
---
drivers/pci/controller/pcie-brcmstb.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index cc30215f5a43..ff7d0d291531 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -1111,9 +1111,10 @@ static inline int brcm_phy_start(struct brcm_pcie *pcie)
return pcie->rescal ? brcm_phy_cntl(pcie, 1) : 0;
}
-static inline int brcm_phy_stop(struct brcm_pcie *pcie)
+static inline void brcm_phy_stop(struct brcm_pcie *pcie)
{
- return pcie->rescal ? brcm_phy_cntl(pcie, 0) : 0;
+ if (pcie->rescal)
+ brcm_phy_cntl(pcie, 0);
}
static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
@@ -1143,14 +1144,13 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
static int brcm_pcie_suspend(struct device *dev)
{
struct brcm_pcie *pcie = dev_get_drvdata(dev);
- int ret;
brcm_pcie_turn_off(pcie);
- ret = brcm_phy_stop(pcie);
+ brcm_phy_stop(pcie);
reset_control_rearm(pcie->rescal);
clk_disable_unprepare(pcie->clk);
- return ret;
+ return 0;
}
static int brcm_pcie_resume(struct device *dev)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v8 2/8] dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map.
2021-11-10 22:14 [PATCH v8 0/8] PCI: brcmstb: have portdrv turn on sub-device power Jim Quinlan
2021-11-10 22:14 ` [PATCH v8 1/8] PCI: brcmstb: Change brcm_phy_stop() to return void Jim Quinlan
@ 2021-11-10 22:14 ` Jim Quinlan
2021-11-10 22:14 ` [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators Jim Quinlan
` (2 subsequent siblings)
4 siblings, 0 replies; 14+ messages in thread
From: Jim Quinlan @ 2021-11-10 22:14 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, jim2101024, james.quinlan
Cc: Florian Fainelli, Rob Herring, Saenz Julienne,
moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
The "pcie" and "msi" interrupts were given the same interrupt when they are
actually different. Interrupt-map only had the INTA entry; the INTB, INTC,
and INTD entries are added.
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
---
Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml
index b9589a0daa5c..508e5dce1282 100644
--- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml
+++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml
@@ -142,11 +142,15 @@ examples:
#address-cells = <3>;
#size-cells = <2>;
#interrupt-cells = <1>;
- interrupts = <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>,
+ interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "pcie", "msi";
interrupt-map-mask = <0x0 0x0 0x0 0x7>;
- interrupt-map = <0 0 0 1 &gicv2 GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-map = <0 0 0 1 &gicv2 GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH
+ 0 0 0 2 &gicv2 GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH
+ 0 0 0 3 &gicv2 GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH
+ 0 0 0 4 &gicv2 GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>;
+
msi-parent = <&pcie0>;
msi-controller;
ranges = <0x02000000 0x0 0xf8000000 0x6 0x00000000 0x0 0x04000000>;
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators
2021-11-10 22:14 [PATCH v8 0/8] PCI: brcmstb: have portdrv turn on sub-device power Jim Quinlan
2021-11-10 22:14 ` [PATCH v8 1/8] PCI: brcmstb: Change brcm_phy_stop() to return void Jim Quinlan
2021-11-10 22:14 ` [PATCH v8 2/8] dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map Jim Quinlan
@ 2021-11-10 22:14 ` Jim Quinlan
2021-11-11 22:17 ` Bjorn Helgaas
2021-11-13 11:38 ` Pali Rohár
2021-11-10 22:14 ` [PATCH v8 7/8] PCI: brcmstb: Split brcm_pcie_setup() into two funcs Jim Quinlan
2021-11-10 22:14 ` [PATCH v8 8/8] PCI: brcmstb: Add control of subdevice voltage regulators Jim Quinlan
4 siblings, 2 replies; 14+ messages in thread
From: Jim Quinlan @ 2021-11-10 22:14 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, jim2101024, james.quinlan
Cc: Florian Fainelli, Rob Herring, Saenz Julienne,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
Similar to the regulator bindings found in "rockchip-pcie-host.txt", this
allows optional regulators to be attached and controlled by the PCIe RC
driver. That being said, this driver searches in the DT subnode (the EP
node, eg pci-ep@0,0) for the regulator property.
The use of a regulator property in the pcie EP subnode such as
"vpcie12v-supply" depends on a pending pullreq to the pci-bus.yaml
file at
https://github.com/devicetree-org/dt-schema/pull/63
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
---
.../bindings/pci/brcm,stb-pcie.yaml | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml
index 508e5dce1282..ef2427320b7d 100644
--- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml
+++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml
@@ -158,5 +158,28 @@ examples:
<0x42000000 0x1 0x80000000 0x3 0x00000000 0x0 0x80000000>;
brcm,enable-ssc;
brcm,scb-sizes = <0x0000000080000000 0x0000000080000000>;
+
+ /* PCIe bridge */
+ pci@0,0 {
+ #address-cells = <3>;
+ #size-cells = <2>;
+ reg = <0x0 0x0 0x0 0x0 0x0>;
+ compatible = "pciclass,0604";
+ device_type = "pci";
+ vpcie3v3-supply = <&vreg7>;
+ ranges;
+
+ /* PCIe endpoint */
+ pci-ep@0,0 {
+ assigned-addresses =
+ <0x82010000 0x0 0xf8000000 0x6 0x00000000 0x0 0x2000>;
+ reg = <0x0 0x0 0x0 0x0 0x0>;
+ compatible = "pci14e4,1688";
+ #address-cells = <3>;
+ #size-cells = <2>;
+
+ ranges;
+ };
+ };
};
};
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v8 7/8] PCI: brcmstb: Split brcm_pcie_setup() into two funcs
2021-11-10 22:14 [PATCH v8 0/8] PCI: brcmstb: have portdrv turn on sub-device power Jim Quinlan
` (2 preceding siblings ...)
2021-11-10 22:14 ` [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators Jim Quinlan
@ 2021-11-10 22:14 ` Jim Quinlan
2021-11-10 22:14 ` [PATCH v8 8/8] PCI: brcmstb: Add control of subdevice voltage regulators Jim Quinlan
4 siblings, 0 replies; 14+ messages in thread
From: Jim Quinlan @ 2021-11-10 22:14 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, jim2101024, james.quinlan
Cc: Florian Fainelli, Lorenzo Pieralisi, Krzysztof Wilczyński,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list
We need to take some code in brcm_pcie_setup() and put it in a new function
brcm_pcie_linkup(). In future commits the brcm_pcie_linkup() function will
be called indirectly by pci_host_probe() as opposed to the host driver
invoking it directly.
Some code that was executed after the PCIe linkup is now placed so that it
executes prior to linkup, since this code has to run prior to the
invocation of pci_host_probe().
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
---
drivers/pci/controller/pcie-brcmstb.c | 65 ++++++++++++++++-----------
1 file changed, 39 insertions(+), 26 deletions(-)
diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index ff7d0d291531..1a841c240abb 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -863,16 +863,9 @@ static inline int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie,
static int brcm_pcie_setup(struct brcm_pcie *pcie)
{
- struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
u64 rc_bar2_offset, rc_bar2_size;
void __iomem *base = pcie->base;
- struct device *dev = pcie->dev;
- struct resource_entry *entry;
- bool ssc_good = false;
- struct resource *res;
- int num_out_wins = 0;
- u16 nlw, cls, lnksta;
- int i, ret, memc;
+ int ret, memc;
u32 tmp, burst, aspm_support;
/* Reset the bridge */
@@ -957,6 +950,40 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
if (pcie->gen)
brcm_pcie_set_gen(pcie, pcie->gen);
+ /* Don't advertise L0s capability if 'aspm-no-l0s' */
+ aspm_support = PCIE_LINK_STATE_L1;
+ if (!of_property_read_bool(pcie->np, "aspm-no-l0s"))
+ aspm_support |= PCIE_LINK_STATE_L0S;
+ tmp = readl(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
+ u32p_replace_bits(&tmp, aspm_support,
+ PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK);
+ writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
+
+ /*
+ * For config space accesses on the RC, show the right class for
+ * a PCIe-PCIe bridge (the default setting is to be EP mode).
+ */
+ tmp = readl(base + PCIE_RC_CFG_PRIV1_ID_VAL3);
+ u32p_replace_bits(&tmp, 0x060400,
+ PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK);
+ writel(tmp, base + PCIE_RC_CFG_PRIV1_ID_VAL3);
+
+ return 0;
+}
+
+static int brcm_pcie_linkup(struct brcm_pcie *pcie)
+{
+ struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
+ struct device *dev = pcie->dev;
+ void __iomem *base = pcie->base;
+ struct resource_entry *entry;
+ struct resource *res;
+ int num_out_wins = 0;
+ u16 nlw, cls, lnksta;
+ bool ssc_good = false;
+ u32 tmp;
+ int ret, i;
+
/* Unassert the fundamental reset */
pcie->perst_set(pcie, 0);
@@ -994,24 +1021,6 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
num_out_wins++;
}
- /* Don't advertise L0s capability if 'aspm-no-l0s' */
- aspm_support = PCIE_LINK_STATE_L1;
- if (!of_property_read_bool(pcie->np, "aspm-no-l0s"))
- aspm_support |= PCIE_LINK_STATE_L0S;
- tmp = readl(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
- u32p_replace_bits(&tmp, aspm_support,
- PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK);
- writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
-
- /*
- * For config space accesses on the RC, show the right class for
- * a PCIe-PCIe bridge (the default setting is to be EP mode).
- */
- tmp = readl(base + PCIE_RC_CFG_PRIV1_ID_VAL3);
- u32p_replace_bits(&tmp, 0x060400,
- PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK);
- writel(tmp, base + PCIE_RC_CFG_PRIV1_ID_VAL3);
-
if (pcie->ssc) {
ret = brcm_pcie_set_ssc(pcie);
if (ret == 0)
@@ -1186,6 +1195,10 @@ static int brcm_pcie_resume(struct device *dev)
if (ret)
goto err_reset;
+ ret = brcm_pcie_linkup(pcie);
+ if (ret)
+ goto err_reset;
+
if (pcie->msi)
brcm_msi_set_regs(pcie->msi);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v8 8/8] PCI: brcmstb: Add control of subdevice voltage regulators
2021-11-10 22:14 [PATCH v8 0/8] PCI: brcmstb: have portdrv turn on sub-device power Jim Quinlan
` (3 preceding siblings ...)
2021-11-10 22:14 ` [PATCH v8 7/8] PCI: brcmstb: Split brcm_pcie_setup() into two funcs Jim Quinlan
@ 2021-11-10 22:14 ` Jim Quinlan
4 siblings, 0 replies; 14+ messages in thread
From: Jim Quinlan @ 2021-11-10 22:14 UTC (permalink / raw)
To: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, jim2101024, james.quinlan
Cc: Florian Fainelli, Lorenzo Pieralisi, Krzysztof Wilczyński,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list
This Broadcom STB PCIe RC driver has one port and connects directly to one
device, be it a switch or an endpoint. We want to be able to leverage
the recently added mechansim that allocates and turns on/off subdevice
regulators.
All that needs to be done is to put the regulator DT nodes in the bridge
below host and to set the pci_ops methods add_bus and remove_bus.
Note that the pci_subdev_regulators_add_bus() method is wrapped for two
reasons:
1. To acheive linkup after the voltage regulators are turned on.
2. If, in the case of an unsuccessful linkup, to redirect
any PCIe accesses to subdevices, e.g. the scan for
DEV/ID. This redirection is needed because the Broadcom
PCIe HW wil issue a CPU abort if such an access is made when
there is no linkup.
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
---
drivers/pci/controller/pcie-brcmstb.c | 56 ++++++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index 1a841c240abb..692df3dda77a 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -191,6 +191,7 @@ static inline void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie,
static inline void brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val);
static inline void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val);
static inline void brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val);
+static int brcm_pcie_add_bus(struct pci_bus *bus);
enum {
RGR1_SW_INIT_1,
@@ -295,6 +296,7 @@ struct brcm_pcie {
u32 hw_rev;
void (*perst_set)(struct brcm_pcie *pcie, u32 val);
void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val);
+ bool refusal_mode;
};
/*
@@ -711,6 +713,18 @@ static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn,
/* Accesses to the RC go right to the RC registers if slot==0 */
if (pci_is_root_bus(bus))
return PCI_SLOT(devfn) ? NULL : base + where;
+ if (pcie->refusal_mode) {
+ /*
+ * At this point we do not have link. There will be a CPU
+ * abort -- a quirk with this controller --if Linux tries
+ * to read any config-space registers besides those
+ * targeting the host bridge. To prevent this we hijack
+ * the address to point to a safe access that will return
+ * 0xffffffff.
+ */
+ writel(0xffffffff, base + PCIE_MISC_RC_BAR2_CONFIG_HI);
+ return base + PCIE_MISC_RC_BAR2_CONFIG_HI + (where & 0x3);
+ }
/* For devices, write to the config space index register */
idx = PCIE_ECAM_OFFSET(bus->number, devfn, 0);
@@ -722,6 +736,8 @@ static struct pci_ops brcm_pcie_ops = {
.map_bus = brcm_pcie_map_conf,
.read = pci_generic_config_read,
.write = pci_generic_config_write,
+ .add_bus = brcm_pcie_add_bus,
+ .remove_bus = pci_subdev_regulators_remove_bus,
};
static inline void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val)
@@ -1242,6 +1258,34 @@ static const struct of_device_id brcm_pcie_match[] = {
{},
};
+static int brcm_pcie_add_bus(struct pci_bus *bus)
+{
+ struct pci_host_bridge *hb;
+ struct brcm_pcie *pcie;
+ int ret;
+
+ if (!pcie_is_port_dev(bus->self))
+ return 0;
+
+ hb = pci_find_host_bridge(bus);
+ pcie = (struct brcm_pcie *) hb->sysdata;
+
+ ret = pci_subdev_regulators_add_bus(bus);
+ if (ret)
+ return ret;
+
+ /*
+ * If we have failed linkup there is no point to return an error as
+ * currently it will cause a WARNING() from pci_alloc_child_bus().
+ * We return 0 and turn on the "refusal_mode" so that any further
+ * accesses to the pci_dev just get 0xffffffff
+ */
+ if (brcm_pcie_linkup(pcie) != 0)
+ pcie->refusal_mode = true;
+
+ return 0;
+}
+
static int brcm_pcie_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node, *msi_np;
@@ -1333,7 +1377,17 @@ static int brcm_pcie_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, pcie);
- return pci_host_probe(bridge);
+ ret = pci_host_probe(bridge);
+ if (!ret && !brcm_pcie_link_up(pcie))
+ ret = -ENODEV;
+
+ if (ret) {
+ brcm_pcie_remove(pdev);
+ return ret;
+ }
+
+ return 0;
+
fail:
__brcm_pcie_remove(pcie);
return ret;
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v8 1/8] PCI: brcmstb: Change brcm_phy_stop() to return void
2021-11-10 22:14 ` [PATCH v8 1/8] PCI: brcmstb: Change brcm_phy_stop() to return void Jim Quinlan
@ 2021-11-11 21:57 ` Bjorn Helgaas
2021-11-15 20:56 ` Jim Quinlan
0 siblings, 1 reply; 14+ messages in thread
From: Bjorn Helgaas @ 2021-11-11 21:57 UTC (permalink / raw)
To: Jim Quinlan
Cc: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, james.quinlan,
Florian Fainelli, Lorenzo Pieralisi, Krzysztof Wilczyński,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list
On Wed, Nov 10, 2021 at 05:14:41PM -0500, Jim Quinlan wrote:
> We do not use the result of this function so make it void.
I don't get it. Can you expand on this?
brcm_phy_cntl() can return -EIO, which means brcm_phy_stop() can
return -EIO, which means brcm_pcie_suspend can return -EIO.
brcm_pcie_suspend() is the dev_pm_ops.suspend() method.
So are you saying we never use the result of dev_pm_ops.suspend()?
> Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
> ---
> drivers/pci/controller/pcie-brcmstb.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
> index cc30215f5a43..ff7d0d291531 100644
> --- a/drivers/pci/controller/pcie-brcmstb.c
> +++ b/drivers/pci/controller/pcie-brcmstb.c
> @@ -1111,9 +1111,10 @@ static inline int brcm_phy_start(struct brcm_pcie *pcie)
> return pcie->rescal ? brcm_phy_cntl(pcie, 1) : 0;
> }
>
> -static inline int brcm_phy_stop(struct brcm_pcie *pcie)
> +static inline void brcm_phy_stop(struct brcm_pcie *pcie)
> {
> - return pcie->rescal ? brcm_phy_cntl(pcie, 0) : 0;
> + if (pcie->rescal)
> + brcm_phy_cntl(pcie, 0);
> }
>
> static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
> @@ -1143,14 +1144,13 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
> static int brcm_pcie_suspend(struct device *dev)
> {
> struct brcm_pcie *pcie = dev_get_drvdata(dev);
> - int ret;
>
> brcm_pcie_turn_off(pcie);
> - ret = brcm_phy_stop(pcie);
> + brcm_phy_stop(pcie);
> reset_control_rearm(pcie->rescal);
> clk_disable_unprepare(pcie->clk);
>
> - return ret;
> + return 0;
> }
>
> static int brcm_pcie_resume(struct device *dev)
> --
> 2.17.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators
2021-11-10 22:14 ` [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators Jim Quinlan
@ 2021-11-11 22:17 ` Bjorn Helgaas
2021-11-12 18:25 ` Jim Quinlan
2021-11-13 11:38 ` Pali Rohár
1 sibling, 1 reply; 14+ messages in thread
From: Bjorn Helgaas @ 2021-11-11 22:17 UTC (permalink / raw)
To: Jim Quinlan
Cc: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, james.quinlan,
Florian Fainelli, Rob Herring, Saenz Julienne,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
On Wed, Nov 10, 2021 at 05:14:43PM -0500, Jim Quinlan wrote:
> Similar to the regulator bindings found in "rockchip-pcie-host.txt", this
> allows optional regulators to be attached and controlled by the PCIe RC
> driver. That being said, this driver searches in the DT subnode (the EP
> node, eg pci-ep@0,0) for the regulator property.
>
> The use of a regulator property in the pcie EP subnode such as
> "vpcie12v-supply" depends on a pending pullreq to the pci-bus.yaml
> file at
>
> https://github.com/devicetree-org/dt-schema/pull/63
Can you use a lore URL here? github.com is sort of outside the Linux
ecosystem and this link is more likely to remain useful if it's to
something in kernel.org.
The subject says what this patch does, but the commit log doesn't.
It's OK to repeat the subject in the commit log if that's what makes
the most sense.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators
2021-11-11 22:17 ` Bjorn Helgaas
@ 2021-11-12 18:25 ` Jim Quinlan
2021-11-12 20:20 ` Bjorn Helgaas
0 siblings, 1 reply; 14+ messages in thread
From: Jim Quinlan @ 2021-11-12 18:25 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, Jim Quinlan,
Florian Fainelli, Rob Herring, Saenz Julienne,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
On Thu, Nov 11, 2021 at 5:17 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Wed, Nov 10, 2021 at 05:14:43PM -0500, Jim Quinlan wrote:
> > Similar to the regulator bindings found in "rockchip-pcie-host.txt", this
> > allows optional regulators to be attached and controlled by the PCIe RC
> > driver. That being said, this driver searches in the DT subnode (the EP
> > node, eg pci-ep@0,0) for the regulator property.
> >
> > The use of a regulator property in the pcie EP subnode such as
> > "vpcie12v-supply" depends on a pending pullreq to the pci-bus.yaml
> > file at
> >
> > https://github.com/devicetree-org/dt-schema/pull/63
>
> Can you use a lore URL here? github.com is sort of outside the Linux
> ecosystem and this link is more likely to remain useful if it's to
> something in kernel.org.
Hi Bjorn,
I'm afraid I don't know how or if this github repo transfers
information to Linux. RobH, what should I be doing here?
>
> The subject says what this patch does, but the commit log doesn't.
> It's OK to repeat the subject in the commit log if that's what makes
> the most sense.
Got it.
Thanks,
Jim Quinlan
Broadcom STB
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators
2021-11-12 18:25 ` Jim Quinlan
@ 2021-11-12 20:20 ` Bjorn Helgaas
2021-11-12 21:46 ` Rob Herring
0 siblings, 1 reply; 14+ messages in thread
From: Bjorn Helgaas @ 2021-11-12 20:20 UTC (permalink / raw)
To: Jim Quinlan
Cc: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, Jim Quinlan,
Florian Fainelli, Rob Herring, Saenz Julienne,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
On Fri, Nov 12, 2021 at 01:25:11PM -0500, Jim Quinlan wrote:
> On Thu, Nov 11, 2021 at 5:17 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
> > On Wed, Nov 10, 2021 at 05:14:43PM -0500, Jim Quinlan wrote:
> > > Similar to the regulator bindings found in "rockchip-pcie-host.txt", this
> > > allows optional regulators to be attached and controlled by the PCIe RC
> > > driver. That being said, this driver searches in the DT subnode (the EP
> > > node, eg pci-ep@0,0) for the regulator property.
> > >
> > > The use of a regulator property in the pcie EP subnode such as
> > > "vpcie12v-supply" depends on a pending pullreq to the pci-bus.yaml
> > > file at
> > >
> > > https://github.com/devicetree-org/dt-schema/pull/63
> >
> > Can you use a lore URL here? github.com is sort of outside the Linux
> > ecosystem and this link is more likely to remain useful if it's to
> > something in kernel.org.
> Hi Bjorn,
> I'm afraid I don't know how or if this github repo transfers
> information to Linux. RobH, what should I be doing here?
Does this change get posted to any mailing lists where people can
review it? Or would people have to watch the github devicetree-org
repo if they wanted to do that? I was assuming this pci-bus.yaml
change was something that would eventually end up in the Linux kernel
source tree, but dt-scheme doesn't seem to be based on Linus' tree, so
I don't know if there's a connection.
Bjorn
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators
2021-11-12 20:20 ` Bjorn Helgaas
@ 2021-11-12 21:46 ` Rob Herring
0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2021-11-12 21:46 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Jim Quinlan, linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne,
Mark Brown, bcm-kernel-feedback-list, Jim Quinlan,
Florian Fainelli, Saenz Julienne,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
On Fri, Nov 12, 2021 at 2:20 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Fri, Nov 12, 2021 at 01:25:11PM -0500, Jim Quinlan wrote:
> > On Thu, Nov 11, 2021 at 5:17 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
> > > On Wed, Nov 10, 2021 at 05:14:43PM -0500, Jim Quinlan wrote:
> > > > Similar to the regulator bindings found in "rockchip-pcie-host.txt", this
> > > > allows optional regulators to be attached and controlled by the PCIe RC
> > > > driver. That being said, this driver searches in the DT subnode (the EP
> > > > node, eg pci-ep@0,0) for the regulator property.
> > > >
> > > > The use of a regulator property in the pcie EP subnode such as
> > > > "vpcie12v-supply" depends on a pending pullreq to the pci-bus.yaml
> > > > file at
> > > >
> > > > https://github.com/devicetree-org/dt-schema/pull/63
> > >
> > > Can you use a lore URL here? github.com is sort of outside the Linux
> > > ecosystem and this link is more likely to remain useful if it's to
> > > something in kernel.org.
> > Hi Bjorn,
> > I'm afraid I don't know how or if this github repo transfers
> > information to Linux. RobH, what should I be doing here?
>
> Does this change get posted to any mailing lists where people can
> review it?
devicetree-spec is where I direct folks to. It's not in lore, but we
could add it I guess. But I take PRs too. There's so few other
contributions I'm looking to make it as painless as possible for
contributors. I'd be happy for more reviewers other than me, but I
don't think where changes are posted is the problem there. :( Someone
should review all the crap Python code I write too.
Generally the flow is I redirect things submitted to the kernel to
dtschema instead. So that review happens first at least.
> Or would people have to watch the github devicetree-org
> repo if they wanted to do that? I was assuming this pci-bus.yaml
> change was something that would eventually end up in the Linux kernel
> source tree, but dt-scheme doesn't seem to be based on Linus' tree, so
> I don't know if there's a connection.
It's more the other way around. The 'rule' is common bindings go in
dtschema and device specific bindings in the kernel tree. Reality is
some common bindings are in the kernel tree primarily because I want
everything in dtschema dual licensed and relicensing is a pain. That's
why we have pci.txt and pci-bus.yaml still.
Rob
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators
2021-11-10 22:14 ` [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators Jim Quinlan
2021-11-11 22:17 ` Bjorn Helgaas
@ 2021-11-13 11:38 ` Pali Rohár
1 sibling, 0 replies; 14+ messages in thread
From: Pali Rohár @ 2021-11-13 11:38 UTC (permalink / raw)
To: Jim Quinlan
Cc: linux-pci, Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring,
Mark Brown, bcm-kernel-feedback-list, james.quinlan,
Florian Fainelli, Rob Herring, Saenz Julienne,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
On Wednesday 10 November 2021 17:14:43 Jim Quinlan wrote:
> Similar to the regulator bindings found in "rockchip-pcie-host.txt", this
> allows optional regulators to be attached and controlled by the PCIe RC
> driver. That being said, this driver searches in the DT subnode (the EP
> node, eg pci-ep@0,0) for the regulator property.
>
> The use of a regulator property in the pcie EP subnode such as
> "vpcie12v-supply" depends on a pending pullreq to the pci-bus.yaml
> file at
>
> https://github.com/devicetree-org/dt-schema/pull/63
>
> Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
> ---
> .../bindings/pci/brcm,stb-pcie.yaml | 23 +++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml
> index 508e5dce1282..ef2427320b7d 100644
> --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml
> +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml
> @@ -158,5 +158,28 @@ examples:
> <0x42000000 0x1 0x80000000 0x3 0x00000000 0x0 0x80000000>;
> brcm,enable-ssc;
> brcm,scb-sizes = <0x0000000080000000 0x0000000080000000>;
> +
> + /* PCIe bridge */
> + pci@0,0 {
Hello! I think that above comment should be "PCIe Root Port" (and not
PCIe bridge) as this node really describes Root Port device in PCIe Root
Complex (correct me if I deduced it wrongly). lspci (-vv) show type of
device on the line "Capabilities: [..] Express".
> + #address-cells = <3>;
> + #size-cells = <2>;
> + reg = <0x0 0x0 0x0 0x0 0x0>;
> + compatible = "pciclass,0604";
> + device_type = "pci";
> + vpcie3v3-supply = <&vreg7>;
> + ranges;
> +
> + /* PCIe endpoint */
> + pci-ep@0,0 {
> + assigned-addresses =
> + <0x82010000 0x0 0xf8000000 0x6 0x00000000 0x0 0x2000>;
> + reg = <0x0 0x0 0x0 0x0 0x0>;
> + compatible = "pci14e4,1688";
> + #address-cells = <3>;
> + #size-cells = <2>;
> +
> + ranges;
> + };
> + };
> };
> };
> --
> 2.17.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v8 1/8] PCI: brcmstb: Change brcm_phy_stop() to return void
2021-11-11 21:57 ` Bjorn Helgaas
@ 2021-11-15 20:56 ` Jim Quinlan
2021-11-16 20:40 ` Bjorn Helgaas
0 siblings, 1 reply; 14+ messages in thread
From: Jim Quinlan @ 2021-11-15 20:56 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Jim Quinlan,
open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS,
Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring, Mark Brown,
maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE, Florian Fainelli,
Lorenzo Pieralisi, Krzysztof Wilczyński,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list
On Thu, Nov 11, 2021 at 4:57 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Wed, Nov 10, 2021 at 05:14:41PM -0500, Jim Quinlan wrote:
> > We do not use the result of this function so make it void.
>
> I don't get it. Can you expand on this?
>
> brcm_phy_cntl() can return -EIO, which means brcm_phy_stop() can
> return -EIO, which means brcm_pcie_suspend can return -EIO.
> brcm_pcie_suspend() is the dev_pm_ops.suspend() method.
>
> So are you saying we never use the result of dev_pm_ops.suspend()?
Hi Bjorn,
In this situation we are going into suspend. In doing so, any
problems with the brcm phy may be erased/forgiven upon resume, since
clocks are turned off and most power removed/reduced. An error from
brcm_phy_stop() that becomes the return value of brcm_pcie_suspend()
will bring a halt to the entire suspend IIRC. In fact, I forced a
-EIO in this code and it panic'd on suspend. This is not really the
behavior I want for what is most likely a recoverable error.
Perhaps a dev_err(...) will suffice while still returning 0?
I noticed that reset_control_rearm() also returns a value, and if that
is in error it will not be erease/forgiven by suspend sleep. I will
fix this.
Regards,
Jim Quinlan
Broadcom STB
>
> > Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
> > ---
> > drivers/pci/controller/pcie-brcmstb.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
> > index cc30215f5a43..ff7d0d291531 100644
> > --- a/drivers/pci/controller/pcie-brcmstb.c
> > +++ b/drivers/pci/controller/pcie-brcmstb.c
> > @@ -1111,9 +1111,10 @@ static inline int brcm_phy_start(struct brcm_pcie *pcie)
> > return pcie->rescal ? brcm_phy_cntl(pcie, 1) : 0;
> > }
> >
> > -static inline int brcm_phy_stop(struct brcm_pcie *pcie)
> > +static inline void brcm_phy_stop(struct brcm_pcie *pcie)
> > {
> > - return pcie->rescal ? brcm_phy_cntl(pcie, 0) : 0;
> > + if (pcie->rescal)
> > + brcm_phy_cntl(pcie, 0);
> > }
> >
> > static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
> > @@ -1143,14 +1144,13 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
> > static int brcm_pcie_suspend(struct device *dev)
> > {
> > struct brcm_pcie *pcie = dev_get_drvdata(dev);
> > - int ret;
> >
> > brcm_pcie_turn_off(pcie);
> > - ret = brcm_phy_stop(pcie);
> > + brcm_phy_stop(pcie);
> > reset_control_rearm(pcie->rescal);
> > clk_disable_unprepare(pcie->clk);
> >
> > - return ret;
> > + return 0;
> > }
> >
> > static int brcm_pcie_resume(struct device *dev)
> > --
> > 2.17.1
> >
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v8 1/8] PCI: brcmstb: Change brcm_phy_stop() to return void
2021-11-15 20:56 ` Jim Quinlan
@ 2021-11-16 20:40 ` Bjorn Helgaas
0 siblings, 0 replies; 14+ messages in thread
From: Bjorn Helgaas @ 2021-11-16 20:40 UTC (permalink / raw)
To: Jim Quinlan
Cc: Jim Quinlan,
open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS,
Bjorn Helgaas, Nicolas Saenz Julienne, Rob Herring, Mark Brown,
maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE, Florian Fainelli,
Lorenzo Pieralisi, Krzysztof Wilczyński,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
open list
On Mon, Nov 15, 2021 at 03:56:14PM -0500, Jim Quinlan wrote:
> On Thu, Nov 11, 2021 at 4:57 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
> > On Wed, Nov 10, 2021 at 05:14:41PM -0500, Jim Quinlan wrote:
> > > We do not use the result of this function so make it void.
> >
> > I don't get it. Can you expand on this?
> >
> > brcm_phy_cntl() can return -EIO, which means brcm_phy_stop() can
> > return -EIO, which means brcm_pcie_suspend can return -EIO.
> > brcm_pcie_suspend() is the dev_pm_ops.suspend() method.
> >
> > So are you saying we never use the result of dev_pm_ops.suspend()?
>
> In this situation we are going into suspend. In doing so, any
> problems with the brcm phy may be erased/forgiven upon resume, since
> clocks are turned off and most power removed/reduced. An error from
> brcm_phy_stop() that becomes the return value of brcm_pcie_suspend()
> will bring a halt to the entire suspend IIRC. In fact, I forced a
> -EIO in this code and it panic'd on suspend. This is not really the
> behavior I want for what is most likely a recoverable error.
>
> Perhaps a dev_err(...) will suffice while still returning 0?
Maybe we just need a note about why we want to intentionally ignore
any errors here.
> I noticed that reset_control_rearm() also returns a value, and if that
> is in error it will not be erease/forgiven by suspend sleep. I will
> fix this.
>
> Regards,
> Jim Quinlan
> Broadcom STB
>
>
> >
> > > Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
> > > ---
> > > drivers/pci/controller/pcie-brcmstb.c | 10 +++++-----
> > > 1 file changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
> > > index cc30215f5a43..ff7d0d291531 100644
> > > --- a/drivers/pci/controller/pcie-brcmstb.c
> > > +++ b/drivers/pci/controller/pcie-brcmstb.c
> > > @@ -1111,9 +1111,10 @@ static inline int brcm_phy_start(struct brcm_pcie *pcie)
> > > return pcie->rescal ? brcm_phy_cntl(pcie, 1) : 0;
> > > }
> > >
> > > -static inline int brcm_phy_stop(struct brcm_pcie *pcie)
> > > +static inline void brcm_phy_stop(struct brcm_pcie *pcie)
> > > {
> > > - return pcie->rescal ? brcm_phy_cntl(pcie, 0) : 0;
> > > + if (pcie->rescal)
> > > + brcm_phy_cntl(pcie, 0);
> > > }
> > >
> > > static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
> > > @@ -1143,14 +1144,13 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
> > > static int brcm_pcie_suspend(struct device *dev)
> > > {
> > > struct brcm_pcie *pcie = dev_get_drvdata(dev);
> > > - int ret;
> > >
> > > brcm_pcie_turn_off(pcie);
> > > - ret = brcm_phy_stop(pcie);
> > > + brcm_phy_stop(pcie);
> > > reset_control_rearm(pcie->rescal);
> > > clk_disable_unprepare(pcie->clk);
> > >
> > > - return ret;
> > > + return 0;
> > > }
> > >
> > > static int brcm_pcie_resume(struct device *dev)
> > > --
> > > 2.17.1
> > >
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2021-11-16 20:41 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-10 22:14 [PATCH v8 0/8] PCI: brcmstb: have portdrv turn on sub-device power Jim Quinlan
2021-11-10 22:14 ` [PATCH v8 1/8] PCI: brcmstb: Change brcm_phy_stop() to return void Jim Quinlan
2021-11-11 21:57 ` Bjorn Helgaas
2021-11-15 20:56 ` Jim Quinlan
2021-11-16 20:40 ` Bjorn Helgaas
2021-11-10 22:14 ` [PATCH v8 2/8] dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map Jim Quinlan
2021-11-10 22:14 ` [PATCH v8 3/8] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators Jim Quinlan
2021-11-11 22:17 ` Bjorn Helgaas
2021-11-12 18:25 ` Jim Quinlan
2021-11-12 20:20 ` Bjorn Helgaas
2021-11-12 21:46 ` Rob Herring
2021-11-13 11:38 ` Pali Rohár
2021-11-10 22:14 ` [PATCH v8 7/8] PCI: brcmstb: Split brcm_pcie_setup() into two funcs Jim Quinlan
2021-11-10 22:14 ` [PATCH v8 8/8] PCI: brcmstb: Add control of subdevice voltage regulators Jim Quinlan
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).