From patchwork Tue Feb 14 13:25:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gianluca Gennari X-Patchwork-Id: 9878 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1RxIPi-0002w6-CY for patchwork@linuxtv.org; Tue, 14 Feb 2012 14:27:22 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-3) with esmtp for id 1RxIPh-0000Ou-FY; Tue, 14 Feb 2012 14:27:22 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760176Ab2BNN1S (ORCPT ); Tue, 14 Feb 2012 08:27:18 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:37048 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754384Ab2BNN1S (ORCPT ); Tue, 14 Feb 2012 08:27:18 -0500 Received: by eaah12 with SMTP id h12so2165716eaa.19 for ; Tue, 14 Feb 2012 05:27:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=z94g+m7ZiVqzWEfbwjm+Rp6R4NeqBCw1bN/zeDHEAUE=; b=VFVFXlPqGZL/JoLfRNojjhjJj6LfMGWmNLt46I0HtvJNoeeMBC9+FN/x/VQ8lM3BWX WxQMeR1WOHPfZeCDoUNfh0tVGVmQAp9PLTy831EJXLuSRwoWERlT+cg8/BAChSh+xtCN mSLlLyWG6UIeaNMD9HFoanH2bJLXClbXLUTgw= Received: by 10.14.28.134 with SMTP id g6mr6811088eea.15.1329226036572; Tue, 14 Feb 2012 05:27:16 -0800 (PST) Received: from localhost.localdomain (93-50-34-119.ip150.fastwebnet.it. [93.50.34.119]) by mx.google.com with ESMTPS id y12sm73231472eeb.11.2012.02.14.05.27.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Feb 2012 05:27:15 -0800 (PST) From: Gianluca Gennari To: linux-media@vger.kernel.org, mchehab@redhat.com Cc: dheitmueller@kernellabs.com, snjw23@gmail.com, Gianluca Gennari Subject: [PATCH] as102: map URB DMA addresses in the driver Date: Tue, 14 Feb 2012 14:25:00 +0100 Message-Id: <1329225900-20890-1-git-send-email-gennarone@gmail.com> X-Mailer: git-send-email 1.7.5.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.2.14.131525 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' FORGED_FROM_GMAIL 0.1, MULTIPLE_RCPTS 0.1, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' On a set-top-box based on the Broadcom 7405 SoC (MIPS), the Abilis as102 driver causes a kernel oops while trying to map the URB stream buffers DMA addresses: CPU 0 Unable to handle kernel paging request at virtual address 007b9900, epc == 80010cc4, ra == 8039d108 Call Trace: [<80010cc4>] mips_dma_map_page+0x14/0x108 [<8039d108>] usb_hcd_map_urb_for_dma+0x338/0x4a8 [<8039d540>] usb_hcd_submit_urb+0x2c8/0x8cc [] as102_submit_urb_stream+0x64/0xc8 [dvb_as102] [] as102_usb_start_stream+0x44/0x80 [dvb_as102] [] as102_dvb_dmx_start_feed+0xb4/0x17c [dvb_as102] [<803e20f4>] dmx_ts_feed_start_filtering+0x5c/0x134 [<803de454>] dvb_dmxdev_start_feed+0xd4/0x158 [<803dff28>] dvb_dmxdev_filter_start+0x2b8/0x448 [<803e07ac>] dvb_demux_do_ioctl+0x2a0/0x654 [<803ddc8c>] dvb_usercopy+0x124/0x204 [<800d5284>] do_vfs_ioctl+0xa0/0x6c0 [<800d58e8>] sys_ioctl+0x44/0xa8 [<8000ecfc>] stack_done+0x20/0x40 On other boxes based on older SoCs (7401) this doesn't happen, so it looks like a bug in the kernel specific to MIPS SMP. This issue has been reproduced on several kernel versions from 2.6.18 to 3.1.0. Since the base DMA address and the offsets are known, it is possible to map the DMA addresses of the URB buffers directly in the driver. This workaround fixes the problem and has been tested on both MIPS and x86 CPUs with success. By the way, with this fix the driver works perfectly fine on the set-top-box: both UHF and VHF frequencies are tuned without problems, and zapping is quite fast. SNR and signal strength reports seems to work fine, too. The only remaining problem (on both the PC and the set-top-box) is that after a soft reboot the device is not recognized again by the kernel. It requires a power cycle (or a manual unplug/replug) to be recognized again. So probably the device state is not reset properly at shut-down. Signed-off-by: Gianluca Gennari --- drivers/staging/media/as102/as102_drv.c b/drivers/staging/media/as102/as102_usb_drv.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/staging/media/as102/as102_drv.c b/drivers/staging/media/as102/as102_usb_drv.c index d775be0..8d2c84c 100644 --- a/drivers/staging/media/as102/as102_usb_drv.c +++ b/drivers/staging/media/as102/as102_usb_drv.c @@ -270,6 +270,8 @@ static int as102_alloc_usb_stream_buffer(struct as102_dev_t *dev) } urb->transfer_buffer = dev->stream + (i * AS102_USB_BUF_SIZE); + urb->transfer_dma = dev->dma_addr + (i * AS102_USB_BUF_SIZE); + urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; urb->transfer_buffer_length = AS102_USB_BUF_SIZE; dev->stream_urb[i] = urb;