Skip to content

Commit

Permalink
arch/risc-v/src/mpfs/mpfs_ddr.c: Re-try DDR training on any error
Browse files Browse the repository at this point in the history
Also errors which currently return other than -EAGAIN, are typically
recoverable with retraining. So just re-try trainining 20 times on any
error, resetting the controller in between.

Only reset if it is not recovered in this time.

Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed Jan 29, 2025
1 parent 4e8326d commit 44558d5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions arch/risc-v/src/mpfs/mpfs_ddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3941,19 +3941,30 @@ static int mpfs_ddr_setup(struct mpfs_ddr_priv_s *priv)
int mpfs_ddr_init(void)
{
struct mpfs_ddr_priv_s *priv = &g_mpfs_ddr_priv;
int ddr_status;

/* On -EAGAIN, the whole training is restarted from the very beginning */
int ddr_status = -EAGAIN;
int retry_count = 20;

/* Restart training until it passes or retry_count reaches 0.
* Errors which return -EAGAIN are known to be always
* recoverable by controller reset; don't count these errors.
* Only count errors which return -EIO; they are typically recoverable.
* If they persist, however, eventually return failure, leading to
* re-trying after full reset.
*/

do
while (ddr_status != OK && retry_count > 0)
{
ddr_status = mpfs_ddr_setup(priv);
if (ddr_status == -EAGAIN)
if (ddr_status != OK)
{
mpfs_ddr_fail(priv);
}

if (ddr_status != -EAGAIN)
{
retry_count--;
}
}
while (ddr_status == -EAGAIN);

if (ddr_status == 0)
{
Expand Down

0 comments on commit 44558d5

Please sign in to comment.