Skip to contentSkip to conversation

ath6kl: Use vmalloc for loading firmware using api1 method

PATCH Superseded Brent Taylor 5 participants 11 messages Oct 16, 2015 – Nov 30, 2015

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

PATCH 1/1 ath6kl: Use vmalloc for loading firmware using api1 method

---
 drivers/net/wireless/ath/ath6kl/init.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath6kl/init.c +0 -1
index 6e473fa..2155739 100644
@@ -673,10 +673,17 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
 		return ret;
 
 	*fw_len = fw_entry->size;
-	*fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
#1 lore raw

Sorry, the first e-mail was sent via gmail and I forgot about sending it in plain text mode.

Whats the status on this patch? I don't see it on patchwork anymore nor is it in any of the git trees I checked.

Thanks,
Brent

Quoted 34 lines · Brent Taylor
---
 drivers/net/wireless/ath/ath6kl/init.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath6kl/init.c +11 -5
index 6e473fa..2155739 100644
@@ -673,10 +673,17 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
                return ret;
 
        *fw_len = fw_entry->size;
-       *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
-
-       if (*fw == NULL)
-               ret = -ENOMEM;
+       if (&ar->fw == fw) {
+               *fw = vmalloc(fw_entry->size);
+               if (*fw == NULL)
+                       ret = -ENOMEM;
+               else
+                       memcpy(*fw, fw_entry->data, fw_entry->size);
+       } else {
+               *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
+               if (*fw == NULL)
+                       ret = -ENOMEM;
+       }
 
        release_firmware(fw_entry);
 
--

2.6.1

#2 lore raw
Quoted 6 lines · Brent Taylor

Sorry, the first e-mail was sent via gmail and I forgot about sending it in plain text mode.

Whats the status on this patch? I don't see it on patchwork anymore nor is it in any of the git trees I checked.

You forget to use kvfree() instead of kfree() in core.c.

Quoted 43 lines

Thanks,
Brent

Quoted 32 lines · Brent Taylor
---
 drivers/net/wireless/ath/ath6kl/init.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath6kl/init.c +11 -5
index 6e473fa..2155739 100644
@@ -673,10 +673,17 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
                return ret;
 
        *fw_len = fw_entry->size;
-       *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
-
-       if (*fw == NULL)
-               ret = -ENOMEM;
+       if (&ar->fw == fw) {
+               *fw = vmalloc(fw_entry->size);
+               if (*fw == NULL)
+                       ret = -ENOMEM;
+               else
+                       memcpy(*fw, fw_entry->data, fw_entry->size);
+       } else {
+               *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
+               if (*fw == NULL)
+                       ret = -ENOMEM;
+       }
 
        release_firmware(fw_entry);
 
--
Quoted 2 lines

2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 7 lines · Andy Shevchenko
Quoted 3 lines · Brent Taylor

Whats the status on this patch? I don't see it on patchwork anymore nor is it in any of the git trees I checked.

You forget to use kvfree() instead of kfree() in core.c.

In addition to that, I think you can do like below.

	if (&ar->fw == fw)
		*fw = vmalloc(fw_entry->size);
	else
		*fw = kmalloc(fw_entry->size, GFP_KERNEL);
	if (*fw == NULL)
		ret = -ENOMEM;
	else
		memcpy(*fw, fw_entry->data, fw_entry->size);
#4 lore raw

PATCH v2 1/1 ath6kl: Use vmalloc for loading firmware using api1 method and use kvfree

In reply to Brent Taylor

ath6kl: Use vmalloc for loading firmware using api1 method and free using kvfree
---
Changes v1 -> v2:
- simplify memory allocation
- use kvfree

 drivers/net/wireless/ath/ath6kl/core.c | 2 +-
 drivers/net/wireless/ath/ath6kl/init.c | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/core.c +1 -1
index 4ec02ce..052e58b 100644
@@ -343,7 +343,7 @@ void ath6kl_core_cleanup(struct ath6kl *ar)
 
 	kfree(ar->fw_board);
 	kfree(ar->fw_otp);
-	vfree(ar->fw);
+	kvfree(ar->fw);
 	kfree(ar->fw_patch);
 	kfree(ar->fw_testscript);
 
drivers/net/wireless/ath/ath6kl/init.c +6 -1
index 6e473fa..836afea2 100644
@@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
 		return ret;
 
 	*fw_len = fw_entry->size;
-	*fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
+	if (&ar->fw == fw)
+		*fw = vmalloc(fw_entry->size);
+	else
+		*fw = kmalloc(fw_entry->size);
 
 	if (*fw == NULL)
 		ret = -ENOMEM;
+	else
+		memcpy(*fw, fw_entry->data, fw_entry->size);
 
 	release_firmware(fw_entry);
 
Signature · 1 line
2.6.3
#5 lore raw

Re: [PATCH v2] ath6kl: Use vmalloc for loading firmware using api1 method and use kvfree

reproduce:

Hi Brent,

[auto build test ERROR on: net-next/master] [also build test ERROR on: v4.4-rc2 next-20151127]

url:    https://github.com/0day-ci/linux/commits/Brent-Taylor/ath6kl-Use-vmalloc-for-loading-firmware-using-api1-method-and-use-kvfree/20151129-132013
config: x86_64-randconfig-x012-201548 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/net/wireless/ath/ath6kl/init.c: In function 'ath6kl_get_fw':

>> drivers/net/wireless/ath/ath6kl/init.c:679:9: error: too few arguments to function 'kmalloc'
      *fw = kmalloc(fw_entry->size);
            ^

In file included from include/linux/textsearch.h:8:0,
from include/linux/skbuff.h:30,
from include/linux/if_ether.h:23, from include/linux/etherdevice.h:25, from drivers/net/wireless/ath/ath6kl/core.h:21, from drivers/net/wireless/ath/ath6kl/init.c:28:
include/linux/slab.h:428:30: note: declared here
static __always_inline void *kmalloc(size_t size, gfp_t flags)
^

vim +/kmalloc +679 drivers/net/wireless/ath/ath6kl/init.c

673 return ret;
674
675 *fw_len = fw_entry->size;
676 if (&ar->fw == fw)
677 *fw = vmalloc(fw_entry->size);
678 else

 > 679			*fw = kmalloc(fw_entry->size);

680
681 if (*fw == NULL)
682 ret = -ENOMEM;

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#6 lore raw

PATCH v3 1/1 ath6kl: Use vmalloc for loading firmware using api1 method and use kvfree

In reply to Brent Taylor

ath6kl: Use vmalloc for loading firmware using api1 method and free using kvfree

ath6kl: fix kmalloc build error
---
Changes v2 -> v3:
- fix kmalloc build error

Changes v1 -> v2:
- simplify memory allocation
- use kvfree

 drivers/net/wireless/ath/ath6kl/core.c | 2 +-
 drivers/net/wireless/ath/ath6kl/init.c | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/core.c +1 -1
index 4ec02ce..052e58b 100644
@@ -343,7 +343,7 @@ void ath6kl_core_cleanup(struct ath6kl *ar)
 
 	kfree(ar->fw_board);
 	kfree(ar->fw_otp);
-	vfree(ar->fw);
+	kvfree(ar->fw);
 	kfree(ar->fw_patch);
 	kfree(ar->fw_testscript);
 
drivers/net/wireless/ath/ath6kl/init.c +6 -1
index 6e473fa..19535dc 100644
@@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
 		return ret;
 
 	*fw_len = fw_entry->size;
-	*fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
+	if (&ar->fw == fw)
+		*fw = vmalloc(fw_entry->size);
+	else
+		*fw = kmalloc(fw_entry->size, GFP_KERNEL);
 
 	if (*fw == NULL)
 		ret = -ENOMEM;
+	else
+		memcpy(*fw, fw_entry->data, fw_entry->size);
 
 	release_firmware(fw_entry);
 
Signature · 6 lines
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw

Re: [PATCH v3] ath6kl: Use vmalloc for loading firmware using api1 method and use kvfree

Quoted 4 lines · Brent Taylor

ath6kl: Use vmalloc for loading firmware using api1 method and free using kvfree

Quoted 8 lines

ath6kl: fix kmalloc build error
---
Changes v2 -> v3:
- fix kmalloc build error

Changes v1 -> v2:
- simplify memory allocation
- use kvfree

The commit log in v3 is even worse.

Signature · 1 line
Kalle Valo
#8 lore raw

Re: [PATCH v2] ath6kl: Use vmalloc for loading firmware using api1 method and use kvfree

In reply to Brent Taylor
Quoted 7 lines · Brent Taylor

ath6kl: Use vmalloc for loading firmware using api1 method and free using kvfree
---
Changes v1 -> v2:
- simplify memory allocation
- use kvfree

Why? The commit log should _always_ answer that. Are you fixing a bug (what bug exactly?), is this just cleanup or what?

And the commit log is wrongly formatted anyway, the Signed-off-by line should be the last and there should be no "ath6kl:" string in the commit log (just in the title). Use 'git log' to find examples.

Signature · 1 line
Kalle Valo
#9 lore raw

Re: [PATCH v2] ath6kl: Use vmalloc for loading firmware using api1 method and use kvfree

Quoted 10 lines · Kalle Valo
Quoted 7 lines · Brent Taylor

ath6kl: Use vmalloc for loading firmware using api1 method and free using kvfree
---
Changes v1 -> v2:
- simplify memory allocation
- use kvfree

Quoted 6 lines

Why? The commit log should _always_ answer that. Are you fixing a bug (what bug exactly?), is this just cleanup or what?

And the commit log is wrongly formatted anyway, the Signed-off-by line should be the last and there should be no "ath6kl:" string in the commit log (just in the title). Use 'git log' to find examples.

Fixing netdev address (kenrel -> kernel)

Signature · 1 line
Kalle Valo
#10 lore raw

PATCH v2 1/1 ath6kl: Use vmalloc for loading firmware using api1 method and use kvfree

In reply to Brent Taylor

ath6kl: Use vmalloc for loading firmware using api1 method and free using kvfree
---
Changes v1 -> v2:
- simplify memory allocation
- use kvfree

 drivers/net/wireless/ath/ath6kl/core.c | 2 +-
 drivers/net/wireless/ath/ath6kl/init.c | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/core.c +1 -1
index 4ec02ce..052e58b 100644
@@ -343,7 +343,7 @@ void ath6kl_core_cleanup(struct ath6kl *ar)
 
 	kfree(ar->fw_board);
 	kfree(ar->fw_otp);
-	vfree(ar->fw);
+	kvfree(ar->fw);
 	kfree(ar->fw_patch);
 	kfree(ar->fw_testscript);
 
drivers/net/wireless/ath/ath6kl/init.c +6 -1
index 6e473fa..836afea2 100644
@@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
 		return ret;
 
 	*fw_len = fw_entry->size;
-	*fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
+	if (&ar->fw == fw)
+		*fw = vmalloc(fw_entry->size);
+	else
+		*fw = kmalloc(fw_entry->size);
 
 	if (*fw == NULL)
 		ret = -ENOMEM;
+	else
+		memcpy(*fw, fw_entry->data, fw_entry->size);
 
 	release_firmware(fw_entry);
 
Signature · 1 line
2.6.3