Enable Tegra PCIe root port features
Subsystems (5)
v2 cover Enable Tegra PCIe root port features
This series of patches adds,
- Tegra root port features like Gen2, AER, etc
- Power and perf optimizations
- Fixes like "power up sequence", "dev_err prints", etc
This series of patches are tested on Tegra186 based Jetson-TX2, Tegra210 based Jetson-TX1 and T124 based Jetson-TK1 platforms.
TODO: I don't have T20 and T30 platforms to verify this series. Thierry has kindly agreed to verify this series on T20 and T30.
V2 takes care of comments from Bjorn and Thierry.
Manikanta Maddireddy (28):
soc/tegra: pmc: Export tegra_powergate_power_on()
PCI: tegra: Handle failure cases in tegra_pcie_power_on()
PCI: tegra: Rearrange Tegra PCIe driver functions
PCI: tegra: Disable PCIe interrupts in runtime suspend
PCI: tegra: Fix PCIe host power up sequence
PCI: tegra: Add PCIe Gen2 link speed support
PCI: tegra: Advertise PCIe Advanced Error Reporting (AER) capability
PCI: tegra: Program UPHY electrical settings for Tegra210
PCI: tegra: Enable opportunistic UpdateFC and ACK
PCI: tegra: Disable AFI dynamic clock gating
PCI: tegra: Process pending DLL transactions before entering L1 or L2
PCI: tegra: Enable PCIe xclk clock clamping
PCI: tegra: Increase the deskew retry time
PCI: tegra: Add SW fixup for RAW violations
PCI: tegra: Update flow control timer frequency in Tegra210
PCI: tegra: Set target speed as Gen1 before starting LTSSM
PCI: tegra: Fix PLLE power down issue due to CLKREQ# signal
PCI: tegra: Program AFI_CACHE* registers only for Tegra20
PCI: tegra: Change PRSNT_SENSE irq log to debug
PCI: tegra: Use legacy irq for port service drivers
PCI: tegra: Add AFI_PEX2_CTRL reg offset as part of soc struct
PCI: tegra: Access endpoint config only if PCIe link is up
dt-bindings: pci: tegra: Document PCIe DPD pinctrl optional prop
arm64: tegra: Add PEX DPD states as pinctrl properties
PCI: tegra: Put PEX CLK & BIAS pads in DPD mode
dt-bindings: pci: tegra: Document reset-gpio optional prop
PCI: tegra: Add support for GPIO based PCIe reset
PCI: tegra: Change link retry log level to info
.../bindings/pci/nvidia,tegra20-pcie.txt | 13 + arch/arm64/boot/dts/nvidia/tegra210.dtsi | 19 + drivers/pci/controller/pci-tegra.c | 605 +++++++++++++++--- drivers/soc/tegra/pmc.c | 1 + 4 files changed, 558 insertions(+), 80 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/28 soc/tegra: pmc: Export tegra_powergate_power_on()
tegra_powergate_sequence_power_up() powers up partition and also enables clock & reset. However, if a controller like PCIe have multiple clocks & resets and they need to be enabled in a sequence, driver must use standalone function tegra_powergate_power_on() to power up partition.
Export tegra_powergate_power_on() to allow Tegra controller drivers to unpower gate partition independent to clock & reset.
---
V2: No change
drivers/soc/tegra/pmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/tegra/pmc.c +1 -0
@@ -701,6 +701,7 @@ int tegra_powergate_power_on(unsigned int id)return tegra_powergate_set (pmc, id, true); } +EXPORT_SYMBOL (tegra_powergate_power_on);/** * tegra_powergate_power_off() - power off partition
Signature · 1 line
2.17.1
Re: [PATCH V2 01/28] soc/tegra: pmc: Export tegra_powergate_power_on()
Quoted 20 lines · Manikanta Maddireddy
tegra_powergate_sequence_power_up()powers up partition and also enables clock & reset. However, if a controller like PCIe have multiple clocks & resets and they need to be enabled in a sequence, driver must use standalone functiontegra_powergate_power_on()to power up partition.Export
tegra_powergate_power_on()to allow Tegra controller drivers to unpower gate partition independent to clock & reset.Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: No changedrivers/soc/tegra/pmc.c | 1 + 1 file changed, 1 insertion(+)drivers/soc/tegra/pmc.c +0
-0
drivers/soc/tegra/pmc.c int tegra_powergate_power_on(unsigned int id) · line 707
Quoted 7 lines
drivers/soc/tegra/pmc.c +1
-0@@ -701,6 +701,7 @@ int tegra_powergate_power_on(unsigned int id)return tegra_powergate_set (pmc, id, true); } +EXPORT_SYMBOL (tegra_powergate_power_on);/** * tegra_powergate_power_off() - power off partition
If the sequence for the PCI power partition is becoming non-standard, this is going to hamper our efforts to move to generic PM domains. But it is what it is, so let's do this for now. We might need to revise this later on if/when we come up with a better solution.
Bjorn, do you want to pick this up as part of this series, given the build dependency? If so:
Alternatively I could provide a stable branch for you to pull in. But I don't think it'd be necessary, the PMC driver is a fairly slow-moving target these days.
Thierry
PATCH v2 2/28 PCI: tegra: Handle failure cases in tegra_pcie_power_on()
In reply to Manikanta MaddireddyUnroll the PCIe power on sequence if any one of the steps fail in tegra_pcie_power_on().
---
V2: New patch to handle error cleanup in tegra_pcie_power_on().
drivers/pci/controller/pci-tegra.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/pci/controller/pci-tegra.c +21 -5
@@ -1052,7 +1052,7 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie) err =clk_prepare_enable (pcie->pex_clk);if (err) {dev_err (dev,"failed to enable PEX clock: %d\n" , err); -return err; + goto regulator_disable; }reset_control_deassert (pcie->pex_rst); }else {
@@ -1061,7 +1061,7 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie) pcie->pex_rst);if (err) {dev_err (dev,"powerup sequence failed: %d\n" , err); -return err; + goto regulator_disable; } }
@@ -1070,24 +1070,40 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie) err =clk_prepare_enable (pcie->afi_clk);if (err <0 ) {dev_err (dev,"failed to enable AFI clock: %d\n" , err); -return err; + goto powergate; }if (soc->has_cml_clk) { err =clk_prepare_enable (pcie->cml_clk);if (err <0 ) {dev_err (dev,"failed to enable CML clock: %d\n" , err); -return err; + goto disable_afi_clk; } } err =clk_prepare_enable (pcie->pll_e);if (err <0 ) {dev_err (dev,"failed to enable PLLE clock: %d\n" , err); -return err; + goto disable_cml_clk; }return 0 ; + +disable_cml_clk: +if (soc->has_cml_clk) +clk_disable_unprepare (pcie->cml_clk); +disable_afi_clk: +clk_disable_unprepare (pcie->afi_clk); +powergate: +reset_control_assert (pcie->afi_rst); +reset_control_assert (pcie->pex_rst); +clk_disable_unprepare (pcie->pex_clk); +if (!dev->pm_domain) +tegra_powergate_power_off (TEGRA_POWERGATE_PCIE ); +regulator_disable: +regulator_bulk_disable (pcie->num_supplies, pcie->supplies); + +return err; }static int tegra_pcie_clocks_get (struct tegra_pcie *pcie)
Signature · 1 line
2.17.1
Re: [PATCH V2 02/28] PCI: tegra: Handle failure cases in tegra_pcie_power_on()
Quoted 9 lines · Manikanta Maddireddy
Unroll the PCIe power on sequence if any one of the steps fail in
tegra_pcie_power_on().Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: New patch to handle error cleanup integra_pcie_power_on().drivers/pci/controller/pci-tegra.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
PATCH v2 3/28 PCI: tegra: Rearrange Tegra PCIe driver functions
In reply to Manikanta MaddireddyTegra PCIe has register spec for,
- AXI to FPCI(AFI) bridge
- Multiple PCIe root ports
- PCIe PHY
- PCIe pad control
Rearrange Tegra PCIe driver functions such that each function programs required module only.
- tegra_pcie_enable_controller(): Program AFI module and enable PCIe
controller.
- tegra_pcie_phy_power_on(): Bring up PCIe PHY.
- tegra_pcie_apply_pad_settings(): Program PCIe REFCLK pad settings.
- tegra_pcie_enable_ports(): Program each root port and bring up PCIe
link.
---
V2: This is new patch in V2
drivers/pci/controller/pci-tegra.c | 70 +++++++++++++----------------- 1 file changed, 30 insertions(+), 40 deletions(-)
drivers/pci/controller/pci-tegra.c +30 -40
@@ -852,7 +852,6 @@ static int tegra_pcie_port_phy_power_off(struct tegra_pcie_port *port)static int tegra_pcie_phy_power_on (struct tegra_pcie *pcie) {struct device *dev = pcie->dev; -const struct tegra_pcie_soc *soc = pcie->soc;struct tegra_pcie_port *port;int err;
@@ -878,12 +877,6 @@ static int tegra_pcie_phy_power_on(struct tegra_pcie *pcie) } } -/* Configure the reference clock driver */ -pads_writel (pcie, soc->pads_refclk_cfg0,PADS_REFCLK_CFG0 ); - -if (soc->num_ports >2 ) -pads_writel (pcie, soc->pads_refclk_cfg1,PADS_REFCLK_CFG1 ); -return 0 ; }
@@ -918,13 +911,11 @@ static int tegra_pcie_phy_power_off(struct tegra_pcie *pcie)return 0 ; } -static int tegra_pcie_enable_controller (struct tegra_pcie *pcie) +static void tegra_pcie_enable_controller (struct tegra_pcie *pcie) { -struct device *dev = pcie->dev;const struct tegra_pcie_soc *soc = pcie->soc;struct tegra_pcie_port *port;unsigned long value; -int err;/* enable PLL power down */ if (pcie->phy) {
@@ -958,14 +949,6 @@ static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)afi_writel (pcie, value,AFI_FUSE ); } -if (soc->program_uphy) { - err =tegra_pcie_phy_power_on (pcie); -if (err <0 ) { -dev_err (dev,"failed to power on PHY(s): %d\n" , err); -return err; - } - } -/* take the PCIe interface module out of reset */ reset_control_deassert (pcie->pcie_xrst);
@@ -989,22 +972,6 @@ static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)/* disable all exceptions */ afi_writel (pcie,0 ,AFI_FPCI_ERROR_MASKS ); - -return 0 ; -} - -static void tegra_pcie_disable_controller (struct tegra_pcie *pcie) -{ -int err; - -reset_control_assert (pcie->pcie_xrst); - -if (pcie->soc->program_uphy) { - err =tegra_pcie_phy_power_off (pcie); -if (err <0 ) -dev_err (pcie->dev,"failed to power off PHY(s): %d\n" , - err); - } }static void tegra_pcie_power_off (struct tegra_pcie *pcie)
@@ -1106,6 +1073,17 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie)return err; } +static void tegra_pcie_apply_pad_settings (struct tegra_pcie *pcie) +{ +const struct tegra_pcie_soc *soc = pcie->soc; + +/* Configure the reference clock driver */ +pads_writel (pcie, soc->pads_refclk_cfg0,PADS_REFCLK_CFG0 ); + +if (soc->num_ports >2 ) +pads_writel (pcie, soc->pads_refclk_cfg1,PADS_REFCLK_CFG1 ); +} +static int tegra_pcie_clocks_get (struct tegra_pcie *pcie) {struct device *dev = pcie->dev;
@@ -2482,16 +2460,23 @@ static int __maybe_unused tegra_pcie_pm_suspend(struct device *dev) {struct tegra_pcie *pcie =dev_get_drvdata (dev);struct tegra_pcie_port *port; +int err;list_for_each_entry (port, &pcie->ports, list)tegra_pcie_pme_turnoff (port);tegra_pcie_disable_ports (pcie); +if (pcie->soc->program_uphy) { + err =tegra_pcie_phy_power_off (pcie); +if (err <0 ) +dev_err (dev,"failed to power off PHY(s): %d\n" , err); + } +if (IS_ENABLED (CONFIG_PCI_MSI ))tegra_pcie_disable_msi (pcie); -tegra_pcie_disable_controller (pcie); +reset_control_assert (pcie->pcie_xrst);tegra_pcie_power_off (pcie);return 0 ;
@@ -2507,16 +2492,21 @@ static int __maybe_unused tegra_pcie_pm_resume(struct device *dev)dev_err (dev,"tegra pcie power on fail: %d\n" , err);return err; } - err =tegra_pcie_enable_controller (pcie); -if (err) { -dev_err (dev,"tegra pcie controller enable fail: %d\n" , err); - goto poweroff; - } +tegra_pcie_enable_controller (pcie);tegra_pcie_setup_translations (pcie);if (IS_ENABLED (CONFIG_PCI_MSI ))tegra_pcie_enable_msi (pcie); +if (pcie->soc->program_uphy) { + err =tegra_pcie_phy_power_on (pcie); +if (err <0 ) { +dev_err (dev,"failed to power on PHY(s): %d\n" , err); + goto poweroff; + } + } + +tegra_pcie_apply_pad_settings (pcie);tegra_pcie_enable_ports (pcie);return 0 ;
Signature · 1 line
2.17.1
Re: [PATCH V2 03/28] PCI: tegra: Rearrange Tegra PCIe driver functions
Quoted 15 lines · Manikanta Maddireddy
Tegra PCIe has register spec for,
- AXI to FPCI(AFI) bridge
- Multiple PCIe root ports
- PCIe PHY
- PCIe pad controlRearrange Tegra PCIe driver functions such that each function programs required module only.
-tegra_pcie_enable_controller(): Program AFI module and enable PCIe
controller.
-tegra_pcie_phy_power_on(): Bring up PCIe PHY.
-tegra_pcie_apply_pad_settings(): Program PCIe REFCLK pad settings.
-tegra_pcie_enable_ports(): Program each root port and bring up PCIe
link.
Quoted 6 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: This is new patch in V2drivers/pci/controller/pci-tegra.c | 70 +++++++++++++----------------- 1 file changed, 30 insertions(+), 40 deletions(-)
PATCH v2 4/28 PCI: tegra: Disable PCIe interrupts in runtime suspend
In reply to Manikanta MaddireddyDisable PCIe interrupts in runtime suspend to avoid executing irq handler and power off sequence in parallel.
Following sequence triggers such scenario,
- tegra_pcie_remove() triggers runtime suspend
- pex_rst is asserted in runtime suspend
- PRSNT_MAP bit field in RP_PRIV_MISC register changes from EP_PRSNT to EP_ABSNT
- This is sensed by AFI and triggers "Slot present pin change" interrupt
- tegra_pcie_isr() function accesses AFI register when runtime suspend is going through power off sequence
rmmod pci-tegra
pci_generic_config_write32: 108 callbacks suppressed
pci_bus 0002:00: 2-byte config write to 0002:00:02.0 offset 0x4c may corrupt adjacent RW1C bits pci_bus 0002:00: 2-byte config write to 0002:00:02.0 offset 0x9c may corrupt adjacent RW1C bits pci_bus 0002:00: 2-byte config write to 0002:00:02.0 offset 0x88 may corrupt adjacent RW1C bits pci_bus 0002:00: 2-byte config write to 0002:00:02.0 offset 0x90 may corrupt adjacent RW1C bits pci_bus 0002:00: 2-byte config write to 0002:00:02.0 offset 0x4 may corrupt adjacent RW1C bits igb 0002:04:00.1: removed PHC on enP2p4s0f1
igb 0002:04:00.0: removed PHC on enP2p4s0f0
pci_bus 0002:00: 2-byte config write to 0002:00:01.0 offset 0x4c may corrupt adjacent RW1C bits pci_bus 0002:00: 2-byte config write to 0002:00:01.0 offset 0x9c may corrupt adjacent RW1C bits pci_bus 0002:00: 2-byte config write to 0002:00:01.0 offset 0x88 may corrupt adjacent RW1C bits pci_bus 0002:00: 2-byte config write to 0002:00:01.0 offset 0x90 may corrupt adjacent RW1C bits pci_bus 0002:00: 2-byte config write to 0002:00:01.0 offset 0x4 may corrupt adjacent RW1C bits
rcu: INFO: rcu_preempt self-detected stall on CPU SError Interrupt on CPU0, code 0xbf000002 -- SError CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 5.1.0-rc3-next-20190405-00027-gcd8110499e6f-dirty #42 Hardware name: NVIDIA Jetson TX1 Developer Kit (DT) pstate: 20000085 (nzCv daIf -PAN -UAO) pc : tegra_pcie_isr+0x58/0x178 [pci_tegra] lr : tegra_pcie_isr+0x40/0x178 [pci_tegra] sp : ffff000010003da0 x29: ffff000010003da0 x28: 0000000000000000 x27: ffff8000f9e61000 x26: ffff000010fbf420 x25: ffff000011427f93 x24: ffff8000fa600410 x23: ffff00001129d000 x22: ffff00001129d000 x21: ffff8000f18bf3c0 x20: 0000000000000070 x19: 00000000ffffffff x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: ffff000008d40a48 x13: ffff000008d40a30 x12: ffff000008d40a20 x11: ffff000008d40a10 x10: ffff000008d40a00 x9 : ffff000008d409e8 x8 : ffff000008d40ae8 x7 : ffff000008d40ad0 x6 : ffff000010003e58 x5 : ffff8000fac00248 x4 : 0000000000000000 x3 : ffff000008d40b08 x2 : fffffffffffffff8 x1 : ffff000008d3f4e8 x0 : 00000000ffffffff Kernel panic - not syncing: Asynchronous SError Interrupt CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 5.1.0-rc3-next-20190405-00027-gcd8110499e6f-dirty #42 Hardware name: NVIDIA Jetson TX1 Developer Kit (DT) Call trace: dump_backtrace+0x0/0x158 show_stack+0x14/0x20 dump_stack+0xa8/0xcc panic+0x140/0x2f4 nmi_panic+0x6c/0x70 arm64_serror_panic+0x74/0x80 __pte_error+0x0/0x28 el1_error+0x84/0xf8 tegra_pcie_isr+0x58/0x178 [pci_tegra] __handle_irq_event_percpu+0x70/0x198 handle_irq_event_percpu+0x34/0x88 handle_irq_event+0x48/0x78 handle_fasteoi_irq+0xb4/0x190 generic_handle_irq+0x24/0x38 __handle_domain_irq+0x5c/0xb8 gic_handle_irq+0x58/0xa8 el1_irq+0xb8/0x180 cpuidle_enter_state+0x138/0x358 cpuidle_enter+0x18/0x20 call_cpuidle+0x1c/0x48 do_idle+0x230/0x2d0 cpu_startup_entry+0x20/0x28 rest_init+0xd4/0xe0 arch_call_rest_init+0xc/0x14 start_kernel+0x444/0x470
---
V2: This is new patch in V2
drivers/pci/controller/pci-tegra.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/pci/controller/pci-tegra.c +17 -0
@@ -1622,6 +1622,18 @@ static int tegra_pcie_disable_msi(struct tegra_pcie *pcie)return 0 ; } +static void tegra_pcie_disable_interrupts (struct tegra_pcie *pcie) +{ +u32 value; + + value =afi_readl (pcie,AFI_INTR_MASK ); + value &= ~AFI_INTR_MASK_INT_MASK ; +afi_writel (pcie, value,AFI_INTR_MASK ); + +if (IS_ENABLED (CONFIG_PCI_MSI )) +tegra_pcie_disable_msi (pcie); +} +static int tegra_pcie_get_xbar_config (struct tegra_pcie *pcie,u32 lanes,u32 *xbar) {
@@ -2466,6 +2478,11 @@ static int __maybe_unused tegra_pcie_pm_suspend(struct device *dev)tegra_pcie_pme_turnoff (port);tegra_pcie_disable_ports (pcie); +/* +* disable interrupts to avoid executing irq handler in parallel +* to power off sequence. +*/ +tegra_pcie_disable_interrupts (pcie);if (pcie->soc->program_uphy) { err =tegra_pcie_phy_power_off (pcie);
Signature · 1 line
2.17.1
Re: [PATCH V2 04/28] PCI: tegra: Disable PCIe interrupts in runtime suspend
Quoted 11 lines · Manikanta Maddireddy
Disable PCIe interrupts in runtime suspend to avoid executing irq handler and power off sequence in parallel.
Following sequence triggers such scenario,
-tegra_pcie_remove()triggers runtime suspend
-pex_rstis asserted in runtime suspend
-PRSNT_MAPbit field inRP_PRIV_MISCregister changes fromEP_PRSNTtoEP_ABSNT
- This is sensed by AFI and triggers "Slot present pin change" interrupt
-tegra_pcie_isr()function accesses AFI register when runtime suspend is going through power off sequence
This sounds like more of a workaround than a proper solution. If the above sequence crashes, it means that we have a bug somewhere in that sequence. By the time the controller is runtime suspended, we should have shut everything down already.
That said, from the looks of it, I think we may be able to fix this by moving the pm_runtime_*() calls in tegra_pcie_remove() below the tegra_pcie_put_resources(). At that point, nothing should be accessing any registers anymore.
Thierry
Quoted 113 lines
rmmod pci-tegra
pci_generic_config_write32: 108 callbacks suppressed
pci_bus0002:00: 2-byte config write to 0002:00:02.0 offset0x4cmay corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:02.0 offset0x9cmay corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:02.0 offset0x88may corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:02.0 offset0x90may corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:02.0 offset0x4may corrupt adjacent RW1C bits igb 0002:04:00.1: removed PHC on enP2p4s0f1
igb 0002:04:00.0: removed PHC on enP2p4s0f0
pci_bus0002:00: 2-byte config write to 0002:00:01.0 offset0x4cmay corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:01.0 offset0x9cmay corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:01.0 offset0x88may corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:01.0 offset0x90may corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:01.0 offset0x4may corrupt adjacent RW1C bitsrcu: INFO: rcu_preempt self-detected stall on CPU SError Interrupt on CPU0, code 0xbf000002 -- SError CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 5.1.0-rc3-next-20190405-00027-gcd8110499e6f-dirty #42 Hardware name: NVIDIA Jetson TX1 Developer Kit (DT) pstate: 20000085 (nzCv daIf -PAN -UAO) pc : tegra_pcie_isr+0x58/0x178 [pci_tegra] lr : tegra_pcie_isr+0x40/0x178 [pci_tegra] sp : ffff000010003da0 x29: ffff000010003da0 x28: 0000000000000000 x27: ffff8000f9e61000 x26: ffff000010fbf420 x25: ffff000011427f93 x24: ffff8000fa600410 x23: ffff00001129d000 x22: ffff00001129d000 x21: ffff8000f18bf3c0 x20: 0000000000000070 x19: 00000000ffffffff x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: ffff000008d40a48 x13: ffff000008d40a30 x12: ffff000008d40a20 x11: ffff000008d40a10 x10: ffff000008d40a00 x9 : ffff000008d409e8 x8 : ffff000008d40ae8 x7 : ffff000008d40ad0 x6 : ffff000010003e58 x5 : ffff8000fac00248 x4 : 0000000000000000 x3 : ffff000008d40b08 x2 : fffffffffffffff8 x1 : ffff000008d3f4e8 x0 : 00000000ffffffff Kernel panic - not syncing: Asynchronous SError Interrupt CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 5.1.0-rc3-next-20190405-00027-gcd8110499e6f-dirty #42 Hardware name: NVIDIA Jetson TX1 Developer Kit (DT) Call trace: dump_backtrace+0x0/0x158 show_stack+0x14/0x20 dump_stack+0xa8/0xcc panic+0x140/0x2f4 nmi_panic+0x6c/0x70 arm64_serror_panic+0x74/0x80 __pte_error+0x0/0x28 el1_error+0x84/0xf8 tegra_pcie_isr+0x58/0x178 [pci_tegra] __handle_irq_event_percpu+0x70/0x198 handle_irq_event_percpu+0x34/0x88 handle_irq_event+0x48/0x78 handle_fasteoi_irq+0xb4/0x190 generic_handle_irq+0x24/0x38 __handle_domain_irq+0x5c/0xb8 gic_handle_irq+0x58/0xa8 el1_irq+0xb8/0x180 cpuidle_enter_state+0x138/0x358 cpuidle_enter+0x18/0x20 call_cpuidle+0x1c/0x48 do_idle+0x230/0x2d0 cpu_startup_entry+0x20/0x28 rest_init+0xd4/0xe0 arch_call_rest_init+0xc/0x14 start_kernel+0x444/0x470Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: This is new patch in V2drivers/pci/controller/pci-tegra.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/pci/controller/pci-tegra.c +17
-0@@ -1622,6 +1622,18 @@ static int tegra_pcie_disable_msi(struct tegra_pcie *pcie)return 0 ; } +static void tegra_pcie_disable_interrupts (struct tegra_pcie *pcie) +{ +u32 value; + + value =afi_readl (pcie,AFI_INTR_MASK ); + value &= ~AFI_INTR_MASK_INT_MASK ; +afi_writel (pcie, value,AFI_INTR_MASK ); + +if (IS_ENABLED (CONFIG_PCI_MSI )) +tegra_pcie_disable_msi (pcie); +} +static int tegra_pcie_get_xbar_config (struct tegra_pcie *pcie,u32 lanes,u32 *xbar) {@@ -2466,6 +2478,11 @@ static int __maybe_unused tegra_pcie_pm_suspend(struct device *dev)tegra_pcie_pme_turnoff (port);tegra_pcie_disable_ports (pcie); +/* +* disable interrupts to avoid executing irq handler in parallel +* to power off sequence. +*/ +tegra_pcie_disable_interrupts (pcie);if (pcie->soc->program_uphy) { err =tegra_pcie_phy_power_off (pcie);Signature · 1 line
2.17.1
Re: [PATCH V2 04/28] PCI: tegra: Disable PCIe interrupts in runtime suspend
Quoted 17 lines · Thierry Reding
Quoted 11 lines · Manikanta Maddireddy
Disable PCIe interrupts in runtime suspend to avoid executing irq handler and power off sequence in parallel.
Following sequence triggers such scenario,
-tegra_pcie_remove()triggers runtime suspend
-pex_rstis asserted in runtime suspend
-PRSNT_MAPbit field inRP_PRIV_MISCregister changes fromEP_PRSNTtoEP_ABSNT
- This is sensed by AFI and triggers "Slot present pin change" interrupt
-tegra_pcie_isr()function accesses AFI register when runtime suspend is going through power off sequenceThis sounds like more of a workaround than a proper solution. If the above sequence crashes, it means that we have a bug somewhere in that sequence. By the time the controller is runtime suspended, we should have shut everything down already.
Quoted 6 lines
That said, from the looks of it, I think we may be able to fix this by moving the pm_runtime_*() calls in
tegra_pcie_remove()below thetegra_pcie_put_resources(). At that point, nothing should be accessing any registers anymore.Thierry
This crash is observed after applying 5/28 patch because,
- In the previous sequence AFI is asserted before PEX reset,
so AFI doesn't raise interrupt
- Whereas in 5/28 patch, PEX reset is asserted before AFI,
so AFI raises interrupt
I believe this patch is correct fix & not workaround because,
- tegra_pcie_pm_resume() -> tegra_pcie_enable_controller() is clearingAFI_INTR_MASK
- In tegra_pcie_pm_suspend() this patch is doing opposite of above
programming, which is masking AFI_INTR_MASK
Moving pm_runtime_put() after tegra_pcie_put_resources() will not be inline with init sequence in probe because tegra_pcie_get_resources() is done before pm_runtime_get().
Manikanta
Quoted 112 lines
Quoted 112 lines
rmmod pci-tegra
pci_generic_config_write32: 108 callbacks suppressed
pci_bus0002:00: 2-byte config write to 0002:00:02.0 offset0x4cmay corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:02.0 offset0x9cmay corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:02.0 offset0x88may corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:02.0 offset0x90may corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:02.0 offset0x4may corrupt adjacent RW1C bits igb 0002:04:00.1: removed PHC on enP2p4s0f1
igb 0002:04:00.0: removed PHC on enP2p4s0f0
pci_bus0002:00: 2-byte config write to 0002:00:01.0 offset0x4cmay corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:01.0 offset0x9cmay corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:01.0 offset0x88may corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:01.0 offset0x90may corrupt adjacent RW1C bitspci_bus0002:00: 2-byte config write to 0002:00:01.0 offset0x4may corrupt adjacent RW1C bitsrcu: INFO: rcu_preempt self-detected stall on CPU SError Interrupt on CPU0, code 0xbf000002 -- SError CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 5.1.0-rc3-next-20190405-00027-gcd8110499e6f-dirty #42 Hardware name: NVIDIA Jetson TX1 Developer Kit (DT) pstate: 20000085 (nzCv daIf -PAN -UAO) pc : tegra_pcie_isr+0x58/0x178 [pci_tegra] lr : tegra_pcie_isr+0x40/0x178 [pci_tegra] sp : ffff000010003da0 x29: ffff000010003da0 x28: 0000000000000000 x27: ffff8000f9e61000 x26: ffff000010fbf420 x25: ffff000011427f93 x24: ffff8000fa600410 x23: ffff00001129d000 x22: ffff00001129d000 x21: ffff8000f18bf3c0 x20: 0000000000000070 x19: 00000000ffffffff x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: ffff000008d40a48 x13: ffff000008d40a30 x12: ffff000008d40a20 x11: ffff000008d40a10 x10: ffff000008d40a00 x9 : ffff000008d409e8 x8 : ffff000008d40ae8 x7 : ffff000008d40ad0 x6 : ffff000010003e58 x5 : ffff8000fac00248 x4 : 0000000000000000 x3 : ffff000008d40b08 x2 : fffffffffffffff8 x1 : ffff000008d3f4e8 x0 : 00000000ffffffff Kernel panic - not syncing: Asynchronous SError Interrupt CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 5.1.0-rc3-next-20190405-00027-gcd8110499e6f-dirty #42 Hardware name: NVIDIA Jetson TX1 Developer Kit (DT) Call trace: dump_backtrace+0x0/0x158 show_stack+0x14/0x20 dump_stack+0xa8/0xcc panic+0x140/0x2f4 nmi_panic+0x6c/0x70 arm64_serror_panic+0x74/0x80 __pte_error+0x0/0x28 el1_error+0x84/0xf8 tegra_pcie_isr+0x58/0x178 [pci_tegra] __handle_irq_event_percpu+0x70/0x198 handle_irq_event_percpu+0x34/0x88 handle_irq_event+0x48/0x78 handle_fasteoi_irq+0xb4/0x190 generic_handle_irq+0x24/0x38 __handle_domain_irq+0x5c/0xb8 gic_handle_irq+0x58/0xa8 el1_irq+0xb8/0x180 cpuidle_enter_state+0x138/0x358 cpuidle_enter+0x18/0x20 call_cpuidle+0x1c/0x48 do_idle+0x230/0x2d0 cpu_startup_entry+0x20/0x28 rest_init+0xd4/0xe0 arch_call_rest_init+0xc/0x14 start_kernel+0x444/0x470Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: This is new patch in V2drivers/pci/controller/pci-tegra.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/pci/controller/pci-tegra.c +17
-0@@ -1622,6 +1622,18 @@ static int tegra_pcie_disable_msi(struct tegra_pcie *pcie)return 0 ; } +static void tegra_pcie_disable_interrupts (struct tegra_pcie *pcie) +{ +u32 value; + + value =afi_readl (pcie,AFI_INTR_MASK ); + value &= ~AFI_INTR_MASK_INT_MASK ; +afi_writel (pcie, value,AFI_INTR_MASK ); + +if (IS_ENABLED (CONFIG_PCI_MSI )) +tegra_pcie_disable_msi (pcie); +} +static int tegra_pcie_get_xbar_config (struct tegra_pcie *pcie,u32 lanes,u32 *xbar) {@@ -2466,6 +2478,11 @@ static int __maybe_unused tegra_pcie_pm_suspend(struct device *dev)tegra_pcie_pme_turnoff (port);tegra_pcie_disable_ports (pcie); +/* +* disable interrupts to avoid executing irq handler in parallel +* to power off sequence. +*/ +tegra_pcie_disable_interrupts (pcie);if (pcie->soc->program_uphy) { err =tegra_pcie_phy_power_off (pcie);Signature · 1 line
2.17.1
PATCH v2 5/28 PCI: tegra: Fix PCIe host power up sequence
In reply to Manikanta MaddireddyPCIe host power up sequence involves programming AFI(AXI to FPCI bridge) registers first and then PCIe registers. Otherwise AFI register settings may not latch to PCIe IP.
PCIe root port starts LTSSM as soon as PCIe xrst is deasserted. So deassert PCIe xrst after programming PCIe registers.
Modify PCIe power up sequence as follows,
- Power ungate PCIe partition
- Enable AFI clock
- Deassert AFI reset
- Program AFI registers
- Enable PCIe clock
- Deassert PCIe reset
- Program PCIe PHY
- Program PCIe pad control registers
- Program PCIe root port registers
- Deassert PCIe xrst to start LTSSM
---
V2: Error cleanup changes are moved to new patch and only sequence correction is done in this patch.
drivers/pci/controller/pci-tegra.c | 51 +++++++++++++++++------------- 1 file changed, 29 insertions(+), 22 deletions(-)
drivers/pci/controller/pci-tegra.c +29 -22
@@ -949,9 +949,6 @@ static void tegra_pcie_enable_controller(struct tegra_pcie *pcie)afi_writel (pcie, value,AFI_FUSE ); } -/* take the PCIe interface module out of reset */ -reset_control_deassert (pcie->pcie_xrst); -/* finally enable PCIe */ value =afi_readl (pcie,AFI_CONFIGURATION ); value |=AFI_CONFIGURATION_EN_FPCI ;
@@ -981,13 +978,11 @@ static void tegra_pcie_power_off(struct tegra_pcie *pcie)int err;reset_control_assert (pcie->afi_rst); -reset_control_assert (pcie->pex_rst);clk_disable_unprepare (pcie->pll_e);if (soc->has_cml_clk)clk_disable_unprepare (pcie->cml_clk);clk_disable_unprepare (pcie->afi_clk); -clk_disable_unprepare (pcie->pex_clk);if (!dev->pm_domain)tegra_powergate_power_off (TEGRA_POWERGATE_PCIE );
@@ -1015,25 +1010,19 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie)if (err <0 )dev_err (dev,"failed to enable regulators: %d\n" , err); -if (dev->pm_domain) { - err =clk_prepare_enable (pcie->pex_clk); +if (!dev->pm_domain) { + err =tegra_powergate_power_on (TEGRA_POWERGATE_PCIE );if (err) { -dev_err (dev,"failed to enable PEX clock: %d\n" , err); +dev_err (dev,"failed to power ungate: %d\n" , err); goto regulator_disable; } -reset_control_deassert (pcie->pex_rst); - }else { - err =tegra_powergate_sequence_power_up (TEGRA_POWERGATE_PCIE , - pcie->pex_clk, - pcie->pex_rst); + err =tegra_powergate_remove_clamping (TEGRA_POWERGATE_PCIE );if (err) { -dev_err (dev,"powerup sequence failed: %d\n" , err); - goto regulator_disable; +dev_err (dev,"failed to remove clamp: %d\n" , err); + goto powergate; } } -reset_control_deassert (pcie->afi_rst); - err =clk_prepare_enable (pcie->afi_clk);if (err <0 ) {dev_err (dev,"failed to enable AFI clock: %d\n" , err);
@@ -1054,6 +1043,8 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie) goto disable_cml_clk; } +reset_control_deassert (pcie->afi_rst); +return 0 ; disable_cml_clk:
@@ -1062,9 +1053,6 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie) disable_afi_clk:clk_disable_unprepare (pcie->afi_clk); powergate: -reset_control_assert (pcie->afi_rst); -reset_control_assert (pcie->pex_rst); -clk_disable_unprepare (pcie->pex_clk);if (!dev->pm_domain)tegra_powergate_power_off (TEGRA_POWERGATE_PCIE ); regulator_disable:
@@ -2114,7 +2102,12 @@ static void tegra_pcie_enable_ports(struct tegra_pcie *pcie) port->index, port->lanes);tegra_pcie_port_enable (port); + } +/* Start LTSSM from Tegra side */ +reset_control_deassert (pcie->pcie_xrst); + +list_for_each_entry_safe (port, tmp, &pcie->ports, list) {if (tegra_pcie_port_check_link (port))continue ;
@@ -2129,6 +2122,8 @@ static void tegra_pcie_disable_ports(struct tegra_pcie *pcie) {struct tegra_pcie_port *port, *tmp; +reset_control_assert (pcie->pcie_xrst); +list_for_each_entry_safe (port, tmp, &pcie->ports, list)tegra_pcie_port_disable (port); }
@@ -2490,10 +2485,12 @@ static int __maybe_unused tegra_pcie_pm_suspend(struct device *dev)dev_err (dev,"failed to power off PHY(s): %d\n" , err); } +reset_control_assert (pcie->pex_rst); +clk_disable_unprepare (pcie->pex_clk); +if (IS_ENABLED (CONFIG_PCI_MSI ))tegra_pcie_disable_msi (pcie); -reset_control_assert (pcie->pcie_xrst);tegra_pcie_power_off (pcie);return 0 ;
@@ -2515,11 +2512,18 @@ static int __maybe_unused tegra_pcie_pm_resume(struct device *dev)if (IS_ENABLED (CONFIG_PCI_MSI ))tegra_pcie_enable_msi (pcie); + err =clk_prepare_enable (pcie->pex_clk); +if (err) { +dev_err (dev,"failed to enable PEX clock: %d\n" , err); + goto poweroff; + } +reset_control_deassert (pcie->pex_rst); +if (pcie->soc->program_uphy) { err =tegra_pcie_phy_power_on (pcie);if (err <0 ) {dev_err (dev,"failed to power on PHY(s): %d\n" , err); - goto poweroff; + goto disable_pex_clk; } }
@@ -2528,6 +2532,9 @@ static int __maybe_unused tegra_pcie_pm_resume(struct device *dev)return 0 ; +disable_pex_clk: +reset_control_assert (pcie->pex_rst); +clk_disable_unprepare (pcie->pex_clk); poweroff:tegra_pcie_power_off (pcie);
Signature · 1 line
2.17.1
Re: [PATCH V2 05/28] PCI: tegra: Fix PCIe host power up sequence
Quoted 143 lines · Manikanta Maddireddy
PCIe host power up sequence involves programming AFI(AXI to FPCI bridge) registers first and then PCIe registers. Otherwise AFI register settings may not latch to PCIe IP.
PCIe root port starts LTSSM as soon as PCIe xrst is deasserted. So deassert PCIe xrst after programming PCIe registers.
Modify PCIe power up sequence as follows,
- Power ungate PCIe partition
- Enable AFI clock
- Deassert AFI reset
- Program AFI registers
- Enable PCIe clock
- Deassert PCIe reset
- Program PCIe PHY
- Program PCIe pad control registers
- Program PCIe root port registers
- Deassert PCIe xrst to start LTSSMSigned-off-by Manikanta Maddireddy <[email protected]>---
V2: Error cleanup changes are moved to new patch and only sequence correction is done in this patch.drivers/pci/controller/pci-tegra.c | 51 +++++++++++++++++------------- 1 file changed, 29 insertions(+), 22 deletions(-)drivers/pci/controller/pci-tegra.c +18
-21@@ -949,9 +949,6 @@ static void tegra_pcie_enable_controller(struct tegra_pcie *pcie)afi_writel (pcie, value,AFI_FUSE ); } -/* take the PCIe interface module out of reset */ -reset_control_deassert (pcie->pcie_xrst); -/* finally enable PCIe */ value =afi_readl (pcie,AFI_CONFIGURATION ); value |=AFI_CONFIGURATION_EN_FPCI ;@@ -981,13 +978,11 @@ static void tegra_pcie_power_off(struct tegra_pcie *pcie)int err;reset_control_assert (pcie->afi_rst); -reset_control_assert (pcie->pex_rst);clk_disable_unprepare (pcie->pll_e);if (soc->has_cml_clk)clk_disable_unprepare (pcie->cml_clk);clk_disable_unprepare (pcie->afi_clk); -clk_disable_unprepare (pcie->pex_clk);if (!dev->pm_domain)tegra_powergate_power_off (TEGRA_POWERGATE_PCIE );@@ -1015,25 +1010,19 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie)if (err <0 )dev_err (dev,"failed to enable regulators: %d\n" , err); -if (dev->pm_domain) { - err =clk_prepare_enable (pcie->pex_clk); +if (!dev->pm_domain) { + err =tegra_powergate_power_on (TEGRA_POWERGATE_PCIE );if (err) { -dev_err (dev,"failed to enable PEX clock: %d\n" , err); +dev_err (dev,"failed to power ungate: %d\n" , err); goto regulator_disable; } -reset_control_deassert (pcie->pex_rst); - }else { - err =tegra_powergate_sequence_power_up (TEGRA_POWERGATE_PCIE , - pcie->pex_clk, - pcie->pex_rst); + err =tegra_powergate_remove_clamping (TEGRA_POWERGATE_PCIE );if (err) { -dev_err (dev,"powerup sequence failed: %d\n" , err); - goto regulator_disable; +dev_err (dev,"failed to remove clamp: %d\n" , err); + goto powergate; } } -reset_control_deassert (pcie->afi_rst); - err =clk_prepare_enable (pcie->afi_clk);if (err <0 ) {dev_err (dev,"failed to enable AFI clock: %d\n" , err);@@ -1054,6 +1043,8 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie) goto disable_cml_clk; } +reset_control_deassert (pcie->afi_rst); +return 0 ; disable_cml_clk:@@ -1062,9 +1053,6 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie) disable_afi_clk:clk_disable_unprepare (pcie->afi_clk); powergate: -reset_control_assert (pcie->afi_rst); -reset_control_assert (pcie->pex_rst); -clk_disable_unprepare (pcie->pex_clk);if (!dev->pm_domain)tegra_powergate_power_off (TEGRA_POWERGATE_PCIE ); regulator_disable:@@ -2114,7 +2102,12 @@ static void tegra_pcie_enable_ports(struct tegra_pcie *pcie) port->index, port->lanes);tegra_pcie_port_enable (port); + } +/* Start LTSSM from Tegra side */ +reset_control_deassert (pcie->pcie_xrst); + +list_for_each_entry_safe (port, tmp, &pcie->ports, list) {if (tegra_pcie_port_check_link (port))continue ;@@ -2129,6 +2122,8 @@ static void tegra_pcie_disable_ports(struct tegra_pcie *pcie) {struct tegra_pcie_port *port, *tmp; +reset_control_assert (pcie->pcie_xrst); +list_for_each_entry_safe (port, tmp, &pcie->ports, list)tegra_pcie_port_disable (port); }@@ -2490,10 +2485,12 @@ static int __maybe_unused tegra_pcie_pm_suspend(struct device *dev)dev_err (dev,"failed to power off PHY(s): %d\n" , err); } +reset_control_assert (pcie->pex_rst); +clk_disable_unprepare (pcie->pex_clk); +if (IS_ENABLED (CONFIG_PCI_MSI ))tegra_pcie_disable_msi (pcie); -reset_control_assert (pcie->pcie_xrst);tegra_pcie_power_off (pcie);return 0 ;
drivers/pci/controller/pci-tegra.c static int __maybe_unused tegra_pcie_pm_resume(struct device *dev) · line 2520
Quoted 9 lines
drivers/pci/controller/pci-tegra.c +6
-0@@ -2515,11 +2512,18 @@ static int __maybe_unused tegra_pcie_pm_resume(struct device *dev)if (IS_ENABLED (CONFIG_PCI_MSI ))tegra_pcie_enable_msi (pcie); + err =clk_prepare_enable (pcie->pex_clk); +if (err) { +dev_err (dev,"failed to enable PEX clock: %d\n" , err); + goto poweroff; + } +reset_control_deassert (pcie->pex_rst);
Can you use a blank line after block statements for better readability? With that:
PATCH v2 6/28 PCI: tegra: Add PCIe Gen2 link speed support
In reply to Manikanta MaddireddyTegra124, Tegra132, Tegra210 and Tegra186 support Gen2 link speed. After PCIe link is up in Gen1, set target link speed as Gen2 and retrain link. Link switches to Gen2 speed if Gen2 capable end point is connected, else link stays in Gen1.
Per PCIe 4.0r0.9 sec 7.6.3.7 implementation note, driver need to wait for PCIe LTSSM to come back from recovery before retraining the link.
---
V2: Changed "for loop" to "while", to make it compact and handled coding style comments.
drivers/pci/controller/pci-tegra.c | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
drivers/pci/controller/pci-tegra.c +62 -0
@@ -191,6 +191,8 @@#define RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE 0x20000000#define RP_LINK_CONTROL_STATUS_LINKSTAT_MASK 0x3fff0000 +#define RP_LINK_CONTROL_STATUS_2 0x000000b0 +#define PADS_CTL_SEL 0x0000009c#define PADS_CTL 0x000000a0
@@ -226,6 +228,7 @@#define PADS_REFCLK_CFG_DRVI_SHIFT 12/* 15:12 */ #define PME_ACK_TIMEOUT 10000 +#define LINK_RETRAIN_TIMEOUT 100000/* in usec */ struct tegra_msi {struct msi_controller chip;
@@ -2092,6 +2095,62 @@ static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port)return false; } +static void tegra_pcie_change_link_speed (struct tegra_pcie *pcie) +{ +struct device *dev = pcie->dev; +struct tegra_pcie_port *port, *tmp; +ktime_t deadline; +u32 value; + +list_for_each_entry_safe (port, tmp, &pcie->ports, list) { +/* +* "Supported Link Speeds Vector" in "Link Capabilities 2" +* is not supported by Tegra. tegra_pcie_change_link_speed() +* is called only for Tegra chips which support Gen2. +* So there no harm if supported link speed is not verified. +*/ + value =readl (port->base +RP_LINK_CONTROL_STATUS_2 ); + value &= ~PCI_EXP_LNKSTA_CLS ; + value |=PCI_EXP_LNKSTA_CLS_5_0GB ; +writel (value, port->base +RP_LINK_CONTROL_STATUS_2 ); + +/* +* Poll until link comes back from recovery to avoid race +* condition. +*/ + deadline =ktime_add_us (ktime_get (),LINK_RETRAIN_TIMEOUT ); + +while (ktime_before (ktime_get (), deadline)) { + value =readl (port->base +RP_LINK_CONTROL_STATUS ); +if ((value &PCI_EXP_LNKSTA_LT ) ==0 ) +break ; + +usleep_range (2000 ,3000 ); + } +if (value &PCI_EXP_LNKSTA_LT ) +dev_warn (dev,"PCIe port %u link is in recovery\n" , + port->index); + +/* Retrain the link */ + value =readl (port->base +RP_LINK_CONTROL_STATUS ); + value |=PCI_EXP_LNKCTL_RL ; +writel (value, port->base +RP_LINK_CONTROL_STATUS ); + + deadline =ktime_add_us (ktime_get (),LINK_RETRAIN_TIMEOUT ); + +while (ktime_before (ktime_get (), deadline)) { + value =readl (port->base +RP_LINK_CONTROL_STATUS ); +if ((value &PCI_EXP_LNKSTA_LT ) ==0 ) +break ; + +usleep_range (2000 ,3000 ); + } +if (value &PCI_EXP_LNKSTA_LT ) +dev_err (dev,"failed to retrain link of port %u\n" , + port->index); + } +} +static void tegra_pcie_enable_ports (struct tegra_pcie *pcie) {struct device *dev = pcie->dev;
@@ -2116,6 +2175,9 @@ static void tegra_pcie_enable_ports(struct tegra_pcie *pcie)tegra_pcie_port_disable (port);tegra_pcie_port_free (port); } + +if (pcie->soc->has_gen2) +tegra_pcie_change_link_speed (pcie); }static void tegra_pcie_disable_ports (struct tegra_pcie *pcie)
Signature · 1 line
2.17.1
Re: [PATCH V2 06/28] PCI: tegra: Add PCIe Gen2 link speed support
On Tue, Apr 23, 2019 at 02:58:03PM +0530, Manikanta Maddireddy wrote:
[...]
Quoted 1 line
drivers/pci/controller/pci-tegra.c +0
-0
[...]
drivers/pci/controller/pci-tegra.c static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port) · line 2132
Quoted 10 lines
drivers/pci/controller/pci-tegra.c +10
-0+while (ktime_before (ktime_get (), deadline)) { + value =readl (port->base +RP_LINK_CONTROL_STATUS ); +if ((value &PCI_EXP_LNKSTA_LT ) ==0 ) +break ; + +usleep_range (2000 ,3000 ); + } +if (value &PCI_EXP_LNKSTA_LT ) +dev_warn (dev,"PCIe port %u link is in recovery\n" , + port->index);
Blank line between "}" and "if (...)" for readability.
drivers/pci/controller/pci-tegra.c static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port) · line 2150
Quoted 10 lines
drivers/pci/controller/pci-tegra.c +10
-0+while (ktime_before (ktime_get (), deadline)) { + value =readl (port->base +RP_LINK_CONTROL_STATUS ); +if ((value &PCI_EXP_LNKSTA_LT ) ==0 ) +break ; + +usleep_range (2000 ,3000 ); + } +if (value &PCI_EXP_LNKSTA_LT ) +dev_err (dev,"failed to retrain link of port %u\n" , + port->index);
Same here.
With that:
PATCH v2 7/28 PCI: tegra: Advertise PCIe Advanced Error Reporting (AER) capability
In reply to Manikanta MaddireddyDefault root port setting hides AER capability. This patch enables the advertisement of AER capability by root port.
---
V2: No change
drivers/pci/controller/pci-tegra.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/pci/controller/pci-tegra.c +15 -0
@@ -180,6 +180,9 @@#define RP_VEND_XP 0x00000f00#define RP_VEND_XP_DL_UP (1 << 30) +#define RP_VEND_CTL1 0x00000f48 +#define RP_VEND_CTL1_ERPT (1 << 13) +#define RP_VEND_CTL2 0x00000fa8#define RP_VEND_CTL2_PCA_ENABLE (1 << 7)
@@ -479,6 +482,16 @@ static void tegra_pcie_port_reset(struct tegra_pcie_port *port)afi_writel (port->pcie, value, ctrl); } +static void tegra_pcie_enable_rp_features (struct tegra_pcie_port *port) +{ +u32 value; + +/* Enable AER capability */ + value =readl (port->base +RP_VEND_CTL1 ); + value |=RP_VEND_CTL1_ERPT ; +writel (value, port->base +RP_VEND_CTL1 ); +} +static void tegra_pcie_port_enable (struct tegra_pcie_port *port) {unsigned long ctrl =tegra_pcie_port_get_pex_ctrl (port);
@@ -503,6 +516,8 @@ static void tegra_pcie_port_enable(struct tegra_pcie_port *port) value |=RP_VEND_CTL2_PCA_ENABLE ;writel (value, port->base +RP_VEND_CTL2 ); } + +tegra_pcie_enable_rp_features (port); }static void tegra_pcie_port_disable (struct tegra_pcie_port *port)
Signature · 1 line
2.17.1
Re: [PATCH V2 07/28] PCI: tegra: Advertise PCIe Advanced Error Reporting (AER) capability
Quoted 9 lines · Manikanta Maddireddy
Default root port setting hides AER capability. This patch enables the advertisement of AER capability by root port.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: No changedrivers/pci/controller/pci-tegra.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
PATCH v2 8/28 PCI: tegra: Program UPHY electrical settings for Tegra210
In reply to Manikanta MaddireddyUPHY electrical programming guidelines are documented in Tegra210 TRM. Program these electrical settings for proper eye diagram in Gen1 and Gen2 link speeds.
---
V2: Addressed coding style comments
drivers/pci/controller/pci-tegra.c | 107 +++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+)
drivers/pci/controller/pci-tegra.c +107 -0
@@ -177,6 +177,32 @@#define AFI_PEXBIAS_CTRL_0 0x168 +#define RP_ECTL_2_R1 0x00000e84 +#define RP_ECTL_2_R1_RX_CTLE_1C_MASK 0xffff + +#define RP_ECTL_4_R1 0x00000e8c +#define RP_ECTL_4_R1_RX_CDR_CTRL_1C_MASK (0xffff << 16) +#define RP_ECTL_4_R1_RX_CDR_CTRL_1C_SHIFT 16 + +#define RP_ECTL_5_R1 0x00000e90 +#define RP_ECTL_5_R1_RX_EQ_CTRL_L_1C_MASK 0xffffffff + +#define RP_ECTL_6_R1 0x00000e94 +#define RP_ECTL_6_R1_RX_EQ_CTRL_H_1C_MASK 0xffffffff + +#define RP_ECTL_2_R2 0x00000ea4 +#define RP_ECTL_2_R2_RX_CTLE_1C_MASK 0xffff + +#define RP_ECTL_4_R2 0x00000eac +#define RP_ECTL_4_R2_RX_CDR_CTRL_1C_MASK (0xffff << 16) +#define RP_ECTL_4_R2_RX_CDR_CTRL_1C_SHIFT 16 + +#define RP_ECTL_5_R2 0x00000eb0 +#define RP_ECTL_5_R2_RX_EQ_CTRL_L_1C_MASK 0xffffffff + +#define RP_ECTL_6_R2 0x00000eb4 +#define RP_ECTL_6_R2_RX_EQ_CTRL_H_1C_MASK 0xffffffff +#define RP_VEND_XP 0x00000f00#define RP_VEND_XP_DL_UP (1 << 30)
@@ -266,6 +292,19 @@ struct tegra_pcie_soc {bool has_gen2;bool force_pca_enable;bool program_uphy; +struct { +struct { +u32 rp_ectl_2_r1; +u32 rp_ectl_4_r1; +u32 rp_ectl_5_r1; +u32 rp_ectl_6_r1; +u32 rp_ectl_2_r2; +u32 rp_ectl_4_r2; +u32 rp_ectl_5_r2; +u32 rp_ectl_6_r2; + } regs; +bool enable; + } ectl; };static inline struct tegra_msi *to_tegra_msi (struct msi_controller *chip)
@@ -492,6 +531,54 @@ static void tegra_pcie_enable_rp_features(struct tegra_pcie_port *port)writel (value, port->base +RP_VEND_CTL1 ); } +static void tegra_pcie_program_ectl_settings (struct tegra_pcie_port *port) +{ +const struct tegra_pcie_soc *soc = port->pcie->soc; +u32 value; + + value =readl (port->base +RP_ECTL_2_R1 ); + value &= ~RP_ECTL_2_R1_RX_CTLE_1C_MASK ; + value |= soc->ectl.regs.rp_ectl_2_r1; +writel (value, port->base +RP_ECTL_2_R1 ); + + value =readl (port->base +RP_ECTL_4_R1 ); + value &= ~RP_ECTL_4_R1_RX_CDR_CTRL_1C_MASK ; + value |= soc->ectl.regs.rp_ectl_4_r1 << +RP_ECTL_4_R1_RX_CDR_CTRL_1C_SHIFT ; +writel (value, port->base +RP_ECTL_4_R1 ); + + value =readl (port->base +RP_ECTL_5_R1 ); + value &= ~RP_ECTL_5_R1_RX_EQ_CTRL_L_1C_MASK ; + value |= soc->ectl.regs.rp_ectl_5_r1; +writel (value, port->base +RP_ECTL_5_R1 ); + + value =readl (port->base +RP_ECTL_6_R1 ); + value &= ~RP_ECTL_6_R1_RX_EQ_CTRL_H_1C_MASK ; + value |= soc->ectl.regs.rp_ectl_6_r1; +writel (value, port->base +RP_ECTL_6_R1 ); + + value =readl (port->base +RP_ECTL_2_R2 ); + value &= ~RP_ECTL_2_R2_RX_CTLE_1C_MASK ; + value |= soc->ectl.regs.rp_ectl_2_r2; +writel (value, port->base +RP_ECTL_2_R2 ); + + value =readl (port->base +RP_ECTL_4_R2 ); + value &= ~RP_ECTL_4_R2_RX_CDR_CTRL_1C_MASK ; + value |= soc->ectl.regs.rp_ectl_4_r2 << +RP_ECTL_4_R2_RX_CDR_CTRL_1C_SHIFT ; +writel (value, port->base +RP_ECTL_4_R2 ); + + value =readl (port->base +RP_ECTL_5_R2 ); + value &= ~RP_ECTL_5_R2_RX_EQ_CTRL_L_1C_MASK ; + value |= soc->ectl.regs.rp_ectl_5_r2; +writel (value, port->base +RP_ECTL_5_R2 ); + + value =readl (port->base +RP_ECTL_6_R2 ); + value &= ~RP_ECTL_6_R2_RX_EQ_CTRL_H_1C_MASK ; + value |= soc->ectl.regs.rp_ectl_6_r2; +writel (value, port->base +RP_ECTL_6_R2 ); +} +static void tegra_pcie_port_enable (struct tegra_pcie_port *port) {unsigned long ctrl =tegra_pcie_port_get_pex_ctrl (port);
@@ -518,6 +605,9 @@ static void tegra_pcie_port_enable(struct tegra_pcie_port *port) }tegra_pcie_enable_rp_features (port); + +if (soc->ectl.enable) +tegra_pcie_program_ectl_settings (port); }static void tegra_pcie_port_disable (struct tegra_pcie_port *port)
@@ -2224,6 +2314,7 @@ static const struct tegra_pcie_soc tegra20_pcie = { .has_gen2 = false, .force_pca_enable = false, .program_uphy = true, + .ectl.enable = false, };static const struct tegra_pcie_port_soc tegra30_pcie_ports[] = {
@@ -2247,6 +2338,7 @@ static const struct tegra_pcie_soc tegra30_pcie = { .has_gen2 = false, .force_pca_enable = false, .program_uphy = true, + .ectl.enable = false, };static const struct tegra_pcie_soc tegra124_pcie = {
@@ -2263,6 +2355,7 @@ static const struct tegra_pcie_soc tegra124_pcie = { .has_gen2 = true, .force_pca_enable = false, .program_uphy = true, + .ectl.enable = false, };static const struct tegra_pcie_soc tegra210_pcie = {
@@ -2279,6 +2372,19 @@ static const struct tegra_pcie_soc tegra210_pcie = { .has_gen2 = true, .force_pca_enable = true, .program_uphy = true, + .ectl = { + .regs = { + .rp_ectl_2_r1 = 0x0000000f, + .rp_ectl_4_r1 = 0x00000067, + .rp_ectl_5_r1 = 0x55010000, + .rp_ectl_6_r1 = 0x00000001, + .rp_ectl_2_r2 = 0x0000008f, + .rp_ectl_4_r2 = 0x000000c7, + .rp_ectl_5_r2 = 0x55010000, + .rp_ectl_6_r2 = 0x00000001, + }, + .enable = true, + }, };static const struct tegra_pcie_port_soc tegra186_pcie_ports[] = {
@@ -2302,6 +2408,7 @@ static const struct tegra_pcie_soc tegra186_pcie = { .has_gen2 = true, .force_pca_enable = false, .program_uphy = false, + .ectl.enable = false, };static const struct of_device_id tegra_pcie_of_match[] = {
Signature · 1 line
2.17.1
Re: [PATCH V2 08/28] PCI: tegra: Program UPHY electrical settings for Tegra210
Quoted 10 lines · Manikanta Maddireddy
UPHY electrical programming guidelines are documented in Tegra210 TRM. Program these electrical settings for proper eye diagram in Gen1 and Gen2 link speeds.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Addressed coding style commentsdrivers/pci/controller/pci-tegra.c | 107 +++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+)
PATCH v2 9/28 PCI: tegra: Enable opportunistic UpdateFC and ACK
In reply to Manikanta MaddireddyEnable opportunistic UpdateFC and ACK to allow data link layer send pending ACKs and UpdateFC packets when link is idle instead of waiting for timers to expire. This improves the PCIe performance due to better utilization of PCIe bandwidth.
---
V2: No change
drivers/pci/controller/pci-tegra.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/pci/controller/pci-tegra.c +9 -1
@@ -204,7 +204,9 @@#define RP_ECTL_6_R2_RX_EQ_CTRL_H_1C_MASK 0xffffffff#define RP_VEND_XP 0x00000f00 -#define RP_VEND_XP_DL_UP (1 << 30) +#define RP_VEND_XP_DL_UP (1 << 30) +#define RP_VEND_XP_OPPORTUNISTIC_ACK (1 << 27) +#define RP_VEND_XP_OPPORTUNISTIC_UPDATEFC (1 << 28)#define RP_VEND_CTL1 0x00000f48#define RP_VEND_CTL1_ERPT (1 << 13)
@@ -529,6 +531,12 @@ static void tegra_pcie_enable_rp_features(struct tegra_pcie_port *port) value =readl (port->base +RP_VEND_CTL1 ); value |=RP_VEND_CTL1_ERPT ;writel (value, port->base +RP_VEND_CTL1 ); + +/* Optimal settings to enhance bandwidth */ + value =readl (port->base +RP_VEND_XP ); + value |=RP_VEND_XP_OPPORTUNISTIC_ACK ; + value |=RP_VEND_XP_OPPORTUNISTIC_UPDATEFC ; +writel (value, port->base +RP_VEND_XP ); }static void tegra_pcie_program_ectl_settings (struct tegra_pcie_port *port)
Signature · 1 line
2.17.1
PATCH v2 10/28 PCI: tegra: Disable AFI dynamic clock gating
In reply to Manikanta MaddireddyOutstanding write counter in AFI is used to generate idle signal to dynamically gate the AFI clock. When there are 32 outstanding writes from AFI to memory, the outstanding write counter overflows and indicates that there are "0" outstanding write transactions.
When memory controller is under heavy load, write completions to AFI gets delayed and AFI write counter overflows. This causes AFI clock gating even when there are outstanding transactions towards memory controller resulting in system hang.
Disable dynamic clock gating of AFI clock to avoid system hang.
CLKEN_OVERRIDE bit is not defined in Tegra20 and Tegra30, however programming this bit doesn't cause any side effects. Program this bit for all Tegra SoCs to avoid conditional check.
---
V2: No change
drivers/pci/controller/pci-tegra.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-tegra.c +4 -2
@@ -95,7 +95,8 @@#define AFI_MSI_EN_VEC7 0xa8#define AFI_CONFIGURATION 0xac -#define AFI_CONFIGURATION_EN_FPCI (1 << 0) +#define AFI_CONFIGURATION_EN_FPCI (1 << 0) +#define AFI_CONFIGURATION_CLKEN_OVERRIDE (1 << 31)#define AFI_FPCI_ERROR_MASKS 0xb0
@@ -1065,9 +1066,10 @@ static void tegra_pcie_enable_controller(struct tegra_pcie *pcie)afi_writel (pcie, value,AFI_FUSE ); } -/* finally enable PCIe */ +/* Disable AFI dynamic clock gating and enable PCIe */ value =afi_readl (pcie,AFI_CONFIGURATION ); value |=AFI_CONFIGURATION_EN_FPCI ; + value |=AFI_CONFIGURATION_CLKEN_OVERRIDE ;afi_writel (pcie, value,AFI_CONFIGURATION ); value = AFI_INTR_EN_INI_SLVERR | AFI_INTR_EN_INI_DECERR |
Signature · 1 line
2.17.1
PATCH v2 11/28 PCI: tegra: Process pending DLL transactions before entering L1 or L2
In reply to Manikanta MaddireddyPM message are truncated while entering L1 or L2, which is resulting in receiver errors. Set the required bit to finish processing DLLP before link enter L1 or L2.
---
V2: No change
drivers/pci/controller/pci-tegra.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/pci/controller/pci-tegra.c +11 -0
@@ -212,6 +212,9 @@#define RP_VEND_CTL1 0x00000f48#define RP_VEND_CTL1_ERPT (1 << 13) +#define RP_VEND_XP_BIST 0x00000f4c +#define RP_VEND_XP_BIST_GOTO_L1_L2_AFTER_DLLP_DONE (1 << 28) +#define RP_VEND_CTL2 0x00000fa8#define RP_VEND_CTL2_PCA_ENABLE (1 << 7)
@@ -538,6 +541,14 @@ static void tegra_pcie_enable_rp_features(struct tegra_pcie_port *port) value |=RP_VEND_XP_OPPORTUNISTIC_ACK ; value |=RP_VEND_XP_OPPORTUNISTIC_UPDATEFC ;writel (value, port->base +RP_VEND_XP ); + +/* +* LTSSM will wait for DLLP to finish before entering L1 or L2, +* to avoid truncation of PM messages which results in receiver errors +*/ + value =readl (port->base +RP_VEND_XP_BIST ); + value |=RP_VEND_XP_BIST_GOTO_L1_L2_AFTER_DLLP_DONE ; +writel (value, port->base +RP_VEND_XP_BIST ); }static void tegra_pcie_program_ectl_settings (struct tegra_pcie_port *port)
Signature · 1 line
2.17.1
PATCH v2 12/28 PCI: tegra: Enable PCIe xclk clock clamping
In reply to Manikanta MaddireddyEnable xclk clock clamping when entering L1. Clamp threshold will determine the time spent waiting for clock module to turn on xclk after signaling it. Default threshold value in Tegra124 and Tegra210 is not enough to turn on xclk clock. Increase the clamp threshold to meet the clock module timing in Tegra124 and Tegra210. Default threshold value is enough in Tegra20, Tegra30 and Tegra186.
---
V2: Took care of typos in commit log and coding style comments.
drivers/pci/controller/pci-tegra.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-tegra.c +28 -2
@@ -219,8 +219,14 @@#define RP_VEND_CTL2_PCA_ENABLE (1 << 7)#define RP_PRIV_MISC 0x00000fe0 -#define RP_PRIV_MISC_PRSNT_MAP_EP_PRSNT (0xe << 0) -#define RP_PRIV_MISC_PRSNT_MAP_EP_ABSNT (0xf << 0) +#define RP_PRIV_MISC_PRSNT_MAP_EP_PRSNT (0xe << 0) +#define RP_PRIV_MISC_PRSNT_MAP_EP_ABSNT (0xf << 0) +#define RP_PRIV_MISC_CTLR_CLK_CLAMP_THRESHOLD_MASK (0x7f << 16) +#define RP_PRIV_MISC_CTLR_CLK_CLAMP_THRESHOLD (0xf << 16) +#define RP_PRIV_MISC_CTLR_CLK_CLAMP_ENABLE (1 << 23) +#define RP_PRIV_MISC_TMS_CLK_CLAMP_THRESHOLD_MASK (0x7f << 24) +#define RP_PRIV_MISC_TMS_CLK_CLAMP_THRESHOLD (0xf << 24) +#define RP_PRIV_MISC_TMS_CLK_CLAMP_ENABLE (1 << 31)#define RP_LINK_CONTROL_STATUS 0x00000090#define RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE 0x20000000
@@ -298,6 +304,7 @@ struct tegra_pcie_soc {bool has_gen2;bool force_pca_enable;bool program_uphy; +bool update_clamp_threshold; struct { struct { u32 rp_ectl_2_r1;
@@ -529,6 +536,7 @@ static void tegra_pcie_port_reset(struct tegra_pcie_port *port)static void tegra_pcie_enable_rp_features (struct tegra_pcie_port *port) { +const struct tegra_pcie_soc *soc = port->pcie->soc;u32 value;/* Enable AER capability */
@@ -549,6 +557,19 @@ static void tegra_pcie_enable_rp_features(struct tegra_pcie_port *port) value =readl (port->base +RP_VEND_XP_BIST ); value |=RP_VEND_XP_BIST_GOTO_L1_L2_AFTER_DLLP_DONE ;writel (value, port->base +RP_VEND_XP_BIST ); + + value =readl (port->base +RP_PRIV_MISC ); + value |=RP_PRIV_MISC_CTLR_CLK_CLAMP_ENABLE ; + value |=RP_PRIV_MISC_TMS_CLK_CLAMP_ENABLE ; + +if (soc->update_clamp_threshold) { + value &= ~(RP_PRIV_MISC_CTLR_CLK_CLAMP_THRESHOLD_MASK | +RP_PRIV_MISC_TMS_CLK_CLAMP_THRESHOLD_MASK ); + value |=RP_PRIV_MISC_CTLR_CLK_CLAMP_THRESHOLD | +RP_PRIV_MISC_TMS_CLK_CLAMP_THRESHOLD ; + } + +writel (value, port->base +RP_PRIV_MISC ); }static void tegra_pcie_program_ectl_settings (struct tegra_pcie_port *port)
@@ -2335,6 +2356,7 @@ static const struct tegra_pcie_soc tegra20_pcie = { .has_gen2 = false, .force_pca_enable = false, .program_uphy = true, + .update_clamp_threshold = false, .ectl.enable = false, };
@@ -2359,6 +2381,7 @@ static const struct tegra_pcie_soc tegra30_pcie = { .has_gen2 = false, .force_pca_enable = false, .program_uphy = true, + .update_clamp_threshold = false, .ectl.enable = false, };
@@ -2376,6 +2399,7 @@ static const struct tegra_pcie_soc tegra124_pcie = { .has_gen2 = true, .force_pca_enable = false, .program_uphy = true, + .update_clamp_threshold = true, .ectl.enable = false, };
@@ -2393,6 +2417,7 @@ static const struct tegra_pcie_soc tegra210_pcie = { .has_gen2 = true, .force_pca_enable = true, .program_uphy = true, + .update_clamp_threshold = true, .ectl = { .regs = { .rp_ectl_2_r1 = 0x0000000f,
@@ -2429,6 +2454,7 @@ static const struct tegra_pcie_soc tegra186_pcie = { .has_gen2 = true, .force_pca_enable = false, .program_uphy = false, + .update_clamp_threshold = false, .ectl.enable = false, };
Signature · 1 line
2.17.1
Re: [PATCH V2 12/28] PCI: tegra: Enable PCIe xclk clock clamping
Quoted 7 lines · Manikanta Maddireddy
Enable xclk clock clamping when entering L1. Clamp threshold will determine the time spent waiting for clock module to turn on xclk after signaling it. Default threshold value in Tegra124 and Tegra210 is not enough to turn on xclk clock. Increase the clamp threshold to meet the clock module timing in Tegra124 and Tegra210. Default threshold value is enough in Tegra20, Tegra30 and Tegra186.
Quoted 6 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Took care of typos in commit log and coding style comments.drivers/pci/controller/pci-tegra.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
PATCH v2 13/28 PCI: tegra: Increase the deskew retry time
In reply to Manikanta MaddireddySometimes link speed change from Gen2 to Gen1 fails due to instability in deskew logic on lane-0 in Tegra210. Increase the deskew retry time to resolve this issue.
---
V2: Took care of typos in commit log and coding style comments.
drivers/pci/controller/pci-tegra.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/pci/controller/pci-tegra.c +30 -0
@@ -209,6 +209,10 @@#define RP_VEND_XP_OPPORTUNISTIC_ACK (1 << 27)#define RP_VEND_XP_OPPORTUNISTIC_UPDATEFC (1 << 28) +#define RP_VEND_CTL0 0x00000f44 +#define RP_VEND_CTL0_DSK_RST_PULSE_WIDTH_MASK (0xf << 12) +#define RP_VEND_CTL0_DSK_RST_PULSE_WIDTH (0x9 << 12) +#define RP_VEND_CTL1 0x00000f48#define RP_VEND_CTL1_ERPT (1 << 13)
@@ -305,6 +309,7 @@ struct tegra_pcie_soc {bool force_pca_enable;bool program_uphy;bool update_clamp_threshold; +bool program_deskew_time; struct { struct { u32 rp_ectl_2_r1;
@@ -620,6 +625,24 @@ static void tegra_pcie_program_ectl_settings(struct tegra_pcie_port *port)writel (value, port->base +RP_ECTL_6_R2 ); } +static void tegra_pcie_apply_sw_fixup (struct tegra_pcie_port *port) +{ +const struct tegra_pcie_soc *soc = port->pcie->soc; +u32 value; + +/* +* Sometimes link speed change from Gen2 to Gen1 fails due to +* instability in deskew logic on lane-0. Increase the deskew +* retry time to resolve this issue. +*/ +if (soc->program_deskew_time) { + value =readl (port->base +RP_VEND_CTL0 ); + value &= ~RP_VEND_CTL0_DSK_RST_PULSE_WIDTH_MASK ; + value |=RP_VEND_CTL0_DSK_RST_PULSE_WIDTH ; +writel (value, port->base +RP_VEND_CTL0 ); + } +} +static void tegra_pcie_port_enable (struct tegra_pcie_port *port) {unsigned long ctrl =tegra_pcie_port_get_pex_ctrl (port);
@@ -649,6 +672,8 @@ static void tegra_pcie_port_enable(struct tegra_pcie_port *port)if (soc->ectl.enable)tegra_pcie_program_ectl_settings (port); + +tegra_pcie_apply_sw_fixup (port); }static void tegra_pcie_port_disable (struct tegra_pcie_port *port)
@@ -2357,6 +2382,7 @@ static const struct tegra_pcie_soc tegra20_pcie = { .force_pca_enable = false, .program_uphy = true, .update_clamp_threshold = false, + .program_deskew_time = false, .ectl.enable = false, };
@@ -2382,6 +2408,7 @@ static const struct tegra_pcie_soc tegra30_pcie = { .force_pca_enable = false, .program_uphy = true, .update_clamp_threshold = false, + .program_deskew_time = false, .ectl.enable = false, };
@@ -2400,6 +2427,7 @@ static const struct tegra_pcie_soc tegra124_pcie = { .force_pca_enable = false, .program_uphy = true, .update_clamp_threshold = true, + .program_deskew_time = false, .ectl.enable = false, };
@@ -2418,6 +2446,7 @@ static const struct tegra_pcie_soc tegra210_pcie = { .force_pca_enable = true, .program_uphy = true, .update_clamp_threshold = true, + .program_deskew_time = true, .ectl = { .regs = { .rp_ectl_2_r1 = 0x0000000f,
@@ -2455,6 +2484,7 @@ static const struct tegra_pcie_soc tegra186_pcie = { .force_pca_enable = false, .program_uphy = false, .update_clamp_threshold = false, + .program_deskew_time = false, .ectl.enable = false, };
Signature · 1 line
2.17.1
Re: [PATCH V2 13/28] PCI: tegra: Increase the deskew retry time
Quoted 10 lines · Manikanta Maddireddy
Sometimes link speed change from Gen2 to Gen1 fails due to instability in deskew logic on lane-0 in Tegra210. Increase the deskew retry time to resolve this issue.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Took care of typos in commit log and coding style comments.drivers/pci/controller/pci-tegra.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
PATCH v2 14/28 PCI: tegra: Add SW fixup for RAW violations
In reply to Manikanta MaddireddyThe logic which blocks read requests till AFI gets ACK for all outstanding writes from memory controller does not behave correctly when number of outstanding writes become more than 32 in Tegra124 and Tegra132.
SW fixup is to prevent writes from accumulating more than 32 by,
- limiting outstanding posted writes to 14
- modifying Gen1 and Gen2 UpdateFC timer frequency
UpdateFC timer frequency is equal to twice the value of register content in nsec. These settings are recommended after stress testing with different values.
---
V2: Changed update_fc_val to update_fc_threshold
drivers/pci/controller/pci-tegra.c | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/pci/controller/pci-tegra.c +34 -0
@@ -178,6 +178,13 @@#define AFI_PEXBIAS_CTRL_0 0x168 +#define RP_PRIV_XP_DL 0x00000494 +#define RP_PRIV_XP_DL_GEN2_UPD_FC_TSHOLD (0x1ff << 1) + +#define RP_RX_HDR_LIMIT 0x00000e00 +#define RP_RX_HDR_LIMIT_PW_MASK (0xff << 8) +#define RP_RX_HDR_LIMIT_PW (0x0e << 8) +#define RP_ECTL_2_R1 0x00000e84#define RP_ECTL_2_R1_RX_CTLE_1C_MASK 0xffff
@@ -208,6 +215,7 @@#define RP_VEND_XP_DL_UP (1 << 30)#define RP_VEND_XP_OPPORTUNISTIC_ACK (1 << 27)#define RP_VEND_XP_OPPORTUNISTIC_UPDATEFC (1 << 28) +#define RP_VEND_XP_UPDATE_FC_THRESHOLD_MASK (0xff << 18)#define RP_VEND_CTL0 0x00000f44#define RP_VEND_CTL0_DSK_RST_PULSE_WIDTH_MASK (0xf << 12)
@@ -301,6 +309,7 @@ struct tegra_pcie_soc {u32 tx_ref_sel;u32 pads_refclk_cfg0;u32 pads_refclk_cfg1; +u32 update_fc_threshold;bool has_pex_clkreq_en;bool has_pex_bias_ctrl;bool has_intr_prsnt_sense;
@@ -310,6 +319,7 @@ struct tegra_pcie_soc {bool program_uphy;bool update_clamp_threshold;bool program_deskew_time; +bool raw_violation_fixup; struct { struct { u32 rp_ectl_2_r1;
@@ -641,6 +651,23 @@ static void tegra_pcie_apply_sw_fixup(struct tegra_pcie_port *port) value |=RP_VEND_CTL0_DSK_RST_PULSE_WIDTH ;writel (value, port->base +RP_VEND_CTL0 ); } + +/* Fixup for read after write violation. */ +if (soc->raw_violation_fixup) { + value =readl (port->base +RP_RX_HDR_LIMIT ); + value &= ~RP_RX_HDR_LIMIT_PW_MASK ; + value |=RP_RX_HDR_LIMIT_PW ; +writel (value, port->base +RP_RX_HDR_LIMIT ); + + value =readl (port->base +RP_PRIV_XP_DL ); + value |=RP_PRIV_XP_DL_GEN2_UPD_FC_TSHOLD ; +writel (value, port->base +RP_PRIV_XP_DL ); + + value =readl (port->base +RP_VEND_XP ); + value &= ~RP_VEND_XP_UPDATE_FC_THRESHOLD_MASK ; + value |= soc->update_fc_threshold; +writel (value, port->base +RP_VEND_XP ); + } }static void tegra_pcie_port_enable (struct tegra_pcie_port *port)
@@ -2383,6 +2410,7 @@ static const struct tegra_pcie_soc tegra20_pcie = { .program_uphy = true, .update_clamp_threshold = false, .program_deskew_time = false, + .raw_violation_fixup = false, .ectl.enable = false, };
@@ -2409,6 +2437,7 @@ static const struct tegra_pcie_soc tegra30_pcie = { .program_uphy = true, .update_clamp_threshold = false, .program_deskew_time = false, + .raw_violation_fixup = false, .ectl.enable = false, };
@@ -2419,6 +2448,8 @@ static const struct tegra_pcie_soc tegra124_pcie = { .pads_pll_ctl = PADS_PLL_CTL_TEGRA30, .tx_ref_sel = PADS_PLL_CTL_TXCLKREF_BUF_EN, .pads_refclk_cfg0 = 0x44ac44ac, +/* FC threshold is bit[25:18] */ + .update_fc_threshold = 0x03fc0000, .has_pex_clkreq_en = true, .has_pex_bias_ctrl = true, .has_intr_prsnt_sense = true,
@@ -2428,6 +2459,7 @@ static const struct tegra_pcie_soc tegra124_pcie = { .program_uphy = true, .update_clamp_threshold = true, .program_deskew_time = false, + .raw_violation_fixup = true, .ectl.enable = false, };
@@ -2447,6 +2479,7 @@ static const struct tegra_pcie_soc tegra210_pcie = { .program_uphy = true, .update_clamp_threshold = true, .program_deskew_time = true, + .raw_violation_fixup = false, .ectl = { .regs = { .rp_ectl_2_r1 = 0x0000000f,
@@ -2485,6 +2518,7 @@ static const struct tegra_pcie_soc tegra186_pcie = { .program_uphy = false, .update_clamp_threshold = false, .program_deskew_time = false, + .raw_violation_fixup = false, .ectl.enable = false, };
Signature · 1 line
2.17.1
Re: [PATCH V2 14/28] PCI: tegra: Add SW fixup for RAW violations
Quoted 12 lines · Manikanta Maddireddy
The logic which blocks read requests till AFI gets ACK for all outstanding writes from memory controller does not behave correctly when number of outstanding writes become more than 32 in Tegra124 and Tegra132.
SW fixup is to prevent writes from accumulating more than 32 by,
- limiting outstanding posted writes to 14
- modifying Gen1 and Gen2 UpdateFC timer frequencyUpdateFC timer frequency is equal to twice the value of register content in nsec. These settings are recommended after stress testing with different values.
Quoted 6 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Changedupdate_fc_valtoupdate_fc_thresholddrivers/pci/controller/pci-tegra.c | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
PATCH v2 15/28 PCI: tegra: Update flow control timer frequency in Tegra210
In reply to Manikanta MaddireddyRecommended UpdateFC threshold in Tegra210 is 0x60 for best performance of x1 link. Setting this to 0x60 provides the best balance between number of UpdateFC packets and read data sent over the link.
UpdateFC timer frequency is equal to twice the value of register content in nsec, i.e (2 * 0x60) = 192 nsec.
---
V2: Changed update_fc_val to update_fc_threshold
drivers/pci/controller/pci-tegra.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/pci/controller/pci-tegra.c +15 -0
@@ -320,6 +320,7 @@ struct tegra_pcie_soc {bool update_clamp_threshold;bool program_deskew_time;bool raw_violation_fixup; +bool update_fc_timer; struct { struct { u32 rp_ectl_2_r1;
@@ -668,6 +669,13 @@ static void tegra_pcie_apply_sw_fixup(struct tegra_pcie_port *port) value |= soc->update_fc_threshold;writel (value, port->base +RP_VEND_XP ); } + +if (soc->update_fc_timer) { + value =readl (port->base +RP_VEND_XP ); + value &= ~RP_VEND_XP_UPDATE_FC_THRESHOLD_MASK ; + value |= soc->update_fc_threshold; +writel (value, port->base +RP_VEND_XP ); + } }static void tegra_pcie_port_enable (struct tegra_pcie_port *port)
@@ -2411,6 +2419,7 @@ static const struct tegra_pcie_soc tegra20_pcie = { .update_clamp_threshold = false, .program_deskew_time = false, .raw_violation_fixup = false, + .update_fc_timer = false, .ectl.enable = false, };
@@ -2438,6 +2447,7 @@ static const struct tegra_pcie_soc tegra30_pcie = { .update_clamp_threshold = false, .program_deskew_time = false, .raw_violation_fixup = false, + .update_fc_timer = false, .ectl.enable = false, };
@@ -2460,6 +2470,7 @@ static const struct tegra_pcie_soc tegra124_pcie = { .update_clamp_threshold = true, .program_deskew_time = false, .raw_violation_fixup = true, + .update_fc_timer = false, .ectl.enable = false, };
@@ -2470,6 +2481,8 @@ static const struct tegra_pcie_soc tegra210_pcie = { .pads_pll_ctl = PADS_PLL_CTL_TEGRA30, .tx_ref_sel = PADS_PLL_CTL_TXCLKREF_BUF_EN, .pads_refclk_cfg0 = 0x90b890b8, +/* FC threshold is bit[25:18] */ + .update_fc_threshold = 0x01800000, .has_pex_clkreq_en = true, .has_pex_bias_ctrl = true, .has_intr_prsnt_sense = true,
@@ -2480,6 +2493,7 @@ static const struct tegra_pcie_soc tegra210_pcie = { .update_clamp_threshold = true, .program_deskew_time = true, .raw_violation_fixup = false, + .update_fc_timer = true, .ectl = { .regs = { .rp_ectl_2_r1 = 0x0000000f,
@@ -2519,6 +2533,7 @@ static const struct tegra_pcie_soc tegra186_pcie = { .update_clamp_threshold = false, .program_deskew_time = false, .raw_violation_fixup = false, + .update_fc_timer = false, .ectl.enable = false, };
Signature · 1 line
2.17.1
Re: [PATCH V2 15/28] PCI: tegra: Update flow control timer frequency in Tegra210
Quoted 7 lines · Manikanta Maddireddy
Recommended UpdateFC threshold in Tegra210 is
0x60for best performance of x1 link. Setting this to0x60provides the best balance between number of UpdateFC packets and read data sent over the link.UpdateFC timer frequency is equal to twice the value of register content in nsec, i.e (2 *
0x60) = 192 nsec.
Quoted 6 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Changedupdate_fc_valtoupdate_fc_thresholddrivers/pci/controller/pci-tegra.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
PATCH v2 16/28 PCI: tegra: Set target speed as Gen1 before starting LTSSM
In reply to Manikanta MaddireddyPCIe link up fails with few legacy endpoints if root port advertises both Gen-1 and Gen-2 speeds in Tegra. This is because link number negotiation fails if both Gen1 & Gen2 are advertised. Tegra doesn't retry link up by advertising only Gen1. Hence, the strategy followed here is to initially advertise only Gen-1 and after link is up, retrain link to Gen-2 speed.
Tegra doesn't support HW autonomous speed change. Link comes up in Gen1 even if Gen2 is advertised, so there is no downside of this change.
This behavior is observed with following two PCIe devices on Tegra,
- Fusion HDTV 5 Express card
- IOGear SIL - PCIE - SATA card
---
V2: Updated commit log to reflect why this issue is observed on Tegra with these particular cards
drivers/pci/controller/pci-tegra.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/pci/controller/pci-tegra.c +11 -0
@@ -676,6 +676,17 @@ static void tegra_pcie_apply_sw_fixup(struct tegra_pcie_port *port) value |= soc->update_fc_threshold;writel (value, port->base +RP_VEND_XP ); } + +/* +* PCIe link doesn't come up with few legacy PCIe endpoints if +* root port advertises both Gen-1 and Gen-2 speeds in Tegra. +* Hence, the strategy followed here is to initially advertise +* only Gen-1 and after link is up, retrain link to Gen-2 speed +*/ + value =readl (port->base +RP_LINK_CONTROL_STATUS_2 ); + value &= ~PCI_EXP_LNKSTA_CLS ; + value |=PCI_EXP_LNKSTA_CLS_2_5GB ; +writel (value, port->base +RP_LINK_CONTROL_STATUS_2 ); }static void tegra_pcie_port_enable (struct tegra_pcie_port *port)
Signature · 1 line
2.17.1
Re: [PATCH V2 16/28] PCI: tegra: Set target speed as Gen1 before starting LTSSM
Quoted 13 lines · Manikanta Maddireddy
PCIe link up fails with few legacy endpoints if root port advertises both Gen-1 and Gen-2 speeds in Tegra. This is because link number negotiation fails if both Gen1 & Gen2 are advertised. Tegra doesn't retry link up by advertising only Gen1. Hence, the strategy followed here is to initially advertise only Gen-1 and after link is up, retrain link to Gen-2 speed.
Tegra doesn't support HW autonomous speed change. Link comes up in Gen1 even if Gen2 is advertised, so there is no downside of this change.
This behavior is observed with following two PCIe devices on Tegra,
- Fusion HDTV 5 Express card
- IOGear SIL - PCIE - SATA card
Quoted 7 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Updated commit log to reflect why this issue is observed on Tegra with these particular cardsdrivers/pci/controller/pci-tegra.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
PATCH v2 17/28 PCI: tegra: Fix PLLE power down issue due to CLKREQ# signal
In reply to Manikanta MaddireddyDisable controllers which failed to link up and configure CLKREQ# signals of these controllers as GPIO. This is required to avoid CLKREQ# signal of inactive controllers interfering with PLLE power down sequence.
PCIE_CLKREQ_GPIO bits are defined only in Tegra186, however programming these bits in other SoCs doesn't cause any side effects. Program these bits for all Tegra SoCs to avoid conditional check.
---
V2: Corrected the comment in driver
drivers/pci/controller/pci-tegra.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/pci/controller/pci-tegra.c +12 -1
@@ -160,6 +160,8 @@#define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_211 (0x1 << 20)#define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_411 (0x2 << 20)#define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_111 (0x2 << 20) +#define AFI_PCIE_CONFIG_PCIE_CLKREQ_GPIO (x) (1 << ((x) + 29)) +#define AFI_PCIE_CONFIG_PCIE_CLKREQ_GPIO_ALL (0x7 << 29)#define AFI_FUSE 0x104#define AFI_FUSE_PCIE_T0_GEN2_DIS (1 << 2)
@@ -741,6 +743,12 @@ static void tegra_pcie_port_disable(struct tegra_pcie_port *port) value &= ~AFI_PEX_CTRL_REFCLK_EN ;afi_writel (port->pcie, value, ctrl); + +/* disable PCIe port and set CLKREQ# as GPIO to allow PLLE power down */ + value =afi_readl (port->pcie,AFI_PCIE_CONFIG ); + value |=AFI_PCIE_CONFIG_PCIE_DISABLE (port->index); + value |=AFI_PCIE_CONFIG_PCIE_CLKREQ_GPIO (port->index); +afi_writel (port->pcie, value,AFI_PCIE_CONFIG ); }static void tegra_pcie_port_free (struct tegra_pcie_port *port)
@@ -1153,9 +1161,12 @@ static void tegra_pcie_enable_controller(struct tegra_pcie *pcie) value =afi_readl (pcie,AFI_PCIE_CONFIG ); value &= ~AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_MASK ; value |=AFI_PCIE_CONFIG_PCIE_DISABLE_ALL | pcie->xbar_config; + value |=AFI_PCIE_CONFIG_PCIE_CLKREQ_GPIO_ALL ; -list_for_each_entry (port, &pcie->ports, list) +list_for_each_entry (port, &pcie->ports, list) { value &= ~AFI_PCIE_CONFIG_PCIE_DISABLE (port->index); + value &= ~AFI_PCIE_CONFIG_PCIE_CLKREQ_GPIO (port->index); + }afi_writel (pcie, value,AFI_PCIE_CONFIG );
Signature · 1 line
2.17.1
Re: [PATCH V2 17/28] PCI: tegra: Fix PLLE power down issue due to CLKREQ# signal
Quoted 8 lines · Manikanta Maddireddy
Disable controllers which failed to link up and configure CLKREQ# signals of these controllers as GPIO. This is required to avoid CLKREQ# signal of inactive controllers interfering with PLLE power down sequence.
PCIE_CLKREQ_GPIObits are defined only in Tegra186, however programming these bits in other SoCs doesn't cause any side effects. Program these bits for all Tegra SoCs to avoid conditional check.
Quoted 6 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Corrected the comment in driverdrivers/pci/controller/pci-tegra.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
PATCH v2 18/28 PCI: tegra: Program AFI_CACHE* registers only for Tegra20
In reply to Manikanta MaddireddyCacheable upstream transactions are supported in Tegra20 and Tegra186 only. AFI_CACHE* registers are available in Tegra20 to support cacheable upstream transactions. In Tegra186, AFI_AXCACHE register is defined instead of AFI_CACHE* to be in line with its MSS design. Therefore, program AFI_CACHE* registers only for Tegra20.
---
V2: Used soc variable for comparision instead of compatible string.
drivers/pci/controller/pci-tegra.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/pci/controller/pci-tegra.c +8 -5
@@ -323,6 +323,7 @@ struct tegra_pcie_soc {bool program_deskew_time;bool raw_violation_fixup;bool update_fc_timer; +bool has_cache_bars; struct { struct { u32 rp_ectl_2_r1;
@@ -932,11 +933,13 @@ static void tegra_pcie_setup_translations(struct tegra_pcie *pcie)afi_writel (pcie,0 ,AFI_AXI_BAR5_SZ );afi_writel (pcie,0 ,AFI_FPCI_BAR5 ); -/* map all upstream transactions as uncached */ -afi_writel (pcie,0 ,AFI_CACHE_BAR0_ST ); -afi_writel (pcie,0 ,AFI_CACHE_BAR0_SZ ); -afi_writel (pcie,0 ,AFI_CACHE_BAR1_ST ); -afi_writel (pcie,0 ,AFI_CACHE_BAR1_SZ ); +if (pcie->soc->has_cache_bars) { +/* map all upstream transactions as uncached */ +afi_writel (pcie,0 ,AFI_CACHE_BAR0_ST ); +afi_writel (pcie,0 ,AFI_CACHE_BAR0_SZ ); +afi_writel (pcie,0 ,AFI_CACHE_BAR1_ST ); +afi_writel (pcie,0 ,AFI_CACHE_BAR1_SZ ); + }/* MSI translations are setup only when needed */ afi_writel (pcie,0 ,AFI_MSI_FPCI_BAR_ST );
Signature · 1 line
2.17.1
Re: [PATCH V2 18/28] PCI: tegra: Program AFI_CACHE* registers only for Tegra20
Quoted 34 lines · Manikanta Maddireddy
Cacheable upstream transactions are supported in Tegra20 and Tegra186 only. AFI_CACHE* registers are available in Tegra20 to support cacheable upstream transactions. In Tegra186,
AFI_AXCACHEregister is defined instead of AFI_CACHE* to be in line with its MSS design. Therefore, program AFI_CACHE* registers only for Tegra20.Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Used soc variable for comparision instead of compatible string.drivers/pci/controller/pci-tegra.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/pci/controller/pci-tegra.c +1
-5@@ -323,6 +323,7 @@ struct tegra_pcie_soc {bool program_deskew_time;bool raw_violation_fixup;bool update_fc_timer; +bool has_cache_bars; struct { struct { u32 rp_ectl_2_r1;@@ -932,11 +933,13 @@ static void tegra_pcie_setup_translations(struct tegra_pcie *pcie)afi_writel (pcie,0 ,AFI_AXI_BAR5_SZ );afi_writel (pcie,0 ,AFI_FPCI_BAR5 ); -/* map all upstream transactions as uncached */ -afi_writel (pcie,0 ,AFI_CACHE_BAR0_ST ); -afi_writel (pcie,0 ,AFI_CACHE_BAR0_SZ ); -afi_writel (pcie,0 ,AFI_CACHE_BAR1_ST ); -afi_writel (pcie,0 ,AFI_CACHE_BAR1_SZ );
drivers/pci/controller/pci-tegra.c static void tegra_pcie_setup_translations(struct tegra_pcie *pcie) · line 945
Quoted 10 lines
drivers/pci/controller/pci-tegra.c +7
-0+if (pcie->soc->has_cache_bars) { +/* map all upstream transactions as uncached */ +afi_writel (pcie,0 ,AFI_CACHE_BAR0_ST ); +afi_writel (pcie,0 ,AFI_CACHE_BAR0_SZ ); +afi_writel (pcie,0 ,AFI_CACHE_BAR1_ST ); +afi_writel (pcie,0 ,AFI_CACHE_BAR1_SZ ); + }/* MSI translations are setup only when needed */ afi_writel (pcie,0 ,AFI_MSI_FPCI_BAR_ST );
You need to squash the below into this patch. If I do that, then TrimSlice works again.
Thierry
--- >8 ---
drivers/pci/controller/pci-tegra.c +5 -0
@@ -2530,6 +2530,7 @@ static const struct tegra_pcie_soc tegra20_pcie = { .program_deskew_time = false, .raw_violation_fixup = false, .update_fc_timer = false, + .has_cache_bars = true, .ectl.enable = false, };
@@ -2558,6 +2559,7 @@ static const struct tegra_pcie_soc tegra30_pcie = { .program_deskew_time = false, .raw_violation_fixup = false, .update_fc_timer = false, + .has_cache_bars = false, .ectl.enable = false, };
@@ -2581,6 +2583,7 @@ static const struct tegra_pcie_soc tegra124_pcie = { .program_deskew_time = false, .raw_violation_fixup = true, .update_fc_timer = false, + .has_cache_bars = false, .ectl.enable = false, };
@@ -2604,6 +2607,7 @@ static const struct tegra_pcie_soc tegra210_pcie = { .program_deskew_time = true, .raw_violation_fixup = false, .update_fc_timer = true, + .has_cache_bars = false, .ectl = { .regs = { .rp_ectl_2_r1 = 0x0000000f,
@@ -2645,6 +2649,7 @@ static const struct tegra_pcie_soc tegra186_pcie = { .program_deskew_time = false, .raw_violation_fixup = false, .update_fc_timer = false, + .has_cache_bars = false, .ectl.enable = false, };
Re: [PATCH V2 18/28] PCI: tegra: Program AFI_CACHE* registers only for Tegra20
Quoted 43 lines · Thierry Reding
Quoted 42 lines · Manikanta Maddireddy
Cacheable upstream transactions are supported in Tegra20 and Tegra186 only. AFI_CACHE* registers are available in Tegra20 to support cacheable upstream transactions. In Tegra186,
AFI_AXCACHEregister is defined instead of AFI_CACHE* to be in line with its MSS design. Therefore, program AFI_CACHE* registers only for Tegra20.Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Used soc variable for comparision instead of compatible string.drivers/pci/controller/pci-tegra.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/pci/controller/pci-tegra.c +8
-5@@ -323,6 +323,7 @@ struct tegra_pcie_soc {bool program_deskew_time;bool raw_violation_fixup;bool update_fc_timer; +bool has_cache_bars; struct { struct { u32 rp_ectl_2_r1;@@ -932,11 +933,13 @@ static void tegra_pcie_setup_translations(struct tegra_pcie *pcie)afi_writel (pcie,0 ,AFI_AXI_BAR5_SZ );afi_writel (pcie,0 ,AFI_FPCI_BAR5 ); -/* map all upstream transactions as uncached */ -afi_writel (pcie,0 ,AFI_CACHE_BAR0_ST ); -afi_writel (pcie,0 ,AFI_CACHE_BAR0_SZ ); -afi_writel (pcie,0 ,AFI_CACHE_BAR1_ST ); -afi_writel (pcie,0 ,AFI_CACHE_BAR1_SZ ); +if (pcie->soc->has_cache_bars) { +/* map all upstream transactions as uncached */ +afi_writel (pcie,0 ,AFI_CACHE_BAR0_ST ); +afi_writel (pcie,0 ,AFI_CACHE_BAR0_SZ ); +afi_writel (pcie,0 ,AFI_CACHE_BAR1_ST ); +afi_writel (pcie,0 ,AFI_CACHE_BAR1_SZ ); + }
Quoted 6 lines
drivers/pci/controller/pci-tegra.c static void tegra_pcie_setup_translations(struct tegra_pcie *pcie) · line 945
Quoted 2 lines
drivers/pci/controller/pci-tegra.c +0
-0/* MSI translations are setup only when needed */ afi_writel (pcie,0 ,AFI_MSI_FPCI_BAR_ST );You need to squash the below into this patch. If I do that, then TrimSlice works again.
Thierry
Thank you Thierry for verifying the series on T20 and T30. I will take care of this comment in V3.
Please review other patches and provide Ack.
Manikanta
Quoted 46 lines
--- >8 ---
drivers/pci/controller/pci-tegra.c +5
-0@@ -2530,6 +2530,7 @@ static const struct tegra_pcie_soc tegra20_pcie = { .program_deskew_time = false, .raw_violation_fixup = false, .update_fc_timer = false, + .has_cache_bars = true, .ectl.enable = false, };@@ -2558,6 +2559,7 @@ static const struct tegra_pcie_soc tegra30_pcie = { .program_deskew_time = false, .raw_violation_fixup = false, .update_fc_timer = false, + .has_cache_bars = false, .ectl.enable = false, };@@ -2581,6 +2583,7 @@ static const struct tegra_pcie_soc tegra124_pcie = { .program_deskew_time = false, .raw_violation_fixup = true, .update_fc_timer = false, + .has_cache_bars = false, .ectl.enable = false, };@@ -2604,6 +2607,7 @@ static const struct tegra_pcie_soc tegra210_pcie = { .program_deskew_time = true, .raw_violation_fixup = false, .update_fc_timer = true, + .has_cache_bars = false, .ectl = { .regs = { .rp_ectl_2_r1 = 0x0000000f,@@ -2645,6 +2649,7 @@ static const struct tegra_pcie_soc tegra186_pcie = { .program_deskew_time = false, .raw_violation_fixup = false, .update_fc_timer = false, + .has_cache_bars = false, .ectl.enable = false, };
Thierry Reding
Acked-byRe: [PATCH V2 18/28] PCI: tegra: Program AFI_CACHE* registers only for Tegra20
Quoted 51 lines · Manikanta Maddireddy
Quoted 48 lines · Thierry Reding
Quoted 34 lines · Manikanta Maddireddy
Cacheable upstream transactions are supported in Tegra20 and Tegra186 only. AFI_CACHE* registers are available in Tegra20 to support cacheable upstream transactions. In Tegra186,
AFI_AXCACHEregister is defined instead of AFI_CACHE* to be in line with its MSS design. Therefore, program AFI_CACHE* registers only for Tegra20.Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Used soc variable for comparision instead of compatible string.drivers/pci/controller/pci-tegra.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/pci/controller/pci-tegra.c +1
-5@@ -323,6 +323,7 @@ struct tegra_pcie_soc {bool program_deskew_time;bool raw_violation_fixup;bool update_fc_timer; +bool has_cache_bars; struct { struct { u32 rp_ectl_2_r1;@@ -932,11 +933,13 @@ static void tegra_pcie_setup_translations(struct tegra_pcie *pcie)afi_writel (pcie,0 ,AFI_AXI_BAR5_SZ );afi_writel (pcie,0 ,AFI_FPCI_BAR5 ); -/* map all upstream transactions as uncached */ -afi_writel (pcie,0 ,AFI_CACHE_BAR0_ST ); -afi_writel (pcie,0 ,AFI_CACHE_BAR0_SZ ); -afi_writel (pcie,0 ,AFI_CACHE_BAR1_ST ); -afi_writel (pcie,0 ,AFI_CACHE_BAR1_SZ );drivers/pci/controller/pci-tegra.c static void tegra_pcie_setup_translations(struct tegra_pcie *pcie) · line 945
Quoted 10 lines
drivers/pci/controller/pci-tegra.c +7
-0+if (pcie->soc->has_cache_bars) { +/* map all upstream transactions as uncached */ +afi_writel (pcie,0 ,AFI_CACHE_BAR0_ST ); +afi_writel (pcie,0 ,AFI_CACHE_BAR0_SZ ); +afi_writel (pcie,0 ,AFI_CACHE_BAR1_ST ); +afi_writel (pcie,0 ,AFI_CACHE_BAR1_SZ ); + }/* MSI translations are setup only when needed */ afi_writel (pcie,0 ,AFI_MSI_FPCI_BAR_ST );You need to squash the below into this patch. If I do that, then TrimSlice works again.
Quoted 4 lines
Quoted 1 line
Thierry
Thank you Thierry for verifying the series on T20 and T30. I will take care of this comment in V3.
Please review other patches and provide Ack.
For the record, with the patch below squashed in, this patch is:
Quoted 49 lines
Manikanta
Quoted 46 lines
--- >8 ---
drivers/pci/controller/pci-tegra.c +5
-0@@ -2530,6 +2530,7 @@ static const struct tegra_pcie_soc tegra20_pcie = { .program_deskew_time = false, .raw_violation_fixup = false, .update_fc_timer = false, + .has_cache_bars = true, .ectl.enable = false, };@@ -2558,6 +2559,7 @@ static const struct tegra_pcie_soc tegra30_pcie = { .program_deskew_time = false, .raw_violation_fixup = false, .update_fc_timer = false, + .has_cache_bars = false, .ectl.enable = false, };@@ -2581,6 +2583,7 @@ static const struct tegra_pcie_soc tegra124_pcie = { .program_deskew_time = false, .raw_violation_fixup = true, .update_fc_timer = false, + .has_cache_bars = false, .ectl.enable = false, };@@ -2604,6 +2607,7 @@ static const struct tegra_pcie_soc tegra210_pcie = { .program_deskew_time = true, .raw_violation_fixup = false, .update_fc_timer = true, + .has_cache_bars = false, .ectl = { .regs = { .rp_ectl_2_r1 = 0x0000000f,@@ -2645,6 +2649,7 @@ static const struct tegra_pcie_soc tegra186_pcie = { .program_deskew_time = false, .raw_violation_fixup = false, .update_fc_timer = false, + .has_cache_bars = false, .ectl.enable = false, };
PATCH v2 19/28 PCI: tegra: Change PRSNT_SENSE irq log to debug
In reply to Manikanta MaddireddyPRSNT_MAP bit field is programmed to update the slot present status. PRSNT_SENSE irq is triggered when this bit field is programmed, which is not an error. Add a new if condition to trap RSNT_SENSE code and print it with debug log level.
---
V2: If-else to switch-case conversion patch is dropped, this patch is rebased to stay with if-else statements
drivers/pci/controller/pci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-tegra.c +1 -1
@@ -864,7 +864,7 @@ static irqreturn_t tegra_pcie_isr(int irq, void *arg)* do not pollute kernel log with master abort reports since they * happen a lot during enumeration */ -if (code ==AFI_INTR_MASTER_ABORT ) +if (code ==AFI_INTR_MASTER_ABORT || code ==AFI_INTR_PE_PRSNT_SENSE )dev_dbg (dev,"%s, signature: %08x\n" , err_msg[code], signature);else dev_err (dev,"%s, signature: %08x\n" , err_msg[code], signature);
Signature · 1 line
2.17.1
Re: [PATCH V2 19/28] PCI: tegra: Change PRSNT_SENSE irq log to debug
Quoted 2 lines · Manikanta Maddireddy
PRSNT_MAPbit field is programmed to update the slot present status.PRSNT_SENSEirq is triggered when this bit field is programmed, which is
s/irq/IRQ/
Quoted 1 line
not an error. Add a new if condition to trap
RSNT_SENSEcode and print it
s/RSNT_SENSE/PRSNT_SENSE/
With that:
Quoted 26 lines
with debug log level.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: If-else to switch-case conversion patch is dropped, this patch is rebased to stay with if-else statementsdrivers/pci/controller/pci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/pci-tegra.c +1
-1@@ -864,7 +864,7 @@ static irqreturn_t tegra_pcie_isr(int irq, void *arg)* do not pollute kernel log with master abort reports since they * happen a lot during enumeration */ -if (code ==AFI_INTR_MASTER_ABORT ) +if (code ==AFI_INTR_MASTER_ABORT || code ==AFI_INTR_PE_PRSNT_SENSE )dev_dbg (dev,"%s, signature: %08x\n" , err_msg[code], signature);else dev_err (dev,"%s, signature: %08x\n" , err_msg[code], signature);Signature · 1 line
2.17.1
PATCH v2 20/28 PCI: tegra: Use legacy irq for port service drivers
In reply to Manikanta MaddireddyTegra signals PCIe services like AER, PME, etc over legacy IRQ line. By default, service drivers register interrupt routine over MSI IRQ line. Use pcie_pme_disable_msi() function to disable MSI for service drivers.
PME and AER interrupts registered to MSI without this change, cat /proc/interrupts | grep -i pci
36: 21 0 0 0 0 0 GICv2 104 Level PCIE
37: 35 0 0 0 0 0 GICv2 105 Level Tegra PCIe MSI
76: 0 0 0 0 0 0 Tegra PCIe MSI 0 Edge PCIe PME, aerdrv, PCIe BW notif
PME and AER interrupts registered to legacy IRQ with this change, cat /proc/interrupts | grep -i pci
36: 33 0 0 0 0 0 GICv2 104 Level PCIE, PCIe PME, aerdrv, PCIe BW notif
37: 52 0 0 0 0 0 GICv2 105 Level Tegra PCIe MSI
---
V2: No change
drivers/pci/controller/pci-tegra.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pci/controller/pci-tegra.c +4 -0
@@ -41,6 +41,7 @@#include <soc/tegra/pmc.h> #include "../pci.h" +#include "../pcie/portdrv.h" #define INT_PCI_MSI_NR (8 * 32)
@@ -2721,6 +2722,9 @@ static int tegra_pcie_probe(struct platform_device *pdev) goto put_resources; } +/* Switch to legacy IRQ for PCIe services like AER, PME*/ +pcie_pme_disable_msi (); +pm_runtime_enable (pcie->dev); err =pm_runtime_get_sync (pcie->dev);if (err) {
Signature · 1 line
2.17.1
Re: [PATCH V2 20/28] PCI: tegra: Use legacy irq for port service drivers
Quoted 15 lines · Manikanta Maddireddy
Tegra signals PCIe services like AER, PME, etc over legacy IRQ line. By default, service drivers register interrupt routine over MSI IRQ line. Use
pcie_pme_disable_msi()function to disable MSI for service drivers.PME and AER interrupts registered to MSI without this change, cat
/proc/interrupts| grep -i pci
36: 21 0 0 0 0 0 GICv2 104 Level PCIE
37: 35 0 0 0 0 0 GICv2 105 Level Tegra PCIe MSI
76: 0 0 0 0 0 0 Tegra PCIe MSI 0 Edge PCIe PME, aerdrv, PCIe BW notifPME and AER interrupts registered to legacy IRQ with this change, cat
/proc/interrupts| grep -i pci
36: 33 0 0 0 0 0 GICv2 104 Level PCIE, PCIe PME, aerdrv, PCIe BW notif
37: 52 0 0 0 0 0 GICv2 105 Level Tegra PCIe MSI
Quoted 6 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: No changedrivers/pci/controller/pci-tegra.c | 4 ++++ 1 file changed, 4 insertions(+)
I think I mentioned this before, but it would be nice to make this setting per-controller rather than system-global. In practice I guess this doesn't really matter at this point, and I'm not sure how much Bjorn cares, so:
Quoted 26 lines
drivers/pci/controller/pci-tegra.c +4
-0@@ -41,6 +41,7 @@#include <soc/tegra/pmc.h> #include "../pci.h" +#include "../pcie/portdrv.h" #define INT_PCI_MSI_NR (8 * 32)@@ -2721,6 +2722,9 @@ static int tegra_pcie_probe(struct platform_device *pdev) goto put_resources; } +/* Switch to legacy IRQ for PCIe services like AER, PME*/ +pcie_pme_disable_msi (); +pm_runtime_enable (pcie->dev); err =pm_runtime_get_sync (pcie->dev);if (err) {Signature · 1 line
2.17.1
PATCH v2 21/28 PCI: tegra: Add AFI_PEX2_CTRL reg offset as part of soc struct
In reply to Manikanta MaddireddyTegra186 and Tegra30 have three PCIe root ports. AFI_PEX2_CTRL register is defined for third root port. Offset of this register in Tegra186 is different from Tegra30, so add offset as part of soc data structure.
---
V2: No change
drivers/pci/controller/pci-tegra.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-tegra.c +5 -2
@@ -169,7 +169,6 @@#define AFI_PEX0_CTRL 0x110#define AFI_PEX1_CTRL 0x118 -#define AFI_PEX2_CTRL 0x128#define AFI_PEX_CTRL_RST (1 << 0)#define AFI_PEX_CTRL_CLKREQ_EN (1 << 1)#define AFI_PEX_CTRL_REFCLK_EN (1 << 3)
@@ -308,6 +307,7 @@ struct tegra_pcie_soc {unsigned int num_ports;const struct tegra_pcie_port_soc *ports;unsigned int msi_base_shift; +unsigned long afi_pex2_ctrl;u32 pads_pll_ctl;u32 tx_ref_sel;u32 pads_refclk_cfg0;
@@ -518,6 +518,7 @@ static struct pci_ops tegra_pcie_ops = {static unsigned long tegra_pcie_port_get_pex_ctrl (struct tegra_pcie_port *port) { +const struct tegra_pcie_soc *soc = port->pcie->soc;unsigned long ret =0 ;switch (port->index) {
@@ -530,7 +531,7 @@ static unsigned long tegra_pcie_port_get_pex_ctrl(struct tegra_pcie_port *port)break ;case 2 : - ret =AFI_PEX2_CTRL ; + ret = soc->afi_pex2_ctrl;break ; }
@@ -2432,6 +2433,7 @@ static const struct tegra_pcie_soc tegra20_pcie = { .num_ports = 2, .ports = tegra20_pcie_ports, .msi_base_shift = 0, + .afi_pex2_ctrl = 0x128, .pads_pll_ctl = PADS_PLL_CTL_TEGRA20, .tx_ref_sel = PADS_PLL_CTL_TXCLKREF_DIV10, .pads_refclk_cfg0 = 0xfa5cfa5c,
@@ -2545,6 +2547,7 @@ static const struct tegra_pcie_soc tegra186_pcie = { .num_ports = 3, .ports = tegra186_pcie_ports, .msi_base_shift = 8, + .afi_pex2_ctrl = 0x19c, .pads_pll_ctl = PADS_PLL_CTL_TEGRA30, .tx_ref_sel = PADS_PLL_CTL_TXCLKREF_BUF_EN, .pads_refclk_cfg0 = 0x80b880b8,
Signature · 1 line
2.17.1
PATCH v2 22/28 PCI: tegra: Access endpoint config only if PCIe link is up
In reply to Manikanta MaddireddyAdd PCIe link up check in config read and write callback functions before accessing endpoint config registers.
---
V2: Change tegra_pcie_link_status() to tegra_pcie_link_up()
drivers/pci/controller/pci-tegra.c | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
drivers/pci/controller/pci-tegra.c +38 -0
@@ -428,6 +428,14 @@ static inline u32 pads_readl(struct tegra_pcie *pcie, unsigned long offset)return readl (pcie->pads + offset); } +static bool tegra_pcie_link_up (struct tegra_pcie_port *port) +{ +u32 value; + + value =readl (port->base +RP_LINK_CONTROL_STATUS ); +return !!(value &RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE ); +} +/* * The configuration space mapping on Tegra is somewhat similar to the ECAM * defined by PCIe. However it deviates a bit in how the 4 bits for extended
@@ -493,20 +501,50 @@ static void __iomem *tegra_pcie_map_bus(struct pci_bus *bus,static int tegra_pcie_config_read (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 *value) { +struct tegra_pcie *pcie = bus->sysdata; +struct pci_dev *bridge; +struct tegra_pcie_port *port; +if (bus->number ==0 )return pci_generic_config_read32 (bus, devfn, where, size, value); + bridge =pcie_find_root_port (bus->self); + +list_for_each_entry (port, &pcie->ports, list) +if (port->index +1 ==PCI_SLOT (bridge->devfn)) +break ; + +/* If there is no link, then there is no device */ +if (!tegra_pcie_link_up (port)) { + *value =0xffffffff ; +return PCIBIOS_DEVICE_NOT_FOUND ; + } +return pci_generic_config_read (bus, devfn, where, size, value); }static int tegra_pcie_config_write (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 value) { +struct tegra_pcie *pcie = bus->sysdata; +struct tegra_pcie_port *port; +struct pci_dev *bridge; +if (bus->number ==0 )return pci_generic_config_write32 (bus, devfn, where, size, value); + bridge =pcie_find_root_port (bus->self); + +list_for_each_entry (port, &pcie->ports, list) +if (port->index +1 ==PCI_SLOT (bridge->devfn)) +break ; + +/* If there is no link, then there is no device */ +if (!tegra_pcie_link_up (port)) +return PCIBIOS_DEVICE_NOT_FOUND ; +return pci_generic_config_write (bus, devfn, where, size, value); }
Signature · 1 line
2.17.1
Re: [PATCH V2 22/28] PCI: tegra: Access endpoint config only if PCIe link is up
Quoted 2 lines · Manikanta Maddireddy
Add PCIe link up check in config read and write callback functions before accessing endpoint config registers.
I mentioned before:
We need to either eradicate this pattern of checking for link up, or include a comment about why it is absolutely necessary.
I still think this check should be unnecessary, but if you really think you need it, at least add the comment.
Quoted 80 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Changetegra_pcie_link_status()totegra_pcie_link_up()drivers/pci/controller/pci-tegra.c | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)drivers/pci/controller/pci-tegra.c +38
-0@@ -428,6 +428,14 @@ static inline u32 pads_readl(struct tegra_pcie *pcie, unsigned long offset)return readl (pcie->pads + offset); } +static bool tegra_pcie_link_up (struct tegra_pcie_port *port) +{ +u32 value; + + value =readl (port->base +RP_LINK_CONTROL_STATUS ); +return !!(value &RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE ); +} +/* * The configuration space mapping on Tegra is somewhat similar to the ECAM * defined by PCIe. However it deviates a bit in how the 4 bits for extended @@ -493,20 +501,50 @@ static void __iomem *tegra_pcie_map_bus(struct pci_bus *bus,static int tegra_pcie_config_read (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 *value) { +struct tegra_pcie *pcie = bus->sysdata; +struct pci_dev *bridge; +struct tegra_pcie_port *port; +if (bus->number ==0 )return pci_generic_config_read32 (bus, devfn, where, size, value); + bridge =pcie_find_root_port (bus->self); + +list_for_each_entry (port, &pcie->ports, list) +if (port->index +1 ==PCI_SLOT (bridge->devfn)) +break ; + +/* If there is no link, then there is no device */ +if (!tegra_pcie_link_up (port)) { + *value =0xffffffff ; +return PCIBIOS_DEVICE_NOT_FOUND ; + } +return pci_generic_config_read (bus, devfn, where, size, value); }static int tegra_pcie_config_write (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 value) { +struct tegra_pcie *pcie = bus->sysdata; +struct tegra_pcie_port *port; +struct pci_dev *bridge; +if (bus->number ==0 )return pci_generic_config_write32 (bus, devfn, where, size, value); + bridge =pcie_find_root_port (bus->self); + +list_for_each_entry (port, &pcie->ports, list) +if (port->index +1 ==PCI_SLOT (bridge->devfn)) +break ; + +/* If there is no link, then there is no device */ +if (!tegra_pcie_link_up (port)) +return PCIBIOS_DEVICE_NOT_FOUND ; +return pci_generic_config_write (bus, devfn, where, size, value); }Signature · 1 line
2.17.1
Re: [PATCH V2 22/28] PCI: tegra: Access endpoint config only if PCIe link is up
Quoted 10 lines · Bjorn Helgaas
Quoted 2 lines · Manikanta Maddireddy
Add PCIe link up check in config read and write callback functions before accessing endpoint config registers.
I mentioned before:
We need to either eradicate this pattern of checking for link up, or include a comment about why it is absolutely necessary.
I still think this check should be unnecessary, but if you really think you need it, at least add the comment.
Sorry, I missed to add comment in V2. I will take care of it in V3.
Manikanta
Quoted 81 lines
Quoted 81 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Changetegra_pcie_link_status()totegra_pcie_link_up()drivers/pci/controller/pci-tegra.c | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)drivers/pci/controller/pci-tegra.c +38
-0@@ -428,6 +428,14 @@ static inline u32 pads_readl(struct tegra_pcie *pcie, unsigned long offset)return readl (pcie->pads + offset); } +static bool tegra_pcie_link_up (struct tegra_pcie_port *port) +{ +u32 value; + + value =readl (port->base +RP_LINK_CONTROL_STATUS ); +return !!(value &RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE ); +} +/* * The configuration space mapping on Tegra is somewhat similar to the ECAM * defined by PCIe. However it deviates a bit in how the 4 bits for extended @@ -493,20 +501,50 @@ static void __iomem *tegra_pcie_map_bus(struct pci_bus *bus,static int tegra_pcie_config_read (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 *value) { +struct tegra_pcie *pcie = bus->sysdata; +struct pci_dev *bridge; +struct tegra_pcie_port *port; +if (bus->number ==0 )return pci_generic_config_read32 (bus, devfn, where, size, value); + bridge =pcie_find_root_port (bus->self); + +list_for_each_entry (port, &pcie->ports, list) +if (port->index +1 ==PCI_SLOT (bridge->devfn)) +break ; + +/* If there is no link, then there is no device */ +if (!tegra_pcie_link_up (port)) { + *value =0xffffffff ; +return PCIBIOS_DEVICE_NOT_FOUND ; + } +return pci_generic_config_read (bus, devfn, where, size, value); }static int tegra_pcie_config_write (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 value) { +struct tegra_pcie *pcie = bus->sysdata; +struct tegra_pcie_port *port; +struct pci_dev *bridge; +if (bus->number ==0 )return pci_generic_config_write32 (bus, devfn, where, size, value); + bridge =pcie_find_root_port (bus->self); + +list_for_each_entry (port, &pcie->ports, list) +if (port->index +1 ==PCI_SLOT (bridge->devfn)) +break ; + +/* If there is no link, then there is no device */ +if (!tegra_pcie_link_up (port)) +return PCIBIOS_DEVICE_NOT_FOUND ; +return pci_generic_config_write (bus, devfn, where, size, value); }Signature · 1 line
2.17.1
Re: [PATCH V2 22/28] PCI: tegra: Access endpoint config only if PCIe link is up
Quoted 6 lines · Manikanta Maddireddy
Quoted 3 lines · Bjorn Helgaas
Quoted 2 lines · Manikanta Maddireddy
Add PCIe link up check in config read and write callback functions before accessing endpoint config registers.
Quoted 8 lines
Quoted 7 lines
I mentioned before:
We need to either eradicate this pattern of checking for link up, or include a comment about why it is absolutely necessary.
I still think this check should be unnecessary, but if you really think you need it, at least add the comment.
Sorry, I missed to add comment in V2. I will take care of it in V3.
Please make sure to explain when exactly this happens. I've never seen this happen before and I don't understand what circumstances could lead to this.
Thierry
Quoted 86 lines
Manikanta
Quoted 81 lines
Quoted 81 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Changetegra_pcie_link_status()totegra_pcie_link_up()drivers/pci/controller/pci-tegra.c | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)drivers/pci/controller/pci-tegra.c +38
-0@@ -428,6 +428,14 @@ static inline u32 pads_readl(struct tegra_pcie *pcie, unsigned long offset)return readl (pcie->pads + offset); } +static bool tegra_pcie_link_up (struct tegra_pcie_port *port) +{ +u32 value; + + value =readl (port->base +RP_LINK_CONTROL_STATUS ); +return !!(value &RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE ); +} +/* * The configuration space mapping on Tegra is somewhat similar to the ECAM * defined by PCIe. However it deviates a bit in how the 4 bits for extended @@ -493,20 +501,50 @@ static void __iomem *tegra_pcie_map_bus(struct pci_bus *bus,static int tegra_pcie_config_read (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 *value) { +struct tegra_pcie *pcie = bus->sysdata; +struct pci_dev *bridge; +struct tegra_pcie_port *port; +if (bus->number ==0 )return pci_generic_config_read32 (bus, devfn, where, size, value); + bridge =pcie_find_root_port (bus->self); + +list_for_each_entry (port, &pcie->ports, list) +if (port->index +1 ==PCI_SLOT (bridge->devfn)) +break ; + +/* If there is no link, then there is no device */ +if (!tegra_pcie_link_up (port)) { + *value =0xffffffff ; +return PCIBIOS_DEVICE_NOT_FOUND ; + } +return pci_generic_config_read (bus, devfn, where, size, value); }static int tegra_pcie_config_write (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 value) { +struct tegra_pcie *pcie = bus->sysdata; +struct tegra_pcie_port *port; +struct pci_dev *bridge; +if (bus->number ==0 )return pci_generic_config_write32 (bus, devfn, where, size, value); + bridge =pcie_find_root_port (bus->self); + +list_for_each_entry (port, &pcie->ports, list) +if (port->index +1 ==PCI_SLOT (bridge->devfn)) +break ; + +/* If there is no link, then there is no device */ +if (!tegra_pcie_link_up (port)) +return PCIBIOS_DEVICE_NOT_FOUND ; +return pci_generic_config_write (bus, devfn, where, size, value); }Signature · 1 line
2.17.1
PATCH v2 23/28 dt-bindings: pci: tegra: Document PCIe DPD pinctrl optional prop
In reply to Manikanta MaddireddyDocument PCIe DPD pinctrl optional property to put PEX clk & BIAS pads in low power mode.
---
V2: Using standard pinctrl names, default and idle
.../devicetree/bindings/pci/nvidia,tegra20-pcie.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +8 -0
@@ -65,6 +65,14 @@ Required properties: - afi - pcie_x +Optional properties: +- pinctrl-names: A list of pinctrl state names. Must contain the following + entries: + - "default": active state, puts PCIe I/O out of deep power down state + - "idle": puts PCIe I/O into deep power down state +- pinctrl-0: phandle for the default/active state of pin configurations. +- pinctrl-1: phandle for the idle state of pin configurations. + Required properties on Tegra124 and later (deprecated): - phys: Must contain an entry for each entry in phy-names. - phy-names: Must include the following entries:
Signature · 1 line
2.17.1
Re: [PATCH V2 23/28] dt-bindings: pci: tegra: Document PCIe DPD pinctrl optional prop
Quoted 10 lines · Manikanta Maddireddy
Document PCIe DPD pinctrl optional property to put PEX clk & BIAS pads in low power mode.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Using standard pinctrl names, default and idle.../devicetree/bindings/pci/nvidia,tegra20-pcie.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
Re: [PATCH V2 23/28] dt-bindings: pci: tegra: Document PCIe DPD pinctrl optional prop
In reply to Manikanta MaddireddyQuoted 9 lines · Manikanta Maddireddy
Document PCIe DPD pinctrl optional property to put PEX clk & BIAS pads in low power mode.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Using standard pinctrl names, default and idle.../devicetree/bindings/pci/nvidia,tegra20-pcie.txt | 8 ++++++++ 1 file changed, 8 insertions(+)
Quoted 23 lines
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +8
-0@@ -65,6 +65,14 @@ Required properties: - afi - pcie_x +Optional properties: +- pinctrl-names: A list of pinctrl state names. Must contain the following + entries: + - "default": active state, puts PCIe I/O out of deep power down state + - "idle": puts PCIe I/O into deep power down state +- pinctrl-0: phandle for the default/active state of pin configurations. +- pinctrl-1: phandle for the idle state of pin configurations. + Required properties on Tegra124 and later (deprecated): - phys: Must contain an entry for each entry in phy-names. - phy-names: Must include the following entries:Signature · 1 line
2.17.1
PATCH v2 24/28 arm64: tegra: Add PEX DPD states as pinctrl properties
In reply to Manikanta MaddireddyAdd PEX deep power down states as pinctrl properties to set in PCIe driver. In Tegra210, BIAS pads are not in power down mode when clamps are applied. To set the pads in DPD, pass the PEX DPD states as pinctrl properties to PCIe driver.
---
V2: Using standard pinctrl names, default and idle
arch/arm64/boot/dts/nvidia/tegra210.dtsi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +19 -0
@@ -48,6 +48,11 @@ <&tegra_car 72>, <&tegra_car 74>; reset-names = "pex", "afi", "pcie_x"; + + pinctrl-names = "default", "idle"; + pinctrl-0 = <&pex_dpd_disable>; + pinctrl-1 = <&pex_dpd_enable>; + status = "disabled"; pci@1,0 {
@@ -848,6 +853,20 @@ pins = "sdmmc3"; power-source = <TEGRA_IO_PAD_VOLTAGE_1V8>; }; + + pex_dpd_disable: pex_en { + pex-dpd-disable { + pins = "pex-bias", "pex-clk1", "pex-clk2"; + low-power-disable; + }; + }; + + pex_dpd_enable: pex_dis { + pex-dpd-enable { + pins = "pex-bias", "pex-clk1", "pex-clk2"; + low-power-enable; + }; + }; }; fuse@7000f800 {
Signature · 1 line
2.17.1
Re: [PATCH V2 24/28] arm64: tegra: Add PEX DPD states as pinctrl properties
Quoted 11 lines · Manikanta Maddireddy
Add PEX deep power down states as pinctrl properties to set in PCIe driver. In Tegra210, BIAS pads are not in power down mode when clamps are applied. To set the pads in DPD, pass the PEX DPD states as pinctrl properties to PCIe driver.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Using standard pinctrl names, default and idlearch/arm64/boot/dts/nvidia/tegra210.dtsi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
I'll pick this up into the Tegra tree once the rest of the set has been merged.
Thierry
PATCH v2 25/28 PCI: tegra: Put PEX CLK & BIAS pads in DPD mode
In reply to Manikanta MaddireddyIn Tegra210 AFI design has clamp value for the BIAS pad as 0, which keeps the bias pad in non power down mode. This is leading to power consumption of 2 mW in BIAS pad, even if the PCIe partition is powergated. To avoid unnecessary power consumption, put PEX CLK & BIAS pads in deep power down mode when PCIe partition is power gated.
---
V2: Using standard pinctrl functions to apply default and idle states
drivers/pci/controller/pci-tegra.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/pci/controller/pci-tegra.c +12 -1
@@ -30,6 +30,7 @@#include <linux/of_platform.h> #include <linux/pci.h> #include <linux/phy/phy.h> +#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/reset.h> #include <linux/sizes.h>
@@ -2871,6 +2872,7 @@ static int __maybe_unused tegra_pcie_pm_suspend(struct device *dev)if (IS_ENABLED (CONFIG_PCI_MSI ))tegra_pcie_disable_msi (pcie); +pinctrl_pm_select_idle_state (dev);tegra_pcie_power_off (pcie);return 0 ;
@@ -2886,6 +2888,13 @@ static int __maybe_unused tegra_pcie_pm_resume(struct device *dev)dev_err (dev,"tegra pcie power on fail: %d\n" , err);return err; } + + err =pinctrl_pm_select_default_state (dev); +if (err <0 ) { +dev_err (dev,"failed to disable PCIe IO DPD: %d\n" , err); + goto poweroff; + } +tegra_pcie_enable_controller (pcie);tegra_pcie_setup_translations (pcie);
@@ -2895,7 +2904,7 @@ static int __maybe_unused tegra_pcie_pm_resume(struct device *dev) err =clk_prepare_enable (pcie->pex_clk);if (err) {dev_err (dev,"failed to enable PEX clock: %d\n" , err); - goto poweroff; + goto pex_dpd_enable; }reset_control_deassert (pcie->pex_rst);
@@ -2915,6 +2924,8 @@ static int __maybe_unused tegra_pcie_pm_resume(struct device *dev) disable_pex_clk:reset_control_assert (pcie->pex_rst);clk_disable_unprepare (pcie->pex_clk); +pex_dpd_enable: +pinctrl_pm_select_idle_state (dev); poweroff:tegra_pcie_power_off (pcie);
Signature · 1 line
2.17.1
Re: [PATCH V2 25/28] PCI: tegra: Put PEX CLK & BIAS pads in DPD mode
Quoted 6 lines · Manikanta Maddireddy
In Tegra210 AFI design has clamp value for the BIAS pad as 0, which keeps the bias pad in non power down mode. This is leading to power consumption of 2 mW in BIAS pad, even if the PCIe partition is powergated. To avoid unnecessary power consumption, put PEX CLK & BIAS pads in deep power down mode when PCIe partition is power gated.
Quoted 6 lines
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Using standard pinctrl functions to apply default and idle statesdrivers/pci/controller/pci-tegra.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
PATCH v2 26/28 dt-bindings: pci: tegra: Document reset-gpio optional prop
In reply to Manikanta MaddireddyDocument "reset-gpio" optional property which supports GPIO based PERST# signal.
---
V2: Using standard "reset-gpio" property
.../devicetree/bindings/pci/nvidia,tegra20-pcie.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +5 -0
@@ -162,6 +162,10 @@ Required properties: - Root port 0 uses 4 lanes, root port 1 is unused. - Both root ports use 2 lanes. +Optional properties: +- reset-gpio: If GPIO is used as PERST# signal instead of available + SFIO, add this property with phandle to GPIO controller and GPIO number. + Required properties for Tegra124 and later: - phys: Must contain an phandle to a PHY for each entry in phy-names. - phy-names: Must include an entry for each active lane. Note that the number
@@ -626,6 +630,7 @@ SoC DTSI: ranges; nvidia,num-lanes = <2>; + reset-gpio = <&gpio TEGRA_GPIO(A, 3) 0>; }; pci@2,0 {
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH V2 26/28] dt-bindings: pci: tegra: Document reset-gpio optional prop
Quoted 15 lines · Manikanta Maddireddy
Document "reset-gpio" optional property which supports GPIO based PERST# signal.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Using standard "reset-gpio" property.../devicetree/bindings/pci/nvidia,tegra20-pcie.txt | 5 +++++ 1 file changed, 5 insertions(+)Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +0
-0
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt Required properties: · line 167
Quoted 6 lines
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +3
-0@@ -162,6 +162,10 @@ Required properties: - Root port 0 uses 4 lanes, root port 1 is unused. - Both root ports use 2 lanes. +Optional properties: +- reset-gpio: If GPIO is used as PERST# signal instead of available + SFIO, add this property with phandle to GPIO controller and GPIO number.
'reset-gpios' is the preferred form.
This is already defined in several other drivers. Perhaps document in a common location and also parse the property in common code.
Rob
Re: [PATCH V2 26/28] dt-bindings: pci: tegra: Document reset-gpio optional prop
In reply to Manikanta MaddireddyQuoted 26 lines · Manikanta Maddireddy
Document "reset-gpio" optional property which supports GPIO based PERST# signal.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Using standard "reset-gpio" property.../devicetree/bindings/pci/nvidia,tegra20-pcie.txt | 5 +++++ 1 file changed, 5 insertions(+)Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +4
-0@@ -162,6 +162,10 @@ Required properties: - Root port 0 uses 4 lanes, root port 1 is unused. - Both root ports use 2 lanes. +Optional properties: +- reset-gpio: If GPIO is used as PERST# signal instead of available + SFIO, add this property with phandle to GPIO controller and GPIO number. + Required properties for Tegra124 and later: - phys: Must contain an phandle to a PHY for each entry in phy-names. - phy-names: Must include an entry for each active lane. Note that the number
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt SoC DTSI: · line 633
Quoted 4 lines
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +1
-0@@ -626,6 +630,7 @@ SoC DTSI: ranges; nvidia,num-lanes = <2>; + reset-gpio = <&gpio TEGRA_GPIO(A, 3) 0>;
Nit: it's customary to put vendor-specific properties below generic ones.
Thierry
Thierry Reding
Acked-byRe: [PATCH V2 26/28] dt-bindings: pci: tegra: Document reset-gpio optional prop
Quoted 29 lines · Thierry Reding
Quoted 28 lines · Manikanta Maddireddy
Document "reset-gpio" optional property which supports GPIO based PERST# signal.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Using standard "reset-gpio" property.../devicetree/bindings/pci/nvidia,tegra20-pcie.txt | 5 +++++ 1 file changed, 5 insertions(+)Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +4
-0@@ -162,6 +162,10 @@ Required properties: - Root port 0 uses 4 lanes, root port 1 is unused. - Both root ports use 2 lanes. +Optional properties: +- reset-gpio: If GPIO is used as PERST# signal instead of available + SFIO, add this property with phandle to GPIO controller and GPIO number. + Required properties for Tegra124 and later: - phys: Must contain an phandle to a PHY for each entry in phy-names. - phy-names: Must include an entry for each active lane. Note that the number@@ -626,6 +630,7 @@ SoC DTSI: ranges;
Quoted 5 lines
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt SoC DTSI: · line 633
Quoted 2 lines
Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt +1
-0nvidia,num-lanes = <2>; + reset-gpio = <&gpio TEGRA_GPIO(A, 3) 0>;Nit: it's customary to put vendor-specific properties below generic ones.
With that:
PATCH v2 27/28 PCI: tegra: Add support for GPIO based PCIe reset
In reply to Manikanta MaddireddyAdd support for GPIO based PERST# instead of SFIO mode controlled by AFI. GPIO number comes from per port PCIe device tree node.
---
V2: Using standard "reset-gpio" property
drivers/pci/controller/pci-tegra.c | 36 +++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-)
drivers/pci/controller/pci-tegra.c +30 -6
@@ -17,6 +17,7 @@#include <linux/debugfs.h> #include <linux/delay.h> #include <linux/export.h> +#include <linux/gpio.h> #include <linux/interrupt.h> #include <linux/iopoll.h> #include <linux/irq.h>
@@ -26,6 +27,7 @@#include <linux/module.h> #include <linux/msi.h> #include <linux/of_address.h> +#include <linux/of_gpio.h> #include <linux/of_pci.h> #include <linux/of_platform.h> #include <linux/pci.h>
@@ -400,6 +402,8 @@ struct tegra_pcie_port {unsigned int lanes;struct phy **phys; + +int reset_gpio; };struct tegra_pcie_bus {
@@ -583,15 +587,23 @@ static void tegra_pcie_port_reset(struct tegra_pcie_port *port)unsigned long value;/* pulse reset signal */ - value =afi_readl (port->pcie, ctrl); - value &= ~AFI_PEX_CTRL_RST ; -afi_writel (port->pcie, value, ctrl); +if (gpio_is_valid (port->reset_gpio)) { +gpiod_set_value (gpio_to_desc (port->reset_gpio),0 ); + }else { + value =afi_readl (port->pcie, ctrl); + value &= ~AFI_PEX_CTRL_RST ; +afi_writel (port->pcie, value, ctrl); + }usleep_range (1000 ,2000 ); - value =afi_readl (port->pcie, ctrl); - value |=AFI_PEX_CTRL_RST ; -afi_writel (port->pcie, value, ctrl); +if (gpio_is_valid (port->reset_gpio)) { +gpiod_set_value (gpio_to_desc (port->reset_gpio),1 ); + }else { + value =afi_readl (port->pcie, ctrl); + value |=AFI_PEX_CTRL_RST ; +afi_writel (port->pcie, value, ctrl); + } }static void tegra_pcie_enable_rp_features (struct tegra_pcie_port *port)
@@ -2299,6 +2311,18 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)if (IS_ERR (rp->base))return PTR_ERR (rp->base); + rp->reset_gpio =of_get_named_gpio (port,"reset-gpio" ,0 ); +if (gpio_is_valid (rp->reset_gpio)) { + err =devm_gpio_request_one (dev, rp->reset_gpio, +GPIOF_OUT_INIT_LOW , +"pex_reset" ); +if (err <0 ) { +dev_err (dev,"failed to request reset-gpio: %d\n" , + err); +return err; + } + } +list_add_tail (&rp->list, &pcie->ports); }
Signature · 1 line
2.17.1
Re: [PATCH V2 27/28] PCI: tegra: Add support for GPIO based PCIe reset
Quoted 31 lines · Manikanta Maddireddy
Add support for GPIO based PERST# instead of SFIO mode controlled by AFI. GPIO number comes from per port PCIe device tree node.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Using standard "reset-gpio" propertydrivers/pci/controller/pci-tegra.c | 36 +++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-)drivers/pci/controller/pci-tegra.c +2
-0@@ -17,6 +17,7 @@#include <linux/debugfs.h> #include <linux/delay.h> #include <linux/export.h> +#include <linux/gpio.h> #include <linux/interrupt.h> #include <linux/iopoll.h> #include <linux/irq.h> @@ -26,6 +27,7 @@#include <linux/module.h> #include <linux/msi.h> #include <linux/of_address.h> +#include <linux/of_gpio.h> #include <linux/of_pci.h> #include <linux/of_platform.h> #include <linux/pci.h>
drivers/pci/controller/pci-tegra.c struct tegra_pcie_port { · line 406
Quoted 5 lines
drivers/pci/controller/pci-tegra.c +2
-0@@ -400,6 +402,8 @@ struct tegra_pcie_port {unsigned int lanes;struct phy **phys; + +int reset_gpio;
Please store the struct gpio_desc * here.
drivers/pci/controller/pci-tegra.c static void tegra_pcie_port_reset(struct tegra_pcie_port *port) · line 591
Quoted 12 lines
drivers/pci/controller/pci-tegra.c +2
-3};struct tegra_pcie_bus {@@ -583,15 +587,23 @@ static void tegra_pcie_port_reset(struct tegra_pcie_port *port)unsigned long value;/* pulse reset signal */ - value =afi_readl (port->pcie, ctrl); - value &= ~AFI_PEX_CTRL_RST ; -afi_writel (port->pcie, value, ctrl); +if (gpio_is_valid (port->reset_gpio)) { +gpiod_set_value (gpio_to_desc (port->reset_gpio),0 );
Then there's no need for the conversion between the integer and the descriptor.
Quoted 22 lines
drivers/pci/controller/pci-tegra.c +12
-3+ }else { + value =afi_readl (port->pcie, ctrl); + value &= ~AFI_PEX_CTRL_RST ; +afi_writel (port->pcie, value, ctrl); + }usleep_range (1000 ,2000 ); - value =afi_readl (port->pcie, ctrl); - value |=AFI_PEX_CTRL_RST ; -afi_writel (port->pcie, value, ctrl); +if (gpio_is_valid (port->reset_gpio)) { +gpiod_set_value (gpio_to_desc (port->reset_gpio),1 ); + }else { + value =afi_readl (port->pcie, ctrl); + value |=AFI_PEX_CTRL_RST ; +afi_writel (port->pcie, value, ctrl); + } }static void tegra_pcie_enable_rp_features (struct tegra_pcie_port *port)
drivers/pci/controller/pci-tegra.c static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) · line 2314
Quoted 4 lines
drivers/pci/controller/pci-tegra.c +1
-0@@ -2299,6 +2311,18 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)if (IS_ERR (rp->base))return PTR_ERR (rp->base); + rp->reset_gpio =of_get_named_gpio (port,"reset-gpio" ,0 );
You can use devm_gpiod_get_from_of_node() to achieve this. Also, that function allows you to pass in flags, so you no longer need the below extra step to configure the GPIO.
drivers/pci/controller/pci-tegra.c static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) · line 2318
Quoted 4 lines
drivers/pci/controller/pci-tegra.c +4
-0+if (gpio_is_valid (rp->reset_gpio)) { + err =devm_gpio_request_one (dev, rp->reset_gpio, +GPIOF_OUT_INIT_LOW , +"pex_reset" );
Perhaps we want to include the port in the label somehow?
drivers/pci/controller/pci-tegra.c static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) · line 2320
Quoted 2 lines
drivers/pci/controller/pci-tegra.c +2
-0+if (err <0 ) { + dev_err(dev, "failed to request reset-gpio: %d\n",
Something like the below would be more consistent with the rest of the driver:
"failed to request reset GPIO: %d\n"
Thierry
Quoted 11 lines
drivers/pci/controller/pci-tegra.c +5
-0+ err); +return err; + } + } +list_add_tail (&rp->list, &pcie->ports); }Signature · 1 line
2.17.1
PATCH v2 28/28 PCI: tegra: Change link retry log level to info
In reply to Manikanta MaddireddyDriver checks for link up three times before giving up, each retry attempt is printed as an error. Letting users know that PCIe link is down and in the process of being brought up again is informational, not an error condition.
---
V2: Updated commit log
drivers/pci/controller/pci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-tegra.c +1 -1
@@ -2370,7 +2370,7 @@ static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port) }while (--timeout);if (!timeout) { -dev_err (dev,"link %u down, retrying\n" , port->index); +dev_info (dev,"link %u down, retrying\n" , port->index); goto retry; }
Signature · 1 line
2.17.1
Re: [PATCH V2 28/28] PCI: tegra: Change link retry log level to info
Quoted 10 lines · Manikanta Maddireddy
Driver checks for link up three times before giving up, each retry attempt is printed as an error. Letting users know that PCIe link is down and in the process of being brought up again is informational, not an error condition.
Signed-off-by Manikanta Maddireddy <[email protected]>---
V2: Updated commit logdrivers/pci/controller/pci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
I wonder if we even need the informational message at all. Is there any information in there that's useful to know? Do we care about how often the link-up was tried if it ends up being brought up in the end?
Thierry
Quoted 17 lines
drivers/pci/controller/pci-tegra.c +1
-1@@ -2370,7 +2370,7 @@ static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port) }while (--timeout);if (!timeout) { -dev_err (dev,"link %u down, retrying\n" , port->index); +dev_info (dev,"link %u down, retrying\n" , port->index); goto retry; }Signature · 1 line
2.17.1
Quoted 10 lines · Manikanta Maddireddy
This series of patches adds,
- Tegra root port features like Gen2, AER, etc
- Power and perf optimizations
- Fixes like "power up sequence", "dev_errprints", etcThis series of patches are tested on Tegra186 based Jetson-TX2, Tegra210 based Jetson-TX1 and T124 based Jetson-TK1 platforms.
TODO: I don't have T20 and T30 platforms to verify this series. Thierry has kindly agreed to verify this series on T20 and T30.
I tested this on TrimSlice and Beaver. next-20190426 boots via NFS on both of those boards. Applying this series on top of next-20190426 works on Beaver but does not work on TrimSlice. I'll see if I can bisect which exact commit breaks this, but it seems like PCI accesses do work, since I see the RTL8169 device being detected. But when the kernel tries to send out DHCP requests, the packet transmission is never completed using an interrupt, so maybe something interrupt related is broken.
Thierry
Quoted 41 lines
V2 takes care of comments from Bjorn and Thierry.
Manikanta Maddireddy (28):
soc/tegra: pmc: Exporttegra_powergate_power_on()
PCI: tegra: Handle failure cases integra_pcie_power_on()
PCI: tegra: Rearrange Tegra PCIe driver functions
PCI: tegra: Disable PCIe interrupts in runtime suspend
PCI: tegra: Fix PCIe host power up sequence
PCI: tegra: Add PCIe Gen2 link speed support
PCI: tegra: Advertise PCIe Advanced Error Reporting (AER) capability
PCI: tegra: Program UPHY electrical settings for Tegra210
PCI: tegra: Enable opportunistic UpdateFC and ACK
PCI: tegra: Disable AFI dynamic clock gating
PCI: tegra: Process pending DLL transactions before entering L1 or L2
PCI: tegra: Enable PCIe xclk clock clamping
PCI: tegra: Increase the deskew retry time
PCI: tegra: Add SW fixup for RAW violations
PCI: tegra: Update flow control timer frequency in Tegra210
PCI: tegra: Set target speed as Gen1 before starting LTSSM
PCI: tegra: Fix PLLE power down issue due to CLKREQ# signal
PCI: tegra: Program AFI_CACHE* registers only for Tegra20
PCI: tegra: ChangePRSNT_SENSEirq log to debug
PCI: tegra: Use legacy irq for port service drivers
PCI: tegra: AddAFI_PEX2_CTRLreg offset as part of soc struct
PCI: tegra: Access endpoint config only if PCIe link is up
dt-bindings: pci: tegra: Document PCIe DPD pinctrl optional prop
arm64: tegra: Add PEX DPD states as pinctrl properties
PCI: tegra: Put PEX CLK & BIAS pads in DPD mode
dt-bindings: pci: tegra: Document reset-gpio optional prop
PCI: tegra: Add support for GPIO based PCIe reset
PCI: tegra: Change link retry log level to info.../bindings/pci/nvidia,tegra20-pcie.txt | 13 + arch/arm64/boot/dts/nvidia/tegra210.dtsi | 19 + drivers/pci/controller/pci-tegra.c | 605 +++++++++++++++--- drivers/soc/tegra/pmc.c | 1 + 4 files changed, 558 insertions(+), 80 deletions(-)Signature · 1 line
2.17.1
Quoted 12 lines · Thierry Reding
Quoted 10 lines · Manikanta Maddireddy
This series of patches adds,
- Tegra root port features like Gen2, AER, etc
- Power and perf optimizations
- Fixes like "power up sequence", "dev_errprints", etcThis series of patches are tested on Tegra186 based Jetson-TX2, Tegra210 based Jetson-TX1 and T124 based Jetson-TK1 platforms.
TODO: I don't have T20 and T30 platforms to verify this series. Thierry has kindly agreed to verify this series on T20 and T30.
Quoted 7 lines
I tested this on TrimSlice and Beaver. next-20190426 boots via NFS on both of those boards. Applying this series on top of next-20190426 works on Beaver but does not work on TrimSlice. I'll see if I can bisect which exact commit breaks this, but it seems like PCI accesses do work, since I see the RTL8169 device being detected. But when the kernel tries to send out DHCP requests, the packet transmission is never completed using an interrupt, so maybe something interrupt related is broken.
I have marked this series as "deferred" in patchwork, more testing needed from what you are reporting.
Thanks,
Lorenzo
Quoted 43 lines
Thierry
Quoted 41 lines
V2 takes care of comments from Bjorn and Thierry.
Manikanta Maddireddy (28):
soc/tegra: pmc: Exporttegra_powergate_power_on()
PCI: tegra: Handle failure cases integra_pcie_power_on()
PCI: tegra: Rearrange Tegra PCIe driver functions
PCI: tegra: Disable PCIe interrupts in runtime suspend
PCI: tegra: Fix PCIe host power up sequence
PCI: tegra: Add PCIe Gen2 link speed support
PCI: tegra: Advertise PCIe Advanced Error Reporting (AER) capability
PCI: tegra: Program UPHY electrical settings for Tegra210
PCI: tegra: Enable opportunistic UpdateFC and ACK
PCI: tegra: Disable AFI dynamic clock gating
PCI: tegra: Process pending DLL transactions before entering L1 or L2
PCI: tegra: Enable PCIe xclk clock clamping
PCI: tegra: Increase the deskew retry time
PCI: tegra: Add SW fixup for RAW violations
PCI: tegra: Update flow control timer frequency in Tegra210
PCI: tegra: Set target speed as Gen1 before starting LTSSM
PCI: tegra: Fix PLLE power down issue due to CLKREQ# signal
PCI: tegra: Program AFI_CACHE* registers only for Tegra20
PCI: tegra: ChangePRSNT_SENSEirq log to debug
PCI: tegra: Use legacy irq for port service drivers
PCI: tegra: AddAFI_PEX2_CTRLreg offset as part of soc struct
PCI: tegra: Access endpoint config only if PCIe link is up
dt-bindings: pci: tegra: Document PCIe DPD pinctrl optional prop
arm64: tegra: Add PEX DPD states as pinctrl properties
PCI: tegra: Put PEX CLK & BIAS pads in DPD mode
dt-bindings: pci: tegra: Document reset-gpio optional prop
PCI: tegra: Add support for GPIO based PCIe reset
PCI: tegra: Change link retry log level to info.../bindings/pci/nvidia,tegra20-pcie.txt | 13 + arch/arm64/boot/dts/nvidia/tegra210.dtsi | 19 + drivers/pci/controller/pci-tegra.c | 605 +++++++++++++++--- drivers/soc/tegra/pmc.c | 1 + 4 files changed, 558 insertions(+), 80 deletions(-)Signature · 1 line
2.17.1
Quoted 19 lines · Lorenzo Pieralisi
Quoted 11 lines · Thierry Reding
Quoted 10 lines · Manikanta Maddireddy
This series of patches adds,
- Tegra root port features like Gen2, AER, etc
- Power and perf optimizations
- Fixes like "power up sequence", "dev_errprints", etcThis series of patches are tested on Tegra186 based Jetson-TX2, Tegra210 based Jetson-TX1 and T124 based Jetson-TK1 platforms.
TODO: I don't have T20 and T30 platforms to verify this series. Thierry has kindly agreed to verify this series on T20 and T30.
Quoted 7 lines
I tested this on TrimSlice and Beaver. next-20190426 boots via NFS on both of those boards. Applying this series on top of next-20190426 works on Beaver but does not work on TrimSlice. I'll see if I can bisect which exact commit breaks this, but it seems like PCI accesses do work, since I see the RTL8169 device being detected. But when the kernel tries to send out DHCP requests, the packet transmission is never completed using an interrupt, so maybe something interrupt related is broken.
Quoted 5 lines
I have marked this series as "deferred" in patchwork, more testing needed from what you are reporting.
Thanks,
Lorenzo
Hi Lorenzo,
Thierry found out that missing soc flag set in 18/28 patch caused the issue. He gave the simple patch to squash on top of 18/28.
I am waiting for review on other patches, so please mark them New. If you prefer new version for the review, I can publish new version with the fix.
Thanks,
Manikanta
Quoted 44 lines
Quoted 43 lines
Thierry
Quoted 41 lines
V2 takes care of comments from Bjorn and Thierry.
Manikanta Maddireddy (28):
soc/tegra: pmc: Exporttegra_powergate_power_on()
PCI: tegra: Handle failure cases integra_pcie_power_on()
PCI: tegra: Rearrange Tegra PCIe driver functions
PCI: tegra: Disable PCIe interrupts in runtime suspend
PCI: tegra: Fix PCIe host power up sequence
PCI: tegra: Add PCIe Gen2 link speed support
PCI: tegra: Advertise PCIe Advanced Error Reporting (AER) capability
PCI: tegra: Program UPHY electrical settings for Tegra210
PCI: tegra: Enable opportunistic UpdateFC and ACK
PCI: tegra: Disable AFI dynamic clock gating
PCI: tegra: Process pending DLL transactions before entering L1 or L2
PCI: tegra: Enable PCIe xclk clock clamping
PCI: tegra: Increase the deskew retry time
PCI: tegra: Add SW fixup for RAW violations
PCI: tegra: Update flow control timer frequency in Tegra210
PCI: tegra: Set target speed as Gen1 before starting LTSSM
PCI: tegra: Fix PLLE power down issue due to CLKREQ# signal
PCI: tegra: Program AFI_CACHE* registers only for Tegra20
PCI: tegra: ChangePRSNT_SENSEirq log to debug
PCI: tegra: Use legacy irq for port service drivers
PCI: tegra: AddAFI_PEX2_CTRLreg offset as part of soc struct
PCI: tegra: Access endpoint config only if PCIe link is up
dt-bindings: pci: tegra: Document PCIe DPD pinctrl optional prop
arm64: tegra: Add PEX DPD states as pinctrl properties
PCI: tegra: Put PEX CLK & BIAS pads in DPD mode
dt-bindings: pci: tegra: Document reset-gpio optional prop
PCI: tegra: Add support for GPIO based PCIe reset
PCI: tegra: Change link retry log level to info.../bindings/pci/nvidia,tegra20-pcie.txt | 13 + arch/arm64/boot/dts/nvidia/tegra210.dtsi | 19 + drivers/pci/controller/pci-tegra.c | 605 +++++++++++++++--- drivers/soc/tegra/pmc.c | 1 + 4 files changed, 558 insertions(+), 80 deletions(-)Signature · 1 line
2.17.1