* [PATCH] habanalabs: add more protection of device during reset
@ 2019-11-18 13:06 Oded Gabbay
2019-11-18 13:19 ` Tomer Tayar
0 siblings, 1 reply; 2+ messages in thread
From: Oded Gabbay @ 2019-11-18 13:06 UTC (permalink / raw)
To: linux-kernel, oshpigelman, ttayar; +Cc: gregkh
Prevent accesses to the device (register read/write) from debugfs entries
during reset as that can cause the device to get stuck.
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
---
drivers/misc/habanalabs/debugfs.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/misc/habanalabs/debugfs.c b/drivers/misc/habanalabs/debugfs.c
index 1cf75010a379..20413e350343 100644
--- a/drivers/misc/habanalabs/debugfs.c
+++ b/drivers/misc/habanalabs/debugfs.c
@@ -528,6 +528,12 @@ static int engines_show(struct seq_file *s, void *data)
struct hl_dbg_device_entry *dev_entry = entry->dev_entry;
struct hl_device *hdev = dev_entry->hdev;
+ if (atomic_read(&hdev->in_reset)) {
+ dev_warn_ratelimited(hdev->dev,
+ "Can't check device idle during reset\n");
+ return 0;
+ }
+
hdev->asic_funcs->is_device_idle(hdev, NULL, s);
return 0;
@@ -640,6 +646,11 @@ static ssize_t hl_data_read32(struct file *f, char __user *buf,
u32 val;
ssize_t rc;
+ if (atomic_read(&hdev->in_reset)) {
+ dev_warn_ratelimited(hdev->dev, "Can't read during reset\n");
+ return 0;
+ }
+
if (*ppos)
return 0;
@@ -669,6 +680,11 @@ static ssize_t hl_data_write32(struct file *f, const char __user *buf,
u32 value;
ssize_t rc;
+ if (atomic_read(&hdev->in_reset)) {
+ dev_warn_ratelimited(hdev->dev, "Can't write during reset\n");
+ return 0;
+ }
+
rc = kstrtouint_from_user(buf, count, 16, &value);
if (rc)
return rc;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH] habanalabs: add more protection of device during reset
2019-11-18 13:06 [PATCH] habanalabs: add more protection of device during reset Oded Gabbay
@ 2019-11-18 13:19 ` Tomer Tayar
0 siblings, 0 replies; 2+ messages in thread
From: Tomer Tayar @ 2019-11-18 13:19 UTC (permalink / raw)
To: Oded Gabbay, linux-kernel, Omer Shpigelman; +Cc: gregkh
On Mon, Nov 18, 2019 at 15:07 Oded Gabbay wrote:
> Prevent accesses to the device (register read/write) from debugfs entries
> during reset as that can cause the device to get stuck.
>
> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Reviewed-by: Tomer Tayar <ttayar@habana.ai>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-18 13:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 13:06 [PATCH] habanalabs: add more protection of device during reset Oded Gabbay
2019-11-18 13:19 ` Tomer Tayar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.