Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1816570rwl; Thu, 30 Mar 2023 01:46:22 -0700 (PDT) X-Google-Smtp-Source: AKy350Y0xtH0tvjOjU4SIQ2lm/j9a8FEEFDMNYD37HZPyaQYcgJ3qlpTu4VOBmHu8PCsjKvB1Q9u X-Received: by 2002:a05:6402:2811:b0:4bb:c3ce:63fc with SMTP id h17-20020a056402281100b004bbc3ce63fcmr26103931ede.3.1680165982305; Thu, 30 Mar 2023 01:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680165982; cv=none; d=google.com; s=arc-20160816; b=L/goImESVFyrcrKU6gm0FhXQqorz+/wmYCCQpHsfWHxwKJY4lbX1trODejX3YVSCnh sox2z+UIP8ZXrqoISPBeF3vnE3OKSxJlHe7Qhf70hlSagWiaRXBrH4yO8SwXOmUutcS+ 1/Y1rOOD1I5REBvGZMSmg4v4dJynveLz1r13xXSt//gvGixj48//fPY+TYG+IzYD5XKa nb2kcko2MlPNo9/jcvIAApXYHZL6lunk3Htz7/bP2+JwI43MTzUOwBWBKxf2erV4j+Zt 4A2UtsJ1uLSE54n4UkB0C0XgVCwDhWcQwouHQdxty5inE/qoZ2Aj8D5Mcfs/GhJQwcHd Tonw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gjLiZGYGTl5tqnESD8D55d0rMdobWZrlKTsCA01tpYk=; b=ZycG2R4Xhq5ME/6Z6vJhSG1HDxQupKW1+wMejEz2HwkSdWk9bn6AiRhySjNyCUK1OU j+O5BjWAK88Veq6iFwF0g/jbQ0yzlk8g4vs8guUvys6r7Hm51ppaJ0fo7Yl1ea6ADulj IUc4VD5EroGZbjaeTThDMiY1WNvmE8HpEUIidPmjIlzYTECWqCCMKEwN7nK/Npi7/RX3 fi3eWF4GvFeZ2sv/WHtIKgnQOogBOTJKXMD9YbmGG06EIVH1wDs8TVvxcOWtczDneu+o eMNJ180PWbu8HP2iiU6rMseyUIAGxzq63XKA/0iUybcERA8hEI071AChBBNGVn8ny3wu 54+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="P6fy/SZr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a05640203c800b0050270e743d4si1045309edw.590.2023.03.30.01.45.51; Thu, 30 Mar 2023 01:46:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="P6fy/SZr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbjC3IpB (ORCPT + 99 others); Thu, 30 Mar 2023 04:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbjC3Ioz (ORCPT ); Thu, 30 Mar 2023 04:44:55 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D2F87AA5; Thu, 30 Mar 2023 01:44:26 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32U6IkM3014937; Thu, 30 Mar 2023 08:43:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=gjLiZGYGTl5tqnESD8D55d0rMdobWZrlKTsCA01tpYk=; b=P6fy/SZrfXv3/M54wqpjxyurXJzfAVgAlf8IsQt/msEDcPEypVwW2uF/9keZ/U9hZTOW DdnZzouQJqa6ZBb4/6sITEwuLZUjEG4roE3dbsXHOvrSBBMjGeZiYFI0a8bbbYZ6ahjP TBFau3zJs0mYJrgr2c7hhCvTecG4OKrUdClKu8doBzMkEo5K2tEo0j097NrEbbuJgdYm hV8/bAj/iAGwrdTRIK88FgUqmFsGS/bMOuIFdhWWlLnkx/Jt0oZ68ZX3cyMNcGQ/yUsm YHpRBp5/c9kpuRdL7+R85snRsiHrCsAa+GQfOhjj8MfrVh8F+0hGgpyS+ko7Q1JnQ65q Fg== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pn51ygcvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Mar 2023 08:43:08 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32U8h7eg007732 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Mar 2023 08:43:07 GMT Received: from hu-mkshah-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 30 Mar 2023 01:43:03 -0700 From: Maulik Shah To: , , , , CC: , , , , , , , Maulik Shah Subject: [PATCH v2 1/2] cpuidle: psci: Move enabling OSI mode after power domains creation Date: Thu, 30 Mar 2023 14:12:49 +0530 Message-ID: <20230330084250.32600-2-quic_mkshah@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230330084250.32600-1-quic_mkshah@quicinc.com> References: <20230330084250.32600-1-quic_mkshah@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: qFe0wD_wY0Kl3rAczSFRwvr1Y11UTwbz X-Proofpoint-GUID: qFe0wD_wY0Kl3rAczSFRwvr1Y11UTwbz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-30_04,2023-03-30_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxscore=0 impostorscore=0 malwarescore=0 adultscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303300069 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A switch from OSI to PC mode is only possible if all CPUs other than the calling one are OFF, either through a call to CPU_OFF or not yet booted. Currently OSI mode is enabled before power domains are created. In cases where CPUidle states are not using hierarchical CPU topology the bail out path tries to switch back to PC mode which gets denied by firmware since other CPUs are online at this point and creates inconsistent state as firmware is in OSI mode and Linux in PC mode. This change moves enabling OSI mode after power domains are created, this would makes sure that hierarchical CPU topology is used before switching firmware to OSI mode. Fixes: 70c179b49870 ("cpuidle: psci: Allow PM domain to be initialized even if no OSI mode") Signed-off-by: Maulik Shah --- drivers/cpuidle/cpuidle-psci-domain.c | 29 +++++++-------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index 11316c3b14ca..d81f6ae35002 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -120,20 +120,6 @@ static void psci_pd_remove(void) } } -static bool psci_pd_try_set_osi_mode(void) -{ - int ret; - - if (!psci_has_osi_support()) - return false; - - ret = psci_set_osi_mode(true); - if (ret) - return false; - - return true; -} - static void psci_cpuidle_domain_sync_state(struct device *dev) { /* @@ -152,15 +138,12 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct device_node *node; - bool use_osi; + bool use_osi = psci_has_osi_support(); int ret = 0, pd_count = 0; if (!np) return -ENODEV; - /* If OSI mode is supported, let's try to enable it. */ - use_osi = psci_pd_try_set_osi_mode(); - /* * Parse child nodes for the "#power-domain-cells" property and * initialize a genpd/genpd-of-provider pair when it's found. @@ -178,13 +161,18 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) /* Bail out if not using the hierarchical CPU topology. */ if (!pd_count) - goto no_pd; + goto remove_pd; /* Link genpd masters/subdomains to model the CPU topology. */ ret = dt_idle_pd_init_topology(np); if (ret) goto remove_pd; + /* let's try to enable OSI. */ + ret = psci_set_osi_mode(use_osi); + if (ret) + goto remove_pd; + pr_info("Initialized CPU PM domain topology using %s mode\n", use_osi ? "OSI" : "PC"); return 0; @@ -194,9 +182,6 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) remove_pd: psci_pd_remove(); pr_err("failed to create CPU PM domains ret=%d\n", ret); -no_pd: - if (use_osi) - psci_set_osi_mode(false); return ret; } -- 2.17.1