From patchwork Fri Sep 16 09:17:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 9335299 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 784DE6077F for ; Fri, 16 Sep 2016 09:19:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67AD929F0A for ; Fri, 16 Sep 2016 09:19:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B69E29F11; Fri, 16 Sep 2016 09:19:17 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6F96329F0A for ; Fri, 16 Sep 2016 09:19:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bkpHR-0004XX-4T; Fri, 16 Sep 2016 09:17:57 +0000 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bkpHK-0004NF-U5 for linux-arm-kernel@lists.infradead.org; Fri, 16 Sep 2016 09:17:52 +0000 Received: by mail-pf0-x22e.google.com with SMTP id z123so25730057pfz.2 for ; Fri, 16 Sep 2016 02:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mZguIFLIDPkYc5zyfIcxJG8NAOrohygm0lmBzRVNNpQ=; b=bs2n31pjx0d+Rw+JxxAzOjK845lKF7Y0GZpCklCKAHKQhqIVnHm/eH0pPXVcqqayhy r1MGnSHA566fPv4zx+tlceKgS3k+EjndIKh22Xn8BD9HulMkdL+Uy8CB2V+LwDntnTJk 6ZjgSXtG5mS6N/LiBVV/pS4sHoE977HroVdmY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mZguIFLIDPkYc5zyfIcxJG8NAOrohygm0lmBzRVNNpQ=; b=Bb8VxDEMCTZsZTBcgUHT3VnggcDAL+RLY8dRKqYqw3LzlC6BcrlAHKP5JoO6O+zssY pZUlD6TtwbE28YdhxhIb053CcbTINx8h5ZgZ+8HyZmLP1D/TUwm4mdZLDxSozKadV5KS BOdWX1ua+t7lTBkBRVlfc1Kc4OkYU0w4wdItauO47NsjUppHCP0x1evJVbgySb0rqydz VmusDKt+XYyDWlwCrrwbS9sS70NIvyKYHVvkfOwfKFm+8LgKTvD/1sL3O7yHC+7Olcei ekd0Rq5Vn+eJ5bNxQO/PypE7+/0Jfo9tDFjr03N8jarr9dushMI+e+VnsxBgmRsoCJ0i dfmw== X-Gm-Message-State: AE9vXwPTJq37AJftEHOGgUclTezYOxF2D8wWvLjgzv0wa8lprW+lo50siAdL2UlCwG8pa3sL X-Received: by 10.98.196.206 with SMTP id h75mr13533824pfk.156.1474017449823; Fri, 16 Sep 2016 02:17:29 -0700 (PDT) Received: from basement.tok.corp.google.com ([100.103.3.207]) by smtp.gmail.com with ESMTPSA id 7sm50614291pfk.6.2016.09.16.02.17.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Sep 2016 02:17:29 -0700 (PDT) From: Tomasz Figa To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/rockchip: Respect page offset for PRIME mmap calls Date: Fri, 16 Sep 2016 18:17:22 +0900 Message-Id: <1474017442-7262-1-git-send-email-tfiga@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160916_021751_063167_53979C1E X-CRM114-Status: GOOD ( 13.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , David Airlie , linux-kernel@vger.kernel.org, Daniel Kurtz , Tomasz Figa , linux-rockchip@lists.infradead.org, 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. Fixes: a8594f2 ("drm/rockchip: unset pgoff when mmap'ing gems") Signed-off-by: Ørjan Eide Signed-off-by: Tomasz Figa Cc: stable@vger.kernel.org --- 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 b70f942..cab4d60 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -64,7 +64,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; ret = dma_mmap_attrs(drm->dev, vma, rk_obj->kvaddr, rk_obj->dma_addr, obj->size, rk_obj->dma_attrs); @@ -96,6 +95,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);