Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4602613pja; Thu, 21 Nov 2019 22:39:30 -0800 (PST) X-Google-Smtp-Source: APXvYqxdWO3r/Cxn4XPDKXYLLriowvCVu4Y2q4MUWw8m8cvOflxdmeYtMMjZicFOcmh+G1x3rXrQ X-Received: by 2002:a5d:570a:: with SMTP id a10mr15446845wrv.107.1574404769865; Thu, 21 Nov 2019 22:39:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574404769; cv=none; d=google.com; s=arc-20160816; b=LIA2V/BlIZpn1CLF6BLvmAJYXyz84cVxKGAMTYxNdicdYcYOPRtRW1ohxvyVoDgCGe L76BUR8AkmRbMK8GI51g5L05ikMnY/PTLnj9GHr96z9QR9u7rttKJnicHNaH+JBVBaUH ff/5uBzgUMvss0h1KaQOsuhkcUhbOd66zFacZ87J5yNfp+NpVYPvFcf9tVoYuz6aF9BN gym3wjv2WqRMhAoIIUCQ0Z6t7aywNtIKts9PJHWqItLHnnsJcK0MsGpM2tD95DjWHhai +1pgEL6+QQEqT4Kc7tQku9dU52MRCNvpaXd5vbX/WkCDoV5dJLSLpGmtVI2btO51iBOZ WSQA== 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=kO/f20OK8ehETRWvdOhwDSCz6FJfjfQn0GgthZnU0Rc=; b=AP/D7Q4d/GjV6cgKOm0VCviHeDjtrnfm2CzDHA8BlmAaQPf18hYW2qpt9Bp3N8LmdD mWzCP9ioKhVeJcinhuFnOmJCwqOZDgVAXp5iw6fa4YwMyYNmQWBRP1ubVfp/XlNwm2dC Jkp/5vq0ymbxP/u/OdH5kb5z1fc0hRRP5MNIFDiwEadbXICUXa9XfzJBi7iFZ5D+FLch qQ+yDRYbzR5xqZZrdg1GySmagapU0krNOKUhi5jhTwDecFB4e0nJtIUI6Jdbhi1Du7jc YXhBAISgpHyEmlbv1LhfC/WZQ/MtlDc/JIss3tI9YeXNsFpdy3VUVPYAFkK3NDHURmya 1Ojw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OiGVLPEh; 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 u93si379155edc.184.2019.11.21.22.39.04; Thu, 21 Nov 2019 22:39:29 -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=OiGVLPEh; 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 S1726836AbfKVGiB (ORCPT + 99 others); Fri, 22 Nov 2019 01:38:01 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:35953 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726391AbfKVGiA (ORCPT ); Fri, 22 Nov 2019 01:38:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574404679; 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=kO/f20OK8ehETRWvdOhwDSCz6FJfjfQn0GgthZnU0Rc=; b=OiGVLPEhhszZ08NhUsVnCAzZLQTHi5Pr/l/afZGSx9aXBpGP2HPK3BYM1TR7TYGx/xsdpP dxL/EP1ej7bSd0xiadpvzXSRwzSPw+YfeLE/Ir+t+vIRODyKIy/n+JiTBZCamz87rjomqD LgjFLGfISWVNlgaHmax7M2PUDOOYyuE= 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-194-TBtFseKXMp6LDL4WsY81WA-1; Fri, 22 Nov 2019 01:37:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22958593CE; Fri, 22 Nov 2019 06:37:54 +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 05F975DF2C; Fri, 22 Nov 2019 06:37:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2B368A1E0; Fri, 22 Nov 2019 07:37:50 +0100 (CET) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: robh@kernel.org, intel-gfx@lists.freedesktop.org, Gerd Hoffmann , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , amd-gfx@lists.freedesktop.org (open list:RADEON and AMDGPU DRM DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 2/2] drm: share address space for dma bufs Date: Fri, 22 Nov 2019 07:37:49 +0100 Message-Id: <20191122063749.27113-3-kraxel@redhat.com> In-Reply-To: <20191122063749.27113-1-kraxel@redhat.com> References: <20191122063749.27113-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: TBtFseKXMp6LDL4WsY81WA-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 Use the shared address space of the drm device (see drm_open() in drm_file.c) for dma-bufs too. That removes a difference betweem drm device mmap vmas and dma-buf mmap vmas and fixes corner cases like dropping ptes (using madvise(DONTNEED) for example) not working properly. Also remove amdgpu driver's private dmabuf update. It is not needed any more now that we are doing this for everybody. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 +--- drivers/gpu/drm/drm_prime.c | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/= amd/amdgpu/amdgpu_dma_buf.c index d5bcdfefbad6..586db4fb46bd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -361,10 +361,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_gem= _object *gobj, =09=09return ERR_PTR(-EPERM); =20 =09buf =3D drm_gem_prime_export(gobj, flags); -=09if (!IS_ERR(buf)) { -=09=09buf->file->f_mapping =3D gobj->dev->anon_inode->i_mapping; +=09if (!IS_ERR(buf)) =09=09buf->ops =3D &amdgpu_dmabuf_ops; -=09} =20 =09return buf; } diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index a9633bd241bb..c3fc341453c0 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -240,6 +240,7 @@ void drm_prime_destroy_file_private(struct drm_prime_fi= le_private *prime_fpriv) struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev, =09=09=09=09 struct dma_buf_export_info *exp_info) { +=09struct drm_gem_object *obj =3D exp_info->priv; =09struct dma_buf *dma_buf; =20 =09dma_buf =3D dma_buf_export(exp_info); @@ -247,7 +248,8 @@ struct dma_buf *drm_gem_dmabuf_export(struct drm_device= *dev, =09=09return dma_buf; =20 =09drm_dev_get(dev); -=09drm_gem_object_get(exp_info->priv); +=09drm_gem_object_get(obj); +=09dma_buf->file->f_mapping =3D obj->dev->anon_inode->i_mapping; =20 =09return dma_buf; } --=20 2.18.1