Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3059758ybc; Thu, 21 Nov 2019 02:42:35 -0800 (PST) X-Google-Smtp-Source: APXvYqyzevIt1Owdr/cYEWdWgnS4f4WQzQC9pL36lgTerG0QfOlNkfqLWTiet8oI9y9JLBxH8KrH X-Received: by 2002:a17:906:c789:: with SMTP id cw9mr13334064ejb.40.1574332954948; Thu, 21 Nov 2019 02:42:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574332954; cv=none; d=google.com; s=arc-20160816; b=MQvE44kjCy3qI2dUG/wJx2LKcqCbpVZKLrdMmtuD9VmwZBq+1D282tQPX/EuYF9GOJ mYMlCcaHQcWUwr7rZfUOXQinmgxZURx0DCRUG05Y/cQGUcsYKeKQF0io5ovw68YUvCGM sQ0JrINhkqcMx3hAEN2Duh0AAw/QMiVCvun4l9PvOc2QfEVVtnfsZp/ihsE+/m+0drmP B/IMPBOtTllzk1FemMmG4PhJrUjjp80IoWzSwjFMgLI7728XgFW/vIqOzKP0SiQ8m4y7 h8Bb1U9ZkbfQYI/sXb5qjNfleVE5knqLrpCgZRTtIBt9OwFLLkqoQnAzRoZmM15A2S3m ZJDg== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=iIac5SPOmc9oxHIYzV9hFqqBc5xVMgS7zIDXwEB9xaw=; b=mtJYkk43xucGSHdpy5O+fCfENYdmkWpgWlDTCt2P7cwxw7RKMsj6aFj/xYYSOie2Sz n5geQDCK6xIbKNHhlKQJxkqSnX38/3P6Qt9yh42SccMWsAh+PkCclJ1L/m7xvs3Z8NEr rK8YzxgqbHYSF34IogA4/kAjSEZqKb69N1SMlN6Ismv+Fda9x00ie6HJHNkkf1HI9Xgv uUs6iqBB01f8y8DTp/HoEezl2SOiKIuFHbRFi76OhX4F9cK4s0qRWjb6iysWft4XN6QM 9cfwSI4TNv8OoGUbW1cEaxcay8io8h1RKIoK1jU7D8WfoT09c+hDGUhZI3OXAFrde6k/ veTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jIDkN6U9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x12si1386627eju.50.2019.11.21.02.42.09; Thu, 21 Nov 2019 02:42:34 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jIDkN6U9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726735AbfKUKiV (ORCPT + 99 others); Thu, 21 Nov 2019 05:38:21 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28530 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726875AbfKUKiU (ORCPT ); Thu, 21 Nov 2019 05:38:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574332698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iIac5SPOmc9oxHIYzV9hFqqBc5xVMgS7zIDXwEB9xaw=; b=jIDkN6U9JgqtI7VhOYQT4bv56VVXA4LtKvztwgjLNJUV6OOT3xqlDJeN4wIkt0tArZOp42 4JdK564sAJu0fNFeCh1UzynYp+wGWrloAXeTODslVHnAi3EIOsokdQjmkJLi5bEb4w2oHP A0id4RZp7YGOUhV1hUAbMnsEhcFTauI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-hrfRQkw1MkazqJtpqYN2wg-1; Thu, 21 Nov 2019 05:38:15 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19AD06A6; Thu, 21 Nov 2019 10:38:13 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F6EE70537; Thu, 21 Nov 2019 10:38:08 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B0ADF17536; Thu, 21 Nov 2019 11:38:07 +0100 (CET) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, Gerd Hoffmann , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Christian Koenig , Huang Rui , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] drm: call drm_gem_object_funcs.mmap with fake offset Date: Thu, 21 Nov 2019 11:38:06 +0100 Message-Id: <20191121103807.18424-2-kraxel@redhat.com> In-Reply-To: <20191121103807.18424-1-kraxel@redhat.com> References: <20191121103807.18424-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: hrfRQkw1MkazqJtpqYN2wg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The fake offset is going to stay, so change the calling convention for drm_gem_object_funcs.mmap to include the fake offset. Update all users accordingly. Signed-off-by: Gerd Hoffmann --- include/drm/drm_gem.h | 4 +--- drivers/gpu/drm/drm_gem.c | 3 --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +++ drivers/gpu/drm/drm_prime.c | 3 +++ drivers/gpu/drm/ttm/ttm_bo_vm.c | 7 ------- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 97a48165642c..0b375069cd48 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -159,9 +159,7 @@ struct drm_gem_object_funcs { =09 * =09 * The callback is used by by both drm_gem_mmap_obj() and =09 * drm_gem_prime_mmap(). When @mmap is present @vm_ops is not -=09 * used, the @mmap callback must set vma->vm_ops instead. The @mmap -=09 * callback is always called with a 0 offset. The caller will remove -=09 * the fake offset as necessary. +=09 * used, the @mmap callback must set vma->vm_ops instead. =09 */ =09int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma); =20 diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 2f2b889096b0..56f42e0f2584 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -1106,9 +1106,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsi= gned long obj_size, =09=09return -EINVAL; =20 =09if (obj->funcs && obj->funcs->mmap) { -=09=09/* Remove the fake offset */ -=09=09vma->vm_pgoff -=3D drm_vma_node_start(&obj->vma_node); - =09=09ret =3D obj->funcs->mmap(obj, vma); =09=09if (ret) =09=09=09return ret; diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_g= em_shmem_helper.c index 0810d3ef6961..a421a2eed48a 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -528,6 +528,9 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, stru= ct vm_area_struct *vma) =09struct drm_gem_shmem_object *shmem; =09int ret; =20 +=09/* Remove the fake offset */ +=09vma->vm_pgoff -=3D drm_vma_node_start(&obj->vma_node); + =09shmem =3D to_drm_gem_shmem_obj(obj); =20 =09ret =3D drm_gem_shmem_get_pages(shmem); diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 0814211b0f3f..a9633bd241bb 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -714,6 +714,9 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, stru= ct vm_area_struct *vma) =09int ret; =20 =09if (obj->funcs && obj->funcs->mmap) { +=09=09/* Add the fake offset */ +=09=09vma->vm_pgoff +=3D drm_vma_node_start(&obj->vma_node); + =09=09ret =3D obj->funcs->mmap(obj, vma); =09=09if (ret) =09=09=09return ret; diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_v= m.c index e6495ca2630b..3e8c3de91ae4 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -514,13 +514,6 @@ EXPORT_SYMBOL(ttm_bo_mmap); int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *= bo) { =09ttm_bo_get(bo); - -=09/* -=09 * FIXME: &drm_gem_object_funcs.mmap is called with the fake offset -=09 * removed. Add it back here until the rest of TTM works without it. -=09 */ -=09vma->vm_pgoff +=3D drm_vma_node_start(&bo->base.vma_node); - =09ttm_bo_mmap_vma_setup(bo, vma); =09return 0; } --=20 2.18.1