Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp33609yba; Fri, 5 Apr 2019 01:12:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwH+SIxi1FCbffJFOpYi4YrnK6Xs5OpgJo9N/lUnxrF67PMVE9vgHWjuJRpL4UHQhg4669k X-Received: by 2002:aa7:85d9:: with SMTP id z25mr10962115pfn.31.1554451977436; Fri, 05 Apr 2019 01:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554451977; cv=none; d=google.com; s=arc-20160816; b=q8l/uKqx115wJ/+hehCq2kiUs8xKilgD9OEfSouFoBwHR+v4ibfAkItY5snsxY/lgT 1H4iz7yWg+inoscI1Co0DOyzC1DqrE9VSt0LygpEBQYsZekt3vAmMZuOmrUUci+7qjTg v5R2m8HYSdsxg1EdEiDJBdID2GEElsc/oIz1Vv5AdIDTbUN/d861lkc3KEzemUnAG1SX vCF9DxwrowUlqHqyY0/bZVgnVFV9wSJLtF+Go7/ZMd4Td0JMitpPzRdK+yNQXd9+sVjQ SLW5vaguByzfzFz22sCrH4FEoE4YuaIrxoAuuF4dHPzXASUfdy+XWKdOmgk6z6jRsUSm d7ew== 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:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=rqxJoN8X09a0XPcQ8jrN1bplBeIeTAFi/N+ypLwZpls=; b=OY34lnh0CBmCow06YvFNEcMP1jTHwk9wNURKl6fxHRi5PTW+3IgaMjW9c8bQl5afaa PBbUBWn2MX83k42GL5asYIVkvbWcUy8f393v7UWXneIM8Tb2sYg0pd/hH7yGtbc4C/30 7XSR8sLUl2Mc+ViZ905mKTutaZD3hGpWj5jkYO0BxnPlxC5c++5arVP+IQWS5R90rb28 wRlvRSpa13J9rjMMdock2d8NOfXcQjQ6jNbksd0liUcBF7jfWuhgu8t6ALquomODKe3I s1PoB2NT1OuvyEUIynv9YKN1vAvD/yrNykziyB0akwOuaZmu+rYRu4CcjZ5/q4P4wDGj xjKA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si18788812pgx.484.2019.04.05.01.12.42; Fri, 05 Apr 2019 01:12:57 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730329AbfDEIMA (ORCPT + 99 others); Fri, 5 Apr 2019 04:12:00 -0400 Received: from mga09.intel.com ([134.134.136.24]:62751 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbfDEIL7 (ORCPT ); Fri, 5 Apr 2019 04:11:59 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2019 01:11:59 -0700 X-IronPort-AV: E=Sophos;i="5.60,310,1549958400"; d="scan'208";a="133178609" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 05 Apr 2019 01:11:56 -0700 Message-ID: <51c51c4d1a2facbc1dfb240b94377027e263872e.camel@linux.intel.com> Subject: Re: [PATCH] drm/i915: Use drm_dev_unplug() From: Janusz Krzysztofik To: Chris Wilson 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 Date: Fri, 05 Apr 2019 10:11:54 +0200 In-Reply-To: <155445007634.8259.18397004914881394541@skylake-alporthouse-com> References: <20190405072657.9997-1-janusz.krzysztofik@linux.intel.com> <155445007634.8259.18397004914881394541@skylake-alporthouse-com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Thanks, Janusz > -Chris > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel