From: Marc Kleine-Budde <mkl@pengutronix.de>
To: sha@pengutronix.de
Cc: barebox@lists.infradead.org
Subject: [PATCH v2 5/6] USB gadget fsl: request cacheline aligned buffer
Date: Wed, 20 Jun 2012 13:57:34 +0200 [thread overview]
Message-ID: <1340193455-2229-6-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1340193455-2229-1-git-send-email-mkl@pengutronix.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
The fsl udc driver allocates a buffer for small requests. The
driver then calls dma_inv_range later on it. This buffer happens
to be not cacheline aligned which means that a dma_inv_range can
corrupt other memory around the buffer.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[mkl: use dma_alloc]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/usb/gadget/fsl_udc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index 5b64ec2..627e417 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -1,5 +1,6 @@
#include <common.h>
#include <errno.h>
+#include <dma.h>
#include <init.h>
#include <clock.h>
#include <usb/ch9.h>
@@ -8,7 +9,6 @@
#include <io.h>
#include <poller.h>
#include <asm/byteorder.h>
-#include <asm/mmu.h>
/* ### define USB registers here
*/
@@ -2109,7 +2109,8 @@ static int struct_udc_setup(struct fsl_udc *udc,
udc->status_req = container_of(fsl_alloc_request(NULL),
struct fsl_req, req);
/* allocate a small amount of memory to get valid address */
- udc->status_req->req.buf = xmalloc(8);
+ udc->status_req->req.buf = dma_alloc(8);
+ udc->status_req->req.length = 8;
udc->resume_state = USB_STATE_NOTATTACHED;
udc->usb_state = USB_STATE_POWERED;
udc->ep0_dir = 0;
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-06-20 11:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-20 11:57 [PATCH v2 0/6] fix dma memory allocations, add dma_alloc/dma_free Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 1/6] ARM mmu: don't use CONFIG_MMU to disable mmu code, there are static inline versions Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 2/6] blackfin, mips, openrisc, ppc, sandbox, x86: add generic dma_alloc, dma_free inlines Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 3/6] nios: add dma_alloc, asm/dma.h Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 4/6] ARM mmu: add dma_alloc Marc Kleine-Budde
2012-06-20 11:57 ` Marc Kleine-Budde [this message]
2012-06-20 11:57 ` [PATCH v2 6/6] USB gadget: Fix dma memory allocations Marc Kleine-Budde
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=1340193455-2229-6-git-send-email-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=sha@pengutronix.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