From patchwork Fri Mar 10 04:32:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9614617 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 3F41A60414 for ; Fri, 10 Mar 2017 04:35:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31B6B285A9 for ; Fri, 10 Mar 2017 04:35:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26667286EF; Fri, 10 Mar 2017 04:35:46 +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,DKIM_SIGNED, DKIM_VALID autolearn=ham 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 9B023285A9 for ; Fri, 10 Mar 2017 04:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=m2i/SB4bStjCGrpls+mYCkJObgLpTe08T/syC7B+Rg4=; b=mR47NX9pwKsJQS kJSbIE2iumdRurFXR7iOaOuImIIV/EJ9Q8UHICWBj7uEyZ2wU4syAmZZjnbpYVPLHyDIgA9ut9klh DmjFrWJaS/J5GiirCftQ1dImHeQd2hgoQvLVYmIMnrsbCpvvdEtstboFJ69PU3v6HTyfYgfwxqjlA DFTu5IG45Yur0iTeA+40+V2hssR9ldIi6ZceqeDp+CPBfK/+hkfmpjZjeqSGG2lBXz/2lGLUbGcI7 4rC5CFUgYUhAgnaKD+cMLkfxU8CiUF9Hu7fZqiBCr2a3vx4NsMPbZpGFyNUKW+BqoDfLhSpaEyG4/ lQCDSgDs5VKq+iW1AThA==; 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 1cmCHI-0000bK-JB; Fri, 10 Mar 2017 04:35:44 +0000 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cmCGD-0006l7-9n for linux-arm-kernel@lists.infradead.org; Fri, 10 Mar 2017 04:34:39 +0000 Received: by mail-qk0-x22c.google.com with SMTP id v125so148863860qkh.2 for ; Thu, 09 Mar 2017 20:34:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z+EcOP9zGquBqjWH6ncVgYuYcuhA+kqx21sEB6Rn3hM=; b=KsHapxG5H+vS2/MUUc+jIsMQW2t6o+S1qN93mRdo18XlVG9pPIYM0F7gaZ5JZLR7/q BG46VfmniGPOu9YLNjACGoaCb85E4UMGNmM3+Jll/hEKQR8AJn+0xKMFZ6hd0So+1zjZ OgH6PfcaeGtzhhKq6OZsnkqEnhIXCsJgb07U0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z+EcOP9zGquBqjWH6ncVgYuYcuhA+kqx21sEB6Rn3hM=; b=S7VKD9LPR537GV83xM4pbFk11AwweqUChcHqRkOh2rfMb3goaaia51Tdlp4gZwBZI+ lGP/55jNafNxmT7w6gHkV09jFYxWUcEt9GK39Qs8ypK1c479yMvrVNw+++PuWQhyUCIS OJgEo9rYlvfbRRxt7BUWBAbE+DyhxcK4RX7AefMXlBDypBmUJYng/AdXekxi2O0vCQnu vynUtzKhQAbeQwH4FPur9mkZpspaDv9sl383dRA5MvhRe7IVmNG74TH+C69AzYpmTXkF TtzVVH91Ao3SHdZ+SNbbGhIyJM5vwjJ7M4J696ibVcBPOC8OWKMVuINGWjpZuMV1IwcF OXpA== X-Gm-Message-State: AMke39kHts2f1Frdb2d/hgHd8U/XVySMpIJ4nlmZoStOwwnIQhrvOJCttqNmdEwsthwzWF/b X-Received: by 10.55.137.69 with SMTP id l66mr17850620qkd.133.1489120460772; Thu, 09 Mar 2017 20:34:20 -0800 (PST) Received: from boxwood.roam.corp.google.com (cpe-75-189-128-87.nc.res.rr.com. [75.189.128.87]) by smtp.gmail.com with ESMTPSA id n19sm5697731qtn.35.2017.03.09.20.34.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 20:34:19 -0800 (PST) From: Sean Paul To: linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH 04/41] drm/rockchip: Respect page offset for PRIME mmap calls Date: Thu, 9 Mar 2017 23:32:19 -0500 Message-Id: <20170310043305.17216-5-seanpaul@chromium.org> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog In-Reply-To: <20170310043305.17216-1-seanpaul@chromium.org> References: <20170310043305.17216-1-seanpaul@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170309_203437_549719_11E971E8 X-CRM114-Status: GOOD ( 13.76 ) 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: Heiko Stuebner , David Airlie , Daniel Kurtz , Tomasz Figa , Sean Paul , =?UTF-8?q?=C3=98rjan=20Eide?= , linux-arm-kernel@lists.infradead.org, Mark Yao 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 external DMA-bufs through the PRIME mmap call, we might be given an offset which has to be respected. However for the internal DRM GEM mmap path, we have to ignore the fake mmap offset used to identify the buffer only. Currently the code always zeroes out vma->vm_pgoff, which breaks the former. This patch fixes the problem by moving the vm_pgoff assignment to a function that is used only for GEM mmap path, so that the PRIME path retains the original offset. BUG=chrome-os-partner:56615 TEST=graphics_GLBench Cc: Daniel Kurtz Signed-off-by: Ørjan Eide Signed-off-by: Tomasz Figa Signed-off-by: Sean Paul Tested-by: Heiko Stuebner --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index 5dffe276d2a7..7fa2cb77bdc0 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -263,7 +263,6 @@ static int rockchip_drm_gem_object_mmap(struct drm_gem_object *obj, * VM_PFNMAP flag that was set by drm_gem_mmap_obj()/drm_gem_mmap(). */ vma->vm_flags &= ~VM_PFNMAP; - vma->vm_pgoff = 0; if (rk_obj->pages) ret = rockchip_drm_gem_object_mmap_iommu(obj, vma); @@ -298,6 +297,12 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma) if (ret) return ret; + /* + * Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the + * whole buffer from the start. + */ + vma->vm_pgoff = 0; + obj = vma->vm_private_data; return rockchip_drm_gem_object_mmap(obj, vma);