2015-10-16 05:11:13

by Brent Taylor

[permalink] [raw]
Subject: [PATCH] ath6kl: Use vmalloc for loading firmware using api1 method

Signed-off-by: Brent Taylor <[email protected]>
---
drivers/net/wireless/ath/ath6kl/init.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 6e473fa..2155739 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -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



2015-11-29 05:51:33

by Brent Taylor

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

Signed-off-by: Brent Taylor <[email protected]>

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(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c
index 4ec02ce..052e58b 100644
--- a/drivers/net/wireless/ath/ath6kl/core.c
+++ b/drivers/net/wireless/ath/ath6kl/core.c
@@ -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);

diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 6e473fa..19535dc 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -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);

--
2.6.3


2015-11-29 02:57:22

by Tetsuo Handa

[permalink] [raw]
Subject: Re: [PATCH] ath6kl: Use vmalloc for loading firmware using api1 method

Andy Shevchenko wrote:
> On Sat, Nov 28, 2015 at 8:58 PM, Brent Taylor <[email protected]> wrote:
> > 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);

2015-11-29 05:28:25

by kernel test robot

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

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


Attachments:
(No filename) (1.60 kB)
.config.gz (23.28 kB)
Download all attachments

2015-11-28 18:58:31

by Brent Taylor

[permalink] [raw]
Subject: Re: [PATCH] ath6kl: Use vmalloc for loading firmware using api1 method

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

On Fri, Oct 16, 2015 at 12:10 AM, Brent Taylor <[email protected]> wrote:
> Signed-off-by: Brent Taylor <[email protected]>
> ---
> drivers/net/wireless/ath/ath6kl/init.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
> index 6e473fa..2155739 100644
> --- a/drivers/net/wireless/ath/ath6kl/init.c
> +++ b/drivers/net/wireless/ath/ath6kl/init.c
> @@ -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
>

2015-11-30 08:48:20

by Kalle Valo

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

Brent Taylor <[email protected]> writes:

> Signed-off-by: Brent Taylor <[email protected]>
>
> 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.

--
Kalle Valo

2015-11-29 00:53:34

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] ath6kl: Use vmalloc for loading firmware using api1 method

On Sat, Nov 28, 2015 at 8:58 PM, Brent Taylor <[email protected]> wrote:
> 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.

> Thanks,
> Brent
>
> On Fri, Oct 16, 2015 at 12:10 AM, Brent Taylor <[email protected]> wrote:
>> Signed-off-by: Brent Taylor <[email protected]>
>> ---
>> drivers/net/wireless/ath/ath6kl/init.c | 15 +++++++++++----
>> 1 file changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
>> index 6e473fa..2155739 100644
>> --- a/drivers/net/wireless/ath/ath6kl/init.c
>> +++ b/drivers/net/wireless/ath/ath6kl/init.c
>> @@ -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
>>
> --
> 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/



--
With Best Regards,
Andy Shevchenko

2015-11-30 08:49:11

by Kalle Valo

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

Brent Taylor <[email protected]> writes:

> Signed-off-by: Brent Taylor <[email protected]>
>
> 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

The commit log in v3 is even worse.

--
Kalle Valo

2015-11-29 05:14:04

by Brent Taylor

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

Signed-off-by: Brent Taylor <[email protected]>

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(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c
index 4ec02ce..052e58b 100644
--- a/drivers/net/wireless/ath/ath6kl/core.c
+++ b/drivers/net/wireless/ath/ath6kl/core.c
@@ -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);

diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 6e473fa..836afea2 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -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);

--
2.6.3


2015-11-30 09:06:06

by Kalle Valo

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

Kalle Valo <[email protected]> writes:

> Brent Taylor <[email protected]> writes:
>
>> Signed-off-by: Brent Taylor <[email protected]>
>>
>> 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.

Fixing netdev address (kenrel -> kernel)

--
Kalle Valo