habanalabs: reset after device is actually released
authorOded Gabbay <ogabbay@kernel.org>
Tue, 16 Feb 2021 20:34:24 +0000 (22:34 +0200)
committerOded Gabbay <ogabbay@kernel.org>
Fri, 9 Apr 2021 11:09:22 +0000 (14:09 +0300)
commit35862d1c99471e3a03175e94d267815a0921e9ca
treef0a22a1c651358ec0584534cdb86395695891fc6
parent8e9445a678cab4478aa90a5f8898ba093371e30f
habanalabs: reset after device is actually released

The device is actually released only after the refcnt of the hpriv
structure is 0, which means all its contexts were closed.

If we reset the device while a context is still open, there are
possibilities for unexpected behavior and crashes. For example, if the
process has a mapping of a register block that is now currently being
reset, and the process writes/reads to that block during the reset,
the device can get stuck.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/device.c