[Fix] Remove the dependency with npu scheduler
authorDongju Chae <dongju.chae@samsung.com>
Wed, 9 Jun 2021 08:37:24 +0000 (17:37 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Thu, 10 Jun 2021 02:43:49 +0000 (11:43 +0900)
This patch removes the dependency with npu scheduler.
Only when taks_handle is set, npu scheduler is used.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
src/core/npu/NPUdrvAPI.h
src/core/npu/NPUdrvAPI_triv2.cc

index ef2834d..385bc77 100644 (file)
@@ -177,7 +177,6 @@ class TrinityVision2API : public DriverAPI {
 
   static ThreadSafeMap<int, CuseElement> cuse_map;
 
-  int sched_dev_fd_;
   bool is_cuse_;
 
   std::fstream dev_ios_;
index 92df919..e4dd128 100644 (file)
@@ -12,7 +12,6 @@
  */
 
 #include <misc/trinity.h>
-#include <misc/npu_sched_ioctl.h>
 
 #include <sys/ioctl.h>
 #include <sys/fcntl.h>
@@ -62,7 +61,7 @@ ThreadSafeMap<int, CuseElement> TrinityVision2API::cuse_map;
  * @param[in] dev_id device id
  */
 TrinityVision2API::TrinityVision2API (int dev_id)
-    : DriverAPI (dev_id), sched_dev_fd_ (-1), is_cuse_ (false) {
+    : DriverAPI (dev_id), is_cuse_ (false) {
   int num_devs;
 
   if (dev_id > max_num_devs) {
@@ -78,17 +77,12 @@ TrinityVision2API::TrinityVision2API (int dev_id)
     this->dev_id_ = -1;
     return;
   }
-
-  /* Try to open a scheduler device */
-  this->sched_dev_fd_ = ::open ("/dev/npusched", O_RDWR);
 }
 
 /** @brief destructor of emulation API driver */
 TrinityVision2API::~TrinityVision2API () {
   if (dev_fd_ >= 0)
     ::close (dev_fd_);
-  if (sched_dev_fd_ >= 0)
-    ::close (sched_dev_fd_);
 }
 
 int
@@ -466,45 +460,6 @@ TrinityVision2API::runInput (input_config_t *input_config) const {
   if (input_config == nullptr)
     return -EINVAL;
 
-  if (sched_dev_fd_ >= 0) {
-    struct npu_sched_ioctl_create_param param;
-    struct npu_sched_ioctl_task_attribute task_attrib;
-    struct npu_sched_ioctl_task_id task_id;
-
-    param.id = getpid ();
-    param.is_rt = false;
-    param.nice_value = input_config->priority;
-    param.num_subtasks = 1; /* FIXME */
-
-    ret = ioctl (sched_dev_fd_, NPU_SCHED_CREATE_TASK, &param);
-    if (ret != 0)
-      return -errno;
-
-    task_attrib.task_handle = param.handle;
-    task_attrib.subtask_idx = 0;
-    /* reference attributes from VD */
-    task_attrib.wcet = 420000; /* worst-case execution time */
-    task_attrib.deadline = 8000000;
-    task_attrib.period = 32000000;
-    task_attrib.yield = 10250000;
-    ret = ioctl (sched_dev_fd_, NPU_SCHED_SET_TASK_ATTRIB, &task_attrib);
-    if (ret != 0)
-      return -errno;
-
-    task_id.task_handle = param.handle;
-    task_id.subtask_idx = 0;
-    task_id.id = 0x0; /* FIXME */
-    ret = ioctl (sched_dev_fd_, NPU_SCHED_SET_TASK_ID, &task_id);
-    if (ret != 0)
-      return -errno;
-
-    ret = ioctl (sched_dev_fd_, NPU_SCHED_ACTIVATE_TASK, &param.handle);
-    if (ret != 0)
-      return -errno;
-
-    input_config->task_handle = param.handle;
-  }
-
   /* translate dmabuf FDs to cuse-compatible ones */
   if (is_cuse_) {
     CuseElement *elem;
@@ -538,6 +493,12 @@ TrinityVision2API::runInput (input_config_t *input_config) const {
     this->munmap (segt, PAGE_SIZE);
   }
 
+  /**
+   * TODO: this value is an indicator whether to use VD NPU Scheduler.
+   * When VD NPU manager is available, set this value properly.
+   */
+  input_config->task_handle = UINT32_MAX;
+
   ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_RUN_INPUT, input_config);
   if (ret != 0)
     return -errno;