Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2018 Advanced Micro Devices, Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  */
0023 #ifndef __AMDGPU_BO_LIST_H__
0024 #define __AMDGPU_BO_LIST_H__
0025 
0026 #include <drm/ttm/ttm_execbuf_util.h>
0027 #include <drm/amdgpu_drm.h>
0028 
0029 struct amdgpu_device;
0030 struct amdgpu_bo;
0031 struct amdgpu_bo_va;
0032 struct amdgpu_fpriv;
0033 
0034 struct amdgpu_bo_list_entry {
0035     struct ttm_validate_buffer  tv;
0036     struct amdgpu_bo_va     *bo_va;
0037     uint32_t            priority;
0038     struct page         **user_pages;
0039     bool                user_invalidated;
0040 };
0041 
0042 struct amdgpu_bo_list {
0043     struct rcu_head rhead;
0044     struct kref refcount;
0045     struct amdgpu_bo *gds_obj;
0046     struct amdgpu_bo *gws_obj;
0047     struct amdgpu_bo *oa_obj;
0048     unsigned first_userptr;
0049     unsigned num_entries;
0050 
0051     /* Protect access during command submission.
0052      */
0053     struct mutex bo_list_mutex;
0054 };
0055 
0056 int amdgpu_bo_list_get(struct amdgpu_fpriv *fpriv, int id,
0057                struct amdgpu_bo_list **result);
0058 void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list,
0059                  struct list_head *validated);
0060 void amdgpu_bo_list_put(struct amdgpu_bo_list *list);
0061 int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in *in,
0062                       struct drm_amdgpu_bo_list_entry **info_param);
0063 
0064 int amdgpu_bo_list_create(struct amdgpu_device *adev,
0065                  struct drm_file *filp,
0066                  struct drm_amdgpu_bo_list_entry *info,
0067                  size_t num_entries,
0068                  struct amdgpu_bo_list **list);
0069 
0070 static inline struct amdgpu_bo_list_entry *
0071 amdgpu_bo_list_array_entry(struct amdgpu_bo_list *list, unsigned index)
0072 {
0073     struct amdgpu_bo_list_entry *array = (void *)&list[1];
0074 
0075     return &array[index];
0076 }
0077 
0078 #define amdgpu_bo_list_for_each_entry(e, list) \
0079     for (e = amdgpu_bo_list_array_entry(list, 0); \
0080          e != amdgpu_bo_list_array_entry(list, (list)->num_entries); \
0081          ++e)
0082 
0083 #define amdgpu_bo_list_for_each_userptr_entry(e, list) \
0084     for (e = amdgpu_bo_list_array_entry(list, (list)->first_userptr); \
0085          e != amdgpu_bo_list_array_entry(list, (list)->num_entries); \
0086          ++e)
0087 
0088 #endif