Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1075310yba; Thu, 4 Apr 2019 03:51:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPUwG3o2BEgtZMXkTK/Qqw85GPxL6LGYcgkrZ5b78JYUtqE1KGFy9DakDH1vjnQ3tQbvvA X-Received: by 2002:a63:df12:: with SMTP id u18mr5142597pgg.135.1554375079270; Thu, 04 Apr 2019 03:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554375079; cv=none; d=google.com; s=arc-20160816; b=CSocLuSRXeDJQYg96ixMmCZhFrLBRgvXxbv3y8wDKvSZEEeTywcI+5WqecAMt5CrMo 0pQnf8a6MraDave5JKO/A0TrvjXeaw14z+83vxN9QGJuUTi6JYN9LX1os9UusLLwwLJV ruVwmUdM/qHYu5YZZTB26fFTyNpe2ftZaCEuVtl8EdMA87RkaqgaSkR5afaXh0NmakXs IaFEaHGL+SeAFKDmKO7ZtkByYowvu1uKCUthjANXoNRbLXOnG9VUlS37yySmIzD/raV4 dNCV466u8+XMoY88NxsVdoqU6yM1Bx1AWzYrNzNfe51Wq2dmIDKdr7r00P8E9Z2U5gfr sTIw== 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=uY69qDP+vL5JGCnQZqBQcLr7kkk/jERrmirchpnpGEc=; b=zh6TufZb+OwdgdEcyZ0DiecxJJSbwytu+sbwrNBIImIcvcFVxhabNy0cZs/9763K7n kOxG68VVAvokSBSSGXddu6g7nKM8DLDONSuzgsLL4svRMj0Z3JIgECG14o6gq4bsHSia xMNKnbWI86ZdXIBCYwjIAoOLIt3vcXfpH5ylRYf8ORVvOaWza8AWe8KkERBIT7wPhTuC z+Snc34CbZZyNwoE4W1P8TOzhhzBPsfooHszw8xSnqIHvQO4qn5RwbEaICgOO3yM6Ng0 bGJJVdoNTO/hRl7liRAAxStz/xdCQIQXw/RxjF9GxU/QCC6VxgEnj5ICXy/tfEc4gZr5 BA1w== 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 y66si11926213pgy.186.2019.04.04.03.51.03; Thu, 04 Apr 2019 03:51:19 -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 S1729196AbfDDKuT (ORCPT + 99 others); Thu, 4 Apr 2019 06:50:19 -0400 Received: from mga06.intel.com ([134.134.136.31]:14924 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726694AbfDDKuT (ORCPT ); Thu, 4 Apr 2019 06:50:19 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2019 03:50:18 -0700 X-IronPort-AV: E=Sophos;i="5.60,308,1549958400"; d="scan'208";a="220486012" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 04 Apr 2019 03:50:16 -0700 Message-ID: <1bda752c136f3a75817fe257027edd8be4e7472e.camel@linux.intel.com> Subject: Re: [Intel-gfx] [PATCH] drm/i915: Fix context IDs not released on driver hot unbind From: Janusz Krzysztofik To: Chris Wilson Cc: David Airlie , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Rodrigo Vivi Date: Thu, 04 Apr 2019 12:50:14 +0200 In-Reply-To: <155437462649.7532.18347010454266779928@skylake-alporthouse-com> References: <20190404102445.12303-1-janusz.krzysztofik@linux.intel.com> <155437373474.7532.10868620123516507965@skylake-alporthouse-com> <155437462649.7532.18347010454266779928@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 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. Janusz > -Chris > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel