ath9k: eeprom: alias vpdTableI onto vpdTableL to shrink stack frame
PATCH 1/1 ath9k: eeprom: alias vpdTableI onto vpdTableL to shrink stack frame
vpdTableL, vpdTableR, and vpdTableI are never live simultaneously. vpdTableL and vpdTableR are consumed during the frequency-interpolation step that writes vpdTableI; after the if/else they are never read again. Reuse vpdTableL for the interpolated result (what was vpdTableI), reducing the stack frame by one 256-byte array.
The read-via-write in the else branch is safe: ath9k_hw_interpolate() receives vpdTableL[i][j] by value as a function argument before the return value is written back to vpdTableL[i][j].
Stack frame size change (x86_64, clang):
before: 0x440 (1088 B)
after: 0x330 (816 B)
--- drivers/net/wireless/ath/ath9k/eeprom.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath9k/eeprom.c +10 -12
@@ -464,8 +464,6 @@ void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah, [AR5416_MAX_PWR_RANGE_IN_HALF_DB ];static u8 vpdTableR[AR5416_NUM_PD_GAINS ] [AR5416_MAX_PWR_RANGE_IN_HALF_DB ]; -static u8 vpdTableI[AR5416_NUM_PD_GAINS ] - [AR5416_MAX_PWR_RANGE_IN_HALF_DB ];u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;u8 minPwrT4[AR5416_NUM_PD_GAINS ];
@@ -509,7 +507,7 @@ void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah, data_9287[idxL].pwrPdg[i], data_9287[idxL].vpdPdg[i], intercepts, - vpdTableI[i]); + vpdTableL[i]); } }else if (eeprom_4k) {for (i =0 ; i < numXpdGains; i++) {
@@ -519,7 +517,7 @@ void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah, data_4k[idxL].pwrPdg[i], data_4k[idxL].vpdPdg[i], intercepts, - vpdTableI[i]); + vpdTableL[i]); } }else {for (i =0 ; i < numXpdGains; i++) {
@@ -529,7 +527,7 @@ void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah, data_def[idxL].pwrPdg[i], data_def[idxL].vpdPdg[i], intercepts, - vpdTableI[i]); + vpdTableL[i]); } } }else {
@@ -568,7 +566,7 @@ void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah, vpdTableR[i]); for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) { - vpdTableI[i][j] = + vpdTableL[i][j] = (u8)(ath9k_hw_interpolate((u16) FREQ2FBIN(centers. synth_center,
@@ -605,11 +603,11 @@ void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah, (minPwrT4[i] / 2)) - tPdGainOverlap + 1 + minDelta); } - vpdStep = (int16_t )(vpdTableI[i][1 ] - vpdTableI[i][0 ]); + vpdStep = (int16_t )(vpdTableL[i][1 ] - vpdTableL[i][0 ]); vpdStep = (int16_t )((vpdStep <1 ) ?1 : vpdStep);while ((ss <0 ) && (k < (AR5416_NUM_PDADC_VALUES -1 ))) { - tmpVal = (int16_t )(vpdTableI[i][0 ] + ss * vpdStep); + tmpVal = (int16_t )(vpdTableL[i][0 ] + ss * vpdStep); pPDADCValues[k++] = (u8)((tmpVal <0 ) ?0 : tmpVal); ss++; }
@@ -621,17 +619,17 @@ void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah, tgtIndex : sizeCurrVpdTable;while ((ss < maxIndex) && (k < (AR5416_NUM_PDADC_VALUES -1 ))) { - pPDADCValues[k++] = vpdTableI[i][ss++]; + pPDADCValues[k++] = vpdTableL[i][ss++]; } - vpdStep = (int16_t )(vpdTableI[i][sizeCurrVpdTable -1 ] - - vpdTableI[i][sizeCurrVpdTable -2 ]); + vpdStep = (int16_t )(vpdTableL[i][sizeCurrVpdTable -1 ] - + vpdTableL[i][sizeCurrVpdTable -2 ]); vpdStep = (int16_t )((vpdStep <1 ) ?1 : vpdStep);if (tgtIndex >= maxIndex) {while ((ss <= tgtIndex) && (k < (AR5416_NUM_PDADC_VALUES -1 ))) { - tmpVal = (int16_t )((vpdTableI[i][sizeCurrVpdTable -1 ] + + tmpVal = (int16_t )((vpdTableL[i][sizeCurrVpdTable -1 ] + (ss - maxIndex +1 ) * vpdStep)); pPDADCValues[k++] = (u8)((tmpVal >255 ) ?255 : tmpVal);
Signature · 1 line
2.54.0
Toke Høiland-Jørgensen
maintainerQuoted 6 lines · Rosen Penev
vpdTableL, vpdTableR, and vpdTableI are never live simultaneously. vpdTableL and vpdTableR are consumed during the frequency-interpolation step that writes vpdTableI; after the if/else they are never read again. Reuse vpdTableL for the interpolated result (what was vpdTableI), reducing the stack frame by one 256-byte array.
Quoted 7 lines
The read-via-write in the else branch is safe:
ath9k_hw_interpolate()receives vpdTableL[i][j] by value as a function argument before the return value is written back to vpdTableL[i][j].Stack frame size change (
x86_64, clang):
before:0x440(1088 B)
after:0x330(816 B)
Huh? These are static variables, how is this affecting stack usage? I assume this is against your previous (broken) patch?
Anyway, adding this kind of aliasing to fix a problem that you introduced by changing working code with no real benefit is not an improvement. I'm OK with fixing actual bugs, but this is just mindless churn...
-Toke
Quoted 12 lines · Toke Høiland-Jørgensen
Quoted 10 lines · Rosen Penev
vpdTableL, vpdTableR, and vpdTableI are never live simultaneously. vpdTableL and vpdTableR are consumed during the frequency-interpolation step that writes vpdTableI; after the if/else they are never read again. Reuse vpdTableL for the interpolated result (what was vpdTableI), reducing the stack frame by one 256-byte array.
The read-via-write in the else branch is safe:
ath9k_hw_interpolate()receives vpdTableL[i][j] by value as a function argument before the return value is written back to vpdTableL[i][j].
Quoted 6 lines
Quoted 3 lines
Stack frame size change (
x86_64, clang):
before:0x440(1088 B)
after:0x330(816 B)Huh? These are static variables, how is this affecting stack usage? I assume this is against your previous (broken) patch?
It's only broken on ARM + GCC. GCC + anything else and Clang + anything else is fine.
Quoted 5 lines
Anyway, adding this kind of aliasing to fix a problem that you introduced by changing working code with no real benefit is not an improvement. I'm OK with fixing actual bugs, but this is just mindless churn...
Fixing actual bugs is the goal yes. It makes sense to split up into multiple parts IMO.
Quoted 2 lines
-Toke
Toke Høiland-Jørgensen
maintainerQuoted 13 lines · Rosen Penev
Quoted 12 lines · Toke Høiland-Jørgensen
Quoted 10 lines · Rosen Penev
vpdTableL, vpdTableR, and vpdTableI are never live simultaneously. vpdTableL and vpdTableR are consumed during the frequency-interpolation step that writes vpdTableI; after the if/else they are never read again. Reuse vpdTableL for the interpolated result (what was vpdTableI), reducing the stack frame by one 256-byte array.
The read-via-write in the else branch is safe:
ath9k_hw_interpolate()receives vpdTableL[i][j] by value as a function argument before the return value is written back to vpdTableL[i][j].
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Stack frame size change (
x86_64, clang):
before:0x440(1088 B)
after:0x330(816 B)Huh? These are static variables, how is this affecting stack usage? I assume this is against your previous (broken) patch?
It's only broken on ARM + GCC. GCC + anything else and Clang + anything else is fine.
That's still broken, though :)
Quoted 6 lines
Quoted 4 lines
Anyway, adding this kind of aliasing to fix a problem that you introduced by changing working code with no real benefit is not an improvement. I'm OK with fixing actual bugs, but this is just mindless churn...
Fixing actual bugs is the goal yes. It makes sense to split up into multiple parts IMO.
If you're fixing an actual bug, include that in the patch description, and if it requires multiple patches include them in a series. Sending these out of context patches that just shuffle code around is just churn...
-Toke