From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.9 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795981497; b=lU/tcVG5o8leMqZTML96tXMxmC5fJehP4wp8aTPrQZp4cUWTwxtB6SHziN2tblBalHBK 5McUWD+Sdy4A+xdMsdX4LppZ+J+/HSxDUHwvP7YRbmlQo66mxP2oCzdTebrFFehfEhld8 zkmPoOoU6ibz46femy/am8ZZDJmvgTRlv/XrIDPiKcXRH+TLbKQA1shI74ERUrkl16nKu UWZ0mpNhBEvGp+v8pxuoXKMfy4GItGu60L5hKu4DRyoM0NZdLJdvcRKnwaabiVHwbpG2o aWiw+X4bGnAcRgDXEjcVd+30Yv+uDn2NZMZqGgrKybvUTddgneTduLsFKj0ltX6JJNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795981497; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=GzXd+8STQqiEAeBKZ/53OsJTJ53/LddiAwtORUOAM38=; b=iT+su7VQgWpJiCCBaCFW/TdF0Ma3qiFs9xuipeWOo4lHoSy5tJpahG5oQwfLQOYxX00W ZGqKEepIBkIV9eUsOUsh73hnHepsefkAuY30JFAd05crWnxGgGcBa6SFzUr+66AHTP+0E jAUTT/i57mNQCcpELOomr6jEGEW6+ypTRTdbDm8ZpYaEhDo18eRUu81YEKd8ppvlwu9PB bFi9d55KcUIFoFVP4gbAEIlGCbWeMoPqLqrlEtIBz1syOyeT3HKM3xRw38HbA6qLmdWJ2 kEHP+AAG948fOi+1NsyVQMJ19cl4tilgfVc5wQQdS6YnRIn5r0y0uQ23AwfQ0bwEVYw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=hhjHzrqv; arc=none smtp.remote-ip=198.175.65.9 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E524F606A333; Sun, 29 Nov 2026 19:44:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E524F606A333 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.a=rsa-sha256 header.s=Intel header.b=hhjHzrqv DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1795981497; x=1827517497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/yzxkWc0Z24NI8V/vEVo7zwXqgytvi4u6SoTy9mGnzI=; b=hhjHzrqv5Y/Vj53KVjaKo1QW9WfxQyEw8S0DDHPi+mYQYmLvKdl6fe5w 2f2ukEzeE1xdhMWOPXJktCJGwokp2Iwfxa8KGGMQ5jwaQP0f582M9XSBa TLnyKzqhj1f3TTGFF0zEo6Z6oMZCkzdu2mcylRUV6rJ8uWjsuKLohqKG3 iYCer39NCJ5r6j+f6gd4sRgxRPNi4w0QogX9uUM3lZa7BwANrQdH7Z8bV KYm2cE63bD4WOdhxEOIvSUWG5zHY9s+uExWdl/brIdRXErqPGZPMFfzXk O1VyICj6UjOg4wB4hGb9c/TDLsRppZd99HSGBa/M2yW2WSYsTIq2N4GKB Q==; X-CSE-ConnectionGUID: UFgftx+aRomMKA/vIMEYBA== X-CSE-MsgGUID: EAg/fn0KTdq8bwui9qQWiQ== X-IronPort-AV: E=McAfee;i="6800,10657,11981"; a="4720131" X-IronPort-AV: E=Sophos;i="6.27,241,1787036400"; d="scan'208";a="4720131" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2026 11:44:56 -0800 X-CSE-ConnectionGUID: e6wvoNO3SHu6/MJVjTsiug== X-CSE-MsgGUID: AeKvDTpWTkuK/qvuxhB5zw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,241,1787036400"; d="scan'208";a="12896568" Received: from spandruv-desk.jf.intel.com ([10.54.55.20]) by fmviesa005.fm.intel.com with ESMTP; 29 Nov 2026 11:44:55 -0800 From: Srinivas Pandruvada To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, kapoorarnav43@gmail.com, Srinivas Pandruvada Subject: [PATCH v2 1/2] platform/x86/intel-uncore-freq: Don't remove entries which are not added Date: Sun, 29 Nov 2026 11:44:44 -0800 Message-ID: <20261129194445.2805447-2-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261129194445.2805447-1-srinivas.pandruvada@linux.intel.com> References: <20261129194445.2805447-1-srinivas.pandruvada@linux.intel.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When uncore_probe() fails, remove_cluster_entries() removes the entries of all clusters of every mapped power domain. But not all of them are added: - When the allocation of cluster_infos fails, cluster_count is already set. So remove_cluster_entries() dereferences the NULL cluster_infos. - When uncore_freq_add_entry() fails for a cluster, this cluster and all later clusters were not added. uncore_freq_remove_die_entry() still removes their attribute group, which doesn't exist. As domain_id of these clusters is not UNCORE_DOMAIN_ID_INVALID, it also frees their seqnum_id with ida_free(). The seqnum_id is 0 from allocation, which can be in use by an entry of another device. Skip removing an entry in uncore_freq_remove_die_entry(), when it is not valid, which means that it was not added or is already removed. Also skip power domains without cluster_infos in remove_cluster_entries(). Fixes: 01c10f88c9b7 ("platform/x86/intel-uncore-freq: tpmi: Provide cluster level control") Signed-off-by: Srinivas Pandruvada --- v2: No change .../x86/intel/uncore-frequency/uncore-frequency-common.c | 5 +++++ .../x86/intel/uncore-frequency/uncore-frequency-tpmi.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c index 4bcafedf68ef..6051aa040abf 100644 --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c @@ -312,12 +312,17 @@ EXPORT_SYMBOL_NS_GPL(uncore_freq_add_entry, "INTEL_UNCORE_FREQUENCY"); void uncore_freq_remove_die_entry(struct uncore_data *data) { mutex_lock(&uncore_lock); + /* Nothing to remove, if the entry was not added or already removed */ + if (!data->valid) + goto uncore_unlock; + delete_attr_group(data, data->name); data->control_cpu = -1; data->valid = false; if (data->domain_id != UNCORE_DOMAIN_ID_INVALID) ida_free(&intel_uncore_ida, data->seqnum_id); +uncore_unlock: mutex_unlock(&uncore_lock); } EXPORT_SYMBOL_NS_GPL(uncore_freq_remove_die_entry, "INTEL_UNCORE_FREQUENCY"); diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c index 753ddfe8c759..73e0b0a94eaf 100644 --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c @@ -524,7 +524,8 @@ static void remove_cluster_entries(struct tpmi_uncore_struct *tpmi_uncore) int j; pd_info = &tpmi_uncore->pd_info[i]; - if (!pd_info->uncore_base) + /* Probe may fail before cluster_infos is allocated */ + if (!pd_info->uncore_base || !pd_info->cluster_infos) continue; for (j = 0; j < pd_info->cluster_count; ++j) { -- 2.56.0