habanalabs: create two char devices per ASIC
authorOded Gabbay <oded.gabbay@gmail.com>
Tue, 30 Jul 2019 06:10:50 +0000 (09:10 +0300)
committerOded Gabbay <oded.gabbay@gmail.com>
Thu, 5 Sep 2019 11:55:26 +0000 (14:55 +0300)
commit4d6a7751f6c376f8d20f46685fe87bc47557e233
treea24ace3555d51bb073f493611669035035760888
parentb968eb1a84e09f30eab9b88d30758187087b3492
habanalabs: create two char devices per ASIC

This patch changes the driver to create two char devices for each ASIC
it discovers. This is done to allow system/monitoring applications to
query the device for stats, information, idle state and more, while also
allowing the deep-learning application to send work to the ASIC.

One char device is the original device, hlX. IOCTL calls through this
device file can perform any task on the device (compute, memory, queries).
The open function for this device will fail if it was called before but
the file-descriptor it created was not completely released yet (the
release callback function is not called from the kernel until all
instances of that FD are closed). The driver needs to keep this behavior
to support backward compatibility with existing userspace, which count
that the open will fail if the device is "occupied".

The second char device is called "hl_controlDx", where x is the same index
of the main device with a minor number of the original char device + 1.
Applications that open this device can only call the INFO IOCTL. There is
no limitation on the number of applications opening this device.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/habanalabs/device.c
drivers/misc/habanalabs/habanalabs.h
drivers/misc/habanalabs/habanalabs_drv.c
drivers/misc/habanalabs/habanalabs_ioctl.c