Index: sys/external/bsd/common/include/linux/err.h =================================================================== RCS file: /cvsroot/src/sys/external/bsd/common/include/linux/err.h,v retrieving revision 1.1 diff -p -u -r1.1 err.h --- sys/external/bsd/common/include/linux/err.h 18 Aug 2015 21:10:56 -0000 1.1 +++ sys/external/bsd/common/include/linux/err.h 23 Apr 2019 00:48:56 -0000 @@ -38,7 +38,7 @@ #include #include -#define MAX_ERRNO ELAST +#define MAX_ERRNO 4095 static inline bool IS_ERR_VALUE(uintptr_t n) Index: sys/external/bsd/common/include/linux/errno.h =================================================================== RCS file: /cvsroot/src/sys/external/bsd/common/include/linux/errno.h,v retrieving revision 1.3 diff -p -u -r1.3 errno.h --- sys/external/bsd/common/include/linux/errno.h 16 Jul 2014 20:56:24 -0000 1.3 +++ sys/external/bsd/common/include/linux/errno.h 23 Apr 2019 00:48:56 -0000 @@ -35,7 +35,10 @@ * - Linux consistently passes around negative errno values. NetBSD * consistently passes around positive ones, except the special magic * in-kernel ones (EJUSTRETURN, ERESTART, &c.) which should not be - * exposed to userland. Be careful! + * exposed to userland *or* linux-only code using the negative pointer + * means error return pattern. Be careful! If Using ERESTARTSYS from + * Linux code, be sure it is remapped back to ERESTART before NetBSD + * code sees it. */ #ifndef _LINUX_ERRNO_H_ @@ -43,7 +46,7 @@ #include -#define ERESTARTSYS ERESTART +#define ERESTARTSYS (ELAST+1) /* XXX */ #define ENOTSUPP ENOTSUP /* XXX ??? */ #define EREMOTEIO EIO /* XXX Urk... */ #define ECHRNG ERANGE /* XXX ??? */ Index: sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c =================================================================== RCS file: /cvsroot/src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c,v retrieving revision 1.8 diff -p -u -r1.8 nouveau_drm.c --- sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c 11 Feb 2016 04:51:44 -0000 1.8 +++ sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drm.c 23 Apr 2019 00:48:56 -0000 @@ -759,7 +759,8 @@ nouveau_drm_open(struct drm_device *dev, /* need to bring up power immediately if opening device */ ret = pm_runtime_get_sync(dev->dev); if (ret < 0 && ret != -EACCES) - return ret; + /* XXX errno Linux->NetBSD */ + return -ret; #ifndef __NetBSD__ get_task_comm(tmpname, current); Index: sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c =================================================================== RCS file: /cvsroot/src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c,v retrieving revision 1.4.10.1 diff -p -u -r1.4.10.1 nouveau_fence.c --- sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c 31 Aug 2018 17:35:51 -0000 1.4.10.1 +++ sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c 23 Apr 2019 00:48:56 -0000 @@ -567,6 +567,8 @@ nouveau_fence_wait(struct nouveau_fence if (lazy && delay_usec >= 1000*hztoms(1)) { /* XXX errno NetBSD->Linux */ ret = -kpause("nvfencew", intr, 1, NULL); + if (ret == -ERESTART) + ret = -ERESTARTSYS; if (ret != -EWOULDBLOCK) break; } else { Index: sys/external/bsd/drm2/drm/drm_drv.c =================================================================== RCS file: /cvsroot/src/sys/external/bsd/drm2/drm/Attic/drm_drv.c,v retrieving revision 1.17.10.1 diff -p -u -r1.17.10.1 drm_drv.c --- sys/external/bsd/drm2/drm/drm_drv.c 8 Dec 2017 05:43:51 -0000 1.17.10.1 +++ sys/external/bsd/drm2/drm/drm_drv.c 23 Apr 2019 00:48:56 -0000 @@ -326,6 +326,8 @@ fail2: spin_lock(&dev->count_lock); (void)drm_lastclose(dev); fail1: drm_minor_release(dminor); fail0: KASSERT(error); + if (error == ERESTARTSYS) + error = ERESTART; return error; } @@ -445,6 +447,8 @@ drm_read(struct file *fp, off_t *off, st } /* Success! */ + if (error == ERESTARTSYS) + error = ERESTART; return error; } @@ -678,6 +682,8 @@ drm_ioctl(struct file *fp, unsigned long if (!ISSET(ioctl->flags, DRM_UNLOCKED)) mutex_unlock(&drm_global_mutex); + if (error == ERESTARTSYS) + error = ERESTART; return error; } @@ -690,11 +696,14 @@ drm_fop_mmap(struct file *fp, off_t *off int error; KASSERT(fp == file->filp); - error = (*dev->driver->mmap_object)(dev, *offp, len, prot, uobjp, + /* XXX errno Linux->NetBSD */ + error = -(*dev->driver->mmap_object)(dev, *offp, len, prot, uobjp, offp, file->filp); *maxprotp = prot; *advicep = UVM_ADV_RANDOM; - return -error; + if (error == ERESTARTSYS) + error = ERESTART; + return error; } static int Index: sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h =================================================================== RCS file: /cvsroot/src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h,v retrieving revision 1.14 diff -p -u -r1.14 drm_wait_netbsd.h --- sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h 13 May 2016 15:25:57 -0000 1.14 +++ sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h 23 Apr 2019 00:48:56 -0000 @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -114,10 +115,13 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, * Like the legacy DRM_WAIT_ON, DRM_SPIN_WAIT_ON returns * * . -EBUSY if timed out (yes, -EBUSY, not -ETIMEDOUT or -EWOULDBLOCK), - * . -EINTR/-ERESTART if interrupted by a signal, or + * . -EINTR/-ERESTARTSYS if interrupted by a signal, or * . 0 if the condition was true before or just after the timeout. * * Note that cv_timedwait* return -EWOULDBLOCK, not -EBUSY, on timeout. + * + * Note that ERESTARTSYS is actually ELAST+1 and only used in Linux + * code and must be converted for use in NetBSD code (user or kernel.) */ #define DRM_SPIN_WAIT_ON(RET, Q, INTERLOCK, TICKS, CONDITION) do \ @@ -148,6 +152,8 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, else \ _dswo_ticks = 0; \ if (RET) { \ + if ((RET) == -ERESTART) \ + (RET) = -ERESTARTSYS; \ if ((RET) == -EWOULDBLOCK) \ /* Waited only one tick. */ \ continue; \ @@ -165,26 +171,29 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, * * The untimed DRM_*WAIT*_UNTIL macros return * - * . -EINTR/-ERESTART if interrupted by a signal, or + * . -EINTR/-ERESTARTSYS if interrupted by a signal, or * . zero if the condition evaluated * * The timed DRM_*TIMED_WAIT*_UNTIL macros return * - * . -EINTR/-ERESTART if interrupted by a signal, + * . -EINTR/-ERESTARTSYS if interrupted by a signal, * . 0 if the condition was false after the timeout, * . 1 if the condition was true just after the timeout, or * . the number of ticks remaining if the condition was true before the * timeout. * - * Contrast DRM_SPIN_WAIT_ON which returns -EINTR/-ERESTART on signal, + * Contrast DRM_SPIN_WAIT_ON which returns -EINTR/-ERESTARTSYS on signal, * -EBUSY on timeout, and zero on success; and cv_*wait*, which return - * -EINTR/-ERESTART on signal, -EWOULDBLOCK on timeout, and zero on + * -EINTR/-ERESTARTSYS on signal, -EWOULDBLOCK on timeout, and zero on * success. * * XXX In retrospect, giving the timed and untimed macros a different * return convention from one another to match Linux may have been a * bad idea. All of this inconsistent timeout return convention logic * has been a consistent source of bugs. + * + * Note that ERESTARTSYS is actually ELAST+1 and only used in Linux + * code and must be converted for use in NetBSD code (user or kernel.) */ #define _DRM_WAIT_UNTIL(RET, WAIT, Q, INTERLOCK, CONDITION) do \ @@ -199,8 +208,11 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, } \ /* XXX errno NetBSD->Linux */ \ (RET) = -WAIT((Q), &(INTERLOCK)->mtx_lock); \ - if (RET) \ + if (RET) { \ + if ((RET) == -ERESTART) \ + (RET) = -ERESTARTSYS; \ break; \ + } \ } \ } while (0) @@ -240,6 +252,8 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, else \ _dtwu_ticks = 0; \ if (RET) { \ + if ((RET) == -ERESTART) \ + (RET) = -ERESTARTSYS; \ if ((RET) == -EWOULDBLOCK) \ (RET) = (CONDITION) ? 1 : 0; \ break; \ @@ -270,6 +284,8 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, while (!(CONDITION)) { \ /* XXX errno NetBSD->Linux */ \ (RET) = -WAIT((Q), &(INTERLOCK)->sl_lock); \ + if ((RET) == -ERESTART) \ + (RET) = -ERESTARTSYS; \ if (RET) \ break; \ } \ @@ -311,6 +327,8 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, else \ _dstwu_ticks = 0; \ if (RET) { \ + if ((RET) == -ERESTART) \ + (RET) = -ERESTARTSYS; \ if ((RET) == -EWOULDBLOCK) \ (RET) = (CONDITION) ? 1 : 0; \ break; \ Index: sys/external/bsd/drm2/linux/linux_ww_mutex.c =================================================================== RCS file: /cvsroot/src/sys/external/bsd/drm2/linux/linux_ww_mutex.c,v retrieving revision 1.2.10.2 diff -p -u -r1.2.10.2 linux_ww_mutex.c --- sys/external/bsd/drm2/linux/linux_ww_mutex.c 27 Sep 2018 14:38:56 -0000 1.2.10.2 +++ sys/external/bsd/drm2/linux/linux_ww_mutex.c 23 Apr 2019 00:48:56 -0000 @@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_ww_mut #include #include +#include #define WW_WANTLOCK(WW) \ LOCKDEBUG_WANTLOCK((WW)->wwm_debug, (WW), \ @@ -250,6 +251,8 @@ ww_mutex_state_wait_sig(struct ww_mutex do { /* XXX errno NetBSD->Linux */ ret = -cv_wait_sig(&mutex->wwm_cv, &mutex->wwm_lock); + if (ret == -ERESTART) + ret = -ERESTARTSYS; if (ret) break; } while (mutex->wwm_state == state); @@ -315,6 +318,8 @@ ww_mutex_lock_wait_sig(struct ww_mutex * do { /* XXX errno NetBSD->Linux */ ret = -cv_wait_sig(&mutex->wwm_cv, &mutex->wwm_lock); + if (ret == -ERESTART) + ret = -ERESTARTSYS; if (ret) goto out; } while (!(((mutex->wwm_state == WW_CTX) ||