Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2440392ioo; Sat, 28 May 2022 13:46:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynbZIGtDD2CVnEnUOgmp6zsgQ7hJU0UYbRt3v+tqVsboZkd2G8mUKyKh0iSlvd/rM4dmj3 X-Received: by 2002:aa7:88d2:0:b0:50a:cf7d:6ff1 with SMTP id k18-20020aa788d2000000b0050acf7d6ff1mr50594577pff.67.1653770818455; Sat, 28 May 2022 13:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653770818; cv=none; d=google.com; s=arc-20160816; b=sv4YFP6Q8cWQJX9aH07oSbzXCOYUlgWT14ZiXECPKqpsXyp7i8qtfiu1soPxyUBlH0 9RTD9c/RnU88FF4+mPtZ7Hc0rFss9s4IuvQMpi9gboYofonFGRsg6e+wPkBUEzyGW/wx elQbzFITfMOsjdR/P/LM2iLbIKmddY2gzMhJxagl09fFy3CWmZsV7/1iYoqoXuYIPKGE wm/+6b2TF87X3CGenREE5smyZ0A9DqfLO/UaPI08lzk4BGL+14SCciuy1rXF3fqfb+Hq Q2qsFkLe6nB1AsIz6yly5tvQemcMA0rmv2mK5C6gcrc/wdsWSOLonous6zAFFdqEZyjZ 4+jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=GF8r/LqGxsImMjC+zviPxuhzQ2c3jmTSmCRe85gniNQ=; b=Z7swJt/qoz7HNwGc5oxayTBpZabqXXD4qWo/qP3vDw/V80tR41csHG0SP/Gn7YiKFN 6WVjuZzzL/4E+Zi9lB3WTADjTyM8W7pL4U5f8ruoSBKpJ/+oW3pd0gbXy+BLm3wc3dhz BhtrYJddPS78QDpnveGwxUsuf0FU8hR1Z/3ulvtIac6UyLC1lNy8lWNxplwolEwE+PsD FZkzLcv1Wgj2QomCdEj9zbUuCLz3IS6RhlZqDcNVdElOSroC2/JP1mMeYYubHn+iIjNG JjO/v8dbDXjfxjOtXeyRV3UzEJNbh9992EOu2Qbpij/OHwjCjxObWXHvvUF8f6KuTSr/ WAzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=C3Of6hnk; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id bi12-20020a170902bf0c00b00163c5233708si1017244plb.430.2022.05.28.13.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:46:58 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=C3Of6hnk; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6C41D69CD1; Sat, 28 May 2022 12:47:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352862AbiE0N64 (ORCPT + 99 others); Fri, 27 May 2022 09:58:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240514AbiE0N6x (ORCPT ); Fri, 27 May 2022 09:58:53 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 024E512AAF; Fri, 27 May 2022 06:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1653659933; x=1685195933; h=message-id:date:mime-version:subject:from:to:cc: references:in-reply-to:content-transfer-encoding; bh=GF8r/LqGxsImMjC+zviPxuhzQ2c3jmTSmCRe85gniNQ=; b=C3Of6hnkQ56S7bWQ7cdTortNPOiWmyrHXfL6fOChe+s7IwPi5IHleIPB HRciHQQ1yPTRoU1zVx+7vRKSdpZ9Wsz3K9MD9v/N/jO/ASPhGewFLgPOy Ih9ef9P1KP9jQ7XYSvdOl3VReCXiF5/X1gokTSvTAxE+C45WKAGhBVBxI c=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 27 May 2022 06:58:52 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2022 06:58:52 -0700 Received: from nalasex01b.na.qualcomm.com (10.47.209.197) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 27 May 2022 06:58:51 -0700 Received: from [10.50.53.253] (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 27 May 2022 06:58:49 -0700 Message-ID: <35141cc2-8269-b4c6-8763-6f18c96ea12c@quicinc.com> Date: Fri, 27 May 2022 19:28:46 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v4 1/2] power_supply: Register cooling device outside of probe From: Manaf Meethalavalappu Pallikunhi To: Sebastian Reichel CC: David Collins , Subbaraman Narayanamurthy , , , References: <1640162489-7847-1-git-send-email-quic_manafm@quicinc.com> <029160a5-a7b0-790c-077a-985be5a1d560@quicinc.com> In-Reply-To: <029160a5-a7b0-790c-077a-985be5a1d560@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 ++ On 1/25/2022 1:04 AM, Manaf Meethalavalappu Pallikunhi wrote: > Hi Sebastian Reichel, > > Just reminder for review for these patches > > Thanks, > > Manaf > > On 12/22/2021 2:11 PM, Manaf Meethalavalappu Pallikunhi wrote: >> Registering the cooling device from the probe can result in the >> execution of get_property() function before it gets initialized. >> >> To avoid this, register the cooling device from a workqueue >> instead of registering in the probe. >> >> Signed-off-by: Manaf Meethalavalappu Pallikunhi >> >> --- >>   drivers/power/supply/power_supply_core.c | 10 ++++------ >>   1 file changed, 4 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/power/supply/power_supply_core.c >> b/drivers/power/supply/power_supply_core.c >> index 668369b..ef6f290 100644 >> --- a/drivers/power/supply/power_supply_core.c >> +++ b/drivers/power/supply/power_supply_core.c >> @@ -132,6 +132,7 @@ void power_supply_changed(struct power_supply *psy) >>   } >>   EXPORT_SYMBOL_GPL(power_supply_changed); >>   +static int psy_register_cooler(struct power_supply *psy); >>   /* >>    * Notify that power supply was registered after parent finished >> the probing. >>    * >> @@ -139,6 +140,8 @@ EXPORT_SYMBOL_GPL(power_supply_changed); >>    * calling power_supply_changed() directly from >> power_supply_register() >>    * would lead to execution of get_property() function provided by >> the driver >>    * too early - before the probe ends. >> + * Also, registering cooling device from the probe will execute the >> + * get_property() function. So register the cooling device after the >> probe. >>    * >>    * Avoid that by waiting on parent's mutex. >>    */ >> @@ -156,6 +159,7 @@ static void >> power_supply_deferred_register_work(struct work_struct *work) >>       } >>         power_supply_changed(psy); >> +    psy_register_cooler(psy); >>         if (psy->dev.parent) >>           mutex_unlock(&psy->dev.parent->mutex); >> @@ -1238,10 +1242,6 @@ __power_supply_register(struct device *parent, >>       if (rc) >>           goto register_thermal_failed; >>   -    rc = psy_register_cooler(psy); >> -    if (rc) >> -        goto register_cooler_failed; >> - >>       rc = power_supply_create_triggers(psy); >>       if (rc) >>           goto create_triggers_failed; >> @@ -1271,8 +1271,6 @@ __power_supply_register(struct device *parent, >>   add_hwmon_sysfs_failed: >>       power_supply_remove_triggers(psy); >>   create_triggers_failed: >> -    psy_unregister_cooler(psy); >> -register_cooler_failed: >>       psy_unregister_thermal(psy); >>   register_thermal_failed: >>       device_del(dev); >>