From patchwork Thu Jun 21 15:28:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Pasternak X-Patchwork-Id: 932730 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 41BN1l26jCz9s2R for ; Thu, 21 Jun 2018 23:33:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933259AbeFUNdN (ORCPT ); Thu, 21 Jun 2018 09:33:13 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54725 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933247AbeFUNcf (ORCPT ); Thu, 21 Jun 2018 09:32:35 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from vadimp@mellanox.com) with ESMTPS (AES256-SHA encrypted); 21 Jun 2018 16:35:02 +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 w5LDWJEZ015344; Thu, 21 Jun 2018 16:32:28 +0300 From: Vadim Pasternak To: davem@davemloft.net Cc: netdev@vger.kernel.org, jiri@resnulli.us, Vadim Pasternak Subject: [PATCH v0 09/12] mlxsw: core: Extend thermal zone operations with get_trend method Date: Thu, 21 Jun 2018 15:28:03 +0000 Message-Id: <1529594883-20619-10-git-send-email-vadimp@mellanox.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1529594883-20619-1-git-send-email-vadimp@mellanox.com> References: <1529594883-20619-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,