Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1226005yba; Thu, 4 Apr 2019 06:45:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzii/ps/A0gS4omClVBAI2CYmvAYFSX3k+kURUjtYxoeP8XU5eE3Ac9i39BcsfBjiHJOOhs X-Received: by 2002:a17:902:a506:: with SMTP id s6mr6312286plq.164.1554385557729; Thu, 04 Apr 2019 06:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554385557; cv=none; d=google.com; s=arc-20160816; b=ntgopFxVCQ0kT/0AIwFGiy2s08+THy7reYVdjm2JRVBm5dYcFvoNsdwGdy+MnCY7ww rtzeoyLdeB5EjtBDOQq3h8ffyxg3196ZjzYqnYI0m+16Kae+khsMIiQRDRy29tE7lFld WUxVMvISSuceizhJ8a+3W23ki7RkI+MJVyureShrflTtDkObs3QOees+RRhiESOlPiQa lcs+c4DqvuvibwAdbv+Jil1eCMuwQHVli/sLJZnW0B0j/+P1diHeI0e7zKb4b3Qw6Gnk B7QnZpgZr1OowM0JAqb6PE5zHx7cw8du4mJyG1PYky99zVUpoT6Pk8CG01KDCh6jjY+h kN0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=QbPijBkVgWKtwg7J21lCg6g4Md3gFivlPeM//p2LITk=; b=uRQSmIUeDoDIT6hQg3e3DoE1EB6EvENh/A7WL6pBICIxkcuESvvrAa4RdDm3cCQFGU 3i+O1UBwA/KGM296p4L/8nGJjGvuZ2uUfOrastSlxPXBaOU2Ekvoh1iX7QD9nVoqfM6v es3U46FkZF2mI5AkUhGS8HrgAQZPPJ7DqYYyVgBHdtgTzHWAA9wvik0bw2rJ0/XidhNT AMdZF/a8mSgr6NC+7xwqicf/UJsdgdgVxSq1cBO19YlRa0anqciMiHTLUldCIworZZmu MPvU/9kEQykOU6F97bR81QAXAeoWAmJthCyuxfufct/87jbqMP8ewCe3rtROvGYNalwe 8zDg== 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 31si3296567pli.14.2019.04.04.06.45.40; Thu, 04 Apr 2019 06:45: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 S1728902AbfDDNo6 (ORCPT + 99 others); Thu, 4 Apr 2019 09:44:58 -0400 Received: from mga18.intel.com ([134.134.136.126]:56678 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727152AbfDDNo6 (ORCPT ); Thu, 4 Apr 2019 09:44:58 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2019 06:44:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,308,1549958400"; d="scan'208";a="161354804" Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.72.79]) by fmsmga001.fm.intel.com with ESMTP; 04 Apr 2019 06:44:55 -0700 From: Jani Nikula To: Chris Wilson , Janusz Krzysztofik Cc: David Airlie , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Rodrigo Vivi Subject: Re: [Intel-gfx] [PATCH] drm/i915: Fix context IDs not released on driver hot unbind In-Reply-To: <155437522546.7532.6754257066058816161@skylake-alporthouse-com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20190404102445.12303-1-janusz.krzysztofik@linux.intel.com> <155437373474.7532.10868620123516507965@skylake-alporthouse-com> <155437462649.7532.18347010454266779928@skylake-alporthouse-com> <1bda752c136f3a75817fe257027edd8be4e7472e.camel@linux.intel.com> <155437522546.7532.6754257066058816161@skylake-alporthouse-com> Date: Thu, 04 Apr 2019 16:47:31 +0300 Message-ID: <87r2ahyj9o.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 04 Apr 2019, Chris Wilson wrote: > Quoting Janusz Krzysztofik (2019-04-04 11:50:14) >> On Thu, 2019-04-04 at 11:43 +0100, Chris Wilson wrote: >> > Quoting Janusz Krzysztofik (2019-04-04 11:40:24) >> > > On Thu, 2019-04-04 at 11:28 +0100, Chris Wilson wrote: >> > > > Quoting Janusz Krzysztofik (2019-04-04 11:24:45) >> > > > > From: Janusz Krzysztofik >> > > > > >> > > > > In case the driver gets unbound while a device is open, kernel >> > > > > panic >> > > > > may be forced if a list of allocated context IDs is not empty. >> > > > > >> > > > > When a device is open, the list may happen to be not empty >> > > > > because >> > > > > a >> > > > > context ID, once allocated by a context ID allocator to a >> > > > > context >> > > > > assosiated with that open file descriptor, is released as late >> > > > > as >> > > > > on device close. >> > > > > >> > > > > On the other hand, there is a need to release all allocated >> > > > > context >> > > > > IDs >> > > > > and destroy the context ID allocator on driver unbind, even if >> > > > > a >> > > > > device >> > > > > is open, in order to free memory resources consumed and prevent >> > > > > from >> > > > > memory leaks. The purpose of the forced kernel panic was to >> > > > > protect >> > > > > the context ID allocator from being silently destroyed if not >> > > > > all >> > > > > allocated IDs had been released. >> > > > >> > > > Those open fd are still pointing into kernel memory where the >> > > > driver >> > > > used to be. The panic is entirely correct, we should not be >> > > > unloading >> > > > the module before those dangling pointers have been made safe. >> > > > >> > > > This is papering over the symptom. How is the module being >> > > > unloaded >> > > > with >> > > > open fd? >> > > >> > > A user can play with the driver unbind or device remove sysfs >> > > interface. >> > >> > Sure, but we must still follow all the steps before _unloading_ the >> > module or else the user is left pointing into reused kernel memory. >> >> I'm not talking about unloading the module, that is prevented by open >> fds. The driver still exists after being unbound from a device and may >> just respond with -ENODEV. > > i915_gem_contexts_fini() *is* module unload. Janusz, please describe what you're doing exactly. BR, Jani. -- Jani Nikula, Intel Open Source Graphics Center