From patchwork Tue Feb 7 08:39:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: yao mark X-Patchwork-Id: 9559499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2801F60236 for ; Tue, 7 Feb 2017 08:39:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 185A8280FC for ; Tue, 7 Feb 2017 08:39:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D62E2818B; Tue, 7 Feb 2017 08:39:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00 autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AB849280FC for ; Tue, 7 Feb 2017 08:39:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cb1JU-0008N3-5O; Tue, 07 Feb 2017 08:39:48 +0000 Received: from regular1.263xmail.com ([211.150.99.139]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cb1JJ-0008Ay-Nj; Tue, 07 Feb 2017 08:39:41 +0000 Received: from mark.yao?rock-chips.com (unknown [192.168.167.204]) by regular1.263xmail.com (Postfix) with ESMTP id 4C0CC5787; Tue, 7 Feb 2017 16:39:12 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from yaozq-pc.lan (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id E6A2C3B2; Tue, 7 Feb 2017 16:39:11 +0800 (CST) X-RL-SENDER: mark.yao@rock-chips.com X-FST-TO: airlied@linux.ie X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: mark.yao@rock-chips.com X-UNIQUE-TAG: <68efd8aff29296bd282b7386b64c3a43> X-ATTACHMENT-NUM: 0 X-SENDER: yzq@rock-chips.com X-DNS-TYPE: 0 Received: from yaozq-pc.lan (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 8623BHGDZV; Tue, 07 Feb 2017 16:39:13 +0800 (CST) From: Mark Yao To: David Airlie , Heiko Stuebner , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] drm/rockchip: Respect page offset in IOMMU mmap Date: Tue, 7 Feb 2017 16:39:09 +0800 Message-Id: <1486456749-19142-1-git-send-email-mark.yao@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486456542-18675-1-git-send-email-mark.yao@rock-chips.com> References: <1486456542-18675-1-git-send-email-mark.yao@rock-chips.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170207_003940_153111_B6D72553 X-CRM114-Status: UNSURE ( 9.74 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?=C3=98rjan=20Eide?= , Mark Yao , Tomasz Figa Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ørjan Eide When mapping buffers through the PRIME DMA-buf mmap path we might be given an offset which has to be respected. The DRM GEM mmap path already takes care of zeroing out the fake mmap offset, so we can just make the IOMMU mmap implementation always respect the offset. TEST=graphics_GLBench Signed-off-by: rjan Eide Signed-off-by: Tomasz Figa Signed-off-by: Mark Yao Reviewed-on: https://chromium-review.googlesource.com/386477 Reviewed-by: Daniel Kurtz --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 1daa531..1769146 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -221,12 +221,16 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj, unsigned int i, count = obj->size >> PAGE_SHIFT; unsigned long user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; unsigned long uaddr = vma->vm_start; + unsigned long offset = vma->vm_pgoff; + unsigned long end = user_count + offset; int ret; - if (user_count == 0 || user_count > count) + if (user_count == 0) + return -ENXIO; + if (end > count) return -ENXIO; - for (i = 0; i < user_count; i++) { + for (i = offset; i < end; i++) { ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]); if (ret) return ret;