diff mbox

[U-Boot,1/6] usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment

Message ID 1391170589-14340-2-git-send-email-l.majewski@samsung.com
State Superseded
Headers show

Commit Message

Ɓukasz Majewski Jan. 31, 2014, 12:16 p.m. UTC
Calls to malloc() have been replaced by memalign. It provides proper
buffer alignment.

Change-Id: Iffcf42082a125f848124bc84d1a95353493798a4
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Cc: Marek Vasut <marex@denx.de>
---
 drivers/usb/gadget/f_mass_storage.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Marek Vasut Feb. 1, 2014, 2:48 a.m. UTC | #1
On Friday, January 31, 2014 at 01:16:24 PM, Lukasz Majewski wrote:
> Calls to malloc() have been replaced by memalign. It provides proper
> buffer alignment.
> 
> Change-Id: Iffcf42082a125f848124bc84d1a95353493798a4

^ Where does this Change-Id come from ?

> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
> ---
>  drivers/usb/gadget/f_mass_storage.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/f_mass_storage.c
> b/drivers/usb/gadget/f_mass_storage.c index b1fe8bd..f896169 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct
> fsg_common *common, buffhds_first_it:
>  		bh->inreq_busy = 0;
>  		bh->outreq_busy = 0;
> -		bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
> +		bh->buf = memalign(CONFIG_SYS_CACHELINE_SIZE, FSG_BUFLEN);
>  		if (unlikely(!bh->buf)) {
>  			rc = -ENOMEM;
>  			goto error_release;
> @@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header
> **src) bytes += (*tmp)->bLength;
>  	bytes += (n_desc + 1) * sizeof(*tmp);
> 
> -	mem = kmalloc(bytes, GFP_KERNEL);
> +	mem = memalign(CONFIG_SYS_CACHELINE_SIZE, bytes);
>  	if (!mem)
>  		return NULL;

Best regards,
Marek Vasut
Lukasz Majewski Feb. 1, 2014, 9:10 a.m. UTC | #2
On Sat, 1 Feb 2014 03:48:57 +0100
Marek Vasut <marex@denx.de> wrote:
Hi Marek,

> On Friday, January 31, 2014 at 01:16:24 PM, Lukasz Majewski wrote:
> > Calls to malloc() have been replaced by memalign. It provides proper
> > buffer alignment.
> > 
> > Change-Id: Iffcf42082a125f848124bc84d1a95353493798a4
> 
> ^ Where does this Change-Id come from ?

This comes from our internal Gerrit. By my mistake I've forgotten to
remove it from a commit.

I will remove it from the commit in the next patch version.

> 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Cc: Marek Vasut <marex@denx.de>
> > ---
> >  drivers/usb/gadget/f_mass_storage.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/f_mass_storage.c
> > b/drivers/usb/gadget/f_mass_storage.c index b1fe8bd..f896169 100644
> > --- a/drivers/usb/gadget/f_mass_storage.c
> > +++ b/drivers/usb/gadget/f_mass_storage.c
> > @@ -2515,7 +2515,7 @@ static struct fsg_common
> > *fsg_common_init(struct fsg_common *common, buffhds_first_it:
> >  		bh->inreq_busy = 0;
> >  		bh->outreq_busy = 0;
> > -		bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
> > +		bh->buf = memalign(CONFIG_SYS_CACHELINE_SIZE,
> > FSG_BUFLEN); if (unlikely(!bh->buf)) {
> >  			rc = -ENOMEM;
> >  			goto error_release;
> > @@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct
> > usb_descriptor_header **src) bytes += (*tmp)->bLength;
> >  	bytes += (n_desc + 1) * sizeof(*tmp);
> > 
> > -	mem = kmalloc(bytes, GFP_KERNEL);
> > +	mem = memalign(CONFIG_SYS_CACHELINE_SIZE, bytes);
> >  	if (!mem)
> >  		return NULL;
> 
> Best regards,
> Marek Vasut
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

Best regards,
Lukasz Majewski
diff mbox

Patch

diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index b1fe8bd..f896169 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2515,7 +2515,7 @@  static struct fsg_common *fsg_common_init(struct fsg_common *common,
 buffhds_first_it:
 		bh->inreq_busy = 0;
 		bh->outreq_busy = 0;
-		bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
+		bh->buf = memalign(CONFIG_SYS_CACHELINE_SIZE, FSG_BUFLEN);
 		if (unlikely(!bh->buf)) {
 			rc = -ENOMEM;
 			goto error_release;
@@ -2622,7 +2622,7 @@  usb_copy_descriptors(struct usb_descriptor_header **src)
 		bytes += (*tmp)->bLength;
 	bytes += (n_desc + 1) * sizeof(*tmp);
 
-	mem = kmalloc(bytes, GFP_KERNEL);
+	mem = memalign(CONFIG_SYS_CACHELINE_SIZE, bytes);
 	if (!mem)
 		return NULL;