Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2168089ybm; Thu, 23 May 2019 12:28:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZ1uaObl5ypjmHXjY4WZiij8UuX3EXQcYNFP1hD27iS2Ke2MF/LYaUfFcsVX3jURI4WiDO X-Received: by 2002:a63:4815:: with SMTP id v21mr2333822pga.312.1558639722589; Thu, 23 May 2019 12:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558639722; cv=none; d=google.com; s=arc-20160816; b=ex8RdMPZMaqiM1bWYVERBj0kfB53A8Lgy6mEVoqVyEM/q/8wfW+g5DIzSB2yE2BOEt mrm5RPf/azBwvLuyzGwZeQWo/FjKrFXyAvj6iuWmm3IF/FUOot/dxbrSXckl0baxqeu2 LdfOzsCmJVNhTjRw9bUoyh8ktuuliAtf8KLWcH8yr4L2xiw1eaOz0B2OS4gJJJyumVH5 WBelQJQsc4FLu+aVfSiMD1I//yQPfV9RGSTYGjG8XXE9XUt6TZN1R1a3ndPabXj322Us 8ZsBP9skd7oKpCVDhv6NzG554WX9qcMIoCd1889a4rjVUDq28zNNXQcSpydGHpXSEpxw oHRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MPn/zx/kx33SNZwtlMZdTVBWVgvSFb2nTTTNv66UTpc=; b=xW8FBLxrM9LVgbW903mwzaHF1bsiXIADzOmNhk6jAQrqmWDrM8DNwHE6a+TmJBzN1v hmw1qFGCkU9nK/82Kv+ffrBICRZKktEyEPFxz7usWRebqmEM1pPk+mBIHhFFagK7CI3A Zjh2hCxNxHXvWnEjDKtkJaTL69lfzkepysibZrTxi4LhmQIUvrY03iGomSnlpWtE+554 NmBOWTVSG9FUnb0d7ZbeM2XvWasBAUBUK+Todf+iSeC1Vc0e/vSxP0LfCPtuJgzZtrrI S4xEPgYvbVY+pkLPRUdfr+kuMcRw/oaaVf6LqDH6rwQG1OYy40RrLfxyrTuDUfACf1HN QOBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1fM3PZ5o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a33si543082plc.283.2019.05.23.12.28.27; Thu, 23 May 2019 12:28:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1fM3PZ5o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391294AbfEWT0N (ORCPT + 99 others); Thu, 23 May 2019 15:26:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:37972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390600AbfEWT0L (ORCPT ); Thu, 23 May 2019 15:26:11 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D546221841; Thu, 23 May 2019 19:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558639570; bh=7HmkXOI4MwlMqzoTXHQ940g51qeofzyUIt+4PDo6JN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1fM3PZ5owub46W5F85k29tav7hZF+GHYuZ0S0HQhr532Mv3zQcQLd/ej59ebby2xB cafy6jjdW5AiRz4XJuXHcELThFQLWeKBmYD4Anp6pSgHM1ypWe36mYO/Z9K7lY9Eem wEb6/mzHzQyaI20oh/Ijel41ChrOeE8eaWJU/zjs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Pirko , Vadim Pasternak , Ido Schimmel , "David S. Miller" Subject: [PATCH 5.1 014/122] mlxsw: core: Prevent QSFP module initialization for old hardware Date: Thu, 23 May 2019 21:05:36 +0200 Message-Id: <20190523181706.827541346@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181705.091418060@linuxfoundation.org> References: <20190523181705.091418060@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vadim Pasternak [ Upstream commit c52ecff7e6439ca8c9b03282e8869a005aa94831 ] Old Mellanox silicons, like switchx-2, switch-ib do not support reading QSFP modules temperature through MTMP register. Attempt to access this register on systems equipped with the this kind of silicon will cause initialization flow failure. Test for hardware resource capability is added in order to distinct between old and new silicon - old silicons do not have such capability. Fixes: 6a79507cfe94 ("mlxsw: core: Extend thermal module with per QSFP module thermal zones") Fixes: 5c42eaa07bd0 ("mlxsw: core: Extend hwmon interface with QSFP module temperature attributes") Reported-by: Jiri Pirko Signed-off-by: Vadim Pasternak Signed-off-by: Ido Schimmel Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlxsw/core.c | 6 ++++++ drivers/net/ethernet/mellanox/mlxsw/core.h | 2 ++ drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c | 3 +++ drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 6 ++++++ 4 files changed, 17 insertions(+) --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -122,6 +122,12 @@ void *mlxsw_core_driver_priv(struct mlxs } EXPORT_SYMBOL(mlxsw_core_driver_priv); +bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core) +{ + return mlxsw_core->driver->res_query_enabled; +} +EXPORT_SYMBOL(mlxsw_core_res_query_enabled); + struct mlxsw_rx_listener_item { struct list_head list; struct mlxsw_rx_listener rxl; --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h @@ -28,6 +28,8 @@ unsigned int mlxsw_core_max_ports(const void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core); +bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core); + int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver); void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver); --- a/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c @@ -518,6 +518,9 @@ static int mlxsw_hwmon_module_init(struc u8 width; int err; + if (!mlxsw_core_res_query_enabled(mlxsw_hwmon->core)) + return 0; + /* Add extra attributes for module temperature. Sensor index is * assigned to sensor_count value, while all indexed before * sensor_count are already utilized by the sensors connected through --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -740,6 +740,9 @@ mlxsw_thermal_modules_init(struct device struct mlxsw_thermal_module *module_tz; int i, err; + if (!mlxsw_core_res_query_enabled(core)) + return 0; + thermal->tz_module_arr = kcalloc(module_count, sizeof(*thermal->tz_module_arr), GFP_KERNEL); @@ -776,6 +779,9 @@ mlxsw_thermal_modules_fini(struct mlxsw_ unsigned int module_count = mlxsw_core_max_ports(thermal->core); int i; + if (!mlxsw_core_res_query_enabled(thermal->core)) + return; + for (i = module_count - 1; i >= 0; i--) mlxsw_thermal_module_fini(&thermal->tz_module_arr[i]); kfree(thermal->tz_module_arr);