wifi: iwlwifi: fw: add clarifying comments about iwl_fwrt_dump_data
authorJohannes Berg <johannes.berg@intel.com>
Tue, 19 Mar 2024 08:10:21 +0000 (10:10 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 25 Mar 2024 14:39:10 +0000 (15:39 +0100)
iwl_fw_dbg_collect_sync() unconditionally accesses 'trig' at
the beginning of the function, even though the data has an
inner union and 'trig' isn't necessarily always used, it can
be 'desc' instead. Add comments clarifying why this is OK,
that 'trig'/'desc' must be first in the struct and how in it
the use of the union's sub-structs is differentiated.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240319100755.49c3a39737cc.I91c588e0d66b49f0ee9103e8d4a0e501c2fd36d6@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/dbg.c
drivers/net/wireless/intel/iwlwifi/fw/runtime.h

index db6d7013df6654434774e9ec2bb4de33be50f4d2..0fd7d130c408e8c80d4e9451b4c7e03f85e5e562 100644 (file)
@@ -3086,6 +3086,7 @@ static void iwl_fw_dbg_collect_sync(struct iwl_fw_runtime *fwrt, u8 wk_idx)
        if (!test_bit(wk_idx, &fwrt->dump.active_wks))
                return;
 
+       /* also checks 'desc' for pre-ini mode, since that shadows in union */
        if (!dump_data->trig) {
                IWL_ERR(fwrt, "dump trigger data is not set\n");
                goto out;
index b2bc4fd37abf9dae98076caecc7c4e469fb37a24..4204e999bbf2f375b9337317eeede35f78c4912d 100644 (file)
@@ -46,6 +46,10 @@ struct iwl_fwrt_shared_mem_cfg {
  * struct iwl_fwrt_dump_data - dump data
  * @trig: trigger the worker was scheduled upon
  * @fw_pkt: packet received from FW
+ *
+ * Note that the decision which part of the union is used
+ * is based on iwl_trans_dbg_ini_valid(): the 'trig' part
+ * is used if it is %true, the 'desc' part otherwise.
  */
 struct iwl_fwrt_dump_data {
        union {
@@ -54,6 +58,7 @@ struct iwl_fwrt_dump_data {
                        struct iwl_rx_packet *fw_pkt;
                };
                struct {
+                       /* must be first to be same as 'trig' */
                        const struct iwl_fw_dump_desc *desc;
                        bool monitor_only;
                };