linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Cristian Marussi <cristian.marussi@arm.com>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH AUTOSEL 5.15 04/20] firmware: arm_scmi: Add SCMI PM driver remove routine
Date: Sun,  2 Oct 2022 18:50:43 -0400	[thread overview]
Message-ID: <20221002225100.239217-4-sashal@kernel.org> (raw)
In-Reply-To: <20221002225100.239217-1-sashal@kernel.org>

From: Cristian Marussi <cristian.marussi@arm.com>

[ Upstream commit dea796fcab0a219830831c070b8dc367d7e0f708 ]

Currently, when removing the SCMI PM driver not all the resources
registered with genpd subsystem are 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 by devres framework.

Link: https://lore.kernel.org/r/20220817172731.1185305-7-cristian.marussi@arm.com
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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);
-- 
2.35.1


  parent reply	other threads:[~2022-10-02 22:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02 22:50 [PATCH AUTOSEL 5.15 01/20] firmware: arm_scmi: Improve checks in the info_get operations Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 02/20] firmware: arm_scmi: Harden accesses to the sensor domains Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 03/20] firmware: arm_scmi: Harden accesses to the reset domains Sasha Levin
2022-10-02 22:50 ` Sasha Levin [this message]
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 05/20] dmaengine: xilinx_dma: Fix devm_platform_ioremap_resource error handling Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 06/20] dmaengine: xilinx_dma: cleanup for fetching xlnx,num-fstores property Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 07/20] dmaengine: xilinx_dma: Report error in case of dma_set_mask_and_coherent API failure Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 08/20] ARM: dts: fix Moxa SDIO 'compatible', remove 'sdhci' misnomer Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 09/20] scsi: qedf: Fix a UAF bug in __qedf_probe() Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 10/20] net/ieee802154: fix uninit value bug in dgram_sendmsg Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 11/20] net: marvell: prestera: add support for for Aldrin2 Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 12/20] ALSA: hda/hdmi: Fix the converter reuse for the silent stream Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 13/20] um: Cleanup syscall_handler_t cast in syscalls_32.h Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 14/20] um: Cleanup compiler warning in arch/x86/um/tls_32.c Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 15/20] arch: um: Mark the stack non-executable to fix a binutils warning Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 16/20] net: atlantic: fix potential memory leak in aq_ndev_close() Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 17/20] drm/amd/display: Fix double cursor on non-video RGB MPO Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 18/20] drm/amd/display: Assume an LTTPR is always present on fixed_vs links Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 19/20] drm/amd/display: update gamut remap if plane has changed Sasha Levin
2022-10-02 22:50 ` [PATCH AUTOSEL 5.15 20/20] drm/amd/display: skip audio setup when audio stream is enabled Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221002225100.239217-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).