From patchwork Sat Jan 4 10:55:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 3433441 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EC9CC9F2E9 for ; Sat, 4 Jan 2014 13:59:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1979C20136 for ; Sat, 4 Jan 2014 13:59:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CAF220134 for ; Sat, 4 Jan 2014 13:59:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754202AbaADN7i (ORCPT ); Sat, 4 Jan 2014 08:59:38 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:43683 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753226AbaADN7R (ORCPT ); Sat, 4 Jan 2014 08:59:17 -0500 Received: from [177.143.150.208] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1VzRkw-00013m-KJ; Sat, 04 Jan 2014 13:59:15 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1VzOtV-0003kx-OR; Sat, 04 Jan 2014 08:55:53 -0200 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH v4 20/22] [media] em28xx: use usb_alloc_coherent() for audio Date: Sat, 4 Jan 2014 08:55:49 -0200 Message-Id: <1388832951-11195-21-git-send-email-m.chehab@samsung.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1388832951-11195-1-git-send-email-m.chehab@samsung.com> References: <1388832951-11195-1-git-send-email-m.chehab@samsung.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of allocating transfer buffers with kmalloc() use usb_alloc_coherent(). That makes it work also with arm CPUs. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-audio.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c index a6eef06ffdcd..e5120430ec80 100644 --- a/drivers/media/usb/em28xx/em28xx-audio.c +++ b/drivers/media/usb/em28xx/em28xx-audio.c @@ -64,16 +64,22 @@ static int em28xx_deinit_isoc_audio(struct em28xx *dev) dprintk("Stopping isoc\n"); for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { + struct urb *urb = dev->adev.urb[i]; + if (!irqs_disabled()) - usb_kill_urb(dev->adev.urb[i]); + usb_kill_urb(urb); else - usb_unlink_urb(dev->adev.urb[i]); + usb_unlink_urb(urb); - usb_free_urb(dev->adev.urb[i]); - dev->adev.urb[i] = NULL; + usb_free_coherent(dev->udev, + urb->transfer_buffer_length, + dev->adev.transfer_buffer[i], + urb->transfer_dma); - kfree(dev->adev.transfer_buffer[i]); dev->adev.transfer_buffer[i] = NULL; + + usb_free_urb(urb); + dev->adev.urb[i] = NULL; } return 0; @@ -176,12 +182,8 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { struct urb *urb; int j, k; + void *buf; - dev->adev.transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC); - if (!dev->adev.transfer_buffer[i]) - return -ENOMEM; - - memset(dev->adev.transfer_buffer[i], 0x80, sb_size); urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); if (!urb) { em28xx_errdev("usb_alloc_urb failed!\n"); @@ -192,10 +194,17 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) return -ENOMEM; } + buf = usb_alloc_coherent(dev->udev, sb_size, GFP_ATOMIC, + &urb->transfer_dma); + if (!buf) + return -ENOMEM; + dev->adev.transfer_buffer[i] = buf; + memset(buf, 0x80, sb_size); + urb->dev = dev->udev; urb->context = dev; urb->pipe = usb_rcvisocpipe(dev->udev, EM28XX_EP_AUDIO); - urb->transfer_flags = URB_ISO_ASAP; + urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; urb->transfer_buffer = dev->adev.transfer_buffer[i]; urb->interval = 1; urb->complete = em28xx_audio_isocirq;