diff mbox series

[next,RFC,5/5] ram: rk3399: fail DRAM init when pctl channel init fails instead of hanging

Message ID 20241105-rk3399-dram-init-v1-5-1e29acdf0966@cherry.de
State New
Delegated to: Kever Yang
Headers show
Series rockchip: panic() when DRAM init fails | expand

Commit Message

Quentin Schulz Nov. 5, 2024, 5:21 p.m. UTC
From: Quentin Schulz <quentin.schulz@cherry.de>

Instead of hanging via an infinite while loop, propagate the fail to the
caller and let it handle the fail. For RK3399, this means that panic()
will be called, (by default) resetting the CPU and giving another chance
at doing a DRAM init.

Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
---
 drivers/ram/rockchip/sdram_rk3399.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Kever Yang Nov. 8, 2024, 3:19 a.m. UTC | #1
Hi Quentin,

On 2024/11/6 01:21, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz@cherry.de>
>
> Instead of hanging via an infinite while loop, propagate the fail to the
> caller and let it handle the fail. For RK3399, this means that panic()
> will be called, (by default) resetting the CPU and giving another chance
> at doing a DRAM init.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
> ---
>   drivers/ram/rockchip/sdram_rk3399.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c
> index d953dda13cd3daa689fa362dc511c372db454064..591e1469afb25ba606d8f7e44f63e50905b4ab31 100644
> --- a/drivers/ram/rockchip/sdram_rk3399.c
> +++ b/drivers/ram/rockchip/sdram_rk3399.c
> @@ -817,8 +817,7 @@ static int pctl_start(struct dram_info *dram,
>   			if (count > 1000) {

Could you try with increase the timeout count from 1000 to 1000000?

Thanks,

- Kever

>   				printf("%s: Failed to init pctl channel 0\n",
>   				       __func__);
> -				while (1)
> -					;
> +				return -1;
>   			}
>   			udelay(1);
>   			count++;
> @@ -853,8 +852,7 @@ static int pctl_start(struct dram_info *dram,
>   			if (count > 1000) {
>   				printf("%s: Failed to init pctl channel 1\n",
>   				       __func__);
> -				while (1)
> -					;
> +				return -2;
>   			}
>   			udelay(1);
>   			count++;
>
Quentin Schulz Nov. 8, 2024, 6:43 p.m. UTC | #2
Hi Kever,

On 11/8/24 4:19 AM, Kever Yang wrote:
> Hi Quentin,
> 
> On 2024/11/6 01:21, Quentin Schulz wrote:
>> From: Quentin Schulz <quentin.schulz@cherry.de>
>>
>> Instead of hanging via an infinite while loop, propagate the fail to the
>> caller and let it handle the fail. For RK3399, this means that panic()
>> will be called, (by default) resetting the CPU and giving another chance
>> at doing a DRAM init.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
>> ---
>>   drivers/ram/rockchip/sdram_rk3399.c | 6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/ 
>> rockchip/sdram_rk3399.c
>> index 
>> d953dda13cd3daa689fa362dc511c372db454064..591e1469afb25ba606d8f7e44f63e50905b4ab31 100644
>> --- a/drivers/ram/rockchip/sdram_rk3399.c
>> +++ b/drivers/ram/rockchip/sdram_rk3399.c
>> @@ -817,8 +817,7 @@ static int pctl_start(struct dram_info *dram,
>>               if (count > 1000) {
> 
> Could you try with increase the timeout count from 1000 to 1000000?
> 

Just tested, didn't help, failed at the same place.

Cheers,
Quentin
diff mbox series

Patch

diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c
index d953dda13cd3daa689fa362dc511c372db454064..591e1469afb25ba606d8f7e44f63e50905b4ab31 100644
--- a/drivers/ram/rockchip/sdram_rk3399.c
+++ b/drivers/ram/rockchip/sdram_rk3399.c
@@ -817,8 +817,7 @@  static int pctl_start(struct dram_info *dram,
 			if (count > 1000) {
 				printf("%s: Failed to init pctl channel 0\n",
 				       __func__);
-				while (1)
-					;
+				return -1;
 			}
 			udelay(1);
 			count++;
@@ -853,8 +852,7 @@  static int pctl_start(struct dram_info *dram,
 			if (count > 1000) {
 				printf("%s: Failed to init pctl channel 1\n",
 				       __func__);
-				while (1)
-					;
+				return -2;
 			}
 			udelay(1);
 			count++;