From patchwork Sat Mar 4 07:41:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 13159794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E891C678D5 for ; Sat, 4 Mar 2023 07:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=nF5Ie20udNls7naEhThEtdOgdr2uZdnamKKehVKsTsM=; b=pGTQxAjjp8a7G4 K9d+L88S09WTkkqdhwAqaj+cq3UiKJLJSWW+eOLDVbCJV1tCv5NJrMoFqwU8CDVKG/S62ehmBj0PA yfStO0EieoawekyoqWO8zg0xK7lygYs/DcIUknbEKPMUYArqJWsP2nweZUftP0n6RzWnYtnDier9j h1i+48L+hAW69c8yrz9wovCPBfAF1GU63+TDPYtBzh0WQkc6KDIrpL745OXiSOKQLVOo01VkkrG8Z UAIp1FyOQAIaSB7rxhXXxjXFDix32U3iH8B4gqLHsiBXDUueXuYnMJGmIzs3RhLjy3qpspN3lzXQ9 FFnJkd8rMxtAmn4i/hPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYMWJ-008WMC-Fw; Sat, 04 Mar 2023 07:41:31 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYMWG-008WLm-T4 for linux-arm-kernel@lists.infradead.org; Sat, 04 Mar 2023 07:41:30 +0000 Received: by mail-pl1-x629.google.com with SMTP id a9so5033978plh.11 for ; Fri, 03 Mar 2023 23:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=onGECTlzCF+rI5jirJ26p2wCglobbVeSGFOjZxWv4BE=; b=Qzwq8d8BN11Vk6QP+JlXkVxSkfKm67lP3g4vexmkNImvu+9z1cwPg0hhp6otmDuvKK SPjzVbBcGC8ls56aIa6r+wCDGeD1GSKIhax4oZsN38nXMyGF1r2dyhZzZvs8xmlKZjtR IpBwDVutBEchavZVIPtceqxQiZU+Mp+xOn+eCrRu+SvKUzyx5Bn6FtQnLv8x0Hi1/SF4 FyEo+LXXHbrpqWc8xRBsJ1iQVmjKUyqs8j87y2jr9NjRBJhKHYNvhANxKmf+W/Ck0Pna qZJjssNDXlP/Ug46LW2sWqJBozWrWK91s5na4Ot4UmbhqC1PChBMetYyMg6RrJZdGtr4 JJQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=onGECTlzCF+rI5jirJ26p2wCglobbVeSGFOjZxWv4BE=; b=Z4VM3wP7aw9+mT/B8N5nyAu2Bwo+QvdLPMDS8A7Ik216X5/5ZzN9Y/KFyouWzdayXe pxXExpXN1ZxHlkizyEch3CUEDw8tk1OdRuZbTY0YEnds2/6S31D+CT1XjPqVjXpPUD7K tRLOanAlwnTqFJ7rv3wDcAt9gva/yyihLlumcVTLk8yjmbEgjX8M0fg0GAidl7aL+1P5 ui7u/WhoNikZz7SetgxUXYFS0UxyDa2lTEG7/VRTvUpho/YuNr9NfM0OcBD+4bqGJq+y tbo/3+4+M2//E3C5O5lO570oyPkVXOwL8jAB5xyAFZG1KAjlRHIPGGWIAnoeuigdGker WxFg== X-Gm-Message-State: AO0yUKXuRkJJJ2IKyf6TUiL4tTAZpn3A1+KK0MKTbbFG3WSXaWQWWcZC mYxW1TBjlBJpAG8Lknl24x9VBw== X-Google-Smtp-Source: AK7set9R7mALzTFfjb3AGkdnIVFGf4fQB2ZSSubUjiTDsQoW3TL60kIg5sRmTb27Wor3JiQiSQ6Izg== X-Received: by 2002:a17:903:2344:b0:19e:6e29:2a8c with SMTP id c4-20020a170903234400b0019e6e292a8cmr5506800plh.5.1677915686715; Fri, 03 Mar 2023 23:41:26 -0800 (PST) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id km12-20020a17090327cc00b0019e30e3068bsm2713471plb.168.2023.03.03.23.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 23:41:25 -0800 (PST) From: Shawn Guo To: Daniel Lezcano , "Rafael J . Wysocki" Cc: Sudeep Holla , Ulf Hansson , Konrad Dybcio , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Shawn Guo Subject: [PATCH RESEND] cpuidle: psci: Iterate backwards over list in psci_pd_remove() Date: Sat, 4 Mar 2023 15:41:07 +0800 Message-Id: <20230304074107.59083-1-shawn.guo@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230303_234129_032680_FE0A0063 X-CRM114-Status: GOOD ( 13.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In case that psci_pd_init_topology() fails for some reason, psci_pd_remove() will be responsible for deleting provider and removing genpd from psci_pd_providers list. There will be a failure when removing the cluster PD, because the cpu (child) PDs haven't been removed. [ 0.050232] CPUidle PSCI: init PM domain cpu0 [ 0.050278] CPUidle PSCI: init PM domain cpu1 [ 0.050329] CPUidle PSCI: init PM domain cpu2 [ 0.050370] CPUidle PSCI: init PM domain cpu3 [ 0.050422] CPUidle PSCI: init PM domain cpu-cluster0 [ 0.050475] PM: genpd_remove: unable to remove cpu-cluster0 [ 0.051412] PM: genpd_remove: removed cpu3 [ 0.051449] PM: genpd_remove: removed cpu2 [ 0.051499] PM: genpd_remove: removed cpu1 [ 0.051546] PM: genpd_remove: removed cpu0 Fix the problem by iterating the provider list reversely, so that parent PD gets removed after child's PDs like below. [ 0.029052] CPUidle PSCI: init PM domain cpu0 [ 0.029076] CPUidle PSCI: init PM domain cpu1 [ 0.029103] CPUidle PSCI: init PM domain cpu2 [ 0.029124] CPUidle PSCI: init PM domain cpu3 [ 0.029151] CPUidle PSCI: init PM domain cpu-cluster0 [ 0.029647] PM: genpd_remove: removed cpu0 [ 0.029666] PM: genpd_remove: removed cpu1 [ 0.029690] PM: genpd_remove: removed cpu2 [ 0.029714] PM: genpd_remove: removed cpu3 [ 0.029738] PM: genpd_remove: removed cpu-cluster0 Fixes: a65a397f2451 ("cpuidle: psci: Add support for PM domains by using genpd") Reviewed-by: Sudeep Holla Reviewed-by: Ulf Hansson Signed-off-by: Shawn Guo --- Hi Rafael, This is a resend of the patch [1]. Could you help pick it up or let me know if there is anything need to be improved, thanks! Shawn [1] https://lore.kernel.org/linux-arm-kernel/20220308082931.3385902-1-shawn.guo@linaro.org/ drivers/cpuidle/cpuidle-psci-domain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index c80cf9ddabd8..1fca250d5dec 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -103,7 +103,8 @@ static void psci_pd_remove(void) struct psci_pd_provider *pd_provider, *it; struct generic_pm_domain *genpd; - list_for_each_entry_safe(pd_provider, it, &psci_pd_providers, link) { + list_for_each_entry_safe_reverse(pd_provider, it, + &psci_pd_providers, link) { of_genpd_del_provider(pd_provider->node); genpd = of_genpd_remove_last(pd_provider->node);