From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 C09573C3F42 for ; Fri, 31 Jul 2026 11:35:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785497744; cv=none; b=MM17K+yyhcH48Xgqu3XFYS5Ma77uDK+vWvKmzBLPMxDfezjqIWBsRRcHC/ljsCNV5PtOAQ70a3Uen4ihOU5dZMKTqypSgKolpPmIQ/4zxVrEkcDbcjBfS0VAViZquR7Bw2OEtIG3mMZD+PR0O/OmO8PwAHlrb1KSDOigE8MOiE4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785497744; c=relaxed/simple; bh=plfZ4FsucgnFmYB+WLfqiTzRuqQ1f/GHyVysSGWQv6o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=S7MK6joDYOISdwjBUmaJVAdzqZR5/oBYovYCsyvHEdp5nZSRe6O6lPyPA5SXu06h23n1+Cr7MDxQOUCk7/Z9fwMv8T/dLxn2wLlSAzpYQy24MdeGzn9grlhvWCH74lEGjajr4Y/JEScYon6ciQl8NMgfd7QrU/n9rjesXlJSqlM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=kxrN1WAD; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=SjyigWmW; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="kxrN1WAD"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="SjyigWmW" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66VBM7E84046112 for ; Fri, 31 Jul 2026 11:35:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= SntzIFPR+4FwE76k9egHNUQnO0nVT2pXTp/Kx+qC7ww=; b=kxrN1WADw9DCh02h SQ5T1fm+EggEMTO0j14VZTvKWSZnDbMroGMOUD7c7xWRPqbPFFyQ81tGnFoIQps2 9Kx2MCNHisvGxAozCoWt8gcLsscBornjTPHFspVsU3oYOgJbS1rlrTL8aZNaznHQ Nky6SDLbN3YFUdT7DzyF4jMDBZoWRI9VgmrsFhL7Z8QsxnkLX5jI/yBK++NhDN/H 0DyH0Iuw4a8UnAQDv71eSAEFWN6krXrotYlDRv66eDLXr6fd5Ss+CL959fks1Mah Rh0e1TaWWNpPaiwoU0vJnpoMiob2U0oHNNlHA7SwBzQLbQ1Mr+BVHanKQOpx1XD7 NlSLLQ== Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4frt4906q2-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 31 Jul 2026 11:35:41 +0000 (GMT) Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-51c21be5bb4so1758651cf.0 for ; Fri, 31 Jul 2026 04:35:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785497741; x=1786102541; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=SntzIFPR+4FwE76k9egHNUQnO0nVT2pXTp/Kx+qC7ww=; b=SjyigWmWGA5cFtSY1uZaf2AysLmzLSaGEBGx5qZtx8oZBlv96/QXdS+AzzkP+hh+Lp 4SELrDpm0JjfUbavF9pvGWixLuiu1+1anemdD1gC/4OdgVvG/lpxpuavmBqoy29IUsxH Gxmvkb2JxNvY+8vta8wgM7v55BdzJ0nNcgvAlkG3jJZ58aNawLC/PCKeaWNskGL9GcO5 mPj7YVTwFpgB1pM5qWQpsk6OB6vEWaGjvcHAWPsKyaSNZPXgjY6h5GVlXse0fjsB1ysy 985y4go7UyDGnLT/4X56R+e30qx4vBXLeIpuhjX/jHF2Ry7FuUi9gralOxP44jbV08KT Iz+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785497741; x=1786102541; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SntzIFPR+4FwE76k9egHNUQnO0nVT2pXTp/Kx+qC7ww=; b=Gw020TyRj63Kl4qYFs2ApSzuGSB/afnFvGTPX2wJs/thSQC31xW6iCC6RmFxBHXCq0 sqdpDe+SRz75umHxdoeEteViBdAy83heRDQPs10oK/a1GUZ2LH59BA+7Cm1LXZ6GP5XT 6RlE9i2EZ4abUbtyN+1MINO39RJdlZip72G7ehKGNCuPT1PqaZed+HSm2kMKLvye37I/ HdABTUFku5vEopsPtL7V0oE/oElaHLVh/pE6mr15AzS/9TUZH1gh2RKm5B8NInfKUdgz HIHbqRVGj51c5EEFh4TF0vlggwqAOyfQWEzbkHra3BoEJvBkimaAzA9u1l3HKrhm2v4s ocpg== X-Forwarded-Encrypted: i=1; AHgh+Ro/Il8+wfFGBWk31X4lIQW4ki+abzcpF2JThMUZjHzUeswdyt+CsVVPYS3Q01mDw9oxqpKCvYatv0cLBYw=@vger.kernel.org X-Gm-Message-State: AOJu0YzuMYxi04iYKvc68pgsgC7TCyCdRLa1uTaS5J8xZY0EkvscP7AI ujr0vcQXzySSv028bk3rCnDZsACAgkyP7x/hvxjoi+Zlg6rwJS4O5ti55LwNQl0xPumO2Ahw2lk Ykt2vnaFx+i8yvvh06QAplDsuo7O9ktMH9qIYC9kE8ZsWR/jKLZh6wGDH9I/WK5jIvEs= X-Gm-Gg: AR+sD11USKkhVryiiVIQnNcBfyxUqBDSKz+pNf2GcxK9GUlp60BeZlwMFZuOzGgnOoD /V1UFj6LyzhdX7215l50HYscAc0KMDh4hGwwLIfKGsOak+Fb/NDUmYt8QKiA7qdPyGJmcDYPp4R v6UtXG9EgbEVZH3MZzR9dtjowOSvelVgyIAL/IjghmYJat0WH0j3TyCXdVwI9hOwas1ZT1Yr6dP ov9O38XSoyEN+lGu+ZDyqs+vDWbF/nwIq2UJTTJwlXMJ3pz9MCSIYjXomXjvz2MOq3yCQSy8wCS uwgvf2gT+Yo63XfKs17urWlWVsHLkQh3H1qyqxyoQJNRmvfrOZmdJdomQitYXh/7eehoQc3E5df aFySfFEMxg1MlaN3I6dqxXHV+ X-Received: by 2002:a05:622a:6bd0:20b0:51c:2324:666 with SMTP id d75a77b69052e-52b4b164ab7mr15392261cf.3.1785497741049; Fri, 31 Jul 2026 04:35:41 -0700 (PDT) X-Received: by 2002:a05:622a:6bd0:20b0:51c:2324:666 with SMTP id d75a77b69052e-52b4b164ab7mr15391851cf.3.1785497740570; Fri, 31 Jul 2026 04:35:40 -0700 (PDT) Received: from [192.168.120.193] ([178.235.128.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a09c664713sm1227143a12.30.2026.07.31.04.35.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 Jul 2026 04:35:39 -0700 (PDT) Message-ID: Date: Fri, 31 Jul 2026 13:35:38 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] pmdomain: core: Wait for device link removals before dropping genpd->dev To: jaseg , Ulf Hansson , Abel Vesa Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, =?UTF-8?Q?Jan_Sebastian_G=C3=B6tte?= , stable@vger.kernel.org References: <20260731102147.127082-1-git@jaseg.de> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20260731102147.127082-1-git@jaseg.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: DWoZCgQgbKyQWrCu5De9Y0_3scst11TN X-Proofpoint-Spam-Info: AW1haW4tMjYwNzMxMDA4NyBTYWx0ZWRfXzaQkwEoQ5AF3 3Rl7dCm5IOh9XBC8lpC8FK12PVS88zWpHafmiw1NUl0sLsk3xI8E9oFOvoWSxCN1uilHkSNJjSa le1Vnm7+eAZLMTUIVS7ME1oKYm+2Kcs= X-Authority-Analysis: v=2.4 cv=Zpbd7d7G c=1 sm=1 tr=0 ts=6a6c888e cx=c_pps a=mPf7EqFMSY9/WdsSgAYMbA==:117 a=PRfkaYvzSr8QmIIGAkY2Sg==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=LNI6Y7vA10jdH1asw2gA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=dawVfQjAaf238kedN5IG:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzMxMDA4NyBTYWx0ZWRfX+iK2poSbLc5x PeW1q0XUk3e5sUBdK+rQSCV0oKOZrEULi2hs0Br4wFwW1vX8qHurQqicgiCxcWNv9HyatN9erV2 DdPVuV1rzZuggC3nwnmOcrW5rvTujUUvd2XDt3g2Iiw8eImVXe//L9I2KLRkRahie5oV+lqJ8wz K47z6JpiYQtr+EG6cDe/XVY018yrbGO2dceCi/WtCcX/ZnE/LBt2GSk/SmD+FIwitFGLIe4JHYP HNh7ZAuedZhMK9TrFcEpZq4wRBtxW5I5h4wntwXOQuQT0jHxwwsM5ocFWS7l6MprRrLJDiiL7zu s0vwurBgopm/0EizmkMXj9kuQSOUDpKI/6vyDZbuzL/Q5LTKoXYdxyqq38ILLFDo4hBl6O29l8L YYCpGZ92Hz4w0HaW/vQi4LLVXjsJTC3D5Ey6wS8RxLchwKYwyTREFhmh0xbKQZ/V0GsyBitjZ46 +j/g05fJD/i6tW0guAQ== X-Proofpoint-ORIG-GUID: DWoZCgQgbKyQWrCu5De9Y0_3scst11TN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-31_04,2026-07-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607310087 On 7/31/26 12:21 PM, jaseg wrote: > From: Jan Sebastian Götte > > genpd->dev is embedded in struct generic_pm_domain and its release > function is empty, so providers free the containing genpd with a plain > kfree() once of_genpd_remove_last() returns, ignoring its refcount. > > Since genpd->dev is registered on the genpd provider bus, fw_devlink > creates device links to it, and those are torn down asynchronously. > Nothing made genpd_remove() wait for those teardowns, so the provider > could free the memory backing genpd->dev while the queued workers still > used it. > > This is reachable at boot on qrb2210, where the firmware rejects PC mode > and psci_cpuidle_domain_probe() removes all the CPU PM domains before > returning -EPROBE_DEFER. The bug is asymptomatic on defconfig, but shows > up when enabling KASAN or INIT_ON_FREE_DEFAULT_ON. In some builds, it > causes the kernel to crash a few hundred ms into the boot. > > Call device_link_wait_removal() before dropping the final reference. All > link removal work is queued from device_del(), via > device_links_driver_cleanup() and device_links_purge(), which precedes > genpd_free_data(), and flush_workqueue() waits for it to complete. > > Note: This patch was LLM-assisted. I reproduced the issue and tested > this patch on hardware, and I did my best to verify it by hand. However, > I'm far from an expert in pmdomain, so YMMV. Thanks for the submission! I'm not an expert in pmdomain either, but it seems to make sense For future contributions, it's best to keep things that you wouldn't necessarily want to preserve in the git log under the --- line (so that it still shows up in the patch but it's removed during `git am`) Also, your sender identity doesn't match the patch author (i.e. your full name shows up in the From: header of the patch but not in the email), but that's just cosmetic Konrad