Skip to contentSkip to conversation

iMX ddrphy_utils difference with U-boot

DISCUSSION Andrei Lalaev 3 participants 9 messages Jun 8 – Aug 19

lore
Share & tools
lore
#0 lore raw

Hi,

I am moving an iMX8MP module from vendor U-Boot 2024.04 to Barebox 2025.02 and found a strange difference in the DDR training code:

vim drivers/ddr/imx/ddrphy_utils.c +94

And the corresponding line in U-Boot:

vim drivers/ddr/imx/phy/ddrphy_utils.c +101

Is there any chance that somebody knows/remembers why "return -1" was replaced with "hang()"?

I couldn't find any explanation in the commits/mailing lists.

Thanks a lot!

--
Best regards,
Andrei Lalaev

#1 lore raw

Hello Andrei,

Quoted 3 lines · Andrei Lalaev

Hi,

I am moving an iMX8MP module from vendor U-Boot 2024.04 to Barebox 2025.02

Sidenote: You'll probably want to use one of the still supported v2026.04 or v2026.06 releases.

Quoted 9 lines

and found a strange difference in the DDR training code:

vim drivers/ddr/imx/ddrphy_utils.c +94

And the corresponding line in U-Boot:

vim drivers/ddr/imx/phy/ddrphy_utils.c +101

Is there any chance that somebody knows/remembers why "return -1" was replaced with "hang()"?

I can't speak for Sascha, but having looked at the code, I see no reason why not to propagate the error.

Quoted 1 line

I couldn't find any explanation in the commits/mailing lists.

My guess is that it wasn't anticipated that boards would handle the error gracefully to fall back to a different DDR init.

Cheers,
Ahmad

Quoted 9 lines

Thanks a lot!

--
Best regards,
Andrei Lalaev

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#2 lore raw

Hi Ahmad,

Thank you for your quick reply.

Quoted 10 lines · Ahmad Fatoum

Hello Andrei,

Quoted 3 lines · Andrei Lalaev

Hi,

I am moving an iMX8MP module from vendor U-Boot 2024.04 to Barebox 2025.02

Sidenote: You'll probably want to use one of the still supported v2026.04 or v2026.06 releases.

That's our plan for the near future :)

Quoted 10 lines
Quoted 9 lines

and found a strange difference in the DDR training code:

vim drivers/ddr/imx/ddrphy_utils.c +94

And the corresponding line in U-Boot:

vim drivers/ddr/imx/phy/ddrphy_utils.c +101

Is there any chance that somebody knows/remembers why "return -1" was replaced with "hang()"?

Quoted 8 lines

I can't speak for Sascha, but having looked at the code, I see no reason why not to propagate the error.

Quoted 1 line

I couldn't find any explanation in the commits/mailing lists.

My guess is that it wasn't anticipated that boards would handle the error gracefully to fall back to a different DDR init.

In our case this is the only option, because we may have 2 and 4 GB modules. So, if the 4 GB timings don't apply, we fall back to the 2 GB timings.

Quoted 2 lines

Cheers,
Ahmad

Signature · 2 lines
Best regards,
Andrei Lalaev
#3 lore raw

Hi,

Quoted 32 lines · Andrei Lalaev

Hi Ahmad,

Thank you for your quick reply.

Quoted 10 lines · Ahmad Fatoum

Hello Andrei,

Quoted 3 lines · Andrei Lalaev

Hi,

I am moving an iMX8MP module from vendor U-Boot 2024.04 to Barebox 2025.02

Sidenote: You'll probably want to use one of the still supported v2026.04 or v2026.06 releases.

That's our plan for the near future :)

Quoted 13 lines
Quoted 9 lines

and found a strange difference in the DDR training code:

vim drivers/ddr/imx/ddrphy_utils.c +94

And the corresponding line in U-Boot:

vim drivers/ddr/imx/phy/ddrphy_utils.c +101

Is there any chance that somebody knows/remembers why "return -1" was replaced with "hang()"?

I can't speak for Sascha, but having looked at the code, I see no reason why not to propagate the error.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

I couldn't find any explanation in the commits/mailing lists.

My guess is that it wasn't anticipated that boards would handle the error gracefully to fall back to a different DDR init.

In our case this is the only option, because we may have 2 and 4 GB modules. So, if the 4 GB timings don't apply, we fall back to the 2 GB timings.

Send a patch and we continue the discussion there?

Cheers,
Ahmad

Quoted 6 lines
Quoted 4 lines

Cheers,
Ahmad

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#7 lore raw
In reply to Andrei Lalaev

Hello Andrei,

Quoted 26 lines · Andrei Lalaev

Hi,

I am moving an iMX8MP module from vendor U-Boot 2024.04 to Barebox 2025.02 and found a strange difference in the DDR training code:

vim drivers/ddr/imx/ddrphy_utils.c +94

And the corresponding line in U-Boot:

vim drivers/ddr/imx/phy/ddrphy_utils.c +101

Is there any chance that somebody knows/remembers why "return -1" was replaced with "hang()"?

I couldn't find any explanation in the commits/mailing lists.

Thanks a lot!

--
Best regards,
Andrei Lalaev

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#8 lore raw

sorry for the noise. Sent a draft instead of discarding it :/

Quoted 31 lines · Ahmad Fatoum

Hello Andrei,

Quoted 26 lines · Andrei Lalaev

Hi,

I am moving an iMX8MP module from vendor U-Boot 2024.04 to Barebox 2025.02 and found a strange difference in the DDR training code:

vim drivers/ddr/imx/ddrphy_utils.c +94

And the corresponding line in U-Boot:

vim drivers/ddr/imx/phy/ddrphy_utils.c +101

Is there any chance that somebody knows/remembers why "return -1" was replaced with "hang()"?

I couldn't find any explanation in the commits/mailing lists.

Thanks a lot!

--
Best regards,
Andrei Lalaev

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#4 lore raw
In reply to Ahmad Fatoum
Quoted 20 lines · Ahmad Fatoum

Hello Andrei,

Quoted 3 lines · Andrei Lalaev

Hi,

I am moving an iMX8MP module from vendor U-Boot 2024.04 to Barebox 2025.02

Sidenote: You'll probably want to use one of the still supported v2026.04 or v2026.06 releases.

Quoted 9 lines

and found a strange difference in the DDR training code:

vim drivers/ddr/imx/ddrphy_utils.c +94

And the corresponding line in U-Boot:

vim drivers/ddr/imx/phy/ddrphy_utils.c +101

Is there any chance that somebody knows/remembers why "return -1" was replaced with "hang()"?

Quoted 7 lines

I can't speak for Sascha, but having looked at the code, I see no reason why not to propagate the error.

Quoted 1 line

I couldn't find any explanation in the commits/mailing lists.

My guess is that it wasn't anticipated that boards would handle the error gracefully to fall back to a different DDR init.

That's my guess as well. Note the callers of imx8m_wait_ddrphy_training_complete() which is only a wrapper around calling wait_ddrphy_training_complete() do not check the error code, so when changing it back to return an error code we likely want to add error checking where missing.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#5 lore raw

Hi,

Quoted 26 lines · Sascha Hauer
Quoted 25 lines · Ahmad Fatoum

Hello Andrei,

Quoted 3 lines · Andrei Lalaev

Hi,

I am moving an iMX8MP module from vendor U-Boot 2024.04 to Barebox 2025.02

Sidenote: You'll probably want to use one of the still supported v2026.04 or v2026.06 releases.

Quoted 9 lines

and found a strange difference in the DDR training code:

vim drivers/ddr/imx/ddrphy_utils.c +94

And the corresponding line in U-Boot:

vim drivers/ddr/imx/phy/ddrphy_utils.c +101

Is there any chance that somebody knows/remembers why "return -1" was replaced with "hang()"?

I can't speak for Sascha, but having looked at the code, I see no reason why not to propagate the error.

Quoted 1 line

I couldn't find any explanation in the commits/mailing lists.

Quoted 8 lines
Quoted 2 lines

My guess is that it wasn't anticipated that boards would handle the error gracefully to fall back to a different DDR init.

That's my guess as well. Note the callers of imx8m_wait_ddrphy_training_complete() which is only a wrapper around calling wait_ddrphy_training_complete() do not check the error code, so when changing it back to return an error code we likely want to add error checking where missing.

I just stumbled upon this patch:
https://lore.kernel.org/all/[email protected]/

If we start allowing ddr_cfg_phy to propagate this error, you'll likely want above patch as well.

Cheers,
Ahmad

Quoted 3 lines

Sascha

Signature · 4 lines
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |
#6 lore raw
Quoted 38 lines · Ahmad Fatoum

Hi,

Quoted 26 lines · Sascha Hauer
Quoted 25 lines · Ahmad Fatoum

Hello Andrei,

Quoted 3 lines · Andrei Lalaev

Hi,

I am moving an iMX8MP module from vendor U-Boot 2024.04 to Barebox 2025.02

Sidenote: You'll probably want to use one of the still supported v2026.04 or v2026.06 releases.

Quoted 9 lines

and found a strange difference in the DDR training code:

vim drivers/ddr/imx/ddrphy_utils.c +94

And the corresponding line in U-Boot:

vim drivers/ddr/imx/phy/ddrphy_utils.c +101

Is there any chance that somebody knows/remembers why "return -1" was replaced with "hang()"?

I can't speak for Sascha, but having looked at the code, I see no reason why not to propagate the error.

Quoted 1 line

I couldn't find any explanation in the commits/mailing lists.

Quoted 8 lines
Quoted 2 lines

My guess is that it wasn't anticipated that boards would handle the error gracefully to fall back to a different DDR init.

That's my guess as well. Note the callers of imx8m_wait_ddrphy_training_complete() which is only a wrapper around calling wait_ddrphy_training_complete() do not check the error code, so when changing it back to return an error code we likely want to add error checking where missing.

Quoted 5 lines

I just stumbled upon this patch:
https://lore.kernel.org/all/[email protected]/

If we start allowing ddr_cfg_phy to propagate this error, you'll likely want above patch as well.

Or maybe not. Just thought to let you know.

Cheers,
Ahmad

Quoted 8 lines

Cheers,
Ahmad

Quoted 3 lines

Sascha

Signature · 4 lines
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |