Path: blob/master/include/drm/ttm/ttm_execbuf_util.h
10817 views
/**************************************************************************1*2* Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL20* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,21* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR22* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE23* USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/26/*27* Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>28*/2930#ifndef _TTM_EXECBUF_UTIL_H_31#define _TTM_EXECBUF_UTIL_H_3233#include "ttm/ttm_bo_api.h"34#include <linux/list.h>3536/**37* struct ttm_validate_buffer38*39* @head: list head for thread-private list.40* @bo: refcounted buffer object pointer.41* @new_sync_obj_arg: New sync_obj_arg for @bo, to be used once42* adding a new sync object.43* @reserved: Indicates whether @bo has been reserved for validation.44* @removed: Indicates whether @bo has been removed from lru lists.45* @put_count: Number of outstanding references on bo::list_kref.46* @old_sync_obj: Pointer to a sync object about to be unreferenced47*/4849struct ttm_validate_buffer {50struct list_head head;51struct ttm_buffer_object *bo;52void *new_sync_obj_arg;53bool reserved;54bool removed;55int put_count;56void *old_sync_obj;57};5859/**60* function ttm_eu_backoff_reservation61*62* @list: thread private list of ttm_validate_buffer structs.63*64* Undoes all buffer validation reservations for bos pointed to by65* the list entries.66*/6768extern void ttm_eu_backoff_reservation(struct list_head *list);6970/**71* function ttm_eu_reserve_buffers72*73* @list: thread private list of ttm_validate_buffer structs.74*75* Tries to reserve bos pointed to by the list entries for validation.76* If the function returns 0, all buffers are marked as "unfenced",77* taken off the lru lists and are not synced for write CPU usage.78*79* If the function detects a deadlock due to multiple threads trying to80* reserve the same buffers in reverse order, all threads except one will81* back off and retry. This function may sleep while waiting for82* CPU write reservations to be cleared, and for other threads to83* unreserve their buffers.84*85* This function may return -ERESTART or -EAGAIN if the calling process86* receives a signal while waiting. In that case, no buffers on the list87* will be reserved upon return.88*89* Buffers reserved by this function should be unreserved by90* a call to either ttm_eu_backoff_reservation() or91* ttm_eu_fence_buffer_objects() when command submission is complete or92* has failed.93*/9495extern int ttm_eu_reserve_buffers(struct list_head *list);9697/**98* function ttm_eu_fence_buffer_objects.99*100* @list: thread private list of ttm_validate_buffer structs.101* @sync_obj: The new sync object for the buffers.102*103* This function should be called when command submission is complete, and104* it will add a new sync object to bos pointed to by entries on @list.105* It also unreserves all buffers, putting them on lru lists.106*107*/108109extern void ttm_eu_fence_buffer_objects(struct list_head *list, void *sync_obj);110111#endif112113114