From patchwork Fri Feb 25 08:24:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 12759865 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 07B9AC433F5 for ; Fri, 25 Feb 2022 08:25:49 +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=61tU24pD+KOEsfh2ccOxd1vYknp0lFRzXgEkKcBDdD0=; b=b8qi5D0jrQ+pFM orug7KM/T+U8De/QwX5De5HisEavZSLelGBpYQ1w+DMPLnl1MZiUgIaIkQfLQDWXG1XtOUKN9VRYn ZOpnPsBt4xsPILp9m30/tnWeXkDIUunVACIeqWm+jlx90NUH2Tl7E3k0dYRN1B5ajOKimJiBaD6Rh dsehckUB6W9ed92RJHzL+Ki/TWjNGDnP3Aq/6I8pDpRbBxi5k+eBDPwUkTVDlvaqPeYVsHvbr23tN VdLRHh8aerNhnQADTFEOGW4Husxu4cuesKtQPbZdJa4p4MuTKcUhalAuWCKtNN2Erg8o1mHAxzgXO PkJy4CBvuyfcJ3h9j/bg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNVu4-003wH6-LG; Fri, 25 Feb 2022 08:24:40 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNVtt-003wE5-Qj for linux-arm-kernel@lists.infradead.org; Fri, 25 Feb 2022 08:24:31 +0000 Received: by mail-pf1-x42d.google.com with SMTP id u16so4074535pfg.12 for ; Fri, 25 Feb 2022 00:24:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yum9+x02mmC9p3Nv4KcgRE/DjU3YZvYXccqQBT5GhAA=; b=JJFjSjikZK5vZ42MIyUM4iSPqZY2jgbF13UZMHQRLNtFjSNMjLXnuwbO4VW6owvNp0 Uhm7Zwv6k+bYEQV/7S7y3PFsx5jIa7SiVxahJJucFDgycf0M4wCDAv81e6zLrcure5kI rJjHZAHHFAi5WUI91/1eCeb5q5aqeylMXG/E0Q1jvEewc5z0MD1DVGU/144Pn6W7xkyP +2mgWMHQ34F/aSqYEg6yN4TEh2ShMZ9Oolx7Sxn3wuSH+OUUcb9AWhhSjr60NcBdfya+ HRu6hB6KpbqByDIY/4F0ahgpJcxg7kdbSqmKFR2ok7qANiq0fV+kwb3+M1yg2sXZJ7FR YhIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yum9+x02mmC9p3Nv4KcgRE/DjU3YZvYXccqQBT5GhAA=; b=Ab1zSvwchj0k/OTfL0KbBuTUZ+AAFAzq15b6MuFevRPGybHrmFBi9g9HJu2aC0mM1n NGr65bqnqgWfrGQLf8VCyn9925/EBBFMgYhuwL9TwChuH03tf4h8XUzzM4HBSVG96gCM g6XmpaCTJhkfBtJ+XcU0UAR7ymI2PNi4jAksvpIcJ5mJF9ZLM0c673MklXamxGpLmJ0C y5nzAK27LCkzGwmhtqc6l41uFKyQ9kYKdbw7D3z8tUhZ+ujruJgU01v1VanBzQH1Zgm1 +pP6MCcAksGmSlr9AI7iIPX149Q6i9CaYFj9tcYiiTm+2F/D+mNOa50ZRwn6ncxV+iMt tKnA== X-Gm-Message-State: AOAM532uIY2FiA8sdl5s5lFwuJ8KdLu3PoMLcc45ZL99EWFS4qWj5Ro2 Ri+9+FZG0vx1wx4vO2+6V7wCew== X-Google-Smtp-Source: ABdhPJxn496aHY+LlUfjJ+UwxuwXeyX/nvjvbcqDUnyAL8mg/Wu5Gs+Wu74+lDDqKI8EBIZ8qa78VQ== X-Received: by 2002:a65:6746:0:b0:377:16e2:33a2 with SMTP id c6-20020a656746000000b0037716e233a2mr1478335pgu.47.1645777468098; Fri, 25 Feb 2022 00:24:28 -0800 (PST) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id b2-20020a056a000a8200b004e1414f0bb1sm2038607pfl.135.2022.02.25.00.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 00:24:27 -0800 (PST) From: Shawn Guo To: Daniel Lezcano , "Rafael J . Wysocki" Cc: Sudeep Holla , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Shawn Guo Subject: [PATCH] cpuidle: psci: Iterate backwards over list in psci_pd_remove() Date: Fri, 25 Feb 2022 16:24:20 +0800 Message-Id: <20220225082420.450620-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-20220225_002429_977357_00E21713 X-CRM114-Status: GOOD ( 11.13 ) 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 in a reversely order, so that parent PD gets removed before child's PDs. Signed-off-by: Shawn Guo Reviewed-by: Sudeep Holla Reviewed-by: Ulf Hansson --- 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 ff2c3f8e4668..ce5c415fb04d 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -182,7 +182,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);