Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp42313yba; Fri, 5 Apr 2019 01:26:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKn6kaLv3gz4B8XYTHM4ljdKMhJvfUZ2P/pdYhT8tH8ImrpHxb1+vO0rP3OF0tVhTqs4fJ X-Received: by 2002:a65:608a:: with SMTP id t10mr156971pgu.125.1554452818526; Fri, 05 Apr 2019 01:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554452818; cv=none; d=google.com; s=arc-20160816; b=JgMhNGmMnnpvmaAbypZ4wCe3GpUyfBMzooo/vvmNpOkZiMvZguL3ZTtXmrQ9Ftyiki QFHYwlG6Xv9JUTv8IIIXOkVBABglytg75LCDLkd6cwSueGBhYws4xZ2hOU2GqigJnMrz Ea8o+CJTG2b5gDwZI29q/M9nVOaP49Q2bWd/11i1D3itO7XcfhoeSVoQc4HTnQoLyVQJ JbhBhQvHINtEpnXIodQtKJO0Yxp+bIUZ1esLNd8VZJYjECa6MTFoVUsvpQIrxHUSrz/S la6Hze02R/DTT2Yht4EEe0u0KY5Y5fSSRGCwe9se4cnfo/Au3vuanyExrXRgbjtejxDT Z4zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version; bh=d2LHpPXsFdWnCIotd1GmZsJqtZh0AMludXldKh3bTyw=; b=Dix81flF5DFKul7ZSc39qiCu7nvsNc0vkLx3lBTyINfACOAhmKkiZ67zO3ki63Hysz RLMLXsauUaS/FeKrnF9BlfHIflYwAtLfyvJyBJJWc00IfyQQUJaH9OyhGnhsbniGjuv8 Ps1OTLSiPXUMjY32FCPL7PTGh2UYIev2Vkotn1tDqkUuMxyoS5IVkAp0AQ6GM3S86/ad UaGcMBQw2BcocD9jg3lUYlUOnWJN4qBqhwF6oB2vGkbFtWqMWzy1EkbX6XRsIdBSOy2L F5iTzW0nBGmeDQnZ/bJDo/HG0HyRaoUuH8joc0zpnM1cZZa9coS5pPnbd72Ai/UlHDJh vHPg== ARC-Authentication-Results: i=1; mx.google.com; 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 a82si5364363pfj.255.2019.04.05.01.26.43; Fri, 05 Apr 2019 01:26:58 -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; 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 S1730424AbfDEIZH convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 Apr 2019 04:25:07 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:58208 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730392AbfDEIZG (ORCPT ); Fri, 5 Apr 2019 04:25:06 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 16140366-1500050 for multiple; Fri, 05 Apr 2019 09:24:51 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Janusz Krzysztofik From: Chris Wilson In-Reply-To: <51c51c4d1a2facbc1dfb240b94377027e263872e.camel@linux.intel.com> Cc: David Airlie , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, michal.wajdeczko@intel.com, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi References: <20190405072657.9997-1-janusz.krzysztofik@linux.intel.com> <155445007634.8259.18397004914881394541@skylake-alporthouse-com> <51c51c4d1a2facbc1dfb240b94377027e263872e.camel@linux.intel.com> Message-ID: <155445268803.8259.16095445514284244974@skylake-alporthouse-com> User-Agent: alot/0.6 Subject: Re: [PATCH] drm/i915: Use drm_dev_unplug() Date: Fri, 05 Apr 2019 09:24:48 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Janusz Krzysztofik (2019-04-05 09:11:54) > On Fri, 2019-04-05 at 08:41 +0100, Chris Wilson wrote: > > Quoting Janusz Krzysztofik (2019-04-05 08:26:57) > > > From: Janusz Krzysztofik > > > > > > The driver does not currently support unbinding from a device which > > > is > > > in use. Since open file descriptors may still be pointing into > > > kernel > > > memory where the device structures used to be, entirely correct > > > kernel > > > panics protect the driver from being unbound as we should not be > > > unbinding it before those dangling pointers have been made safe. > > > > > > According to the documentation found inside > > > drivers/gpu/drm/drm_drv.c, > > > drm_dev_unplug() should be used instead of drm_dev_unregister() in > > > order to make a device inaccessible to users as soon as it is > > > unpluged. > > > Follow that advice to make those possibly dangling pointers safe, > > > protected by DRM layer from a user who is otherwise left pointing > > > into > > > possibly reused kernel memory after the driver has been unbound > > > from > > > the device. > > > > > > Signed-off-by: Janusz Krzysztofik > > > --- > > > drivers/gpu/drm/i915/i915_drv.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/gpu/drm/i915/i915_drv.c > > > b/drivers/gpu/drm/i915/i915_drv.c > > > index 9df65d386d11..66163378c481 100644 > > > --- a/drivers/gpu/drm/i915/i915_drv.c > > > +++ b/drivers/gpu/drm/i915/i915_drv.c > > > @@ -1596,7 +1596,7 @@ static void i915_driver_unregister(struct > > > drm_i915_private *dev_priv) > > > i915_pmu_unregister(dev_priv); > > > > > > i915_teardown_sysfs(dev_priv); > > > - drm_dev_unregister(&dev_priv->drm); > > > + drm_dev_unplug(&dev_priv->drm); > > > > I think we may have our onion inverted here. We want to stop the > > users > > as the first step, then start removing the entries. (That will also > > nicely invert the order from register, which is what we typically > > expect). > > > > After calling i915_driver_unregister(); call i915_gem_set_wedged() to > > immediately (give or take external fences) cancel inflight > > operations. > > OK, thanks. Do you prefer them squashed or as serparate patches? Quite happy to do the s/unregister/unplug/ and move in one go. Have a pre-emptive Reviewed-by: Chris Wilson on that as that seems to be the right thing to do. And there should be no issues in placing a i915_gem_set_wedged() immediately after the call to i915_driver_unregister, so if you include a line of commentary about why, for example /* * After unregistering the device to prevent any new users, cancel * all in-flight requests so that we can quickly unbind the active * resources. */ i915_gem_set_wedged(dev_priv); Reviewed-by: Chris Wilson I think overall though, we need to go through i915_driver_unload() and push the module cleanup operations to i915_driver_release -- that will take a bit of surgery to separate the different phases that are currently smashed together. -Chris