From patchwork Tue Oct 23 21:37:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Martin X-Patchwork-Id: 193578 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 8D93E2C00A6 for ; Wed, 24 Oct 2012 08:38:20 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BC95D4A114; Tue, 23 Oct 2012 23:38:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VqjxbRRRzxE6; Tue, 23 Oct 2012 23:38:16 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 096604A186; Tue, 23 Oct 2012 23:38:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6EF244A186 for ; Tue, 23 Oct 2012 23:38:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wgQRApS4XjXl for ; Tue, 23 Oct 2012 23:38:07 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from hqemgate04.nvidia.com (hqemgate04.nvidia.com [216.228.121.35]) by theia.denx.de (Postfix) with ESMTPS id 8B2D44A114 for ; Tue, 23 Oct 2012 23:38:04 +0200 (CEST) Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Tue, 23 Oct 2012 14:37:28 -0700 Received: from hqemhub02.nvidia.com ([172.17.108.22]) by hqnvupgp07.nvidia.com (PGP Universal service); Tue, 23 Oct 2012 14:25:55 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Tue, 23 Oct 2012 14:25:55 -0700 Received: from badger.nvidia.com (172.20.144.16) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server id 8.3.279.1; Tue, 23 Oct 2012 14:37:59 -0700 From: Allen Martin To: , , Date: Tue, 23 Oct 2012 14:37:52 -0700 Message-ID: <1351028274-30301-1-git-send-email-amartin@nvidia.com> X-Mailer: git-send-email 1.7.10.4 X-NVConfidentiality: public MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 1/3] USB: make usb_kbd obey USB DMA alignment requirements X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Change usb_kbd driver to obey alignment requirements for USB DMA on the buffer used for data transfer. This is necessary for architectures that enable dcache and enable USB DMA. Signed-off-by: Allen Martin Tested-by: Stephen Warren --- v3: add comment about alignemnt requirement v2: use memalign instead of __align() --- common/usb_kbd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 19f01db..be5e8bc 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -105,16 +105,20 @@ static const unsigned char usb_kbd_num_keypad[] = { #define USB_KBD_LEDMASK \ (USB_KBD_NUMLOCK | USB_KBD_CAPSLOCK | USB_KBD_SCROLLLOCK) +/* + * This structure must be aligned to USB_DMA_MINALIGN to allow DMA to + * buffer "new" below. + */ struct usb_kbd_pdata { + uint8_t new[8]; + uint8_t old[8]; + uint32_t repeat_delay; uint32_t usb_in_pointer; uint32_t usb_out_pointer; uint8_t usb_kbd_buffer[USB_KBD_BUFFER_LEN]; - uint8_t new[8]; - uint8_t old[8]; - uint8_t flags; }; @@ -426,7 +430,7 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum) USB_KBD_PRINTF("USB KBD: found set protocol...\n"); - data = malloc(sizeof(struct usb_kbd_pdata)); + data = memalign(USB_DMA_MINALIGN, sizeof(struct usb_kbd_pdata)); if (!data) { printf("USB KBD: Error allocating private data\n"); return 0;