From nobody Tue Jun 16 18:01:53 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A51DC31F989; Thu, 30 Apr 2026 15:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777561877; cv=none; b=EEMKXjhnUzCizmzcZ5pt1pH5pEP2on6S1L9AF3mP9R+Ml7gwUmZbpm/J1LPgDQXZLxWjyy2lIcM86aCVkb8TNqOkNLMirVOR5kMY1gQUt659hIV4gyrUGlbR/uWXBmWriStMIeVJjCHkks7gn62JtYXQOTajBfVkHKE8KjKhRhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777561877; c=relaxed/simple; bh=+nd8s7gfQp/En4pd5u3HKu50CUSpxEmkHUSDYTDjb90=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SjVry6/q3wVTlfhdodNrCMMteNghxvb9wwBZhNbIcn92YUisqcGVq4BAaWfs/36DA2nl0hIe/Xn9SEX9Uxya/8pOREOLkx6LaorIDIw7rIWALNiqW8DwtY8kdHCvf+4FOTw+vfKwrZlk/1PsPKYPsFAsVzyZZIqQlfSVIZAjSu8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HC45SvdN; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HC45SvdN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777561875; x=1809097875; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+nd8s7gfQp/En4pd5u3HKu50CUSpxEmkHUSDYTDjb90=; b=HC45SvdN3ur0HO7Kj4yl68CvMyX0CCScpMt5oj9d59QitCCLM+KUPEXo Qd0pa0df5Z/KXwfJXfLLZfcl+qOBp+95Fi2MYDzoxkDcwQF9gGum86Z78 Z2e8tyZMSE1s0HJt/czoGG7PDiu6abvTHrGoG6TIaaI8DA0I9wCDdVqek lT7ahaRFFphgURobygINk2AWrPBhD0GuCvuAp5H05O3YLe5fp+sxE1FE2 4oDp8OI6Md173bzYy8CZu4/8u1gGMQQwUwrMRisAMOkWgEMEzDrJZWyeE UPxbO8mAMGlQxy2M+xlDMWrCs2UkW6sRCI7JF07qva/rjlSFI0lBsPLCt A==; X-CSE-ConnectionGUID: kG0tY0xLSkmAc+yrVw7Gfg== X-CSE-MsgGUID: WoRnRFbVTsqZUtdgqB8LIg== X-IronPort-AV: E=McAfee;i="6800,10657,11772"; a="88828154" X-IronPort-AV: E=Sophos;i="6.23,208,1770624000"; d="scan'208";a="88828154" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2026 08:11:12 -0700 X-CSE-ConnectionGUID: tABge+VjRT+Eoa4UVinWHw== X-CSE-MsgGUID: 80Db9/bNT3GDQOdFX4FS+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,208,1770624000"; d="scan'208";a="258194278" Received: from spandruv-desk.jf.intel.com ([10.54.55.20]) by fmviesa001.fm.intel.com with ESMTP; 30 Apr 2026 08:11:12 -0700 From: Srinivas Pandruvada To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Stable@vger.kernel.org Subject: [PATCH v2 1/3] platform/x86: intel: Move debugfs register before creating devices Date: Thu, 30 Apr 2026 08:11:01 -0700 Message-ID: <20260430151103.1549733-2-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260430151103.1549733-1-srinivas.pandruvada@linux.intel.com> References: <20260430151103.1549733-1-srinivas.pandruvada@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It is possible that the driver handling device is enumerated before registering debugfs. If the driver wants to access debugfs by calling tpmi_get_debugfs_dir(), this will return error in this case. Hence register debugfs before creating devices. Fixes: 811f67c51636 ("platform/x86/intel/tpmi: Add new auxiliary driver for= performance limits") Signed-off-by: Srinivas Pandruvada Cc: --- v2: No change drivers/platform/x86/intel/vsec_tpmi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/intel/vsec_tpmi.c b/drivers/platform/x86/= intel/vsec_tpmi.c index 7fc6ff8d1040..a38014e81e85 100644 --- a/drivers/platform/x86/intel/vsec_tpmi.c +++ b/drivers/platform/x86/intel/vsec_tpmi.c @@ -817,10 +817,6 @@ static int intel_vsec_tpmi_init(struct auxiliary_devic= e *auxdev) =20 auxiliary_set_drvdata(auxdev, tpmi_info); =20 - ret =3D tpmi_create_devices(tpmi_info); - if (ret) - return ret; - /* * Allow debugfs when security policy allows. Everything this debugfs * interface provides, can also be done via /dev/mem access. If @@ -830,6 +826,12 @@ static int intel_vsec_tpmi_init(struct auxiliary_devic= e *auxdev) if (!security_locked_down(LOCKDOWN_DEV_MEM) && capable(CAP_SYS_RAWIO)) tpmi_dbgfs_register(tpmi_info); =20 + ret =3D tpmi_create_devices(tpmi_info); + if (ret) { + debugfs_remove_recursive(tpmi_info->dbgfs_dir); + return ret; + } + return 0; } =20 --=20 2.52.0 From nobody Tue Jun 16 18:01:53 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBF652D0617; Thu, 30 Apr 2026 15:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777561877; cv=none; b=r2PJAhD7x8GkfoA1+ZmSLSdkS3MRRc4YvYyuA0Z8tbPH9CgkQDHtSEyZ7WVvf5mzDYmRW4aer5DoX9cdM/UCDprykKust57GIMrtV3ovahqjkZEq2uvx8XeUheBKoK+QZaJcBqdlkdH49wv5/9XSnn+avJmrLMJjntMIGYazoQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777561877; c=relaxed/simple; bh=RpSxg8XS1qS2UN+yR2n8TCnuE1CcA6X3EuBwp033rjs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ko8PE087MgRkqoK90nLTCT/DQNrv6TXuMD2e0F7J+LLsNHAMA3ZzgZYMcb/fMYp4kcMqcwZ3lsV6xSXuAecoqrEkmvaB/Ll1E8AVEPEEu53FDxANVXNtjkd2LrI/dMWAVWdfb/ptcWUTeiWfccf8MY7sKeD0K8hlWKJ4Z1QpFW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QKCL925D; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QKCL925D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777561876; x=1809097876; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RpSxg8XS1qS2UN+yR2n8TCnuE1CcA6X3EuBwp033rjs=; b=QKCL925DVl7CyXpBPmzEdBB/WLpgrSpbA9PYZmFMC+2ysLq3+GTJLmZZ U/UBAkquvdsApDIJqaxihxlYwmnS71MtLuCjdFFWgr01ovrFbChIOu8u5 dfgf3RRqLONzPt4OhNSuTOCIsR9skQDyQSH4GQX1HpDqY7mm2WIuR3W3i FlwjjHuqEbpbm1e8tW4MhtRlELry0XlrDaN+9OCGB/U43aB0R/jAh74nS oOjjwGkyDeH6zdJJup7qe2llEjPUsVqxQv1/pAccHrbOFL/hbKaw00nIH zU7eRfNCcSh1FwSGOcnA8ZGo3f+Tp+mXgCpPtyM0QlPuNMSUYBwOUS83i A==; X-CSE-ConnectionGUID: olRb7kFqQfeo+taPFzt60Q== X-CSE-MsgGUID: gYb0hPSVQDm7dvbCVYl8aQ== X-IronPort-AV: E=McAfee;i="6800,10657,11772"; a="88828156" X-IronPort-AV: E=Sophos;i="6.23,208,1770624000"; d="scan'208";a="88828156" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2026 08:11:12 -0700 X-CSE-ConnectionGUID: ge4lzdaTRJOZA7oQpJ65dw== X-CSE-MsgGUID: c/l6jQYZT/y00+55gch+Mg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,208,1770624000"; d="scan'208";a="258194279" Received: from spandruv-desk.jf.intel.com ([10.54.55.20]) by fmviesa001.fm.intel.com with ESMTP; 30 Apr 2026 08:11:12 -0700 From: Srinivas Pandruvada To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Stable@vger.kernel.org Subject: [PATCH v2 2/3] platform/x86: intel: Add notifiers support Date: Thu, 30 Apr 2026 08:11:02 -0700 Message-ID: <20260430151103.1549733-3-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260430151103.1549733-1-srinivas.pandruvada@linux.intel.com> References: <20260430151103.1549733-1-srinivas.pandruvada@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In some cases a driver using services of vsec_tpmi driver requires some processing before vsec_tpmi exits. For example a children using debugfs can't use debugfs as this will be deleted by the vsec_tpmi driver. This is the case when unbind using PCI driver interface. In this case the remove callback of vsec_tpmi driver is called first, then remove callback of its children. Add support of blocking chain notifiers support. Notify on successful probe and before clean up in the remove callback. Fixes: 811f67c51636 ("platform/x86/intel/tpmi: Add new auxiliary driver for= performance limits") Signed-off-by: Srinivas Pandruvada Cc: --- v2: No change drivers/platform/x86/intel/vsec_tpmi.c | 19 +++++++++++++++++++ include/linux/intel_tpmi.h | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/platform/x86/intel/vsec_tpmi.c b/drivers/platform/x86/= intel/vsec_tpmi.c index a38014e81e85..16fd7aa41f20 100644 --- a/drivers/platform/x86/intel/vsec_tpmi.c +++ b/drivers/platform/x86/intel/vsec_tpmi.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -188,6 +189,20 @@ struct tpmi_feature_state { /* Used during auxbus device creation */ static DEFINE_IDA(intel_vsec_tpmi_ida); =20 +static BLOCKING_NOTIFIER_HEAD(tpmi_notify_list); + +int tpmi_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&tpmi_notify_list, nb); +} +EXPORT_SYMBOL_NS_GPL(tpmi_register_notifier, "INTEL_TPMI"); + +int tpmi_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&tpmi_notify_list, nb); +} +EXPORT_SYMBOL_NS_GPL(tpmi_unregister_notifier, "INTEL_TPMI"); + struct oobmsm_plat_info *tpmi_get_platform_data(struct auxiliary_device *a= uxdev) { struct intel_vsec_device *vsec_dev =3D auxdev_to_ivdev(auxdev); @@ -832,6 +847,8 @@ static int intel_vsec_tpmi_init(struct auxiliary_device= *auxdev) return ret; } =20 + blocking_notifier_call_chain(&tpmi_notify_list, TPMI_CORE_INIT, auxdev); + return 0; } =20 @@ -845,6 +862,8 @@ static void tpmi_remove(struct auxiliary_device *auxdev) { struct intel_tpmi_info *tpmi_info =3D auxiliary_get_drvdata(auxdev); =20 + blocking_notifier_call_chain(&tpmi_notify_list, TPMI_CORE_EXIT, auxdev); + debugfs_remove_recursive(tpmi_info->dbgfs_dir); } =20 diff --git a/include/linux/intel_tpmi.h b/include/linux/intel_tpmi.h index 94c06bf214fb..15f02422e9ca 100644 --- a/include/linux/intel_tpmi.h +++ b/include/linux/intel_tpmi.h @@ -28,6 +28,12 @@ enum intel_tpmi_id { TPMI_INFO_ID =3D 0x81, /* Special ID for PCI BDF and Package ID informati= on */ }; =20 +#define TPMI_CORE_INIT 0 +#define TPMI_CORE_EXIT 1 + +int tpmi_register_notifier(struct notifier_block *nb); +int tpmi_unregister_notifier(struct notifier_block *nb); + struct oobmsm_plat_info *tpmi_get_platform_data(struct auxiliary_device *a= uxdev); struct resource *tpmi_get_resource_at_index(struct auxiliary_device *auxde= v, int index); int tpmi_get_resource_count(struct auxiliary_device *auxdev); --=20 2.52.0 From nobody Tue Jun 16 18:01:53 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56721324B1F; Thu, 30 Apr 2026 15:11:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777561878; cv=none; b=htmt5/2pP6Txpz199QRVpGivmLz09eHkKLXJsJO0K9kSbLAaiTqKhitcG1GEj3R4hviHv7fi8sFas1J7hUzIFr34cTDaCEtv+4IKBLvcouFOE0U7oNLmiCuna+tFFZSVvHam20P1AGAJbHrtXczPSPeCfdRlEPxAZ1Abw5s+xuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777561878; c=relaxed/simple; bh=/jT3UsAf2htYJdjwVD6d9uXLNHV3tNM4nopKh9VVdD8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m4IPoyhZZuk8diFKVo5WdeyzY5ih/t8A81Ox0FR0Lg/fnp/PpcoACdcpcVsZSl6q5tGzLHT2B/xMtgyjFXcGo3fOd8VRgMr6B14AY+SzTDzBBa1msfSUzCUZSZ7SIbOfmi/YYsp2QAjneoyQiXpsGFgN6eeZ5fVlioKQEXl/FPY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=PPrldHTt; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PPrldHTt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777561877; x=1809097877; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/jT3UsAf2htYJdjwVD6d9uXLNHV3tNM4nopKh9VVdD8=; b=PPrldHTtD/Lw40zeXdO/Y22850tEg+lbp2z1YwWHT8myzycPYQS5vqug kZByaRKUQUWyyNtqumCROuFV2nsD3jkLb7KmhuouV4scvNzngmT6f5vP4 IMK02ysYvWU/k3sULUvKwR7RogiJuRtIX0SjGOskucE9sAhqCZ0miMDrK gC3gsWm3aKsYbZHyNp1/hC1VZwowA0ubxFhD1mrukOKfOwgVSytI243sC O/8gFmqNsEBfn+xOz9VgmzQY6UxcwNg6ZkbczkL6rMSWMAGC5g2g7Thbn P53D2CSJ+MPzObDOiIm+2RrEQSeNOxO6N7rPab1dLlXul7bYa7FW/5X6b w==; X-CSE-ConnectionGUID: gLNmTwSOTzu6ZagwvkYJKw== X-CSE-MsgGUID: u81kZPpIS+y/9V3EwEAD6g== X-IronPort-AV: E=McAfee;i="6800,10657,11772"; a="88828158" X-IronPort-AV: E=Sophos;i="6.23,208,1770624000"; d="scan'208";a="88828158" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2026 08:11:12 -0700 X-CSE-ConnectionGUID: /9pW+huzRZ27zhItRzS4YA== X-CSE-MsgGUID: wtaBE7FPQ8KpFsF9WB95tQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,208,1770624000"; d="scan'208";a="258194280" Received: from spandruv-desk.jf.intel.com ([10.54.55.20]) by fmviesa001.fm.intel.com with ESMTP; 30 Apr 2026 08:11:12 -0700 From: Srinivas Pandruvada To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Stable@vger.kernel.org Subject: [PATCH v2 3/3] platform/x86/intel/tpmi/plr: Prevent fault during unbind Date: Thu, 30 Apr 2026 08:11:03 -0700 Message-ID: <20260430151103.1549733-4-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260430151103.1549733-1-srinivas.pandruvada@linux.intel.com> References: <20260430151103.1549733-1-srinivas.pandruvada@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This driver faults when intel vsec driver unbound from PCI driver interface. For example: echo 0000:00:03.1 > /sys/bus/pci/drivers/intel_vsec/unbind This is caused by accessing plr->dbgfs_dir after vsec_tpmi driver is removed. Here vsec_tpmi driver is the parent. On unbind, the parent device remove callback is called first which here will remove debugfs interface. Hence plr->dbgfs_dir is no longer valid. Register notifier for TPMI_CORE_EXIT and make this pointer to NULL, so that debugfs_remove_recursive() is not called with bad plr->dbgfs_dir pointer. After notifier is returned the vsec_tpmi driver will call remove debugfs by calling debugfs_remove_recursive(). Fixes: 811f67c51636 ("platform/x86/intel/tpmi: Add new auxiliary driver for= performance limits") Signed-off-by: Srinivas Pandruvada Cc: --- v2: Replace mutex_init to devm_mutex_init Space in the comment for new mutex drivers/platform/x86/intel/plr_tpmi.c | 45 +++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel/plr_tpmi.c b/drivers/platform/x86/i= ntel/plr_tpmi.c index 05727169f49c..8faecc311038 100644 --- a/drivers/platform/x86/intel/plr_tpmi.c +++ b/drivers/platform/x86/intel/plr_tpmi.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,8 @@ struct tpmi_plr { struct tpmi_plr_die *die_info; int num_dies; struct auxiliary_device *auxdev; + struct notifier_block nb; + struct mutex lock; /* Protect access to dbgfs_dir */ }; =20 static const char * const plr_coarse_reasons[] =3D { @@ -255,6 +258,30 @@ static ssize_t plr_status_write(struct file *filp, con= st char __user *ubuf, } DEFINE_SHOW_STORE_ATTRIBUTE(plr_status); =20 +static int intel_plr_notify(struct notifier_block *self, unsigned long act= ion, void *data) +{ + struct tpmi_plr *plr =3D container_of(self, struct tpmi_plr, nb); + + if (action =3D=3D TPMI_CORE_EXIT) { + guard(mutex)(&plr->lock); + plr->dbgfs_dir =3D NULL; + } + + return NOTIFY_DONE; +} + +static int intel_plr_register_notifier(struct notifier_block *nb) +{ + nb->notifier_call =3D intel_plr_notify; + nb->priority =3D 0; + return tpmi_register_notifier(nb); +} + +static void intel_plr_unregister_notifier(struct notifier_block *nb) +{ + tpmi_unregister_notifier(nb); +} + static int intel_plr_probe(struct auxiliary_device *auxdev, const struct a= uxiliary_device_id *id) { struct oobmsm_plat_info *plat_info; @@ -282,10 +309,18 @@ static int intel_plr_probe(struct auxiliary_device *a= uxdev, const struct auxilia if (!plr) return -ENOMEM; =20 + err =3D devm_mutex_init(&auxdev->dev, &plr->lock); + if (err) + return err; + + intel_plr_register_notifier(&plr->nb); + plr->die_info =3D devm_kcalloc(&auxdev->dev, num_resources, sizeof(*plr->= die_info), GFP_KERNEL); - if (!plr->die_info) - return -ENOMEM; + if (!plr->die_info) { + err =3D -ENOMEM; + goto err_notify; + } =20 plr->num_dies =3D num_resources; plr->dbgfs_dir =3D debugfs_create_dir("plr", dentry); @@ -326,6 +361,9 @@ static int intel_plr_probe(struct auxiliary_device *aux= dev, const struct auxilia =20 err: debugfs_remove_recursive(plr->dbgfs_dir); +err_notify: + intel_plr_unregister_notifier(&plr->nb); + return err; } =20 @@ -333,6 +371,9 @@ static void intel_plr_remove(struct auxiliary_device *a= uxdev) { struct tpmi_plr *plr =3D auxiliary_get_drvdata(auxdev); =20 + intel_plr_unregister_notifier(&plr->nb); + + guard(mutex)(&plr->lock); debugfs_remove_recursive(plr->dbgfs_dir); } =20 --=20 2.52.0