Received: by 10.223.176.46 with SMTP id f43csp691500wra; Fri, 26 Jan 2018 05:28:37 -0800 (PST) X-Google-Smtp-Source: AH8x227N8qXpSC+51P4dRAwAsFpnPKmdWiWhK3Jo/b6T6Lepmy8AzKHc2egveGtF9CkTBRVjhs6T X-Received: by 2002:a17:902:6849:: with SMTP id f9-v6mr14762140pln.113.1516973317080; Fri, 26 Jan 2018 05:28:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516973317; cv=none; d=google.com; s=arc-20160816; b=afPpL4rC7KFeJKX2EWhxpDDm63nPQpwgjJWniLaZEjtkz4hV8U0wKZAP9fxAjHLO33 4rg7K8X4R+nD/f2GXEU9inWCnWN74wH5FHmoXv8pAbBh22R0lPnlq72IwDaAVatmsRPE uGosFqa3QBeN0W18ZeBkXOfK2+cbHFND6E19o5INeihl1aikoVVf1ZtDWqSu5z7PbR8E jwGScnjtIlD8oeeKNguWgayjkvaXe8B9pLzXBsDTtWjXRIPAfhBCcT6vGJJcLbmFGU5M G58Sv01U8KyUOCMCeJFukjD4/VST3Xz7pTeTnfC32gDJ0bqpeV3skiu2pLWcrrDgM6Rg 3mGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-transfert-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=FqEA3iCvn7Y8gNBeyMpFWAxeDfQW3NRPv7b8q27JLhk=; b=U/qhq8RI6WZYm327h69n9+eWhTBGjcP0k/Ant9bAc7AaV0PoJxMSJuH+8Uq5JRY1EX 762VCRmNLiTgOFROnkkbsRHmVXCNy63mCC0DZnXymi7VQy8Hc04Ar9x+NgJ86mASSpHI 9Ni9pGLDoQ+dsClIexyuZQMlgAFfganZ6eO4Ied+hFBG1g3WTAx28YAzTZn6mWJ4ShR+ FieE0BhPVev0yuhqZ7r3ZZlQ5EVrHqrQ5X08rpLvVIJvJkII5OAfwuqebmS5jFXaDeeC kq6DItoG3RmBhW1YkhjzIp9m+aB19WhDvfndiE8N5KxP5wAsw/+q7gTCBO4tYvFhseqW EzEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b25si6351166pfc.241.2018.01.26.05.28.22; Fri, 26 Jan 2018 05:28:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752436AbeAZN1m (ORCPT + 99 others); Fri, 26 Jan 2018 08:27:42 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:34356 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751641AbeAZNRk (ORCPT ); Fri, 26 Jan 2018 08:17:40 -0500 Received: from localhost.localdomain (unknown [IPv6:2a01:e35:8a7e:4790:a8d7:ca4:7b4f:7f87]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tescande) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 2B33F274708; Fri, 26 Jan 2018 13:17:39 +0000 (GMT) From: Thierry Escande To: Archit Taneja , Inki Dae , Thierry Reding , Sandy Huang , Sean Paul , David Airlie , Tomasz Figa Cc: Haixia Shi , =?UTF-8?q?=C3=98rjan=20Eide?= , Zain Wang , Yakir Yang , Lin Huang , Douglas Anderson , Mark Yao , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 03/43] drm/rockchip: Respect page offset for PRIME mmap calls Date: Fri, 26 Jan 2018 14:16:30 +0100 Message-Id: <20180126131710.7622-4-thierry.escande@collabora.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180126131710.7622-1-thierry.escande@collabora.com> References: <20180126131710.7622-1-thierry.escande@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset = "utf-8" Content-Transfert-Encoding: 8bit Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cc: Daniel Kurtz Signed-off-by: Ørjan Eide Signed-off-by: Tomasz Figa Signed-off-by: Sean Paul Signed-off-by: Thierry Escande 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 5d52020deca1..074db7a92809 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -264,7 +264,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); @@ -299,6 +298,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); -- 2.14.1