From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14FAA43E9D2 for ; Fri, 5 Jun 2026 20:19:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780690755; cv=none; b=a0LQf5IlfPfyuZqGxaGzeCxrQC75RoyUmMG5/1penl/D9B0IbERlg0PVSdSOpijyjfXGn968GmxVrdUiKtrG6/GHdSPHr1bmGuVzWl5XN9xy8hjV92+U4Jfewp+yroRZ950cKSqID90gcIaOfKsfYdf8jowZ979XimzOrhaiEY8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780690755; c=relaxed/simple; bh=HRCZhVoWK0niODWt+XbH4EjpgqnXLW23jOkUBvgIqgQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Xp3C795x51d+gfAxtvZKWCxBM1CpWaeROWYopo2WJeAV5iRgXOOtDnacR17z59H1SryJ9KmFIharBvEg6nuJgptWaNxMUvkNgk1gpdHp/FGWjzkG8qpG047RLrdMeEkVmSxcI9/RGqIfRsAqQnUIVYXrApJUBU0DhcUQVODV1NM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=sU5fyK5g; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sU5fyK5g" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490be03d47bso19334455e9.0 for ; Fri, 05 Jun 2026 13:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780690752; x=1781295552; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=POfwTOxPePIR+bzQ/YWTWSHHwFIOZT4YImIC9EJ68WE=; b=sU5fyK5gYcSzWubJr35fK1H0jTC4PhI3utTSRW1psYPWa4dMe5GduD5nwK1Vw6zvQZ uprW1ahtwIHLn0Dzlbrd14IA3QJzIEnjURC/nvxHizO+rCy8J4hqhk5JEMv/+JH4c9ri x9kNPVydvRsiT5nmO8YHbU4RYpwQ7h4HtVfBe+1esqI7J9cQ5cywUrxR/onbnisyJIvx hyQGSbLWDkLxKCXkFI0ogXt8gmOWnkuru87iV68P8/y9J8E/e6ojX4rcHSgpPHHW0yJT VCRDqtPboZcTLqe4BkIVCXCJNPxgTdUtoeLx1TwXLWH6C53YJZwNtVOOWO1oq3jsPxgv WV/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780690752; x=1781295552; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=POfwTOxPePIR+bzQ/YWTWSHHwFIOZT4YImIC9EJ68WE=; b=qPhV51AAKuA5TQtVigzwiGbyqoo8ycpG4Qz2Bi7VBswfdItsIrZwirD0Aivye5n4vq Qmbj6q2BzF4q7RrnxqzcyTlYMmK1mE/ABScoz7+AjT0rhm7OduIuxTJSgDJ52FogaQnJ 8nK0CnGnh+NU/YHt80i/GI3J4kPtzRyjNhxXdepZ3DxCXEpX6HeiDPMevO1KLmX+oQeG Ykl7WpJP8PVIwoRAkB6ZuOvqF/av+HXgbK8NqpAdBPRS6w+GtGY6zjEeDz4Qr5+d8jvF RtE4tch+e1Msm31HNHT5JxLJKZj97UmH8KDy44ElOa85fyOryFVwf1aj6mZSJlbO69nJ nJ5Q== X-Forwarded-Encrypted: i=1; AFNElJ/uMvIklqFZt5hmoD1ggc5tMMJBsGnFDGrW0XWnUQTq5Yx73goNoLw772X8f+ffNne8Mo1gxNxaRVxtpiI=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+GzNcAmYJrIPq/h7+uUCkcscny5KW+NPdv1MSDpPVHouCiWLo s0A9a4PP8cfWQzHvlXF67clj+Bn+mAuERQlmaPG8tke+eXODDbksY8Th5sS9SFvtbi0= X-Gm-Gg: Acq92OGJm+14i7Usl8Ys1e9WEjpwB+6ADITLYksBQe1N9sJ4Jr8wvNHPPokjBH0AMN7 CSte4wnIG1PxUF3AK61GiB4uzW/kQDpnn7L6vzrh4t6BRmfoE5qkeELTO2rhz44nWcAX9n0EHBm XjgVSJusktpElnIghovbWIc9KD71vmWXqUrh+N7OxCMxPIKoLVFSy8/6O1VaBO0VxTWszo/Wbcj 6wYMIsW1AWxx020GJ6ArrygM6zwLGOuxRK+hN8xxpogRqUMI3HM6Pn0IL/wxuITrW9lbxL7fWBb ZGOO1nhaPldAS2qNl+wQr7pZxHPYyEzFEznVblvXYUgQ/9t/UI3UNMojrFPa8HYi35rNUBSG2BL VVtOpP4TgDU0fFFB1BiTOGFdXdShwMv44ig0v2ax+dAVtJDN0cZ+vzKBPQzJl1aFb/DrnIr4UZa OJstEg2r4i8NM5Rsn64lta9GubDm/w3ijMtV8kigEVE016ySukKRsiEXqL5+r+VSRDyYSJAqE2R /rEEDQN318vP1w4YOF3b187Hb8= X-Received: by 2002:a05:600c:8705:b0:488:ac01:72de with SMTP id 5b1f17b1804b1-490c25898efmr107486035e9.5.1780690751755; Fri, 05 Jun 2026 13:19:11 -0700 (PDT) Received: from [127.0.1.1] ([94.4.195.193]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc413541sm190533895e9.14.2026.06.05.13.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 13:19:10 -0700 (PDT) From: Alexey Klimov Date: Fri, 05 Jun 2026 21:18:52 +0100 Subject: [PATCH 3/3] soc: samsung: exynos-pmu: fix error paths in cpuhotplug/idle states setup Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-3-0cd05c81a82d@linaro.org> References: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-0-0cd05c81a82d@linaro.org> In-Reply-To: <20260605-exynos-pmu-cpuhp-idle-fixes-v1-0-0cd05c81a82d@linaro.org> To: Krzysztof Kozlowski , Alim Akhtar , Peter Griffin Cc: Sam Protsenko , linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Sashiko X-Mailer: b4 0.14.3 The setup_cpuhp_and_cpuidle() initialisation sequence currently ignores the return values of cpuhp_setup_state(), cpu_pm_register_notifier(), and register_reboot_notifier(). If any of these registrations fail during probe() routine, the driver returns 0, leaving the driver partially configured. Furthermore, if anything after setup_cpuhp_and_cpuidle() fails in probe() routine, for instance devm_mfd_add_devices(), the probe() lacks an error path and leaves notifiers and cpu hotplug states registered. Introduce variables for the cpu hotplug state IDs in exynos_pmu_context struct, that should be initialised to CPUHP_INVALID by default. Check all return codes in setup_cpuhp_and_cpuidle(), and add an error path to remove registered states on failure. Finally, add destroy_cpuhp_and_cpuidle() helper to safely tear down notifiers and cpu hotplug states. Reported-by: Sashiko Closes: https://sashiko.dev/#/patchset/20260513-exynos850-cpuhotplug-v4-0-54fec5f65362@linaro.org?part=3 Fixes: 78b72897a5c8 ("soc: samsung: exynos-pmu: Enable CPU Idle for gs101") Cc: stable@vger.kernel.org Signed-off-by: Alexey Klimov --- drivers/soc/samsung/exynos-pmu.c | 57 ++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-pmu.c index 9636287f6794..846313a28e9a 100644 --- a/drivers/soc/samsung/exynos-pmu.c +++ b/drivers/soc/samsung/exynos-pmu.c @@ -38,6 +38,8 @@ struct exynos_pmu_context { unsigned long *in_cpuhp; bool sys_insuspend; bool sys_inreboot; + int cpuhp_prepare_state; + int cpuhp_online_state; }; void __iomem *pmu_base_addr; @@ -404,6 +406,17 @@ static struct notifier_block exynos_cpupm_reboot_nb = { .notifier_call = exynos_cpupm_reboot_notifier, }; +static void destroy_cpuhp_and_cpuidle(void) +{ + cpu_pm_unregister_notifier(&gs101_cpu_pm_notifier); + unregister_reboot_notifier(&exynos_cpupm_reboot_nb); + + if (pmu_context->cpuhp_prepare_state != CPUHP_INVALID) + cpuhp_remove_state(pmu_context->cpuhp_prepare_state); + if (pmu_context->cpuhp_online_state != CPUHP_INVALID) + cpuhp_remove_state(pmu_context->cpuhp_online_state); +} + static int setup_cpuhp_and_cpuidle(struct device *dev) { struct device_node *intr_gen_node; @@ -465,16 +478,42 @@ static int setup_cpuhp_and_cpuidle(struct device *dev) gs101_cpuhp_pmu_online(cpu); /* register CPU hotplug callbacks */ - cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "soc/exynos-pmu:prepare", - gs101_cpuhp_pmu_online, NULL); + pmu_context->cpuhp_prepare_state = CPUHP_INVALID; + pmu_context->cpuhp_online_state = CPUHP_INVALID; - cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "soc/exynos-pmu:online", - NULL, gs101_cpuhp_pmu_offline); + ret = cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "soc/exynos-pmu:prepare", + gs101_cpuhp_pmu_online, NULL); + if (ret < 0) + return ret; + + pmu_context->cpuhp_prepare_state = ret; + + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "soc/exynos-pmu:online", + NULL, gs101_cpuhp_pmu_offline); + if (ret < 0) + goto clean_cpuhp_states; + + pmu_context->cpuhp_online_state = ret; /* register CPU PM notifiers for cpuidle */ - cpu_pm_register_notifier(&gs101_cpu_pm_notifier); - register_reboot_notifier(&exynos_cpupm_reboot_nb); - return 0; + ret = cpu_pm_register_notifier(&gs101_cpu_pm_notifier); + if (ret) + goto clean_cpuhp_states; + + ret = register_reboot_notifier(&exynos_cpupm_reboot_nb); + if (!ret) + /* Success */ + return ret; + + cpu_pm_unregister_notifier(&gs101_cpu_pm_notifier); + +clean_cpuhp_states: + if (pmu_context->cpuhp_prepare_state != CPUHP_INVALID) + cpuhp_remove_state(pmu_context->cpuhp_prepare_state); + if (pmu_context->cpuhp_online_state != CPUHP_INVALID) + cpuhp_remove_state(pmu_context->cpuhp_online_state); + + return ret; } static int exynos_pmu_probe(struct platform_device *pdev) @@ -548,8 +587,10 @@ static int exynos_pmu_probe(struct platform_device *pdev) ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, exynos_pmu_devs, ARRAY_SIZE(exynos_pmu_devs), NULL, 0, NULL); - if (ret) + if (ret) { + destroy_cpuhp_and_cpuidle(); return ret; + } if (devm_of_platform_populate(dev)) dev_err(dev, "Error populating children, reboot and poweroff might not work properly\n"); -- 2.51.0