From patchwork Wed Oct 23 22:22:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 177360 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp1356316ill; Wed, 23 Oct 2019 15:22:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUq0zs4fl91lwEHltpq+z3mZPKXdB4zDMteIPGqm3WLGoKQqmj+krtSfdE80Hj5iDPp4i9 X-Received: by 2002:a63:5417:: with SMTP id i23mr6939951pgb.305.1571869353089; Wed, 23 Oct 2019 15:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571869353; cv=none; d=google.com; s=arc-20160816; b=yLXk970I8kukryVHiX5t0BRQWoBAW7zbNAqQKQ6StxK94fs6o/RJDpC+kA7J5aUvys NTi0gmUnSUNhdJP88aberB1CIRGXV8QtF/d5MG5WFU/hR/VT3c+VL53OPqei5rvLLJp0 QZFmu5cADHM1XB8B8Z5KfqmYCHEEa8QP1teCBN1rTuM5ernrKv3sdAtsUFa+WJJDFOc3 L3IwxBgOXoZebh4RWPifx4xoMiQxpf0Pc6n6SShD7YcVjsqJa2uVS9Pr5LkupIldjnX6 Ibv2V0Xxc8f0/3nzNYH7NtWNj6VaBLpT45Lz/4/UbG54OV7mC5QvZlQjzc4f8sozQU1a UmKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :delivered-to; bh=Gxssmz8ruMZncC3v7AjrbgOYtpCc7hM1Un4tfmXZSHI=; b=cidPNPji3mM97R5ZhZR9Icajh2izMyPMw85PqkX/+MSE6vLg5mCgEVyx5gkb57t3IU 5mWk4fXhJE1kUI03ZGWr0swM3QlLvv5zvy16GTEzOLeWTpOqNcQwGUBYf9CgbX6ytMnc a8OEy1wpCXse5aiFd+L9Rny0zMoaHi8VcD/3KaWQ99ZVXwZ1FakRR4EmXy7OCpQYE7jY zfo5Optg+vR9uIS0qM2zoBwXyydB1uQP2BN+5p0yJ0i3JY093/x7sBIJuqmdssuVCQnH wbdxgjPwHCBA9TFmZDwBLOIUlPRvvWzzhni4/xxRNkih7Fx+6lKGqdm03jx5w6mPGKzM mM+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id n14si24372631pgr.217.2019.10.23.15.22.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Oct 2019 15:22:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4DA66E0B6; Wed, 23 Oct 2019 22:22:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by gabe.freedesktop.org (Postfix) with ESMTPS id 828AC6E0B6 for ; Wed, 23 Oct 2019 22:22:29 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id b25so7214817oib.7 for ; Wed, 23 Oct 2019 15:22:29 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=Q+mpw/DJpg8X7g76hDP88VPzzqWD7qhoYfGoXof7Ryw=; b=Ij32MXd3kheteOVtaFdB45wsghpFAeokzpy5VISIqpid0kOazzOVOUB1m1STOVyIM5 KyUWKIkouKbu7ikjxYK6QD8NxutronjjIC/eCRIl2dePLFrU62xPYMEuaCgfZzInfR94 8YJbzYft/vB6y3sqx7Fi/Q0ig+F92QUh0GHrkvcQRyO39SWrarpszhPX+THNuzpBwgA3 GmKdUAOT1/RtwcYYPGca9AZ141mTjAPO7AT9X8Vs9SI/SKYJckc0ILyT0dZ8ksTvIV+x wL9mSMBR6P6hoPqvugddMCl2tmB7wBRCJtOxaItjzrF7SgQFye69v34EkT9rnyKK2PqV y0Gg== X-Gm-Message-State: APjAAAXOB8j5GlddbdMoAkRpqRrcJrEtLhhIvM3TTXy+zrbCmaRgGqnW osqXk+RZ2LyVcVOiPBv4VhEih+U= X-Received: by 2002:aca:56d6:: with SMTP id k205mr1856542oib.51.1571869348400; Wed, 23 Oct 2019 15:22:28 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id 21sm5936971oin.26.2019.10.23.15.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 15:22:27 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org, Gerd Hoffmann Subject: [PATCH] drm/prime: Fix mmap fake offset for drm_gem_object_funcs.mmap Date: Wed, 23 Oct 2019 17:22:26 -0500 Message-Id: <20191023222226.9064-1-robh@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Commit c40069cb7bd6 ("drm: add mmap() to drm_gem_object_funcs") introduced a GEM object mmap() hook which is expected to subtract the fake offset from vm_pgoff. However, for mmap() on dmabufs, there is not a fake offset. To fix this, we need to add the fake offset just like the driver->fops->mmap() code path. Fixes: c40069cb7bd6 ("drm: add mmap() to drm_gem_object_funcs") Cc: Gerd Hoffmann Cc: Daniel Vetter Signed-off-by: Rob Herring Acked-by: Gerd Hoffmann --- I ran into this while working on converting vgem to shmem helpers and the IGT vgem_basic dmabuf-mmap test failed. This fixes shmem, but I have checked any other users of the new mmap hook. Rob drivers/gpu/drm/drm_prime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 0814211b0f3f..5d06690a2e9d 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -713,6 +713,8 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) struct file *fil; int ret; + vma->vm_pgoff += drm_vma_node_start(&obj->vma_node); + if (obj->funcs && obj->funcs->mmap) { ret = obj->funcs->mmap(obj, vma); if (ret) @@ -737,8 +739,6 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) if (ret) goto out; - vma->vm_pgoff += drm_vma_node_start(&obj->vma_node); - ret = obj->dev->driver->fops->mmap(fil, vma); drm_vma_node_revoke(&obj->vma_node, priv);