Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/807176/?format=api
{ "id": 807176, "url": "http://patchwork.ozlabs.org/api/patches/807176/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1504032311-195988-3-git-send-email-vadimp@mellanox.com/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504032311-195988-3-git-send-email-vadimp@mellanox.com>", "list_archive_url": null, "date": "2017-08-29T18:45:11", "name": "[v1,2/2] mlxsw: core: add support for the external thermal zone setting (by DTS)", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "9da7675c919459ae0d3b2ae688771ef89c4d7cdc", "submitter": { "id": 69757, "url": "http://patchwork.ozlabs.org/api/people/69757/?format=api", "name": "Vadim Pasternak", "email": "vadimp@mellanox.com" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/1504032311-195988-3-git-send-email-vadimp@mellanox.com/mbox/", "series": [ { "id": 408, "url": "http://patchwork.ozlabs.org/api/series/408/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=408", "date": "2017-08-29T18:45:10", "name": "add support for the external thermal zone and cooling device binding for Mellanox network devices", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/408/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/807176/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/807176/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xhZMT3fQwz9t38\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 30 Aug 2017 02:48:21 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751799AbdH2QsT (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 29 Aug 2017 12:48:19 -0400", "from mail-il-dmz.mellanox.com ([193.47.165.129]:34182 \"EHLO\n\tmellanox.co.il\" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org\n\twith ESMTP id S1751717AbdH2QsJ (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 29 Aug 2017 12:48:09 -0400", "from Internal Mail-Server by MTLPINE1 (envelope-from\n\tvadimp@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 29 Aug 2017 19:48:06 +0300", "from r-mgtswh-226.mtr.labs.mlnx. (r-mgtswh-226.mtr.labs.mlnx\n\t[10.209.1.51])\n\tby labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v7TGm3G2030696;\n\tTue, 29 Aug 2017 19:48:06 +0300" ], "From": "Vadim Pasternak <vadimp@mellanox.com>", "To": "robh+dt@kernel.org, davem@davemloft.net", "Cc": "jiri@resnulli.us, ivecera@redhat.com, devicetree@vger.kernel.org,\n\tnetdev@vger.kernel.org, Vadim Pasternak <vadimp@mellanox.com>", "Subject": "[patch v1 2/2] mlxsw: core: add support for the external thermal\n\tzone setting (by DTS)", "Date": "Tue, 29 Aug 2017 18:45:11 +0000", "Message-Id": "<1504032311-195988-3-git-send-email-vadimp@mellanox.com>", "X-Mailer": "git-send-email 2.1.4", "In-Reply-To": "<1504032311-195988-1-git-send-email-vadimp@mellanox.com>", "References": "<1504032311-195988-1-git-send-email-vadimp@mellanox.com>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "It allows:\n- thermal zone setting for mlxsw based HW and from DTS file;\n- binding ASIC temperature sensor to cooling devices.\nIt requires setting of CONFIG_OF.\n\nSigned-off-by: Vadim Pasternak <vadimp@mellanox.com>\n---\n drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 107 ++++++++++++++++++++-\n drivers/net/ethernet/mellanox/mlxsw/minimal.c | 6 ++\n 2 files changed, 109 insertions(+), 4 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c\nindex d866c98..c30783e 100644\n--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c\n+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c\n@@ -34,6 +34,7 @@\n #include <linux/kernel.h>\n #include <linux/types.h>\n #include <linux/device.h>\n+#include <linux/of_platform.h>\n #include <linux/sysfs.h>\n #include <linux/thermal.h>\n #include <linux/err.h>\n@@ -44,6 +45,7 @@\n #define MLXSW_THERMAL_MAX_TEMP\t110000\t/* 110C */\n #define MLXSW_THERMAL_MAX_STATE\t10\n #define MLXSW_THERMAL_MAX_DUTY\t255\n+#define MLXSW_THERMAL_TRIP_ELEM\t4\n \n struct mlxsw_thermal_trip {\n \tint\ttype;\n@@ -98,6 +100,8 @@ struct mlxsw_thermal {\n \tstruct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX];\n \tstruct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];\n \tenum thermal_device_mode mode;\n+\tint ntrips;\n+\tbool cooling_external;\n };\n \n static inline u8 mlxsw_state_to_duty(int state)\n@@ -121,6 +125,10 @@ static int mlxsw_get_cooling_device_idx(struct mlxsw_thermal *thermal,\n \t\tif (thermal->cdevs[i] == cdev)\n \t\t\treturn i;\n \n+\t/* Allow external cooling binding if theres is no local. */\n+\tif (thermal->cooling_external)\n+\t\treturn 0;\n+\n \treturn -ENODEV;\n }\n \n@@ -334,6 +342,83 @@ static const struct thermal_cooling_device_ops mlxsw_cooling_ops = {\n \t.set_cur_state\t= mlxsw_thermal_set_cur_state,\n };\n \n+#ifdef CONFIG_OF\n+static int\n+mlxsw_thermal_of_init(struct device *dev, struct mlxsw_thermal *thermal)\n+{\n+\tstruct device_node *np = dev->of_node;\n+\tu32 trip[MLXSW_THERMAL_TRIP_ELEM];\n+\tstruct platform_device *pdev;\n+\tstruct device_node *phandle;\n+\tstruct device_node *gchild;\n+\tstruct device_node *child;\n+\tint ntrips;\n+\tint i;\n+\tint ret;\n+\n+\t/* trips */\n+\tchild = of_get_child_by_name(np, \"trips\");\n+\n+\t/* No trips provided */\n+\tif (!child) {\n+\t\tof_node_put(child);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Cooling device is optional parameter. If it is not defined, driver\n+\t * will try to connect PWM which is owned, if any.\n+\t */\n+\tphandle = of_parse_phandle(child, \"cooling-phandle\", 0);\n+\tif (phandle) {\n+\t\tpdev = of_find_device_by_node(phandle);\n+\t\tof_node_put(phandle);\n+\t\tif (!pdev) {\n+\t\t\tret = -ENODEV;\n+\t\t\tgoto put_child;\n+\t\t}\n+\n+\t\tthermal->cooling_external = true;\n+\t}\n+\n+\tntrips = of_get_child_count(child);\n+\tif (ntrips == 0) {\n+\t\t/* should have at least one child */\n+\t\tret = 0;\n+\t\tgoto put_child;\n+\t}\n+\n+\ti = 0;\n+\tfor_each_child_of_node(child, gchild) {\n+\t\tret = of_property_count_u32_elems(gchild, \"trip\");\n+\t\tif (ret != MLXSW_THERMAL_TRIP_ELEM) {\n+\t\t\tret = -EINVAL;\n+\t\t\tgoto put_child;\n+\t\t}\n+\n+\t\tret = of_property_read_u32_array(gchild, \"trip\",\n+\t\t\t\t\t\t trip, ret);\n+\t\tif (ret)\n+\t\t\tgoto put_gchild;\n+\n+\t\tmemcpy(&thermal->trips[i++], trip, sizeof(trip));\n+\t}\n+\tret = ntrips;\n+\n+put_gchild:\n+\tof_node_put(gchild);\n+put_child:\n+\tof_node_put(child);\n+\n+\treturn ret;\n+}\n+#else\n+static int\n+mlxsw_thermal_of_init(struct device *dev, struct mlxsw_thermal *thermal)\n+{\n+\treturn 0;\n+}\n+#endif\n+\n int mlxsw_thermal_init(struct mlxsw_core *core,\n \t\t const struct mlxsw_bus_info *bus_info,\n \t\t struct mlxsw_thermal **p_thermal)\n@@ -344,7 +429,9 @@ int mlxsw_thermal_init(struct mlxsw_core *core,\n \tstruct mlxsw_thermal *thermal;\n \tu16 tacho_active;\n \tu8 pwm_active;\n-\tint err, i;\n+\tint ntrips;\n+\tint i;\n+\tint err;\n \n \tthermal = devm_kzalloc(dev, sizeof(*thermal),\n \t\t\t GFP_KERNEL);\n@@ -353,7 +440,19 @@ int mlxsw_thermal_init(struct mlxsw_core *core,\n \n \tthermal->core = core;\n \tthermal->bus_info = bus_info;\n-\tmemcpy(thermal->trips, default_thermal_trips, sizeof(thermal->trips));\n+\n+\tif (dev->of_node) {\n+\t\tntrips = mlxsw_thermal_of_init(dev, thermal);\n+\t\tif (ntrips > 0)\n+\t\t\tthermal->ntrips = ntrips;\n+\t}\n+\n+\tif (!dev->of_node || ntrips <= 0) {\n+\t\t/* Use default if the external setting is not available */\n+\t\tmemcpy(thermal->trips, default_thermal_trips,\n+\t\t sizeof(thermal->trips));\n+\t\tthermal->ntrips = MLXSW_THERMAL_NUM_TRIPS;\n+\t}\n \n \terr = mlxsw_reg_query(thermal->core, MLXSW_REG(mfcr), mfcr_pl);\n \tif (err) {\n@@ -398,8 +497,8 @@ int mlxsw_thermal_init(struct mlxsw_core *core,\n \t}\n \n \tthermal->tzdev = thermal_zone_device_register(\"mlxsw\",\n-\t\t\t\t\t\t MLXSW_THERMAL_NUM_TRIPS,\n-\t\t\t\t\t\t MLXSW_THERMAL_TRIP_MASK,\n+\t\t\t\t\t\t thermal->ntrips,\n+\t\t\t\t\t\t BIT(thermal->ntrips) - 1,\n \t\t\t\t\t\t thermal,\n \t\t\t\t\t\t &mlxsw_thermal_ops,\n \t\t\t\t\t\t NULL, 0,\ndiff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c\nindex 3dd1626..8e3cc13 100644\n--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c\n+++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c\n@@ -56,8 +56,14 @@ static const struct i2c_device_id mlxsw_minimal_i2c_id[] = {\n \t{ },\n };\n \n+static const struct of_device_id mlxsw_minimal_dt_match[] = {\n+\t{ .compatible = \"mellanox,mlxsw_minimal\" },\n+\t{ },\n+};\n+\n static struct i2c_driver mlxsw_minimal_i2c_driver = {\n \t.driver.name = \"mlxsw_minimal\",\n+\t.driver.of_match_table = of_match_ptr(mlxsw_minimal_dt_match),\n \t.class = I2C_CLASS_HWMON,\n \t.id_table = mlxsw_minimal_i2c_id,\n };\n", "prefixes": [ "v1", "2/2" ] }