i2c: stm32f7_i2c: save some ms in stm32_i2c_choose_solution
PATCH 1/1 i2c: stm32f7_i2c: save some ms in stm32_i2c_choose_solution
In stm32_i2c_choose_solution, the double loop continues even after a solution is found.
Breaking out of this double loop once a solution is found permits to gain some precious ms.
This saves about 13ms in U-Boot.
--- drivers/i2c/stm32f7_i2c.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i2c/stm32f7_i2c.c +2 -0
@@ -651,11 +651,13 @@ static int stm32_i2c_choose_solution(u32 i2cclk, v->sclh = h; sol_found = true;memcpy (s, v,sizeof (*s)); + goto end_loop; } } } } } +end_loop:if (!sol_found) {log_err ("no solution at all\n" );
base-commit: c5e6d2ab7eba68cbfb600cdc131c0c375ced2ec9
Signature · 1 line
2.47.3
Quoted 32 lines · Richard Genoud
In
stm32_i2c_choose_solution, the double loop continues even after a solution is found.Breaking out of this double loop once a solution is found permits to gain some precious ms.
This saves about 13ms in U-Boot.
Signed-off-by Richard Genoud <[email protected]>--- drivers/i2c/stm32f7_i2c.c | 2 ++ 1 file changed, 2 insertions(+)drivers/i2c/stm32f7_i2c.c +2
-0@@ -651,11 +651,13 @@ static int stm32_i2c_choose_solution(u32 i2cclk, v->sclh = h; sol_found = true;memcpy (s, v,sizeof (*s)); + goto end_loop; } } } } } +end_loop:if (!sol_found) {log_err ("no solution at all\n" );
Quoted 1 line
base-commit:
c5e6d2ab7eba68cbfb600cdc131c0c375ced2ec9
Hi Richard
If i have well understood the algorithm, the original implementation selects the *best* solution whereas with your patch, the algorithm selects the *first* solution.
Patrice
Le 05/12/2025 à 17:49, Patrice CHOTARD a écrit :
Quoted 40 lines · Richard Genoud
Quoted 32 lines
In
stm32_i2c_choose_solution, the double loop continues even after a solution is found.Breaking out of this double loop once a solution is found permits to gain some precious ms.
This saves about 13ms in U-Boot.
Signed-off-by Richard Genoud <[email protected]>--- drivers/i2c/stm32f7_i2c.c | 2 ++ 1 file changed, 2 insertions(+)drivers/i2c/stm32f7_i2c.c +2
-0@@ -651,11 +651,13 @@ static int stm32_i2c_choose_solution(u32 i2cclk, v->sclh = h; sol_found = true;memcpy (s, v,sizeof (*s)); + goto end_loop; } } } } } +end_loop:if (!sol_found) {log_err ("no solution at all\n" );Quoted 1 line
base-commit:
c5e6d2ab7eba68cbfb600cdc131c0c375ced2ec9Hi Richard
Quoted 4 lines
If i have well understood the algorithm, the original implementation selects the *best* solution whereas with your patch, the algorithm selects the *first* solution.
Patrice
Hum, indeed. The solution with the lesser error is selected.
I'll have to study this algorithm a little bit more to see it we can take some shortcut.
Thanks!
Regards,
Richard