From patchwork Tue Mar 8 08:29:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 12773278 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 3BC35C433F5 for ; Tue, 8 Mar 2022 08:31:20 +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=W2Z+R3M1DeR/7qtdZLOsQlNQGxW9XtKxRAM1eRuh02Y=; b=JltXa6Xv6UCQtc 468saQxLBTiNsmKGGhZz3t9m+90WYV7v3MDqNKtFn17SB1YR7Oi3zCwKQiQDSIKCwWXXX8pWtDej/ 0fBXCqnYhCUpFj6+2qXWfJMUdZUFcx2igq97asR1BfS2GOdDPxpdHFCpYw0XkPlPrp4kLJHAyWh44 wyG4HFe/m3CO7J2G8haHyji8CfJ4abMCXqLmHqDCa8D66pxWg4HE0m7rff4rGwnmDM8hhBc+cZ3y2 1Hda08K3Sz9fwiFIunzKaX7kGL/NvJzrRVZbKjk9wbVjQMmOD0iqgKf2ycE7JB7qJrdJS+RIbsp0W mvkkcyDhmKwRSyj0Y/GQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRVEI-003GUn-Tc; Tue, 08 Mar 2022 08:30:03 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRVEE-003GSs-Bw for linux-arm-kernel@lists.infradead.org; Tue, 08 Mar 2022 08:29:59 +0000 Received: by mail-pf1-x431.google.com with SMTP id p8so16715438pfh.8 for ; Tue, 08 Mar 2022 00:29:57 -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=biY5ams/L/8gAUldcXYdkodIReIruP+fnC3UwnEvKik=; b=FR5UYtStER6p/1YZQvrw3ScM5SgcgyBONMffv5EQPqlHUrnjdoxfZZ+yRdnVbYNFxb w2ZvfSdx3sslpCnGLI6akBCeP5omUHdhKvrlVjutHND41gfD89CXojsSAnLK1GO/DR6A oxsx8HCMN402k9J7sAsMuVWb/eiLNQV6/Nvhvqqcv6uwPgRYT37sNuBxrsUMyjWGIYlt Eij8Eso6oHN5v9aEAUk3BYRCtCuyS6fFIa2nSsQtgukRMg4q+To4Xc14xbqQqtHR8z0H 2G36AgBMtUHhcbZg8HzlPBY8neN/HVTz6ppBryGonswOhmkhPs+ErpWt+Zj/QCO+VmfC SFeA== 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=biY5ams/L/8gAUldcXYdkodIReIruP+fnC3UwnEvKik=; b=ZziAPSjJmpXjWCJWA0fhGcu8rLDyc1jtFyn0LDlB907hzE3FOxd6e0t9YJaXWiqogF WkZLaJ1ek7dH9dQBXEazfguG/aKHxE5ftqscJEddrld/xT3T8bsw1h3B02WjjW5XqPFI fZQ+Ank8c2bdzWh6+SbGzrIKnovuqMdRR92OkhRw6/bfpmG9eNylHQjabWsLiSFWhjZv vVH82qMGfdFz1/8kRWwBWnCMbqechg+keiGZYuTfCzF5jV847CaAYpjYKOUueXBhdrZt INOAqY+RKVb0oKU+YZTEjzBqVWisidSg4ispnrhkxjB8rwapbnbDrvym9D8M5vY3L/pH g+bg== X-Gm-Message-State: AOAM53144S4LlzkvGQZNof0DgxkXJqTUwKBfaOWCOO3V56GBrvhhH/Md OFkx4glkyvt9e0Yn7HBT6oBtZw== X-Google-Smtp-Source: ABdhPJwtleDHDeXzrBf/O+A+/gweObqeGpJC3OV68tzPuEyMJ5MfEfsiH62i5lEDEawS1VIox5YjAA== X-Received: by 2002:a05:6a00:2815:b0:4f6:ecc6:1173 with SMTP id bl21-20020a056a00281500b004f6ecc61173mr12739958pfb.74.1646728196621; Tue, 08 Mar 2022 00:29:56 -0800 (PST) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id e18-20020a056a001a9200b004bc82d0e125sm18369364pfv.119.2022.03.08.00.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 00:29:56 -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 v2] cpuidle: psci: Iterate backwards over list in psci_pd_remove() Date: Tue, 8 Mar 2022 16:29:31 +0800 Message-Id: <20220308082931.3385902-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-20220308_002958_478627_1EE57F86 X-CRM114-Status: GOOD ( 12.14 ) 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 --- Changes since v1: - Fix commit log - Pick up Reviewed-by tag from Sudeep and Ulf (Thanks!) - Add Fixes tag as suggested by Ulf 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);