Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3826320ybi; Mon, 3 Jun 2019 00:32:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6m5yiBT7QZdd0raUbK/jcQdAhWg2bQ/gEJZjeWDpum41+YCBCa3hZDAco9T8UtKDIv9I2 X-Received: by 2002:a63:3dcf:: with SMTP id k198mr26695326pga.60.1559547130831; Mon, 03 Jun 2019 00:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559547130; cv=none; d=google.com; s=arc-20160816; b=jQQYzC+SbfIP+wjFJjZAk/7i2K4Qjp0zNrTVzJc+fffC0z8lEokdWDYDYZHpF6FRXN AAXSgK7CaEZly6KVCP0O6Ovv1pNHNoLVIl26EHgaco6UWmz3L4S55saBiiMJHLdYYhk5 mBQtQgI2uP0QL/hOv2ZLHXPKnSjR2zaxCYc0tfuZnqWvDUmHIMnz9W7Ggi7AVeVMO55z CMek5I2eKEsoemmQ/smsWa69ZNy7jpnOVfMdjOKwwV9w0dR7LexH/DeqiN2Za/vCgNbp HUiLNBRaLZXwm4CUdHkeh4DQ8m94ZsEltmNt1+kz3niDcG6m0KPTfIbTYZR97ZI6DeNq QzWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=3jjN+IUXsOjHIptTOl5JWqEKPtVcuNlnHwmJuoFFIww=; b=lh1N8WD3F2GLqSd6YFPHulUnl6W0HRQ2UJrwvFFWd4yPq6qd2Sd5xZtTXw4+N8Mx+3 /2peSq8diKiew9nQjZPG/1BSj+V6B12kQYL2QedpxU1UciQu8ci+8Kn7UavR04ky2HQk tqtEh7v6K5lPFsDV5eb5rNF1zRoAx71RCCdz2PKAZ4dkfMUxfNVtU1aw/wiUbkENbTo6 QehRJQmpQvJwzSPl9qbdQw3ep6BBGyzxo5l+VCd0acXfvFACKw5mR6c13+4NnggtxIw/ U+z6g3olk3aKjB/DzBQuZFyfyTL/xm3wMm/Tlkv1k2L3Su3N/EEvbzYEHoxwpHIUcTkK ivOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=Brcy2jdP; 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 m1si18247371pld.236.2019.06.03.00.31.54; Mon, 03 Jun 2019 00:32:10 -0700 (PDT) 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=@ffwll.ch header.s=google header.b=Brcy2jdP; 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 S1726791AbfFCH3T (ORCPT + 99 others); Mon, 3 Jun 2019 03:29:19 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:42728 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbfFCH3T (ORCPT ); Mon, 3 Jun 2019 03:29:19 -0400 Received: by mail-ed1-f68.google.com with SMTP id g24so15882028eds.9 for ; Mon, 03 Jun 2019 00:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=3jjN+IUXsOjHIptTOl5JWqEKPtVcuNlnHwmJuoFFIww=; b=Brcy2jdPXUAzNpiEHrfV7UeyzBi4k5q2V6K/4n/RcfPFRfyPDu1FGaFz9ButcF9Ecn OxvAJIQsgvIfxJbFPlOxKyfZ04aAKLq6g0Wf/x9TzIdDelElJSTqVQXLME4RycN+/78e 143aME4tWkLnlJLuI1vcJ8nZs3tZ5tY2TA2Ao= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=3jjN+IUXsOjHIptTOl5JWqEKPtVcuNlnHwmJuoFFIww=; b=FHcs3o61gnJG3OpYV0JokNSJg/sZUo2IiJVi7Hatq1Rw15uj01g3w9PG9gDMiWDsCB 0ixnv36S56yzW9kp1GlVIe/qDirVgxsHeqgqgPIGYS3QU9g51y9597JtpOXrP7X30wXi Fkn6qaxod46odBqcUkDipMcQiUb1/mZHTTe3Zr+THqpgDCF2yG9cXBp/fNo0gano6xdr /1pWCRuClD/kHY5OPJb8H+6+PPRB2XGJ/T/RXNZJHosZUa4FARCrvsP4Sg/FgXdgw04q vwhN/g+aLQuUrEjV7SAVMEVkuTqaQ6SfNsh0zb1QvIe6nrWJouPTV0NHXUObhgnm8wFy R8uQ== X-Gm-Message-State: APjAAAVtp6GpNUR4QaBCjo36Y3Mht8uk7OkEdUDEZtd6jkcHdyWyyAWR fWXDF43ry3Iwseqrvwp0P6OlFw== X-Received: by 2002:a50:ba1b:: with SMTP id g27mr7172413edc.18.1559546956944; Mon, 03 Jun 2019 00:29:16 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id c12sm3503859edt.38.2019.06.03.00.29.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jun 2019 00:29:16 -0700 (PDT) Date: Mon, 3 Jun 2019 09:29:14 +0200 From: Daniel Vetter To: Janusz Krzysztofik Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Chris Wilson , Daniel Vetter , David Airlie , Michal Wajdeczko , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] drm/i915: Split off pci_driver.remove() tail to drm_driver.release() Message-ID: <20190603072914.GB21222@phenom.ffwll.local> Mail-Followup-To: Janusz Krzysztofik , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Chris Wilson , David Airlie , Michal Wajdeczko , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20190530133105.30467-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190530133105.30467-1-janusz.krzysztofik@linux.intel.com> X-Operating-System: Linux phenom 4.14.0-3-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 30, 2019 at 03:31:05PM +0200, Janusz Krzysztofik wrote: > In order to support driver hot unbind, some cleanup operations, now > performed on PCI driver remove, must be called later, after all device > file descriptors are closed. > > Split out those operations from the tail of pci_driver.remove() > callback and put them into drm_driver.release() which is called as soon > as all references to the driver are put. As a result, those cleanups > will be now run on last drm_dev_put(), either still called from > pci_driver.remove() if all device file descriptors are already closed, > or on last drm_release() file operation. > > Signed-off-by: Janusz Krzysztofik > Reviewed-by: Chris Wilson > --- > Changelog: > v1 -> v2: > - defer intel_engines_cleanup() as well. (Chris) Just an aside, we generally keep the changelog in the commit message on dri-devel, it's occasionally useful to reference in the future. Yes that's different from some other areas of the kernel. -Daniel > > drivers/gpu/drm/i915/i915_drv.c | 17 +++++++++++++---- > drivers/gpu/drm/i915/i915_drv.h | 1 + > drivers/gpu/drm/i915/i915_gem.c | 10 +++++++++- > 3 files changed, 23 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c > index 83d2eb9e74cb..8be69f84eb6d 100644 > --- a/drivers/gpu/drm/i915/i915_drv.c > +++ b/drivers/gpu/drm/i915/i915_drv.c > @@ -738,6 +738,7 @@ static int i915_load_modeset_init(struct drm_device *dev) > > cleanup_gem: > i915_gem_suspend(dev_priv); > + i915_gem_fini_hw(dev_priv); > i915_gem_fini(dev_priv); > cleanup_modeset: > intel_modeset_cleanup(dev); > @@ -1685,7 +1686,6 @@ static void i915_driver_cleanup_hw(struct drm_i915_private *dev_priv) > pci_disable_msi(pdev); > > pm_qos_remove_request(&dev_priv->pm_qos); > - i915_ggtt_cleanup_hw(dev_priv); > } > > /** > @@ -1909,6 +1909,7 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent) > > out_cleanup_hw: > i915_driver_cleanup_hw(dev_priv); > + i915_ggtt_cleanup_hw(dev_priv); > out_cleanup_mmio: > i915_driver_cleanup_mmio(dev_priv); > out_runtime_pm_put: > @@ -1960,21 +1961,29 @@ void i915_driver_unload(struct drm_device *dev) > cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work); > i915_reset_error_state(dev_priv); > > - i915_gem_fini(dev_priv); > + i915_gem_fini_hw(dev_priv); > > intel_power_domains_fini_hw(dev_priv); > > i915_driver_cleanup_hw(dev_priv); > - i915_driver_cleanup_mmio(dev_priv); > > enable_rpm_wakeref_asserts(dev_priv); > - intel_runtime_pm_cleanup(dev_priv); > } > > static void i915_driver_release(struct drm_device *dev) > { > struct drm_i915_private *dev_priv = to_i915(dev); > > + disable_rpm_wakeref_asserts(dev_priv); > + > + i915_gem_fini(dev_priv); > + > + i915_ggtt_cleanup_hw(dev_priv); > + i915_driver_cleanup_mmio(dev_priv); > + > + enable_rpm_wakeref_asserts(dev_priv); > + intel_runtime_pm_cleanup(dev_priv); > + > i915_driver_cleanup_early(dev_priv); > i915_driver_destroy(dev_priv); > } > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h > index a2664ea1395b..d08e7bd83544 100644 > --- a/drivers/gpu/drm/i915/i915_drv.h > +++ b/drivers/gpu/drm/i915/i915_drv.h > @@ -3047,6 +3047,7 @@ void i915_gem_init_mmio(struct drm_i915_private *i915); > int __must_check i915_gem_init(struct drm_i915_private *dev_priv); > int __must_check i915_gem_init_hw(struct drm_i915_private *dev_priv); > void i915_gem_init_swizzling(struct drm_i915_private *dev_priv); > +void i915_gem_fini_hw(struct drm_i915_private *dev_priv); > void i915_gem_fini(struct drm_i915_private *dev_priv); > int i915_gem_wait_for_idle(struct drm_i915_private *dev_priv, > unsigned int flags, long timeout); > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c > index 7cafd5612f71..20d3f7532cef 100644 > --- a/drivers/gpu/drm/i915/i915_gem.c > +++ b/drivers/gpu/drm/i915/i915_gem.c > @@ -4667,7 +4667,7 @@ int i915_gem_init(struct drm_i915_private *dev_priv) > return ret; > } > > -void i915_gem_fini(struct drm_i915_private *dev_priv) > +void i915_gem_fini_hw(struct drm_i915_private *dev_priv) > { > GEM_BUG_ON(dev_priv->gt.awake); > > @@ -4680,6 +4680,14 @@ void i915_gem_fini(struct drm_i915_private *dev_priv) > mutex_lock(&dev_priv->drm.struct_mutex); > intel_uc_fini_hw(dev_priv); > intel_uc_fini(dev_priv); > + mutex_unlock(&dev_priv->drm.struct_mutex); > + > + i915_gem_drain_freed_objects(dev_priv); > +} > + > +void i915_gem_fini(struct drm_i915_private *dev_priv) > +{ > + mutex_lock(&dev_priv->drm.struct_mutex); > intel_engines_cleanup(dev_priv); > i915_gem_contexts_fini(dev_priv); > i915_gem_fini_scratch(dev_priv); > -- > 2.21.0 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch