All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm: make drm_syncobj_array_wait() use the range hrtimer feature
@ 2021-12-18 14:18 Tatsuyuki Ishi
  2021-12-18 18:07 ` kernel test robot
  2021-12-19  4:14   ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Tatsuyuki Ishi @ 2021-12-18 14:18 UTC (permalink / raw)
  To: dri-devel; +Cc: Tatsuyuki Ishi

select(), poll() and epoll_wait() all already supports high-precision
timeout handling. This patch makes drm_syncobj_array_wait() to handle
the timeout in high precision using the same heuristics and functions
implemented for select().

v2: Fix a name error resulting in NULL dereference.

Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
---
 drivers/gpu/drm/drm_syncobj.c | 75 ++++++++++++++++++++---------------
 1 file changed, 44 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index c9a9d74f338c..b2f1631e7dc2 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -949,17 +949,30 @@ static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,
 	list_del_init(&wait->node);
 }
 
-static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
-						  void __user *user_points,
-						  uint32_t count,
-						  uint32_t flags,
-						  signed long timeout,
-						  uint32_t *idx)
+static int drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
+					  void __user *user_points,
+					  uint32_t count, uint32_t flags,
+					  struct timespec64 *timeout,
+					  uint32_t *idx)
 {
 	struct syncobj_wait_entry *entries;
 	struct dma_fence *fence;
 	uint64_t *points;
 	uint32_t signaled_count, i;
+	u64 slack = 0;
+	ktime_t expires, *to = NULL;
+	int ret = 0, timed_out = 0;
+
+	if (timeout->tv_sec | timeout->tv_nsec) {
+		slack = select_estimate_accuracy(timeout);
+		to = &expires;
+		*to = timespec64_to_ktime(*timeout);
+	} else {
+		/*
+		 * Avoid scheduling a hrtimer wait if timeout is zero.
+		 */
+		timed_out = 1;
+	}
 
 	if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT)
 		lockdep_assert_none_held_once();
@@ -973,13 +986,13 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
 
 	} else if (copy_from_user(points, user_points,
 				  sizeof(uint64_t) * count)) {
-		timeout = -EFAULT;
+		ret = -EFAULT;
 		goto err_free_points;
 	}
 
 	entries = kcalloc(count, sizeof(*entries), GFP_KERNEL);
 	if (!entries) {
-		timeout = -ENOMEM;
+		ret = -ENOMEM;
 		goto err_free_points;
 	}
 	/* Walk the list of sync objects and initialize entries.  We do
@@ -999,7 +1012,7 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
 			if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {
 				continue;
 			} else {
-				timeout = -EINVAL;
+				ret = -EINVAL;
 				goto cleanup_entries;
 			}
 		}
@@ -1063,17 +1076,18 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
 		if (signaled_count == count)
 			goto done_waiting;
 
-		if (timeout == 0) {
-			timeout = -ETIME;
+		if (timed_out) {
+			ret = -ETIME;
 			goto done_waiting;
 		}
 
 		if (signal_pending(current)) {
-			timeout = -ERESTARTSYS;
+			ret = -ERESTARTSYS;
 			goto done_waiting;
 		}
 
-		timeout = schedule_timeout(timeout);
+		timed_out =
+			!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS);
 	} while (1);
 
 done_waiting:
@@ -1092,7 +1106,7 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
 err_free_points:
 	kfree(points);
 
-	return timeout;
+	return ret;
 }
 
 /**
@@ -1134,28 +1148,27 @@ static int drm_syncobj_array_wait(struct drm_device *dev,
 				  struct drm_syncobj_timeline_wait *timeline_wait,
 				  struct drm_syncobj **syncobjs, bool timeline)
 {
-	signed long timeout = 0;
+	int ret = 0;
+	struct timespec64 timeout;
 	uint32_t first = ~0;
 
 	if (!timeline) {
-		timeout = drm_timeout_abs_to_jiffies(wait->timeout_nsec);
-		timeout = drm_syncobj_array_wait_timeout(syncobjs,
-							 NULL,
-							 wait->count_handles,
-							 wait->flags,
-							 timeout, &first);
-		if (timeout < 0)
-			return timeout;
+		timeout = ns_to_timespec64(wait->timeout_nsec);
+		ret = drm_syncobj_array_wait_timeout(syncobjs, NULL,
+						     wait->count_handles,
+						     wait->flags, &timeout,
+						     &first);
+		if (ret < 0)
+			return ret;
 		wait->first_signaled = first;
 	} else {
-		timeout = drm_timeout_abs_to_jiffies(timeline_wait->timeout_nsec);
-		timeout = drm_syncobj_array_wait_timeout(syncobjs,
-							 u64_to_user_ptr(timeline_wait->points),
-							 timeline_wait->count_handles,
-							 timeline_wait->flags,
-							 timeout, &first);
-		if (timeout < 0)
-			return timeout;
+		timeout = ns_to_timespec64(timeline_wait->timeout_nsec);
+		ret = drm_syncobj_array_wait_timeout(
+			syncobjs, u64_to_user_ptr(timeline_wait->points),
+			timeline_wait->count_handles, timeline_wait->flags,
+			&timeout, &first);
+		if (ret < 0)
+			return ret;
 		timeline_wait->first_signaled = first;
 	}
 	return 0;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm: make drm_syncobj_array_wait() use the range hrtimer feature
  2021-12-18 14:18 [PATCH v2] drm: make drm_syncobj_array_wait() use the range hrtimer feature Tatsuyuki Ishi
@ 2021-12-18 18:07 ` kernel test robot
  2021-12-19  4:14   ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-12-18 18:07 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1772 bytes --]

Hi Tatsuyuki,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on drm-intel/for-linux-next drm-tip/drm-tip drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next v5.16-rc5 next-20211217]
[cannot apply to airlied/drm-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tatsuyuki-Ishi/drm-make-drm_syncobj_array_wait-use-the-range-hrtimer-feature/20211218-222016
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: i386-randconfig-r032-20211218 (https://download.01.org/0day-ci/archive/20211219/202112190150.F108DFWh-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/d0e29bdb6f8cd1a9042e34c833035438900bf332
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tatsuyuki-Ishi/drm-make-drm_syncobj_array_wait-use-the-range-hrtimer-feature/20211218-222016
        git checkout d0e29bdb6f8cd1a9042e34c833035438900bf332
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "select_estimate_accuracy" [drivers/gpu/drm/drm.ko] undefined!

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm: make drm_syncobj_array_wait() use the range hrtimer feature
  2021-12-18 14:18 [PATCH v2] drm: make drm_syncobj_array_wait() use the range hrtimer feature Tatsuyuki Ishi
@ 2021-12-19  4:14   ` kernel test robot
  2021-12-19  4:14   ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-12-19  4:14 UTC (permalink / raw)
  To: Tatsuyuki Ishi; +Cc: llvm, kbuild-all

Hi Tatsuyuki,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on drm-intel/for-linux-next drm-tip/drm-tip drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next v5.16-rc5 next-20211217]
[cannot apply to airlied/drm-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tatsuyuki-Ishi/drm-make-drm_syncobj_array_wait-use-the-range-hrtimer-feature/20211218-222016
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: x86_64-randconfig-a016-20211218 (https://download.01.org/0day-ci/archive/20211219/202112191223.dorzSdCu-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4c9e31a4814592bbda7153833e46728dc7b21100)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d0e29bdb6f8cd1a9042e34c833035438900bf332
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tatsuyuki-Ishi/drm-make-drm_syncobj_array_wait-use-the-range-hrtimer-feature/20211218-222016
        git checkout d0e29bdb6f8cd1a9042e34c833035438900bf332
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "select_estimate_accuracy" [drivers/gpu/drm/drm.ko] undefined!

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm: make drm_syncobj_array_wait() use the range hrtimer feature
@ 2021-12-19  4:14   ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-12-19  4:14 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2043 bytes --]

Hi Tatsuyuki,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on drm-intel/for-linux-next drm-tip/drm-tip drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next v5.16-rc5 next-20211217]
[cannot apply to airlied/drm-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tatsuyuki-Ishi/drm-make-drm_syncobj_array_wait-use-the-range-hrtimer-feature/20211218-222016
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: x86_64-randconfig-a016-20211218 (https://download.01.org/0day-ci/archive/20211219/202112191223.dorzSdCu-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4c9e31a4814592bbda7153833e46728dc7b21100)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d0e29bdb6f8cd1a9042e34c833035438900bf332
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tatsuyuki-Ishi/drm-make-drm_syncobj_array_wait-use-the-range-hrtimer-feature/20211218-222016
        git checkout d0e29bdb6f8cd1a9042e34c833035438900bf332
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "select_estimate_accuracy" [drivers/gpu/drm/drm.ko] undefined!

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-19  4:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-18 14:18 [PATCH v2] drm: make drm_syncobj_array_wait() use the range hrtimer feature Tatsuyuki Ishi
2021-12-18 18:07 ` kernel test robot
2021-12-19  4:14 ` kernel test robot
2021-12-19  4:14   ` kernel test robot

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.