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: 9559493 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 356B160236 for ; Tue, 7 Feb 2017 08:39:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26077280FC for ; Tue, 7 Feb 2017 08:39:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 185F82818B; Tue, 7 Feb 2017 08:39:19 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A6528280FC for ; Tue, 7 Feb 2017 08:39:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E52926E60D; Tue, 7 Feb 2017 08:39:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id 532296E60D for ; Tue, 7 Feb 2017 08:39:16 +0000 (UTC) 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 Cc: =?UTF-8?q?=C3=98rjan=20Eide?= , Tomasz Figa X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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;