From 7d2fdac2257cbc3c866e65727f1468f4c164707b Mon Sep 17 00:00:00 2001 From: Manikanta Pubbisetty Date: Wed, 20 Jan 2021 14:58:18 +0530 Subject: [PATCH] qcacld-3.0: add history for FST locking Adding history to track the FST lock/unlock events; this would come in handy in debugging deadlock issues. Change-Id: I40f783e72e516330fdf71ac91553bc7c4338b82a CRs-Fixed: 2854397 --- Kbuild | 2 + configs/default_defconfig | 3 ++ core/dp/txrx3.0/dp_fisa_rx.c | 88 ++++++++++++++++++++++++++++++++++-- core/dp/txrx3.0/dp_fisa_rx.h | 21 ++++++++- 4 files changed, 108 insertions(+), 6 deletions(-) diff --git a/Kbuild b/Kbuild index 6d70d7fbcc18..dd7642bc2741 100644 --- a/Kbuild +++ b/Kbuild @@ -3657,6 +3657,8 @@ ccflags-y += -DDP_RX_BUFFER_POOL_ALLOC_THRES=$(CONFIG_DP_RX_BUFFER_POOL_ALLOC_TH endif endif +cppflags-$(CONFIG_DP_FT_LOCK_HISTORY) += -DDP_FT_LOCK_HISTORY + ccflags-$(CONFIG_GET_DRIVER_MODE) += -DFEATURE_GET_DRIVER_MODE KBUILD_CPPFLAGS += $(cppflags-y) diff --git a/configs/default_defconfig b/configs/default_defconfig index 67200686f1b8..457e58764dfb 100644 --- a/configs/default_defconfig +++ b/configs/default_defconfig @@ -1129,6 +1129,9 @@ ifeq ($(CONFIG_CNSS_QCA6750), y) CONFIG_BAND_6GHZ := y CONFIG_RX_FISA := y CONFIG_MORE_TX_DESC := y + ifeq ($(CONFIG_SLUB_DEBUG_ON), y) + CONFIG_DP_FT_LOCK_HISTORY := y + endif endif ifeq ($(CONFIG_CNSS_QCA6490), y) diff --git a/core/dp/txrx3.0/dp_fisa_rx.c b/core/dp/txrx3.0/dp_fisa_rx.c index 7212f08789da..284b1037c5a7 100644 --- a/core/dp/txrx3.0/dp_fisa_rx.c +++ b/core/dp/txrx3.0/dp_fisa_rx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -257,6 +257,82 @@ dp_rx_fisa_setup_hw_fse(struct dp_rx_fst *fisa_hdl, return hw_fse; } +#ifdef DP_FT_LOCK_HISTORY +struct dp_ft_lock_history ft_lock_hist[MAX_REO_DEST_RINGS]; + +/** + * dp_rx_fisa_record_ft_lock_event() - Record FT lock/unlock events + * @reo_id: REO ID + * @func: caller function + * @type: lock/unlock event type + * + * Return: None + */ +static void dp_rx_fisa_record_ft_lock_event(uint8_t reo_id, const char *func, + enum dp_ft_lock_event_type type) +{ + struct dp_ft_lock_history *lock_hist; + struct dp_ft_lock_record *record; + uint32_t record_idx; + + if (reo_id >= MAX_REO_DEST_RINGS) + return; + + lock_hist = &ft_lock_hist[reo_id]; + record_idx = lock_hist->record_idx % DP_FT_LOCK_MAX_RECORDS; + ft_lock_hist->record_idx++; + + record = &lock_hist->ft_lock_rec[record_idx]; + + record->func = func; + record->cpu_id = qdf_get_cpu(); + record->timestamp = qdf_get_log_timestamp(); + record->type = type; +} + +/** + * __dp_rx_fisa_acquire_ft_lock() - Acquire lock which protects SW FT entries + * @fisa_hdl: Handle to fisa context + * @reo_id: REO ID + * + * Return: None + */ +static inline void +__dp_rx_fisa_acquire_ft_lock(struct dp_rx_fst *fisa_hdl, + uint8_t reo_id, const char *func) +{ + if (!fisa_hdl->flow_deletion_supported) + return; + + qdf_spin_lock_bh(&fisa_hdl->dp_rx_sw_ft_lock[reo_id]); + dp_rx_fisa_record_ft_lock_event(reo_id, func, DP_FT_LOCK_EVENT); +} + +/** + * __dp_rx_fisa_release_ft_lock() - Release lock which protects SW FT entries + * @fisa_hdl: Handle to fisa context + * @reo_id: REO ID + * + * Return: None + */ +static inline void +__dp_rx_fisa_release_ft_lock(struct dp_rx_fst *fisa_hdl, + uint8_t reo_id, const char *func) +{ + if (!fisa_hdl->flow_deletion_supported) + return; + + qdf_spin_unlock_bh(&fisa_hdl->dp_rx_sw_ft_lock[reo_id]); + dp_rx_fisa_record_ft_lock_event(reo_id, func, DP_FT_UNLOCK_EVENT); +} + +#define dp_rx_fisa_acquire_ft_lock(fisa_hdl, reo_id) \ + __dp_rx_fisa_acquire_ft_lock(fisa_hdl, reo_id, __func__) + +#define dp_rx_fisa_release_ft_lock(fisa_hdl, reo_id) \ + __dp_rx_fisa_release_ft_lock(fisa_hdl, reo_id, __func__) + +#else /** * dp_rx_fisa_acquire_ft_lock() - Acquire lock which protects SW FT entries * @fisa_hdl: Handle to fisa context @@ -272,7 +348,7 @@ dp_rx_fisa_acquire_ft_lock(struct dp_rx_fst *fisa_hdl, uint8_t reo_id) } /** - * dp_rx_fisa_acquire_ft_lock() - Release lock which protects SW FT entries + * dp_rx_fisa_release_ft_lock() - Release lock which protects SW FT entries * @fisa_hdl: Handle to fisa context * @reo_id: REO ID * @@ -284,6 +360,7 @@ dp_rx_fisa_release_ft_lock(struct dp_rx_fst *fisa_hdl, uint8_t reo_id) if (fisa_hdl->flow_deletion_supported) qdf_spin_unlock_bh(&fisa_hdl->dp_rx_sw_ft_lock[reo_id]); } +#endif /* DP_FT_LOCK_HISTORY */ /** * dp_rx_fisa_setup_cmem_fse() - Setup the flow search entry in HW CMEM @@ -1484,6 +1561,7 @@ static int dp_add_nbuf_to_fisa_flow(struct dp_rx_fst *fisa_hdl, hal_soc_handle_t hal_soc_hdl = fisa_hdl->soc_hdl->hal_soc; uint32_t hal_aggr_count; uint8_t napi_id = QDF_NBUF_CB_RX_CTX_ID(nbuf); + uint8_t reo_id = fisa_flow->napi_id; dump_tlvs(hal_soc_hdl, rx_tlv_hdr, QDF_TRACE_LEVEL_INFO_HIGH); dp_fisa_debug("nbuf: %pK nbuf->next:%pK nbuf->data:%pK len %d data_len %d", @@ -1507,7 +1585,7 @@ static int dp_add_nbuf_to_fisa_flow(struct dp_rx_fst *fisa_hdl, hal_aggr_count = hal_rx_get_fisa_flow_agg_count(hal_soc_hdl, rx_tlv_hdr); - dp_rx_fisa_acquire_ft_lock(fisa_hdl, fisa_flow->napi_id); + dp_rx_fisa_acquire_ft_lock(fisa_hdl, reo_id); if (!flow_aggr_cont) { /* Start of new aggregation for the flow @@ -1612,12 +1690,12 @@ static int dp_add_nbuf_to_fisa_flow(struct dp_rx_fst *fisa_hdl, dp_rx_fisa_aggr_tcp(fisa_hdl, fisa_flow, nbuf); } - dp_rx_fisa_release_ft_lock(fisa_hdl, fisa_flow->napi_id); + dp_rx_fisa_release_ft_lock(fisa_hdl, reo_id); return FISA_AGGR_DONE; invalid_fisa_assist: /* Not eligible aggregation deliver frame without FISA */ - dp_rx_fisa_release_ft_lock(fisa_hdl, fisa_flow->napi_id); + dp_rx_fisa_release_ft_lock(fisa_hdl, reo_id); return FISA_AGGR_NOT_ELIGIBLE; } diff --git a/core/dp/txrx3.0/dp_fisa_rx.h b/core/dp/txrx3.0/dp_fisa_rx.h index f3b7cb860b1d..83aa22951902 100644 --- a/core/dp/txrx3.0/dp_fisa_rx.h +++ b/core/dp/txrx3.0/dp_fisa_rx.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -41,6 +41,8 @@ #define IPSEC_PORT 500 #define IPSEC_NAT_PORT 4500 +#define DP_FT_LOCK_MAX_RECORDS 32 + struct dp_fisa_rx_fst_update_elem { /* Do not add new entries here */ qdf_list_node_t node; @@ -53,6 +55,23 @@ struct dp_fisa_rx_fst_update_elem { u8 reo_id; }; +enum dp_ft_lock_event_type { + DP_FT_LOCK_EVENT, + DP_FT_UNLOCK_EVENT, +}; + +struct dp_ft_lock_record { + const char *func; + int cpu_id; + uint64_t timestamp; + enum dp_ft_lock_event_type type; +}; + +struct dp_ft_lock_history { + uint32_t record_idx; + struct dp_ft_lock_record ft_lock_rec[DP_FT_LOCK_MAX_RECORDS]; +}; + /** * dp_rx_dump_fisa_stats() - Dump fisa stats * @soc: core txrx main context