Commit c738fb61 authored by Alon Giladi's avatar Alon Giladi Committed by Johannes Berg

wifi: iwlwifi: Separate loading and setting of power reduce tables

Take the part that copies the tables into DRAM, out of the method
that sets the prph_scratch to make the code cleaner. Each of the
operations will get more complex in the future when it will also
support larger power-reduce tables images.
Signed-off-by: default avatarAlon Giladi <alon.giladi@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230606103519.7695684dc848.I13626cd318e5d68efec9618b2045f52788bff114@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 63b9e7b9
...@@ -329,14 +329,17 @@ int iwl_pnvm_load(struct iwl_trans *trans, ...@@ -329,14 +329,17 @@ int iwl_pnvm_load(struct iwl_trans *trans,
*/ */
trans->reduce_power_loaded = true; trans->reduce_power_loaded = true;
} else { } else {
ret = iwl_trans_set_reduce_power(trans, data, length); ret = iwl_trans_load_reduce_power(trans, data, length);
if (ret) if (ret) {
IWL_DEBUG_FW(trans, IWL_DEBUG_FW(trans,
"Failed to set reduce power table %d\n", "Failed to load reduce power table %d\n",
ret); ret);
trans->reduce_power_loaded = true;
}
kfree(data); kfree(data);
} }
} }
iwl_trans_set_reduce_power(trans);
iwl_init_notification_wait(notif_wait, &pnvm_wait, iwl_init_notification_wait(notif_wait, &pnvm_wait,
ntf_cmds, ARRAY_SIZE(ntf_cmds), ntf_cmds, ARRAY_SIZE(ntf_cmds),
......
...@@ -292,8 +292,9 @@ int iwl_trans_pcie_ctx_info_gen3_load_pnvm(struct iwl_trans *trans, ...@@ -292,8 +292,9 @@ int iwl_trans_pcie_ctx_info_gen3_load_pnvm(struct iwl_trans *trans,
const struct iwl_ucode_capabilities *capa); const struct iwl_ucode_capabilities *capa);
void iwl_trans_pcie_ctx_info_gen3_set_pnvm(struct iwl_trans *trans, void iwl_trans_pcie_ctx_info_gen3_set_pnvm(struct iwl_trans *trans,
const struct iwl_ucode_capabilities *capa); const struct iwl_ucode_capabilities *capa);
int iwl_trans_pcie_ctx_info_gen3_set_reduce_power(struct iwl_trans *trans, int iwl_trans_pcie_ctx_info_gen3_load_reduce_power(struct iwl_trans *trans,
const void *data, u32 len); const void *data, u32 len);
void iwl_trans_pcie_ctx_info_gen3_set_reduce_power(struct iwl_trans *trans);
int iwl_trans_pcie_ctx_info_gen3_set_step(struct iwl_trans *trans, int iwl_trans_pcie_ctx_info_gen3_set_step(struct iwl_trans *trans,
u32 mbx_addr_0_step, u32 mbx_addr_1_step); u32 mbx_addr_0_step, u32 mbx_addr_1_step);
#endif /* __iwl_context_info_file_gen3_h__ */ #endif /* __iwl_context_info_file_gen3_h__ */
...@@ -562,6 +562,8 @@ struct iwl_pnvm_image { ...@@ -562,6 +562,8 @@ struct iwl_pnvm_image {
* @load_pnvm: save the pnvm data in DRAM * @load_pnvm: save the pnvm data in DRAM
* @set_pnvm: set the pnvm data in the prph scratch buffer, inside the * @set_pnvm: set the pnvm data in the prph scratch buffer, inside the
* context info. * context info.
* @load_reduce_power: copy reduce power table to the corresponding DRAM memory
* @set_reduce_power: set reduce power table addresses in the sratch buffer
* @interrupts: disable/enable interrupts to transport * @interrupts: disable/enable interrupts to transport
*/ */
struct iwl_trans_ops { struct iwl_trans_ops {
...@@ -638,8 +640,11 @@ struct iwl_trans_ops { ...@@ -638,8 +640,11 @@ struct iwl_trans_ops {
const struct iwl_ucode_capabilities *capa); const struct iwl_ucode_capabilities *capa);
void (*set_pnvm)(struct iwl_trans *trans, void (*set_pnvm)(struct iwl_trans *trans,
const struct iwl_ucode_capabilities *capa); const struct iwl_ucode_capabilities *capa);
int (*set_reduce_power)(struct iwl_trans *trans, int (*load_reduce_power)(struct iwl_trans *trans,
const void *data, u32 len); const void *data,
u32 len);
void (*set_reduce_power)(struct iwl_trans *trans);
void (*interrupts)(struct iwl_trans *trans, bool enable); void (*interrupts)(struct iwl_trans *trans, bool enable);
int (*imr_dma_data)(struct iwl_trans *trans, int (*imr_dma_data)(struct iwl_trans *trans,
u32 dst_addr, u64 src_addr, u32 dst_addr, u64 src_addr,
...@@ -1554,18 +1559,17 @@ static inline void iwl_trans_set_pnvm(struct iwl_trans *trans, ...@@ -1554,18 +1559,17 @@ static inline void iwl_trans_set_pnvm(struct iwl_trans *trans,
trans->ops->set_pnvm(trans, capa); trans->ops->set_pnvm(trans, capa);
} }
static inline int iwl_trans_set_reduce_power(struct iwl_trans *trans, static inline int iwl_trans_load_reduce_power(struct iwl_trans *trans,
const void *data, u32 len) const void *data,
u32 len)
{ {
if (trans->ops->set_reduce_power) { return trans->ops->load_reduce_power(trans, data, len);
int ret = trans->ops->set_reduce_power(trans, data, len); }
if (ret)
return ret;
}
trans->reduce_power_loaded = true; static inline void iwl_trans_set_reduce_power(struct iwl_trans *trans)
return 0; {
if (trans->ops->set_reduce_power)
trans->ops->set_reduce_power(trans);
} }
static inline bool iwl_trans_dbg_ini_valid(struct iwl_trans *trans) static inline bool iwl_trans_dbg_ini_valid(struct iwl_trans *trans)
......
...@@ -442,8 +442,9 @@ void iwl_trans_pcie_ctx_info_gen3_set_pnvm(struct iwl_trans *trans, ...@@ -442,8 +442,9 @@ void iwl_trans_pcie_ctx_info_gen3_set_pnvm(struct iwl_trans *trans,
iwl_pcie_set_continuous_pnvm(trans); iwl_pcie_set_continuous_pnvm(trans);
} }
int iwl_trans_pcie_ctx_info_gen3_set_reduce_power(struct iwl_trans *trans, int iwl_trans_pcie_ctx_info_gen3_load_reduce_power(struct iwl_trans *trans,
const void *data, u32 len) const void *data,
u32 len)
{ {
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl = struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl =
...@@ -467,12 +468,21 @@ int iwl_trans_pcie_ctx_info_gen3_set_reduce_power(struct iwl_trans *trans, ...@@ -467,12 +468,21 @@ int iwl_trans_pcie_ctx_info_gen3_set_reduce_power(struct iwl_trans *trans,
return ret; return ret;
} }
} }
return 0;
}
void iwl_trans_pcie_ctx_info_gen3_set_reduce_power(struct iwl_trans *trans)
{
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl =
&trans_pcie->prph_scratch->ctrl_cfg;
if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210)
return;
prph_sc_ctrl->reduce_power_cfg.base_addr = prph_sc_ctrl->reduce_power_cfg.base_addr =
cpu_to_le64(trans_pcie->reduce_power_dram.physical); cpu_to_le64(trans_pcie->reduce_power_dram.physical);
prph_sc_ctrl->reduce_power_cfg.size = prph_sc_ctrl->reduce_power_cfg.size =
cpu_to_le32(trans_pcie->reduce_power_dram.size); cpu_to_le32(trans_pcie->reduce_power_dram.size);
return 0;
} }
...@@ -3556,6 +3556,7 @@ static const struct iwl_trans_ops trans_ops_pcie_gen2 = { ...@@ -3556,6 +3556,7 @@ static const struct iwl_trans_ops trans_ops_pcie_gen2 = {
.rxq_dma_data = iwl_trans_pcie_rxq_dma_data, .rxq_dma_data = iwl_trans_pcie_rxq_dma_data,
.load_pnvm = iwl_trans_pcie_ctx_info_gen3_load_pnvm, .load_pnvm = iwl_trans_pcie_ctx_info_gen3_load_pnvm,
.set_pnvm = iwl_trans_pcie_ctx_info_gen3_set_pnvm, .set_pnvm = iwl_trans_pcie_ctx_info_gen3_set_pnvm,
.load_reduce_power = iwl_trans_pcie_ctx_info_gen3_load_reduce_power,
.set_reduce_power = iwl_trans_pcie_ctx_info_gen3_set_reduce_power, .set_reduce_power = iwl_trans_pcie_ctx_info_gen3_set_reduce_power,
#ifdef CONFIG_IWLWIFI_DEBUGFS #ifdef CONFIG_IWLWIFI_DEBUGFS
.debugfs_cleanup = iwl_trans_pcie_debugfs_cleanup, .debugfs_cleanup = iwl_trans_pcie_debugfs_cleanup,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment