From patchwork Wed Sep 11 22:32:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 173644 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1341510ilq; Wed, 11 Sep 2019 15:32:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEKKuRoL4O6zWokjRBI3sHJIcY5m48xGNJaZbGu8ow6zk+r02cHp+eQ749Ugnqf13d+y8v X-Received: by 2002:a17:906:cf8a:: with SMTP id um10mr30814317ejb.310.1568241167494; Wed, 11 Sep 2019 15:32:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568241167; cv=none; d=google.com; s=arc-20160816; b=w+U33foSXkLyCsIui6M3lHOQrYE7ezAMefGBBYrED15j4A6TiGjbdV/+mSPaRXHpNj OlTwB/6c96FJRbBJfowWEW3SWjbnqrNZqgUxvCpe+odNb20ggCYLO+W0GQ2DNK2XuP93 TO0grduCdro8GohnjnrNK8DGpRPFuPbnqdRoPDgnNpvDrwaxJTG0c6OpzfonFEcWtx5z 6zJv+ZPq/CQOu7rWWzM+DG4tRb2o27wrllcFiDGSrMsbfdmwtV5essfvsESoAnE1P0/k /f4HDucNsAut95P8kfJZMog1EoCs1yaX+oSLVEQmvDreJdo4x6Qu0mXjWPwr3pvsxsl6 iDjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=ScbFZHT8u+sMIz+KTn9O5YNo5f1GPSOha1PRAwThAGs=; b=s/udXxxowQsq4ZiCVLBc81Lqw/oOi1oA9XulcZIz2jyv5YbgOAs3Wk5WalfaEbFhBC cBKJOnHN7g1Xq9LHDDw1in4dyXz0su5R3kYJluIs9QQH2S3u0MLPjFTJJj1IcXinaZvB KZw4m2BexZTyPSipNdge4WN/HcaChmBVasOvvrXPnEauJX06Ma8NlhB4a3QDhsHBEoeB 0rv7WrjKU+Q6MOgqwQ3Zd/J/inQ3OaAzowIJ1vGeg2dj4KpJn9ZXHtZmW9zUfyZocnUz 5KHbzRM5oRyK4HrzO//ULHaqUCvwyAq1U7ISiakMmdX6G19xlykYW6zeDGZwTE0vRvm/ oQaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ByRODCAW; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qq22si12042300ejb.288.2019.09.11.15.32.44; Wed, 11 Sep 2019 15:32:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ByRODCAW; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728746AbfIKWco (ORCPT + 15 others); Wed, 11 Sep 2019 18:32:44 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:38353 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728739AbfIKWco (ORCPT ); Wed, 11 Sep 2019 18:32:44 -0400 Received: by mail-pg1-f195.google.com with SMTP id d10so12271835pgo.5 for ; Wed, 11 Sep 2019 15:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ScbFZHT8u+sMIz+KTn9O5YNo5f1GPSOha1PRAwThAGs=; b=ByRODCAWvy/kyXsVj95HgmPjB3MkHbd/yKPycsFepYBcnM6Wz2GxAzfDZvefAaoIf9 /I9cKG+8WEqcquskrx5j4vVH9a7aCTDg3GQoN0oAjEv84zEVwcrXiPmkQx0HUc8vtKtb SNd0RfJcM811JvaSxdh7ovqo/QBId4Ds4cpSX3yYQWEvWYSbXHZINi7TcurTXCILekRn CazeH4EQSzp2WPG1phLN1DYAFAqgNy5OrtFHLwYP0kfeMnl7+l/jlLqlQDj8Zohe2yIZ gv7jYIJQhP6AFhlrJbHk8u8ezIMMucJomybd69kFN9F+dcV9Zp289DqDnRQg6+nCLXSd kfHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=ScbFZHT8u+sMIz+KTn9O5YNo5f1GPSOha1PRAwThAGs=; b=B2TZFj5cHHGDMO25u2NBY6xT1edQe8M9FVm1VrH8uQJRYCGMS71Aup12n24Gc0DXkY iFjR+EQVSCRuR/Gz+DRVaApD8Kh+IMDoJzRekYkmH50V/G6LeFpxoUPMBf5BXhK0ly2m nGlBmR+WRKwqzQBQdyZfytGIZLljQPO9uQDqpmaNW0imQiEuYC7wvI7dKR16f+qmdYPV ZKlclqMnfAONK01xbsXeFT0+gAimH1fLH5jiyyFAqeA6KOskMzNYrhJfAVpFJ6V36CZN nLC8263EtkKLUvDgEnNIt5KNFlQ2lID2qkOnaqqyIJDO8GtM6aXcrNRonmJ7Exc3dWNN joCA== X-Gm-Message-State: APjAAAWyl/pvlLPuLpV+OZCEcbiKo5dK4voxs37pcJtNtS8VTVhJx5Vn KSiaSjwr1iFNyjsspEZlijyUuA== X-Received: by 2002:a17:90a:210b:: with SMTP id a11mr7931109pje.23.1568241163434; Wed, 11 Sep 2019 15:32:43 -0700 (PDT) Received: from localhost ([49.248.179.160]) by smtp.gmail.com with ESMTPSA id t9sm20936002pgj.89.2019.09.11.15.32.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2019 15:32:42 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, agross@kernel.org, tdas@codeaurora.org, swboyd@chromium.org, ilina@codeaurora.org, "Rafael J. Wysocki" , Daniel Lezcano , Viresh Kumar , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH 1/5] thermal: Initialize thermal subsystem earlier Date: Thu, 12 Sep 2019 04:02:30 +0530 Message-Id: <97b6f861e6e6a2ac7b50efb7211f3c8e7fe872b0.1568240476.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Lina Iyer Now that the thermal framework is built-in, in order to facilitate thermal mitigation as early as possible in the boot cycle, move the thermal framework initialization to core_initcall. However, netlink initialization happens only as part of subsys_initcall. At this time in the boot process, the userspace is not available yet. So initialize the netlink events later in fs_initcall. Signed-off-by: Lina Iyer [Rebased, refactored and moved to core_initcall] Signed-off-by: Amit Kucheria --- drivers/thermal/thermal_core.c | 41 ++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 17 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 6bab66e84eb5..b13e8a9298cc 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1468,6 +1468,8 @@ static struct genl_family thermal_event_genl_family __ro_after_init = { .n_mcgrps = ARRAY_SIZE(thermal_event_mcgrps), }; +static bool allow_netlink_events; + int thermal_generate_netlink_event(struct thermal_zone_device *tz, enum events event) { @@ -1482,6 +1484,9 @@ int thermal_generate_netlink_event(struct thermal_zone_device *tz, if (!tz) return -EINVAL; + if (!allow_netlink_events) + return -ENODEV; + /* allocate memory */ size = nla_total_size(sizeof(struct thermal_genl_event)) + nla_total_size(0); @@ -1533,16 +1538,18 @@ EXPORT_SYMBOL_GPL(thermal_generate_netlink_event); static int __init genetlink_init(void) { - return genl_register_family(&thermal_event_genl_family); -} + int ret; -static void genetlink_exit(void) -{ - genl_unregister_family(&thermal_event_genl_family); + ret = genl_register_family(&thermal_event_genl_family); + if (!ret) + allow_netlink_events = true; + return ret; } + #else /* !CONFIG_NET */ static inline int genetlink_init(void) { return 0; } -static inline void genetlink_exit(void) {} +static inline int thermal_generate_netlink_event(struct thermal_zone_device *tz, + enum events event) { return -ENODEV; } #endif /* !CONFIG_NET */ static int thermal_pm_notify(struct notifier_block *nb, @@ -1591,19 +1598,15 @@ static int __init thermal_init(void) mutex_init(&poweroff_lock); result = thermal_register_governors(); if (result) - goto error; + goto init_exit; result = class_register(&thermal_class); if (result) goto unregister_governors; - result = genetlink_init(); - if (result) - goto unregister_class; - result = of_parse_thermal_zones(); if (result) - goto exit_netlink; + goto exit_zone_parse; result = register_pm_notifier(&thermal_pm_nb); if (result) @@ -1612,13 +1615,11 @@ static int __init thermal_init(void) return 0; -exit_netlink: - genetlink_exit(); -unregister_class: +exit_zone_parse: class_unregister(&thermal_class); unregister_governors: thermal_unregister_governors(); -error: +init_exit: ida_destroy(&thermal_tz_ida); ida_destroy(&thermal_cdev_ida); mutex_destroy(&thermal_list_lock); @@ -1626,4 +1627,10 @@ static int __init thermal_init(void) mutex_destroy(&poweroff_lock); return result; } -fs_initcall(thermal_init); + +static int __init thermal_netlink_init(void) +{ + return genetlink_init(); +} +core_initcall(thermal_init); +fs_initcall(thermal_netlink_init);