From patchwork Tue Jun 26 12:10:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Pasternak X-Patchwork-Id: 934770 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41FMNw5MyRz9rxs for ; Tue, 26 Jun 2018 20:15:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934069AbeFZKPL (ORCPT ); Tue, 26 Jun 2018 06:15:11 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:37363 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933795AbeFZKPI (ORCPT ); Tue, 26 Jun 2018 06:15:08 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from vadimp@mellanox.com) with ESMTPS (AES256-SHA encrypted); 26 Jun 2018 13:17:43 +0300 Received: from r-mgtswh-226.mtr.labs.mlnx. (r-mgtswh-226.mtr.labs.mlnx [10.209.1.51]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w5QAEt1N011163; Tue, 26 Jun 2018 13:15:04 +0300 From: Vadim Pasternak To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux@roeck-us.net, rui.zhang@intel.com, edubezval@gmail.com, jiri@resnulli.us, mlxsw@mellanox.com, michaelsh@mellanox.com, Vadim Pasternak Subject: [patch net-next RFC 07/12] mlxsw: core: Extend thermal zone operations with get_trend method Date: Tue, 26 Jun 2018 12:10:32 +0000 Message-Id: <1530015037-67361-8-git-send-email-vadimp@mellanox.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1530015037-67361-1-git-send-email-vadimp@mellanox.com> References: <1530015037-67361-1-git-send-email-vadimp@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Thermal get_trend method is added in order to notify user in case of fast temperature downgrade. It could happen in case one or few very hot port cables are removed. In such situation temperature trend could go down once, and then could stay in a stable state, while PWM state will be decreased only once and could stay in not optimal high state. Notification will allow user to take an appropriate action if necessary. Signed-off-by: Vadim Pasternak Acked-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index 91c4946..1587820 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -281,6 +281,32 @@ static int mlxsw_thermal_set_trip_hyst(struct thermal_zone_device *tzdev, return 0; } +static int mlxsw_thermal_get_trend(struct thermal_zone_device *tzdev, + int trip, enum thermal_trend *trend) +{ + int delta; + + if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS) + return -EINVAL; + + delta = tzdev->last_temperature - tzdev->temperature; + if (delta > MLXSW_ENV_TEMP_WINDOW) { + /* Notify user about fast temperature decreasing by sending + * hwmon uevent. Decreasing could happen in case one or few + * very hot port cables have been removed. In this situation + * temperature trend could go down once, and then could stay + * in a stable state, while PWM state will be decreased only + * once. As a side effect PWM could be not at optimal speed. + * Notification will allow user to handle such case, if user + * supposes to optimize PWM state. + */ + kobject_uevent(&tzdev->device.kobj, KOBJ_CHANGE); + } + + /* Return non-zero value to pass control to get_tz_trend() routine. */ + return 1; +} + static struct thermal_zone_device_ops mlxsw_thermal_ops = { .bind = mlxsw_thermal_bind, .unbind = mlxsw_thermal_unbind, @@ -292,6 +318,7 @@ static struct thermal_zone_device_ops mlxsw_thermal_ops = { .set_trip_temp = mlxsw_thermal_set_trip_temp, .get_trip_hyst = mlxsw_thermal_get_trip_hyst, .set_trip_hyst = mlxsw_thermal_set_trip_hyst, + .get_trend = mlxsw_thermal_get_trend, }; static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev,