From patchwork Thu Sep 4 08:34:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fancy Fang X-Patchwork-Id: 4843451 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 E61D69FC44 for ; Thu, 4 Sep 2014 09:38:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7B3D20211 for ; Thu, 4 Sep 2014 09:38:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E31A5201E4 for ; Thu, 4 Sep 2014 09:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751176AbaIDJiE (ORCPT ); Thu, 4 Sep 2014 05:38:04 -0400 Received: from mail-by2lp0244.outbound.protection.outlook.com ([207.46.163.244]:7514 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750902AbaIDJiC (ORCPT ); Thu, 4 Sep 2014 05:38:02 -0400 Received: from BN3PR0301CA0077.namprd03.prod.outlook.com (25.160.152.173) by BL2PR03MB547.namprd03.prod.outlook.com (10.141.90.20) with Microsoft SMTP Server (TLS) id 15.0.1019.16; Thu, 4 Sep 2014 09:37:59 +0000 Received: from BN1AFFO11FD054.protection.gbl (2a01:111:f400:7c10::149) by BN3PR0301CA0077.outlook.office365.com (2a01:111:e400:401e::45) with Microsoft SMTP Server (TLS) id 15.0.1019.16 via Frontend Transport; Thu, 4 Sep 2014 09:37:59 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD054.mail.protection.outlook.com (10.58.53.69) with Microsoft SMTP Server (TLS) id 15.0.1010.11 via Frontend Transport; Thu, 4 Sep 2014 09:37:59 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s849brcl019296; Thu, 4 Sep 2014 02:37:56 -0700 From: Fancy Fang To: , , CC: , , Fancy Fang Subject: [PATCH] [media] videobuf-dma-contig: replace vm_iomap_memory() with remap_pfn_range(). Date: Thu, 4 Sep 2014 16:34:39 +0800 Message-ID: <1409819679-31497-1-git-send-email-chen.fang@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(199003)(189002)(106466001)(4396001)(50226001)(575784001)(74662001)(79102001)(87286001)(105606002)(74502001)(46102001)(86362001)(95666004)(84676001)(62966002)(87936001)(93916002)(107046002)(77982001)(92726001)(47776003)(104166001)(102836001)(50466002)(230783001)(50986999)(85306004)(76482001)(21056001)(48376002)(88136002)(6806004)(229853001)(83322001)(81542001)(2201001)(68736004)(104016003)(85852003)(19580405001)(20776003)(33646002)(64706001)(31966008)(36756003)(26826002)(90102001)(97736001)(89996001)(80022001)(44976005)(92566001)(83072002)(99396002)(81342001)(77156001)(19580395003); DIR:OUT; SFP:; SCL:1; SRVR:BL2PR03MB547; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 0324C2C0E2 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=chen.fang@freescale.com; X-OriginatorOrg: freescale.com Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.5 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 When user requests V4L2_MEMORY_MMAP type buffers, the videobuf-core will assign the corresponding offset to the 'boff' field of the videobuf_buffer for each requested buffer sequentially. Later, user may call mmap() to map one or all of the buffers with the 'offset' parameter which is equal to its 'boff' value. Obviously, the 'offset' value is only used to find the matched buffer instead of to be the real offset from the buffer's physical start address as used by vm_iomap_memory(). So, in some case that if the offset is not zero, vm_iomap_memory() will fail. Signed-off-by: Fancy Fang --- drivers/media/v4l2-core/videobuf-dma-contig.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/videobuf-dma-contig.c b/drivers/media/v4l2-core/videobuf-dma-contig.c index bf80f0f..8bd9889 100644 --- a/drivers/media/v4l2-core/videobuf-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf-dma-contig.c @@ -305,7 +305,9 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, /* Try to remap memory */ size = vma->vm_end - vma->vm_start; vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - retval = vm_iomap_memory(vma, mem->dma_handle, size); + retval = remap_pfn_range(vma, vma->vm_start, + mem->dma_handle >> PAGE_SHIFT, + size, vma->vm_page_prot); if (retval) { dev_err(q->dev, "mmap: remap failed with error %d. ", retval);