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: 9335285 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 559F660839 for ; Fri, 16 Sep 2016 09:17:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4213429F0A for ; Fri, 16 Sep 2016 09:17:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3607E29F11; Fri, 16 Sep 2016 09:17:56 +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 C0A5529F0A for ; Fri, 16 Sep 2016 09:17:55 +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 1bkpHN-0004X0-IY; Fri, 16 Sep 2016 09:17:53 +0000 Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bkpHK-0004NG-TV for linux-rockchip@lists.infradead.org; Fri, 16 Sep 2016 09:17:51 +0000 Received: by mail-pf0-x22a.google.com with SMTP id 21so15020016pfy.0 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=id2yt+qdb2dmc29c/Iy0QBmdrZwx0Jg2gPitkAQYm+7YRAy6/Zm9fx2E/86cpk+nBu SLGxXEAWT7J5FQVYJ6CJaWpeI1CXdVAav1iCuwjlxS2YZItjq5Q1u+AnhMWZ3ry5g7nL Z86lYubE4DpRq4T9WoW/SglfN2kJptOOszw4IjamH9oR2/DtomY05JjUiYL6b4IzJl+B o/6rHUS4bVwL6EfIIQrSQmTPFQb5Pniw4uIrzETZhbJp4w0Lo6nO4xsooOJaf6qtY7zR 1dQHSxk7q1FRQUPI4kZATjgUx42eaFBtJ5fNY+uEnz8qKiiXLaQzt45ylj5ZbPCZaII1 RdNA== X-Gm-Message-State: AE9vXwMVDb/TCi/x9leoJNbzeuXMuBAesq7WotA07Rwh2qGGBFkK+2dD/mpm827rgt1Cga49 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_055215_AFEC7731 X-CRM114-Status: GOOD ( 12.00 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms 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-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=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);