From patchwork Thu May 16 16:27:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 10946903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7E651390 for ; Thu, 16 May 2019 16:27:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7E35287C2 for ; Thu, 16 May 2019 16:27:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8F022897D; Thu, 16 May 2019 16:27:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 70691287C2 for ; Thu, 16 May 2019 16:27:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 79D9489780; Thu, 16 May 2019 16:27:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id A704C89781 for ; Thu, 16 May 2019 16:27:52 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id ED153AEA3; Thu, 16 May 2019 16:27:50 +0000 (UTC) From: Thomas Zimmermann To: daniel@ffwll.ch, airlied@linux.ie, kraxel@redhat.com, christian.koenig@amd.com, ray.huang@amd.com, hdegoede@redhat.com, noralf@tronnes.org, sam@ravnborg.org, z.liuxinliang@hisilicon.com, zourongrong@gmail.com, kong.kongxinwei@hisilicon.com, puck.chen@hisilicon.com Subject: [PATCH 0/2] Add BO reservation to GEM VRAM pin/unpin/push_to_system Date: Thu, 16 May 2019 18:27:44 +0200 Message-Id: <20190516162746.11636-1-tzimmermann@suse.de> X-Mailer: git-send-email 2.21.0 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: Thomas Zimmermann , dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP A kernel test bot reported a problem with the locktorture testcase that was triggered by the GEM VRAM helpers. ... [ 10.004734] RIP: 0010:ttm_bo_validate+0x41/0x141 [ttm] ... [ 10.015669] ? kvm_sched_clock_read+0x5/0xd [ 10.016157] ? get_lock_stats+0x11/0x3f [ 10.016607] drm_gem_vram_pin+0x77/0xa2 [drm_vram_helper] [ 10.017229] drm_gem_vram_driver_gem_prime_vmap+0xe/0x39 [drm_vram_helper] [ 10.018015] drm_gem_vmap+0x36/0x43 [drm] [ 10.018491] drm_client_framebuffer_create+0xc6/0x1ca [drm] [ 10.019143] drm_fb_helper_generic_probe+0x4c/0x157 [drm_kms_helper] [ 10.019864] __drm_fb_helper_initial_config_and_unlock+0x307/0x442 [drm_kms_helper] [ 10.020739] drm_fbdev_client_hotplug+0xc8/0x115 [drm_kms_helper] [ 10.021442] drm_fbdev_generic_setup+0xc4/0xf1 [drm_kms_helper] [ 10.022120] bochs_pci_probe+0x123/0x143 [bochs_drm] [ 10.022688] local_pci_probe+0x34/0x75 [ 10.023127] pci_device_probe+0xf8/0x150A ... It turns out that the bochs and vbox drivers automatically reserved and unreserved the BO from within their pin and unpin functions. The other drivers; ast, hibmc and mgag200; performed reservation explicitly. With the GEM VRAM conversion, automatic BO reservation within pin and unpin functions accidentally got lost. So for bochs and vbox, ttm_bo_validate() worked on unlocked BOs. This patch set fixes the problem by adding automatic reservation to the implementation of drm_gem_vram_{pin,unpin,push_to_system}() to fix bochs and vbox. It removes explicit BO reservation around the pin, unpin and push-to-system calls in the ast, hibmc and mgag200 drivers. The only exception is the cursor handling of mgag200. In this case, the mgag200 driver now calls drm_gem_vram_{pin,unpin}_reserved(), which works with reserved BOs. The respective code should be refactored in a future patch to work with the regular pin and unpin functions. Thomas Zimmermann (2): drm: Add drm_gem_vram_{pin/unpin}_reserved() and convert mgag200 drm: Reserve/unreserve GEM VRAM BOs from within pin/unpin functions drivers/gpu/drm/ast/ast_mode.c | 24 +--- drivers/gpu/drm/drm_gem_vram_helper.c | 115 +++++++++++++++++- .../gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 6 - .../gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 17 +-- drivers/gpu/drm/mgag200/mgag200_cursor.c | 18 +-- drivers/gpu/drm/mgag200/mgag200_mode.c | 19 +-- include/drm/drm_gem_vram_helper.h | 3 + 7 files changed, 126 insertions(+), 76 deletions(-) --- 2.21.0