From nobody Mon Sep 28 17:49:01 2026 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 D028447F764 for ; Wed, 19 Aug 2026 15:15:21 +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=1787152523; cv=none; b=d4OY1cIsentimGM+/mH853uYNsxnWIt5xAdm8Kmj1wzhECXhyeg5gYKVuTQEFowz5zpgw+K7kmVHbKaQfUWE7ZbNbQIRtSygCRr0tK8J+8z6vSCP1oZLJW7IbNh9E6t6RQbQnsfWd6N2YEWzT8QG+WwRvRYgKieY5KWvZpVbxEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787152523; c=relaxed/simple; bh=UcA162awZ/FDLL+nLPTQwzMiSqcHxbiYyOYH5gX1pI4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r9qvHQl/JX7oqwEk+svZi0hq+PWIPDVt/EHKhkSb4GDFA1zak9DHBIkmfhseFJ8EKUxmWFVCrWa2/6RylKJRRWyJPF+jVJ8iyzMB6lVcDeP8YAfXoOKKxT5W+soZ9j5nblcIbHXpMBclgEClcWaO4ebumYIu6LQEl0P45iuGI6o= 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=JoqoNvOv; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Ux0GzagR; 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="JoqoNvOv"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Ux0GzagR" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67JF2B5S190605 for ; Wed, 19 Aug 2026 15:15:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=feUNzhq5Dex 7vlE9YWr3DimXFOMzSyfolhfBuwRnZkk=; b=JoqoNvOvpksv9Fcn60bfrQfGwL7 oxctt78YzNZbdVLBTDB3UbHaYAeOvtuHbaY679K2Q9V325HeKhxsnIBxOJ9IH/Nc 1VoDD0vYDS5/vg3YKU8f4mKMHg//Nzv614HV8FXuw3WDmJLrKb/s7WoZ+rWnAh/K ykS1qBgtwK282xtJ8cbOcsKajWSzO3XXCMGmMmh/i6U7kYFJE0SO1ET19LmhoiWC 2sMs6N06PBQaPDtdy2V5trYESPKVO7PRvcRC2CWzaxYjRs0fmNDGx40z026TWTek 5Stkvgba5J5DsT8RxY3+lUgd9XgpKb0AZSm8+AgREUs4DbGmTXma6V8IX/Q== Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g5esc025n-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 19 Aug 2026 15:15:20 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-933023a5980so186249985a.3 for ; Wed, 19 Aug 2026 08:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787152520; x=1787757320; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=feUNzhq5Dex7vlE9YWr3DimXFOMzSyfolhfBuwRnZkk=; b=Ux0GzagR3Ufxq1DN6j1UFe4ApP7acJUJ+7EgZRcyDgbwqN6RIxVBMXAeEnh1397pyB KBpRaAVtgV8/9oNx3Cm9y+QlqhqhX5lfazzZrVI7W9RuKypKsbJC9FoLp/9WDgH7BWFv nk7NBWKdMMlGjK61bA9od49mf6yLrLbhVVbDHHWqFI0/tPmO4JF/H3vltxmGp1oRu8hm 8m4ziaztiqvsdT430Ya9Wf0yVJdlbvcj9kU3us8ovhZkgJL40doMrj/XkcnGqvw6G/lr oduQdFT2bGcqJnluGtDtfbYcKjHfXxup7NRywH+9ueWy0ij+/HenUNZsCni/M+nvl7mg F5pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787152520; x=1787757320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=feUNzhq5Dex7vlE9YWr3DimXFOMzSyfolhfBuwRnZkk=; b=b+7csO15s6KEUqf2g5fGLrJRaffcjSXeYe5GcIjabJKSa5VKmshgDngc3wHUnDKRs0 9WX1PNKFkgWExk/YSxCVjA85fB0anQM2KWFyZM5g0uON3lSEwE/LhNKODMSvJIy7NTwk +6N6cdVdj9X/AKGUy3BCfq38fovzAFo4XlI0G9huDSi10QLJZWaYnPr/Ig3fqsHUE49O p0TNxln1YRaw6LPC7XWK9vcBWYmWzzFfhBin///6VnTmajGvylBRH8UYS+uSHJw44O8l MDvhIxxKPx01Z+3TChhODYLwssGKl4gSIeSGTq8VX6OZRveuS+tbC4xc0/5cAFD4R10/ +FEQ== X-Forwarded-Encrypted: i=1; AHgh+Rq15VM0lBekiVeXAgd73T/aWo9kwnEW/dR1ZtRZApDHAExn5cSxt3O82O03drIAFeHwj8DMpSScuRQ2N4A=@vger.kernel.org X-Gm-Message-State: AOJu0YyGfkt/e3mDkLOFh6zBpMB6szCKKUJpVF18IEsldjPUSyAF2/3F T7pBhvlfQzEhSOx874Q+j/d+a3POuiYCXrF8OqGuNZuK9+Dqyt1HBQtX94nFTM8eBQLmEMRijos 9gbRBHCoLQL/Qa+qOTkyRlLBJ8qW/XCfX3yeMs+bpeYJHrUVgTt9b5gZuhTVb9pqMPAond80pco g= X-Gm-Gg: AR+sD11b/UeAvhRRhvFfpmGhLuubKEsgbKp/QzD0sCiNIGnhhMYg/aYMbMkeq7rPaJm TezRM2AgjtZXcmwZVnMienYJ0vxh7ZPhx75Pm4aFNyv1f2wBDRKFMY6WfuHlrXPTMuK+Qb9r3K3 d4/1qD8KIyOz5uj/HIYttb7CT7Ja817yxE8hvZwaPV7IWYzcYUz/mD3UKACBN4L+cHMwyQEIlN5 j30L8zM+AechRuAFUTrS/ifUBbb4aAiB73Qd908+7veVzFW8Nh4feFxxd+zDiGurRb9MtjhHitm /PbHkl292jzPJQR5IFRlRmGbAqpF4YFftv9MQT761Bd9vYbIHKIZRXkNGo2tf+s7K//aw2FCWM2 PCgetMLij6wnOPm2qSWSabs5r9s4TyCp5fckZtbLOhi6nhFX/zZ4kY7L5Gw== X-Received: by 2002:a05:620a:608d:b0:937:65d:d89e with SMTP id af79cd13be357-9371e1dd574mr581278385a.3.1787152519547; Wed, 19 Aug 2026 08:15:19 -0700 (PDT) X-Received: by 2002:a05:620a:608d:b0:937:65d:d89e with SMTP id af79cd13be357-9371e1dd574mr581268685a.3.1787152519023; Wed, 19 Aug 2026 08:15:19 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c243c4ac06asm94124666b.33.2026.08.19.08.15.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2026 08:15:14 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , "Rafael J . Wysocki" , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Christian Loehle , Maulik Shah , Yuanfang Zhang , Suzuki K Poulose , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [RFC PATCH 1/3] pmdomain: core: Allow a non-CPU device in a CPU PM domain to do power on Date: Wed, 19 Aug 2026 17:14:51 +0200 Message-ID: <20260819151457.256959-2-ulf.hansson@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260819151457.256959-1-ulf.hansson@oss.qualcomm.com> References: <20260819151457.256959-1-ulf.hansson@oss.qualcomm.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 X-Proofpoint-GUID: O4TkrA-6zm-0eOgzF-_09aprMxVVy2DM X-Proofpoint-Spam-Info: AW1haW4tMjYwODE5MDExOCBTYWx0ZWRfX7qPRzwLcrWPg mHD6Bn/YgzywhDNKSFDdgHfelawv49hHIJ+FqFVUpvENPsuSqtEvMbHph98JAIr3clJ70npHhaX 3DibSqZYMgfmg49HVrASg69flzRl2wA= X-Proofpoint-ORIG-GUID: O4TkrA-6zm-0eOgzF-_09aprMxVVy2DM X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODE5MDExOCBTYWx0ZWRfX0AMIvy0tJsbx U8OEfgyD51HG6EB67KsGDkVcnACwMK44ivOEDQoB7jfG69W5B3ibdOiE4Fjbzf16lgJjlwyfvck Hdnz3bE24NbfCyPYsUZEOC8xdPjMrTJ0HJtxhsYJzDNNduQcFCxpxBcbPa6kGrxDf1wQQO+ZLQW Rt70QKRcTU0mkGhOhMozPIrfvHoP0dlBny1d1DEY87lxbFOqypxVsvYcgCbLtfMeDX+/wkSXX6O HNONKDnxH9H+T8s3NgWKopTyHfBskjqyEjYgKXzNQcjzedAkI9KT5dysrm7TB3I/rpGvBRaEN4X FXRqNsXyw1lq0so0mT2k5JC/bKWw3aMv4zCeTjtol6EaI/YC9l5PeH+e5T7rsJPxL9kOTlbQ3gI Z7zfCPc0XG4+gQ8xzcVws31CtxGAXazsOa+U+dcX2oSPPM1pkkCWPGJBybF2KDrHm9NMAXIjwtT SouyCLwtp6RoxoLm5Tg== X-Authority-Analysis: v=2.4 cv=b6uCJNGx c=1 sm=1 tr=0 ts=6a85c888 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=h7aNHqOhPKB91FvYUefsSA==:17 a=u8BtVuMVLpZXKRMe:21 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=VwQbUJbxAAAA:8 a=pGLkceISAAAA:8 a=VqZmVlX21PZHT1he1CgA:9 a=NFOGd7dJGGMPyQGDc5-O:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-19_04,2026-08-19_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 spamscore=0 clxscore=1015 bulkscore=0 adultscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608190118 Content-Type: text/plain; charset="utf-8" From: Ulf Hansson A driver for a non-CPU device that is attached to a CPU PM domain (the genpd has the GENPD_FLAG_CPU_DOMAIN configuration set), is currently not able to power on the PM domain. More precisely, to power on a CPU PM domain one of its corresponding CPUs needs to be woken up if they are idle. The current support for a non-CPU device is that its driver can only prevent an already powered on CPU PM domain from being powered off. This leads to problems for a driver while probing its device or when it needs to call pm_runtime_get_sync() to turn on the power for it. From the driver point of view it looks like it all works fine, but when accessing the device it may end up with various errors as the device may not be fully powered on. To fix the behavior for these types of devices, let's adjust the behaviour in genpd_power_on() to wake up an idle CPU that belongs to it, in cases when it's needed. Link: https://lore.kernel.org/all/CAPx+jO-sCierYj8jnoKQHckJG16dOBxnNrsZVYO= =3D38R2cLV8nw@mail.gmail.com/ Signed-off-by: Ulf Hansson Reviewed-by: Abel Vesa --- drivers/pmdomain/core.c | 80 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 5 deletions(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 842c4169e290..7345c06f1d55 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -19,11 +20,14 @@ #include #include #include +#include #include #include #include #include =20 +#include + /* Provides a unique ID for each genpd device */ static DEFINE_IDA(genpd_ida); =20 @@ -32,7 +36,9 @@ static const struct bus_type genpd_provider_bus_type =3D { .name =3D "genpd_provider", }; =20 -#define GENPD_RETRY_MAX_MS 250 /* Approximate */ +#define GENPD_RETRY_MAX_MS 250 /* Approximate */ +#define GENPD_CPU_ON_POLL_PERIOD_US 100 /* 100us */ +#define GENPD_CPU_ON_TIMEOUT_US 5000000 /* 5s */ =20 #define GENPD_DEV_CALLBACK(genpd, type, callback, dev) \ ({ \ @@ -1027,15 +1033,75 @@ static void genpd_power_off(struct generic_pm_domai= n *genpd, bool one_dev_on, } } =20 +static bool genpd_check_status_on(struct generic_pm_domain *genpd) +{ + bool is_on; + + genpd_lock(genpd); + is_on =3D genpd_status_on(genpd); + genpd_unlock(genpd); + + return is_on; +} + +static int genpd_wakeup_cpu(struct generic_pm_domain *genpd) +{ + unsigned int cpu; + bool is_on; + int ret; + + /* Find the first online CPU in the genpd's cpumask. */ + cpu =3D cpumask_first_and(genpd->cpus, cpu_online_mask); + if (cpu >=3D nr_cpu_ids) + return -EAGAIN; + + genpd_unlock(genpd); + + /* Send a IPI to wakeup the selected CPU. */ + smp_send_reschedule(cpu); + + /* Poll to wait for it to complete the power on sequence. */ + ret =3D readx_poll_timeout(genpd_check_status_on, genpd, is_on, is_on, + GENPD_CPU_ON_POLL_PERIOD_US, + GENPD_CPU_ON_TIMEOUT_US); + + genpd_lock(genpd); + + /* Re-check the status as we have released the lock in between. */ + if (ret || !genpd_status_on(genpd)) + return -EAGAIN; + + return 0; +} + +static bool genpd_need_alive_cpu(struct generic_pm_domain *genpd, + struct device *dev) +{ + if (!genpd_is_cpu_domain(genpd)) + return false; + + /* This is not for CPU devices as those are managed differently. */ + if (to_gpd_data(dev->power.subsys_data->domain_data)->cpu >=3D 0) + return false; + + /* + * If the current CPU doesn't belong to the genpd's cpumask, we need to + * wake up one of those idle CPUs to power on the CPU domain correctly. + */ + return !cpumask_test_cpu(smp_processor_id(), genpd->cpus); +} + /** * genpd_power_on - Restore power to a given PM domain and its parents. * @genpd: PM domain to power up. + * @dev: The device that needs the PM domain to power on. * @depth: nesting count for lockdep. * * Restore power to @genpd and all of its parents so that it is possible to * resume a device belonging to it. */ -static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int de= pth) +static int genpd_power_on(struct generic_pm_domain *genpd, struct device *= dev, + unsigned int depth) { struct gpd_link *link; int ret =3D 0; @@ -1043,6 +1109,10 @@ static int genpd_power_on(struct generic_pm_domain *= genpd, unsigned int depth) if (genpd_status_on(genpd)) return 0; =20 + /* Special case for a device attached to a CPU domain. */ + if (genpd_need_alive_cpu(genpd, dev)) + return genpd_wakeup_cpu(genpd); + /* Reflect over the entered idle-states residency for debugfs. */ genpd_reflect_residency(genpd); =20 @@ -1057,7 +1127,7 @@ static int genpd_power_on(struct generic_pm_domain *g= enpd, unsigned int depth) genpd_sd_counter_inc(parent); =20 genpd_lock_nested(parent, depth + 1); - ret =3D genpd_power_on(parent, depth + 1); + ret =3D genpd_power_on(parent, dev, depth + 1); genpd_unlock(parent); =20 if (ret) { @@ -1307,7 +1377,7 @@ static int genpd_runtime_resume(struct device *dev) =20 genpd_lock(genpd); genpd_restore_performance_state(dev, gpd_data->rpm_pstate); - ret =3D genpd_power_on(genpd, 0); + ret =3D genpd_power_on(genpd, dev, 0); genpd_unlock(genpd); =20 if (ret) @@ -3410,7 +3480,7 @@ static int __genpd_dev_pm_attach(struct device *dev, = struct device *base_dev, =20 if (power_on) { genpd_lock(pd); - ret =3D genpd_power_on(pd, 0); + ret =3D genpd_power_on(pd, dev, 0); genpd_unlock(pd); } =20 --=20 2.43.0 From nobody Mon Sep 28 17:49:01 2026 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 E02F63B4E9E for ; Wed, 19 Aug 2026 15:15:24 +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=1787152526; cv=none; b=ruTRrsv6cRCXpFeMKM6AdLydqtFvZKNrE2+BqX4U3iLjCH2mHENBqzZI2x1bdXQq0160XLPf9bwEbFkI/gOisGlWZ3mRoxFoc7jl8v/gZkSsMZ3103/OfiQ1Adrn4xrQ21TXUSbnjxkpmP0w5ZuvP71QTp4knyR7mpDizFYPe7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787152526; c=relaxed/simple; bh=t9RKPwKIuF9czTJyUtLXrPmSVsdrAZssYJ6svQqtCmo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dCpSMqkf5lVw/yL8L4B1Bp8Ekoz/yw5ceZjfna2PpoMp3VcxWZGVbwR7HrdJaGatg1Cq+gwTPJQxDBQ07HXUtxXm4dHjO3r4T225WexMf0Zyv5+xD6u4v1cSDmeBEHwwnUgNNGJJdHuVlrlfTvsPGqL/B4OAC7T/9q7v+4kDuhM= 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=l4YS5b0u; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=c53jOteA; 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="l4YS5b0u"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="c53jOteA" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67JEbQJC067627 for ; Wed, 19 Aug 2026 15:15:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=bNB08OhPcvO dZDBtMLi9pQZN5MeRm7mGZFlCO0ycw6Y=; b=l4YS5b0upWHmz3bitOLRZsxZVt2 N+jadfMhE52oSSq6PPJjAN90EIa8zNEmMnS5eCE1o5+s1AzuMX66A1t9EXQEMl0W huWgW7tWUGmZqXS+QMPF25X3mDrWB9jDk33cb4jCJf9PeF9XEdB9iSj0ji9Q9sq1 Xdw/nwFNnY4VPNphMuxuPRLf7PD4p+DaxfrLOQkHQbnYa3BmOvDbmFdPAGjVst3N YMY4TY/+J/0PGWjlMDpM6s/IQs8jeYOOyxEM1TkURgkr2M5wAKI9R3XhLqEaGZaD dSmMYKqfagwm5wclwrSp0JMDqxG6Ncbgm54UDHFCmSCMP+zKSAwemVE3NqQ== Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g5e5d0889-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 19 Aug 2026 15:15:23 +0000 (GMT) Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-936d067836eso145010285a.0 for ; Wed, 19 Aug 2026 08:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787152523; x=1787757323; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bNB08OhPcvOdZDBtMLi9pQZN5MeRm7mGZFlCO0ycw6Y=; b=c53jOteAut7ZZwIK1MUaAsYekBk7OC48g06zxtd4hJ9N7sWAlISStPmyH5x7/JpGlb KikKkFiUcokXw4tN9mumPBzuo78Pk787BedOHxTE7BN+ygnC2plt6DnvHVJEipEX1Z+J sEyvXORe0K+cf+GfxpoDCppqXmFNujqBxSpkm2LAeCX4rWm8jlMzNO2Pm/zU83Lhdw8h mGe5jttLDmisJhzGGtTGAhgGoqKwBBrCGGx5OocaZM4wgiQsyDvww20cKupW+HRo6l+Q dcLxZZBlOQhEWttAYnHuabhDaqc84iUqqAGwZdHVOtmmTSbkCw+9a2OkQTGrcn/OJfg8 pgLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787152523; x=1787757323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=bNB08OhPcvOdZDBtMLi9pQZN5MeRm7mGZFlCO0ycw6Y=; b=oQ5bBVLWyQw1YBT6Jnl2q2aUN4JeAqfktVivkHY5aSNLwFP66vhq2+aHbqPCccY/Zg ayZ/FBBM6J1j8xxb1TtwY83FfbEOs03aG1F48bN73vlcBp/LvoxyO4r0JtDeh6UoRBe1 Nvrf26LezJThzgz1DOOMONscUKnX/qVdk1LOLr9Kp5doWrim7JcrLIR9TLsdAEqXaaWV rTf5g1y+X3VyRJ7o7MntjQ2ek1XDqqxadvtlX7FjIRdJQkpuZiDAXnRu/lIOPxxCgnHz Wi4o5W4FmSp9fPCqvZTkeA7RnD8MDIaZVmILcI6flNCXlFDJTCx9G9CKbG2nyA26QTSm UzNw== X-Forwarded-Encrypted: i=1; AHgh+Rqh5as2pSL2hCsQ3QRW2wBlBNOppDn5cTRapJOxWhUk3h6PhiVdc1V3n4D6IBXFSIEsmqcfDGwaaP1Wt+8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2Zxy7LdKIfuVMBhzoPM/XBbsNXRuMUT815Y/qwE/b0GMomQ++ PgM4288oF1p1a3mJjdcaV7nkyJszJVdbyDu1YUv4EIK85/quqUL4imEUGjG7g6XiVfh7wF8EUPK p7LeJ9l3+RYUPofogohpfqP72V2oSEeUSFKKvpEwwSI27DsR/ESG9T1/4fN32GokcNr4= X-Gm-Gg: AR+sD128vzLCuPEJSDI0YCR7iUe1PTORgBykwgP35IP0FYyc9VpgY03yyyXj4pSGCpx 9ulzH5KT6/L6O8zoAi6CYCTniEJHRVdaHUlI3H1t1JPpMd7opTXzBvBGY+aZ2GI6F6IluCiboMM GhRINwXCsFnvAALhJsuEvEOQeKR8NDomJLLohLeJD09cLva2nTpDxjpCrNGFaWJuxfyAsYxov+J 6BzvZpZ5sdvnrciOKfF+UBfDIBDqzecONtOT5QWDeiDJPtzh/x4cw7cj0CAN1FOp2akDomraQhG njud3elAD2Xyu+HRTrBi39As/CUHRlA/EJfrQqMF6WIRJDw6EG5jp7DF59JB4k0XDu5BvdYku0M cJyr8XjFqgvLYPq8Kc1UUeiW7A2Of57sKUAm6EuWYwJ0LvC/fmWudo6XDpQ== X-Received: by 2002:a05:620a:46a9:b0:936:befe:42a4 with SMTP id af79cd13be357-9371e6b710bmr500315685a.42.1787152522909; Wed, 19 Aug 2026 08:15:22 -0700 (PDT) X-Received: by 2002:a05:620a:46a9:b0:936:befe:42a4 with SMTP id af79cd13be357-9371e6b710bmr500301685a.42.1787152522169; Wed, 19 Aug 2026 08:15:22 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c243c4ac06asm94124666b.33.2026.08.19.08.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2026 08:15:20 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , "Rafael J . Wysocki" , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Christian Loehle , Maulik Shah , Yuanfang Zhang , Suzuki K Poulose , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [RFC PATCH 2/3] pmdomain: core: Add a genpd config to support unknown initial status Date: Wed, 19 Aug 2026 17:14:52 +0200 Message-ID: <20260819151457.256959-3-ulf.hansson@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260819151457.256959-1-ulf.hansson@oss.qualcomm.com> References: <20260819151457.256959-1-ulf.hansson@oss.qualcomm.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 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODE5MDExOCBTYWx0ZWRfXwefdTzLGKFlE bz1hXl4OeT55VZxwogAR8OH07nPRoPBc+0zWyOkymH5sHQYlnRZeWBhGoNTrGHfVd26zqEHyoJ1 z2OxzAGxsMztA3VF286vPYSWy0lgAlR9PB3gDc25r6KhzLmnCOi2o9/YfhYHBHAPapDyxFpJsoj f7bVjsSKJI8VTazrxwWpy3pAsWUPXg7rdx5x2eQVsChHpf1yp0sf9MbfWesHzxbdpBbAlSQqfBl MeRyufyMoSrczzjLKgnwW6UyXjHGT50BOGxiAm6ubb8kNXq4yYM7jkjngm7v6wCvrNvwYZirspH VoqLl43HpqR7ji1UOTc5MRggpj5Ov9IZ0IYxU7qJBUzTK71r2pW3B5IgVQOC/MnJtuRZLmkUfE8 oXvDOWcParaNT2Q6BFcmQc3b/zk+jBxLTAhTIKRe5myUoK1zeZER2YFrmkPaba7bbUPMOh+IIqG JnK1qO9bg+eqJvRyloQ== X-Authority-Analysis: v=2.4 cv=cuOrVV4i c=1 sm=1 tr=0 ts=6a85c88b cx=c_pps a=HLyN3IcIa5EE8TELMZ618Q==:117 a=h7aNHqOhPKB91FvYUefsSA==:17 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=EPyTabgPSFAr6pNicGcA:9 a=bTQJ7kPSJx9SKPbeHEYW:22 X-Proofpoint-ORIG-GUID: djLW8qsq2FyhIGzUZD_LKnb3VGOMkRfv X-Proofpoint-GUID: djLW8qsq2FyhIGzUZD_LKnb3VGOMkRfv X-Proofpoint-Spam-Info: AW1haW4tMjYwODE5MDExOCBTYWx0ZWRfXxHstRB7jc/Rw GoUG1QiqunMncg6DNeJUjzz/N3g+0zr5cQdPgokgvJlkNb0rRXJOZaaF3ULi6obLA/dkhcBBIQo FfgeU1xgfeH38CySIwKSRJqhBcS3Blg= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-19_04,2026-08-19_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 spamscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608190118 Content-Type: text/plain; charset="utf-8" From: Ulf Hansson It's not always possible for a genpd provider to know the initial status for its corresponding PM domain(s). To register the PM domain in a safe state, the genpd provider driver may therefore have to initialize the genpd's status to be powered off, as a way to prevent the PM domain from being used when it actually could be powered off. In these cases we may end up to power on a PM domain through the genpd subsystem, while from the HW point of view it may already be powered on. Under these circumstances, it may also be required to keep the PM domain powered on until all the consumer devices have been probed. In other words, until the ->sync_state() callback for the genpd provider in question have been called. To support this behaviour for a genpd provider, let's introduce a new genpd configuration, GENPD_FLAG_OFF_STAY_ON. Reported-by: Maulik Shah Link: https://lore.kernel.org/all/20260811-domain_off_ss3-v1-0-6a0a0fc023f5= @oss.qualcomm.com/ Signed-off-by: Ulf Hansson Reviewed-by: Abel Vesa --- drivers/pmdomain/core.c | 6 +++++- include/linux/pm_domain.h | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 7345c06f1d55..be4fff2f4664 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -189,6 +189,7 @@ static const struct genpd_lock_ops genpd_raw_spin_ops = =3D { #define genpd_is_dev_name_fw(genpd) (genpd->flags & GENPD_FLAG_DEV_NAME_FW) #define genpd_is_no_sync_state(genpd) (genpd->flags & GENPD_FLAG_NO_SYNC_S= TATE) #define genpd_is_no_stay_on(genpd) (genpd->flags & GENPD_FLAG_NO_STAY_ON) +#define genpd_is_off_stay_on(genpd) (genpd->flags & GENPD_FLAG_OFF_STAY_ON) =20 static inline bool irq_safe_dev_in_sleep_domain(struct device *dev, const struct generic_pm_domain *genpd) @@ -2445,7 +2446,10 @@ static void genpd_lock_init(struct generic_pm_domain= *genpd) #ifdef CONFIG_PM_GENERIC_DOMAINS_OF static void genpd_set_stay_on(struct generic_pm_domain *genpd, bool is_off) { - genpd->stay_on =3D !genpd_is_no_stay_on(genpd) && !is_off; + if (genpd_is_off_stay_on(genpd)) + genpd->stay_on =3D is_off; + else + genpd->stay_on =3D !genpd_is_no_stay_on(genpd) && !is_off; } #else static void genpd_set_stay_on(struct generic_pm_domain *genpd, bool is_off) diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f925614aebdb..9929347e1d7f 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -121,6 +121,14 @@ struct dev_pm_domain_list { * powered-off until the ->sync_state() callback is * invoked. This flag informs genpd to allow a * power-off without waiting for ->sync_state(). + * + * GENPD_FLAG_OFF_STAY_ON: Use this flag to inform genpd that its initial + * status for the PM domain is set to powered off, + * which may not correctly reflect the state of the + * HW, as it's unknown. If the PM domain becomes + * powered on during boot, genpd will prevent it + * from being powered off until the ->sync_state + * callback is invoked for it. */ #define GENPD_FLAG_PM_CLK (1U << 0) #define GENPD_FLAG_IRQ_SAFE (1U << 1) @@ -133,6 +141,7 @@ struct dev_pm_domain_list { #define GENPD_FLAG_DEV_NAME_FW (1U << 8) #define GENPD_FLAG_NO_SYNC_STATE (1U << 9) #define GENPD_FLAG_NO_STAY_ON (1U << 10) +#define GENPD_FLAG_OFF_STAY_ON (1U << 11) =20 enum gpd_status { GENPD_STATE_ON =3D 0, /* PM domain is on */ --=20 2.43.0 From nobody Mon Sep 28 17:49:01 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 DB1BE47A872 for ; Wed, 19 Aug 2026 15:15:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787152529; cv=none; b=kkSaacn78NN/wJqB90DpuOGIHtDwpKj0lvdASXN+gCyHXwXnAX+PIdYqrlezBGk2htpItJ/sEDLqchq62LEwmzfYqCgG/ExPOzAYQ9zoOnWvzF4oxfDEIC0Ofb1O0RhPvJC8BU0TNkhLMtz0zgJn3jDlh30JoXmrcXip3DvNkfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787152529; c=relaxed/simple; bh=UqLHAb5jkXZAS+tzMNPWmBKOx/DrwxVipmhYZV2c+2Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KL3kiOPgs+DT00Rw/vLJxdhFoW2hGX6JemyyPGJ4rVctDsUf4HQxXBqrcQ2dzNcfir8I8t836dcYYaDQF0s3j6mgHSP/Ot+O1HMV1tsRfehamqebUUXvJau/Es7Fd+Do6TfJnfgY1FOVHuHxxrGvXEUBicueGhBVUaSqhawCv6c= 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=FbRVP3+W; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ZLBxoMjG; arc=none smtp.client-ip=205.220.180.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="FbRVP3+W"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ZLBxoMjG" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67JF1eNq963720 for ; Wed, 19 Aug 2026 15:15:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=Vv//GFttk3q YBPU7mvMr/By4VJqy5iyji7k+koecDb0=; b=FbRVP3+W6IIApSK1NLeoMk8lg3n C08s7YVSJikjatnQYKiIG+YWoD2jRZSm1L+yM3NUwiSVpjs3zU4ryY2XDxmtiCFF e+Nlqeqt3qXoJUURz/IRsv2YhK/VLWbZ19liu9u+S/JS+2TRk51kzAdS60++VLmj hmihvb4sKU4WNWM6+NwPCXZedIicyQ7gumcf10hngMaIodpnlH53/yhfb0xq4Yvd PP8MyrUTLJMEe8WnYo7P8+A1tr7tgVeVTnoBMRYLUhQOnJHQoRgRbGpPU8ApI20U 3g2uiU/zhWbU75HuOvXQVYYJkJ+tNxZXCULwDvDPtiEeMUvS/OvbOpJHSLg== Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g5es3g24j-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 19 Aug 2026 15:15:26 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-92e9a2b95b5so201084985a.2 for ; Wed, 19 Aug 2026 08:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787152526; x=1787757326; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Vv//GFttk3qYBPU7mvMr/By4VJqy5iyji7k+koecDb0=; b=ZLBxoMjGxVAJukPYpz46kxXPUe25dzNErCBgeXL15i17CSAKK/C1aKdvvtDecky+zl nSxIna0FyuTOovQp5raCd0Aw9IqT3PUVBpmMjIw9henGD/hwGr1rnbUafVpMmhWGGtsQ oDSUUwVplt86r9H8/3Z+xA4pHZ8JzPiufV+eN5n6n5kxIY6f1VesFYIwF8DbqMCUBXec 3gC4BYAIJFqJhJ3q3doZy3Q66N6hisL0o/k2P7le5P/OBJO9q/o3fGfLKV1z3OVt4yYr XpicB8vkHaqmBzwwD3Q/wlnXJX8ldcMzOW95U+yRmwTYgMvH8fsMlkgmJBx8/A5SyySg BE/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787152526; x=1787757326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Vv//GFttk3qYBPU7mvMr/By4VJqy5iyji7k+koecDb0=; b=JmN8vKsKRtiPBZLGfhhG3wdpvR92P5PEfSipiNNju+HI40lz82WcVMr34Vmut+ZLrq 2Ue75ETcpLicc7K0mVNbTFsCidsDuuIeg0q7Up9o0x8N6C1E+MjG7VFN8p05Fu88aRUj 6du3IFthQoOPZ3QOm/p1q0oE3l/Gv8M8tkUCqep2dniNm+nNB7Z5I0ROYkRcUMmlo2g4 CZd0+jM6riFNU6LIhEri9uF8NHiWKKzvOL7HJTrZDYBhtn9ZKTRieWG6uHjklevJTBaG 1LXNa1kSPpw8F1pdSGTSLcj2x6C6iC2MxSEP4d8XAelRuDJRAP/3pHBsCJAnkoaLOM43 bvXw== X-Forwarded-Encrypted: i=1; AHgh+RoN4sEZLPtSo3fpeNh6209Kw8WH4++mNcbeLMfWjfwFRG9YA4HBRuQnhfUEI1sQFe9UPNM38Lu+M13m8MM=@vger.kernel.org X-Gm-Message-State: AOJu0YwO+DMhapsA7jFsuFuGqWZQIXH0BeCtH9rhQ2mpPEWIiL4VNX8K ZsuIuF1kVg6QXLYySMZBSfhc9TNyxLGFm7mX7bfLjOmAZe+kzbe4+Qhz/jJ0IDNpx8tqFmYApmB hNlgmKv+6/W1EQHINMdsW4P+oLll+MoGer4borQ2U4V90ivaqowM0WhH5KfBiCqf7LSI= X-Gm-Gg: AR+sD12kyqKDQNyayxwWQJbIpHwILQePPjldj1NCRDBFnUsJRpkkIKJECuOniz8Sf16 9HWs8KEuyvIbDgUKBuFq+gT/y2yBdLugrZIvc0zq6vxwbTMogiTYg+mPNXZwJFZALXk/Mj7SagO 7xS8jw+YJkbxekN7VLatCpKKW5qm3PeN3l1vc6Uu0gjYR7Nol4lNJ24MukYkkQ3Hf/0OiyixvHN hIA8sSqyZ9QWMkdP/Ept2zpes/yJqsBTJw8TH7knWHT7NBNv0qZUxnOBawi+kd4T4WCfW385W54 jXaTmwKiL5fwVpkilhWljiD/iy0ykMQlEkLLTU0S6vfKgdReF93zUnKxe39EMHkMtmEChwOpJYp 19dg9rtWkKVxj5GFr6Fy9b071U5wGxGn++YA+d0iXmS9hvbUQ5VpUR47pVg== X-Received: by 2002:a05:620a:1d0d:b0:937:1710:f839 with SMTP id af79cd13be357-9371e79aceemr569269785a.47.1787152526109; Wed, 19 Aug 2026 08:15:26 -0700 (PDT) X-Received: by 2002:a05:620a:1d0d:b0:937:1710:f839 with SMTP id af79cd13be357-9371e79aceemr569252785a.47.1787152525350; Wed, 19 Aug 2026 08:15:25 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c243c4ac06asm94124666b.33.2026.08.19.08.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2026 08:15:23 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , "Rafael J . Wysocki" , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Christian Loehle , Maulik Shah , Yuanfang Zhang , Suzuki K Poulose , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [RFC PATCH 3/3] cpuidle: psci: Initialize the PM domains in powered off state for OSI Date: Wed, 19 Aug 2026 17:14:53 +0200 Message-ID: <20260819151457.256959-4-ulf.hansson@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260819151457.256959-1-ulf.hansson@oss.qualcomm.com> References: <20260819151457.256959-1-ulf.hansson@oss.qualcomm.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 X-Authority-Analysis: v=2.4 cv=UIrt2ify c=1 sm=1 tr=0 ts=6a85c88e cx=c_pps a=50t2pK5VMbmlHzFWWp8p/g==:117 a=h7aNHqOhPKB91FvYUefsSA==:17 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=GddhhVl5-a8N4MGu71oA:9 a=IoWCM6iH3mJn3m4BftBB:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODE5MDExOCBTYWx0ZWRfX4n3IeOVJ97aV gyi6c0xilfTUmqTBoyBJvVQFZ1zZfFGvLDAKyfTs+l3Gvgi+L/leSUppTWTFfP4derPFX5jDJO+ yBYinYuRlcRHWSOXdr6WyxCXH0B42BiceJwEsLZRCHoBiF44Rdb0jAZNI2lt1j7+QsCRVf590v8 QfKiQY/8qeQJ8UOvcT5GeVf9xuMCuAPok78gfA0KUo++CzEY9CuUIBcpVqlNAX5J7ADMCUpgR34 gMMGPhj2dcxYaAnnVyv4GXUkduIQ2XJvsjoZ+nFCtFNVTTOHVrfxDaafxYL/1trJBzVWxpu2gMQ ADv2byZP7X6FbQUbCDq7knm9hA0DJzsekmpz/8YF6r+0ZbMElnPDEQLwyPehlQjvIXkLchKNbed vBrHP4trgx5WmnFG8mR92Gau3jLpbeyKAAFKWJIftZme8tkiR5p+A2wE+RTSNaIA1E3A893RKA6 5mACM7G5+uDzr3Bb+ZQ== X-Proofpoint-Spam-Info: AW1haW4tMjYwODE5MDExOCBTYWx0ZWRfXxB1fGI3/IkWE +DM4G3xma9o+ygXkn3QsrEuBslW6dPYUuiTf7hT1P9l3+jWuiFoYjz3atJ3A519P7rbsE/GjbrV 8r2dSvmQqavmtuNTOb6pV6AbgSfgrME= X-Proofpoint-ORIG-GUID: 4s3AKT1cnwXYXQeo30oZRnXpTTCWYzrc X-Proofpoint-GUID: 4s3AKT1cnwXYXQeo30oZRnXpTTCWYzrc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-19_04,2026-08-19_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 impostorscore=0 spamscore=0 priorityscore=1501 clxscore=1015 phishscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608190118 Content-Type: text/plain; charset="utf-8" From: Ulf Hansson At the point when the PM domain and the topology are registered through the genpd subsystem, it's not really known whether corresponding CPUs are online and thus if the PM domain should be initialized as powered on or not. Instead this information becomes available when the CPU devices gets attached to their respective PM domain through dt_idle_attach_cpu(). This is a problem when using PSCI OS-initiated mode, as we may end up with a PM domain that has the genpd's status indicating it to be powered on, while it in fact may not be the case. In the less severe scenario, this leads to selecting a shallower domain idle state for the PM domain than necessary. A more critical problem is when a non-CPU device shares the PM domain, leading to their corresponding drivers not being able to trust the status of it. Let's fix these problems by initializing the state for the genpd's to be powered off and in the deepest possible domain idle state, when using OS-initiated mode. The support for ->sync_state() is maintained by setting the GENPD_FLAG_OFF_STAY_ON for the genpds in question. Reported-by: Maulik Shah Link: https://lore.kernel.org/all/20260811-domain_off_ss3-v1-0-6a0a0fc023f5= @oss.qualcomm.com/ Signed-off-by: Ulf Hansson Reviewed-by: Abel Vesa --- drivers/cpuidle/cpuidle-psci-domain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidl= e-psci-domain.c index b9e4ad7d43a3..29caf3114185 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -68,7 +68,8 @@ static int psci_pd_init(struct device_node *np, bool use_= osi) */ if (use_osi) { pd->power_off =3D psci_pd_power_off; - pd->flags |=3D GENPD_FLAG_ACTIVE_WAKEUP; + pd->flags |=3D GENPD_FLAG_ACTIVE_WAKEUP | GENPD_FLAG_OFF_STAY_ON; + pd->state_idx =3D pd->state_count ? pd->state_count - 1 : 0; if (IS_ENABLED(CONFIG_PREEMPT_RT)) pd->flags |=3D GENPD_FLAG_RPM_ALWAYS_ON; } else { @@ -78,7 +79,7 @@ static int psci_pd_init(struct device_node *np, bool use_= osi) /* Use governor for CPU PM domains if it has some states to manage. */ pd_gov =3D pd->states ? &pm_domain_cpu_gov : NULL; =20 - ret =3D pm_genpd_init(pd, pd_gov, false); + ret =3D pm_genpd_init(pd, pd_gov, !use_osi); if (ret) goto free_pd_prov; =20 --=20 2.43.0