Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

wifi: mt76: Fix DTS power-limits on little endian systems

The power-limits for ru and mcs and stored in the devicetree as bytewise
array (often with sizes which are not a multiple of 4). These arrays have a
prefix which defines for how many modes a line is applied. This prefix is
also only a byte - but the code still tried to fix the endianness of this
byte with a be32 operation. As result, loading was mostly failing or was
sending completely unexpected values to the firmware.

Since the other rates are also stored in the devicetree as bytewise arrays,
just drop the u32 access + be32_to_cpu conversion and directly access them
as bytes arrays.

Cc: stable@vger.kernel.org
Fixes: 22b980badc0f ("mt76: add functions for parsing rate power limits from DT")
Fixes: a9627d992b5e ("mt76: extend DT rate power limits to support 11ax devices")
Signed-off-by: Sven Eckelmann (Plasma Cloud) <se@simonwunderlich.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>

authored by

Sven Eckelmann (Plasma Cloud) and committed by
Felix Fietkau
38b845e1 8c5b0630

+24 -13
+24 -13
drivers/net/wireless/mediatek/mt76/eeprom.c
··· 253 253 return prop->value; 254 254 } 255 255 256 + static const s8 * 257 + mt76_get_of_array_s8(struct device_node *np, char *name, size_t *len, int min) 258 + { 259 + struct property *prop = of_find_property(np, name, NULL); 260 + 261 + if (!prop || !prop->value || prop->length < min) 262 + return NULL; 263 + 264 + *len = prop->length; 265 + 266 + return prop->value; 267 + } 268 + 256 269 struct device_node * 257 270 mt76_find_channel_node(struct device_node *np, struct ieee80211_channel *chan) 258 271 { ··· 307 294 } 308 295 309 296 static void 310 - mt76_apply_array_limit(s8 *pwr, size_t pwr_len, const __be32 *data, 297 + mt76_apply_array_limit(s8 *pwr, size_t pwr_len, const s8 *data, 311 298 s8 target_power, s8 nss_delta, s8 *max_power) 312 299 { 313 300 int i; ··· 316 303 return; 317 304 318 305 for (i = 0; i < pwr_len; i++) { 319 - pwr[i] = min_t(s8, target_power, 320 - be32_to_cpu(data[i]) + nss_delta); 306 + pwr[i] = min_t(s8, target_power, data[i] + nss_delta); 321 307 *max_power = max(*max_power, pwr[i]); 322 308 } 323 309 } 324 310 325 311 static void 326 312 mt76_apply_multi_array_limit(s8 *pwr, size_t pwr_len, s8 pwr_num, 327 - const __be32 *data, size_t len, s8 target_power, 313 + const s8 *data, size_t len, s8 target_power, 328 314 s8 nss_delta, s8 *max_power) 329 315 { 330 316 int i, cur; ··· 331 319 if (!data) 332 320 return; 333 321 334 - len /= 4; 335 - cur = be32_to_cpu(data[0]); 322 + cur = data[0]; 336 323 for (i = 0; i < pwr_num; i++) { 337 324 if (len < pwr_len + 1) 338 325 break; ··· 346 335 if (!len) 347 336 break; 348 337 349 - cur = be32_to_cpu(data[0]); 338 + cur = data[0]; 350 339 } 351 340 } 352 341 ··· 357 346 { 358 347 struct mt76_dev *dev = phy->dev; 359 348 struct device_node *np; 360 - const __be32 *val; 349 + const s8 *val; 361 350 char name[16]; 362 351 u32 mcs_rates = dev->drv->mcs_rates; 363 352 u32 ru_rates = ARRAY_SIZE(dest->ru[0]); ··· 403 392 404 393 txs_delta = mt76_get_txs_delta(np, hweight16(phy->chainmask)); 405 394 406 - val = mt76_get_of_array(np, "rates-cck", &len, ARRAY_SIZE(dest->cck)); 395 + val = mt76_get_of_array_s8(np, "rates-cck", &len, ARRAY_SIZE(dest->cck)); 407 396 mt76_apply_array_limit(dest->cck, ARRAY_SIZE(dest->cck), val, 408 397 target_power, txs_delta, &max_power); 409 398 410 - val = mt76_get_of_array(np, "rates-ofdm", 411 - &len, ARRAY_SIZE(dest->ofdm)); 399 + val = mt76_get_of_array_s8(np, "rates-ofdm", 400 + &len, ARRAY_SIZE(dest->ofdm)); 412 401 mt76_apply_array_limit(dest->ofdm, ARRAY_SIZE(dest->ofdm), val, 413 402 target_power, txs_delta, &max_power); 414 403 415 - val = mt76_get_of_array(np, "rates-mcs", &len, mcs_rates + 1); 404 + val = mt76_get_of_array_s8(np, "rates-mcs", &len, mcs_rates + 1); 416 405 mt76_apply_multi_array_limit(dest->mcs[0], ARRAY_SIZE(dest->mcs[0]), 417 406 ARRAY_SIZE(dest->mcs), val, len, 418 407 target_power, txs_delta, &max_power); 419 408 420 - val = mt76_get_of_array(np, "rates-ru", &len, ru_rates + 1); 409 + val = mt76_get_of_array_s8(np, "rates-ru", &len, ru_rates + 1); 421 410 mt76_apply_multi_array_limit(dest->ru[0], ARRAY_SIZE(dest->ru[0]), 422 411 ARRAY_SIZE(dest->ru), val, len, 423 412 target_power, txs_delta, &max_power);