From patchwork Tue Jul 13 09:02:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 12373255 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F6CBC07E96 for ; Tue, 13 Jul 2021 09:02:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3D3961260 for ; Tue, 13 Jul 2021 09:02:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3D3961260 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C4DD06E061; Tue, 13 Jul 2021 09:02:40 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9991E89DEC; Tue, 13 Jul 2021 09:02:39 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BC29D221D2; Tue, 13 Jul 2021 09:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1626166957; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7FFP9WhCY9C7CZTQ6EWmeyFN/DqwjqBMDGbQZsz/Nhc=; b=VQPf8Vtkvqk6MoWXC+Bta7FMP3X9Am7qoQzzBcjJ7nIFQsQlqJieHDW9ysvzfRn7NU8O60 2gwa/Waxdw4p8qbRYUWCXftKTGRywrDcm96wDwr7KOjvKG14aryDF3qLShj7pFmuKHQm6q S3/7oVldewL8Lk0qT3w8LUrzms3rFpQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1626166957; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7FFP9WhCY9C7CZTQ6EWmeyFN/DqwjqBMDGbQZsz/Nhc=; b=ZcY9QWiOvEhTo6mzdQLJYb7UE+2ukj2NLPNs2/cNRtEhvMzcHgtfdDwzKND47Hb6UASgvO Ulg0lV+8JHfhbJBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 795B713B3B; Tue, 13 Jul 2021 09:02:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8QWxHK1W7WDDTgAAMHmgww (envelope-from ); Tue, 13 Jul 2021 09:02:37 +0000 From: Thomas Zimmermann To: airlied@linux.ie, daniel@ffwll.ch, christian.koenig@amd.com, ville.syrjala@linux.intel.com, melissa.srw@gmail.com, jgg@ziepe.ca, lee.jones@linaro.org, chris@chris-wilson.co.uk, miaoqinglang@huawei.com Date: Tue, 13 Jul 2021 11:02:35 +0200 Message-Id: <20210713090235.26372-1-tzimmermann@suse.de> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] Revert "drm/vgem: Implement mmap as GEM object function" X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , intel-gfx@lists.freedesktop.org, Thomas Zimmermann , dri-devel@lists.freedesktop.org, Gerd Hoffmann Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Commit 375cca1cfeb5 ("drm/vgem: Implement mmap as GEM object function") broke severla IGT tests in vgem_basic. [1] Attempts to fix the issue have not worked out so far. [2][3] Revert the original patch for now. Note that there is a patch that converts vgem to shmem helpers. [4] Merging this change would be preferable to modifying vgem's mmap code. [1] https://intel-gfx-ci.01.org/tree/drm-tip/igt@vgem_basic@unload.html [2] https://lore.kernel.org/intel-gfx/20210709154256.12005-1-tzimmermann@suse.de/ [3] https://lore.kernel.org/intel-gfx/20210712123321.3658-1-tzimmermann@suse.de/ [4] https://patchwork.freedesktop.org/series/90671/ Signed-off-by: Thomas Zimmermann Fixes: 375cca1cfeb5 ("drm/vgem: Implement mmap as GEM object function") Reviewed-by: Daniel Vetter Cc: Thomas Zimmermann Cc: Christian König Cc: Daniel Vetter Cc: "Christian König" Cc: Jason Gunthorpe Cc: Melissa Wen Cc: Qinglang Miao Cc: Gerd Hoffmann --- drivers/gpu/drm/vgem/vgem_drv.c | 46 +++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) -- 2.32.0 diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c index df634aa52638..bf38a7e319d1 100644 --- a/drivers/gpu/drm/vgem/vgem_drv.c +++ b/drivers/gpu/drm/vgem/vgem_drv.c @@ -239,7 +239,32 @@ static struct drm_ioctl_desc vgem_ioctls[] = { DRM_IOCTL_DEF_DRV(VGEM_FENCE_SIGNAL, vgem_fence_signal_ioctl, DRM_RENDER_ALLOW), }; -DEFINE_DRM_GEM_FOPS(vgem_driver_fops); +static int vgem_mmap(struct file *filp, struct vm_area_struct *vma) +{ + unsigned long flags = vma->vm_flags; + int ret; + + ret = drm_gem_mmap(filp, vma); + if (ret) + return ret; + + /* Keep the WC mmaping set by drm_gem_mmap() but our pages + * are ordinary and not special. + */ + vma->vm_flags = flags | VM_DONTEXPAND | VM_DONTDUMP; + return 0; +} + +static const struct file_operations vgem_driver_fops = { + .owner = THIS_MODULE, + .open = drm_open, + .mmap = vgem_mmap, + .poll = drm_poll, + .read = drm_read, + .unlocked_ioctl = drm_ioctl, + .compat_ioctl = drm_compat_ioctl, + .release = drm_release, +}; static struct page **vgem_pin_pages(struct drm_vgem_gem_object *bo) { @@ -362,12 +387,24 @@ static void vgem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *ma vgem_unpin_pages(bo); } -static int vgem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) +static int vgem_prime_mmap(struct drm_gem_object *obj, + struct vm_area_struct *vma) { + int ret; + + if (obj->size < vma->vm_end - vma->vm_start) + return -EINVAL; + + if (!obj->filp) + return -ENODEV; + + ret = call_mmap(obj->filp, vma); + if (ret) + return ret; + vma_set_file(vma, obj->filp); vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); - vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); return 0; } @@ -379,7 +416,6 @@ static const struct drm_gem_object_funcs vgem_gem_object_funcs = { .get_sg_table = vgem_prime_get_sg_table, .vmap = vgem_prime_vmap, .vunmap = vgem_prime_vunmap, - .mmap = vgem_prime_mmap, .vm_ops = &vgem_gem_vm_ops, }; @@ -397,7 +433,7 @@ static const struct drm_driver vgem_driver = { .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_import = vgem_prime_import, .gem_prime_import_sg_table = vgem_prime_import_sg_table, - .gem_prime_mmap = drm_gem_prime_mmap, + .gem_prime_mmap = vgem_prime_mmap, .name = DRIVER_NAME, .desc = DRIVER_DESC,