Skip to contentSkip to conversation

wl1251: Fix MAC address for Nokia N900

PATCH Superseded Pali Rohár 7 participants 68 messages Dec 24, 2016 – Feb 27, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover wl1251: Fix MAC address for Nokia N900

This patch series fix processing MAC address for wl1251 chip found in Nokia N900.

Pali Rohár (6):
firmware: Add request_firmware_prefer_user() function
wl1251: Use request_firmware_prefer_user() for loading NVS
calibration data
wl1251: Update wl->nvs_len after wl->nvs is valid
wl1251: Generate random MAC address only if driver does not have
valid
wl1251: Parse and use MAC address from supplied NVS data
wl1251: Set generated MAC address back to NVS data

 drivers/base/firmware_class.c          |   45 +++++++++++++++-
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |   91 +++++++++++++++++++++++++-------
 include/linux/firmware.h               |    9 ++++
 4 files changed, 125 insertions(+), 21 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/6 firmware: Add request_firmware_prefer_user() function

This function works pretty much like request_firmware(), but it prefer usermode helper. If usermode helper fails then it fallback to direct access. Useful for dynamic or model specific firmware data.

---
 drivers/base/firmware_class.c |   45 +++++++++++++++++++++++++++++++++++++++--
 include/linux/firmware.h      |    9 +++++++++
 2 files changed, 52 insertions(+), 2 deletions(-)
drivers/base/firmware_class.c +43 -2
index 22d1760..6a8c261 100644
@@ -119,6 +119,11 @@ static inline long firmware_loading_timeout(void)
 #endif
 #define FW_OPT_NO_WARN	(1U << 3)
 #define FW_OPT_NOCACHE	(1U << 4)
+#ifdef CONFIG_FW_LOADER_USER_HELPER
+#define FW_OPT_PREFER_USER	(1U << 5)
+#else
+#define FW_OPT_PREFER_USER	0
+#endif
 
 struct firmware_cache {
 	/* firmware_buf instance will be added into the below list */
@@ -1169,13 +1174,26 @@ static int assign_firmware_buf(struct firmware *fw, struct device *device,
 		}
 	}
 
-	ret = fw_get_filesystem_firmware(device, fw->priv);
+	if (opt_flags & FW_OPT_PREFER_USER) {
+		ret = fw_load_from_user_helper(fw, name, device, opt_flags, timeout);
+		if (ret && !(opt_flags & FW_OPT_NO_WARN)) {
+			dev_warn(device,
+				 "User helper firmware load for %s failed with error %d\n",
+				 name, ret);
+			dev_warn(device, "Falling back to direct firmware load\n");
+		}
+	} else {
+		ret = -EINVAL;
+	}
+
+	if (ret)
+		ret = fw_get_filesystem_firmware(device, fw->priv);
 	if (ret) {
 		if (!(opt_flags & FW_OPT_NO_WARN))
 			dev_warn(device,
 				 "Direct firmware load for %s failed with error %d\n",
 				 name, ret);
-		if (opt_flags & FW_OPT_USERHELPER) {
+		if ((opt_flags & FW_OPT_USERHELPER) && !(opt_flags & FW_OPT_PREFER_USER)) {
 			dev_warn(device, "Falling back to user helper\n");
 			ret = fw_load_from_user_helper(fw, name, device,
 						       opt_flags, timeout);
@@ -1287,6 +1305,29 @@ int request_firmware_direct(const struct firmware **firmware_p,
 EXPORT_SYMBOL(request_firmware_into_buf);
 
 /**
+ * request_firmware_prefer_user: - prefer usermode helper for loading firmware
+ * @firmware_p: pointer to firmware image
+ * @name: name of firmware file
+ * @device: device for which firmware is being loaded
+ *
+ * This function works pretty much like request_firmware(), but it prefer
+ * usermode helper. If usermode helper fails then it fallback to direct access.
+ * Useful for dynamic or model specific firmware data.
+ **/
+int request_firmware_prefer_user(const struct firmware **firmware_p,
+			    const char *name, struct device *device)
+{
+	int ret;
+
+	__module_get(THIS_MODULE);
+	ret = _request_firmware(firmware_p, name, device, NULL, 0,
+				FW_OPT_UEVENT | FW_OPT_PREFER_USER);
+	module_put(THIS_MODULE);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(request_firmware_prefer_user);
+
+/**
  * release_firmware: - release the resource associated with a firmware image
  * @fw: firmware resource to release
  **/
include/linux/firmware.h +9 -0
index b1f9f0c..01f7a85 100644
@@ -47,6 +47,8 @@ int request_firmware_nowait(
 	void (*cont)(const struct firmware *fw, void *context));
 int request_firmware_direct(const struct firmware **fw, const char *name,
 			    struct device *device);
+int request_firmware_prefer_user(const struct firmware **fw, const char *name,
+				 struct device *device);
 int request_firmware_into_buf(const struct firmware **firmware_p,
 	const char *name, struct device *device, void *buf, size_t size);
 
@@ -77,6 +79,13 @@ static inline int request_firmware_direct(const struct firmware **fw,
 	return -EINVAL;
 }
 
+static inline int request_firmware_prefer_user(const struct firmware **fw,
+					       const char *name,
+					       struct device *device)
+{
+	return -EINVAL;
+}
+
 static inline int request_firmware_into_buf(const struct firmware **firmware_p,
 	const char *name, struct device *device, void *buf, size_t size)
 {
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/6 wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device which has wl1251 chip, NVS calibration data are stored in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

---
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wl1251/Kconfig +1 -0
index 7142ccf..affe154 100644
@@ -2,6 +2,7 @@ config WL1251
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
+	select FW_LOADER_USER_HELPER
 	select CRC7
 	---help---
 	  This will enable TI wl1251 driver support. The drivers make
drivers/net/wireless/ti/wl1251/main.c +1 -1
index 208f062..24f8866 100644
@@ -110,7 +110,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 	struct device *dev = wiphy_dev(wl->hw->wiphy);
 	int ret;
 
-	ret = request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret = request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);
 
 	if (ret < 0) {
 		wl1251_error("could not get nvs file: %d", ret);
Signature · 1 line
1.7.9.5
#36 lore raw

PATCH 3/6 wl1251: Update wl->nvs_len after wl->nvs is valid

In reply to Pali Rohár

In case kmemdup fails thne wl->nvs_len will contains invalid non-zero size. This patch fixes it.

---
 drivers/net/wireless/ti/wl1251/main.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/ti/wl1251/main.c +3 -2
index 24f8866..8971b64 100644
@@ -124,8 +124,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 		goto out;
 	}
 
-	wl->nvs_len = fw->size;
-	wl->nvs = kmemdup(fw->data, wl->nvs_len, GFP_KERNEL);
+	wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL);
 
 	if (!wl->nvs) {
 		wl1251_error("could not allocate memory for the nvs file");
@@ -133,6 +132,8 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 		goto out;
 	}
 
+	wl->nvs_len = fw->size;
+
 	ret = 0;
 
 out:
Signature · 1 line
1.7.9.5
#38 lore raw

PATCH 4/6 wl1251: Generate random MAC address only if driver does not have valid

In reply to Pali Rohár

Before this patch driver generated random MAC address every time when was doing initialization. And after that random MAC address could be overwritten with fixed one if provided.

This patch changes order. First it tries to read fixed MAC address and if it fails then driver generates random MAC address.

---
 drivers/net/wireless/ti/wl1251/main.c |   27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/net/wireless/ti/wl1251/main.c +18 -9
index 8971b64..c3fa0b6 100644
@@ -1582,7 +1582,24 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
 	wl->hw->queues = 4;
 
 	if (wl->use_eeprom)
-		wl1251_read_eeprom_mac(wl);
+		ret = wl1251_read_eeprom_mac(wl);
+	else
+		ret = -EINVAL;
+
+	if (ret == 0 && !is_valid_ether_addr(wl->mac_addr))
+		ret = -EINVAL;
+
+	if (ret < 0) {
+		/*
+		 * In case our MAC address is not correctly set,
+		 * we use a random but Nokia MAC.
+		 */
+		static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
+		memcpy(wl->mac_addr, nokia_oui, 3);
+		get_random_bytes(wl->mac_addr + 3, 3);
+		wl1251_warning("MAC address in eeprom or nvs data is not valid");
+		wl1251_warning("Setting random MAC address: %pM", wl->mac_addr);
+	}
 
 	ret = wl1251_register_hw(wl);
 	if (ret)
@@ -1623,7 +1640,6 @@ struct ieee80211_hw *wl1251_alloc_hw(void)
 	struct ieee80211_hw *hw;
 	struct wl1251 *wl;
 	int i;
-	static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
 
 	hw = ieee80211_alloc_hw(sizeof(*wl), &wl1251_ops);
 	if (!hw) {
@@ -1674,13 +1690,6 @@ struct ieee80211_hw *wl1251_alloc_hw(void)
 	INIT_WORK(&wl->irq_work, wl1251_irq_work);
 	INIT_WORK(&wl->tx_work, wl1251_tx_work);
 
-	/*
-	 * In case our MAC address is not correctly set,
-	 * we use a random but Nokia MAC.
-	 */
-	memcpy(wl->mac_addr, nokia_oui, 3);
-	get_random_bytes(wl->mac_addr + 3, 3);
-
 	wl->state = WL1251_STATE_OFF;
 	mutex_init(&wl->mutex);
 
Signature · 1 line
1.7.9.5
#41 lore raw

PATCH 5/6 wl1251: Parse and use MAC address from supplied NVS data

In reply to Pali Rohár

This patch implements parsing MAC address from NVS data which are sent to wl1251 chip. Calibration NVS data could contain valid MAC address and it will be used instead randomly generated.

This patch also move code for requesting NVS data from userspace to driver initialization code to make sure that NVS data will be there at time when permanent MAC address is needed.

Calibration NVS data for wl1251 are model specific. Every one device with wl1251 chip should have been calibrated in factory and needs to provide own calibration data.

Default example wl1251-nvs.bin data found in linux-firmware repository and contains MAC address 00:00:20:07:03:09. So this MAC address is marked as invalid as it is not real device specific address, just example one.

Format of calibration NVS data can be found at:
http://notaz.gp2x.de/misc/pnd/wl1251/nvs_map.txt

---
 drivers/net/wireless/ti/wl1251/main.c |   39 ++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 8 deletions(-)
drivers/net/wireless/ti/wl1251/main.c +31 -8
index c3fa0b6..1454ba2 100644
@@ -205,13 +205,6 @@ static int wl1251_chip_wakeup(struct wl1251 *wl)
 			goto out;
 	}
 
-	if (wl->nvs == NULL && !wl->use_eeprom) {
-		/* No NVS from netlink, try to get it from the filesystem */
-		ret = wl1251_fetch_nvs(wl);
-		if (ret < 0)
-			goto out;
-	}
-
 out:
 	return ret;
 }
@@ -1538,6 +1531,30 @@ static int wl1251_read_eeprom_mac(struct wl1251 *wl)
 	return 0;
 }
 
+static int wl1251_read_nvs_mac(struct wl1251 *wl)
+{
+	u8 mac[ETH_ALEN];
+	int i;
+
+	if (wl->nvs_len < 0x24)
+		return -ENODATA;
+
+	/* length is 2 and data address is 0x546c (mask is 0xfffe) */
+	if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b] != 0x54)
+		return -EINVAL;
+
+	/* MAC is stored in reverse order */
+	for (i = 0; i < ETH_ALEN; i++)
+		mac[i] = wl->nvs[0x1c + ETH_ALEN - i - 1];
+
+	/* 00:00:20:07:03:09 is in default example wl1251-nvs.bin, so invalid */
+	if (ether_addr_equal_unaligned(mac, "\x00\x00\x20\x07\x03\x09"))
+		return -EINVAL;
+
+	memcpy(wl->mac_addr, mac, ETH_ALEN);
+	return 0;
+}
+
 static int wl1251_register_hw(struct wl1251 *wl)
 {
 	int ret;
@@ -1581,10 +1598,16 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
 
 	wl->hw->queues = 4;
 
+	if (wl->nvs == NULL && !wl->use_eeprom) {
+		ret = wl1251_fetch_nvs(wl);
+		if (ret < 0)
+			goto out;
+	}
+
 	if (wl->use_eeprom)
 		ret = wl1251_read_eeprom_mac(wl);
 	else
-		ret = -EINVAL;
+		ret = wl1251_read_nvs_mac(wl);
 
 	if (ret == 0 && !is_valid_ether_addr(wl->mac_addr))
 		ret = -EINVAL;
Signature · 1 line
1.7.9.5
#45 lore raw

PATCH 6/6 wl1251: Set generated MAC address back to NVS data

In reply to Pali Rohár

In case there is no valid MAC address kernel generates random one. This patch propagate this generated MAC address back to NVS data which will be uploaded to wl1251 chip. So HW would have same MAC address as linux kernel uses.

---
 drivers/net/wireless/ti/wl1251/main.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/net/wireless/ti/wl1251/main.c +20 -0
index 1454ba2..895ae05 100644
@@ -1555,6 +1555,24 @@ static int wl1251_read_nvs_mac(struct wl1251 *wl)
 	return 0;
 }
 
+static int wl1251_write_nvs_mac(struct wl1251 *wl)
+{
+	int i;
+
+	if (wl->nvs_len < 0x24)
+		return -ENODATA;
+
+	/* length is 2 and data address is 0x546c (mask is 0xfffe) */
+	if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b] != 0x54)
+		return -EINVAL;
+
+	/* MAC is stored in reverse order */
+	for (i = 0; i < ETH_ALEN; i++)
+		wl->nvs[0x1c + i] = wl->mac_addr[ETH_ALEN - i - 1];
+
+	return 0;
+}
+
 static int wl1251_register_hw(struct wl1251 *wl)
 {
 	int ret;
@@ -1620,6 +1638,8 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
 		static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
 		memcpy(wl->mac_addr, nokia_oui, 3);
 		get_random_bytes(wl->mac_addr + 3, 3);
+		if (!wl->use_eeprom)
+			wl1251_write_nvs_mac(wl);
 		wl1251_warning("MAC address in eeprom or nvs data is not valid");
 		wl1251_warning("Setting random MAC address: %pM", wl->mac_addr);
 	}
Signature · 1 line
1.7.9.5
Acked-by on v1 3/6
#37 lore raw

Re: [PATCH 3/6] wl1251: Update wl->nvs_len after wl->nvs is valid

In reply to Pali Rohár
Quoted 2 lines · Pali Rohár

In case kmemdup fails thne wl->nvs_len will contains invalid non-zero size. This patch fixes it.

If kmemdup fails, then wl->nvs_len will contain invalid non-zero size.

?

This probably should go as first in series, as it is bugfix?

Pavel

Quoted 28 lines
---
 drivers/net/wireless/ti/wl1251/main.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/ti/wl1251/main.c +3 -2
index 24f8866..8971b64 100644
@@ -124,8 +124,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 		goto out;
 	}
 
-	wl->nvs_len = fw->size;
-	wl->nvs = kmemdup(fw->data, wl->nvs_len, GFP_KERNEL);
+	wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL);
 
 	if (!wl->nvs) {
 		wl1251_error("could not allocate memory for the nvs file");
@@ -133,6 +132,8 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 		goto out;
 	}
 
+	wl->nvs_len = fw->size;
+
 	ret = 0;
 
 out:
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Acked-by on v1 4/6
#39 lore raw

Re: [PATCH 4/6] wl1251: Generate random MAC address only if driver does not have valid

In reply to Pali Rohár
Quoted 3 lines · Pali Rohár

Before this patch driver generated random MAC address every time when was doing initialization. And after that random MAC address could be overwritten with fixed one if provided.

Before this patch, driver generated random MAC address every time it was initialized. After that random MAC address could be overwritten with fixed one, if provided.

Quoted 2 lines

This patch changes order. First it tries to read fixed MAC address and if it fails then driver generates random MAC address.

I don't quite get where the advantage is supposed to be. Is it that "use_eeprom" is set, but reading fails?

The only case where this helps is if wl1251_read_eeprom_mac() succeeds but reads invalid address.

Quoted 1 line
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#42 lore raw

Re: [PATCH 5/6] wl1251: Parse and use MAC address from supplied NVS data

In reply to Pali Rohár
Quoted 3 lines · Pali Rohár

This patch implements parsing MAC address from NVS data which are sent to wl1251 chip. Calibration NVS data could contain valid MAC address and it will be used instead randomly generated.

will be used instead of randomly generated one.

Quoted 1 line

This patch also move code for requesting NVS data from userspace to driver

"moves"

Quoted 2 lines

initialization code to make sure that NVS data will be there at time when permanent MAC address is needed.

"at a time"

Quoted 1 line

Calibration NVS data for wl1251 are model specific. Every one device with

"device specific"? "Every device".

Quoted 4 lines

wl1251 chip should have been calibrated in factory and needs to provide own calibration data.

Default example wl1251-nvs.bin data found in linux-firmware repository and

"are found"

Quoted 1 line

contains MAC address 00:00:20:07:03:09. So this MAC address is marked as

"contain"

Quoted 39 lines

invalid as it is not real device specific address, just example one.

Format of calibration NVS data can be found at:
http://notaz.gp2x.de/misc/pnd/wl1251/nvs_map.txt

---
 drivers/net/wireless/ti/wl1251/main.c |   39 ++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 8 deletions(-)
drivers/net/wireless/ti/wl1251/main.c +7 -7
index c3fa0b6..1454ba2 100644
@@ -205,13 +205,6 @@ static int wl1251_chip_wakeup(struct wl1251 *wl)
 			goto out;
 	}
 
-	if (wl->nvs == NULL && !wl->use_eeprom) {
-		/* No NVS from netlink, try to get it from the filesystem */
-		ret = wl1251_fetch_nvs(wl);
-		if (ret < 0)
-			goto out;
-	}
-
 out:
 	return ret;
 }
@@ -1538,6 +1531,30 @@ static int wl1251_read_eeprom_mac(struct wl1251 *wl)
 	return 0;
 }
 
+static int wl1251_read_nvs_mac(struct wl1251 *wl)
+{
+	u8 mac[ETH_ALEN];
+	int i;
+
+	if (wl->nvs_len < 0x24)
+		return -ENODATA;

drivers/net/wireless/ti/wl1251/main.c static int wl1251_read_eeprom_mac(struct wl1251 *wl) · line 1550

Quoted 10 lines
drivers/net/wireless/ti/wl1251/main.c +10 -0
+
+	/* length is 2 and data address is 0x546c (mask is 0xfffe) */
+	if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b] != 0x54)
+		return -EINVAL;
+
+	/* MAC is stored in reverse order */
+	for (i = 0; i < ETH_ALEN; i++)
+		mac[i] = wl->nvs[0x1c + ETH_ALEN - i - 1];
+
+	/* 00:00:20:07:03:09 is in default example wl1251-nvs.bin, so invalid */

remove "default".

Quoted 11 lines
drivers/net/wireless/ti/wl1251/main.c +7 -0
+	if (ether_addr_equal_unaligned(mac, "\x00\x00\x20\x07\x03\x09"))
+		return -EINVAL;
+
+	memcpy(wl->mac_addr, mac, ETH_ALEN);
+	return 0;
+}
+
 static int wl1251_register_hw(struct wl1251 *wl)
 {
 	int ret;

drivers/net/wireless/ti/wl1251/main.c int wl1251_init_ieee80211(struct wl1251 *wl) · line 1605

Quoted 8 lines
drivers/net/wireless/ti/wl1251/main.c +5 -0
@@ -1581,10 +1598,16 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
 
 	wl->hw->queues = 4;
 
+	if (wl->nvs == NULL && !wl->use_eeprom) {
+		ret = wl1251_fetch_nvs(wl);
+		if (ret < 0)
+			goto out;
+	}

Is goto out here good idea? IMNSHO it is copy&paste bug, it should just proceed with generating random address.

drivers/net/wireless/ti/wl1251/main.c int wl1251_init_ieee80211(struct wl1251 *wl) · line 1613

Quoted 8 lines
drivers/net/wireless/ti/wl1251/main.c +1 -1
 	if (wl->use_eeprom)
 		ret = wl1251_read_eeprom_mac(wl);
 	else
-		ret = -EINVAL;
+		ret = wl1251_read_nvs_mac(wl);
 
 	if (ret == 0 && !is_valid_ether_addr(wl->mac_addr))
 		ret = -EINVAL;

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#46 lore raw

Re: [PATCH 6/6] wl1251: Set generated MAC address back to NVS data

In reply to Pali Rohár

Hi!

drivers/net/wireless/ti/wl1251/main.c static int wl1251_read_nvs_mac(struct wl1251 *wl) · line 1559

Quoted 10 lines

In case there is no valid MAC address kernel generates random one. This patch propagate this generated MAC address back to NVS data which will be uploaded to wl1251 chip. So HW would have same MAC address as linux kernel uses.

drivers/net/wireless/ti/wl1251/main.c +2 -0
 	return 0;
 }
 
+static int wl1251_write_nvs_mac(struct wl1251 *wl)
+{

The name is quite confusing, this sounds like writing into non-volatile storage.

drivers/net/wireless/ti/wl1251/main.c static int wl1251_read_nvs_mac(struct wl1251 *wl) · line 1565

Quoted 6 lines
drivers/net/wireless/ti/wl1251/main.c +6 -0
+	int i;
+
+	if (wl->nvs_len < 0x24)
+		return -ENODATA;
+
+	/* length is 2 and data address is 0x546c (mask is 0xfffe) */

You don't actually check for the mask.

drivers/net/wireless/ti/wl1251/main.c static int wl1251_read_nvs_mac(struct wl1251 *wl) · line 1567

Quoted 2 lines
drivers/net/wireless/ti/wl1251/main.c +2 -0
+	if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b] != 0x54)
+		return -EINVAL;

You have two copies of these. Does it make sense to move it to helper function?

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#40 lore raw

Re: [PATCH 4/6] wl1251: Generate random MAC address only if driver does not have valid

In reply to Pavel Machek
Quoted 9 lines · On Saturday 24 December 2016 19:08:54 Pavel Machek wrote:
Quoted 3 lines · Pali Rohár

Before this patch driver generated random MAC address every time when was doing initialization. And after that random MAC address could be overwritten with fixed one if provided.

Before this patch, driver generated random MAC address every time it was initialized. After that random MAC address could be overwritten with fixed one, if provided.

Quoted 5 lines
Quoted 2 lines

This patch changes order. First it tries to read fixed MAC address and if it fails then driver generates random MAC address.

I don't quite get where the advantage is supposed to be. Is it that "use_eeprom" is set, but reading fails?

Random bytes are read from kernel only if random MAC address is needed. And in wl->mac_addr is always either invalid address or permanenent mac address which will be used. Without patch in wl->mac_addr can be random temporary address for some time...

Quoted 6 lines

The only case where this helps is if wl1251_read_eeprom_mac() succeeds but reads invalid address.

Quoted 1 line
Signature · 2 lines
Pali Rohár
[email protected]
#43 lore raw

Re: [PATCH 5/6] wl1251: Parse and use MAC address from supplied NVS data

In reply to Pavel Machek
Quoted 6 lines · On Saturday 24 December 2016 19:14:21 Pavel Machek wrote:
Quoted 5 lines · Pali Rohár
drivers/net/wireless/ti/wl1251/main.c +0 -0
@@ -1581,10 +1598,16 @@ int wl1251_init_ieee80211(struct wl1251
 *wl)
 
 	wl->hw->queues = 4;
 
Quoted 8 lines

drivers/net/wireless/ti/wl1251/main.c int wl1251_init_ieee80211(struct wl1251 *wl) · line 1605

Quoted 5 lines
drivers/net/wireless/ti/wl1251/main.c +5 -0
+	if (wl->nvs == NULL && !wl->use_eeprom) {
+		ret = wl1251_fetch_nvs(wl);
+		if (ret < 0)
+			goto out;
+	}

Is goto out here good idea? IMNSHO it is copy&paste bug, it should just proceed with generating random address.

No, goto is correct here. wl1251 cannot be initialized without NVS data. And when fetching (from userspace) fails it is fatal error.

Signature · 2 lines
Pali Rohár
[email protected]
#47 lore raw

Re: [PATCH 6/6] wl1251: Set generated MAC address back to NVS data

In reply to Pavel Machek
Quoted 17 lines · On Saturday 24 December 2016 19:17:30 Pavel Machek wrote:

Hi!

drivers/net/wireless/ti/wl1251/main.c static int wl1251_read_nvs_mac(struct wl1251 *wl) · line 1559

Quoted 11 lines

In case there is no valid MAC address kernel generates random one. This patch propagate this generated MAC address back to NVS data which will be uploaded to wl1251 chip. So HW would have same MAC address as linux kernel uses.

drivers/net/wireless/ti/wl1251/main.c +2 -0
 	return 0;
 
 }
 
+static int wl1251_write_nvs_mac(struct wl1251 *wl)
+{

The name is quite confusing, this sounds like writing into non-volatile storage.

Quoted 8 lines

drivers/net/wireless/ti/wl1251/main.c static int wl1251_read_nvs_mac(struct wl1251 *wl) · line 1565

Quoted 6 lines
drivers/net/wireless/ti/wl1251/main.c +6 -0
+	int i;
+
+	if (wl->nvs_len < 0x24)
+		return -ENODATA;
+
+	/* length is 2 and data address is 0x546c (mask is 0xfffe) */

You don't actually check for the mask.

It is quite complicated. { 0x6d, 0x54 } (= 0x546d) in data represent address 0x546c and content are data. You need to apply mask 0xfffe for 0x546d and you get address where data will be written (so 0x546c).

Quoted 5 lines
Quoted 2 lines
(quoted diff) +1 -0
+	if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b]

!= 0x54) + return -EINVAL;

You have two copies of these. Does it make sense to move it to helper function?

I'm thinking if checks is really needed. But probably moving it to separate function is good idea.

Signature · 2 lines
Pali Rohár
[email protected]
#3 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Pali Rohár
Quoted 8 lines · Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Quoted 4 lines

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

Responding to this patch as it provides a lot of context to discuss. As you might have gathered from earlier discussions I am not a fan of using user-space helper. I can agree that the kernel driver, wl1251 in this case, should be agnostic to platform specific details regarding storage solutions and the firmware api should hide that. However, it seems your only solution is adding user-space to the mix and changing the api towards that. Can we solve it without user-space help?

The firmware_class already supports a number of path prefixes it traverses looking for the requested firmware. So I was thinking about adding a hashtable in which a platform driver can add firmware which are stored in the hashtable using the hashed firmware name. Upon a firmware request from the driver we could check the hashtable before traversing the path prefixes on VFS. The obvious problem is that the request may come before the firmware is added to the hashtable. Just wanted to pitch the idea first and hear what others think about it and maybe someone has a nice solution for this problem. Fingers crossed :-p

Quoted 6 lines

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device which has wl1251 chip, NVS calibration data are stored in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With the firmware hashtable api on N900 a platform driver could interpret the CAL data in the nand partition and provide it through the firmware_class.

Quoted 2 lines

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

But on other devices that use wl1251, but for instance have no userspace helper the request to userspace will fail (after 60 sec?) and try VFS after that. Maybe not so nice. You should consider other device configurations. Not just N900.

Regards,
Arend

Quoted 32 lines
---
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wl1251/Kconfig +1 -0
index 7142ccf..affe154 100644
@@ -2,6 +2,7 @@ config WL1251
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
+	select FW_LOADER_USER_HELPER
 	select CRC7
 	---help---
 	  This will enable TI wl1251 driver support. The drivers make
drivers/net/wireless/ti/wl1251/main.c +1 -1
index 208f062..24f8866 100644
@@ -110,7 +110,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 	struct device *dev = wiphy_dev(wl->hw->wiphy);
 	int ret;
 
-	ret = request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret = request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);
 
 	if (ret < 0) {
 		wl1251_error("could not get nvs file: %d", ret);
#4 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 16 lines · On Sunday 25 December 2016 21:15:40 Arend Van Spriel wrote:
Quoted 9 lines · Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Quoted 5 lines

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

Quoted 8 lines

Responding to this patch as it provides a lot of context to discuss. As you might have gathered from earlier discussions I am not a fan of using user-space helper. I can agree that the kernel driver, wl1251 in this case, should be agnostic to platform specific details regarding storage solutions and the firmware api should hide that. However, it seems your only solution is adding user-space to the mix and changing the api towards that. Can we solve it without user-space help?

Without userspace helper it means that userspace helper code must be integrated into kernel.

So what is userspace helper doing?

1) Read MAC address from CAL
2) Read NVS data from CAL
3) Modify MAC address in memory NVS data (new for this patch series)
4) Modify in memory NVS data if we in FCC country

Checking for country is done via dbus call to either Maemo cellular daemon or alternatively via REGDOMAIN in /etc/default/crda. I have plan to use ofono (instead Maemo cellular daemon) too...

Currently we are using closed Nokia proprietary CAL library.

Steps 1) and 2) needs closed library, step 4) needs dbus call.

In current state I do not see way to integrate it into kernel. And because wl1251 currently uses request_firmware() to load those nvs data I think it is still the best way how to handle it...

And IIRC there was already discussion about Nokia CAL parser in kernel and it was declined.

Quoted 22 lines

The firmware_class already supports a number of path prefixes it traverses looking for the requested firmware. So I was thinking about adding a hashtable in which a platform driver can add firmware which are stored in the hashtable using the hashed firmware name. Upon a firmware request from the driver we could check the hashtable before traversing the path prefixes on VFS. The obvious problem is that the request may come before the firmware is added to the hashtable. Just wanted to pitch the idea first and hear what others think about it and maybe someone has a nice solution for this problem. Fingers crossed :-p

Quoted 6 lines

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device which has wl1251 chip, NVS calibration data are stored in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With the firmware hashtable api on N900 a platform driver could interpret the CAL data in the nand partition and provide it through the firmware_class.

Quoted 6 lines
Quoted 2 lines

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

But on other devices that use wl1251, but for instance have no userspace helper the request to userspace will fail (after 60 sec?) and try VFS after that. Maybe not so nice.

Currently support for those devices is broken (like for N900) as without proper NVS data they do not work correctly...

Quoted 1 line

You should consider other device configurations. Not just N900.

I do not have any other wl1251 devices. I know that pandora has wl1251 too, but it has wl1251 with eeprom where is stored NVS. And in this case request_firmware() is not used there.

Quoted 44 lines

Regards,
Arend

Quoted 41 lines

---

 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/net/wireless/ti/wl1251/Kconfig index 7142ccf..affe154 100644

drivers/net/wireless/ti/wl1251/Kconfig +1 -0
@@ -2,6 +2,7 @@ config WL1251
 
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
 
+	select FW_LOADER_USER_HELPER
 
drivers/net/wireless/ti/wl1251/Kconfig +0 -0
 	select CRC7
 	---help---
 
 	  This will enable TI wl1251 driver support. The drivers make
(quoted diff) +0 -0

b/drivers/net/wireless/ti/wl1251/main.c index 208f062..24f8866 100644

drivers/net/wireless/ti/wl1251/main.c +1 -1
@@ -110,7 +110,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 
 	struct device *dev = wiphy_dev(wl->hw->wiphy);
 	int ret;
 
-	ret = request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret = request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);
 
 	if (ret < 0) {

wl1251_error("could not get nvs file: %d", ret);

Signature · 2 lines
Pali Rohár
[email protected]
#5 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Hi!

Quoted 34 lines
Quoted 15 lines
Quoted 9 lines

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Quoted 5 lines

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

Quoted 8 lines

Responding to this patch as it provides a lot of context to discuss. As you might have gathered from earlier discussions I am not a fan of using user-space helper. I can agree that the kernel driver, wl1251 in this case, should be agnostic to platform specific details regarding storage solutions and the firmware api should hide that. However, it seems your only solution is adding user-space to the mix and changing the api towards that. Can we solve it without user-space help?

Without userspace helper it means that userspace helper code must be integrated into kernel.

So what is userspace helper doing?

1) Read MAC address from CAL
2) Read NVS data from CAL
3) Modify MAC address in memory NVS data (new for this patch series)
4) Modify in memory NVS data if we in FCC country

Quoted 7 lines

Checking for country is done via dbus call to either Maemo cellular daemon or alternatively via REGDOMAIN in /etc/default/crda. I have plan to use ofono (instead Maemo cellular daemon) too...

Currently we are using closed Nokia proprietary CAL library.

Steps 1) and 2) needs closed library, step 4) needs dbus call.

I guess pointer to the source code implementing this would be welcome.

Quoted 6 lines
Quoted 3 lines

But on other devices that use wl1251, but for instance have no userspace helper the request to userspace will fail (after 60 sec?) and try VFS after that. Maybe not so nice.

Currently support for those devices is broken (like for N900) as without proper NVS data they do not work correctly...

Is it expected to work at all, perhaps with degraded performance / range? Because it seems to work for me.

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 41 lines · On Monday 26 December 2016 16:43:53 Pavel Machek wrote:

Hi!

Quoted 39 lines
Quoted 16 lines
Quoted 10 lines

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Quoted 5 lines

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

Quoted 8 lines

Responding to this patch as it provides a lot of context to discuss. As you might have gathered from earlier discussions I am not a fan of using user-space helper. I can agree that the kernel driver, wl1251 in this case, should be agnostic to platform specific details regarding storage solutions and the firmware api should hide that. However, it seems your only solution is adding user-space to the mix and changing the api towards that. Can we solve it without user-space help?

Without userspace helper it means that userspace helper code must be integrated into kernel.

So what is userspace helper doing?

1) Read MAC address from CAL
2) Read NVS data from CAL
3) Modify MAC address in memory NVS data (new for this patch series) 4) Modify in memory NVS data if we in FCC country

Checking for country is done via dbus call to either Maemo cellular daemon or alternatively via REGDOMAIN in /etc/default/crda. I have plan to use ofono (instead Maemo cellular daemon) too...

Quoted 6 lines
Quoted 3 lines

Currently we are using closed Nokia proprietary CAL library.

Steps 1) and 2) needs closed library, step 4) needs dbus call.

I guess pointer to the source code implementing this would be welcome.

Here is current code: https://github.com/community-ssu/wl1251-cal

(there is implemented also Maemo netlink interface)

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

But on other devices that use wl1251, but for instance have no userspace helper the request to userspace will fail (after 60 sec?) and try VFS after that. Maybe not so nice.

Currently support for those devices is broken (like for N900) as without proper NVS data they do not work correctly...

Is it expected to work at all, perhaps with degraded performance / range? Because it seems to work for me.

Yes, some degraded performance or problems with connecting is expected. And random MAC address at every boot. Plus some regulatory problems in FCC countries.

Signature · 2 lines
Pali Rohár
[email protected]
#7 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Arend Van Spriel
Quoted 14 lines · Arend Van Spriel
Quoted 8 lines · Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Quoted 4 lines

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

Quoted 7 lines

Responding to this patch as it provides a lot of context to discuss. As you might have gathered from earlier discussions I am not a fan of using user-space helper. I can agree that the kernel driver, wl1251 in this case, should be agnostic to platform specific details regarding storage solutions and the firmware api should hide that. However, it seems your only solution is adding user-space to the mix and changing the api towards that. Can we solve it without user-space help?

Answer is no, due to licensing. But that's wrong question to ask.

Right question is "should we solve it without user-space help"?

Answer is no, too. Way too complex. Yes, it would be nice if hardware was designed in such a way that getting calibration data from kernel is easy, and if you design hardware, please design it like that. But N900 is not designed like that and getting the calibration through userspace looks like only reasonable solution.

Now... how exactly to do that is other question. (But this is looks very reasonable. Maybe I'd add request_firmware_with_flags(, ...int flags), but.. that's a tiny detail.). But userspace needs to be involved.

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#8 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 8 lines · Pavel Machek

Right question is "should we solve it without user-space help"?

Answer is no, too. Way too complex. Yes, it would be nice if hardware was designed in such a way that getting calibration data from kernel is easy, and if you design hardware, please design it like that. But N900 is not designed like that and getting the calibration through userspace looks like only reasonable solution.

Arend seems to have a better alternative in mind possible for other devices which *can* probably pull of doing this easily and nicely, given the nasty history of the usermode helper crap we should not in any way discourage such efforts.

Arend -- please look at the firmware cache, it not a hash but a hash table for an O(1) lookups would be a welcomed change, then it could be repurposed for what you describe, I think the only difference is you'd perhaps want a custom driver hook to fetch the calibration data so the driver does whatever it needs.

Quoted 4 lines

Now... how exactly to do that is other question. (But this is looks very reasonable. Maybe I'd add request_firmware_with_flags(, ...int flags), but.. that's a tiny detail.). But userspace needs to be involved.

No, no, we keep adding yet-another-exported symbol for requesting firmware, instead of just adding a set of parameters possible and easily extending functionality. Please review the patches posted on my last set which adds a flexible API with only 2 calls, sync and async, and lets us customize our requests using a parameter:

https://git.kernel.org/cgit/linux/kernel/git/mcgrof/linux-next.git/log/?h=20161216-drvdata-v3-try3

This also documents the "usermode helper" properly and explains some of the issues and limitations you will need to consider if you use it, its one reason I'd highly encourage to consider an alternative as what Arend is considering. *Iff* you insist on using the (now using the proper term, as per the documentation update I am providing) "custom fallback mechanism" I welcome such a change but I ask we *really* think this through well so we avoid the stupid issues which have historically made the custom fallback mechanism more of a nuisance for Linux distributions, users and developers. To this end -- I ask you check out Daniel Wagner and Tom Gundersen's firmwared work [0] which I referred you to in December. Although the drvdata API does not yet use a custom fallback mechanism, after and its merged the goal here would be to *only* support a clean custom fallback mechanism which aligns itself *well* with firmwared or solutions like it. Your patch set then could just become a patch set to add the custom fallback mechaism support to drvdata API with the new options/prefernce you are looking for to be specified in the new parameters, not a new exported symbol.

One of the cruxes we should consider addressing before the drvdata API gets a custom fallback mechanism support added is that the usermode helper lock should be replaced with a generic solution for the races it was intended to address:
use of the API on suspend/resume and implicitly later avoid a race on init. To this end we should consider the same race for *other* real kernel "user mode helpers", I've documented this on a wiki [1] which documents the *real* kernel usermode helpers users, one of which was the kobject uevent which is one of the fallback mechanisms.

I should also note that the idea of fallback mechanism using kobject uevents should really suffice, in review with Johannes Berg at least, he seemed convinced just letting either the upstream firmwared, a custom firmwared or a custom userspace solution should be able to just monitor for uevents for drvdata and do the right thing, this whole "custom fallback mechanism" in retrospect seems not really needed as far as I can tell.

[0] https://github.com/teg/firmwared
[1] https://kernelnewbies.org/KernelProjects/usermode-helper-enhancements

Luis

#12 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Pali Rohár
Quoted 4 lines · Pali Roh=C3=A1r <[email protected]> writes:

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. A=

nd

Quoted 9 lines

in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

Quoted 4 lines

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device which has wl1251 chip, NVS calibration data are stor=

ed

drivers/net/wireles=

Quoted 13 lines

in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

---
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireles= renamed from drivers/net/wireless/ti/wl1251/Kconfig +0 -0

s/ti/wl1251/Kconfig

drivers/net/wireless=

Quoted 12 lines

index 7142ccf..affe154 100644

drivers/net/wireless/ti/wl1251/Kconfig +1 -0
@@ -2,6 +2,7 @@ config WL1251
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
+	select FW_LOADER_USER_HELPER
 	select CRC7
 	---help---
 	  This will enable TI wl1251 driver support. The drivers make
drivers/net/wireless= renamed from drivers/net/wireless/ti/wl1251/main.c +0 -0

/ti/wl1251/main.c

drivers/net/wireless/ti/wl1251/main.c

Quoted 9 lines

index 208f062..24f8866 100644

drivers/net/wireless/ti/wl1251/main.c +0 -0
@@ -110,7 +110,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 	struct device *dev =3D wiphy_dev(wl->hw->wiphy);
 	int ret;

=20=20

drivers/net/wireless/ti/wl1251/main.c +1 -1
-	ret =3D request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret =3D request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);

I don't see the need for this. Just remove the default nvs file from filesystem and the fallback user helper will be always used, right?

Like we discussed earlier, the default nvs file should not be used by normal users.

--=20
Kalle Valo

#44 lore raw

Re: [PATCH 5/6] wl1251: Parse and use MAC address from supplied NVS data

In reply to Pali Rohár
Quoted 20 lines · Pali Rohár

This patch implements parsing MAC address from NVS data which are sent to wl1251 chip. Calibration NVS data could contain valid MAC address and it will be used instead randomly generated.

This patch also move code for requesting NVS data from userspace to driver initialization code to make sure that NVS data will be there at time when permanent MAC address is needed.

Calibration NVS data for wl1251 are model specific. Every one device with wl1251 chip should have been calibrated in factory and needs to provide own calibration data.

Default example wl1251-nvs.bin data found in linux-firmware repository and contains MAC address 00:00:20:07:03:09. So this MAC address is marked as invalid as it is not real device specific address, just example one.

Format of calibration NVS data can be found at:
http://notaz.gp2x.de/misc/pnd/wl1251/nvs_map.txt

[...]

Quoted 5 lines
drivers/net/wireless/ti/wl1251/main.c +5 -0
+static int wl1251_read_nvs_mac(struct wl1251 *wl)
+{
+	u8 mac[ETH_ALEN];
+	int i;
+

drivers/net/wireless/ti/wl1251/main.c static int wl1251_read_eeprom_mac(struct wl1251 *wl) · line 1548

Quoted 10 lines
drivers/net/wireless/ti/wl1251/main.c +10 -0
+	if (wl->nvs_len < 0x24)
+		return -ENODATA;
+
+	/* length is 2 and data address is 0x546c (mask is 0xfffe) */
+	if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b] != 0x54)
+		return -EINVAL;
+
+	/* MAC is stored in reverse order */
+	for (i = 0; i < ETH_ALEN; i++)
+		mac[i] = wl->nvs[0x1c + ETH_ALEN - i - 1];

No magic numbers, please. Replace all nvs offsets with proper defines to make the code more readable.

Signature · 1 line
Kalle Valo
#48 lore raw

Re: [PATCH 6/6] wl1251: Set generated MAC address back to NVS data

In reply to Pali Rohár
Quoted 6 lines · Pali Roh=C3=A1r <[email protected]> writes:

In case there is no valid MAC address kernel generates random one. This patch propagate this generated MAC address back to NVS data which will be uploaded to wl1251 chip. So HW would have same MAC address as linux kernel uses.

Why? What issue does this fix?

--=20
Kalle Valo

#13 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Kalle Valo
Quoted 51 lines · Kalle Valo
Quoted 49 lines · Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device which has wl1251 chip, NVS calibration data are stored in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

---
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wl1251/Kconfig +1 -0
index 7142ccf..affe154 100644
@@ -2,6 +2,7 @@ config WL1251
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
+	select FW_LOADER_USER_HELPER
 	select CRC7
 	---help---
 	  This will enable TI wl1251 driver support. The drivers make
drivers/net/wireless/ti/wl1251/main.c +0 -0
index 208f062..24f8866 100644
@@ -110,7 +110,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 	struct device *dev = wiphy_dev(wl->hw->wiphy);
 	int ret;
 
Quoted 5 lines

drivers/net/wireless/ti/wl1251/main.c static int wl1251_fetch_nvs(struct wl1251 *wl) · line 113

Quoted 2 lines
drivers/net/wireless/ti/wl1251/main.c +1 -1
-	ret = request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret = request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);

I don't see the need for this. Just remove the default nvs file from filesystem and the fallback user helper will be always used, right?

Indeed. The only remaining issue would be that an error message is logged. Also note the fallback is only used if selected in Kconfig.

Quoted 2 lines

Like we discussed earlier, the default nvs file should not be used by normal users.

Yup.

Regards,
Arend

#49 lore raw

Re: [PATCH 6/6] wl1251: Set generated MAC address back to NVS data

In reply to Kalle Valo
Quoted 10 lines · On Friday 27 January 2017 09:56:09 Kalle Valo wrote:
Quoted 6 lines · Pali Rohár

In case there is no valid MAC address kernel generates random one. This patch propagate this generated MAC address back to NVS data which will be uploaded to wl1251 chip. So HW would have same MAC address as linux kernel uses.

Why? What issue does this fix?

Send permanent MAC address to wl1251 chip, same what is doing wl12xx driver.

Signature · 2 lines
Pali Rohár
[email protected]
#50 lore raw

Re: [PATCH 6/6] wl1251: Set generated MAC address back to NVS data

Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Friday 27 January 2017 09:56:09 Kalle Valo wrote:
Quoted 5 lines · Pali Rohár

In case there is no valid MAC address kernel generates random one. This patch propagate this generated MAC address back to NVS data which will be uploaded to wl1251 chip. So HW would have same MAC address as linux kernel uses.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Why? What issue does this fix?

Send permanent MAC address to wl1251 chip, same what is doing wl12xx driver.

Ok, so this doesn't change functionality in any way and you are adding it only because wl12xx does the same? You should document that in the the commit log.

If there's no change I don't really see the point of this. But if there's harm, hopefully, I guess it's ok.

Signature · 1 line
Kalle Valo
#14 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Kalle Valo
Quoted 51 lines · On Friday 27 January 2017 09:33:40 Kalle Valo wrote:
Quoted 49 lines · Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device which has wl1251 chip, NVS calibration data are stored in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

---
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wl1251/Kconfig +1 -0
index 7142ccf..affe154 100644
@@ -2,6 +2,7 @@ config WL1251
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
+	select FW_LOADER_USER_HELPER
 	select CRC7
 	---help---
 	  This will enable TI wl1251 driver support. The drivers make
drivers/net/wireless/ti/wl1251/main.c +0 -0
index 208f062..24f8866 100644
@@ -110,7 +110,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 	struct device *dev = wiphy_dev(wl->hw->wiphy);
 	int ret;
 
Quoted 5 lines

drivers/net/wireless/ti/wl1251/main.c static int wl1251_fetch_nvs(struct wl1251 *wl) · line 113

Quoted 2 lines
drivers/net/wireless/ti/wl1251/main.c +1 -1
-	ret = request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret = request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);

I don't see the need for this. Just remove the default nvs file from filesystem and the fallback user helper will be always used, right?

It is part of linux-firmware repository. And already part of all previous versions of linux-firmware packages in lot of linux distributions. So removing it is not possible...

Quoted 2 lines

Like we discussed earlier, the default nvs file should not be used by normal users.

But already is and we need to deal with this fact.

Signature · 2 lines
Pali Rohár
[email protected]
#15 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 58 lines · Pali Rohár
Quoted 51 lines · On Friday 27 January 2017 09:33:40 Kalle Valo wrote:
Quoted 49 lines · Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device which has wl1251 chip, NVS calibration data are stored in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

---
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wl1251/Kconfig +1 -0
index 7142ccf..affe154 100644
@@ -2,6 +2,7 @@ config WL1251
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
+	select FW_LOADER_USER_HELPER
 	select CRC7
 	---help---
 	  This will enable TI wl1251 driver support. The drivers make
drivers/net/wireless/ti/wl1251/main.c +0 -0
index 208f062..24f8866 100644
@@ -110,7 +110,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 	struct device *dev = wiphy_dev(wl->hw->wiphy);
 	int ret;
 
Quoted 5 lines

drivers/net/wireless/ti/wl1251/main.c static int wl1251_fetch_nvs(struct wl1251 *wl) · line 113

Quoted 2 lines
drivers/net/wireless/ti/wl1251/main.c +1 -1
-	ret = request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret = request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);

I don't see the need for this. Just remove the default nvs file from filesystem and the fallback user helper will be always used, right?

Quoted 3 lines

It is part of linux-firmware repository. And already part of all previous versions of linux-firmware packages in lot of linux distributions. So removing it is not possible...

You are probably saying that on your platform you can not remove anything from /lib/firmware, right? I don't see how you come from "it is part of firmware package" to "removing is not possible". Trying to understand this and it makes no sense.

Quoted 4 lines
Quoted 2 lines

Like we discussed earlier, the default nvs file should not be used by normal users.

But already is and we need to deal with this fact.

Why? Are there other platforms that use the default nvs file and have a working wifi. So your "removing is not possible" would be about regression for those?

Regards,
Arend

#16 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 59 lines · On Friday 27 January 2017 11:05:32 Arend Van Spriel wrote:
Quoted 58 lines · Pali Rohár
Quoted 56 lines · On Friday 27 January 2017 09:33:40 Kalle Valo wrote:
Quoted 46 lines · Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device which has wl1251 chip, NVS calibration data are stored in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

---
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wl1251/Kconfig +1 -0
index 7142ccf..affe154 100644
@@ -2,6 +2,7 @@ config WL1251
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
+	select FW_LOADER_USER_HELPER
 	select CRC7
 	---help---
 	  This will enable TI wl1251 driver support. The drivers make
drivers/net/wireless/ti/wl1251/main.c +0 -0
index 208f062..24f8866 100644

drivers/net/wireless/ti/wl1251/main.c static int wl1251_fetch_nvs(struct wl1251 *wl) · line 113

Quoted 5 lines
drivers/net/wireless/ti/wl1251/main.c +1 -1
@@ -110,7 +110,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 	struct device *dev = wiphy_dev(wl->hw->wiphy);
 	int ret;
 
-	ret = request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret = request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);

I don't see the need for this. Just remove the default nvs file from filesystem and the fallback user helper will be always used, right?

Quoted 8 lines
Quoted 3 lines

It is part of linux-firmware repository. And already part of all previous versions of linux-firmware packages in lot of linux distributions. So removing it is not possible...

You are probably saying that on your platform you can not remove anything from /lib/firmware, right? I don't see how you come from "it is part of firmware package" to "removing is not possible". Trying to understand this and it makes no sense.

It is already in linux distribution packages. If I remove that file from file system it will be placed there again by package management or it it will throw error message about system integrity (missing file, etc...).

Also that file is already in linux-firmware git and so is propagated to /lib/firmware by anybody who is using linux-firmware.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Like we discussed earlier, the default nvs file should not be used by normal users.

But already is and we need to deal with this fact.

Why?

Because everybody has already installed it.

Quoted 2 lines

Are there other platforms that use the default nvs file and have a working wifi.

I do not know.

Quoted 2 lines

So your "removing is not possible" would be about
regression for those?

Yes, that is possible.

Also you can use wifi on Nokia N900 with this default file. Yes it is not recommended and probably has performance problems... but more people use it for SSH and it is working. Pavel could confirm this.

So yes, if you remove that file *now* there is regression for Nokia N900 when you are using SSH over wifi.

Signature · 2 lines
Pali Rohár
[email protected]
#17 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 93 lines · Pali Rohár
Quoted 59 lines · On Friday 27 January 2017 11:05:32 Arend Van Spriel wrote:
Quoted 58 lines · Pali Rohár
Quoted 56 lines · On Friday 27 January 2017 09:33:40 Kalle Valo wrote:
Quoted 46 lines · Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device which has wl1251 chip, NVS calibration data are stored in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

---
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wl1251/Kconfig +1 -0
index 7142ccf..affe154 100644
@@ -2,6 +2,7 @@ config WL1251
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
+	select FW_LOADER_USER_HELPER
 	select CRC7
 	---help---
 	  This will enable TI wl1251 driver support. The drivers make
drivers/net/wireless/ti/wl1251/main.c +0 -0
index 208f062..24f8866 100644

drivers/net/wireless/ti/wl1251/main.c static int wl1251_fetch_nvs(struct wl1251 *wl) · line 113

Quoted 5 lines
drivers/net/wireless/ti/wl1251/main.c +1 -1
@@ -110,7 +110,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 	struct device *dev = wiphy_dev(wl->hw->wiphy);
 	int ret;
 
-	ret = request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret = request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);

I don't see the need for this. Just remove the default nvs file from filesystem and the fallback user helper will be always used, right?

Quoted 8 lines
Quoted 3 lines

It is part of linux-firmware repository. And already part of all previous versions of linux-firmware packages in lot of linux distributions. So removing it is not possible...

You are probably saying that on your platform you can not remove anything from /lib/firmware, right? I don't see how you come from "it is part of firmware package" to "removing is not possible". Trying to understand this and it makes no sense.

It is already in linux distribution packages. If I remove that file from file system it will be placed there again by package management or it it will throw error message about system integrity (missing file, etc...).

Also that file is already in linux-firmware git and so is propagated to /lib/firmware by anybody who is using linux-firmware.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Like we discussed earlier, the default nvs file should not be used by normal users.

But already is and we need to deal with this fact.

Why?

Because everybody has already installed it.

Quoted 2 lines

Are there other platforms that use the default nvs file and have a working wifi.

I do not know.

Quoted 2 lines

So your "removing is not possible" would be about
regression for those?

Quoted 8 lines

Yes, that is possible.

Also you can use wifi on Nokia N900 with this default file. Yes it is not recommended and probably has performance problems... but more people use it for SSH and it is working. Pavel could confirm this.

So yes, if you remove that file *now* there is regression for Nokia N900 when you are using SSH over wifi.

So you are changing the behavior for all platforms using wl1251, but the user-helper preference is (probably) only applicable for N900, right? So for those other platforms there will be a delay waiting for user-mode helper to fail, before trying to get nvs file from /lib/firmware.

Regards,
Arend

#18 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 100 lines · On Friday 27 January 2017 11:19:25 Arend Van Spriel wrote:
Quoted 99 lines · Pali Rohár
Quoted 59 lines · On Friday 27 January 2017 11:05:32 Arend Van Spriel wrote:
Quoted 58 lines · Pali Rohár
Quoted 56 lines · On Friday 27 January 2017 09:33:40 Kalle Valo wrote:
Quoted 46 lines · Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device which has wl1251 chip, NVS calibration data are stored in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

---
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wl1251/Kconfig +1 -0
index 7142ccf..affe154 100644
@@ -2,6 +2,7 @@ config WL1251
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
+	select FW_LOADER_USER_HELPER
 	select CRC7
 	---help---
 	  This will enable TI wl1251 driver support. The drivers make
drivers/net/wireless/ti/wl1251/main.c +0 -0
index 208f062..24f8866 100644

drivers/net/wireless/ti/wl1251/main.c static int wl1251_fetch_nvs(struct wl1251 *wl) · line 113

Quoted 5 lines
drivers/net/wireless/ti/wl1251/main.c +1 -1
@@ -110,7 +110,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 	struct device *dev = wiphy_dev(wl->hw->wiphy);
 	int ret;
 
-	ret = request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret = request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);

I don't see the need for this. Just remove the default nvs file from filesystem and the fallback user helper will be always used, right?

Quoted 8 lines
Quoted 3 lines

It is part of linux-firmware repository. And already part of all previous versions of linux-firmware packages in lot of linux distributions. So removing it is not possible...

You are probably saying that on your platform you can not remove anything from /lib/firmware, right? I don't see how you come from "it is part of firmware package" to "removing is not possible". Trying to understand this and it makes no sense.

It is already in linux distribution packages. If I remove that file from file system it will be placed there again by package management or it it will throw error message about system integrity (missing file, etc...).

Also that file is already in linux-firmware git and so is propagated to /lib/firmware by anybody who is using linux-firmware.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Like we discussed earlier, the default nvs file should not be used by normal users.

But already is and we need to deal with this fact.

Why?

Because everybody has already installed it.

Quoted 2 lines

Are there other platforms that use the default nvs file and have a working wifi.

I do not know.

Quoted 2 lines

So your "removing is not possible" would be about
regression for those?

Yes, that is possible.

Also you can use wifi on Nokia N900 with this default file. Yes it is not recommended and probably has performance problems... but more people use it for SSH and it is working. Pavel could confirm this.

Quoted 5 lines
Quoted 2 lines

So yes, if you remove that file *now* there is regression for Nokia N900 when you are using SSH over wifi.

So you are changing the behavior for all platforms using wl1251, but the user-helper preference is (probably) only applicable for N900, right?

No. Some wl1251 chips have internal EEPROM where is stored MAC address and NVS data. And kernel driver already can read it. So this change is only for platforms without internal EEPROM.

And all platforms without internal EEPROM should use userspace helper to provide correct NVS data (and ideally also MAC address).

Except Nokia N900 I know just Pandora who has also wl1251 chip. But Pandora has EEPROM.

Grepping linux source code... and I see only defines for Nokia N900 and Pandora. There can be also another user with external DTS file, but what is reality? Is there still really any other user of wl1251 chip with upstream kernel? If yes, we can prepare userspace helper if he does not have NVS stored in EEPROM...

Quoted 3 lines

So
for those other platforms there will be a delay waiting for user-mode helper to fail, before trying to get nvs file from /lib/firmware.

Yes, there will be. But there is no easy way to fix this problem that kernel is trying to use default/example NVS data...

When helper is not available this patch just adds delay, but functionality is still there and same. With helper support will be finally fixed.

And I have no idea if those default NVS data are somehow usable on other platforms...

Signature · 2 lines
Pali Rohár
[email protected]
#19 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 6 lines · Pali Roh=C3=A1r <[email protected]> writes:
Quoted 3 lines

So
for those other platforms there will be a delay waiting for user-mode helper to fail, before trying to get nvs file from /lib/firmware.

Yes, there will be. But there is no easy way to fix this problem that kernel is trying to use default/example NVS data...

Kernel is doing correctly and requesting NVS data as expected, the problem here is that linux-firmware claims that the example NVS data is real calibration data (which it is not). Distros should not use that, only developers for testing purposes. We should not courage users using example calibration data.

The simple fix is to rename the NVS file in linux-firmware to something like wl1251-nvs.bin.example, no need to workaround this in kernel. If you send a patch to linux-firmware I'm happy to ack that.

--=20
Kalle Valo

#20 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 15 lines · On Friday 27 January 2017 13:49:03 Kalle Valo wrote:
Quoted 6 lines · Pali Rohár
Quoted 3 lines

So
for those other platforms there will be a delay waiting for user-mode helper to fail, before trying to get nvs file from /lib/firmware.

Yes, there will be. But there is no easy way to fix this problem that kernel is trying to use default/example NVS data...

Kernel is doing correctly and requesting NVS data as expected, the problem here is that linux-firmware claims that the example NVS data is real calibration data (which it is not). Distros should not use that, only developers for testing purposes. We should not courage users using example calibration data.

Quoted 3 lines

The simple fix is to rename the NVS file in linux-firmware to something like wl1251-nvs.bin.example, no need to workaround this in kernel. If you send a patch to linux-firmware I'm happy to ack that.

I agree with rename and fact that default/example data should not be used.

But...

1) Kernel should not read device/model specific data from VFS where are stored not-device-specific files preinstalled by linux distributions.

And linux distributions are already putting files into VFS and kernel cannot enforce userspace to not do that (as they are already doing it).

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

3) If we do rename *now* we will totally break wifi support on Nokia N900.

Signature · 2 lines
Pali Rohár
[email protected]
#35 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Pali Rohár

Hi!

Quoted 26 lines
Quoted 4 lines

You are probably saying that on your platform you can not remove anything from /lib/firmware, right? I don't see how you come from "it is part of firmware package" to "removing is not possible". Trying to understand this and it makes no sense.

It is already in linux distribution packages. If I remove that file from file system it will be placed there again by package management or it it will throw error message about system integrity (missing file, etc...).

Also that file is already in linux-firmware git and so is propagated to /lib/firmware by anybody who is using linux-firmware.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Like we discussed earlier, the default nvs file should not be used by normal users.

But already is and we need to deal with this fact.

Why?

Because everybody has already installed it.

Quoted 2 lines

Are there other platforms that use the default nvs file and have a working wifi.

I do not know.

Quoted 8 lines
Quoted 2 lines

So your "removing is not possible" would be about
regression for those?

Yes, that is possible.

Also you can use wifi on Nokia N900 with this default file. Yes it is not recommended and probably has performance problems... but more people use it for SSH and it is working. Pavel could confirm this.

Yes, wifi somehow works on N900. .. depending on userspace and kernel versions.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#21 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Pali Rohár
Quoted 23 lines · Pali Rohár
Quoted 15 lines · On Friday 27 January 2017 13:49:03 Kalle Valo wrote:
Quoted 6 lines · Pali Rohár
Quoted 3 lines

So
for those other platforms there will be a delay waiting for user-mode helper to fail, before trying to get nvs file from /lib/firmware.

Yes, there will be. But there is no easy way to fix this problem that kernel is trying to use default/example NVS data...

Kernel is doing correctly and requesting NVS data as expected, the problem here is that linux-firmware claims that the example NVS data is real calibration data (which it is not). Distros should not use that, only developers for testing purposes. We should not courage users using example calibration data.

Quoted 3 lines

The simple fix is to rename the NVS file in linux-firmware to something like wl1251-nvs.bin.example, no need to workaround this in kernel. If you send a patch to linux-firmware I'm happy to ack that.

I agree with rename and fact that default/example data should not be used.

Quoted 8 lines

But...

1) Kernel should not read device/model specific data from VFS where are stored not-device-specific files preinstalled by linux distributions.

And linux distributions are already putting files into VFS and kernel cannot enforce userspace to not do that (as they are already doing it).

I'm having problems to understand what you are saying here.

Quoted 4 lines

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

I disagree. Allowing default calibration data to be used can be unnoticed by user and left her wondering why wifi works so badly.

Quoted 2 lines

3) If we do rename *now* we will totally break wifi support on Nokia N900.

Then the distro should fix that when updating the linux-firmware packages. Can you provide details about the setup, what distro etc?

Signature · 1 line
Kalle Valo
#22 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 27 lines · Kalle Valo
Quoted 25 lines · Pali Rohár
Quoted 15 lines · On Friday 27 January 2017 13:49:03 Kalle Valo wrote:
Quoted 6 lines · Pali Rohár
Quoted 3 lines

So
for those other platforms there will be a delay waiting for user-mode helper to fail, before trying to get nvs file from /lib/firmware.

Yes, there will be. But there is no easy way to fix this problem that kernel is trying to use default/example NVS data...

Kernel is doing correctly and requesting NVS data as expected, the problem here is that linux-firmware claims that the example NVS data is real calibration data (which it is not). Distros should not use that, only developers for testing purposes. We should not courage users using example calibration data.

Quoted 3 lines

The simple fix is to rename the NVS file in linux-firmware to something like wl1251-nvs.bin.example, no need to workaround this in kernel. If you send a patch to linux-firmware I'm happy to ack that.

I agree with rename and fact that default/example data should not be used.

But...

Quoted 8 lines
Quoted 6 lines

1) Kernel should not read device/model specific data from VFS where are stored not-device-specific files preinstalled by linux distributions.

And linux distributions are already putting files into VFS and kernel cannot enforce userspace to not do that (as they are already doing it).

I'm having problems to understand what you are saying here.

This is a personal opinion. I read it as: /lib/firmware can only contain files for from linux-firmware.

At least the device-specific vs. non-device-specific does not seem to hold. The firmware files that we have in the linux-firmware repository are very device-specific. Unless you mean the 'platform' when talking about 'device'.

Regards,
Arend

#24 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Kalle Valo
Quoted 27 lines · On Friday 27 January 2017 14:26:22 Kalle Valo wrote:
Quoted 25 lines · Pali Rohár
Quoted 15 lines · On Friday 27 January 2017 13:49:03 Kalle Valo wrote:
Quoted 6 lines · Pali Rohár
Quoted 3 lines

So
for those other platforms there will be a delay waiting for user-mode helper to fail, before trying to get nvs file from /lib/firmware.

Yes, there will be. But there is no easy way to fix this problem that kernel is trying to use default/example NVS data...

Kernel is doing correctly and requesting NVS data as expected, the problem here is that linux-firmware claims that the example NVS data is real calibration data (which it is not). Distros should not use that, only developers for testing purposes. We should not courage users using example calibration data.

Quoted 3 lines

The simple fix is to rename the NVS file in linux-firmware to something like wl1251-nvs.bin.example, no need to workaround this in kernel. If you send a patch to linux-firmware I'm happy to ack that.

I agree with rename and fact that default/example data should not be used.

But...

Quoted 8 lines
Quoted 6 lines

1) Kernel should not read device/model specific data from VFS where are stored not-device-specific files preinstalled by linux distributions.

And linux distributions are already putting files into VFS and kernel cannot enforce userspace to not do that (as they are already doing it).

I'm having problems to understand what you are saying here.

I'm saying that linux distributions are putting files to /lib/firmware which comes from some sources already released. You cannot force linux distributions to stop putting particular file to /lib/firmware *now* after it was already released and recommended.

Quoted 7 lines
Quoted 4 lines

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

I disagree. Allowing default calibration data to be used can be unnoticed by user and left her wondering why wifi works so badly.

So there are only two options:

1) Disallow it and so these users will have non-working wifi.

2) Allow those data to be used as fallback mechanism.

And personally I'm against 1) because it will break wifi support for *all* Nokia N900 devices right now.

Quoted 5 lines
Quoted 2 lines

3) If we do rename *now* we will totally break wifi support on Nokia N900.

Then the distro should fix that when updating the linux-firmware packages. Can you provide details about the setup, what distro etc?

Debian stable, Ubuntu LTSs 14.04, 16.04. And I think that other LTS distributions contains that example nvs file too (I'm not going to verify others, but list will be probably long). Upgrading linux-firmware is against policy of those distributions. So no this is not an solution.

Signature · 2 lines
Pali Rohár
[email protected]
#23 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Arend Van Spriel
Quoted 37 lines · On Friday 27 January 2017 13:53:28 Arend Van Spriel wrote:
Quoted 27 lines · Kalle Valo
Quoted 25 lines · Pali Rohár
Quoted 15 lines · On Friday 27 January 2017 13:49:03 Kalle Valo wrote:
Quoted 6 lines · Pali Rohár
Quoted 3 lines

So
for those other platforms there will be a delay waiting for user-mode helper to fail, before trying to get nvs file from /lib/firmware.

Yes, there will be. But there is no easy way to fix this problem that kernel is trying to use default/example NVS data...

Kernel is doing correctly and requesting NVS data as expected, the problem here is that linux-firmware claims that the example NVS data is real calibration data (which it is not). Distros should not use that, only developers for testing purposes. We should not courage users using example calibration data.

Quoted 3 lines

The simple fix is to rename the NVS file in linux-firmware to something like wl1251-nvs.bin.example, no need to workaround this in kernel. If you send a patch to linux-firmware I'm happy to ack that.

I agree with rename and fact that default/example data should not be used.

But...

Quoted 8 lines
Quoted 6 lines

1) Kernel should not read device/model specific data from VFS where are stored not-device-specific files preinstalled by linux distributions.

And linux distributions are already putting files into VFS and kernel cannot enforce userspace to not do that (as they are already doing it).

I'm having problems to understand what you are saying here.

Quoted 7 lines

This is a personal opinion. I read it as: /lib/firmware can only contain files for from linux-firmware.

At least the device-specific vs. non-device-specific does not seem to hold. The firmware files that we have in the linux-firmware repository are very device-specific. Unless you mean the 'platform' when talking about 'device'.

Here I'm talking about files which are specific per unit. Every one N900 has different NVS file (stored in CAL) and so every one N900 device needs its own NVS file. And we cannot store thousands of NVS files into linux-firmware repository for each N900 which was ever produced in factory.

Firmware files in linux-firmware repository are "device" specific, but "filename" of that file describe exactly for which "device" it is specific.

But there are thousands of different NVS files for one filename "wl1251-nvs.bin" and we cannot use one particular for another device. In linux-firmware is stored "wl1251-nvs.bin" file with example data.

Signature · 2 lines
Pali Rohár
[email protected]
#25 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Pali Rohár
Quoted 11 lines · Pali Rohár
Quoted 9 lines · On Friday 27 January 2017 14:26:22 Kalle Valo wrote:
Quoted 4 lines · Pali Rohár

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

I disagree. Allowing default calibration data to be used can be unnoticed by user and left her wondering why wifi works so badly.

Quoted 8 lines

So there are only two options:

1) Disallow it and so these users will have non-working wifi.

2) Allow those data to be used as fallback mechanism.

And personally I'm against 1) because it will break wifi support for *all* Nokia N900 devices right now.

All two of them? :)

But not working is exactly my point, if correct calibration data is not available wifi should not work. And it's not only about functionality problems, there's also the regulatory aspect.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

3) If we do rename *now* we will totally break wifi support on Nokia N900.

Then the distro should fix that when updating the linux-firmware packages. Can you provide details about the setup, what distro etc?

Debian stable, Ubuntu LTSs 14.04, 16.04.

You can run these out of box on N900?

Quoted 4 lines

And I think that other LTS distributions contains that example nvs file too (I'm not going to verify others, but list will be probably long). Upgrading linux-firmware is against policy of those distributions. So no this is not an solution.

So instead we should workaround distro policies in kernel? Come on.

Seriously, just rename the file in linux-firmware and file a bug (with a patch) to distros. If they don't fix the bug you just have to do a custom hack for N900. But such is life.

Signature · 1 line
Kalle Valo
#26 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 15 lines · On Friday 27 January 2017 17:23:07 Kalle Valo wrote:
Quoted 13 lines · Pali Rohár
Quoted 9 lines · On Friday 27 January 2017 14:26:22 Kalle Valo wrote:
Quoted 4 lines · Pali Rohár

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

I disagree. Allowing default calibration data to be used can be unnoticed by user and left her wondering why wifi works so badly.

So there are only two options:

Quoted 8 lines
Quoted 6 lines

1) Disallow it and so these users will have non-working wifi.

2) Allow those data to be used as fallback mechanism.

And personally I'm against 1) because it will break wifi support for *all* Nokia N900 devices right now.

All two of them? :)

Ehm...

Quoted 3 lines

But not working is exactly my point, if correct calibration data is not available wifi should not work. And it's not only about functionality problems, there's also the regulatory aspect.

About functionality, Pavel confirmed too that SSH is somehow working...

Regulatory aspect is different, but via iw can be manually configured some settings.

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

3) If we do rename *now* we will totally break wifi support on Nokia N900.

Then the distro should fix that when updating the linux-firmware packages. Can you provide details about the setup, what distro etc?

Debian stable, Ubuntu LTSs 14.04, 16.04.

You can run these out of box on N900?

Out-of-box I can run Kubuntu 12.04 (which is LTS too). They had prepared special image for N900 and I still have it on uSD card.

I guess that new versions of Ubuntu could somehow work (maybe not out-of-box but with some changes) and Pavel has working Debian.

Also basic support needed for wifi and SSH server is probably working with any distribution targeting armv7-a or omap3. So yes, I can say it is out-of-box. We will not have GSM calls or camera support, but wifi breakage is there.

Quoted 10 lines
Quoted 4 lines

And I think that other LTS distributions contains that example nvs file too (I'm not going to verify others, but list will be probably long). Upgrading linux-firmware is against policy of those distributions. So no this is not an solution.

So instead we should workaround distro policies in kernel? Come on.

Seriously, just rename the file in linux-firmware and file a bug (with a patch) to distros. If they don't fix the bug you just have to do a custom hack for N900. But such is life.

I do not see point what will be changed. I rename that file and after system update (or integrity check) it will be there again.

And if I do that, what prevents kernel to stop using NVS file from /lib/firmware/? Nothing, original problem (which is going solved by this patch series) still remains.

Signature · 2 lines
Pali Rohár
[email protected]
#27 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Kalle Valo
Quoted 15 lines · Kalle Valo
Quoted 13 lines · Pali Rohár
Quoted 9 lines · On Friday 27 January 2017 14:26:22 Kalle Valo wrote:
Quoted 4 lines · Pali Rohár

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

I disagree. Allowing default calibration data to be used can be unnoticed by user and left her wondering why wifi works so badly.

So there are only two options:

Quoted 8 lines
Quoted 6 lines

1) Disallow it and so these users will have non-working wifi.

2) Allow those data to be used as fallback mechanism.

And personally I'm against 1) because it will break wifi support for *all* Nokia N900 devices right now.

All two of them? :)

Umm. You clearly want a flock of angry penguins at your doorsteps :-).

Quoted 3 lines

But not working is exactly my point, if correct calibration data is not available wifi should not work. And it's not only about functionality problems, there's also the regulatory aspect.

If you break existing configuration that's called "regression".

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

3) If we do rename *now* we will totally break wifi support on Nokia N900.

Then the distro should fix that when updating the linux-firmware packages. Can you provide details about the setup, what distro etc?

Debian stable, Ubuntu LTSs 14.04, 16.04.

You can run these out of box on N900?

Debian stable does.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#34 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Pali Rohár
Quoted 5 lines · Pali Rohár

So there are only two options:

1) Disallow it and so these users will have non-working wifi.

2) Allow those data to be used as fallback mechanism.

There is one "custom fallback" user in kernel which we recently determined was a total mistake. A sysfs interface should have been defined to enable custom LED settings. Can't a series of sysfs interfaces be used to enable override ? So is that not a third option worth consideration?

Luis

#28 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Pavel Machek
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Kalle Valo
Quoted 15 lines · Pali Rohár
Quoted 9 lines · On Friday 27 January 2017 14:26:22 Kalle Valo wrote:
Quoted 4 lines · Pali Rohár

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

I disagree. Allowing default calibration data to be used can be unnoticed by user and left her wondering why wifi works so badly.

So there are only two options:

1) Disallow it and so these users will have non-working wifi.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

2) Allow those data to be used as fallback mechanism.

And personally I'm against 1) because it will break wifi support for *all* Nokia N900 devices right now.

All two of them? :)

Umm. You clearly want a flock of angry penguins at your doorsteps :-).

Well this silly issue of symlinking and renaming nvs files in a standard Linux distro was also hitting me on various devices with wl12xx/wl18xx trying to use the same rootfs.

Why don't we just set a custom compatible property for n900 that then picks up some other nvs file instead of the default?

Regards,

Tony

#29 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 24 lines · On Monday 30 January 2017 18:53:09 Tony Lindgren wrote:
Quoted 23 lines · Pavel Machek
Quoted 22 lines · Kalle Valo
Quoted 20 lines · Pali Rohár
Quoted 10 lines · On Friday 27 January 2017 14:26:22 Kalle Valo wrote:
Quoted 5 lines · Pali Rohár

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

I disagree. Allowing default calibration data to be used can be unnoticed by user and left her wondering why wifi works so badly.

So there are only two options:

1) Disallow it and so these users will have non-working wifi.

2) Allow those data to be used as fallback mechanism.

And personally I'm against 1) because it will break wifi support for *all* Nokia N900 devices right now.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

All two of them? :)

Umm. You clearly want a flock of angry penguins at your doorsteps :-).

Well this silly issue of symlinking and renaming nvs files in a standard Linux distro was also hitting me on various devices with wl12xx/wl18xx trying to use the same rootfs.

wl12xx/wl18xx have probably exactly same problem as wl1251.

Quoted 2 lines

Why don't we just set a custom compatible property for n900 that then picks up some other nvs file instead of the default?

But that still does not solve this problem correctly. Every n900 device have different NVS file. If we allow to load firmware directly from VFS without userspace helper we would see again same problem.

Signature · 2 lines
Pali Rohár
[email protected]
#30 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Tony Lindgren
Quoted 26 lines · Tony Lindgren
Quoted 25 lines · Pavel Machek
Quoted 23 lines · Kalle Valo
Quoted 11 lines · Pali Rohár
Quoted 9 lines · On Friday 27 January 2017 14:26:22 Kalle Valo wrote:
Quoted 4 lines · Pali Rohár

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

I disagree. Allowing default calibration data to be used can be unnoticed by user and left her wondering why wifi works so badly.

Quoted 8 lines

So there are only two options:

1) Disallow it and so these users will have non-working wifi.

2) Allow those data to be used as fallback mechanism.

And personally I'm against 1) because it will break wifi support for *all* Nokia N900 devices right now.

All two of them? :)

Quoted 8 lines
Quoted 1 line

Umm. You clearly want a flock of angry penguins at your doorsteps :-).

Well this silly issue of symlinking and renaming nvs files in a standard Linux distro was also hitting me on various devices with wl12xx/wl18xx trying to use the same rootfs.

Why don't we just set a custom compatible property for n900 that then picks up some other nvs file instead of the default?

Please don't. An ugly kernel workaround in kernel because of user space problems is a bad idea. wl1251 should just ask for NVS file from user space, it shouldn't care if it's a "default" file or something else. That's a user space policy decision.

Why can't you do something like this:

* rename the NVS file linux-firmware to wl1251-nvs.bin.example

* before distro updates linux-firmware create yours own deb/rpm/whatever package "wl1251-firmware" which installs your flavor of nvs file (or the user fallback helper if more dynamic functionality is preferred)

Signature · 1 line
Kalle Valo
#31 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 34 lines · Kalle Valo
Quoted 32 lines · Tony Lindgren
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Kalle Valo
Quoted 15 lines · Pali Rohár
Quoted 9 lines · On Friday 27 January 2017 14:26:22 Kalle Valo wrote:
Quoted 4 lines · Pali Rohár

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

I disagree. Allowing default calibration data to be used can be unnoticed by user and left her wondering why wifi works so badly.

So there are only two options:

1) Disallow it and so these users will have non-working wifi.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

2) Allow those data to be used as fallback mechanism.

And personally I'm against 1) because it will break wifi support for *all* Nokia N900 devices right now.

All two of them? :)

Umm. You clearly want a flock of angry penguins at your doorsteps :-).

Well this silly issue of symlinking and renaming nvs files in a standard Linux distro was also hitting me on various devices with wl12xx/wl18xx trying to use the same rootfs.

Quoted 7 lines
Quoted 2 lines

Why don't we just set a custom compatible property for n900 that then picks up some other nvs file instead of the default?

Please don't. An ugly kernel workaround in kernel because of user space problems is a bad idea. wl1251 should just ask for NVS file from user space, it shouldn't care if it's a "default" file or something else. That's a user space policy decision.

Grr I keep forgetting it needs to be for each device manufactured so yeah that won't work.

The names of standard distro files are hardcoded into the kernel driver so it's also a kernel problem though :p

How about a custom devices tree property saying "needs-custom-firmware"?

Something that would prevent anything being loaded until user space loads the firmware. It could also be set in the driver automatically based on the compatible flag if we always want it enabled. And we could have some cmdline option to ignore it. Or the other way around whatever makes sense.

Quoted 3 lines

Why can't you do something like this:

* rename the NVS file linux-firmware to wl1251-nvs.bin.example

As that name is hardcoded in the kernel and that file is provided by all standard distros, let's assume we just have to deal with that ABI forever.

Quoted 3 lines

* before distro updates linux-firmware create yours own deb/rpm/whatever package "wl1251-firmware" which installs your flavor of nvs file (or the user fallback helper if more dynamic functionality is preferred)

And that won't work when using the same file system on other machines.

Think NFSroot for example. At least I'm using the same NFSroot across about 15 different machines including one n900 macro board with smc91x Ethernet.

Regards,

Tony

#32 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 43 lines · On Tuesday 31 January 2017 07:59:18 Tony Lindgren wrote:
Quoted 34 lines · Kalle Valo
Quoted 32 lines · Tony Lindgren
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Kalle Valo
Quoted 15 lines · Pali Rohár
Quoted 9 lines · On Friday 27 January 2017 14:26:22 Kalle Valo wrote:
Quoted 4 lines · Pali Rohár

2) It was already tested that example NVS data can be used for N900 e.g. for SSH connection. If real correct data are not available it is better to use at least those example (and probably log warning message) so user can connect via SSH and start investigating where is problem.

I disagree. Allowing default calibration data to be used can be unnoticed by user and left her wondering why wifi works so badly.

So there are only two options:

1) Disallow it and so these users will have non-working wifi.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

2) Allow those data to be used as fallback mechanism.

And personally I'm against 1) because it will break wifi support for *all* Nokia N900 devices right now.

All two of them? :)

Umm. You clearly want a flock of angry penguins at your doorsteps :-).

Well this silly issue of symlinking and renaming nvs files in a standard Linux distro was also hitting me on various devices with wl12xx/wl18xx trying to use the same rootfs.

Quoted 7 lines
Quoted 2 lines

Why don't we just set a custom compatible property for n900 that then picks up some other nvs file instead of the default?

Please don't. An ugly kernel workaround in kernel because of user space problems is a bad idea. wl1251 should just ask for NVS file from user space, it shouldn't care if it's a "default" file or something else. That's a user space policy decision.

Quoted 7 lines

Grr I keep forgetting it needs to be for each device manufactured so yeah that won't work.

The names of standard distro files are hardcoded into the kernel driver so it's also a kernel problem though :p

How about a custom devices tree property saying "needs-custom-firmware"?

How does it help request_firmware() call which automatically loads firmware file from VFS (if is available)?

Quoted 5 lines

Something that would prevent anything being loaded until user space loads the firmware. It could also be set in the driver automatically based on the compatible flag if we always want it enabled. And we could have some cmdline option to ignore it. Or the other way around whatever makes sense.

So you just want to kernel automatically prevent loading firmware file (based on flag which driver can set). That is similar approach as mine.

Quoted 7 lines
Quoted 3 lines

Why can't you do something like this:

* rename the NVS file linux-firmware to wl1251-nvs.bin.example

As that name is hardcoded in the kernel and that file is provided by all standard distros, let's assume we just have to deal with that ABI forever.

Yes.

Quoted 9 lines
Quoted 3 lines

* before distro updates linux-firmware create yours own deb/rpm/whatever package "wl1251-firmware" which installs your flavor of nvs file (or the user fallback helper if more dynamic functionality is preferred)

And that won't work when using the same file system on other machines.

Think NFSroot for example. At least I'm using the same NFSroot across about 15 different machines including one n900 macro board with smc91x Ethernet.

Exactly problem which we already discussed in previous emails. You cannot serve one file (loaded by direct request_firmware) when your rootfs is readonly, e.g. comes via NFS shared for more devices...

Signature · 2 lines
Pali Rohár
[email protected]
#33 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 2 lines · On 1 February 2017 at 09:33, Pali Roh=C3=A1r <[email protected]> wrote:
Quoted 1 line · On Tuesday 31 January 2017 07:59:18 Tony Lindgren wrote:

* Kalle Valo <[email protected]> [170130 22:36]:

[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line

* before distro updates linux-firmware create yours own deb/rpm/whatev=

er

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

package "wl1251-firmware" which installs your flavor of nvs file (or the user fallback helper if more dynamic functionality is preferred)

And that won't work when using the same file system on other machines.

Quoted 7 lines
Quoted 3 lines

Think NFSroot for example. At least I'm using the same NFSroot across about 15 different machines including one n900 macro board with smc91x Ethernet.

Exactly problem which we already discussed in previous emails. You cannot serve one file (loaded by direct request_firmware) when your rootfs is readonly, e.g. comes via NFS shared for more devices...

You can extract the nvs blob, put it in tmpfs and bind-mount (or symlink) it to /lib/firmware/ via modprobe install hook (or init scripts).

Micha=C5=82

#9 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Luis R. Rodriguez
Quoted 15 lines · Luis R. Rodriguez
Quoted 8 lines · Pavel Machek

Right question is "should we solve it without user-space help"?

Answer is no, too. Way too complex. Yes, it would be nice if hardware was designed in such a way that getting calibration data from kernel is easy, and if you design hardware, please design it like that. But N900 is not designed like that and getting the calibration through userspace looks like only reasonable solution.

Arend seems to have a better alternative in mind possible for other devices which *can* probably pull of doing this easily and nicely, given the nasty history of the usermode helper crap we should not in any way discourage such efforts.

Quoted 5 lines

Arend -- please look at the firmware cache, it not a hash but a hash table for an O(1) lookups would be a welcomed change, then it could be repurposed for what you describe, I think the only difference is you'd perhaps want a custom driver hook to fetch the calibration data so the driver does whatever it needs.

Hi Luis,

I let my idea catch dust on the shelf for a while. Actually had a couple of patches ready, but did get around testing them. So I wanted to rebase them on your linux-next tree. I bumped into the umh lock thing and was wondering why direct filesystem access was under that lock as well. In your tree I noticed a fix for that. The more reason to base my work on top of your firmware_class changes. Now my question is what is the best branch to choose, because you have a "few" in that repo to choose from ;-)

Regards,
Arend

#10 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 22 lines · Arend Van Spriel
Quoted 15 lines · Luis R. Rodriguez
Quoted 8 lines · Pavel Machek

Right question is "should we solve it without user-space help"?

Answer is no, too. Way too complex. Yes, it would be nice if hardware was designed in such a way that getting calibration data from kernel is easy, and if you design hardware, please design it like that. But N900 is not designed like that and getting the calibration through userspace looks like only reasonable solution.

Arend seems to have a better alternative in mind possible for other devices which *can* probably pull of doing this easily and nicely, given the nasty history of the usermode helper crap we should not in any way discourage such efforts.

Quoted 5 lines

Arend -- please look at the firmware cache, it not a hash but a hash table for an O(1) lookups would be a welcomed change, then it could be repurposed for what you describe, I think the only difference is you'd perhaps want a custom driver hook to fetch the calibration data so the driver does whatever it needs.

Quoted 3 lines

Hi Luis,

I let my idea catch dust on the shelf for a while.

:) BTW did you get to check out Daniel Wagner and Tom Gundersen's firmware work
[0] ? This can provide a proper clear fallback mechanism which *also* helps address the race between "critical mount points ready" problem we had discussed long ago. IIRC it did this by having two modes of operation a best effort-mode and a final-mode. The final-mode would only be used once all the real rootfs is ready. Userspace decides when to kick / signal firmwared to switch to final-mode as only userspace will know for sure when that is ready. The best-effort mode would be used in initramfs. There is also no need for a "custom fallback", the uevent fallback mechanism can be relied upon alone. Custom tools can just fork off and do something similar to firmward then in terms of architecture. This is a form of fallback mechanism I think I'd be happy to see enabled on the new driver data API. But of course, I recall also liking what you had in mind as well so would be happy to see more alternatives! The cleaner the better !

[0] https://github.com/teg/firmwared

Quoted 4 lines

Actually had a couple
of patches ready, but did get around testing them. So I wanted to rebase them on your linux-next tree. I bumped into the umh lock thing and was wondering why direct filesystem access was under that lock as well.

Indeed, it was an odd thing.

Quoted 1 line

In your tree I noticed a fix for that.

Yup!

It took a lot of git archeology to reach a sound approach forward which makes me feel comfortable without regressing the kernel, this should not regress the kernel.

Quoted 3 lines

The more reason to base my work on
top of your firmware_class changes. Now my question is what is the best branch to choose, because you have a "few" in that repo to choose from ;-)

I have a series of topical changes, and I rebase onto the latest linux-next regularly before posting patches, if 0-day finds issues, I dish out a next try2 or tryX iteration until all issues are fixed. So in this case you'd just go for the latest driver-data-$(next_date) and if there is a try postfix use the latest tryX.

In this case 20170501-driver-data-try2, this is based on linux-next tag next-20170501. If you have issues booting on that next tag though you could instead try the v4.11-rc8-driver-data-try3 branch based on v4.11-rc8. But naturally patches ultimately should be based on the latest linux-next tag for actual submission.

PS. after my changes the fallback mechanism can easily be shoved into its own file, not sure if that helps with how clean of a solution your work will be.

Luis

#11 lore raw

Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

Quoted 74 lines · Luis R. Rodriguez
Quoted 22 lines · Arend Van Spriel
Quoted 15 lines · Luis R. Rodriguez
Quoted 8 lines · Pavel Machek

Right question is "should we solve it without user-space help"?

Answer is no, too. Way too complex. Yes, it would be nice if hardware was designed in such a way that getting calibration data from kernel is easy, and if you design hardware, please design it like that. But N900 is not designed like that and getting the calibration through userspace looks like only reasonable solution.

Arend seems to have a better alternative in mind possible for other devices which *can* probably pull of doing this easily and nicely, given the nasty history of the usermode helper crap we should not in any way discourage such efforts.

Quoted 5 lines

Arend -- please look at the firmware cache, it not a hash but a hash table for an O(1) lookups would be a welcomed change, then it could be repurposed for what you describe, I think the only difference is you'd perhaps want a custom driver hook to fetch the calibration data so the driver does whatever it needs.

Quoted 3 lines

Hi Luis,

I let my idea catch dust on the shelf for a while.

:) BTW did you get to check out Daniel Wagner and Tom Gundersen's firmware work
[0] ? This can provide a proper clear fallback mechanism which *also* helps address the race between "critical mount points ready" problem we had discussed long ago. IIRC it did this by having two modes of operation a best effort-mode and a final-mode. The final-mode would only be used once all the real rootfs is ready. Userspace decides when to kick / signal firmwared to switch to final-mode as only userspace will know for sure when that is ready. The best-effort mode would be used in initramfs. There is also no need for a "custom fallback", the uevent fallback mechanism can be relied upon alone. Custom tools can just fork off and do something similar to firmward then in terms of architecture. This is a form of fallback mechanism I think I'd be happy to see enabled on the new driver data API. But of course, I recall also liking what you had in mind as well so would be happy to see more alternatives! The cleaner the better !

[0] https://github.com/teg/firmwared

Quoted 4 lines

Actually had a couple
of patches ready, but did get around testing them. So I wanted to rebase them on your linux-next tree. I bumped into the umh lock thing and was wondering why direct filesystem access was under that lock as well.

Indeed, it was an odd thing.

Quoted 1 line

In your tree I noticed a fix for that.

Yup!

It took a lot of git archeology to reach a sound approach forward which makes me feel comfortable without regressing the kernel, this should not regress the kernel.

Quoted 3 lines

The more reason to base my work on
top of your firmware_class changes. Now my question is what is the best branch to choose, because you have a "few" in that repo to choose from ;-)

I have a series of topical changes, and I rebase onto the latest linux-next regularly before posting patches, if 0-day finds issues, I dish out a next try2 or tryX iteration until all issues are fixed. So in this case you'd just go for the latest driver-data-$(next_date) and if there is a try postfix use the latest tryX.

In this case 20170501-driver-data-try2, this is based on linux-next tag next-20170501. If you have issues booting on that next tag though you could instead try the v4.11-rc8-driver-data-try3 branch based on v4.11-rc8. But naturally patches ultimately should be based on the latest linux-next tag for actual submission.

Quoted 3 lines

PS. after my changes the fallback mechanism can easily be shoved into its own file, not sure if that helps with how clean of a solution your work will be.

Let me explain the idea to refresh your memory (and mine). It started when we were working on adding driver support for OpenWrt in brcmfmac. The driver requests for firmware calibration data, but on routers it is stored in flash. So after failing on the firmware request we now call a platform specific API. That was my itch, but it was not bad enough to go and scratch. Now for N900 case there is a similar scenario alhtough it has additional requirement to go to user-space due to need to use a proprietary library to obtain the NVS calibration data. My thought: Why should firmware_class care? So the idea is that firmware_class provides a registry for modules that can produce a certain firmware "file". Those modules can do whatever is needed. If they need to use umh so be it. They would only register themselves with firmware_class on platforms that need them. It would basically be replacing the fallback mechanism and only be effective on certain platforms.

Let me know if this idea is still of interest and I will rebase what I have for an RFC round.

Regards,
Arend

#51 lore raw

v2 cover wl1251: Fix MAC address for Nokia N900

In reply to Pali Rohár

This patch series fix processing MAC address for wl1251 chip found in Nokia N900.

Changes since v1:
* Added Acked-by for Pavel Machek
* Fixed grammar
* Magic numbers for NVS offsets are replaced by defines
* Check for validity of mac address NVS data is moved into function
* Changed order of patches as Pavel requested

Pali Rohár (6):
wl1251: Update wl->nvs_len after wl->nvs is valid
wl1251: Generate random MAC address only if driver does not have
valid
wl1251: Parse and use MAC address from supplied NVS data
wl1251: Set generated MAC address back to NVS data
firmware: Add request_firmware_prefer_user() function
wl1251: Use request_firmware_prefer_user() for loading NVS
calibration data

 drivers/base/firmware_class.c          |   45 +++++++++++++-
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |  104 ++++++++++++++++++++++++++------
 include/linux/firmware.h               |    9 +++
 4 files changed, 138 insertions(+), 21 deletions(-)
Signature · 1 line
1.7.9.5
#52 lore raw

PATCH v2 1/6 wl1251: Update wl->nvs_len after wl->nvs is valid

If kmemdup fails, then wl->nvs_len will contain invalid non-zero size.

---
 drivers/net/wireless/ti/wl1251/main.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/ti/wl1251/main.c +3 -2
index 9915d83..8929bb3 100644
@@ -122,8 +122,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 		goto out;
 	}
 
-	wl->nvs_len = fw->size;
-	wl->nvs = kmemdup(fw->data, wl->nvs_len, GFP_KERNEL);
+	wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL);
 
 	if (!wl->nvs) {
 		wl1251_error("could not allocate memory for the nvs file");
@@ -131,6 +130,8 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 		goto out;
 	}
 
+	wl->nvs_len = fw->size;
+
 	ret = 0;
 
 out:
Signature · 1 line
1.7.9.5
#55 lore raw

PATCH v2 2/6 wl1251: Generate random MAC address only if driver does not have valid

In reply to Pali Rohár

Before this patch, driver generated random MAC address every time it was initialized. After that random MAC address could be overwritten with fixed one, if provided.

This patch changes order. First it tries to read fixed MAC address and if it fails then driver generates random MAC address.

---
 drivers/net/wireless/ti/wl1251/main.c |   27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/net/wireless/ti/wl1251/main.c +18 -9
index 8929bb3..9106c20 100644
@@ -1492,7 +1492,24 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
 	wl->hw->queues = 4;
 
 	if (wl->use_eeprom)
-		wl1251_read_eeprom_mac(wl);
+		ret = wl1251_read_eeprom_mac(wl);
+	else
+		ret = -EINVAL;
+
+	if (ret == 0 && !is_valid_ether_addr(wl->mac_addr))
+		ret = -EINVAL;
+
+	if (ret < 0) {
+		/*
+		 * In case our MAC address is not correctly set,
+		 * we use a random but Nokia MAC.
+		 */
+		static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
+		memcpy(wl->mac_addr, nokia_oui, 3);
+		get_random_bytes(wl->mac_addr + 3, 3);
+		wl1251_warning("MAC address in eeprom or nvs data is not valid");
+		wl1251_warning("Setting random MAC address: %pM", wl->mac_addr);
+	}
 
 	ret = wl1251_register_hw(wl);
 	if (ret)
@@ -1513,7 +1530,6 @@ struct ieee80211_hw *wl1251_alloc_hw(void)
 	struct ieee80211_hw *hw;
 	struct wl1251 *wl;
 	int i;
-	static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
 
 	hw = ieee80211_alloc_hw(sizeof(*wl), &wl1251_ops);
 	if (!hw) {
@@ -1563,13 +1579,6 @@ struct ieee80211_hw *wl1251_alloc_hw(void)
 	INIT_WORK(&wl->irq_work, wl1251_irq_work);
 	INIT_WORK(&wl->tx_work, wl1251_tx_work);
 
-	/*
-	 * In case our MAC address is not correctly set,
-	 * we use a random but Nokia MAC.
-	 */
-	memcpy(wl->mac_addr, nokia_oui, 3);
-	get_random_bytes(wl->mac_addr + 3, 3);
-
 	wl->state = WL1251_STATE_OFF;
 	mutex_init(&wl->mutex);
 	spin_lock_init(&wl->wl_lock);
Signature · 1 line
1.7.9.5
#56 lore raw

PATCH v2 3/6 wl1251: Parse and use MAC address from supplied NVS data

In reply to Pali Rohár

This patch implements parsing MAC address from NVS data which are sent to wl1251 chip. Calibration NVS data could contain valid MAC address and it will be used instead of randomly generated one.

This patch also moves code for requesting NVS data from userspace to driver initialization code to make sure that NVS data will be there at time when permanent MAC address is needed.

Calibration NVS data for wl1251 are device specific. Every device with wl1251 chip should have been calibrated in factory and needs to provide own calibration data.

Default example file wl1251-nvs.bin, found in linux-firmware repository, contains MAC address 00:00:20:07:03:09. So this MAC address is marked as invalid as it is not real device specific address, just example one.

Format of calibration NVS data can be found at:
http://notaz.gp2x.de/misc/pnd/wl1251/nvs_map.txt

---
 drivers/net/wireless/ti/wl1251/main.c |   55 ++++++++++++++++++++++++++++-----
 1 file changed, 47 insertions(+), 8 deletions(-)
drivers/net/wireless/ti/wl1251/main.c +47 -8
index 9106c20..d497ba5 100644
@@ -203,13 +203,6 @@ static int wl1251_chip_wakeup(struct wl1251 *wl)
 			goto out;
 	}
 
-	if (wl->nvs == NULL && !wl->use_eeprom) {
-		/* No NVS from netlink, try to get it from the filesystem */
-		ret = wl1251_fetch_nvs(wl);
-		if (ret < 0)
-			goto out;
-	}
-
 out:
 	return ret;
 }
@@ -1448,6 +1441,46 @@ static int wl1251_read_eeprom_mac(struct wl1251 *wl)
 	return 0;
 }
 
+#define NVS_OFF_MAC_LEN 0x19
+#define NVS_OFF_MAC_ADDR_LO 0x1a
+#define NVS_OFF_MAC_ADDR_HI 0x1b
+#define NVS_OFF_MAC_DATA 0x1c
+
+static int wl1251_check_nvs_mac(struct wl1251 *wl)
+{
+	if (wl->nvs_len < 0x24)
+		return -ENODATA;
+
+	/* length is 2 and data address is 0x546c (ANDed with 0xfffe) */
+	if (wl->nvs[NVS_OFF_MAC_LEN] != 2 ||
+	    wl->nvs[NVS_OFF_MAC_ADDR_LO] != 0x6d ||
+	    wl->nvs[NVS_OFF_MAC_ADDR_HI] != 0x54)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int wl1251_read_nvs_mac(struct wl1251 *wl)
+{
+	u8 mac[ETH_ALEN];
+	int i, ret;
+
+	ret = wl1251_check_nvs_mac(wl);
+	if (ret)
+		return ret;
+
+	/* MAC is stored in reverse order */
+	for (i = 0; i < ETH_ALEN; i++)
+		mac[i] = wl->nvs[NVS_OFF_MAC_DATA + ETH_ALEN - i - 1];
+
+	/* 00:00:20:07:03:09 is in example file wl1251-nvs.bin, so invalid */
+	if (ether_addr_equal_unaligned(mac, "\x00\x00\x20\x07\x03\x09"))
+		return -EINVAL;
+
+	memcpy(wl->mac_addr, mac, ETH_ALEN);
+	return 0;
+}
+
 static int wl1251_register_hw(struct wl1251 *wl)
 {
 	int ret;
@@ -1491,10 +1524,16 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
 
 	wl->hw->queues = 4;
 
+	if (wl->nvs == NULL && !wl->use_eeprom) {
+		ret = wl1251_fetch_nvs(wl);
+		if (ret < 0)
+			goto out;
+	}
+
 	if (wl->use_eeprom)
 		ret = wl1251_read_eeprom_mac(wl);
 	else
-		ret = -EINVAL;
+		ret = wl1251_read_nvs_mac(wl);
 
 	if (ret == 0 && !is_valid_ether_addr(wl->mac_addr))
 		ret = -EINVAL;
Signature · 1 line
1.7.9.5
#58 lore raw

PATCH v2 5/6 firmware: Add request_firmware_prefer_user() function

In reply to Pali Rohár

This function works pretty much like request_firmware(), but it prefer usermode helper. If usermode helper fails then it fallback to direct access. Useful for dynamic or model specific firmware data.

---
 drivers/base/firmware_class.c |   45 +++++++++++++++++++++++++++++++++++++++--
 include/linux/firmware.h      |    9 +++++++++
 2 files changed, 52 insertions(+), 2 deletions(-)
drivers/base/firmware_class.c +43 -2
index 4b57cf5..c3a9fe5 100644
@@ -195,6 +195,11 @@ static int __fw_state_check(struct fw_state *fw_st, enum fw_status status)
 #endif
 #define FW_OPT_NO_WARN	(1U << 3)
 #define FW_OPT_NOCACHE	(1U << 4)
+#ifdef CONFIG_FW_LOADER_USER_HELPER
+#define FW_OPT_PREFER_USER	(1U << 5)
+#else
+#define FW_OPT_PREFER_USER	0
+#endif
 
 struct firmware_cache {
 	/* firmware_buf instance will be added into the below list */
@@ -1214,13 +1219,26 @@ static void fw_abort_batch_reqs(struct firmware *fw)
 	if (ret <= 0) /* error or already assigned */
 		goto out;
 
-	ret = fw_get_filesystem_firmware(device, fw->priv);
+	if (opt_flags & FW_OPT_PREFER_USER) {
+		ret = fw_load_from_user_helper(fw, name, device, opt_flags, timeout);
+		if (ret && !(opt_flags & FW_OPT_NO_WARN)) {
+			dev_warn(device,
+				 "User helper firmware load for %s failed with error %d\n",
+				 name, ret);
+			dev_warn(device, "Falling back to direct firmware load\n");
+		}
+	} else {
+		ret = -EINVAL;
+	}
+
+	if (ret)
+		ret = fw_get_filesystem_firmware(device, fw->priv);
 	if (ret) {
 		if (!(opt_flags & FW_OPT_NO_WARN))
 			dev_warn(device,
 				 "Direct firmware load for %s failed with error %d\n",
 				 name, ret);
-		if (opt_flags & FW_OPT_USERHELPER) {
+		if ((opt_flags & FW_OPT_USERHELPER) && !(opt_flags & FW_OPT_PREFER_USER)) {
 			dev_warn(device, "Falling back to user helper\n");
 			ret = fw_load_from_user_helper(fw, name, device,
 						       opt_flags);
@@ -1329,6 +1347,29 @@ int request_firmware_direct(const struct firmware **firmware_p,
 EXPORT_SYMBOL(request_firmware_into_buf);
 
 /**
+ * request_firmware_prefer_user: - prefer usermode helper for loading firmware
+ * @firmware_p: pointer to firmware image
+ * @name: name of firmware file
+ * @device: device for which firmware is being loaded
+ *
+ * This function works pretty much like request_firmware(), but it prefer
+ * usermode helper. If usermode helper fails then it fallback to direct access.
+ * Useful for dynamic or model specific firmware data.
+ **/
+int request_firmware_prefer_user(const struct firmware **firmware_p,
+			    const char *name, struct device *device)
+{
+	int ret;
+
+	__module_get(THIS_MODULE);
+	ret = _request_firmware(firmware_p, name, device, NULL, 0,
+				FW_OPT_UEVENT | FW_OPT_PREFER_USER);
+	module_put(THIS_MODULE);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(request_firmware_prefer_user);
+
+/**
  * release_firmware: - release the resource associated with a firmware image
  * @fw: firmware resource to release
  **/
include/linux/firmware.h +9 -0
index d450808..8584528 100644
@@ -48,6 +48,8 @@ int request_firmware_nowait(
 	void (*cont)(const struct firmware *fw, void *context));
 int request_firmware_direct(const struct firmware **fw, const char *name,
 			    struct device *device);
+int request_firmware_prefer_user(const struct firmware **fw, const char *name,
+				 struct device *device);
 int request_firmware_into_buf(const struct firmware **firmware_p,
 	const char *name, struct device *device, void *buf, size_t size);
 
@@ -78,6 +80,13 @@ static inline int request_firmware_direct(const struct firmware **fw,
 	return -EINVAL;
 }
 
+static inline int request_firmware_prefer_user(const struct firmware **fw,
+					       const char *name,
+					       struct device *device)
+{
+	return -EINVAL;
+}
+
 static inline int request_firmware_into_buf(const struct firmware **firmware_p,
 	const char *name, struct device *device, void *buf, size_t size)
 {
Signature · 1 line
1.7.9.5
#63 lore raw

PATCH v2 6/6 wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

In reply to Pali Rohár

NVS calibration data for wl1251 are model specific. Every one device with wl1251 chip has different and calibrated in factory.

Not all wl1251 chips have own EEPROM where are calibration data stored. And in that case there is no "standard" place. Every device has stored them on different place (some in rootfs file, some in dedicated nand partition, some in another proprietary structure).

Kernel wl1251 driver cannot support every one different storage decided by device manufacture so it will use request_firmware_prefer_user() call for loading NVS calibration data and userspace helper will be responsible to prepare correct data.

In case userspace helper fails request_firmware_prefer_user() still try to load data file directly from VFS as fallback mechanism.

On Nokia N900 device, which has wl1251 chip, NVS calibration data are stored in CAL nand partition. CAL is proprietary Nokia key/value format for nand devices.

With this patch it is finally possible to load correct model specific NVS calibration data for Nokia N900.

Userspace tool for reading NVS calibration data on Nokia N900 is available in git repository at: https://github.com/community-ssu/wl1251-cal

---
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wl1251/Kconfig +1 -0
index 7142ccf..affe154 100644
@@ -2,6 +2,7 @@ config WL1251
 	tristate "TI wl1251 driver support"
 	depends on MAC80211
 	select FW_LOADER
+	select FW_LOADER_USER_HELPER
 	select CRC7
 	---help---
 	  This will enable TI wl1251 driver support. The drivers make
drivers/net/wireless/ti/wl1251/main.c +1 -1
index 1f423be..e9d232c 100644
@@ -108,7 +108,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
 	struct device *dev = wiphy_dev(wl->hw->wiphy);
 	int ret;
 
-	ret = request_firmware(&fw, WL1251_NVS_NAME, dev);
+	ret = request_firmware_prefer_user(&fw, WL1251_NVS_NAME, dev);
 
 	if (ret < 0) {
 		wl1251_error("could not get nvs file: %d", ret);
Signature · 1 line
1.7.9.5
#57 lore raw

PATCH v2 4/6 wl1251: Set generated MAC address back to NVS data

In reply to Pali Rohár

In case there is no valid MAC address kernel generates random one. This patch propagate this generated MAC address back to NVS data which will be uploaded to wl1251 chip. So HW would have same MAC address as linux kernel uses.

This should not change any functionality, but it is better to tell wl1251 correct mac address since beginning of chip usage.

---
 drivers/net/wireless/ti/wl1251/main.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/net/wireless/ti/wl1251/main.c +17 -0
index d497ba5..1f423be 100644
@@ -1481,6 +1481,21 @@ static int wl1251_read_nvs_mac(struct wl1251 *wl)
 	return 0;
 }
 
+static int wl1251_write_nvs_mac(struct wl1251 *wl)
+{
+	int i, ret;
+
+	ret = wl1251_check_nvs_mac(wl);
+	if (ret)
+		return ret;
+
+	/* MAC is stored in reverse order */
+	for (i = 0; i < ETH_ALEN; i++)
+		wl->nvs[NVS_OFF_MAC_DATA + i] = wl->mac_addr[ETH_ALEN - i - 1];
+
+	return 0;
+}
+
 static int wl1251_register_hw(struct wl1251 *wl)
 {
 	int ret;
@@ -1546,6 +1561,8 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
 		static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
 		memcpy(wl->mac_addr, nokia_oui, 3);
 		get_random_bytes(wl->mac_addr + 3, 3);
+		if (!wl->use_eeprom)
+			wl1251_write_nvs_mac(wl);
 		wl1251_warning("MAC address in eeprom or nvs data is not valid");
 		wl1251_warning("Setting random MAC address: %pM", wl->mac_addr);
 	}
Signature · 1 line
1.7.9.5
#59 lore raw

Re: [PATCH v2 5/6] firmware: Add request_firmware_prefer_user() function

In reply to Pali Rohár
Quoted 15 lines · Pali Rohár

This function works pretty much like request_firmware(), but it prefer usermode helper. If usermode helper fails then it fallback to direct access. Useful for dynamic or model specific firmware data.

---
 drivers/base/firmware_class.c |   45 +++++++++++++++++++++++++++++++++++++++--
 include/linux/firmware.h      |    9 +++++++++
 2 files changed, 52 insertions(+), 2 deletions(-)
drivers/base/firmware_class.c +0 -0
index 4b57cf5..c3a9fe5 100644

drivers/base/firmware_class.c static int __fw_state_check(struct fw_state *fw_st, enum fw_status status) · line 202

Quoted 8 lines
drivers/base/firmware_class.c +5 -0
@@ -195,6 +195,11 @@ static int __fw_state_check(struct fw_state *fw_st, enum fw_status status)
 #endif
 #define FW_OPT_NO_WARN	(1U << 3)
 #define FW_OPT_NOCACHE	(1U << 4)
+#ifdef CONFIG_FW_LOADER_USER_HELPER
+#define FW_OPT_PREFER_USER	(1U << 5)
+#else
+#define FW_OPT_PREFER_USER	0
+#endif

I've been cleaning these up these flags [0], which I'll shortly respin based on feedback, so this sort of stuff should be avoided at all costs.

Regardless of this even if you *leave* the flag in place and a driver required this, but the kernel was compiled without CONFIG_FW_LOADER_USER_HELPER then calling fw_load_from_user_helper would just already return -ENOENT, as such it would in turn fallback to direct fs loading so the #ifef'ery seems to be not needed.

[0] https://lkml.kernel.org/r/[email protected]

Quoted 4 lines
drivers/base/firmware_class.c +0 -0
 struct firmware_cache {
 	/* firmware_buf instance will be added into the below list */
@@ -1214,13 +1219,26 @@ static void fw_abort_batch_reqs(struct firmware *fw)
 	if (ret <= 0) /* error or already assigned */

drivers/base/firmware_class.c static void fw_abort_batch_reqs(struct firmware *fw) · line 1228

Quoted 10 lines
drivers/base/firmware_class.c +7 -1
 		goto out;
 
-	ret = fw_get_filesystem_firmware(device, fw->priv);
+	if (opt_flags & FW_OPT_PREFER_USER) {
+		ret = fw_load_from_user_helper(fw, name, device, opt_flags, timeout);
+		if (ret && !(opt_flags & FW_OPT_NO_WARN)) {
+			dev_warn(device,
+				 "User helper firmware load for %s failed with error %d\n",
+				 name, ret);
+			dev_warn(device, "Falling back to direct firmware load\n");

As I had noted before, the usermode helper was really not well designed, as such extending further use of it is something we should shy away unless we determine its completely necessary.

So what's wrong with this driver failing at direct access, which should be fast, and relying on a uevent to then work using the current fallback mechanisms?

The commit log in no way documents any of the justifications for further extending use of the usermode helper.

Luis

#60 lore raw

Re: [PATCH v2 5/6] firmware: Add request_firmware_prefer_user() function

Quoted 8 lines · Luis R. Rodriguez

even if you *leave* the flag in place and a driver required
this, but the kernel was compiled without CONFIG_FW_LOADER_USER_HELPER then calling fw_load_from_user_helper would just already return -ENOENT, as such it would in turn fallback to direct fs loading so the #ifef'ery seems to be not needed.

The commit log in no way documents any of the justifications for further extending use of the usermode helper.

Also, any new functionality introduced should have a respective test case in tools/testing/selftests/firmware/ and lib/test_firmware.c, as well as extending existing documentation on Documentation/driver-api/firmware/.

Luis

#61 lore raw

Re: [PATCH v2 5/6] firmware: Add request_firmware_prefer_user() function

In reply to Luis R. Rodriguez
Quoted 55 lines · On Friday 10 November 2017 21:26:01 Luis R. Rodriguez wrote:
Quoted 15 lines · Pali Rohár

This function works pretty much like request_firmware(), but it prefer usermode helper. If usermode helper fails then it fallback to direct access. Useful for dynamic or model specific firmware data.

---
 drivers/base/firmware_class.c |   45 +++++++++++++++++++++++++++++++++++++++--
 include/linux/firmware.h      |    9 +++++++++
 2 files changed, 52 insertions(+), 2 deletions(-)
drivers/base/firmware_class.c +0 -0
index 4b57cf5..c3a9fe5 100644

drivers/base/firmware_class.c static int __fw_state_check(struct fw_state *fw_st, enum fw_status status) · line 202

Quoted 8 lines
drivers/base/firmware_class.c +5 -0
@@ -195,6 +195,11 @@ static int __fw_state_check(struct fw_state *fw_st, enum fw_status status)
 #endif
 #define FW_OPT_NO_WARN	(1U << 3)
 #define FW_OPT_NOCACHE	(1U << 4)
+#ifdef CONFIG_FW_LOADER_USER_HELPER
+#define FW_OPT_PREFER_USER	(1U << 5)
+#else
+#define FW_OPT_PREFER_USER	0
+#endif

I've been cleaning these up these flags [0], which I'll shortly respin based on feedback, so this sort of stuff should be avoided at all costs.

Regardless of this even if you *leave* the flag in place and a driver required this, but the kernel was compiled without CONFIG_FW_LOADER_USER_HELPER then calling fw_load_from_user_helper would just already return -ENOENT, as such it would in turn fallback to direct fs loading so the #ifef'ery seems to be not needed.

[0] https://lkml.kernel.org/r/[email protected]

Quoted 4 lines
drivers/base/firmware_class.c +0 -0
 struct firmware_cache {
 	/* firmware_buf instance will be added into the below list */
@@ -1214,13 +1219,26 @@ static void fw_abort_batch_reqs(struct firmware *fw)
 	if (ret <= 0) /* error or already assigned */

drivers/base/firmware_class.c static void fw_abort_batch_reqs(struct firmware *fw) · line 1228

Quoted 10 lines
drivers/base/firmware_class.c +7 -1
 		goto out;
 
-	ret = fw_get_filesystem_firmware(device, fw->priv);
+	if (opt_flags & FW_OPT_PREFER_USER) {
+		ret = fw_load_from_user_helper(fw, name, device, opt_flags, timeout);
+		if (ret && !(opt_flags & FW_OPT_NO_WARN)) {
+			dev_warn(device,
+				 "User helper firmware load for %s failed with error %d\n",
+				 name, ret);
+			dev_warn(device, "Falling back to direct firmware load\n");

As I had noted before, the usermode helper was really not well designed, as such extending further use of it is something we should shy away unless we determine its completely necessary.

Quoted 5 lines

So what's wrong with this driver failing at direct access, which should be fast, and relying on a uevent to then work using the current fallback mechanisms?

The commit log in no way documents any of the justifications for further extending use of the usermode helper.

Hi! See patch 6/6. It is needed to avoid direct access and wl1251 on Nokia N900 needs to use userspace helper which prepares firmware data.

Direct access is just fallback when userspace helper is not available. Without userspace helper on devices where wl1251 do not have own eeprom memory, wl1251 cannot work.

I know that usermode helper is not well designed, but it is the best option what we can do for wl1251.

Signature · 2 lines
Pali Rohár
[email protected]
#62 lore raw

Re: [PATCH v2 5/6] firmware: Add request_firmware_prefer_user() function

Quoted 56 lines · Pali Rohár
Quoted 55 lines · On Friday 10 November 2017 21:26:01 Luis R. Rodriguez wrote:
Quoted 15 lines · Pali Rohár

This function works pretty much like request_firmware(), but it prefer usermode helper. If usermode helper fails then it fallback to direct access. Useful for dynamic or model specific firmware data.

---
 drivers/base/firmware_class.c |   45 +++++++++++++++++++++++++++++++++++++++--
 include/linux/firmware.h      |    9 +++++++++
 2 files changed, 52 insertions(+), 2 deletions(-)
drivers/base/firmware_class.c +0 -0
index 4b57cf5..c3a9fe5 100644

drivers/base/firmware_class.c static int __fw_state_check(struct fw_state *fw_st, enum fw_status status) · line 202

Quoted 8 lines
drivers/base/firmware_class.c +5 -0
@@ -195,6 +195,11 @@ static int __fw_state_check(struct fw_state *fw_st, enum fw_status status)
 #endif
 #define FW_OPT_NO_WARN	(1U << 3)
 #define FW_OPT_NOCACHE	(1U << 4)
+#ifdef CONFIG_FW_LOADER_USER_HELPER
+#define FW_OPT_PREFER_USER	(1U << 5)
+#else
+#define FW_OPT_PREFER_USER	0
+#endif

I've been cleaning these up these flags [0], which I'll shortly respin based on feedback, so this sort of stuff should be avoided at all costs.

Regardless of this even if you *leave* the flag in place and a driver required this, but the kernel was compiled without CONFIG_FW_LOADER_USER_HELPER then calling fw_load_from_user_helper would just already return -ENOENT, as such it would in turn fallback to direct fs loading so the #ifef'ery seems to be not needed.

[0] https://lkml.kernel.org/r/[email protected]

Quoted 4 lines
drivers/base/firmware_class.c +0 -0
 struct firmware_cache {
 	/* firmware_buf instance will be added into the below list */
@@ -1214,13 +1219,26 @@ static void fw_abort_batch_reqs(struct firmware *fw)
 	if (ret <= 0) /* error or already assigned */

drivers/base/firmware_class.c static void fw_abort_batch_reqs(struct firmware *fw) · line 1228

Quoted 10 lines
drivers/base/firmware_class.c +7 -1
 		goto out;
 
-	ret = fw_get_filesystem_firmware(device, fw->priv);
+	if (opt_flags & FW_OPT_PREFER_USER) {
+		ret = fw_load_from_user_helper(fw, name, device, opt_flags, timeout);
+		if (ret && !(opt_flags & FW_OPT_NO_WARN)) {
+			dev_warn(device,
+				 "User helper firmware load for %s failed with error %d\n",
+				 name, ret);
+			dev_warn(device, "Falling back to direct firmware load\n");

As I had noted before, the usermode helper was really not well designed, as such extending further use of it is something we should shy away unless we determine its completely necessary.

Quoted 8 lines
Quoted 5 lines

So what's wrong with this driver failing at direct access, which should be fast, and relying on a uevent to then work using the current fallback mechanisms?

The commit log in no way documents any of the justifications for further extending use of the usermode helper.

Hi! See patch 6/6. It is needed to avoid direct access and wl1251 on Nokia N900 needs to use userspace helper which prepares firmware data.

My point is your commit log in no way describes the shortcomings of the current affairs for device drivers which only can access the data it needs using the firmware fallback mechanism.

In order for a change to go in, specially if its extending use of the fallback mechanism through sysfs now as primary citizen, the justification should be well documented on the commit log.

For instance you may want to highlight that what I documented here:

https://www.kernel.org/doc/html/latest/driver-api/firmware/fallback-mechanisms.html

"CONFIG_FW_LOADER_USER_HELPER: enables building the firmware fallback mechanism. Most distributions enable this option today. If enabled but CONFIG_FW_LOADER_USER_HELPER_FALLBACK is disabled, only the custom fallback mechanism is available and for the request_firmware_nowait() call."

Since most distros disable CONFIG_FW_LOADER_USER_HELPER_FALLBACK, in practice this means the fallback mechanism is never actually triggered, and the only way to do that in practice this for most distros is to use the custom fallback mechanism, and the only difference there is that the custom fallback mechanism has an infinite timeout since we have no clear way to know what it is or when it will complete, other than when it actually does its work.

That begs the question, why cant you just use request_firmware_nowait() with the custom fallback mechanism?

Your commit log should explain the shortcomings of the current API.

Also note that "usermode helper" refers to kernel/umh.c, and the only code being used from that UMH API is the usermodehelper_read_lock_wait() on async, or usermodehelper_read_trylock() on sync. Nothing else. The rest of the firmware uploading is done via a sysfs file upload mechanism. Its precisely why I documented the fallback mechanism instead as:

"Firmware sysfs loading facility"

Adding any other flag which reflects "UMH" only will confuse people further. If you are going to add a new flag, perhaps "FW_OPT_PREFER_SYSFS_LOAD" is much more suitable.

Quoted 3 lines

Direct access is just fallback when userspace helper is not available. Without userspace helper on devices where wl1251 do not have own eeprom memory, wl1251 cannot work.

That is not an explanation as to why request_firmware_nowait() could not be used with the custom fallback interface.

Quoted 2 lines

I know that usermode helper is not well designed, but it is the best option what we can do for wl1251.

It does not seem like you have tested the custom fallback mechanism, nor have you documented properly the justification for extending and making use of the sysfs loading facility a first option for loading firmware.

Luis

#64 lore raw
In reply to Pali Rohár
Quoted 19 lines · On Friday 10 November 2017 00:38:22 Pali Rohár wrote:

This patch series fix processing MAC address for wl1251 chip found in Nokia N900.

Changes since v1:
* Added Acked-by for Pavel Machek
* Fixed grammar
* Magic numbers for NVS offsets are replaced by defines
* Check for validity of mac address NVS data is moved into function
* Changed order of patches as Pavel requested

Pali Rohár (6):
wl1251: Update wl->nvs_len after wl->nvs is valid
wl1251: Generate random MAC address only if driver does not have
valid
wl1251: Parse and use MAC address from supplied NVS data
wl1251: Set generated MAC address back to NVS data
firmware: Add request_firmware_prefer_user() function
wl1251: Use request_firmware_prefer_user() for loading NVS
calibration data

Quoted 5 lines
 drivers/base/firmware_class.c          |   45 +++++++++++++-
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |  104 ++++++++++++++++++++++++++------
 include/linux/firmware.h               |    9 +++
 4 files changed, 138 insertions(+), 21 deletions(-)

Hi! Are there any comments for first 4 patches? If not, could they be accepted and merged?

Signature · 2 lines
Pali Rohár
[email protected]
#65 lore raw
Quoted 20 lines · Pali Rohár
Quoted 19 lines · On Friday 10 November 2017 00:38:22 Pali Rohár wrote:

This patch series fix processing MAC address for wl1251 chip found in Nokia N900.

Changes since v1:
* Added Acked-by for Pavel Machek
* Fixed grammar
* Magic numbers for NVS offsets are replaced by defines
* Check for validity of mac address NVS data is moved into function
* Changed order of patches as Pavel requested

Pali Rohár (6):
wl1251: Update wl->nvs_len after wl->nvs is valid
wl1251: Generate random MAC address only if driver does not have
valid
wl1251: Parse and use MAC address from supplied NVS data
wl1251: Set generated MAC address back to NVS data
firmware: Add request_firmware_prefer_user() function
wl1251: Use request_firmware_prefer_user() for loading NVS
calibration data

Quoted 8 lines
Quoted 5 lines
 drivers/base/firmware_class.c          |   45 +++++++++++++-
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |  104 ++++++++++++++++++++++++++------
 include/linux/firmware.h               |    9 +++
 4 files changed, 138 insertions(+), 21 deletions(-)

Hi! Are there any comments for first 4 patches? If not, could they be accepted and merged?

Since the first 4 patches do not touch the firmware API they seem fine to me so long as the maintainer accepts them. Maybe resend and clarify you have dropped the other ones and amend with the new tags.

Luis

#66 lore raw
Quoted 27 lines · On Friday 05 January 2018 02:45:10 Luis R. Rodriguez wrote:
Quoted 26 lines · Pali Rohár
Quoted 24 lines · On Friday 10 November 2017 00:38:22 Pali Rohár wrote:

This patch series fix processing MAC address for wl1251 chip found in Nokia N900.

Changes since v1:
* Added Acked-by for Pavel Machek
* Fixed grammar
* Magic numbers for NVS offsets are replaced by defines
* Check for validity of mac address NVS data is moved into function
* Changed order of patches as Pavel requested

Pali Rohár (6):
wl1251: Update wl->nvs_len after wl->nvs is valid
wl1251: Generate random MAC address only if driver does not have
valid
wl1251: Parse and use MAC address from supplied NVS data
wl1251: Set generated MAC address back to NVS data
firmware: Add request_firmware_prefer_user() function
wl1251: Use request_firmware_prefer_user() for loading NVS
calibration data

 drivers/base/firmware_class.c          |   45 +++++++++++++-
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |  104 ++++++++++++++++++++++++++------
 include/linux/firmware.h               |    9 +++
 4 files changed, 138 insertions(+), 21 deletions(-)
Quoted 6 lines
Quoted 2 lines

Hi! Are there any comments for first 4 patches? If not, could they be accepted and merged?

Since the first 4 patches do not touch the firmware API they seem fine to me so long as the maintainer accepts them. Maybe resend and clarify you have dropped the other ones and amend with the new tags.

According to get_maintainer.pl, Kalle Valo is maintainer.

Kalle Valo, if you do not have any other comments, can you accept first 4 patches? Or do you really need to resent first 4 patches again?

Signature · 2 lines
Pali Rohár
[email protected]
#67 lore raw
Quoted 31 lines · Pali Rohár
Quoted 30 lines · On Friday 05 January 2018 02:45:10 Luis R. Rodriguez wrote:
Quoted 28 lines · Pali Rohár
Quoted 19 lines · On Friday 10 November 2017 00:38:22 Pali Rohár wrote:

This patch series fix processing MAC address for wl1251 chip found in Nokia N900.

Changes since v1:
* Added Acked-by for Pavel Machek
* Fixed grammar
* Magic numbers for NVS offsets are replaced by defines
* Check for validity of mac address NVS data is moved into function
* Changed order of patches as Pavel requested

Pali Rohár (6):
wl1251: Update wl->nvs_len after wl->nvs is valid
wl1251: Generate random MAC address only if driver does not have
valid
wl1251: Parse and use MAC address from supplied NVS data
wl1251: Set generated MAC address back to NVS data
firmware: Add request_firmware_prefer_user() function
wl1251: Use request_firmware_prefer_user() for loading NVS
calibration data

Quoted 5 lines
 drivers/base/firmware_class.c          |   45 +++++++++++++-
 drivers/net/wireless/ti/wl1251/Kconfig |    1 +
 drivers/net/wireless/ti/wl1251/main.c  |  104 ++++++++++++++++++++++++++------
 include/linux/firmware.h               |    9 +++
 4 files changed, 138 insertions(+), 21 deletions(-)

Hi! Are there any comments for first 4 patches? If not, could they be accepted and merged?

Quoted 8 lines
Quoted 3 lines

Since the first 4 patches do not touch the firmware API they seem fine to me so long as the maintainer accepts them. Maybe resend and clarify you have dropped the other ones and amend with the new tags.

According to get_maintainer.pl, Kalle Valo is maintainer.

Kalle Valo, if you do not have any other comments, can you accept first 4 patches? Or do you really need to resent first 4 patches again?

The first 4 patches are now in my queue, I should get to them in the next few days.

Signature · 1 line
Kalle Valo
#53 lore raw

Re: [v2,1/6] wl1251: Update wl->nvs_len after wl->nvs is valid

In reply to Pali Rohár
Quoted 4 lines · Pali Rohár

If kmemdup fails, then wl->nvs_len will contain invalid non-zero size.

4 patches applied to wireless-drivers-next.git, thanks.

f63b4c971f5f wl1251: Update wl->nvs_len after wl->nvs is valid 562da3a39cb7 wl1251: Generate random MAC address only if driver does not have valid 4f507d588d08 wl1251: Parse and use MAC address from supplied NVS data 3142467fc15b wl1251: Set generated MAC address back to NVS data

Signature · 3 lines
https://patchwork.kernel.org/patch/10052101/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#54 lore raw

Re: [v2,1/6] wl1251: Update wl->nvs_len after wl->nvs is valid

In reply to Pali Rohár
Quoted 4 lines · Pali Rohár

If kmemdup fails, then wl->nvs_len will contain invalid non-zero size.

4 patches applied to wireless-drivers-next.git, thanks.

f63b4c971f5f wl1251: Update wl->nvs_len after wl->nvs is valid 562da3a39cb7 wl1251: Generate random MAC address only if driver does not have valid 4f507d588d08 wl1251: Parse and use MAC address from supplied NVS data 3142467fc15b wl1251: Set generated MAC address back to NVS data

Signature · 3 lines
https://patchwork.kernel.org/patch/10052101/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches