wil6210: prevent device memory access while in reset or suspend
Accessing some of the memory of the device while the device is resetting or suspending may cause unexpected error as the HW is still not in a stable state. Prevent this access to guarantee successful read/write memory operations. Signed-off-by: Ahmad Masri <amasri@codeaurora.org> Signed-off-by: Maya Erez <merez@codeaurora.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
@@ -258,6 +258,11 @@ static void wil_print_mbox_ring(struct seq_file *s, const char *prefix,
|
||||
|
||||
wil_halp_vote(wil);
|
||||
|
||||
if (wil_mem_access_lock(wil)) {
|
||||
wil_halp_unvote(wil);
|
||||
return;
|
||||
}
|
||||
|
||||
wil_memcpy_fromio_32(&r, off, sizeof(r));
|
||||
wil_mbox_ring_le2cpus(&r);
|
||||
/*
|
||||
@@ -323,6 +328,7 @@ static void wil_print_mbox_ring(struct seq_file *s, const char *prefix,
|
||||
}
|
||||
out:
|
||||
seq_puts(s, "}\n");
|
||||
wil_mem_access_unlock(wil);
|
||||
wil_halp_unvote(wil);
|
||||
}
|
||||
|
||||
@@ -601,6 +607,12 @@ static int memread_show(struct seq_file *s, void *data)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = wil_mem_access_lock(wil);
|
||||
if (ret) {
|
||||
wil_pm_runtime_put(wil);
|
||||
return ret;
|
||||
}
|
||||
|
||||
a = wmi_buffer(wil, cpu_to_le32(mem_addr));
|
||||
|
||||
if (a)
|
||||
@@ -608,6 +620,7 @@ static int memread_show(struct seq_file *s, void *data)
|
||||
else
|
||||
seq_printf(s, "[0x%08x] = INVALID\n", mem_addr);
|
||||
|
||||
wil_mem_access_unlock(wil);
|
||||
wil_pm_runtime_put(wil);
|
||||
|
||||
return 0;
|
||||
@@ -626,10 +639,6 @@ static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
|
||||
size_t unaligned_bytes, aligned_count, ret;
|
||||
int rc;
|
||||
|
||||
if (test_bit(wil_status_suspending, wil_blob->wil->status) ||
|
||||
test_bit(wil_status_suspended, wil_blob->wil->status))
|
||||
return 0;
|
||||
|
||||
if (pos < 0)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -656,11 +665,19 @@ static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = wil_mem_access_lock(wil);
|
||||
if (rc) {
|
||||
kfree(buf);
|
||||
wil_pm_runtime_put(wil);
|
||||
return rc;
|
||||
}
|
||||
|
||||
wil_memcpy_fromio_32(buf, (const void __iomem *)
|
||||
wil_blob->blob.data + aligned_pos, aligned_count);
|
||||
|
||||
ret = copy_to_user(user_buf, buf + unaligned_bytes, count);
|
||||
|
||||
wil_mem_access_unlock(wil);
|
||||
wil_pm_runtime_put(wil);
|
||||
|
||||
kfree(buf);
|
||||
|
Reference in New Issue
Block a user