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: 9335281 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 397E360839 for ; Fri, 16 Sep 2016 09:17:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28BD829F0A for ; Fri, 16 Sep 2016 09:17:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BE1229F11; Fri, 16 Sep 2016 09:17:42 +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=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 C652A29F0A for ; Fri, 16 Sep 2016 09:17:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2CA976E9C9; Fri, 16 Sep 2016 09:17:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x236.google.com (mail-pf0-x236.google.com [IPv6:2607:f8b0:400e:c00::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id 18F656E9C9 for ; Fri, 16 Sep 2016 09:17:31 +0000 (UTC) Received: by mail-pf0-x236.google.com with SMTP id z123so25730058pfz.2 for ; Fri, 16 Sep 2016 02:17:31 -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=lQizSCYD7HFVxUxOKANeOc4Rpj0YzNnQ6OB3EW+hebGVsM99X+vdSAiSwdvOCzKYU3 AchemyCAKFwBJ0wPfwnyJEKvshJMkOGodpzwE6rsBbwERZltLJKpET8TKn1Y9I4sCwD7 61o8qPinXujQM1GVweZ9QKng2kTdr3xKg+RfAGREPePE0CSOk2JPZAsjDSbyYTmXSYG2 S20W2CPhhgP3G90o4OwbYmMI+jTLBC1gkEdTNavj968KP92VkPtF4DVZUkHcme1JIimP 79+BOTzZldMxn13ti/pPCbTVsYnEPhLV899Ldqy7zfs29uFqz/UFH6ncsKWcLL7ZOvjj XQEg== X-Gm-Message-State: AE9vXwOUqSccH5NJYgZ3DdgYywWjw8yKdHZPXeBX4CC43DkAAz2n3v7gtuOgVgoAeXoaT6V0 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 Cc: linux-kernel@vger.kernel.org, Tomasz Figa , linux-rockchip@lists.infradead.org, =?UTF-8?q?=C3=98rjan=20Eide?= , linux-arm-kernel@lists.infradead.org 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 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);