From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/6] usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment
Date: Thu, 06 Feb 2014 07:33:07 +0100 [thread overview]
Message-ID: <20140206073307.633ae6b9@amdc2363> (raw)
In-Reply-To: <201402060220.17449.marex@denx.de>
Hi Marek,
> On Wednesday, February 05, 2014 at 10:10:41 AM, Lukasz Majewski wrote:
> > Calls to malloc() have been replaced by memalign. It now provides
> > proper buffer alignment.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Cc: Marek Vasut <marex@denx.de>
> >
> > ---
> > Changes for v2:
> > - Remove Change-Id.
> > ---
> > 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);
>
> I wonder, does this align the begining of the buffer as well or only
> the size? Can we rely on the fact the begining is also
> cacheline-aligned ?
In this case, the memalign assures, that beginning of the buffer is
aligned to a cache line.
It is the programmer's responsibility to either have "bytes" aligned to
cache line size or use a wrapper like DEFINE_CACHE_ALIGN_BUFFER().
>
> > if (!mem)
> > return NULL;
>
> Best regards,
> Marek Vasut
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
next prev parent reply other threads:[~2014-02-06 6:33 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-31 12:16 [U-Boot] [PATCH 0/6] usb:samsung: Exynos4 SoC USB code improvements Lukasz Majewski
2014-01-31 12:16 ` [U-Boot] [PATCH 1/6] usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment Lukasz Majewski
2014-02-01 2:48 ` Marek Vasut
2014-02-01 9:10 ` Lukasz Majewski
2014-01-31 12:16 ` [U-Boot] [PATCH 2/6] usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver Lukasz Majewski
2014-02-01 2:50 ` Marek Vasut
2014-02-01 9:56 ` Lukasz Majewski
2014-02-01 22:49 ` Marek Vasut
2014-02-03 8:05 ` Lukasz Majewski
2014-02-03 18:06 ` Marek Vasut
2014-02-04 6:23 ` Lukasz Majewski
2014-01-31 12:16 ` [U-Boot] [PATCH 3/6] usb:udc:samsung: Allow burst transfers for non EP0 endpints Lukasz Majewski
2014-01-31 12:16 ` [U-Boot] [PATCH 4/6] usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver Lukasz Majewski
2014-02-01 2:55 ` Marek Vasut
2014-02-01 11:05 ` Lukasz Majewski
2014-02-01 22:55 ` Marek Vasut
2014-02-03 11:06 ` Lukasz Majewski
2014-02-03 18:11 ` Marek Vasut
2014-02-04 7:29 ` Lukasz Majewski
2014-02-04 20:21 ` Marek Vasut
2014-02-04 21:49 ` Lukasz Majewski
2014-02-05 2:35 ` Marek Vasut
2014-01-31 12:16 ` [U-Boot] [PATCH 5/6] usb:gadget:f_thor: Allocate request up to THOR_PACKET_SIZE not ep->maxpacket Lukasz Majewski
2014-01-31 12:16 ` [U-Boot] [PATCH 6/6] usb:gadget:f_thor: cosmetic: Remove debug memset Lukasz Majewski
2014-02-05 9:10 ` [U-Boot] [PATCH v2 0/6] usb:samsung: Exynos4 SoC USB code improvements Lukasz Majewski
2014-02-05 9:10 ` [U-Boot] [PATCH v2 1/6] usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment Lukasz Majewski
2014-02-06 1:20 ` Marek Vasut
2014-02-06 6:33 ` Lukasz Majewski [this message]
2014-02-06 6:41 ` Marek Vasut
2014-02-06 8:16 ` Lukasz Majewski
2014-02-05 9:10 ` [U-Boot] [PATCH v2 2/6] usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver Lukasz Majewski
2014-02-05 9:10 ` [U-Boot] [PATCH v2 3/6] usb:udc:samsung: Allow burst transfers for non EP0 endpints Lukasz Majewski
2014-02-05 9:10 ` [U-Boot] [PATCH v2 4/6] usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver Lukasz Majewski
2014-02-05 9:10 ` [U-Boot] [PATCH v2 5/6] usb:gadget:f_thor: Allocate request up to THOR_PACKET_SIZE not ep->maxpacket Lukasz Majewski
2014-02-05 9:10 ` [U-Boot] [PATCH v2 6/6] usb:gadget:f_thor: cosmetic: Remove debug memset Lukasz Majewski
2014-02-06 1:24 ` [U-Boot] [PATCH v2 0/6] usb:samsung: Exynos4 SoC USB code improvements Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140206073307.633ae6b9@amdc2363 \
--to=l.majewski@samsung.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox