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 X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0282C282CA for ; Wed, 13 Feb 2019 11:29:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A1532075B for ; Wed, 13 Feb 2019 11:29:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="QFJdFuOh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403926AbfBML3A (ORCPT ); Wed, 13 Feb 2019 06:29:00 -0500 Received: from mail-eopbgr150041.outbound.protection.outlook.com ([40.107.15.41]:45056 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2403916AbfBML26 (ORCPT ); Wed, 13 Feb 2019 06:28:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3NYw/mTIuYjzwj/nZgal79JPpmAoIGMTUAnOAXPvfks=; b=QFJdFuOhjvH45XaKlw3tf78iwP7AjYv/4NiOtaXVn4VXhp5rt0M/WIaIuiNC9/AsP80Uk0Cz6QJdRzVsFBgN+2WUWjN/hYndtFNYlNMFCYdHGZinRMUsL/nyjIFe8a+uaXglqW6VUKfeCMeAXrHZkvnyVucAh4R9pe+dja1CGyI= Received: from AM6PR05MB5240.eurprd05.prod.outlook.com (20.177.196.214) by AM6PR05MB6230.eurprd05.prod.outlook.com (20.178.95.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.16; Wed, 13 Feb 2019 11:28:50 +0000 Received: from AM6PR05MB5240.eurprd05.prod.outlook.com ([fe80::3542:889c:3a85:3866]) by AM6PR05MB5240.eurprd05.prod.outlook.com ([fe80::3542:889c:3a85:3866%5]) with mapi id 15.20.1601.023; Wed, 13 Feb 2019 11:28:50 +0000 From: Ido Schimmel To: "netdev@vger.kernel.org" CC: "davem@davemloft.net" , Jiri Pirko , "andrew@lunn.ch" , mlxsw , Vadim Pasternak , Ido Schimmel Subject: [PATCH net-next 06/12] mlxsw: core: Modify thermal zone definition Thread-Topic: [PATCH net-next 06/12] mlxsw: core: Modify thermal zone definition Thread-Index: AQHUw49KT1FJxyZhOU2GPKn3o+TZJA== Date: Wed, 13 Feb 2019 11:28:50 +0000 Message-ID: <20190213112814.32334-7-idosch@mellanox.com> References: <20190213112814.32334-1-idosch@mellanox.com> In-Reply-To: <20190213112814.32334-1-idosch@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LNXP265CA0090.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::30) To AM6PR05MB5240.eurprd05.prod.outlook.com (2603:10a6:20b:64::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 02d5a484-4101-4b97-5689-08d691a66ce7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM6PR05MB6230; x-ms-traffictypediagnostic: AM6PR05MB6230: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1;AM6PR05MB6230;23:tBsCERSkahm/Z4Y8rZyu3LV2c0AeSs0PfKDGCy5?= =?iso-8859-1?Q?TqkYvO1T55o2Bl0++ZP6EzBKRADx+LoUCjNQIKIroX/TTr7oDpjdPMu/mJ?= =?iso-8859-1?Q?Yz/D9+Wds00FhB5YEbCcpHunuGr3muxfvWTjI/KBGgNB1wIcWJcDvABoJC?= =?iso-8859-1?Q?y3Ndk42ft2Fg+CMe7UQv1i7LkWyUgi5W+A5nW5vikWFxOem9794V1h7jXv?= =?iso-8859-1?Q?x/v0HLkT2xpmdc2ADxgc3XQ4TVYCGB3DTqqdch3HrLE1OVkotKmYmJlqU6?= =?iso-8859-1?Q?EC9dRzZ6lDEn6SthjWEM8f0tVpQViNtjNkxUQOH8R+PWzRGE1Nq/ShLgp6?= =?iso-8859-1?Q?A0/reOEDOvTaH8yoHl+x+KtlmsLGr53qQnOpgfVgnQnX27iJmqYkNqDgYV?= =?iso-8859-1?Q?tOtHOUK+mgPs6WH7K2EIsjOuHx8v6w3PR0iA15toQ7BnfaiS1BBHesRXEx?= =?iso-8859-1?Q?v6SiDxP4uv5uWjQ4Lkjc5aif9lLowE63ZItQvZmkIFe4jcoC3XnjNmeVhE?= =?iso-8859-1?Q?j9R929eLK9o2MLsGsFWDbbtNxoN0szA1fxwB/0v9JgO7R5t9DGXAMIp0KU?= =?iso-8859-1?Q?v5FHeX7A63k7hcWNc8g3Lc8iOrEh4Qh/xAj/GeW0woqJtWZK1dmd7REQBQ?= =?iso-8859-1?Q?4qUT5Ooc3hHdoa3zJjppJww6cB9X3p4dlPmPmYApj2TuOA95zhPRPdZsy1?= =?iso-8859-1?Q?weYmjdiwh6/Ejd/WqKfPYqle335RUfejzUaqix1TZ/GAtSKlHtuXFaKTBv?= =?iso-8859-1?Q?H36YcD+PbOZvwHmPww9EVM4uuErj9A6GTmsSCvpeFoEd5MGd+GnY5cuvmX?= =?iso-8859-1?Q?S4YG48pVCp2nEP+F6Pi9UYfKRMezG53eRDOQIpvloNy7QqK2uOiSJJf18X?= =?iso-8859-1?Q?a2wLeuqseHGBdo0E2rD+YhbrlvUbjF2o/LTozJTyL57lL0VvDyB0myWoMZ?= =?iso-8859-1?Q?JFLLRXGgPpKvBAbgMe/Kt8QtcHI55cnEyi+tchZs0lmAssHfsNri0emrS3?= =?iso-8859-1?Q?kptU59PzY34OA9on8Ht2QzUz9/CrVCH/vARipbyPzXdKKH2DaG20KAMqGF?= =?iso-8859-1?Q?OVg8Y9/o9mTMw5VAWG4HdP2pdAVA34GXaSJ9XX6hzvJpU1hVkXkdGjAiNE?= =?iso-8859-1?Q?Rv3CPA35KcJfmG6UgRIVpLK7OIoO23g7GdGMZ0gP59wmGw/BL6JdzqObJK?= =?iso-8859-1?Q?EczEbEuppfp3DH4G6zbDvm52XlN8b4q+sdHwV2U9d6jcTXllhtop7+ZGO+?= =?iso-8859-1?Q?BMU7tXAepErmsg0ZSkgG1WuNk1627AEkNTwyYRQt6b+O0QlJb3Eg7Hklmn?= =?iso-8859-1?Q?jsiJyqrh4CbGxBR+iICmSU3QLhkegKUphqfe9kHoX91ezHQcwyYht3PmK/?= =?iso-8859-1?Q?gH+ESY/M=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 094700CA91 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(366004)(396003)(346002)(136003)(39860400002)(189003)(199004)(26005)(186003)(386003)(6506007)(2616005)(476003)(446003)(11346002)(102836004)(486006)(2906002)(8936002)(106356001)(105586002)(71200400001)(2351001)(71190400001)(50226002)(97736004)(81166006)(8676002)(1730700003)(81156014)(6916009)(305945005)(7736002)(14454004)(478600001)(6116002)(3846002)(86362001)(2501003)(66066001)(14444005)(256004)(68736007)(107886003)(53936002)(6436002)(6512007)(1076003)(36756003)(25786009)(54906003)(316002)(6486002)(4326008)(5640700003)(99286004)(76176011)(52116002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR05MB6230;H:AM6PR05MB5240.eurprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TxUGE6qYJ1F4PTovz4Ope97OyDO3wy1bdFniWRsxDLjkuRCXam7SmkJEu0r3d89kOPxpo0zPnchF1bye0M85O4d793qQ3aO8u+z+pHoxDs4c7ZBi1wdXzHZ+6qoaVx5MtpqSU2nKENfefN3zw/rdwn3SdYqMJ2HMij7iYASXCbO16ck6s6AWt1LQxvoCL7WLdn8NKcE0nMf2c3f6H3myZex+/YKsHfH+xmg/m4l0HEqifvFQrexPuYYeftsTC4VzXghUE6uuLkprSNRPbCTBThN/0+ZA4Y1EYEwIfyGEdLO75UsHFoi8/81LKEc0jdM71M9i/6NAr3Bmln10mJ4elvvmYKJ5ncOAZofssydOBUvYgOVcFDb6rL+ZejXnbpCCW8jWUN+b0R2CtsEqx4X5fypFJVGy7GSuwrzkBePSkqs= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02d5a484-4101-4b97-5689-08d691a66ce7 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2019 11:28:49.0868 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB6230 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vadim Pasternak Modify thermal zone trip points setting for better alignment with system thermal requirement. Add hysteresis thresholds for thermal trips in order to avoid throttling around thermal trip point. If hysteresis temperature is not considered, PWM can have side effect of flip up/down on thermal trip point boundary. Signed-off-by: Vadim Pasternak Reviewed-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/core_thermal.c | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/n= et/ethernet/mellanox/mlxsw/core_thermal.c index b1f9b459766c..dbf9a845084a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -15,6 +15,7 @@ #define MLXSW_THERMAL_POLL_INT 1000 /* ms */ #define MLXSW_THERMAL_SLOW_POLL_INT 20000 /* ms */ #define MLXSW_THERMAL_MAX_TEMP 110000 /* 110C */ +#define MLXSW_THERMAL_HYSTERESIS_TEMP 5000 /* 5C */ #define MLXSW_THERMAL_MAX_STATE 10 #define MLXSW_THERMAL_MAX_DUTY 255 /* Minimum and maximum fan allowed speed in percent: from 20% to 100%. Val= ues @@ -30,6 +31,7 @@ struct mlxsw_thermal_trip { int type; int temp; + int hyst; int min_state; int max_state; }; @@ -38,25 +40,22 @@ static const struct mlxsw_thermal_trip default_thermal_= trips[] =3D { { /* In range - 0-40% PWM */ .type =3D THERMAL_TRIP_ACTIVE, .temp =3D 75000, + .hyst =3D MLXSW_THERMAL_HYSTERESIS_TEMP, .min_state =3D 0, .max_state =3D (4 * MLXSW_THERMAL_MAX_STATE) / 10, }, - { /* High - 40-100% PWM */ + { + /* In range - 40-100% PWM */ .type =3D THERMAL_TRIP_ACTIVE, .temp =3D 80000, + .hyst =3D MLXSW_THERMAL_HYSTERESIS_TEMP, .min_state =3D (4 * MLXSW_THERMAL_MAX_STATE) / 10, .max_state =3D MLXSW_THERMAL_MAX_STATE, }, - { - /* Very high - 100% PWM */ - .type =3D THERMAL_TRIP_ACTIVE, - .temp =3D 85000, - .min_state =3D MLXSW_THERMAL_MAX_STATE, - .max_state =3D MLXSW_THERMAL_MAX_STATE, - }, { /* Warning */ .type =3D THERMAL_TRIP_HOT, - .temp =3D 105000, + .temp =3D 85000, + .hyst =3D MLXSW_THERMAL_HYSTERESIS_TEMP, .min_state =3D MLXSW_THERMAL_MAX_STATE, .max_state =3D MLXSW_THERMAL_MAX_STATE, }, @@ -246,6 +245,24 @@ static int mlxsw_thermal_set_trip_temp(struct thermal_= zone_device *tzdev, return 0; } =20 +static int mlxsw_thermal_get_trip_hyst(struct thermal_zone_device *tzdev, + int trip, int *p_hyst) +{ + struct mlxsw_thermal *thermal =3D tzdev->devdata; + + *p_hyst =3D thermal->trips[trip].hyst; + return 0; +} + +static int mlxsw_thermal_set_trip_hyst(struct thermal_zone_device *tzdev, + int trip, int hyst) +{ + struct mlxsw_thermal *thermal =3D tzdev->devdata; + + thermal->trips[trip].hyst =3D hyst; + return 0; +} + static struct thermal_zone_device_ops mlxsw_thermal_ops =3D { .bind =3D mlxsw_thermal_bind, .unbind =3D mlxsw_thermal_unbind, @@ -255,6 +272,8 @@ static struct thermal_zone_device_ops mlxsw_thermal_ops= =3D { .get_trip_type =3D mlxsw_thermal_get_trip_type, .get_trip_temp =3D mlxsw_thermal_get_trip_temp, .set_trip_temp =3D mlxsw_thermal_set_trip_temp, + .get_trip_hyst =3D mlxsw_thermal_get_trip_hyst, + .set_trip_hyst =3D mlxsw_thermal_set_trip_hyst, }; =20 static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev= , --=20 2.20.1