From patchwork Fri Oct 20 21:27:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13431193 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85DDB29CFF for ; Fri, 20 Oct 2023 21:28:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="GcCvvuWe" Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DD05D6D for ; Fri, 20 Oct 2023 14:28:11 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-27dc1e4d8b6so1095897a91.0 for ; Fri, 20 Oct 2023 14:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1697837290; x=1698442090; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=wsewz1O4dEf/OJMpchk/NqM6K0iIx4UKdLiZScLmVBU=; b=GcCvvuWe/HDWngM6e2EGQ6f0lqjutSjEAhm4bsuQhVq1evX45yw5NO6Nu8+pLpQJ2S G6iHNmGF7DnOKs3aZh6++fuqQ/b8Iw+Mc6kQDhc+zNFs7ey61JDWseEQEbFk+4vByIKz NtJOjOMTgnwm1mc3NrnCTb1fv2/zVjbvIEKXc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697837290; x=1698442090; 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=wsewz1O4dEf/OJMpchk/NqM6K0iIx4UKdLiZScLmVBU=; b=ho26lEe4umfMr2cu1F+aj6VQF/PlGjaBnTWKYhCdPIeVIGZxN/Ef4U0qHG5ELUsCfZ AiIckUXrVwr50CurlJigj105ISM1grJ0TEeoFIbe8Vt5+wIPcJ6qCmI79G00cRW3v2uC qGN+4UhoY0NLrdPbrA6F78XobCXLUWunukd+IVGgdwRCAilIvQu0mwkyNMHgyu4gtAQx 0oVrfecv2Y2cbv51Y1x7wnTQo678nn96kh+sqa7YtaLMhCf82uMdaw6WPrzKtw60lOEo 6DwRxWcKLzh+A6kbD4n1jd6nHNp7JtwS0+7Fntq/+Q3QbzmgC5BW9RI8nPlXN11d5KK8 M3GQ== X-Gm-Message-State: AOJu0YwIC1+cD13fv3PAhZuPAaqJHv000Xl8AklLnwP4veZWSneRiNrM 5javy4Ue6TVz2Z3R/7f3Oeeffg== X-Google-Smtp-Source: AGHT+IEoJ+tHcxjjs3qYCkaLDPFI4oVj2sL8HJi/7Dw2oSSRlWFE7/Jltm361WKxeIMEZZWLyA7KnQ== X-Received: by 2002:a17:90a:1996:b0:27d:2054:9641 with SMTP id 22-20020a17090a199600b0027d20549641mr3158023pji.36.1697837290335; Fri, 20 Oct 2023 14:28:10 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id j13-20020a17090a7e8d00b0026d4100e0e8sm1843348pjl.10.2023.10.20.14.28.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Oct 2023 14:28:09 -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-anakkur.purayil@broadcom.com, Guenter Roeck Subject: [PATCH net-next 1/8] bnxt_en: Do not call sleeping hwmon_notify_event() from NAPI Date: Fri, 20 Oct 2023 14:27:50 -0700 Message-Id: <20231020212757.173551-2-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231020212757.173551-1-michael.chan@broadcom.com> References: <20231020212757.173551-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Kalesh AP Defer hwmon_notify_event() to bnxt_sp_task() workqueue because hwmon_notify_event() can try to acquire a mutex shown in the stack trace below. Modify bnxt_event_error_report() to return true if we need to schedule bnxt_sp_task() to notify hwmon. __schedule+0x68/0x520 hwmon_notify_event+0xe8/0x114 schedule+0x60/0xe0 schedule_preempt_disabled+0x28/0x40 __mutex_lock.constprop.0+0x534/0x550 __mutex_lock_slowpath+0x18/0x20 mutex_lock+0x5c/0x70 kobject_uevent_env+0x2f4/0x3d0 kobject_uevent+0x10/0x20 hwmon_notify_event+0x94/0x114 bnxt_hwmon_notify_event+0x40/0x70 [bnxt_en] bnxt_event_error_report+0x260/0x290 [bnxt_en] bnxt_async_event_process.isra.0+0x250/0x850 [bnxt_en] bnxt_hwrm_handler.isra.0+0xc8/0x120 [bnxt_en] bnxt_poll_p5+0x150/0x350 [bnxt_en] __napi_poll+0x3c/0x210 net_rx_action+0x308/0x3b0 __do_softirq+0x120/0x3e0 Cc: Guenter Roeck Fixes: a19b4801457b ("bnxt_en: Event handler for Thermal event") Signed-off-by: Kalesh AP Signed-off-by: Michael Chan Reviewed-by: Guenter Roeck --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 ++++++++++++----- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c | 4 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h | 4 ++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 16eb7a7af970..7837e22f237b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -2147,7 +2147,8 @@ static u16 bnxt_agg_ring_id_to_grp_idx(struct bnxt *bp, u16 ring_id) ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR) ==\ ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_INCREASING) -static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2) +/* Return true if the workqueue has to be scheduled */ +static bool bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2) { u32 err_type = BNXT_EVENT_ERROR_REPORT_TYPE(data1); @@ -2182,7 +2183,7 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2) break; default: netdev_err(bp->dev, "Unknown Thermal threshold type event\n"); - return; + return false; } if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING(data1)) dir_str = "above"; @@ -2193,14 +2194,16 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2) 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, type); - break; + bp->thermal_threshold_type = type; + set_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event); + return true; } default: netdev_err(bp->dev, "FW reported unknown error type %u\n", err_type); break; } + return false; } #define BNXT_GET_EVENT_PORT(data) \ @@ -2401,7 +2404,8 @@ static int bnxt_async_event_process(struct bnxt *bp, goto async_event_process_exit; } case ASYNC_EVENT_CMPL_EVENT_ID_ERROR_REPORT: { - bnxt_event_error_report(bp, data1, data2); + if (bnxt_event_error_report(bp, data1, data2)) + break; goto async_event_process_exit; } case ASYNC_EVENT_CMPL_EVENT_ID_PHC_UPDATE: { @@ -12085,6 +12089,9 @@ static void bnxt_sp_task(struct work_struct *work) if (test_and_clear_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event)) bnxt_fw_echo_reply(bp); + if (test_and_clear_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event)) + bnxt_hwmon_notify_event(bp); + /* These functions below will clear BNXT_STATE_IN_SP_TASK. They * must be the last functions to be called before exiting. */ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 9ce0193798d4..80846c3ca9fc 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2094,6 +2094,7 @@ struct bnxt { #define BNXT_FW_RESET_NOTIFY_SP_EVENT 18 #define BNXT_FW_EXCEPTION_SP_EVENT 19 #define BNXT_LINK_CFG_CHANGE_SP_EVENT 21 +#define BNXT_THERMAL_THRESHOLD_SP_EVENT 22 #define BNXT_FW_ECHO_REQUEST_SP_EVENT 23 struct delayed_work fw_reset_task; @@ -2196,6 +2197,7 @@ struct bnxt { u8 fatal_thresh_temp; u8 shutdown_thresh_temp; #endif + u32 thermal_threshold_type; enum board_idx board_idx; }; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c index e48094043c3b..669d24ba0e87 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c @@ -18,14 +18,14 @@ #include "bnxt_hwrm.h" #include "bnxt_hwmon.h" -void bnxt_hwmon_notify_event(struct bnxt *bp, u32 type) +void bnxt_hwmon_notify_event(struct bnxt *bp) { u32 attr; if (!bp->hwmon_dev) return; - switch (type) { + switch (bp->thermal_threshold_type) { case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_WARN: attr = hwmon_temp_max_alarm; break; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h index 76d9f599ebc0..de54a562e06a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h @@ -11,11 +11,11 @@ #define BNXT_HWMON_H #ifdef CONFIG_BNXT_HWMON -void bnxt_hwmon_notify_event(struct bnxt *bp, u32 type); +void bnxt_hwmon_notify_event(struct bnxt *bp); 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 type) +static inline void bnxt_hwmon_notify_event(struct bnxt *bp) { }