Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3927009ybv; Mon, 10 Feb 2020 09:00:02 -0800 (PST) X-Google-Smtp-Source: APXvYqxxfope2N4va22WqnRVRr47dfVnc1FGr/UgkqX6shVla3iMJ/wXL/6dnWwI0rIKlYFQmaz2 X-Received: by 2002:a05:6830:1304:: with SMTP id p4mr1776048otq.327.1581354002102; Mon, 10 Feb 2020 09:00:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581354002; cv=none; d=google.com; s=arc-20160816; b=iX3MjKwj2Hx9+cij+2ogrfjF4jDHYCnpwd72C5pEfEyrOVfQO5vwBt8G1wmXo2O9Pw I+7IpPPGJrFQce0jJiKG+BdNjmqXFpx3xUUztCelKWBy1UzczTGxTZDuTfymG8XJc7NU W1CYR0rtpI7dEyUb16++hMYx560ofDsTR53hvb2lou96sFU+QqweveHWwfSWoygILZkf ttg2pI5yU24eX4ypANFGXzAxe7AV9Ukwx05ZMTJB7J6CtyKyL0xjjgl195ga6FexQNGK 770PxrEReEay7mWCkxjRmNZ4afumLhOwfKqQh6GfInlVqWkhMOvfVVRnla3nXhSiDaa2 ffLg== 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:in-reply-to :mime-version:user-agent:date:message-id:references:to:from:subject :dkim-signature; bh=ll4buIJukwY/pRiSVbGMIX07/MqDt1FyJ94Rs6Q9sl4=; b=adNeU00NUVgBtpaL437jhzsjm4OHf0k/NjwdL3zbWTzSCR5FSGsh2n2i5VNx/kOcmn +cI3vIM5Km7s3wLg6B5wlLtA5FwZu84tfMNVSX7PzfS5gjOZqtknHr5XuxHLiC87cRVO 5YAQbY0PIt55QbaICYw82z20BGr5pcREBYm4pHxskcV0dy/r/P9a+aNUeYW0h3b0WSNQ slxf7C4sOHAmjOgH6kslxUheM1KJQdptkKeiom+Gv+tycJUutuVfcc25qzFZyxO8gdqX tB4w5Hb09GSIGDFvo9OknNGyZ1OMW1fNQHPCOhl2jzrEO89nbHLI0O+kGKr6DmlM4cuh 2/fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@tronnes.org header.s=ds201912 header.b=J+Sg4AGu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si469545otf.32.2020.02.10.08.59.49; Mon, 10 Feb 2020 09:00:02 -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=fail header.i=@tronnes.org header.s=ds201912 header.b=J+Sg4AGu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727856AbgBJQ7Y (ORCPT + 99 others); Mon, 10 Feb 2020 11:59:24 -0500 Received: from smtp.domeneshop.no ([194.63.252.55]:42801 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727003AbgBJQ7Y (ORCPT ); Mon, 10 Feb 2020 11:59:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org ; s=ds201912; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:References:To:From:Subject:Sender:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ll4buIJukwY/pRiSVbGMIX07/MqDt1FyJ94Rs6Q9sl4=; b=J+Sg4AGuBNxYvElc9L7vefYKPs t7Lxcyew/cLA5Ius46AMRmRtu/Y5RjQEXlkvIWPSCWfwsQFKux1z0A1lcCH9sXKXaU8WUBnvjMb8E mIID9Qcugu4oxZ3Hv3Y5qVYP/bCNsncldpBHG3U1ta+A0WVFdbQ3M+MQ3WblVON3jTjm8KylDL4Us PjFQUPEyFbXKEW6gj7VpzRVerxLnCfbV3lWRqEuLufe89m9wj2Qpbzo0/t2aZDONPppafGGoqvGWO flFtmZEymhOW8jxYG3wTsKA5/oYPwvVRBUC0iZeaziCar4/JaXFK0PQxMdyM135ESmmCwS80NNIJO yq62DgCQ==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:61329 helo=[192.168.10.61]) by smtp.domeneshop.no with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j1CP3-0007bJ-7y; Mon, 10 Feb 2020 17:59:21 +0100 Subject: Re: [PATCH v2 2/2] drm/qxl: add drm_driver.release callback. From: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= To: Gerd Hoffmann , dri-devel@lists.freedesktop.org, Dave Airlie , David Airlie , "open list:DRM DRIVER FOR QXL VIRTUAL GPU" , "open list:DRM DRIVER FOR QXL VIRTUAL GPU" , open list , Daniel Vetter References: <20200210113753.5614-1-kraxel@redhat.com> <20200210113753.5614-3-kraxel@redhat.com> <20200210150633.GS43062@phenom.ffwll.local> Message-ID: <8b28f881-ea8e-af70-3ce3-f1d9b4a7f31a@tronnes.org> Date: Mon, 10 Feb 2020 17:59:18 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (adding back Daniel) Den 10.02.2020 17.57, skrev Noralf Trønnes: > > > Den 10.02.2020 16.06, skrev Daniel Vetter: >> On Mon, Feb 10, 2020 at 12:37:52PM +0100, Gerd Hoffmann wrote: >>> Move final cleanups to qxl_drm_release() callback. >>> Add drm_atomic_helper_shutdown() call to qxl_pci_remove(). >>> >>> Signed-off-by: Gerd Hoffmann >>> --- >>> drivers/gpu/drm/qxl/qxl_drv.c | 26 +++++++++++++++++++------- >>> 1 file changed, 19 insertions(+), 7 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c >>> index 1d601f57a6ba..4fda3f9b29f4 100644 >>> --- a/drivers/gpu/drm/qxl/qxl_drv.c >>> +++ b/drivers/gpu/drm/qxl/qxl_drv.c >>> @@ -34,6 +34,7 @@ >>> #include >>> >>> #include >>> +#include >>> #include >>> #include >>> #include >>> @@ -132,21 +133,30 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) >>> return ret; >>> } >>> >>> +static void qxl_drm_release(struct drm_device *dev) >>> +{ >>> + struct qxl_device *qdev = dev->dev_private; >>> + >>> + /* >>> + * TODO: qxl_device_fini() call should be in qxl_pci_remove(), >>> + * reodering qxl_modeset_fini() + qxl_device_fini() calls is >>> + * non-trivial though. >>> + */ >>> + qxl_modeset_fini(qdev); >> >> So the drm_mode_config_cleanup call in here belongs in ->release, but the >> qxl_destroy_monitors_object feels like should be perfectly fine in the >> remove hook. You might need to sprinkle a few drm_dev_enter/exit around to >> protect code paths thought. >> >> Aside from this lgtm, for the series >> >> Acked-by: Daniel Vetter >> >> And up to you whether you want to fix this or not really. >> >> Btw for testing all these patches that add a ->release hook I think it'd >> be good if the drm core checks that drm_device->dev is set to NULL, and >> that we do this in the remove hook. Since that's guaranteed to be gone at >> that point, so anything in ->release that still needs the device is >> broken. Ofc maybe do that check only for drivers which have a ->release >> hook, and we might need a few fixups. >> > > We take a ref on the parent device in drm_dev_init() and release it in > drm_dev_fini(). I added this because of the DRM_DEV_* macros we have, to > protect access to the device struct after it was unregistered. Setting > drm_device->dev to NULL in drm_dev_unregister() instead will provide the > same protection I think. > > commit 56be6503aab2 > drm/drv: Hold ref on parent device during drm_device lifetime > > Noralf. > >> Cheers, Daniel >> >>> + qxl_device_fini(qdev); >>> + dev->dev_private = NULL; >>> + kfree(qdev); >>> +} >>> + >>> static void >>> qxl_pci_remove(struct pci_dev *pdev) >>> { >>> struct drm_device *dev = pci_get_drvdata(pdev); >>> - struct qxl_device *qdev = dev->dev_private; >>> >>> drm_dev_unregister(dev); >>> - >>> - qxl_modeset_fini(qdev); >>> - qxl_device_fini(qdev); >>> + drm_atomic_helper_shutdown(dev); >>> if (is_vga(pdev)) >>> vga_put(pdev, VGA_RSRC_LEGACY_IO); >>> - >>> - dev->dev_private = NULL; >>> - kfree(qdev); >>> drm_dev_put(dev); >>> } >>> >>> @@ -279,6 +289,8 @@ static struct drm_driver qxl_driver = { >>> .major = 0, >>> .minor = 1, >>> .patchlevel = 0, >>> + >>> + .release = qxl_drm_release, >>> }; >>> >>> static int __init qxl_init(void) >>> -- >>> 2.18.1 >>> >> > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel >