PCI: xilinx-nwl: Add phy support
Subsystems (6)
v3 cover PCI: xilinx-nwl: Add phy support
Add phy subsystem support for the xilinx-nwl PCIe controller. This series also includes several small fixes and improvements.
Changes in v3:
- Document phys property
- Expand off-by-one commit message
Changes in v2:
- Remove phy-names
- Add an example
- Get phys by index and not by name
Sean Anderson (7):
dt-bindings: pci: xilinx-nwl: Add phys
PCI: xilinx-nwl: Fix off-by-one in IRQ handler
PCI: xilinx-nwl: Fix register misspelling
PCI: xilinx-nwl: Rate-limit misc interrupt messages
PCI: xilinx-nwl: Clean up clock on probe failure/removal
PCI: xilinx-nwl: Add phy support
arm64: zynqmp: Add PCIe phys
.../bindings/pci/xlnx,nwl-pcie.yaml | 7 + .../boot/dts/xilinx/zynqmp-zcu102-revA.dts | 1 + drivers/pci/controller/pcie-xilinx-nwl.c | 122 ++++++++++++++---- 3 files changed, 107 insertions(+), 23 deletions(-)
Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v3 1/7 dt-bindings: pci: xilinx-nwl: Add phys
Add phys properties so Linux can power-on/configure the GTR transcievers.
---
Changes in v3:
- Document phys property
Changes in v2:
- Remove phy-names
- Add an example
Documentation/devicetree/bindings/pci/xlnx,nwl-pcie.yaml | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/pci/xlnx,nwl-pcie.yaml +7 -0
@@ -61,6 +61,11 @@ properties: interrupt-map: maxItems: 4 + phys: + minItems: 1 + maxItems: 4 + description: One phy per logical lane, in order + power-domains: maxItems: 1
@@ -110,6 +115,7 @@ examples: - | #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/phy/phy.h> #include <dt-bindings/power/xlnx-zynqmp-power.h> soc { #address-cells = <2>;
@@ -138,6 +144,7 @@ examples: <0x0 0x0 0x0 0x3 &pcie_intc 0x3>, <0x0 0x0 0x0 0x4 &pcie_intc 0x4>; msi-parent = <&nwl_pcie>; + phys = <&psgtr 0 PHY_TYPE_PCIE 0 0>; power-domains = <&zynqmp_firmware PD_PCIE>; iommus = <&smmu 0x4d0>; pcie_intc: legacy-interrupt-controller {
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Re: [PATCH v3 1/7] dt-bindings: pci: xilinx-nwl: Add phys
Quoted 9 lines · Sean Anderson
Add phys properties so Linux can power-on/configure the GTR transcievers.
Signed-off-by Sean Anderson <[email protected]>---
Changes in v3:
- Document phys property
Quoted 7 lines
Changes in v2:
- Remove phy-names
- Add an exampleDocumentation/devicetree/bindings/pci/xlnx,nwl-pcie.yaml | 7 +++++++ 1 file changed, 7 insertions(+)
Re: [PATCH v3 1/7] dt-bindings: pci: xilinx-nwl: Add phys
In reply to Sean AndersonQuoted 2 lines · Sean Anderson
Add phys properties so Linux can power-on/configure the GTR transcievers.
s/transcievers/transceivers/
Possibly s/phys/PHYs/ in subject, commit log, DT description to avoid confusion with "phys" (short for generic "physical"). Or maybe even just "PHY properties"?
What does "GTR" mean? Possibly expand that?
Quoted 48 lines
Signed-off-by Sean Anderson <[email protected]>---
Changes in v3:
- Document phys propertyChanges in v2:
- Remove phy-names
- Add an exampleDocumentation/devicetree/bindings/pci/xlnx,nwl-pcie.yaml | 7 +++++++ 1 file changed, 7 insertions(+)Documentation/devicetree/bindings/pci/xlnx,nwl-pcie.yaml +7
-0@@ -61,6 +61,11 @@ properties: interrupt-map: maxItems: 4 + phys: + minItems: 1 + maxItems: 4 + description: One phy per logical lane, in order + power-domains: maxItems: 1@@ -110,6 +115,7 @@ examples: - | #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/phy/phy.h> #include <dt-bindings/power/xlnx-zynqmp-power.h> soc { #address-cells = <2>;@@ -138,6 +144,7 @@ examples: <0x0 0x0 0x0 0x3 &pcie_intc 0x3>, <0x0 0x0 0x0 0x4 &pcie_intc 0x4>; msi-parent = <&nwl_pcie>; + phys = <&psgtr 0 PHY_TYPE_PCIE 0 0>; power-domains = <&zynqmp_firmware PD_PCIE>; iommus = <&smmu 0x4d0>; pcie_intc: legacy-interrupt-controller {Signature · 1 line
2.35.1.1320.gc452695387.dirty
Re: [PATCH v3 1/7] dt-bindings: pci: xilinx-nwl: Add phys
Quoted 5 lines · Bjorn Helgaas
Quoted 2 lines · Sean Anderson
Add phys properties so Linux can power-on/configure the GTR transcievers.
s/transcievers/transceivers/
I always forget the spelling is backwards on this one
Quoted 3 lines
Possibly s/phys/PHYs/ in subject, commit log, DT description to avoid confusion with "phys" (short for generic "physical"). Or maybe even just "PHY properties"?
Well, this is the name for the property...
Quoted 1 line
What does "GTR" mean? Possibly expand that?
It's "xlnx,zynqmp-psgtr-v1.1". These are the available transceivers on the ZynqMP, which is the only SoC this device is present on. I had hoped this would be clear by calling them "GTR transcievers"...
--Sean
Quoted 48 lines
Quoted 48 lines
Signed-off-by Sean Anderson <[email protected]>---
Changes in v3:
- Document phys propertyChanges in v2:
- Remove phy-names
- Add an exampleDocumentation/devicetree/bindings/pci/xlnx,nwl-pcie.yaml | 7 +++++++ 1 file changed, 7 insertions(+)Documentation/devicetree/bindings/pci/xlnx,nwl-pcie.yaml +7
-0@@ -61,6 +61,11 @@ properties: interrupt-map: maxItems: 4 + phys: + minItems: 1 + maxItems: 4 + description: One phy per logical lane, in order + power-domains: maxItems: 1@@ -110,6 +115,7 @@ examples: - | #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/phy/phy.h> #include <dt-bindings/power/xlnx-zynqmp-power.h> soc { #address-cells = <2>;@@ -138,6 +144,7 @@ examples: <0x0 0x0 0x0 0x3 &pcie_intc 0x3>, <0x0 0x0 0x0 0x4 &pcie_intc 0x4>; msi-parent = <&nwl_pcie>; + phys = <&psgtr 0 PHY_TYPE_PCIE 0 0>; power-domains = <&zynqmp_firmware PD_PCIE>; iommus = <&smmu 0x4d0>; pcie_intc: legacy-interrupt-controller {Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v3 2/7 PCI: xilinx-nwl: Fix off-by-one in IRQ handler
In reply to Sean AndersonMSGF_LEG_MASK is laid out with INTA in bit 0, INTB in bit 1, INTC in bit 2, and INTD in bit 3. Hardware IRQ numbers start at 0, and we register PCI_NUM_INTX irqs. So to enable INTA (aka hwirq 0) we should set bit 0. Remove the subtraction of one. This fixes the following UBSAN error:
[ 5.037483] ================================================================================ [ 5.046260] UBSAN: shift-out-of-bounds in ../drivers/pci/controller/pcie-xilinx-nwl.c:389:11 [ 5.054983] shift exponent 18446744073709551615 is too large for 32-bit type 'int' [ 5.062813] CPU: 1 PID: 61 Comm: kworker/u10:1 Not tainted 6.6.20+ #268 [ 5.070008] Hardware name: xlnx,zynqmp (DT) [ 5.074348] Workqueue: events_unbound deferred_probe_work_func [ 5.080410] Call trace: [ 5.082958] dump_backtrace (arch/arm64/kernel/stacktrace.c:235) [ 5.086850] show_stack (arch/arm64/kernel/stacktrace.c:242) [ 5.090292] dump_stack_lvl (lib/dump_stack.c:107) [ 5.094095] dump_stack (lib/dump_stack.c:114) [ 5.097540] __ubsan_handle_shift_out_of_bounds (lib/ubsan.c:218 lib/ubsan.c:387) [ 5.103227] nwl_unmask_leg_irq (drivers/pci/controller/pcie-xilinx-nwl.c:389 (discriminator 1)) [ 5.107386] irq_enable (kernel/irq/internals.h:234 kernel/irq/chip.c:170 kernel/irq/chip.c:439 kernel/irq/chip.c:432 kernel/irq/chip.c:345) [ 5.110838] __irq_startup (kernel/irq/internals.h:239 kernel/irq/chip.c:180 kernel/irq/chip.c:250) [ 5.114552] irq_startup (kernel/irq/chip.c:270) [ 5.118266] __setup_irq (kernel/irq/manage.c:1800) [ 5.121982] request_threaded_irq (kernel/irq/manage.c:2206) [ 5.126412] pcie_pme_probe (include/linux/interrupt.h:168 drivers/pci/pcie/pme.c:348) [ 5.130303] pcie_port_probe_service (drivers/pci/pcie/portdrv.c:528) [ 5.134915] really_probe (drivers/base/dd.c:579 drivers/base/dd.c:658) [ 5.138720] __driver_probe_device (drivers/base/dd.c:800) [ 5.143236] driver_probe_device (drivers/base/dd.c:830) [ 5.147571] __device_attach_driver (drivers/base/dd.c:959) [ 5.152179] bus_for_each_drv (drivers/base/bus.c:457) [ 5.156163] __device_attach (drivers/base/dd.c:1032) [ 5.160147] device_initial_probe (drivers/base/dd.c:1080) [ 5.164488] bus_probe_device (drivers/base/bus.c:532) [ 5.168471] device_add (drivers/base/core.c:3638) [ 5.172098] device_register (drivers/base/core.c:3714) [ 5.175994] pcie_portdrv_probe (drivers/pci/pcie/portdrv.c:309 drivers/pci/pcie/portdrv.c:363 drivers/pci/pcie/portdrv.c:695) [ 5.180338] pci_device_probe (drivers/pci/pci-driver.c:324 drivers/pci/pci-driver.c:392 drivers/pci/pci-driver.c:417 drivers/pci/pci-driver.c:460) [ 5.184410] really_probe (drivers/base/dd.c:579 drivers/base/dd.c:658) [ 5.188213] __driver_probe_device (drivers/base/dd.c:800) [ 5.192729] driver_probe_device (drivers/base/dd.c:830) [ 5.197064] __device_attach_driver (drivers/base/dd.c:959) [ 5.201672] bus_for_each_drv (drivers/base/bus.c:457) [ 5.205657] __device_attach (drivers/base/dd.c:1032) [ 5.209641] device_attach (drivers/base/dd.c:1074) [ 5.213357] pci_bus_add_device (drivers/pci/bus.c:352) [ 5.217518] pci_bus_add_devices (drivers/pci/bus.c:371 (discriminator 2)) [ 5.221774] pci_host_probe (drivers/pci/probe.c:3099) [ 5.225581] nwl_pcie_probe (drivers/pci/controller/pcie-xilinx-nwl.c:938) [ 5.229562] platform_probe (drivers/base/platform.c:1404) [ 5.233367] really_probe (drivers/base/dd.c:579 drivers/base/dd.c:658) [ 5.237169] __driver_probe_device (drivers/base/dd.c:800) [ 5.241685] driver_probe_device (drivers/base/dd.c:830) [ 5.246020] __device_attach_driver (drivers/base/dd.c:959) [ 5.250628] bus_for_each_drv (drivers/base/bus.c:457) [ 5.254612] __device_attach (drivers/base/dd.c:1032) [ 5.258596] device_initial_probe (drivers/base/dd.c:1080) [ 5.262938] bus_probe_device (drivers/base/bus.c:532) [ 5.266920] deferred_probe_work_func (drivers/base/dd.c:124) [ 5.271619] process_one_work (arch/arm64/include/asm/jump_label.h:21 include/linux/jump_label.h:207 include/trace/events/workqueue.h:108 kernel/workqueue.c:2632) [ 5.275788] worker_thread (kernel/workqueue.c:2694 (discriminator 2) kernel/workqueue.c:2781 (discriminator 2)) [ 5.279686] kthread (kernel/kthread.c:388) [ 5.283048] ret_from_fork (arch/arm64/kernel/entry.S:862) [ 5.286765] ================================================================================
---
Changes in v3:
- Expand commit message
drivers/pci/controller/pcie-xilinx-nwl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +2 -2
@@ -371,7 +371,7 @@ static void nwl_mask_intx_irq(struct irq_data *data)u32 mask;u32 val; - mask =1 << (data->hwirq -1 ); + mask =1 << data->hwirq;raw_spin_lock_irqsave (&pcie->leg_mask_lock, flags); val =nwl_bridge_readl (pcie,MSGF_LEG_MASK );nwl_bridge_writel (pcie, (val & (~mask)),MSGF_LEG_MASK );
@@ -385,7 +385,7 @@ static void nwl_unmask_intx_irq(struct irq_data *data)u32 mask;u32 val; - mask =1 << (data->hwirq -1 ); + mask =1 << data->hwirq;raw_spin_lock_irqsave (&pcie->leg_mask_lock, flags); val =nwl_bridge_readl (pcie,MSGF_LEG_MASK );nwl_bridge_writel (pcie, (val | mask),MSGF_LEG_MASK );
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Re: [PATCH v3 2/7] PCI: xilinx-nwl: Fix off-by-one in IRQ handler
Quoted 4 lines · Sean Anderson
MSGF_LEG_MASKis laid out with INTA in bit 0, INTB in bit 1, INTC in bit 2, and INTD in bit 3. Hardware IRQ numbers start at 0, and we registerPCI_NUM_INTXirqs. So to enable INTA (aka hwirq 0) we should set bit 0. Remove the subtraction of one. This fixes the following UBSAN error:
Thanks for these details!
I guess UBSAN == "undefined behavior sanitizer", right? That sounds like an easy way to find this but not the way users are likely to find it.
I assume users would notice spurious and missing interrupts, e.g., a driver that tried to enable INTB would have actually enabled INTA, so we'd see spurious INTA interrupts and the driver would never see the INTB it expected.
And a driver that tried to enable INTA would never see that interrupt, and we might not set any bit in MSGF_LEG_MASK?
I think the normal way people would trip over this, i.e., spurious and missing INTx interrupts, is the important thing to mention here.
Quoted 11 lines
[ 5.037483] ================================================================================ [ 5.046260] UBSAN: shift-out-of-bounds in ../drivers/pci/controller/pcie-xilinx-nwl.c:389:11 [ 5.054983] shift exponent 18446744073709551615 is too large for 32-bit type 'int' [ 5.062813] CPU: 1 PID: 61 Comm: kworker/u10:1 Not tainted 6.6.20+ #268 [ 5.070008] Hardware name: xlnx,zynqmp (DT) [ 5.074348] Workqueue: events_unbound deferred_probe_work_func [ 5.080410] Call trace: [ 5.082958] dump_backtrace (arch/arm64/kernel/stacktrace.c:235) [ 5.086850] show_stack (arch/arm64/kernel/stacktrace.c:242) [ 5.090292] dump_stack_lvl (lib/dump_stack.c:107) [ 5.094095] dump_stack (lib/dump_stack.c:114)
Quoted 8 lines
[ 5.097540] __ubsan_handle_shift_out_of_bounds (lib/ubsan.c:218 lib/ubsan.c:387) [ 5.103227] nwl_unmask_leg_irq (drivers/pci/controller/pcie-xilinx-nwl.c:389 (discriminator 1)) [ 5.107386] irq_enable (kernel/irq/internals.h:234 kernel/irq/chip.c:170 kernel/irq/chip.c:439 kernel/irq/chip.c:432 kernel/irq/chip.c:345) [ 5.110838] __irq_startup (kernel/irq/internals.h:239 kernel/irq/chip.c:180 kernel/irq/chip.c:250) [ 5.114552] irq_startup (kernel/irq/chip.c:270) [ 5.118266] __setup_irq (kernel/irq/manage.c:1800) [ 5.121982] request_threaded_irq (kernel/irq/manage.c:2206) [ 5.126412] pcie_pme_probe (include/linux/interrupt.h:168 drivers/pci/pcie/pme.c:348)
The rest of the stacktrace below is not relevant and could be omitted. The timestamps don't add useful information either.
Quoted 76 lines
[ 5.130303] pcie_port_probe_service (drivers/pci/pcie/portdrv.c:528) [ 5.134915] really_probe (drivers/base/dd.c:579 drivers/base/dd.c:658) [ 5.138720] __driver_probe_device (drivers/base/dd.c:800) [ 5.143236] driver_probe_device (drivers/base/dd.c:830) [ 5.147571] __device_attach_driver (drivers/base/dd.c:959) [ 5.152179] bus_for_each_drv (drivers/base/bus.c:457) [ 5.156163] __device_attach (drivers/base/dd.c:1032) [ 5.160147] device_initial_probe (drivers/base/dd.c:1080) [ 5.164488] bus_probe_device (drivers/base/bus.c:532) [ 5.168471] device_add (drivers/base/core.c:3638) [ 5.172098] device_register (drivers/base/core.c:3714) [ 5.175994] pcie_portdrv_probe (drivers/pci/pcie/portdrv.c:309 drivers/pci/pcie/portdrv.c:363 drivers/pci/pcie/portdrv.c:695) [ 5.180338] pci_device_probe (drivers/pci/pci-driver.c:324 drivers/pci/pci-driver.c:392 drivers/pci/pci-driver.c:417 drivers/pci/pci-driver.c:460) [ 5.184410] really_probe (drivers/base/dd.c:579 drivers/base/dd.c:658) [ 5.188213] __driver_probe_device (drivers/base/dd.c:800) [ 5.192729] driver_probe_device (drivers/base/dd.c:830) [ 5.197064] __device_attach_driver (drivers/base/dd.c:959) [ 5.201672] bus_for_each_drv (drivers/base/bus.c:457) [ 5.205657] __device_attach (drivers/base/dd.c:1032) [ 5.209641] device_attach (drivers/base/dd.c:1074) [ 5.213357] pci_bus_add_device (drivers/pci/bus.c:352) [ 5.217518] pci_bus_add_devices (drivers/pci/bus.c:371 (discriminator 2)) [ 5.221774] pci_host_probe (drivers/pci/probe.c:3099) [ 5.225581] nwl_pcie_probe (drivers/pci/controller/pcie-xilinx-nwl.c:938) [ 5.229562] platform_probe (drivers/base/platform.c:1404) [ 5.233367] really_probe (drivers/base/dd.c:579 drivers/base/dd.c:658) [ 5.237169] __driver_probe_device (drivers/base/dd.c:800) [ 5.241685] driver_probe_device (drivers/base/dd.c:830) [ 5.246020] __device_attach_driver (drivers/base/dd.c:959) [ 5.250628] bus_for_each_drv (drivers/base/bus.c:457) [ 5.254612] __device_attach (drivers/base/dd.c:1032) [ 5.258596] device_initial_probe (drivers/base/dd.c:1080) [ 5.262938] bus_probe_device (drivers/base/bus.c:532) [ 5.266920] deferred_probe_work_func (drivers/base/dd.c:124) [ 5.271619] process_one_work (arch/arm64/include/asm/jump_label.h:21 include/linux/jump_label.h:207 include/trace/events/workqueue.h:108 kernel/workqueue.c:2632) [ 5.275788] worker_thread (kernel/workqueue.c:2694 (discriminator 2) kernel/workqueue.c:2781 (discriminator 2)) [ 5.279686] kthread (kernel/kthread.c:388) [ 5.283048] ret_from_fork (arch/arm64/kernel/entry.S:862) [ 5.286765] ================================================================================Fixes 9a181e1093af ("PCI: xilinx-nwl: Modify IRQ chip for legacy interrupts")Cc <[email protected]>Signed-off-by Sean Anderson <[email protected]>---
Changes in v3:
- Expand commit messagedrivers/pci/controller/pcie-xilinx-nwl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pci/controller/pcie-xilinx-nwl.c +2
-2@@ -371,7 +371,7 @@ static void nwl_mask_intx_irq(struct irq_data *data)u32 mask;u32 val; - mask =1 << (data->hwirq -1 ); + mask =1 << data->hwirq;raw_spin_lock_irqsave (&pcie->leg_mask_lock, flags); val =nwl_bridge_readl (pcie,MSGF_LEG_MASK );nwl_bridge_writel (pcie, (val & (~mask)),MSGF_LEG_MASK );@@ -385,7 +385,7 @@ static void nwl_unmask_intx_irq(struct irq_data *data)u32 mask;u32 val; - mask =1 << (data->hwirq -1 ); + mask =1 << data->hwirq;raw_spin_lock_irqsave (&pcie->leg_mask_lock, flags); val =nwl_bridge_readl (pcie,MSGF_LEG_MASK );nwl_bridge_writel (pcie, (val | mask),MSGF_LEG_MASK );Signature · 1 line
2.35.1.1320.gc452695387.dirty
Re: [PATCH v3 2/7] PCI: xilinx-nwl: Fix off-by-one in IRQ handler
Quoted 11 lines · Bjorn Helgaas
Quoted 4 lines · Sean Anderson
MSGF_LEG_MASKis laid out with INTA in bit 0, INTB in bit 1, INTC in bit 2, and INTD in bit 3. Hardware IRQ numbers start at 0, and we registerPCI_NUM_INTXirqs. So to enable INTA (aka hwirq 0) we should set bit 0. Remove the subtraction of one. This fixes the following UBSAN error:Thanks for these details!
I guess UBSAN == "undefined behavior sanitizer", right? That sounds like an easy way to find this but not the way users are likely to find it.
It's pretty likely they will find it this way, since I found it this way and no one else had ;)
Quoted 7 lines
I assume users would notice spurious and missing interrupts, e.g., a driver that tried to enable INTB would have actually enabled INTA, so we'd see spurious INTA interrupts and the driver would never see the INTB it expected.
And a driver that tried to enable INTA would never see that interrupt, and we might not set any bit in
MSGF_LEG_MASK?
And yes, this would manifest as INTx interrupts being broken.
Quoted 23 lines
I think the normal way people would trip over this, i.e., spurious and missing INTx interrupts, is the important thing to mention here.
Quoted 11 lines
[ 5.037483] ================================================================================ [ 5.046260] UBSAN: shift-out-of-bounds in ../drivers/pci/controller/pcie-xilinx-nwl.c:389:11 [ 5.054983] shift exponent 18446744073709551615 is too large for 32-bit type 'int' [ 5.062813] CPU: 1 PID: 61 Comm: kworker/u10:1 Not tainted 6.6.20+ #268 [ 5.070008] Hardware name: xlnx,zynqmp (DT) [ 5.074348] Workqueue: events_unbound deferred_probe_work_func [ 5.080410] Call trace: [ 5.082958] dump_backtrace (arch/arm64/kernel/stacktrace.c:235) [ 5.086850] show_stack (arch/arm64/kernel/stacktrace.c:242) [ 5.090292] dump_stack_lvl (lib/dump_stack.c:107) [ 5.094095] dump_stack (lib/dump_stack.c:114)Quoted 8 lines
[ 5.097540] __ubsan_handle_shift_out_of_bounds (lib/ubsan.c:218 lib/ubsan.c:387) [ 5.103227] nwl_unmask_leg_irq (drivers/pci/controller/pcie-xilinx-nwl.c:389 (discriminator 1)) [ 5.107386] irq_enable (kernel/irq/internals.h:234 kernel/irq/chip.c:170 kernel/irq/chip.c:439 kernel/irq/chip.c:432 kernel/irq/chip.c:345) [ 5.110838] __irq_startup (kernel/irq/internals.h:239 kernel/irq/chip.c:180 kernel/irq/chip.c:250) [ 5.114552] irq_startup (kernel/irq/chip.c:270) [ 5.118266] __setup_irq (kernel/irq/manage.c:1800) [ 5.121982] request_threaded_irq (kernel/irq/manage.c:2206) [ 5.126412] pcie_pme_probe (include/linux/interrupt.h:168 drivers/pci/pcie/pme.c:348)
Quoted 2 lines
The rest of the stacktrace below is not relevant and could be omitted. The timestamps don't add useful information either.
OK
--Sean
Quoted 76 lines
Quoted 76 lines
[ 5.130303] pcie_port_probe_service (drivers/pci/pcie/portdrv.c:528) [ 5.134915] really_probe (drivers/base/dd.c:579 drivers/base/dd.c:658) [ 5.138720] __driver_probe_device (drivers/base/dd.c:800) [ 5.143236] driver_probe_device (drivers/base/dd.c:830) [ 5.147571] __device_attach_driver (drivers/base/dd.c:959) [ 5.152179] bus_for_each_drv (drivers/base/bus.c:457) [ 5.156163] __device_attach (drivers/base/dd.c:1032) [ 5.160147] device_initial_probe (drivers/base/dd.c:1080) [ 5.164488] bus_probe_device (drivers/base/bus.c:532) [ 5.168471] device_add (drivers/base/core.c:3638) [ 5.172098] device_register (drivers/base/core.c:3714) [ 5.175994] pcie_portdrv_probe (drivers/pci/pcie/portdrv.c:309 drivers/pci/pcie/portdrv.c:363 drivers/pci/pcie/portdrv.c:695) [ 5.180338] pci_device_probe (drivers/pci/pci-driver.c:324 drivers/pci/pci-driver.c:392 drivers/pci/pci-driver.c:417 drivers/pci/pci-driver.c:460) [ 5.184410] really_probe (drivers/base/dd.c:579 drivers/base/dd.c:658) [ 5.188213] __driver_probe_device (drivers/base/dd.c:800) [ 5.192729] driver_probe_device (drivers/base/dd.c:830) [ 5.197064] __device_attach_driver (drivers/base/dd.c:959) [ 5.201672] bus_for_each_drv (drivers/base/bus.c:457) [ 5.205657] __device_attach (drivers/base/dd.c:1032) [ 5.209641] device_attach (drivers/base/dd.c:1074) [ 5.213357] pci_bus_add_device (drivers/pci/bus.c:352) [ 5.217518] pci_bus_add_devices (drivers/pci/bus.c:371 (discriminator 2)) [ 5.221774] pci_host_probe (drivers/pci/probe.c:3099) [ 5.225581] nwl_pcie_probe (drivers/pci/controller/pcie-xilinx-nwl.c:938) [ 5.229562] platform_probe (drivers/base/platform.c:1404) [ 5.233367] really_probe (drivers/base/dd.c:579 drivers/base/dd.c:658) [ 5.237169] __driver_probe_device (drivers/base/dd.c:800) [ 5.241685] driver_probe_device (drivers/base/dd.c:830) [ 5.246020] __device_attach_driver (drivers/base/dd.c:959) [ 5.250628] bus_for_each_drv (drivers/base/bus.c:457) [ 5.254612] __device_attach (drivers/base/dd.c:1032) [ 5.258596] device_initial_probe (drivers/base/dd.c:1080) [ 5.262938] bus_probe_device (drivers/base/bus.c:532) [ 5.266920] deferred_probe_work_func (drivers/base/dd.c:124) [ 5.271619] process_one_work (arch/arm64/include/asm/jump_label.h:21 include/linux/jump_label.h:207 include/trace/events/workqueue.h:108 kernel/workqueue.c:2632) [ 5.275788] worker_thread (kernel/workqueue.c:2694 (discriminator 2) kernel/workqueue.c:2781 (discriminator 2)) [ 5.279686] kthread (kernel/kthread.c:388) [ 5.283048] ret_from_fork (arch/arm64/kernel/entry.S:862) [ 5.286765] ================================================================================Fixes 9a181e1093af ("PCI: xilinx-nwl: Modify IRQ chip for legacy interrupts")Cc <[email protected]>Signed-off-by Sean Anderson <[email protected]>---
Changes in v3:
- Expand commit messagedrivers/pci/controller/pcie-xilinx-nwl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pci/controller/pcie-xilinx-nwl.c +2
-2@@ -371,7 +371,7 @@ static void nwl_mask_intx_irq(struct irq_data *data)u32 mask;u32 val; - mask =1 << (data->hwirq -1 ); + mask =1 << data->hwirq;raw_spin_lock_irqsave (&pcie->leg_mask_lock, flags); val =nwl_bridge_readl (pcie,MSGF_LEG_MASK );nwl_bridge_writel (pcie, (val & (~mask)),MSGF_LEG_MASK );@@ -385,7 +385,7 @@ static void nwl_unmask_intx_irq(struct irq_data *data)u32 mask;u32 val; - mask =1 << (data->hwirq -1 ); + mask =1 << data->hwirq;raw_spin_lock_irqsave (&pcie->leg_mask_lock, flags); val =nwl_bridge_readl (pcie,MSGF_LEG_MASK );nwl_bridge_writel (pcie, (val | mask),MSGF_LEG_MASK );Signature · 1 line
2.35.1.1320.gc452695387.dirty
Re: [PATCH v3 2/7] PCI: xilinx-nwl: Fix off-by-one in IRQ handler
Quoted 21 lines · Sean Anderson
Quoted 11 lines · Bjorn Helgaas
Quoted 4 lines · Sean Anderson
MSGF_LEG_MASKis laid out with INTA in bit 0, INTB in bit 1, INTC in bit 2, and INTD in bit 3. Hardware IRQ numbers start at 0, and we registerPCI_NUM_INTXirqs. So to enable INTA (aka hwirq 0) we should set bit 0. Remove the subtraction of one. This fixes the following UBSAN error:Thanks for these details!
I guess UBSAN == "undefined behavior sanitizer", right? That sounds like an easy way to find this but not the way users are likely to find it.
It's pretty likely they will find it this way, since I found it this way and no one else had ;)
Quoted 5 lines
I assume users would notice spurious and missing interrupts, e.g., a driver that tried to enable INTB would have actually enabled INTA, so we'd see spurious INTA interrupts and the driver would never see the INTB it expected.
Quoted 5 lines
Quoted 2 lines
And a driver that tried to enable INTA would never see that interrupt, and we might not set any bit in
MSGF_LEG_MASK?And yes, this would manifest as INTx interrupts being broken.
It's so weird that it's been broken for seven years and no one reported it. :/
regards,
dan carpenter
Re: [PATCH v3 2/7] PCI: xilinx-nwl: Fix off-by-one in IRQ handler
Quoted 22 lines · Dan Carpenter
Quoted 21 lines · Sean Anderson
Quoted 11 lines · Bjorn Helgaas
Quoted 4 lines · Sean Anderson
MSGF_LEG_MASKis laid out with INTA in bit 0, INTB in bit 1, INTC in bit 2, and INTD in bit 3. Hardware IRQ numbers start at 0, and we registerPCI_NUM_INTXirqs. So to enable INTA (aka hwirq 0) we should set bit 0. Remove the subtraction of one. This fixes the following UBSAN error:Thanks for these details!
I guess UBSAN == "undefined behavior sanitizer", right? That sounds like an easy way to find this but not the way users are likely to find it.
It's pretty likely they will find it this way, since I found it this way and no one else had ;)
Quoted 5 lines
I assume users would notice spurious and missing interrupts, e.g., a driver that tried to enable INTB would have actually enabled INTA, so we'd see spurious INTA interrupts and the driver would never see the INTB it expected.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
And a driver that tried to enable INTA would never see that interrupt, and we might not set any bit in
MSGF_LEG_MASK?And yes, this would manifest as INTx interrupts being broken.
It's so weird that it's been broken for seven years and no one reported it. :/
If I had to guess it's because most PCIe hardware uses MSIs. Unless you plugged in a PCI bridge there's almost no reason to use INTx at all.
--Sean
PATCH v3 3/7 PCI: xilinx-nwl: Fix register misspelling
In reply to Sean AndersonMSIC -> MISC
---
(no changes since v1)
drivers/pci/controller/pcie-xilinx-nwl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +6 -6
@@ -80,8 +80,8 @@#define MSGF_MISC_SR_NON_FATAL_DEV BIT(22)#define MSGF_MISC_SR_FATAL_DEV BIT(23)#define MSGF_MISC_SR_LINK_DOWN BIT(24) -#define MSGF_MSIC_SR_LINK_AUTO_BWIDTH BIT(25) -#define MSGF_MSIC_SR_LINK_BWIDTH BIT(26) +#define MSGF_MISC_SR_LINK_AUTO_BWIDTH BIT(25) +#define MSGF_MISC_SR_LINK_BWIDTH BIT(26)#define MSGF_MISC_SR_MASKALL (MSGF_MISC_SR_RXMSG_AVAIL | \ MSGF_MISC_SR_RXMSG_OVER | \
@@ -96,8 +96,8 @@ MSGF_MISC_SR_NON_FATAL_DEV | \ MSGF_MISC_SR_FATAL_DEV | \ MSGF_MISC_SR_LINK_DOWN | \ - MSGF_MSIC_SR_LINK_AUTO_BWIDTH | \ - MSGF_MSIC_SR_LINK_BWIDTH) + MSGF_MISC_SR_LINK_AUTO_BWIDTH | \ + MSGF_MISC_SR_LINK_BWIDTH)/* Legacy interrupt status mask bits */ #define MSGF_LEG_SR_INTA BIT(0)
@@ -299,10 +299,10 @@ static irqreturn_t nwl_pcie_misc_handler(int irq, void *data)if (misc_stat &MSGF_MISC_SR_FATAL_DEV )dev_err (dev,"Fatal Error Detected\n" ); -if (misc_stat &MSGF_MSIC_SR_LINK_AUTO_BWIDTH ) +if (misc_stat &MSGF_MISC_SR_LINK_AUTO_BWIDTH )dev_info (dev,"Link Autonomous Bandwidth Management Status bit set\n" ); -if (misc_stat &MSGF_MSIC_SR_LINK_BWIDTH ) +if (misc_stat &MSGF_MISC_SR_LINK_BWIDTH )dev_info (dev,"Link Bandwidth Management Status bit set\n" );/* Clear misc interrupt status */
Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v3 4/7 PCI: xilinx-nwl: Rate-limit misc interrupt messages
In reply to Sean AndersonThe conditions logged by the misc interrupt can occur repeatedly and continuously. Avoid rendering the console unusable by rate-limiting these messages.
---
(no changes since v1)
drivers/pci/controller/pcie-xilinx-nwl.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +11 -11
@@ -267,37 +267,37 @@ static irqreturn_t nwl_pcie_misc_handler(int irq, void *data)return IRQ_NONE ;if (misc_stat &MSGF_MISC_SR_RXMSG_OVER ) -dev_err (dev,"Received Message FIFO Overflow\n" ); +dev_err_ratelimited (dev,"Received Message FIFO Overflow\n" );if (misc_stat &MSGF_MISC_SR_SLAVE_ERR ) -dev_err (dev,"Slave error\n" ); +dev_err_ratelimited (dev,"Slave error\n" );if (misc_stat &MSGF_MISC_SR_MASTER_ERR ) -dev_err (dev,"Master error\n" ); +dev_err_ratelimited (dev,"Master error\n" );if (misc_stat &MSGF_MISC_SR_I_ADDR_ERR ) -dev_err (dev,"In Misc Ingress address translation error\n" ); +dev_err_ratelimited (dev,"In Misc Ingress address translation error\n" );if (misc_stat &MSGF_MISC_SR_E_ADDR_ERR ) -dev_err (dev,"In Misc Egress address translation error\n" ); +dev_err_ratelimited (dev,"In Misc Egress address translation error\n" );if (misc_stat &MSGF_MISC_SR_FATAL_AER ) -dev_err (dev,"Fatal Error in AER Capability\n" ); +dev_err_ratelimited (dev,"Fatal Error in AER Capability\n" );if (misc_stat &MSGF_MISC_SR_NON_FATAL_AER ) -dev_err (dev,"Non-Fatal Error in AER Capability\n" ); +dev_err_ratelimited (dev,"Non-Fatal Error in AER Capability\n" );if (misc_stat &MSGF_MISC_SR_CORR_AER ) -dev_err (dev,"Correctable Error in AER Capability\n" ); +dev_err_ratelimited (dev,"Correctable Error in AER Capability\n" );if (misc_stat &MSGF_MISC_SR_UR_DETECT ) -dev_err (dev,"Unsupported request Detected\n" ); +dev_err_ratelimited (dev,"Unsupported request Detected\n" );if (misc_stat &MSGF_MISC_SR_NON_FATAL_DEV ) -dev_err (dev,"Non-Fatal Error Detected\n" ); +dev_err_ratelimited (dev,"Non-Fatal Error Detected\n" );if (misc_stat &MSGF_MISC_SR_FATAL_DEV ) -dev_err (dev,"Fatal Error Detected\n" ); +dev_err_ratelimited (dev,"Fatal Error Detected\n" );if (misc_stat &MSGF_MISC_SR_LINK_AUTO_BWIDTH )dev_info (dev,"Link Autonomous Bandwidth Management Status bit set\n" );
Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v3 5/7 PCI: xilinx-nwl: Clean up clock on probe failure/removal
In reply to Sean AndersonMake sure we turn off the clock on probe failure and device removal.
---
(no changes since v1)
drivers/pci/controller/pcie-xilinx-nwl.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +18 -4
@@ -779,6 +779,7 @@ static int nwl_pcie_probe(struct platform_device *pdev)return -ENODEV ; pcie =pci_host_bridge_priv (bridge); +platform_set_drvdata (pdev, pcie); pcie->dev = dev;
@@ -801,13 +802,13 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_bridge_init (pcie);if (err) {dev_err (dev,"HW Initialization failed\n" ); -return err; + goto err_clk; } err =nwl_pcie_init_irq_domain (pcie);if (err) {dev_err (dev,"Failed creating IRQ Domain\n" ); -return err; + goto err_clk; } bridge->sysdata = pcie;
@@ -817,11 +818,23 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_enable_msi (pcie);if (err <0 ) {dev_err (dev,"failed to enable MSI support: %d\n" , err); -return err; + goto err_clk; } } -return pci_host_probe (bridge); + err =pci_host_probe (bridge); + +err_clk: +if (err) +clk_disable_unprepare (pcie->clk); +return err; +} + +static void nwl_pcie_remove (struct platform_device *pdev) +{ +struct nwl_pcie *pcie =platform_get_drvdata (pdev); + +clk_disable_unprepare (pcie->clk); }static struct platform_driver nwl_pcie_driver = {
@@ -831,5 +844,6 @@ static struct platform_driver nwl_pcie_driver = { .of_match_table = nwl_pcie_of_match, }, .probe = nwl_pcie_probe, + .remove_new = nwl_pcie_remove, };builtin_platform_driver (nwl_pcie_driver);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Re: [PATCH v3 5/7] PCI: xilinx-nwl: Clean up clock on probe failure/removal
Quoted 1 line
Make sure we turn off the clock on probe failure and device removal.
…
Quoted 1 line
+++
b/drivers/pci/controller/pcie-xilinx-nwl.c
…
Quoted 5 lines
drivers/pci/controller/pcie-xilinx-nwl.c +0
-1@@ -817,11 +818,23 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_enable_msi (pcie);if (err <0 ) {dev_err (dev,"failed to enable MSI support: %d\n" , err); -return err;
drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_probe(struct platform_device *pdev) · line 829
Quoted 10 lines
drivers/pci/controller/pcie-xilinx-nwl.c +6
-1+ goto err_clk; } } -return pci_host_probe (bridge); + err =pci_host_probe (bridge); + +err_clk: +if (err) +clk_disable_unprepare (pcie->clk);
I suggest to use the label “disable_unprepare_clock” directly before this function call (in the if branch) so that a duplicate check would be avoided after some error cases.
Regards,
Markus
Re: [PATCH v3 5/7] PCI: xilinx-nwl: Clean up clock on probe failure/removal
Quoted 13 lines · Markus Elfring
Quoted 1 line
Make sure we turn off the clock on probe failure and device removal.
…
Quoted 1 line
+++
b/drivers/pci/controller/pcie-xilinx-nwl.c…
Quoted 9 lines
drivers/pci/controller/pcie-xilinx-nwl.c +1
-1@@ -817,11 +818,23 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_enable_msi (pcie);if (err <0 ) {dev_err (dev,"failed to enable MSI support: %d\n" , err); -return err; + goto err_clk; } }
Quoted 9 lines
drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_probe(struct platform_device *pdev) · line 829
Quoted 6 lines
drivers/pci/controller/pcie-xilinx-nwl.c +5
-1-return pci_host_probe (bridge); + err =pci_host_probe (bridge); + +err_clk: +if (err) +clk_disable_unprepare (pcie->clk);I suggest to use the label “disable_unprepare_clock” directly before this function call (in the if branch) so that a duplicate check would be avoided after some error cases.
Well if you want to avoid a check, we can just do
err = pci_host_probe(bridge);
if (!err)
return 0;
err_clk:
...
--Sean
Re: [PATCH v3 5/7] PCI: xilinx-nwl: Clean up clock on probe failure/removal
Quoted 22 lines
Quoted 12 lines
…
Quoted 1 line
+++
b/drivers/pci/controller/pcie-xilinx-nwl.c…
Quoted 9 lines
drivers/pci/controller/pcie-xilinx-nwl.c +1
-1@@ -817,11 +818,23 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_enable_msi (pcie);if (err <0 ) {dev_err (dev,"failed to enable MSI support: %d\n" , err); -return err; + goto err_clk; } }Quoted 9 lines
drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_probe(struct platform_device *pdev) · line 829
Quoted 6 lines
drivers/pci/controller/pcie-xilinx-nwl.c +5
-1-return pci_host_probe (bridge); + err =pci_host_probe (bridge); + +err_clk: +if (err) +clk_disable_unprepare (pcie->clk);I suggest to use the label “disable_unprepare_clock” directly before this function call (in the if branch) so that a duplicate check would be avoided after some error cases.
Quoted 8 lines
Well if you want to avoid a check, we can just do
err =
pci_host_probe(bridge);
if (!err)return 0;
err_clk:...
This design variant can also be reasonable.
Do any preferences matter here for label name selections?
Regards,
Markus
Re: [PATCH v3 5/7] PCI: xilinx-nwl: Clean up clock on probe failure/removal
Quoted 28 lines · Markus Elfring
Quoted 28 lines
Quoted 12 lines
…
Quoted 1 line
+++
b/drivers/pci/controller/pcie-xilinx-nwl.c…
Quoted 9 lines
drivers/pci/controller/pcie-xilinx-nwl.c +1
-1@@ -817,11 +818,23 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_enable_msi (pcie);if (err <0 ) {dev_err (dev,"failed to enable MSI support: %d\n" , err); -return err; + goto err_clk; } }Quoted 9 lines
drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_probe(struct platform_device *pdev) · line 829
Quoted 6 lines
drivers/pci/controller/pcie-xilinx-nwl.c +5
-1-return pci_host_probe (bridge); + err =pci_host_probe (bridge); + +err_clk: +if (err) +clk_disable_unprepare (pcie->clk);I suggest to use the label “disable_unprepare_clock” directly before this function call (in the if branch) so that a duplicate check would be avoided after some error cases.
Well if you want to avoid a check, we can just do
err =
pci_host_probe(bridge);
if (!err)return 0;
Quoted 6 lines
Quoted 2 lines
err_clk:...This design variant can also be reasonable.
Do any preferences matter here for label name selections?
Personally, I prefer to use labels named after what they're cleaning up and not what they're doing.
--Sean
PATCH v3 6/7 PCI: xilinx-nwl: Add phy support
In reply to Sean AndersonAdd support for enabling/disabling PCIe phys. We can't really do anything about failures in the disable/remove path, so just warn.
---
(no changes since v2)
Changes in v2:
- Get phys by index and not by name
drivers/pci/controller/pcie-xilinx-nwl.c | 68 ++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +65 -3
@@ -19,6 +19,7 @@#include <linux/of_platform.h> #include <linux/pci.h> #include <linux/pci-ecam.h> +#include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/irqchip/chained_irq.h>
@@ -157,6 +158,7 @@ struct nwl_pcie {void __iomem *breg_base;void __iomem *pcireg_base;void __iomem *ecam_base; +struct phy *phy[4 ];phys_addr_t phys_breg_base;/* Physical Bridge Register Base */ phys_addr_t phys_pcie_reg_base;/* Physical PCIe Controller Base */ phys_addr_t phys_ecam_base;/* Physical Configuration Base */
@@ -521,6 +523,43 @@ static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie)return 0 ; } +static int nwl_pcie_phy_enable (struct nwl_pcie *pcie) +{ +int i, ret; + +for (i =0 ; i <ARRAY_SIZE (pcie->phy); i++) { + ret =phy_init (pcie->phy[i]); +if (ret) + goto err; + + ret =phy_power_on (pcie->phy[i]); +if (ret) { +WARN_ON (phy_exit (pcie->phy[i])); + goto err; + } + } + +return 0 ; + +err: +while (--i) { +WARN_ON (phy_power_off (pcie->phy[i])); +WARN_ON (phy_exit (pcie->phy[i])); + } + +return ret; +} + +static void nwl_pcie_phy_disable (struct nwl_pcie *pcie) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (pcie->phy); i++) { +WARN_ON (phy_power_off (pcie->phy[i])); +WARN_ON (phy_exit (pcie->phy[i])); + } +} +static int nwl_pcie_init_irq_domain (struct nwl_pcie *pcie) {struct device *dev = pcie->dev;
@@ -732,6 +771,7 @@ static int nwl_pcie_parse_dt(struct nwl_pcie *pcie, {struct device *dev = pcie->dev;struct resource *res; +int i; res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"breg" ); pcie->breg_base =devm_ioremap_resource (dev, res);
@@ -759,6 +799,18 @@ static int nwl_pcie_parse_dt(struct nwl_pcie *pcie,irq_set_chained_handler_and_data (pcie->irq_intx, nwl_pcie_leg_handler, pcie); + +for (i =0 ; i <ARRAY_SIZE (pcie->phy); i++) { + pcie->phy[i] =devm_of_phy_get_by_index (dev, dev->of_node, i); +if (PTR_ERR (pcie->phy[i]) == -ENODEV ) { + pcie->phy[i] =NULL ; +break ; + } + +if (IS_ERR (pcie->phy[i])) +return PTR_ERR (pcie->phy[i]); + } +return 0 ; }
@@ -799,16 +851,22 @@ static int nwl_pcie_probe(struct platform_device *pdev)return err; } + err =nwl_pcie_phy_enable (pcie); +if (err) { +dev_err (dev,"could not enable PHYs\n" ); + goto err_clk; + } + err =nwl_pcie_bridge_init (pcie);if (err) {dev_err (dev,"HW Initialization failed\n" ); - goto err_clk; + goto err_phy; } err =nwl_pcie_init_irq_domain (pcie);if (err) {dev_err (dev,"Failed creating IRQ Domain\n" ); - goto err_clk; + goto err_phy; } bridge->sysdata = pcie;
@@ -818,12 +876,15 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_enable_msi (pcie);if (err <0 ) {dev_err (dev,"failed to enable MSI support: %d\n" , err); - goto err_clk; + goto err_phy; } } err =pci_host_probe (bridge); +err_phy: +if (err) +nwl_pcie_phy_disable (pcie); err_clk:if (err)clk_disable_unprepare (pcie->clk);
@@ -834,6 +895,7 @@ static void nwl_pcie_remove(struct platform_device *pdev) {struct nwl_pcie *pcie =platform_get_drvdata (pdev); +nwl_pcie_phy_disable (pcie);clk_disable_unprepare (pcie->clk); }
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Quoted 2 lines
Add support for enabling/disabling PCIe phys. We can't really do anything about failures in the disable/remove path, so just warn.
…
Quoted 1 line
+++
b/drivers/pci/controller/pcie-xilinx-nwl.c
…
Quoted 7 lines
drivers/pci/controller/pcie-xilinx-nwl.c +1
-1@@ -818,12 +876,15 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_enable_msi (pcie);if (err <0 ) {dev_err (dev,"failed to enable MSI support: %d\n" , err); - goto err_clk; + goto err_phy; }
drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_probe(struct platform_device *pdev) · line 890
Quoted 10 lines
drivers/pci/controller/pcie-xilinx-nwl.c +3
-0} err =pci_host_probe (bridge); +err_phy: +if (err) +nwl_pcie_phy_disable (pcie); err_clk:if (err)clk_disable_unprepare (pcie->clk);
I got the impression that some source code adjustments should be performed in another separate update step for this function implementation.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9#n81
You propose to extend the exception handling here. Does such information indicate a need for another tag “Fixes”?
How do you think about to increase the usage of a corresponding goto chain?
https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources
Would you become more interested in the application of scope-based resource management?
Regards,
Markus
Quoted 27 lines · Markus Elfring
Quoted 2 lines
Add support for enabling/disabling PCIe phys. We can't really do anything about failures in the disable/remove path, so just warn.
…
Quoted 1 line
+++
b/drivers/pci/controller/pcie-xilinx-nwl.c…
Quoted 7 lines
drivers/pci/controller/pcie-xilinx-nwl.c +1
-1@@ -818,12 +876,15 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_enable_msi (pcie);if (err <0 ) {dev_err (dev,"failed to enable MSI support: %d\n" , err); - goto err_clk; + goto err_phy; }drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_probe(struct platform_device *pdev) · line 890
Quoted 10 lines
drivers/pci/controller/pcie-xilinx-nwl.c +3
-0} err =pci_host_probe (bridge); +err_phy: +if (err) +nwl_pcie_phy_disable (pcie); err_clk:if (err)clk_disable_unprepare (pcie->clk);I got the impression that some source code adjustments should be performed in another separate update step for this function implementation.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9#n81
Quoted 2 lines
You propose to extend the exception handling here. Does such information indicate a need for another tag “Fixes”?
Huh? I am only disabling what I enabled...
--Sean
Quoted 25 lines
Quoted 25 lines
…
Quoted 1 line
+++
b/drivers/pci/controller/pcie-xilinx-nwl.c…
Quoted 7 lines
drivers/pci/controller/pcie-xilinx-nwl.c +1
-1@@ -818,12 +876,15 @@ static int nwl_pcie_probe(struct platform_device *pdev) err =nwl_pcie_enable_msi (pcie);if (err <0 ) {dev_err (dev,"failed to enable MSI support: %d\n" , err); - goto err_clk; + goto err_phy; }drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_probe(struct platform_device *pdev) · line 890
Quoted 10 lines
drivers/pci/controller/pcie-xilinx-nwl.c +3
-0} err =pci_host_probe (bridge); +err_phy: +if (err) +nwl_pcie_phy_disable (pcie); err_clk:if (err)clk_disable_unprepare (pcie->clk);I got the impression that some source code adjustments should be performed in another separate update step for this function implementation.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9#n81
Quoted 4 lines
Quoted 2 lines
You propose to extend the exception handling here. Does such information indicate a need for another tag “Fixes”?
Huh? I am only disabling what I enabled...
* Was a resource deactivation accidentally missing in a previous release of this software component?
* Can repeated checks be avoided a bit more by a design approach which we tried to clarify for the update step “[PATCH v3 5/7] PCI: xilinx-nwl: Clean up clock on probe failure/removal”?
https://lore.kernel.org/lkml/[email protected]/
Regards,
Markus
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 10 lines · Sean Anderson
drivers/pci/controller/pcie-xilinx-nwl.c +10
-0+static int nwl_pcie_phy_enable (struct nwl_pcie *pcie) +{ +int i, ret; + +for (i =0 ; i <ARRAY_SIZE (pcie->phy); i++) { + ret =phy_init (pcie->phy[i]); +if (ret) + goto err; + + ret =phy_power_on (pcie->phy[i]);
drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie) · line 545
Quoted 10 lines
drivers/pci/controller/pcie-xilinx-nwl.c +10
-0+if (ret) { +WARN_ON (phy_exit (pcie->phy[i])); + goto err; + } + } + +return 0 ; + +err: +while (--i) {
This doesn't work. If we fail on the first iteration, then it will lead to an array underflow. It should be while (--i >= 0) or while (i--). I prefer the first, but the second format works for people who use unsigned iterators.
drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie) · line 551
Quoted 6 lines
drivers/pci/controller/pcie-xilinx-nwl.c +6
-0+WARN_ON (phy_power_off (pcie->phy[i])); +WARN_ON (phy_exit (pcie->phy[i])); + } + +return ret; +}
regards,
dan carpenter
Quoted 18 lines · Dan Carpenter
Quoted 17 lines · Sean Anderson
drivers/pci/controller/pcie-xilinx-nwl.c +17
-0+static int nwl_pcie_phy_enable (struct nwl_pcie *pcie) +{ +int i, ret; + +for (i =0 ; i <ARRAY_SIZE (pcie->phy); i++) { + ret =phy_init (pcie->phy[i]); +if (ret) + goto err; + + ret =phy_power_on (pcie->phy[i]); +if (ret) { +WARN_ON (phy_exit (pcie->phy[i])); + goto err; + } + } + +return 0 ;
Quoted 8 lines
drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie) · line 545
Quoted 3 lines
drivers/pci/controller/pcie-xilinx-nwl.c +3
-0+ +err: +while (--i) {This doesn't work. If we fail on the first iteration, then it will lead to an array underflow. It should be while (--i >= 0) or while (i--). I prefer the first, but the second format works for people who use unsigned iterators.
Thanks, will fix.
--Sean
Quoted 10 lines
drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie) · line 551
Quoted 6 lines
drivers/pci/controller/pcie-xilinx-nwl.c +6
-0+WARN_ON (phy_power_off (pcie->phy[i])); +WARN_ON (phy_exit (pcie->phy[i])); + } + +return ret; +}regards,
dan carpenter
PATCH v3 7/7 arm64: zynqmp: Add PCIe phys
In reply to Sean AndersonAdd PCIe phy bindings for the ZCU102.
---
(no changes since v2)
Changes in v2:
- Remove phy-names
arch/arm64/boot/dts/xilinx/zynqmp-zcu102-revA.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/xilinx/zynqmp-zcu102-revA.dts +1 -0
@@ -941,6 +941,7 @@ conf-pull-none { &pcie { status = "okay"; + phys = <&psgtr 0 PHY_TYPE_PCIE 0 0>; }; &psgtr {
Signature · 1 line
2.35.1.1320.gc452695387.dirty