Skip to content

Commit 5586209

Browse files
Kalesh APdavem330
authored andcommitted
bnxt_en: Do not call sleeping hwmon_notify_event() from NAPI
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 <[email protected]> Fixes: a19b480 ("bnxt_en: Event handler for Thermal event") Signed-off-by: Kalesh AP <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e10f401 commit 5586209

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,8 @@ static u16 bnxt_agg_ring_id_to_grp_idx(struct bnxt *bp, u16 ring_id)
21472147
ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR) ==\
21482148
ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_INCREASING)
21492149

2150-
static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)
2150+
/* Return true if the workqueue has to be scheduled */
2151+
static bool bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)
21512152
{
21522153
u32 err_type = BNXT_EVENT_ERROR_REPORT_TYPE(data1);
21532154

@@ -2182,7 +2183,7 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)
21822183
break;
21832184
default:
21842185
netdev_err(bp->dev, "Unknown Thermal threshold type event\n");
2185-
return;
2186+
return false;
21862187
}
21872188
if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING(data1))
21882189
dir_str = "above";
@@ -2193,14 +2194,16 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)
21932194
netdev_warn(bp->dev, "Temperature (In Celsius), Current: %lu, threshold: %lu\n",
21942195
BNXT_EVENT_THERMAL_CURRENT_TEMP(data2),
21952196
BNXT_EVENT_THERMAL_THRESHOLD_TEMP(data2));
2196-
bnxt_hwmon_notify_event(bp, type);
2197-
break;
2197+
bp->thermal_threshold_type = type;
2198+
set_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event);
2199+
return true;
21982200
}
21992201
default:
22002202
netdev_err(bp->dev, "FW reported unknown error type %u\n",
22012203
err_type);
22022204
break;
22032205
}
2206+
return false;
22042207
}
22052208

22062209
#define BNXT_GET_EVENT_PORT(data) \
@@ -2401,7 +2404,8 @@ static int bnxt_async_event_process(struct bnxt *bp,
24012404
goto async_event_process_exit;
24022405
}
24032406
case ASYNC_EVENT_CMPL_EVENT_ID_ERROR_REPORT: {
2404-
bnxt_event_error_report(bp, data1, data2);
2407+
if (bnxt_event_error_report(bp, data1, data2))
2408+
break;
24052409
goto async_event_process_exit;
24062410
}
24072411
case ASYNC_EVENT_CMPL_EVENT_ID_PHC_UPDATE: {
@@ -12085,6 +12089,9 @@ static void bnxt_sp_task(struct work_struct *work)
1208512089
if (test_and_clear_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event))
1208612090
bnxt_fw_echo_reply(bp);
1208712091

12092+
if (test_and_clear_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event))
12093+
bnxt_hwmon_notify_event(bp);
12094+
1208812095
/* These functions below will clear BNXT_STATE_IN_SP_TASK. They
1208912096
* must be the last functions to be called before exiting.
1209012097
*/

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,6 +2094,7 @@ struct bnxt {
20942094
#define BNXT_FW_RESET_NOTIFY_SP_EVENT 18
20952095
#define BNXT_FW_EXCEPTION_SP_EVENT 19
20962096
#define BNXT_LINK_CFG_CHANGE_SP_EVENT 21
2097+
#define BNXT_THERMAL_THRESHOLD_SP_EVENT 22
20972098
#define BNXT_FW_ECHO_REQUEST_SP_EVENT 23
20982099

20992100
struct delayed_work fw_reset_task;
@@ -2196,6 +2197,7 @@ struct bnxt {
21962197
u8 fatal_thresh_temp;
21972198
u8 shutdown_thresh_temp;
21982199
#endif
2200+
u32 thermal_threshold_type;
21992201
enum board_idx board_idx;
22002202
};
22012203

drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
#include "bnxt_hwrm.h"
1919
#include "bnxt_hwmon.h"
2020

21-
void bnxt_hwmon_notify_event(struct bnxt *bp, u32 type)
21+
void bnxt_hwmon_notify_event(struct bnxt *bp)
2222
{
2323
u32 attr;
2424

2525
if (!bp->hwmon_dev)
2626
return;
2727

28-
switch (type) {
28+
switch (bp->thermal_threshold_type) {
2929
case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_WARN:
3030
attr = hwmon_temp_max_alarm;
3131
break;

drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
#define BNXT_HWMON_H
1212

1313
#ifdef CONFIG_BNXT_HWMON
14-
void bnxt_hwmon_notify_event(struct bnxt *bp, u32 type);
14+
void bnxt_hwmon_notify_event(struct bnxt *bp);
1515
void bnxt_hwmon_uninit(struct bnxt *bp);
1616
void bnxt_hwmon_init(struct bnxt *bp);
1717
#else
18-
static inline void bnxt_hwmon_notify_event(struct bnxt *bp, u32 type)
18+
static inline void bnxt_hwmon_notify_event(struct bnxt *bp)
1919
{
2020
}
2121

0 commit comments

Comments
 (0)