From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F787ECAAA1 for ; Fri, 28 Oct 2022 16:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbiJ1QeM (ORCPT ); Fri, 28 Oct 2022 12:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiJ1QeL (ORCPT ); Fri, 28 Oct 2022 12:34:11 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7F5B1DE3CE; Fri, 28 Oct 2022 09:34:09 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id i7so6692566oif.4; Fri, 28 Oct 2022 09:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:sender :from:to:cc:subject:date:message-id:reply-to; bh=nwbPjBZmRyyK77zC/9SPzBIJETh2C9WOSbSEnKhMCwY=; b=B7YHTFsyLRTHAa4c9U0mEWUART9I0BHpU4ccCD8Rv4/9/2Gz4blKiCoeq/eQjUvLDS wAjQQgcZ2EiCofM6YtJYvK/gW8tQHoRjVTMvxc4my/tWnn4rOaYybarnPmjMU8ZTK6RP NmQQY67kfEluF9iJzf4pdwmnz6p5cGrv7pZiYP8b6uEiOc+WR0BkVsNy/fF+sjBBzNnA 7ThUKAvQZNfVOA9miMgMsiovoNFkYU2/F4pKdFYd5HHyK3CvHBlyh0QMH0gWPem8riLM j5iSLuntEaRuqmGtMNRVCAiRl9p9gjdj3szv9/MlDb9q23TYJCS7duxZ43X31qX08epj mbRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nwbPjBZmRyyK77zC/9SPzBIJETh2C9WOSbSEnKhMCwY=; b=tDN06vPGibDEVlU5VI84sS5SW6aXS+Dnrw7Kk5rlIrSCT9PF0yDEbLdr7KgtIqJRPZ LyAchDmFNnCwyQ8dHry4RzZ0MCqKGsNIy/lgAmnaOipMTPpjm72qDG48nIloV0DAoRND fXeFEehGzH4QPP8OpSwkpLrvuZUbuB8B7MH2m9ji40gt6GVoXY+agoVQ6qLPr8om64Es 3FkxIalQv9i7AoOzP/3MsU8cmsIpNCZejcyu8Y72Rzb9h/lcNoFd9eOd+rHGGideMuvI 2ra0ciSjGGYZioOb06BTN2RR4iv5q7JikVnQpU0zfmte/FREhxKexc5dZOlvjwaHnQl2 cTDw== X-Gm-Message-State: ACrzQf0bLaDj5m+dN/BB1R+YBuZoUeAff3C6cISU1WQO+DmOpLcRFkey Yc/+deQ25IejB7qwZLtymrc= X-Google-Smtp-Source: AMsMyM57F2e1pkir5cLcENr/NGv8gZVjUbB/97CEMjfcnFPYB7ZnEwiO4FsIsZ9jyOvZjWsnqNhBfg== X-Received: by 2002:a05:6808:f01:b0:354:2d95:3f96 with SMTP id m1-20020a0568080f0100b003542d953f96mr155387oiw.41.1666974848978; Fri, 28 Oct 2022 09:34:08 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d24-20020a9d5e18000000b0066c312b044dsm733848oti.27.2022.10.28.09.34.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Oct 2022 09:34:07 -0700 (PDT) Sender: Guenter Roeck Message-ID: <7acc7a49-debb-abdb-f01c-f8adef4c1f0e@roeck-us.net> Date: Fri, 28 Oct 2022 09:34:05 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Content-Language: en-US To: Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, Daniel Lezcano , linux-hwmon@vger.kernel.org References: <20221028140833.280091-1-cristian.marussi@arm.com> <20221028140833.280091-7-cristian.marussi@arm.com> From: Guenter Roeck Subject: Re: [PATCH 7/8] hwmon: (scmi) Register explicitly with Thermal Framework In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org On 10/28/22 09:15, Cristian Marussi wrote: > On Fri, Oct 28, 2022 at 08:58:58AM -0700, Guenter Roeck wrote: >> On 10/28/22 08:35, Cristian Marussi wrote: >> [ ... ] >>>>> + /* >>>>> + * Try to register a temperature sensor with the Thermal Framework: >>>>> + * skip sensors not defined as part of any thermal zone (-ENODEV) but >>>>> + * report any other errors related to misconfigured zones/sensors. >>>>> + */ >>>>> + tzd = devm_thermal_of_zone_register(dev, th_sensor->info->id, th_sensor, >>>>> + &scmi_hwmon_thermal_ops); >>>>> + if (IS_ERR(tzd)) { >>>>> + devm_kfree(dev, th_sensor); >>>>> + >>>>> + if (PTR_ERR(tzd) != -ENODEV) >>>>> + return PTR_ERR(tzd); >>>>> + >>>>> + dev_info(dev, "Sensor '%s' not attached to any thermal zone.\n", >>>>> + sensor->name); >>>> >>>> There were complaints about this message as it is noisy. If you send >>>> another version, please drop it unless attaching each sensor to a thermal >>>> zone is strongly expected. If you don't send another version, I'll drop it >>>> while applying. >>>> >>> >>> Ok fine for me. I am waiting to have some feedback from Sudeep too, but >>> I do not have plan for another version as of now. >>> >>> As a side note, though, I understand the 'noisiness' argument, but, >>> sincerely this same message in the original HWMON code was the only >>> reason why I spotted that something was wrong with the SCMI/HWMON >>> interactions and discovered the indexes/ids mismatch...if not for >>> that it would have gone un-noticed that a perfectly configured >>> ThermalZone/Sensor was not working properly... >>> (un-noticed at least until something would have been burnt to fire >>> in my house .. joking :P) >>> >> >> Good point. >> >> Did you ever check the returned error code ? Maybe we could use it to >> distinguish "it is not attached to a thermal zone because it is not >> associated with one" from "attaching to a thermal zone failed because >> its configuration is bad/incomplete". >> > > Yes, it is what I do already indeed, in this regards I mimicked what > the hwmon-thermal bridge was doing. > > In scmi_thermal_sensor_register() this message is printed out only > if Thermal registration returned -ENODEV and no err is reported > (which means teh specified sensor was not found attached to any TZ), > while in the caller of scmi_thermal_sensor_register() for any error > returned but -ENOMEM I print: > > "Thermal zone misconfigured for %s. err=%d\n", > > since any error reported by Thermal other than ENODEV and ENOMEM > means the DT parsing unveiled some configuration anomaly. > Ok, then let's hope that this finds misconfigurations and drop the info message. I just noticed another problem in your code: + if (ret == -ENOMEM) + return ret; + else if (ret) + dev_warn(dev, + "Thermal zone misconfigured for %s. err=%d\n", + sensor->name, ret); Static analyzers will rightfully notice that else after return is unnecessary. Please rewrite and drop the else. I think something like if (ret) { if (ret == -ENOMEM) return ret; dev_warn(dev, "Thermal zone misconfigured for %s. err=%d\n", sensor->name, ret); } would be better since ret would only be evaluated once in the no-error case. Thanks, Guenter From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF07FC38A02 for ; Fri, 28 Oct 2022 16:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:Subject:From:References:Cc:To: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xWgAvrZBjJ4omDRdgfh+dPnjFwNqENGzFwwHsnIaPq4=; b=JEX8AetKwh73tC X2vJ/v1HkKoElAXbBVXV3rfbdhH1bq/f6U4idGcMeuHtL29XJwbHrVjZXfTYPfv+kVagb1ey58CEY niH3jwETn6OISWiOWjM6tdiq0kzVhMzVCU5qaDAq/iLYDfdISe5efNd8hUeZNK8Nl4mxTuQaBiqPC s+/BQy9GqtikCxRtc6gq2FwTkw+ofprqN4Pro/bwsvrozfY6B+enyWSKCpT1bp8GrUqJD0U+rOu4L KTnXei99BMyHNnlchRfD/9LvP3DdJ/eKXZWXdokUuC85wsR/SLDND8UDAIEQCss3pYxbUVcIAgMje 2xOMfyC7K96jndrFQipw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSJC-000vSs-74; Fri, 28 Oct 2022 16:34:14 +0000 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSJ8-000vRH-SU for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 16:34:12 +0000 Received: by mail-oi1-x22d.google.com with SMTP id n83so6653264oif.11 for ; Fri, 28 Oct 2022 09:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:sender :from:to:cc:subject:date:message-id:reply-to; bh=nwbPjBZmRyyK77zC/9SPzBIJETh2C9WOSbSEnKhMCwY=; b=B7YHTFsyLRTHAa4c9U0mEWUART9I0BHpU4ccCD8Rv4/9/2Gz4blKiCoeq/eQjUvLDS wAjQQgcZ2EiCofM6YtJYvK/gW8tQHoRjVTMvxc4my/tWnn4rOaYybarnPmjMU8ZTK6RP NmQQY67kfEluF9iJzf4pdwmnz6p5cGrv7pZiYP8b6uEiOc+WR0BkVsNy/fF+sjBBzNnA 7ThUKAvQZNfVOA9miMgMsiovoNFkYU2/F4pKdFYd5HHyK3CvHBlyh0QMH0gWPem8riLM j5iSLuntEaRuqmGtMNRVCAiRl9p9gjdj3szv9/MlDb9q23TYJCS7duxZ43X31qX08epj mbRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nwbPjBZmRyyK77zC/9SPzBIJETh2C9WOSbSEnKhMCwY=; b=aObfLit0bUQX/38QvykrkEDmhFTFC8xL88yF4XzjQbvDWSeZ59LEPA4/BhKY9JeQlP GygQQokhlcjhGls8MpQNy9OVfUXwKcAQWsxNdTLo5UPFnvZw24sSu2YJnfjx4Ly4iDS3 kWd3ihbVK7HG2cIBBZggKbBBOzOtu8oqCzhvf/l6UhRH9drGUY2vwRYxzNu4QNJZLiea 9zHximGhVPf/U+sqrjGRvw0Hdks4w7keiT1xNr5WAwYj+rjeqvfSm0kcpA04JbOC5X04 AsPOx0gEJFkl6t/fsTa87K6fD5oxuPU1wOUKDjYZnGzkPrtJ+exgKzEltyOCp4mYz4Bv Bx3A== X-Gm-Message-State: ACrzQf0CLkgVq/D7WStzPVoDxerSxGKmfGCrc0iAxTITK1udBTQZaT+Y vrr9klHT4wrWCCOLsS6DJ7w= X-Google-Smtp-Source: AMsMyM57F2e1pkir5cLcENr/NGv8gZVjUbB/97CEMjfcnFPYB7ZnEwiO4FsIsZ9jyOvZjWsnqNhBfg== X-Received: by 2002:a05:6808:f01:b0:354:2d95:3f96 with SMTP id m1-20020a0568080f0100b003542d953f96mr155387oiw.41.1666974848978; Fri, 28 Oct 2022 09:34:08 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d24-20020a9d5e18000000b0066c312b044dsm733848oti.27.2022.10.28.09.34.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Oct 2022 09:34:07 -0700 (PDT) Message-ID: <7acc7a49-debb-abdb-f01c-f8adef4c1f0e@roeck-us.net> Date: Fri, 28 Oct 2022 09:34:05 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Content-Language: en-US To: Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, Daniel Lezcano , linux-hwmon@vger.kernel.org References: <20221028140833.280091-1-cristian.marussi@arm.com> <20221028140833.280091-7-cristian.marussi@arm.com> From: Guenter Roeck Subject: Re: [PATCH 7/8] hwmon: (scmi) Register explicitly with Thermal Framework In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_093410_954808_CEB34B9A X-CRM114-Status: GOOD ( 26.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 10/28/22 09:15, Cristian Marussi wrote: > On Fri, Oct 28, 2022 at 08:58:58AM -0700, Guenter Roeck wrote: >> On 10/28/22 08:35, Cristian Marussi wrote: >> [ ... ] >>>>> + /* >>>>> + * Try to register a temperature sensor with the Thermal Framework: >>>>> + * skip sensors not defined as part of any thermal zone (-ENODEV) but >>>>> + * report any other errors related to misconfigured zones/sensors. >>>>> + */ >>>>> + tzd = devm_thermal_of_zone_register(dev, th_sensor->info->id, th_sensor, >>>>> + &scmi_hwmon_thermal_ops); >>>>> + if (IS_ERR(tzd)) { >>>>> + devm_kfree(dev, th_sensor); >>>>> + >>>>> + if (PTR_ERR(tzd) != -ENODEV) >>>>> + return PTR_ERR(tzd); >>>>> + >>>>> + dev_info(dev, "Sensor '%s' not attached to any thermal zone.\n", >>>>> + sensor->name); >>>> >>>> There were complaints about this message as it is noisy. If you send >>>> another version, please drop it unless attaching each sensor to a thermal >>>> zone is strongly expected. If you don't send another version, I'll drop it >>>> while applying. >>>> >>> >>> Ok fine for me. I am waiting to have some feedback from Sudeep too, but >>> I do not have plan for another version as of now. >>> >>> As a side note, though, I understand the 'noisiness' argument, but, >>> sincerely this same message in the original HWMON code was the only >>> reason why I spotted that something was wrong with the SCMI/HWMON >>> interactions and discovered the indexes/ids mismatch...if not for >>> that it would have gone un-noticed that a perfectly configured >>> ThermalZone/Sensor was not working properly... >>> (un-noticed at least until something would have been burnt to fire >>> in my house .. joking :P) >>> >> >> Good point. >> >> Did you ever check the returned error code ? Maybe we could use it to >> distinguish "it is not attached to a thermal zone because it is not >> associated with one" from "attaching to a thermal zone failed because >> its configuration is bad/incomplete". >> > > Yes, it is what I do already indeed, in this regards I mimicked what > the hwmon-thermal bridge was doing. > > In scmi_thermal_sensor_register() this message is printed out only > if Thermal registration returned -ENODEV and no err is reported > (which means teh specified sensor was not found attached to any TZ), > while in the caller of scmi_thermal_sensor_register() for any error > returned but -ENOMEM I print: > > "Thermal zone misconfigured for %s. err=%d\n", > > since any error reported by Thermal other than ENODEV and ENOMEM > means the DT parsing unveiled some configuration anomaly. > Ok, then let's hope that this finds misconfigurations and drop the info message. I just noticed another problem in your code: + if (ret == -ENOMEM) + return ret; + else if (ret) + dev_warn(dev, + "Thermal zone misconfigured for %s. err=%d\n", + sensor->name, ret); Static analyzers will rightfully notice that else after return is unnecessary. Please rewrite and drop the else. I think something like if (ret) { if (ret == -ENOMEM) return ret; dev_warn(dev, "Thermal zone misconfigured for %s. err=%d\n", sensor->name, ret); } would be better since ret would only be evaluated once in the no-error case. Thanks, Guenter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel