From patchwork Wed Aug 17 17:27:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12946277 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 CF9B2C25B08 for ; Wed, 17 Aug 2022 17:31:26 +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:References:In-Reply-To: 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: List-Owner; bh=pOhCBek3J9Nlp29NDvW3cEgRtd4Xykb7pirq+Od/hcY=; b=myoiKbQakON6Lm j4hY5w5kvmqbwQrtPIrndp9q3dF4RU2qGSaO8HCV+YGj+EyAu78TVxVn8utYxOaeS4PzHgUMe4A56 rJxLYtO41Oh0yNer3FTgKAiElizMqmrYTaZlmDDlS13R4icVTnZLvYYQ/pC+cn4lKkEildn4DV/Yo A3W4urzTqrkUlbco3tpILZZuHrmwkg06unjet2kBguZdyMoqRLq+93FqJcq+jmY87kfZca5t9KgNM lXcija/sCR8YP/gvwC9yE1pAZvCbGSFXeKkKqgqU8l4X9a7dVcGQaEvJkA+RsmDHsa1IA6oGT/nuS M/2qpYdMXFi/QQc92QLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOMrw-004OCk-K0; Wed, 17 Aug 2022 17:30:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOMpj-004MjO-0r for linux-arm-kernel@lists.infradead.org; Wed, 17 Aug 2022 17:28:01 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2BD711063; Wed, 17 Aug 2022 10:27:59 -0700 (PDT) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9159A3F66F; Wed, 17 Aug 2022 10:27:57 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com Subject: [PATCH 6/6] [RFC] firmware: arm_scmi: Add SCMI PM driver remove routine Date: Wed, 17 Aug 2022 18:27:31 +0100 Message-Id: <20220817172731.1185305-7-cristian.marussi@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220817172731.1185305-1-cristian.marussi@arm.com> References: <20220817172731.1185305-1-cristian.marussi@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220817_102759_205969_99AB98A9 X-CRM114-Status: GOOD ( 15.24 ) 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 Currently, when removing the SCMI PM driver not all the resources registered with GenPD subsystem are currently properly de-registered. As a side effect of this after a driver unload/load cycle you get a splat with a few warnings like this: debugfs: Directory 'BIG_CPU0' with parent 'pm_genpd' already present! debugfs: Directory 'BIG_CPU1' with parent 'pm_genpd' already present! debugfs: Directory 'LITTLE_CPU0' with parent 'pm_genpd' already present! debugfs: Directory 'LITTLE_CPU1' with parent 'pm_genpd' already present! debugfs: Directory 'LITTLE_CPU2' with parent 'pm_genpd' already present! debugfs: Directory 'LITTLE_CPU3' with parent 'pm_genpd' already present! debugfs: Directory 'BIG_SSTOP' with parent 'pm_genpd' already present! debugfs: Directory 'LITTLE_SSTOP' with parent 'pm_genpd' already present! debugfs: Directory 'DBGSYS' with parent 'pm_genpd' already present! debugfs: Directory 'GPUTOP' with parent 'pm_genpd' already present! Add a proper scmi_pm_domain_remove callback to the driver in order to take care of all the needed cleanups not handled already by devres. Signed-off-by: Cristian Marussi --- The patch is marked as RFC since this solution can be controversial: what about any 3rd party consumer of the above unregistered genpd domain ? Should we even ever allow a PM driver like to be unloaded ? --- drivers/firmware/arm_scmi/scmi_pm_domain.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/firmware/arm_scmi/scmi_pm_domain.c b/drivers/firmware/arm_scmi/scmi_pm_domain.c index 581d34c95769..4e27c3d66a83 100644 --- a/drivers/firmware/arm_scmi/scmi_pm_domain.c +++ b/drivers/firmware/arm_scmi/scmi_pm_domain.c @@ -138,9 +138,28 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev) scmi_pd_data->domains = domains; scmi_pd_data->num_domains = num_domains; + dev_set_drvdata(dev, scmi_pd_data); + return of_genpd_add_provider_onecell(np, scmi_pd_data); } +static void scmi_pm_domain_remove(struct scmi_device *sdev) +{ + int i; + struct genpd_onecell_data *scmi_pd_data; + struct device *dev = &sdev->dev; + struct device_node *np = dev->of_node; + + of_genpd_del_provider(np); + + scmi_pd_data = dev_get_drvdata(dev); + for (i = 0; i < scmi_pd_data->num_domains; i++) { + if (!scmi_pd_data->domains[i]) + continue; + pm_genpd_remove(scmi_pd_data->domains[i]); + } +} + static const struct scmi_device_id scmi_id_table[] = { { SCMI_PROTOCOL_POWER, "genpd" }, { }, @@ -150,6 +169,7 @@ MODULE_DEVICE_TABLE(scmi, scmi_id_table); static struct scmi_driver scmi_power_domain_driver = { .name = "scmi-power-domain", .probe = scmi_pm_domain_probe, + .remove = scmi_pm_domain_remove, .id_table = scmi_id_table, }; module_scmi_driver(scmi_power_domain_driver);