From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35B73C433E5 for ; Thu, 23 Jul 2020 17:44:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 15B1A207BB for ; Thu, 23 Jul 2020 17:44:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15B1A207BB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 17D166E2DC; Thu, 23 Jul 2020 17:44:12 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8976E6E2D7; Thu, 23 Jul 2020 17:44:10 +0000 (UTC) IronPort-SDR: Grw6GeDzqg6YLDk5VR6YBPJHsFsiiInI/G3dDQxuAeGPs76aBznqCIE566Xj7aYAlCsrZHvEve Sh5+OLpYHDKw== X-IronPort-AV: E=McAfee;i="6000,8403,9691"; a="130664632" X-IronPort-AV: E=Sophos;i="5.75,387,1589266800"; d="scan'208";a="130664632" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jul 2020 10:44:09 -0700 IronPort-SDR: qoDZPp8xaBOFuq8BdYHacEb11LDbs/vj66/URjxsNfr5myN8nr/LqL2N4HUSA2SvLpJwgXlG9N 21tyO8bxADPg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,387,1589266800"; d="scan'208";a="328639284" Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by orsmga007.jf.intel.com with ESMTP; 23 Jul 2020 10:44:09 -0700 Received: from orsmsx121.amr.corp.intel.com (10.22.225.226) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 23 Jul 2020 10:44:09 -0700 Received: from orsmsx163.amr.corp.intel.com ([169.254.9.101]) by ORSMSX121.amr.corp.intel.com ([169.254.10.71]) with mapi id 14.03.0439.000; Thu, 23 Jul 2020 10:44:09 -0700 From: "Tang, CQ" To: Chris Wilson , "intel-gfx@lists.freedesktop.org" Thread-Topic: [PATCH 2/3] drm/i915/gem: Move context decoupling from postclose to preclose Thread-Index: AQHWYRW0ju6h2xQdSEex8T/aQszD5akVbtQQ Date: Thu, 23 Jul 2020 17:44:08 +0000 Message-ID: <1D440B9B88E22A4ABEF89F9F1F81BC290117BC5431@ORSMSX163.amr.corp.intel.com> References: <20200723172119.17649-1-chris@chris-wilson.co.uk> <20200723172119.17649-2-chris@chris-wilson.co.uk> In-Reply-To: <20200723172119.17649-2-chris@chris-wilson.co.uk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Subject: Re: [Intel-gfx] [PATCH 2/3] drm/i915/gem: Move context decoupling from postclose to preclose X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Vetter, Daniel" , "stable@vger.kernel.org" , "dri-devel@lists.freedesktop.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" > -----Original Message----- > From: Chris Wilson > Sent: Thursday, July 23, 2020 10:21 AM > To: intel-gfx@lists.freedesktop.org > Cc: dri-devel@lists.freedesktop.org; Chris Wilson ; > Tang, CQ ; Vetter, Daniel ; > stable@vger.kernel.org > Subject: [PATCH 2/3] drm/i915/gem: Move context decoupling from > postclose to preclose > > Since the GEM contexts refer to other GEM state, we need to nerf those > pointers before that state is freed during drm_gem_release(). We need to > move i915_gem_context_close() from the postclose callback to the preclose. > > In particular, debugfs likes to peek into the GEM contexts, and from there > peek at the drm core objects. If the context is closed during the peeking, we > may attempt to dereference a stale core object. > > Signed-off-by: Chris Wilson > Cc: CQ Tang > Cc: Daniel Vetter > Cc: stable@vger.kernel.org > --- > drivers/gpu/drm/i915/i915_drv.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/i915_drv.c > b/drivers/gpu/drm/i915/i915_drv.c index 5fd5af4bc855..15242a8c70f7 100644 > --- a/drivers/gpu/drm/i915/i915_drv.c > +++ b/drivers/gpu/drm/i915/i915_drv.c > @@ -1114,11 +1114,15 @@ static void i915_driver_lastclose(struct > drm_device *dev) > vga_switcheroo_process_delayed_switch(); > } > > +static void i915_driver_preclose(struct drm_device *dev, struct > +drm_file *file) { > + i915_gem_context_close(file); > +} > + > static void i915_driver_postclose(struct drm_device *dev, struct drm_file > *file) { > struct drm_i915_file_private *file_priv = file->driver_priv; > > - i915_gem_context_close(file); > i915_gem_release(dev, file); Now we separate i915_gem_context_close() from i915_gem_release() and other freeing code in postclose(), is there any side effect to allow code to run in between? Can we move all postclose() code into preclose()? --CQ > > kfree_rcu(file_priv, rcu); > @@ -1850,6 +1854,7 @@ static struct drm_driver driver = { > .release = i915_driver_release, > .open = i915_driver_open, > .lastclose = i915_driver_lastclose, > + .preclose = i915_driver_preclose, > .postclose = i915_driver_postclose, > > .gem_close_object = i915_gem_close_object, > -- > 2.20.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx