mirror of
https://github.com/torvalds/linux.git
synced 2024-12-01 00:21:32 +00:00
drm/ttm: Have the TTM code return -ERESTARTSYS instead of -ERESTART.
Return -ERESTARTSYS instead of -ERESTART when interrupted by a signal. The -ERESTARTSYS is converted to an -EINTR by the kernel signal layer before returned to user-space. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
312ea8da04
commit
98ffc4158e
@ -125,7 +125,7 @@ int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo, bool interruptible)
|
|||||||
ret = wait_event_interruptible(bo->event_queue,
|
ret = wait_event_interruptible(bo->event_queue,
|
||||||
atomic_read(&bo->reserved) == 0);
|
atomic_read(&bo->reserved) == 0);
|
||||||
if (unlikely(ret != 0))
|
if (unlikely(ret != 0))
|
||||||
return -ERESTART;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
wait_event(bo->event_queue, atomic_read(&bo->reserved) == 0);
|
wait_event(bo->event_queue, atomic_read(&bo->reserved) == 0);
|
||||||
}
|
}
|
||||||
@ -571,7 +571,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
|
|||||||
spin_unlock(&bo->lock);
|
spin_unlock(&bo->lock);
|
||||||
|
|
||||||
if (unlikely(ret != 0)) {
|
if (unlikely(ret != 0)) {
|
||||||
if (ret != -ERESTART) {
|
if (ret != -ERESTARTSYS) {
|
||||||
printk(KERN_ERR TTM_PFX
|
printk(KERN_ERR TTM_PFX
|
||||||
"Failed to expire sync object before "
|
"Failed to expire sync object before "
|
||||||
"buffer eviction.\n");
|
"buffer eviction.\n");
|
||||||
@ -588,7 +588,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
|
|||||||
ret = ttm_bo_mem_space(bo, &placement, &evict_mem, interruptible,
|
ret = ttm_bo_mem_space(bo, &placement, &evict_mem, interruptible,
|
||||||
no_wait);
|
no_wait);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret != -ERESTART)
|
if (ret != -ERESTARTSYS)
|
||||||
printk(KERN_ERR TTM_PFX
|
printk(KERN_ERR TTM_PFX
|
||||||
"Failed to find memory space for "
|
"Failed to find memory space for "
|
||||||
"buffer 0x%p eviction.\n", bo);
|
"buffer 0x%p eviction.\n", bo);
|
||||||
@ -598,7 +598,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
|
|||||||
ret = ttm_bo_handle_move_mem(bo, &evict_mem, true, interruptible,
|
ret = ttm_bo_handle_move_mem(bo, &evict_mem, true, interruptible,
|
||||||
no_wait);
|
no_wait);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret != -ERESTART)
|
if (ret != -ERESTARTSYS)
|
||||||
printk(KERN_ERR TTM_PFX "Buffer eviction failed\n");
|
printk(KERN_ERR TTM_PFX "Buffer eviction failed\n");
|
||||||
spin_lock(&glob->lru_lock);
|
spin_lock(&glob->lru_lock);
|
||||||
if (evict_mem.mm_node) {
|
if (evict_mem.mm_node) {
|
||||||
@ -795,7 +795,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
|
|||||||
uint32_t cur_flags = 0;
|
uint32_t cur_flags = 0;
|
||||||
bool type_found = false;
|
bool type_found = false;
|
||||||
bool type_ok = false;
|
bool type_ok = false;
|
||||||
bool has_eagain = false;
|
bool has_erestartsys = false;
|
||||||
struct drm_mm_node *node = NULL;
|
struct drm_mm_node *node = NULL;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
@ -882,28 +882,21 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
|
|||||||
mem->mm_node->private = bo;
|
mem->mm_node->private = bo;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (ret == -ERESTART)
|
if (ret == -ERESTARTSYS)
|
||||||
has_eagain = true;
|
has_erestartsys = true;
|
||||||
}
|
}
|
||||||
ret = (has_eagain) ? -ERESTART : -ENOMEM;
|
ret = (has_erestartsys) ? -ERESTARTSYS : -ENOMEM;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(ttm_bo_mem_space);
|
EXPORT_SYMBOL(ttm_bo_mem_space);
|
||||||
|
|
||||||
int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait)
|
int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if ((atomic_read(&bo->cpu_writers) > 0) && no_wait)
|
if ((atomic_read(&bo->cpu_writers) > 0) && no_wait)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
ret = wait_event_interruptible(bo->event_queue,
|
return wait_event_interruptible(bo->event_queue,
|
||||||
atomic_read(&bo->cpu_writers) == 0);
|
atomic_read(&bo->cpu_writers) == 0);
|
||||||
|
|
||||||
if (ret == -ERESTARTSYS)
|
|
||||||
ret = -ERESTART;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
|
int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
|
||||||
@ -1673,7 +1666,7 @@ int ttm_bo_block_reservation(struct ttm_buffer_object *bo, bool interruptible,
|
|||||||
ret = wait_event_interruptible
|
ret = wait_event_interruptible
|
||||||
(bo->event_queue, atomic_read(&bo->reserved) == 0);
|
(bo->event_queue, atomic_read(&bo->reserved) == 0);
|
||||||
if (unlikely(ret != 0))
|
if (unlikely(ret != 0))
|
||||||
return -ERESTART;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
wait_event(bo->event_queue,
|
wait_event(bo->event_queue,
|
||||||
atomic_read(&bo->reserved) == 0);
|
atomic_read(&bo->reserved) == 0);
|
||||||
|
@ -114,7 +114,7 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
|||||||
ret = ttm_bo_wait(bo, false, true, false);
|
ret = ttm_bo_wait(bo, false, true, false);
|
||||||
spin_unlock(&bo->lock);
|
spin_unlock(&bo->lock);
|
||||||
if (unlikely(ret != 0)) {
|
if (unlikely(ret != 0)) {
|
||||||
retval = (ret != -ERESTART) ?
|
retval = (ret != -ERESTARTSYS) ?
|
||||||
VM_FAULT_SIGBUS : VM_FAULT_NOPAGE;
|
VM_FAULT_SIGBUS : VM_FAULT_NOPAGE;
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
@ -349,9 +349,6 @@ ssize_t ttm_bo_io(struct ttm_bo_device *bdev, struct file *filp,
|
|||||||
switch (ret) {
|
switch (ret) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case -ERESTART:
|
|
||||||
ret = -EINTR;
|
|
||||||
goto out_unref;
|
|
||||||
case -EBUSY:
|
case -EBUSY:
|
||||||
ret = -EAGAIN;
|
ret = -EAGAIN;
|
||||||
goto out_unref;
|
goto out_unref;
|
||||||
@ -421,8 +418,6 @@ ssize_t ttm_bo_fbdev_io(struct ttm_buffer_object *bo, const char __user *wbuf,
|
|||||||
switch (ret) {
|
switch (ret) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case -ERESTART:
|
|
||||||
return -EINTR;
|
|
||||||
case -EBUSY:
|
case -EBUSY:
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
default:
|
default:
|
||||||
|
@ -303,7 +303,7 @@ ttm_bo_reference(struct ttm_buffer_object *bo)
|
|||||||
* Note: It might be necessary to block validations before the
|
* Note: It might be necessary to block validations before the
|
||||||
* wait by reserving the buffer.
|
* wait by reserving the buffer.
|
||||||
* Returns -EBUSY if no_wait is true and the buffer is busy.
|
* Returns -EBUSY if no_wait is true and the buffer is busy.
|
||||||
* Returns -ERESTART if interrupted by a signal.
|
* Returns -ERESTARTSYS if interrupted by a signal.
|
||||||
*/
|
*/
|
||||||
extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,
|
extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,
|
||||||
bool interruptible, bool no_wait);
|
bool interruptible, bool no_wait);
|
||||||
@ -321,7 +321,7 @@ extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,
|
|||||||
* -EINVAL on invalid proposed placement.
|
* -EINVAL on invalid proposed placement.
|
||||||
* -ENOMEM on out-of-memory condition.
|
* -ENOMEM on out-of-memory condition.
|
||||||
* -EBUSY if no_wait is true and buffer busy.
|
* -EBUSY if no_wait is true and buffer busy.
|
||||||
* -ERESTART if interrupted by a signal.
|
* -ERESTARTSYS if interrupted by a signal.
|
||||||
*/
|
*/
|
||||||
extern int ttm_buffer_object_validate(struct ttm_buffer_object *bo,
|
extern int ttm_buffer_object_validate(struct ttm_buffer_object *bo,
|
||||||
struct ttm_placement *placement,
|
struct ttm_placement *placement,
|
||||||
@ -347,7 +347,7 @@ extern void ttm_bo_unref(struct ttm_buffer_object **bo);
|
|||||||
* waiting for buffer idle. This lock is recursive.
|
* waiting for buffer idle. This lock is recursive.
|
||||||
* Returns
|
* Returns
|
||||||
* -EBUSY if the buffer is busy and no_wait is true.
|
* -EBUSY if the buffer is busy and no_wait is true.
|
||||||
* -ERESTART if interrupted by a signal.
|
* -ERESTARTSYS if interrupted by a signal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
@ -390,7 +390,7 @@ extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo);
|
|||||||
* Returns
|
* Returns
|
||||||
* -ENOMEM: Out of memory.
|
* -ENOMEM: Out of memory.
|
||||||
* -EINVAL: Invalid placement flags.
|
* -EINVAL: Invalid placement flags.
|
||||||
* -ERESTART: Interrupted by signal while sleeping waiting for resources.
|
* -ERESTARTSYS: Interrupted by signal while sleeping waiting for resources.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int ttm_buffer_object_init(struct ttm_bo_device *bdev,
|
extern int ttm_buffer_object_init(struct ttm_bo_device *bdev,
|
||||||
@ -430,7 +430,7 @@ extern int ttm_buffer_object_init(struct ttm_bo_device *bdev,
|
|||||||
* Returns
|
* Returns
|
||||||
* -ENOMEM: Out of memory.
|
* -ENOMEM: Out of memory.
|
||||||
* -EINVAL: Invalid placement flags.
|
* -EINVAL: Invalid placement flags.
|
||||||
* -ERESTART: Interrupted by signal while waiting for resources.
|
* -ERESTARTSYS: Interrupted by signal while waiting for resources.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int ttm_buffer_object_create(struct ttm_bo_device *bdev,
|
extern int ttm_buffer_object_create(struct ttm_bo_device *bdev,
|
||||||
@ -521,7 +521,7 @@ extern int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type);
|
|||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* -EINVAL: Invalid or uninitialized memory type.
|
* -EINVAL: Invalid or uninitialized memory type.
|
||||||
* -ERESTART: The call was interrupted by a signal while waiting to
|
* -ERESTARTSYS: The call was interrupted by a signal while waiting to
|
||||||
* evict a buffer.
|
* evict a buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -624,7 +624,7 @@ extern int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
|
|||||||
* be called from the fops::read and fops::write method.
|
* be called from the fops::read and fops::write method.
|
||||||
* Returns:
|
* Returns:
|
||||||
* See man (2) write, man(2) read. In particular,
|
* See man (2) write, man(2) read. In particular,
|
||||||
* the function may return -EINTR if
|
* the function may return -ERESTARTSYS if
|
||||||
* interrupted by a signal.
|
* interrupted by a signal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ extern bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev,
|
|||||||
* -EBUSY: No space available (only if no_wait == 1).
|
* -EBUSY: No space available (only if no_wait == 1).
|
||||||
* -ENOMEM: Could not allocate memory for the buffer object, either due to
|
* -ENOMEM: Could not allocate memory for the buffer object, either due to
|
||||||
* fragmentation or concurrent allocators.
|
* fragmentation or concurrent allocators.
|
||||||
* -ERESTART: An interruptible sleep was interrupted by a signal.
|
* -ERESTARTSYS: An interruptible sleep was interrupted by a signal.
|
||||||
*/
|
*/
|
||||||
extern int ttm_bo_mem_space(struct ttm_buffer_object *bo,
|
extern int ttm_bo_mem_space(struct ttm_buffer_object *bo,
|
||||||
struct ttm_placement *placement,
|
struct ttm_placement *placement,
|
||||||
@ -653,7 +653,7 @@ extern int ttm_bo_mem_space(struct ttm_buffer_object *bo,
|
|||||||
* Wait until a buffer object is no longer sync'ed for CPU access.
|
* Wait until a buffer object is no longer sync'ed for CPU access.
|
||||||
* Returns:
|
* Returns:
|
||||||
* -EBUSY: Buffer object was sync'ed for CPU access. (only if no_wait == 1).
|
* -EBUSY: Buffer object was sync'ed for CPU access. (only if no_wait == 1).
|
||||||
* -ERESTART: An interruptible sleep was interrupted by a signal.
|
* -ERESTARTSYS: An interruptible sleep was interrupted by a signal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait);
|
extern int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait);
|
||||||
@ -757,7 +757,7 @@ extern void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo);
|
|||||||
* -EAGAIN: The reservation may cause a deadlock.
|
* -EAGAIN: The reservation may cause a deadlock.
|
||||||
* Release all buffer reservations, wait for @bo to become unreserved and
|
* Release all buffer reservations, wait for @bo to become unreserved and
|
||||||
* try again. (only if use_sequence == 1).
|
* try again. (only if use_sequence == 1).
|
||||||
* -ERESTART: A wait for the buffer to become unreserved was interrupted by
|
* -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
|
||||||
* a signal. Release all buffer reservations and return to user-space.
|
* a signal. Release all buffer reservations and return to user-space.
|
||||||
*/
|
*/
|
||||||
extern int ttm_bo_reserve(struct ttm_buffer_object *bo,
|
extern int ttm_bo_reserve(struct ttm_buffer_object *bo,
|
||||||
@ -798,7 +798,7 @@ extern int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo,
|
|||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* -EBUSY: If no_wait == 1 and the buffer is already reserved.
|
* -EBUSY: If no_wait == 1 and the buffer is already reserved.
|
||||||
* -ERESTART: If interruptible == 1 and the process received a signal
|
* -ERESTARTSYS: If interruptible == 1 and the process received a signal
|
||||||
* while sleeping.
|
* while sleeping.
|
||||||
*/
|
*/
|
||||||
extern int ttm_bo_block_reservation(struct ttm_buffer_object *bo,
|
extern int ttm_bo_block_reservation(struct ttm_buffer_object *bo,
|
||||||
|
Loading…
Reference in New Issue
Block a user