iwlwifi: mvm: check firmware is up in debugfs
Protect various debugfs files that need to communicate with the firmware from being used when the firmware isn't running. Some will just reject getting written to, while others that store some state will simply store it and not apply it immediately. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
This commit is contained in:
parent
9eca702ca1
commit
504bd62466
|
@ -583,7 +583,11 @@ iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
|
||||||
mvm->bt_force_ant_mode = bt_force_ant_mode;
|
mvm->bt_force_ant_mode = bt_force_ant_mode;
|
||||||
IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
|
IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
|
||||||
modes_str[mvm->bt_force_ant_mode]);
|
modes_str[mvm->bt_force_ant_mode]);
|
||||||
|
|
||||||
|
if (iwl_mvm_firmware_running(mvm))
|
||||||
ret = iwl_send_bt_init_conf(mvm);
|
ret = iwl_send_bt_init_conf(mvm);
|
||||||
|
else
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&mvm->mutex);
|
mutex_unlock(&mvm->mutex);
|
||||||
|
@ -800,6 +804,9 @@ static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
|
||||||
{
|
{
|
||||||
int __maybe_unused ret;
|
int __maybe_unused ret;
|
||||||
|
|
||||||
|
if (!iwl_mvm_firmware_running(mvm))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
mutex_lock(&mvm->mutex);
|
mutex_lock(&mvm->mutex);
|
||||||
|
|
||||||
/* allow one more restart that we're provoking here */
|
/* allow one more restart that we're provoking here */
|
||||||
|
@ -817,7 +824,12 @@ static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
|
||||||
static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
|
static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
|
||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI);
|
int ret;
|
||||||
|
|
||||||
|
if (!iwl_mvm_firmware_running(mvm))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
|
ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -857,6 +869,9 @@ iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf,
|
||||||
{
|
{
|
||||||
u8 scan_rx_ant;
|
u8 scan_rx_ant;
|
||||||
|
|
||||||
|
if (!iwl_mvm_firmware_running(mvm))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
|
if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (scan_rx_ant > ANT_ABC)
|
if (scan_rx_ant > ANT_ABC)
|
||||||
|
@ -911,7 +926,11 @@ static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm,
|
||||||
netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));
|
netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));
|
||||||
|
|
||||||
mutex_lock(&mvm->mutex);
|
mutex_lock(&mvm->mutex);
|
||||||
ret = iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, sizeof(cmd), &cmd);
|
if (iwl_mvm_firmware_running(mvm))
|
||||||
|
ret = iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0,
|
||||||
|
sizeof(cmd), &cmd);
|
||||||
|
else
|
||||||
|
ret = 0;
|
||||||
mutex_unlock(&mvm->mutex);
|
mutex_unlock(&mvm->mutex);
|
||||||
|
|
||||||
return ret ?: count;
|
return ret ?: count;
|
||||||
|
@ -931,6 +950,9 @@ static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm,
|
||||||
int bin_len = count / 2;
|
int bin_len = count / 2;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
|
|
||||||
|
if (!iwl_mvm_firmware_running(mvm))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
/* supporting only 9000 descriptor */
|
/* supporting only 9000 descriptor */
|
||||||
if (!mvm->trans->cfg->mq_rx_supported)
|
if (!mvm->trans->cfg->mq_rx_supported)
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
@ -1004,6 +1026,9 @@ static ssize_t iwl_dbgfs_cont_recording_write(struct iwl_mvm *mvm,
|
||||||
struct iwl_continuous_record_cmd cont_rec = {};
|
struct iwl_continuous_record_cmd cont_rec = {};
|
||||||
int ret, rec_mode;
|
int ret, rec_mode;
|
||||||
|
|
||||||
|
if (!iwl_mvm_firmware_running(mvm))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
if (!dest)
|
if (!dest)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
@ -1034,6 +1059,9 @@ static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm,
|
||||||
unsigned int conf_id;
|
unsigned int conf_id;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!iwl_mvm_firmware_running(mvm))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
ret = kstrtouint(buf, 0, &conf_id);
|
ret = kstrtouint(buf, 0, &conf_id);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1052,8 +1080,12 @@ static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm,
|
||||||
char *buf, size_t count,
|
char *buf, size_t count,
|
||||||
loff_t *ppos)
|
loff_t *ppos)
|
||||||
{
|
{
|
||||||
int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
|
int ret;
|
||||||
|
|
||||||
|
if (!iwl_mvm_firmware_running(mvm))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
|
ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
|
@ -1184,7 +1216,8 @@ static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf,
|
||||||
&filter, sizeof(filter));
|
&filter, sizeof(filter));
|
||||||
|
|
||||||
/* send updated bcast filtering configuration */
|
/* send updated bcast filtering configuration */
|
||||||
if (mvm->dbgfs_bcast_filtering.override &&
|
if (iwl_mvm_firmware_running(mvm) &&
|
||||||
|
mvm->dbgfs_bcast_filtering.override &&
|
||||||
iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
|
iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
|
||||||
err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
|
err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
|
||||||
sizeof(cmd), &cmd);
|
sizeof(cmd), &cmd);
|
||||||
|
@ -1256,7 +1289,8 @@ static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm,
|
||||||
&mac, sizeof(mac));
|
&mac, sizeof(mac));
|
||||||
|
|
||||||
/* send updated bcast filtering configuration */
|
/* send updated bcast filtering configuration */
|
||||||
if (mvm->dbgfs_bcast_filtering.override &&
|
if (iwl_mvm_firmware_running(mvm) &&
|
||||||
|
mvm->dbgfs_bcast_filtering.override &&
|
||||||
iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
|
iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
|
||||||
err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
|
err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
|
||||||
sizeof(cmd), &cmd);
|
sizeof(cmd), &cmd);
|
||||||
|
@ -1473,6 +1507,9 @@ iwl_dbgfs_send_echo_cmd_write(struct iwl_mvm *mvm, char *buf,
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!iwl_mvm_firmware_running(mvm))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
mutex_lock(&mvm->mutex);
|
mutex_lock(&mvm->mutex);
|
||||||
ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
|
ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
|
||||||
mutex_unlock(&mvm->mutex);
|
mutex_unlock(&mvm->mutex);
|
||||||
|
@ -1534,6 +1571,9 @@ static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,
|
||||||
size_t delta;
|
size_t delta;
|
||||||
ssize_t ret, len;
|
ssize_t ret, len;
|
||||||
|
|
||||||
|
if (!iwl_mvm_firmware_running(mvm))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
|
hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
|
||||||
DEBUG_GROUP, 0);
|
DEBUG_GROUP, 0);
|
||||||
cmd.op = cpu_to_le32(DEBUG_MEM_OP_READ);
|
cmd.op = cpu_to_le32(DEBUG_MEM_OP_READ);
|
||||||
|
@ -1586,6 +1626,9 @@ static ssize_t iwl_dbgfs_mem_write(struct file *file,
|
||||||
u32 op, len;
|
u32 op, len;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
|
if (!iwl_mvm_firmware_running(mvm))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
|
hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
|
||||||
DEBUG_GROUP, 0);
|
DEBUG_GROUP, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue