Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5114418rwb; Wed, 17 Aug 2022 11:17:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR6CNw/4mSZbMaQvDZxSqKo3xF4Q2Hu/3jY/kP9quXo+a5cShamlG1AZ3PNzxXekHIqQzUNC X-Received: by 2002:a17:903:2113:b0:16f:6ee:65f2 with SMTP id o19-20020a170903211300b0016f06ee65f2mr28006608ple.76.1660760274979; Wed, 17 Aug 2022 11:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660760274; cv=none; d=google.com; s=arc-20160816; b=o3oAsM9rDbHAoaLOrS8sAQJBQp0P17ELXdAdQrEb8Duo2tiOleTfiszTTOSRjYWeaZ TrRGgU1d8hBkX/2M98otUkFK2+cbLvyaWc6uBB7oQekM+LUD0H19kusD9FGbsYTl4Ct0 fePL6+R+oaYL9kNcSxwWZjx+0z5wcMWMclBIAPjKU+q9xypTwh3v6kipFNNUEIFBihp2 YgJ0xPulNzf1rs68Cc0p7rK5OTK3noNKbIuVJR33hDQSdTCfz7l+Lt602JErC4H68S5f SDQ1TDfEu9CsFs78lvkjVgcFlRGuPh1fq//byOUZtUWWw4C5KLVss3iTjdGVh5r6TnM6 blEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Pl2DapQ9K9E8dNRbFtUPE/5gI5PNXot5lMmcjIDk7JM=; b=qWbURIFft/QITLfQ3Y7jsQCYRdV0xDHclIyF4mwx83Qq876dWG7IwC9Vg3hwTI2UTd JTbTwNlZlVIULrxznjAuIaZQxy46ePNOkPh5V7OuW/7fSJzTDAWgr7z3KtRhJyM6eVLU MGB8V2+WlTj0+DLyG70DLcwtfjaGXbTSX8luJoQKG/EJ8LYGTFdl1Vzh94aLucLCSQq2 uzUxWCYGu/0+p8RbTAXGNjKeomSUoouHaOTpMsiSdiJfLdpw+Vg8TyUnDKmQvPntWeMe CE5XQY81utUICrgwZF4Q1pyQfR5Gwtm74ilNAcZTKc4VTPF8ILD6VA+OK7sJLjBFW/tL PmRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s38-20020a056a0017a600b0052b1e2f86ccsi1338265pfg.321.2022.08.17.11.17.44; Wed, 17 Aug 2022 11:17:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241177AbiHQR2S (ORCPT + 99 others); Wed, 17 Aug 2022 13:28:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241106AbiHQR2A (ORCPT ); Wed, 17 Aug 2022 13:28:00 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 84FA0A1D24 for ; Wed, 17 Aug 2022 10:27:58 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.32.0