Skip to content

Commit dea796f

Browse files
cris-masudeep-holla
authored andcommitted
firmware: arm_scmi: Add SCMI PM driver remove routine
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>
1 parent b75c83d commit dea796f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

drivers/firmware/arm_scmi/scmi_pm_domain.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,28 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
138138
scmi_pd_data->domains = domains;
139139
scmi_pd_data->num_domains = num_domains;
140140

141+
dev_set_drvdata(dev, scmi_pd_data);
142+
141143
return of_genpd_add_provider_onecell(np, scmi_pd_data);
142144
}
143145

146+
static void scmi_pm_domain_remove(struct scmi_device *sdev)
147+
{
148+
int i;
149+
struct genpd_onecell_data *scmi_pd_data;
150+
struct device *dev = &sdev->dev;
151+
struct device_node *np = dev->of_node;
152+
153+
of_genpd_del_provider(np);
154+
155+
scmi_pd_data = dev_get_drvdata(dev);
156+
for (i = 0; i < scmi_pd_data->num_domains; i++) {
157+
if (!scmi_pd_data->domains[i])
158+
continue;
159+
pm_genpd_remove(scmi_pd_data->domains[i]);
160+
}
161+
}
162+
144163
static const struct scmi_device_id scmi_id_table[] = {
145164
{ SCMI_PROTOCOL_POWER, "genpd" },
146165
{ },
@@ -150,6 +169,7 @@ MODULE_DEVICE_TABLE(scmi, scmi_id_table);
150169
static struct scmi_driver scmi_power_domain_driver = {
151170
.name = "scmi-power-domain",
152171
.probe = scmi_pm_domain_probe,
172+
.remove = scmi_pm_domain_remove,
153173
.id_table = scmi_id_table,
154174
};
155175
module_scmi_driver(scmi_power_domain_driver);

0 commit comments

Comments
 (0)