Skip to contentSkip to conversation

Smatch issues reported for Marvell a38x DDR4

DISCUSSION Andrew Goodbody 3 participants 6 messages Jul 24, 2025 – Aug 5, 2025

lore
Share & tools
lore
#0 lore raw

Hi Stefan,

Smatch reports the following issues

drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:1029 mv_ddr4_center_of_mass_calc() warn: unsigned 'd_min' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2192 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2270 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: unsigned 'if_id' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: we never enter this loop drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:911 mv_ddr4_dqs_reposition() warn: always true condition '(delta >= 0) => (0-255 >= 0)' drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:924 mv_ddr4_dqs_reposition() warn: unsigned 'delta' is never less than zero.

As I have no way to validate the correctness of the code I am not confident enough to attempt to make the appropriate fixes in this case as it could affect its operation. Perhaps you would like to take a look?

Thanks,
Andrew

#1 lore raw

Hi Andrew,

Quoted 12 lines · Andrew Goodbody

Hi Stefan,

Smatch reports the following issues

drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:1029 mv_ddr4_center_of_mass_calc() warn: unsigned 'd_min' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2192 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2270 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: unsigned 'if_id' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: we never enter this loop drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:911 mv_ddr4_dqs_reposition() warn: always true condition '(delta >= 0) => (0-255 >= 0)' drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:924 mv_ddr4_dqs_reposition() warn: unsigned 'delta' is never less than zero.

Quoted 1 line

As I have no way to validate the correctness of the code I am not confident enough to attempt to make the appropriate fixes in this case as it could affect its operation. Perhaps you would like to take a look?

Sure, thanks for all your work on these smatch issues. Really appreciated.

But frankly, it's not easy to test anything in this area. I still have access to one board (AFAIK), but minor changes usually don't really make a notable difference in the DDR controller configuration here.

My suggestion is to send the patches (or one patch) "as best as you can" to the list for official review. I'll try to review and perhaps someone else with access to such a board will take a look.

Thanks,
Stefan

#2 lore raw
Quoted 24 lines · Stefan Roese

Hi Andrew,

Quoted 12 lines · Andrew Goodbody

Hi Stefan,

Smatch reports the following issues

drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:1029 mv_ddr4_center_of_mass_calc() warn: unsigned 'd_min' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2192 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2270 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: unsigned 'if_id' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: we never enter this loop drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:911 mv_ddr4_dqs_reposition() warn: always true condition '(delta >= 0) => (0-255 >= 0)' drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:924 mv_ddr4_dqs_reposition() warn: unsigned 'delta' is never less than zero.

Quoted 1 line

As I have no way to validate the correctness of the code I am not confident enough to attempt to make the appropriate fixes in this case as it could affect its operation. Perhaps you would like to take a look?

Sure, thanks for all your work on these smatch issues. Really appreciated.

But frankly, it's not easy to test anything in this area. I still have access to one board (AFAIK), but minor changes usually don't really make a notable difference in the DDR controller configuration here.

Quoted 6 lines

My suggestion is to send the patches (or one patch) "as best as you can" to the list for official review. I'll try to review and perhaps someone else with access to such a board will take a look.

Thanks,
Stefan

OK, patch coming. It was not as invasive as I feared.

Andrew

#3 lore raw

Hi Andrew,

Quoted 37 lines · Andrew Goodbody
Quoted 35 lines · Stefan Roese

Hi Andrew,

Quoted 21 lines · Andrew Goodbody

Hi Stefan,

Smatch reports the following issues

drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:1029 mv_ddr4_center_of_mass_calc() warn: unsigned 'd_min' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2192 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2270 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: unsigned 'if_id' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: we never enter this loop drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:911 mv_ddr4_dqs_reposition() warn: always true condition '(delta >= 0) => (0-255 >= 0)' drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:924 mv_ddr4_dqs_reposition() warn: unsigned 'delta' is never less than zero.

Quoted 3 lines

As I have no way to validate the correctness of the code I am not confident enough to attempt to make the appropriate fixes in this case as it could affect its operation. Perhaps you would like to take a look?

Sure, thanks for all your work on these smatch issues. Really appreciated.

But frankly, it's not easy to test anything in this area. I still have access to one board (AFAIK), but minor changes usually don't really make a notable difference in the DDR controller configuration here.

Quoted 9 lines
Quoted 6 lines

My suggestion is to send the patches (or one patch) "as best as you can" to the list for official review. I'll try to review and perhaps someone else with access to such a board will take a look.

Thanks,
Stefan

OK, patch coming. It was not as invasive as I feared.

Please add me to the CC list of your patches. I'll be available (in a couple weeks) to run regression tests for this Armada 38x DDR4 area.

All the best,
Tony

Quoted 1 line

Andrew

#4 lore raw

Hi Tony,

Quoted 45 lines · Tony Dinh

Hi Andrew,

Quoted 41 lines · Andrew Goodbody
Quoted 39 lines · Stefan Roese

Hi Andrew,

Quoted 21 lines · Andrew Goodbody

Hi Stefan,

Smatch reports the following issues

drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:1029 mv_ddr4_center_of_mass_calc() warn: unsigned 'd_min' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2192 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2270 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: unsigned 'if_id' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: we never enter this loop drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:911 mv_ddr4_dqs_reposition() warn: always true condition '(delta >= 0) => (0-255 >= 0)' drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:924 mv_ddr4_dqs_reposition() warn: unsigned 'delta' is never less than zero.

Quoted 3 lines

As I have no way to validate the correctness of the code I am not confident enough to attempt to make the appropriate fixes in this case as it could affect its operation. Perhaps you would like to take a look?

Sure, thanks for all your work on these smatch issues. Really appreciated.

But frankly, it's not easy to test anything in this area. I still have access to one board (AFAIK), but minor changes usually don't really make a notable difference in the DDR controller configuration here.

My suggestion is to send the patches (or one patch) "as best as you can" to the list for official review. I'll try to review and perhaps someone else with access to such a board will take a look.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Thanks,
Stefan

OK, patch coming. It was not as invasive as I feared.

Please add me to the CC list of your patches. I'll be available (in a couple weeks) to run regression tests for this Armada 38x DDR4 area.

The (one) patch is already in master. It would be great though, if you could run some regression tests once time permits though.

Thanks,
Stefan

#5 lore raw

Hi Stefan,

Quoted 52 lines · Stefan Roese

Hi Tony,

Quoted 48 lines · Tony Dinh

Hi Andrew,

Quoted 44 lines · Andrew Goodbody
Quoted 41 lines · Stefan Roese

Hi Andrew,

Quoted 21 lines · Andrew Goodbody

Hi Stefan,

Smatch reports the following issues

drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:1029 mv_ddr4_center_of_mass_calc() warn: unsigned 'd_min' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2192 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:2270 mv_ddr4_dm_tuning() warn: unsigned 'reg_val' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: unsigned 'if_id' is never less than zero. drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:662 mv_ddr4_centralization() warn: we never enter this loop drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:911 mv_ddr4_dqs_reposition() warn: always true condition '(delta >= 0) => (0-255 >= 0)' drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:924 mv_ddr4_dqs_reposition() warn: unsigned 'delta' is never less than zero.

Quoted 3 lines

As I have no way to validate the correctness of the code I am not confident enough to attempt to make the appropriate fixes in this case as it could affect its operation. Perhaps you would like to take a look?

Sure, thanks for all your work on these smatch issues. Really appreciated.

But frankly, it's not easy to test anything in this area. I still have access to one board (AFAIK), but minor changes usually don't really make a notable difference in the DDR controller configuration here.

My suggestion is to send the patches (or one patch) "as best as you can" to the list for official review. I'll try to review and perhaps someone else with access to such a board will take a look.

Thanks,
Stefan

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

OK, patch coming. It was not as invasive as I feared.

Please add me to the CC list of your patches. I'll be available (in a couple weeks) to run regression tests for this Armada 38x DDR4 area.

The (one) patch is already in master. It would be great though, if you could run some regression tests once time permits though.

Ah, I see that patch has covered all the error cases. Will do the regression test.

All the best,
Tony

Quoted 4 lines

Thanks,
Stefan