Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp13635yba; Fri, 5 Apr 2019 00:42:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoz4PG1HiVsh1k5S8PQ320DqM+ma9gb64EA2wG6e5g9pAa/DgXNcd2J7BSQ45UZ4JOsMNF X-Received: by 2002:a17:902:442:: with SMTP id 60mr11407931ple.107.1554450155077; Fri, 05 Apr 2019 00:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554450155; cv=none; d=google.com; s=arc-20160816; b=bRdM8cku8l/cccO9EhgiTV1lWbfQ0k/HQFGK14V5ZSY0Vh8ldZe1Z+XWEkr6715fJD fuU11i33cys47FOmUE+dARhCJ4xVVg5lTOWSTUa3p/USjPsVZO5wo0EpbFboyt0/0Tb+ hIQtYBl4Fxs+kXwcz877808iAzvOb/isftOpFGDKnLNfja/EVUgB7UBv6HUxLV2bOHel I94NekdnuK8JYS36xzUf1wnyNNwkaBlSsCGu+W056Ig6b3qXk219QEXPUXnR3+gtUB1k tz9NIYkloWI1eLH+UuBFYIDTO4b/6Ce0XCD3S5niordVMhbIiT0AaiKi67wVcUH8L52M knQA== 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=N+daygy8SwyViPHy7FHKAKKczS9/PUxBxribLbEWvnM=; b=R/sskZEWe595qgb61S/mwX3UCok1kdq7aykA2JOyghhfEKxnHWF/rPviAyd3/pxv/W Dj6k+9Mq48WeA4c+gfLChGhmc5HiOM51dnlZUlWEq9JgEr4Yu9rlmBwficXiDl0m5PE7 LO7tNUkCljhEMoKPgD3/rqhwYxUSDX2G2aALiGx2sq4mhA23bJp468pkZKjq1azxB0xm 5td7hdAIu4Lt/1AdqlQGVzkifD2rp9gBbTzEcUsayO0qj12fqHfsARIpQs5VMxaZiefg YdXGcHQ7gAFmoAAduUn4mtyzyXKmPEbP+rhdyldfppVSQRupUcaJCbxrFWbDgCftyTiH nGmg== 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 p90si19056741pfa.18.2019.04.05.00.42.18; Fri, 05 Apr 2019 00:42:35 -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 S1730077AbfDEHlc convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 Apr 2019 03:41:32 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:52974 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729142AbfDEHlc (ORCPT ); Fri, 5 Apr 2019 03:41:32 -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 16139798-1500050 for multiple; Fri, 05 Apr 2019 08:41:19 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Jani Nikula , Janusz Krzysztofik , Joonas Lahtinen , Rodrigo Vivi From: Chris Wilson In-Reply-To: <20190405072657.9997-1-janusz.krzysztofik@linux.intel.com> Cc: David Airlie , Daniel Vetter , michal.wajdeczko@intel.com, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik References: <20190405072657.9997-1-janusz.krzysztofik@linux.intel.com> Message-ID: <155445007634.8259.18397004914881394541@skylake-alporthouse-com> User-Agent: alot/0.6 Subject: Re: [PATCH] drm/i915: Use drm_dev_unplug() Date: Fri, 05 Apr 2019 08:41:16 +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 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. -Chris