From patchwork Tue Aug 15 04:56:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13353525 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1165EC001DB for ; Tue, 15 Aug 2023 04:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234469AbjHOE6P (ORCPT ); Tue, 15 Aug 2023 00:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234470AbjHOE5d (ORCPT ); Tue, 15 Aug 2023 00:57:33 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03318133 for ; Mon, 14 Aug 2023 21:57:30 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-76ce59842c1so308941285a.3 for ; Mon, 14 Aug 2023 21:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1692075449; x=1692680249; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=3YKVvaqJEV7IIu6DihHjSX80Ubcju3i+t9QT5eFzbdA=; b=A5gzICyyERiOeLTEsjciDiGqggdRrUi2th/IY+47NRb/iTwEHkDucfbeXiFQcSrjsG TjOq+vV19PYQsPpvQDLxV0TTZYxdqOlgJ7jji0iDC7pkX8nDns5N2vGiZy3BAnKzedP4 +J2Z53/ogBbfy9SyWh1nPV9ckpadJwcrpaRCE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692075449; x=1692680249; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3YKVvaqJEV7IIu6DihHjSX80Ubcju3i+t9QT5eFzbdA=; b=IKXExC0XMcxQR5Lk5Iz2uQGyAJwphVqo9RhzhlrqddZnMPiZgtno8sUTG3+IjSedyj RJxskDXvt66gaAdXP2uOpsuit00hSg6OGC88RGyz0WKruE29fbD8DNT8rse9CVk50u6S akzwHnU7d3RPpBOxTrt64wcJ9NMlFYyrkCMEQHjFVMCNra+oQ1nN32DP2k+Wk6wsQw+/ Rkd5LD5DNg9hx2VZzU5jT3ifpMCU8URB9afvCm1x7IKRhlX+TpL0kLTzRHkQQqZrBVk6 WTRJwJiNrrckYGptuJo+G4vn6TqPHI6VXWJjdxchJwS0DPuBvROEznoOk0/mVC40Kpjl +z6A== X-Gm-Message-State: AOJu0YxSw5y5YIoQryZkMlJWx9qO+bKzhjLGolDTn2TEHydlFSvHhvJs TdcsBT0s7QljQ/EXfTi9rww5ww== X-Google-Smtp-Source: AGHT+IFxERCkUGDxFTT/vKVeRwmahoXOIEyiSMop6ckEzy1zcXfj8pQ4d6Zrfai6WT+lWm+DGVTKdw== X-Received: by 2002:a05:620a:668:b0:76c:ddf8:522b with SMTP id a8-20020a05620a066800b0076cddf8522bmr11017372qkh.37.1692075448575; Mon, 14 Aug 2023 21:57:28 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id k28-20020a05620a143c00b00767cbd5e942sm3516575qkj.72.2023.08.14.21.57.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Aug 2023 21:57:28 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, gospo@broadcom.com, Kalesh AP , Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org Subject: [PATCH net-next 12/12] bnxt_en: Event handler for Thermal event Date: Mon, 14 Aug 2023 21:56:58 -0700 Message-Id: <20230815045658.80494-13-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230815045658.80494-1-michael.chan@broadcom.com> References: <20230815045658.80494-1-michael.chan@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Kalesh AP Newer FW will send a new async event when it detects that the chip's temperature has crossed the configured threshold value. The driver will now notify hwmon and will log a warning message. Cc: Jean Delvare Cc: Guenter Roeck Cc: linux-hwmon@vger.kernel.org Signed-off-by: Kalesh AP Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 44 +++++++++++++++++++ .../net/ethernet/broadcom/bnxt/bnxt_hwmon.c | 8 ++++ .../net/ethernet/broadcom/bnxt/bnxt_hwmon.h | 5 +++ 3 files changed, 57 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 5e97a3d93e87..c8e04c9501ee 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -2130,6 +2130,17 @@ static u16 bnxt_agg_ring_id_to_grp_idx(struct bnxt *bp, u16 ring_id) return INVALID_HW_RING_ID; } +#define BNXT_EVENT_THERMAL_CURRENT_TEMP(data2) \ + ((data2) & ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_CURRENT_TEMP_MASK) + +#define BNXT_EVENT_THERMAL_THRESHOLD_TEMP(data2) \ + (((data2) & \ + ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_THRESHOLD_TEMP_MASK) >> \ + ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_THRESHOLD_TEMP_SFT) + +#define EVENT_DATA1_THERMAL_THRESHOLD_TYPE(data1) \ + ((data1) & ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_MASK) + static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2) { u32 err_type = BNXT_EVENT_ERROR_REPORT_TYPE(data1); @@ -2145,6 +2156,39 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2) case ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_DOORBELL_DROP_THRESHOLD: netdev_warn(bp->dev, "One or more MMIO doorbells dropped by the device!\n"); break; + case ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_THERMAL_THRESHOLD: { + char *threshold_type; + u32 attr; + + switch (EVENT_DATA1_THERMAL_THRESHOLD_TYPE(data1)) { + case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_WARN: + attr = hwmon_temp_lcrit_alarm; + threshold_type = "warning"; + break; + case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_CRITICAL: + attr = hwmon_temp_crit_alarm; + threshold_type = "critical"; + break; + case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_FATAL: + attr = hwmon_temp_emergency_alarm; + threshold_type = "fatal"; + break; + case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_SHUTDOWN: + attr = hwmon_temp_max_alarm; + threshold_type = "shutdown"; + break; + default: + netdev_err(bp->dev, "Unknown Thermal threshold type event\n"); + return; + } + netdev_warn(bp->dev, "Chip temperature has crossed the %s thermal threshold!\n", + threshold_type); + netdev_warn(bp->dev, "Temperature (In Celsius), Current: %lu, threshold: %lu\n", + BNXT_EVENT_THERMAL_CURRENT_TEMP(data2), + BNXT_EVENT_THERMAL_THRESHOLD_TEMP(data2)); + bnxt_hwmon_notify_event(bp, attr); + break; + } default: netdev_err(bp->dev, "FW reported unknown error type %u\n", err_type); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c index f5affac1169a..483571264276 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c @@ -18,6 +18,14 @@ #include "bnxt_hwrm.h" #include "bnxt_hwmon.h" +void bnxt_hwmon_notify_event(struct bnxt *bp, u32 attr) +{ + if (!bp->hwmon_dev) + return; + + hwmon_notify_event(&bp->pdev->dev, hwmon_temp, attr, 0); +} + static int bnxt_hwrm_temp_query(struct bnxt *bp, u8 *temp) { struct hwrm_temp_monitor_query_output *resp; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h index af310066687c..5cf127702764 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h @@ -11,9 +11,14 @@ #define BNXT_HWMON_H #ifdef CONFIG_BNXT_HWMON +void bnxt_hwmon_notify_event(struct bnxt *bp, u32 attr); void bnxt_hwmon_uninit(struct bnxt *bp); void bnxt_hwmon_init(struct bnxt *bp); #else +static inline void bnxt_hwmon_notify_event(struct bnxt *bp, u32 attr) +{ +} + static inline void bnxt_hwmon_uninit(struct bnxt *bp) { }