mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] PCI: spacemit: Ignore PERST# bit for controllers
@ 2026-11-04 14:07 Ali Tariq
  2026-11-04 14:14 ` Troy Mitchell
  0 siblings, 1 reply; 3+ messages in thread
From: Ali Tariq @ 2026-11-04 14:07 UTC (permalink / raw)
  To: Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, linux-pci
  Cc: Ali Tariq, Rob Herring, Yixun Lan, Troy Mitchell, Ping-Ke Shih,
	Anirudh Srinivasan, Alex Elder, Vladimir Oltean,
	Uwe Kleine-König (The Capable Hub),
	Pengpeng Hou, open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support, open list

The k1_pcie_init() does not set PCIE_IGNORE_PERSTN bit of the
control logic register, which causes controller to reset itself once
PERST# signal is asserted even when acting as host.
On Orange Pi RV2 (SpacemiT K1), this resets the controller and wipes
the IDs. k1_pcie_deinit() leaves PERST# asserted, so when k1_pcie_init()
runs again, its first DBI access hangs the CPU.

Set PCIE_IGNORE_PERSTN bit of the control logic register of APMU
in k1_pcie_init() before enabling resources so controllers
dont end up resetting themselves when PERST# signal is asserted.

Fixes: ff64e078e45f ("PCI: spacemit: Add SpacemiT PCIe host driver")
Signed-off-by: Ali Tariq <alitariq45892@gmail.com>
---
Hang log: https://kernelci.cloud-v.co/scheduler/job/420
Fixed Log: https://kernelci.cloud-v.co/scheduler/job/430
---
 drivers/pci/controller/dwc/pcie-spacemit-k1.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
index 92a71ea90ac3..af6028e8825a 100644
--- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
+++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
@@ -47,6 +47,7 @@
 
 #define PCIE_CONTROL_LOGIC			0x0004
 #define PCIE_SOFT_RESET			BIT(0)
+#define PCIE_IGNORE_PERSTN		BIT(2)	/* 1: ignore PERST# */
 
 struct k1_pcie {
 	struct dw_pcie pci;
@@ -131,11 +132,19 @@ static int k1_pcie_init(struct dw_pcie_rp *pp)
 	struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
 	struct k1_pcie *k1 = to_k1_pcie(pci);
 	u32 reset_ctrl;
+	u32 ctrl_logic;
 	u32 val;
 	int ret;
 
 	k1_pcie_toggle_soft_reset(k1);
 
+	/*
+	 * Ignore the PERST# signal so the controller does not reset
+	 * itself when it pulls PERST# low.
+	 */
+	ctrl_logic = k1->pmu_off + PCIE_CONTROL_LOGIC;
+	regmap_set_bits(k1->pmu, ctrl_logic, PCIE_IGNORE_PERSTN);
+
 	ret = k1_pcie_enable_resources(k1);
 	if (ret)
 		return ret;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: spacemit: Ignore PERST# bit for controllers
  2026-11-04 14:07 [PATCH] PCI: spacemit: Ignore PERST# bit for controllers Ali Tariq
@ 2026-11-04 14:14 ` Troy Mitchell
  2026-11-04 15:38   ` Ali Tariq
  0 siblings, 1 reply; 3+ messages in thread
From: Troy Mitchell @ 2026-11-04 14:14 UTC (permalink / raw)
  To: Ali Tariq, Bjorn Helgaas, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, linux-pci
  Cc: Rob Herring, Yixun Lan, Troy Mitchell, Ping-Ke Shih,
	Anirudh Srinivasan, Alex Elder, Vladimir Oltean,
	Uwe Kleine-König (The Capable Hub),
	Pengpeng Hou, open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support, open list

[-- Attachment #1: Type: text/plain, Size: 1622 bytes --]

On Wed Nov 4, 2026 at 2:07 PM GMT, Ali Tariq wrote:
> The k1_pcie_init() does not set PCIE_IGNORE_PERSTN bit of the
> control logic register, which causes controller to reset itself once
> PERST# signal is asserted even when acting as host.
> On Orange Pi RV2 (SpacemiT K1), this resets the controller and wipes
> the IDs. k1_pcie_deinit() leaves PERST# asserted, so when k1_pcie_init()
> runs again, its first DBI access hangs the CPU.
>
> Set PCIE_IGNORE_PERSTN bit of the control logic register of APMU
> in k1_pcie_init() before enabling resources so controllers
> dont end up resetting themselves when PERST# signal is asserted.
>
> Fixes: ff64e078e45f ("PCI: spacemit: Add SpacemiT PCIe host driver")
> Signed-off-by: Ali Tariq <alitariq45892@gmail.com>
> ---
> Hang log: https://kernelci.cloud-v.co/scheduler/job/420
> Fixed Log: https://kernelci.cloud-v.co/scheduler/job/430
> ---
>  drivers/pci/controller/dwc/pcie-spacemit-k1.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
> index 92a71ea90ac3..af6028e8825a 100644
> --- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
> +++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
> @@ -47,6 +47,7 @@
>  
>  #define PCIE_CONTROL_LOGIC			0x0004
>  #define PCIE_SOFT_RESET			BIT(0)
> +#define PCIE_IGNORE_PERSTN		BIT(2)	/* 1: ignore PERST# */
A similar but earlier patch can be found here [1]

Link: https://lore.kernel.org/all/20260924-spacemit-k1-pcie-fix-v1-1-002b5c1ba9fc@linux.spacemit.com/ [1]

-- 
Troy Mitchell


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: spacemit: Ignore PERST# bit for controllers
  2026-11-04 14:14 ` Troy Mitchell
@ 2026-11-04 15:38   ` Ali Tariq
  0 siblings, 0 replies; 3+ messages in thread
From: Ali Tariq @ 2026-11-04 15:38 UTC (permalink / raw)
  To: Troy Mitchell, Bjorn Helgaas, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, linux-pci
  Cc: Rob Herring, Yixun Lan, Ping-Ke Shih, Anirudh Srinivasan,
	Alex Elder, Vladimir Oltean,
	Uwe Kleine-König (The Capable Hub),
	Pengpeng Hou, open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support, open list



On 11/4/26 7:14 PM, Troy Mitchell wrote:
> On Wed Nov 4, 2026 at 2:07 PM GMT, Ali Tariq wrote:
>> The k1_pcie_init() does not set PCIE_IGNORE_PERSTN bit of the
>> control logic register, which causes controller to reset itself once
>> PERST# signal is asserted even when acting as host.
>> On Orange Pi RV2 (SpacemiT K1), this resets the controller and wipes
>> the IDs. k1_pcie_deinit() leaves PERST# asserted, so when k1_pcie_init()
>> runs again, its first DBI access hangs the CPU.
>>
>> Set PCIE_IGNORE_PERSTN bit of the control logic register of APMU
>> in k1_pcie_init() before enabling resources so controllers
>> dont end up resetting themselves when PERST# signal is asserted.
>>
>> Fixes: ff64e078e45f ("PCI: spacemit: Add SpacemiT PCIe host driver")
>> Signed-off-by: Ali Tariq <alitariq45892@gmail.com>
>> ---
>> Hang log: https://kernelci.cloud-v.co/scheduler/job/420
>> Fixed Log: https://kernelci.cloud-v.co/scheduler/job/430
>> ---
>>   drivers/pci/controller/dwc/pcie-spacemit-k1.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
>> index 92a71ea90ac3..af6028e8825a 100644
>> --- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
>> +++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
>> @@ -47,6 +47,7 @@
>>   
>>   #define PCIE_CONTROL_LOGIC			0x0004
>>   #define PCIE_SOFT_RESET			BIT(0)
>> +#define PCIE_IGNORE_PERSTN		BIT(2)	/* 1: ignore PERST# */
> A similar but earlier patch can be found here [1]
> 
> Link: https://lore.kernel.org/all/20260924-spacemit-k1-pcie-fix-v1-1-002b5c1ba9fc@linux.spacemit.com/ [1]
> 

Thank you for pointing.

I missed that. I will check that patch.

You can drop my patch.

Regards,
Ali


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-04 15:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 14:07 [PATCH] PCI: spacemit: Ignore PERST# bit for controllers Ali Tariq
2026-11-04 14:14 ` Troy Mitchell
2026-11-04 15:38   ` Ali Tariq

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®