<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Why don't we just fix up the current GDS code so it works the same as vram and then we can add a new CS or context flag to ignore the current static allocation for gfx. We can ignore data persistence if it's too much
trouble. Assume you always have to init the memory before you use it. That's already the case.<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Alex<br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Marek Olák <maraeo@gmail.com><br>
<b>Sent:</b> Thursday, September 13, 2018 2:20:28 PM<br>
<b>To:</b> Koenig, Christian<br>
<b>Cc:</b> amd-gfx mailing list<br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: reserve GDS resources statically</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">GDS is a temporary memory. Its purpose depends on the job, but most of<br>
the time, the idea is:<br>
- beginning of IB<br>
- initialize GDS variables<br>
- dispatch compute that works with GDS variables<br>
- when done, copy GDS variables to memory<br>
- repeat ...<br>
- end of IB<br>
<br>
GDS is like a pool of global shader GPRs.<br>
<br>
GDS is too small for persistent data.<br>
<br>
Marek<br>
<br>
On Thu, Sep 13, 2018 at 1:26 PM, Christian König<br>
<christian.koenig@amd.com> wrote:<br>
> Are you sure of that? I mean it is rather pointless to have a Global Data<br>
> Share when it can't be used to share anything?<br>
><br>
> On the other hand I'm not opposed to get rid of all that stuff if we really<br>
> don't need it.<br>
><br>
> Christian.<br>
><br>
> Am 13.09.2018 um 17:27 schrieb Marek Olák:<br>
>><br>
>> That's OK. We don't need IBs to get the same VMID.<br>
>><br>
>> Marek<br>
>><br>
>> On Thu, Sep 13, 2018 at 4:40 AM, Christian König<br>
>> <ckoenig.leichtzumerken@gmail.com> wrote:<br>
>>><br>
>>> As discussed internally that doesn't work because threads don't necessary<br>
>>> get the same VMID assigned.<br>
>>><br>
>>> Christian.<br>
>>><br>
>>> Am 12.09.2018 um 22:33 schrieb Marek Olák:<br>
>>>><br>
>>>> From: Marek Olák <marek.olsak@amd.com><br>
>>>><br>
>>>> I've chosen to do it like this because it's easy and allows an arbitrary<br>
>>>> number of processes.<br>
>>>><br>
>>>> Signed-off-by: Marek Olák <marek.olsak@amd.com><br>
>>>> ---<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 10 --<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h | 3 -<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 20 ----<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h | 19 +--<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 24 +---<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 6 -<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h | 7 --<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 3 -<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 14 +--<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 21 ----<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 6 -<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 5 -<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 61 ----------<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 8 --<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 34 +-----<br>
>>>> drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 125<br>
>>>> +++++---------------<br>
>>>> drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 123 +++++--------------<br>
>>>> drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 124 ++++++-------------<br>
>>>> include/uapi/drm/amdgpu_drm.h | 15 +--<br>
>>>> 19 files changed, 109 insertions(+), 519 deletions(-)<br>
>>>><br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c<br>
>>>> index b80243d3972e..7264a4930b88 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c<br>
>>>> @@ -71,23 +71,20 @@ int amdgpu_bo_list_create(struct amdgpu_device<br>
>>>> *adev,<br>
>>>> struct drm_file *filp,<br>
>>>> / sizeof(struct amdgpu_bo_list_entry))<br>
>>>> return -EINVAL;<br>
>>>> size = sizeof(struct amdgpu_bo_list);<br>
>>>> size += num_entries * sizeof(struct amdgpu_bo_list_entry);<br>
>>>> list = kvmalloc(size, GFP_KERNEL);<br>
>>>> if (!list)<br>
>>>> return -ENOMEM;<br>
>>>> kref_init(&list->refcount);<br>
>>>> - list->gds_obj = adev->gds.gds_gfx_bo;<br>
>>>> - list->gws_obj = adev->gds.gws_gfx_bo;<br>
>>>> - list->oa_obj = adev->gds.oa_gfx_bo;<br>
>>>> array = amdgpu_bo_list_array_entry(list, 0);<br>
>>>> memset(array, 0, num_entries * sizeof(struct<br>
>>>> amdgpu_bo_list_entry));<br>
>>>> for (i = 0; i < num_entries; ++i) {<br>
>>>> struct amdgpu_bo_list_entry *entry;<br>
>>>> struct drm_gem_object *gobj;<br>
>>>> struct amdgpu_bo *bo;<br>
>>>> struct mm_struct *usermm;<br>
>>>> @@ -111,27 +108,20 @@ int amdgpu_bo_list_create(struct amdgpu_device<br>
>>>> *adev, struct drm_file *filp,<br>
>>>> } else {<br>
>>>> entry = &array[last_entry++];<br>
>>>> }<br>
>>>> entry->robj = bo;<br>
>>>> entry->priority = min(info[i].bo_priority,<br>
>>>> AMDGPU_BO_LIST_MAX_PRIORITY);<br>
>>>> entry->tv.bo = &entry->robj->tbo;<br>
>>>> entry->tv.shared = !entry->robj->prime_shared_count;<br>
>>>> - if (entry->robj->preferred_domains ==<br>
>>>> AMDGPU_GEM_DOMAIN_GDS)<br>
>>>> - list->gds_obj = entry->robj;<br>
>>>> - if (entry->robj->preferred_domains ==<br>
>>>> AMDGPU_GEM_DOMAIN_GWS)<br>
>>>> - list->gws_obj = entry->robj;<br>
>>>> - if (entry->robj->preferred_domains ==<br>
>>>> AMDGPU_GEM_DOMAIN_OA)<br>
>>>> - list->oa_obj = entry->robj;<br>
>>>> -<br>
>>>> total_size += amdgpu_bo_size(entry->robj);<br>
>>>> trace_amdgpu_bo_list_set(list, entry->robj);<br>
>>>> }<br>
>>>> list->first_userptr = first_userptr;<br>
>>>> list->num_entries = num_entries;<br>
>>>> trace_amdgpu_cs_bo_status(list->num_entries, total_size);<br>
>>>> *result = list;<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h<br>
>>>> index 61b089768e1c..30f12a60aa28 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h<br>
>>>> @@ -36,23 +36,20 @@ struct amdgpu_bo_list_entry {<br>
>>>> struct ttm_validate_buffer tv;<br>
>>>> struct amdgpu_bo_va *bo_va;<br>
>>>> uint32_t priority;<br>
>>>> struct page **user_pages;<br>
>>>> int user_invalidated;<br>
>>>> };<br>
>>>> struct amdgpu_bo_list {<br>
>>>> struct rcu_head rhead;<br>
>>>> struct kref refcount;<br>
>>>> - struct amdgpu_bo *gds_obj;<br>
>>>> - struct amdgpu_bo *gws_obj;<br>
>>>> - struct amdgpu_bo *oa_obj;<br>
>>>> unsigned first_userptr;<br>
>>>> unsigned num_entries;<br>
>>>> };<br>
>>>> int amdgpu_bo_list_get(struct amdgpu_fpriv *fpriv, int id,<br>
>>>> struct amdgpu_bo_list **result);<br>
>>>> void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list,<br>
>>>> struct list_head *validated);<br>
>>>> void amdgpu_bo_list_put(struct amdgpu_bo_list *list);<br>
>>>> int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in<br>
>>>> *in,<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
>>>> index 1081fd00b059..88b58facf29e 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
>>>> @@ -565,23 +565,20 @@ static int amdgpu_cs_list_validate(struct<br>
>>>> amdgpu_cs_parser *p,<br>
>>>> return 0;<br>
>>>> }<br>
>>>> static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,<br>
>>>> union drm_amdgpu_cs *cs)<br>
>>>> {<br>
>>>> struct amdgpu_fpriv *fpriv = p->filp->driver_priv;<br>
>>>> struct amdgpu_vm *vm = &fpriv->vm;<br>
>>>> struct amdgpu_bo_list_entry *e;<br>
>>>> struct list_head duplicates;<br>
>>>> - struct amdgpu_bo *gds;<br>
>>>> - struct amdgpu_bo *gws;<br>
>>>> - struct amdgpu_bo *oa;<br>
>>>> unsigned tries = 10;<br>
>>>> int r;<br>
>>>> INIT_LIST_HEAD(&p->validated);<br>
>>>> /* p->bo_list could already be assigned if<br>
>>>> AMDGPU_CHUNK_ID_BO_HANDLES is present */<br>
>>>> if (cs->in.bo_list_handle) {<br>
>>>> if (p->bo_list)<br>
>>>> return -EINVAL;<br>
>>>> @@ -705,40 +702,23 @@ static int amdgpu_cs_parser_bos(struct<br>
>>>> amdgpu_cs_parser *p,<br>
>>>> r = amdgpu_cs_list_validate(p, &p->validated);<br>
>>>> if (r) {<br>
>>>> DRM_ERROR("amdgpu_cs_list_validate(validated)<br>
>>>> failed.\n");<br>
>>>> goto error_validate;<br>
>>>> }<br>
>>>> amdgpu_cs_report_moved_bytes(p->adev, p->bytes_moved,<br>
>>>> p->bytes_moved_vis);<br>
>>>> - gds = p->bo_list->gds_obj;<br>
>>>> - gws = p->bo_list->gws_obj;<br>
>>>> - oa = p->bo_list->oa_obj;<br>
>>>> -<br>
>>>> amdgpu_bo_list_for_each_entry(e, p->bo_list)<br>
>>>> e->bo_va = amdgpu_vm_bo_find(vm, e->robj);<br>
>>>> - if (gds) {<br>
>>>> - p->job->gds_base = amdgpu_bo_gpu_offset(gds);<br>
>>>> - p->job->gds_size = amdgpu_bo_size(gds);<br>
>>>> - }<br>
>>>> - if (gws) {<br>
>>>> - p->job->gws_base = amdgpu_bo_gpu_offset(gws);<br>
>>>> - p->job->gws_size = amdgpu_bo_size(gws);<br>
>>>> - }<br>
>>>> - if (oa) {<br>
>>>> - p->job->oa_base = amdgpu_bo_gpu_offset(oa);<br>
>>>> - p->job->oa_size = amdgpu_bo_size(oa);<br>
>>>> - }<br>
>>>> -<br>
>>>> if (!r && p->uf_entry.robj) {<br>
>>>> struct amdgpu_bo *uf = p->uf_entry.robj;<br>
>>>> r = amdgpu_ttm_alloc_gart(&uf->tbo);<br>
>>>> p->job->uf_addr += amdgpu_bo_gpu_offset(uf);<br>
>>>> }<br>
>>>> error_validate:<br>
>>>> if (r)<br>
>>>> ttm_eu_backoff_reservation(&p->ticket, &p->validated);<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h<br>
>>>> index e73728d90388..69ba25c2e921 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gds.h<br>
>>>> @@ -17,48 +17,33 @@<br>
>>>> * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM,<br>
>>>> DAMAGES<br>
>>>> OR<br>
>>>> * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR<br>
>>>> OTHERWISE,<br>
>>>> * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE<br>
>>>> OR<br>
>>>> * OTHER DEALINGS IN THE SOFTWARE.<br>
>>>> *<br>
>>>> */<br>
>>>> #ifndef __AMDGPU_GDS_H__<br>
>>>> #define __AMDGPU_GDS_H__<br>
>>>> -/* Because TTM request that alloacted buffer should be PAGE_SIZE<br>
>>>> aligned,<br>
>>>> - * we should report GDS/GWS/OA size as PAGE_SIZE aligned<br>
>>>> - * */<br>
>>>> -#define AMDGPU_GDS_SHIFT 2<br>
>>>> -#define AMDGPU_GWS_SHIFT PAGE_SHIFT<br>
>>>> -#define AMDGPU_OA_SHIFT PAGE_SHIFT<br>
>>>> -<br>
>>>> struct amdgpu_ring;<br>
>>>> struct amdgpu_bo;<br>
>>>> struct amdgpu_gds_asic_info {<br>
>>>> uint32_t total_size;<br>
>>>> - uint32_t gfx_partition_size;<br>
>>>> - uint32_t cs_partition_size;<br>
>>>> + uint32_t gfx_size_per_vmid;<br>
>>>> + uint32_t kfd_size_per_vmid;<br>
>>>> };<br>
>>>> struct amdgpu_gds {<br>
>>>> struct amdgpu_gds_asic_info mem;<br>
>>>> struct amdgpu_gds_asic_info gws;<br>
>>>> struct amdgpu_gds_asic_info oa;<br>
>>>> - /* At present, GDS, GWS and OA resources for gfx (graphics)<br>
>>>> - * is always pre-allocated and available for graphics operation.<br>
>>>> - * Such resource is shared between all gfx clients.<br>
>>>> - * TODO: move this operation to user space<br>
>>>> - * */<br>
>>>> - struct amdgpu_bo* gds_gfx_bo;<br>
>>>> - struct amdgpu_bo* gws_gfx_bo;<br>
>>>> - struct amdgpu_bo* oa_gfx_bo;<br>
>>>> };<br>
>>>> struct amdgpu_gds_reg_offset {<br>
>>>> uint32_t mem_base;<br>
>>>> uint32_t mem_size;<br>
>>>> uint32_t gws;<br>
>>>> uint32_t oa;<br>
>>>> };<br>
>>>> #endif /* __AMDGPU_GDS_H__ */<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
>>>> index d30a0838851b..c87ad4b4d0b6 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
>>>> @@ -223,43 +223,25 @@ int amdgpu_gem_create_ioctl(struct drm_device<br>
>>>> *dev,<br>
>>>> void *data,<br>
>>>> if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |<br>
>>>> AMDGPU_GEM_CREATE_NO_CPU_ACCESS |<br>
>>>> AMDGPU_GEM_CREATE_CPU_GTT_USWC |<br>
>>>> AMDGPU_GEM_CREATE_VRAM_CLEARED |<br>
>>>> AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |<br>
>>>> AMDGPU_GEM_CREATE_EXPLICIT_SYNC))<br>
>>>> return -EINVAL;<br>
>>>> /* reject invalid gem domains */<br>
>>>> - if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)<br>
>>>> + if (args->in.domains & ~(AMDGPU_GEM_DOMAIN_CPU |<br>
>>>> + AMDGPU_GEM_DOMAIN_GTT |<br>
>>>> + AMDGPU_GEM_DOMAIN_VRAM))<br>
>>>> return -EINVAL;<br>
>>>> - /* create a gem object to contain this object in */<br>
>>>> - if (args->in.domains & (AMDGPU_GEM_DOMAIN_GDS |<br>
>>>> - AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA)) {<br>
>>>> - if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {<br>
>>>> - /* if gds bo is created from user space, it must<br>
>>>> be<br>
>>>> - * passed to bo list<br>
>>>> - */<br>
>>>> - DRM_ERROR("GDS bo cannot be per-vm-bo\n");<br>
>>>> - return -EINVAL;<br>
>>>> - }<br>
>>>> - flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;<br>
>>>> - if (args->in.domains == AMDGPU_GEM_DOMAIN_GDS)<br>
>>>> - size = size << AMDGPU_GDS_SHIFT;<br>
>>>> - else if (args->in.domains == AMDGPU_GEM_DOMAIN_GWS)<br>
>>>> - size = size << AMDGPU_GWS_SHIFT;<br>
>>>> - else if (args->in.domains == AMDGPU_GEM_DOMAIN_OA)<br>
>>>> - size = size << AMDGPU_OA_SHIFT;<br>
>>>> - else<br>
>>>> - return -EINVAL;<br>
>>>> - }<br>
>>>> size = roundup(size, PAGE_SIZE);<br>
>>>> if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {<br>
>>>> r = amdgpu_bo_reserve(vm->root.base.bo, false);<br>
>>>> if (r)<br>
>>>> return r;<br>
>>>> resv = vm->root.base.bo->tbo.resv;<br>
>>>> }<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c<br>
>>>> index 3a072a7a39f0..c2e6a1a11d7f 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c<br>
>>>> @@ -516,26 +516,20 @@ void amdgpu_vmid_free_reserved(struct<br>
>>>> amdgpu_device<br>
>>>> *adev,<br>
>>>> * Reset saved GDW, GWS and OA to force switch on next flush.<br>
>>>> */<br>
>>>> void amdgpu_vmid_reset(struct amdgpu_device *adev, unsigned vmhub,<br>
>>>> unsigned vmid)<br>
>>>> {<br>
>>>> struct amdgpu_vmid_mgr *id_mgr =<br>
>>>> &adev->vm_manager.id_mgr[vmhub];<br>
>>>> struct amdgpu_vmid *id = &id_mgr->ids[vmid];<br>
>>>> mutex_lock(&id_mgr->lock);<br>
>>>> id->owner = 0;<br>
>>>> - id->gds_base = 0;<br>
>>>> - id->gds_size = 0;<br>
>>>> - id->gws_base = 0;<br>
>>>> - id->gws_size = 0;<br>
>>>> - id->oa_base = 0;<br>
>>>> - id->oa_size = 0;<br>
>>>> mutex_unlock(&id_mgr->lock);<br>
>>>> }<br>
>>>> /**<br>
>>>> * amdgpu_vmid_reset_all - reset VMID to zero<br>
>>>> *<br>
>>>> * @adev: amdgpu device structure<br>
>>>> *<br>
>>>> * Reset VMID to force flush on next use<br>
>>>> */<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h<br>
>>>> index 7625419f0fc2..06078e665532 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h<br>
>>>> @@ -44,27 +44,20 @@ struct amdgpu_vmid {<br>
>>>> struct amdgpu_sync active;<br>
>>>> struct dma_fence *last_flush;<br>
>>>> uint64_t owner;<br>
>>>> uint64_t pd_gpu_addr;<br>
>>>> /* last flushed PD/PT update */<br>
>>>> struct dma_fence *flushed_updates;<br>
>>>> uint32_t current_gpu_reset_count;<br>
>>>> - uint32_t gds_base;<br>
>>>> - uint32_t gds_size;<br>
>>>> - uint32_t gws_base;<br>
>>>> - uint32_t gws_size;<br>
>>>> - uint32_t oa_base;<br>
>>>> - uint32_t oa_size;<br>
>>>> -<br>
>>>> unsigned pasid;<br>
>>>> struct dma_fence *pasid_mapping;<br>
>>>> };<br>
>>>> struct amdgpu_vmid_mgr {<br>
>>>> struct mutex lock;<br>
>>>> unsigned num_ids;<br>
>>>> struct list_head ids_lru;<br>
>>>> struct amdgpu_vmid ids[AMDGPU_NUM_VMID];<br>
>>>> atomic_t reserved_vmid_num;<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h<br>
>>>> index 57cfe78a262b..3db553f6ad01 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h<br>
>>>> @@ -42,23 +42,20 @@ struct amdgpu_job {<br>
>>>> struct amdgpu_sync sched_sync;<br>
>>>> struct amdgpu_ib *ibs;<br>
>>>> struct dma_fence *fence; /* the hw fence */<br>
>>>> uint32_t preamble_status;<br>
>>>> uint32_t num_ibs;<br>
>>>> void *owner;<br>
>>>> bool vm_needs_flush;<br>
>>>> uint64_t vm_pd_addr;<br>
>>>> unsigned vmid;<br>
>>>> unsigned pasid;<br>
>>>> - uint32_t gds_base, gds_size;<br>
>>>> - uint32_t gws_base, gws_size;<br>
>>>> - uint32_t oa_base, oa_size;<br>
>>>> uint32_t vram_lost_counter;<br>
>>>> /* user fence handling */<br>
>>>> uint64_t uf_addr;<br>
>>>> uint64_t uf_sequence;<br>
>>>> };<br>
>>>> int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,<br>
>>>> struct amdgpu_job **job, struct amdgpu_vm *vm);<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
>>>> index 29ac3873eeb0..209954290954 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
>>>> @@ -517,27 +517,27 @@ static int amdgpu_info_ioctl(struct drm_device<br>
>>>> *dev,<br>
>>>> void *data, struct drm_file<br>
>>>> case AMDGPU_INFO_VIS_VRAM_USAGE:<br>
>>>> ui64 =<br>
>>>> amdgpu_vram_mgr_vis_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);<br>
>>>> return copy_to_user(out, &ui64, min(size, 8u)) ?<br>
>>>> -EFAULT :<br>
>>>> 0;<br>
>>>> case AMDGPU_INFO_GTT_USAGE:<br>
>>>> ui64 =<br>
>>>> amdgpu_gtt_mgr_usage(&adev->mman.bdev.man[TTM_PL_TT]);<br>
>>>> return copy_to_user(out, &ui64, min(size, 8u)) ?<br>
>>>> -EFAULT :<br>
>>>> 0;<br>
>>>> case AMDGPU_INFO_GDS_CONFIG: {<br>
>>>> struct drm_amdgpu_info_gds gds_info;<br>
>>>> memset(&gds_info, 0, sizeof(gds_info));<br>
>>>> - gds_info.gds_gfx_partition_size =<br>
>>>> adev->gds.mem.gfx_partition_size >> AMDGPU_GDS_SHIFT;<br>
>>>> - gds_info.compute_partition_size =<br>
>>>> adev->gds.mem.cs_partition_size >> AMDGPU_GDS_SHIFT;<br>
>>>> - gds_info.gds_total_size = adev->gds.mem.total_size >><br>
>>>> AMDGPU_GDS_SHIFT;<br>
>>>> - gds_info.gws_per_gfx_partition =<br>
>>>> adev->gds.gws.gfx_partition_size >> AMDGPU_GWS_SHIFT;<br>
>>>> - gds_info.gws_per_compute_partition =<br>
>>>> adev->gds.gws.cs_partition_size >> AMDGPU_GWS_SHIFT;<br>
>>>> - gds_info.oa_per_gfx_partition =<br>
>>>> adev->gds.oa.gfx_partition_size >> AMDGPU_OA_SHIFT;<br>
>>>> - gds_info.oa_per_compute_partition =<br>
>>>> adev->gds.oa.cs_partition_size >> AMDGPU_OA_SHIFT;<br>
>>>> + gds_info.gds_gfx_partition_size =<br>
>>>> adev->gds.mem.gfx_size_per_vmid;<br>
>>>> + gds_info.compute_partition_size =<br>
>>>> adev->gds.mem.kfd_size_per_vmid;<br>
>>>> + gds_info.gds_total_size = adev->gds.mem.total_size;<br>
>>>> + gds_info.gws_per_gfx_partition =<br>
>>>> adev->gds.gws.gfx_size_per_vmid;<br>
>>>> + gds_info.gws_per_compute_partition =<br>
>>>> adev->gds.gws.kfd_size_per_vmid;<br>
>>>> + gds_info.oa_per_gfx_partition =<br>
>>>> adev->gds.oa.gfx_size_per_vmid;<br>
>>>> + gds_info.oa_per_compute_partition =<br>
>>>> adev->gds.oa.kfd_size_per_vmid;<br>
>>>> return copy_to_user(out, &gds_info,<br>
>>>> min((size_t)size,<br>
>>>> sizeof(gds_info))) ?<br>
>>>> -EFAULT : 0;<br>
>>>> }<br>
>>>> case AMDGPU_INFO_VRAM_GTT: {<br>
>>>> struct drm_amdgpu_info_vram_gtt vram_gtt;<br>
>>>> vram_gtt.vram_size = adev->gmc.real_vram_size -<br>
>>>> atomic64_read(&adev->vram_pin_size);<br>
>>>> vram_gtt.vram_cpu_accessible_size =<br>
>>>> adev->gmc.visible_vram_size -<br>
>>>> atomic64_read(&adev->visible_pin_size);<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c<br>
>>>> index de990bdcdd6c..76770a8c29a5 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c<br>
>>>> @@ -178,41 +178,20 @@ void amdgpu_bo_placement_from_domain(struct<br>
>>>> amdgpu_bo *abo, u32 domain)<br>
>>>> places[c].lpfn = 0;<br>
>>>> places[c].flags = TTM_PL_FLAG_SYSTEM;<br>
>>>> if (flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC)<br>
>>>> places[c].flags |= TTM_PL_FLAG_WC |<br>
>>>> TTM_PL_FLAG_UNCACHED;<br>
>>>> else<br>
>>>> places[c].flags |= TTM_PL_FLAG_CACHED;<br>
>>>> c++;<br>
>>>> }<br>
>>>> - if (domain & AMDGPU_GEM_DOMAIN_GDS) {<br>
>>>> - places[c].fpfn = 0;<br>
>>>> - places[c].lpfn = 0;<br>
>>>> - places[c].flags = TTM_PL_FLAG_UNCACHED |<br>
>>>> AMDGPU_PL_FLAG_GDS;<br>
>>>> - c++;<br>
>>>> - }<br>
>>>> -<br>
>>>> - if (domain & AMDGPU_GEM_DOMAIN_GWS) {<br>
>>>> - places[c].fpfn = 0;<br>
>>>> - places[c].lpfn = 0;<br>
>>>> - places[c].flags = TTM_PL_FLAG_UNCACHED |<br>
>>>> AMDGPU_PL_FLAG_GWS;<br>
>>>> - c++;<br>
>>>> - }<br>
>>>> -<br>
>>>> - if (domain & AMDGPU_GEM_DOMAIN_OA) {<br>
>>>> - places[c].fpfn = 0;<br>
>>>> - places[c].lpfn = 0;<br>
>>>> - places[c].flags = TTM_PL_FLAG_UNCACHED |<br>
>>>> AMDGPU_PL_FLAG_OA;<br>
>>>> - c++;<br>
>>>> - }<br>
>>>> -<br>
>>>> if (!c) {<br>
>>>> places[c].fpfn = 0;<br>
>>>> places[c].lpfn = 0;<br>
>>>> places[c].flags = TTM_PL_MASK_CACHING |<br>
>>>> TTM_PL_FLAG_SYSTEM;<br>
>>>> c++;<br>
>>>> }<br>
>>>> BUG_ON(c >= AMDGPU_BO_MAX_PLACEMENTS);<br>
>>>> placement->num_placement = c;<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h<br>
>>>> index 907fdf46d895..e089964cbcb7 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h<br>
>>>> @@ -120,26 +120,20 @@ static inline struct amdgpu_bo<br>
>>>> *ttm_to_amdgpu_bo(struct ttm_buffer_object *tbo)<br>
>>>> */<br>
>>>> static inline unsigned amdgpu_mem_type_to_domain(u32 mem_type)<br>
>>>> {<br>
>>>> switch (mem_type) {<br>
>>>> case TTM_PL_VRAM:<br>
>>>> return AMDGPU_GEM_DOMAIN_VRAM;<br>
>>>> case TTM_PL_TT:<br>
>>>> return AMDGPU_GEM_DOMAIN_GTT;<br>
>>>> case TTM_PL_SYSTEM:<br>
>>>> return AMDGPU_GEM_DOMAIN_CPU;<br>
>>>> - case AMDGPU_PL_GDS:<br>
>>>> - return AMDGPU_GEM_DOMAIN_GDS;<br>
>>>> - case AMDGPU_PL_GWS:<br>
>>>> - return AMDGPU_GEM_DOMAIN_GWS;<br>
>>>> - case AMDGPU_PL_OA:<br>
>>>> - return AMDGPU_GEM_DOMAIN_OA;<br>
>>>> default:<br>
>>>> break;<br>
>>>> }<br>
>>>> return 0;<br>
>>>> }<br>
>>>> /**<br>
>>>> * amdgpu_bo_reserve - reserve bo<br>
>>>> * @bo: bo structure<br>
>>>> * @no_intr: don't return -ERESTARTSYS on pending signal<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
>>>> index 9cc239968e40..f6ea9604e611 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
>>>> @@ -130,24 +130,20 @@ struct amdgpu_ring_funcs {<br>
>>>> /* command emit functions */<br>
>>>> void (*emit_ib)(struct amdgpu_ring *ring,<br>
>>>> struct amdgpu_ib *ib,<br>
>>>> unsigned vmid, bool ctx_switch);<br>
>>>> void (*emit_fence)(struct amdgpu_ring *ring, uint64_t addr,<br>
>>>> uint64_t seq, unsigned flags);<br>
>>>> void (*emit_pipeline_sync)(struct amdgpu_ring *ring);<br>
>>>> void (*emit_vm_flush)(struct amdgpu_ring *ring, unsigned vmid,<br>
>>>> uint64_t pd_addr);<br>
>>>> void (*emit_hdp_flush)(struct amdgpu_ring *ring);<br>
>>>> - void (*emit_gds_switch)(struct amdgpu_ring *ring, uint32_t vmid,<br>
>>>> - uint32_t gds_base, uint32_t gds_size,<br>
>>>> - uint32_t gws_base, uint32_t gws_size,<br>
>>>> - uint32_t oa_base, uint32_t oa_size);<br>
>>>> /* testing functions */<br>
>>>> int (*test_ring)(struct amdgpu_ring *ring);<br>
>>>> int (*test_ib)(struct amdgpu_ring *ring, long timeout);<br>
>>>> /* insert NOP packets */<br>
>>>> void (*insert_nop)(struct amdgpu_ring *ring, uint32_t count);<br>
>>>> void (*insert_start)(struct amdgpu_ring *ring);<br>
>>>> void (*insert_end)(struct amdgpu_ring *ring);<br>
>>>> /* pad the indirect buffer to the necessary number of dw */<br>
>>>> void (*pad_ib)(struct amdgpu_ring *ring, struct amdgpu_ib *ib);<br>
>>>> unsigned (*init_cond_exec)(struct amdgpu_ring *ring);<br>
>>>> @@ -226,21 +222,20 @@ struct amdgpu_ring {<br>
>>>> #define amdgpu_ring_patch_cs_in_place(r, p, ib)<br>
>>>> ((r)->funcs->patch_cs_in_place((p), (ib)))<br>
>>>> #define amdgpu_ring_test_ring(r) (r)->funcs->test_ring((r))<br>
>>>> #define amdgpu_ring_test_ib(r, t) (r)->funcs->test_ib((r), (t))<br>
>>>> #define amdgpu_ring_get_rptr(r) (r)->funcs->get_rptr((r))<br>
>>>> #define amdgpu_ring_get_wptr(r) (r)->funcs->get_wptr((r))<br>
>>>> #define amdgpu_ring_set_wptr(r) (r)->funcs->set_wptr((r))<br>
>>>> #define amdgpu_ring_emit_ib(r, ib, vmid, c) (r)->funcs->emit_ib((r),<br>
>>>> (ib), (vmid), (c))<br>
>>>> #define amdgpu_ring_emit_pipeline_sync(r)<br>
>>>> (r)->funcs->emit_pipeline_sync((r))<br>
>>>> #define amdgpu_ring_emit_vm_flush(r, vmid, addr)<br>
>>>> (r)->funcs->emit_vm_flush((r), (vmid), (addr))<br>
>>>> #define amdgpu_ring_emit_fence(r, addr, seq, flags)<br>
>>>> (r)->funcs->emit_fence((r), (addr), (seq), (flags))<br>
>>>> -#define amdgpu_ring_emit_gds_switch(r, v, db, ds, wb, ws, ab, as)<br>
>>>> (r)->funcs->emit_gds_switch((r), (v), (db), (ds), (wb), (ws), (ab),<br>
>>>> (as))<br>
>>>> #define amdgpu_ring_emit_hdp_flush(r) (r)->funcs->emit_hdp_flush((r))<br>
>>>> #define amdgpu_ring_emit_switch_buffer(r)<br>
>>>> (r)->funcs->emit_switch_buffer((r))<br>
>>>> #define amdgpu_ring_emit_cntxcntl(r, d)<br>
>>>> (r)->funcs->emit_cntxcntl((r),<br>
>>>> (d))<br>
>>>> #define amdgpu_ring_emit_rreg(r, d) (r)->funcs->emit_rreg((r), (d))<br>
>>>> #define amdgpu_ring_emit_wreg(r, d, v) (r)->funcs->emit_wreg((r),<br>
>>>> (d),<br>
>>>> (v))<br>
>>>> #define amdgpu_ring_emit_reg_wait(r, d, v, m)<br>
>>>> (r)->funcs->emit_reg_wait((r), (d), (v), (m))<br>
>>>> #define amdgpu_ring_emit_reg_write_reg_wait(r, d0, d1, v, m)<br>
>>>> (r)->funcs->emit_reg_write_reg_wait((r), (d0), (d1), (v), (m))<br>
>>>> #define amdgpu_ring_emit_tmz(r, b) (r)->funcs->emit_tmz((r), (b))<br>
>>>> #define amdgpu_ring_pad_ib(r, ib) ((r)->funcs->pad_ib((r), (ib)))<br>
>>>> #define amdgpu_ring_init_cond_exec(r) (r)->funcs->init_cond_exec((r))<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
>>>> index 8a158ee922f7..2cc62b0e7ea8 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
>>>> @@ -195,30 +195,20 @@ static int amdgpu_init_mem_type(struct<br>
>>>> ttm_bo_device<br>
>>>> *bdev, uint32_t type,<br>
>>>> break;<br>
>>>> case TTM_PL_VRAM:<br>
>>>> /* "On-card" video ram */<br>
>>>> man->func = &amdgpu_vram_mgr_func;<br>
>>>> man->gpu_offset = adev->gmc.vram_start;<br>
>>>> man->flags = TTM_MEMTYPE_FLAG_FIXED |<br>
>>>> TTM_MEMTYPE_FLAG_MAPPABLE;<br>
>>>> man->available_caching = TTM_PL_FLAG_UNCACHED |<br>
>>>> TTM_PL_FLAG_WC;<br>
>>>> man->default_caching = TTM_PL_FLAG_WC;<br>
>>>> break;<br>
>>>> - case AMDGPU_PL_GDS:<br>
>>>> - case AMDGPU_PL_GWS:<br>
>>>> - case AMDGPU_PL_OA:<br>
>>>> - /* On-chip GDS memory*/<br>
>>>> - man->func = &ttm_bo_manager_func;<br>
>>>> - man->gpu_offset = 0;<br>
>>>> - man->flags = TTM_MEMTYPE_FLAG_FIXED |<br>
>>>> TTM_MEMTYPE_FLAG_CMA;<br>
>>>> - man->available_caching = TTM_PL_FLAG_UNCACHED;<br>
>>>> - man->default_caching = TTM_PL_FLAG_UNCACHED;<br>
>>>> - break;<br>
>>>> default:<br>
>>>> DRM_ERROR("Unsupported memory type %u\n",<br>
>>>> (unsigned)type);<br>
>>>> return -EINVAL;<br>
>>>> }<br>
>>>> return 0;<br>
>>>> }<br>
>>>> /**<br>
>>>> * amdgpu_evict_flags - Compute placement flags<br>
>>>> *<br>
>>>> @@ -1039,25 +1029,20 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt<br>
>>>> *ttm,<br>
>>>> if (r) {<br>
>>>> DRM_ERROR("failed to pin userptr\n");<br>
>>>> return r;<br>
>>>> }<br>
>>>> }<br>
>>>> if (!ttm->num_pages) {<br>
>>>> WARN(1, "nothing to bind %lu pages for mreg %p back<br>
>>>> %p!\n",<br>
>>>> ttm->num_pages, bo_mem, ttm);<br>
>>>> }<br>
>>>> - if (bo_mem->mem_type == AMDGPU_PL_GDS ||<br>
>>>> - bo_mem->mem_type == AMDGPU_PL_GWS ||<br>
>>>> - bo_mem->mem_type == AMDGPU_PL_OA)<br>
>>>> - return -EINVAL;<br>
>>>> -<br>
>>>> if (!amdgpu_gtt_mgr_has_gart_addr(bo_mem)) {<br>
>>>> gtt->offset = AMDGPU_BO_INVALID_OFFSET;<br>
>>>> return 0;<br>
>>>> }<br>
>>>> /* compute PTE flags relevant to this BO memory */<br>
>>>> flags = amdgpu_ttm_tt_pte_flags(adev, ttm, bo_mem);<br>
>>>> /* bind pages into GART page tables */<br>
>>>> gtt->offset = ((u64)bo_mem->start << PAGE_SHIFT) -<br>
>>>> adev->gmc.gart_start;<br>
>>>> @@ -1818,60 +1803,20 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)<br>
>>>> /* Initialize GTT memory pool */<br>
>>>> r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, gtt_size >><br>
>>>> PAGE_SHIFT);<br>
>>>> if (r) {<br>
>>>> DRM_ERROR("Failed initializing GTT heap.\n");<br>
>>>> return r;<br>
>>>> }<br>
>>>> DRM_INFO("amdgpu: %uM of GTT memory ready.\n",<br>
>>>> (unsigned)(gtt_size / (1024 * 1024)));<br>
>>>> - /* Initialize various on-chip memory pools */<br>
>>>> - adev->gds.mem.total_size = adev->gds.mem.total_size <<<br>
>>>> AMDGPU_GDS_SHIFT;<br>
>>>> - adev->gds.mem.gfx_partition_size =<br>
>>>> adev->gds.mem.gfx_partition_size << AMDGPU_GDS_SHIFT;<br>
>>>> - adev->gds.mem.cs_partition_size =<br>
>>>> adev->gds.mem.cs_partition_size<br>
>>>> << AMDGPU_GDS_SHIFT;<br>
>>>> - adev->gds.gws.total_size = adev->gds.gws.total_size <<<br>
>>>> AMDGPU_GWS_SHIFT;<br>
>>>> - adev->gds.gws.gfx_partition_size =<br>
>>>> adev->gds.gws.gfx_partition_size << AMDGPU_GWS_SHIFT;<br>
>>>> - adev->gds.gws.cs_partition_size =<br>
>>>> adev->gds.gws.cs_partition_size<br>
>>>> << AMDGPU_GWS_SHIFT;<br>
>>>> - adev->gds.oa.total_size = adev->gds.oa.total_size <<<br>
>>>> AMDGPU_OA_SHIFT;<br>
>>>> - adev->gds.oa.gfx_partition_size =<br>
>>>> adev->gds.oa.gfx_partition_size<br>
>>>> << AMDGPU_OA_SHIFT;<br>
>>>> - adev->gds.oa.cs_partition_size = adev->gds.oa.cs_partition_size<br>
>>>> <<<br>
>>>> AMDGPU_OA_SHIFT;<br>
>>>> - /* GDS Memory */<br>
>>>> - if (adev->gds.mem.total_size) {<br>
>>>> - r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,<br>
>>>> - adev->gds.mem.total_size >><br>
>>>> PAGE_SHIFT);<br>
>>>> - if (r) {<br>
>>>> - DRM_ERROR("Failed initializing GDS heap.\n");<br>
>>>> - return r;<br>
>>>> - }<br>
>>>> - }<br>
>>>> -<br>
>>>> - /* GWS */<br>
>>>> - if (adev->gds.gws.total_size) {<br>
>>>> - r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,<br>
>>>> - adev->gds.gws.total_size >><br>
>>>> PAGE_SHIFT);<br>
>>>> - if (r) {<br>
>>>> - DRM_ERROR("Failed initializing gws heap.\n");<br>
>>>> - return r;<br>
>>>> - }<br>
>>>> - }<br>
>>>> -<br>
>>>> - /* OA */<br>
>>>> - if (adev->gds.oa.total_size) {<br>
>>>> - r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,<br>
>>>> - adev->gds.oa.total_size >><br>
>>>> PAGE_SHIFT);<br>
>>>> - if (r) {<br>
>>>> - DRM_ERROR("Failed initializing oa heap.\n");<br>
>>>> - return r;<br>
>>>> - }<br>
>>>> - }<br>
>>>> -<br>
>>>> /* Register debugfs entries for amdgpu_ttm */<br>
>>>> r = amdgpu_ttm_debugfs_init(adev);<br>
>>>> if (r) {<br>
>>>> DRM_ERROR("Failed to init debugfs\n");<br>
>>>> return r;<br>
>>>> }<br>
>>>> return 0;<br>
>>>> }<br>
>>>> /**<br>
>>>> @@ -1892,26 +1837,20 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)<br>
>>>> return;<br>
>>>> amdgpu_ttm_debugfs_fini(adev);<br>
>>>> amdgpu_ttm_fw_reserve_vram_fini(adev);<br>
>>>> if (adev->mman.aper_base_kaddr)<br>
>>>> iounmap(adev->mman.aper_base_kaddr);<br>
>>>> adev->mman.aper_base_kaddr = NULL;<br>
>>>> ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_VRAM);<br>
>>>> ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_TT);<br>
>>>> - if (adev->gds.mem.total_size)<br>
>>>> - ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GDS);<br>
>>>> - if (adev->gds.gws.total_size)<br>
>>>> - ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GWS);<br>
>>>> - if (adev->gds.oa.total_size)<br>
>>>> - ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_OA);<br>
>>>> ttm_bo_device_release(&adev->mman.bdev);<br>
>>>> amdgpu_ttm_global_fini(adev);<br>
>>>> adev->mman.initialized = false;<br>
>>>> DRM_INFO("amdgpu: ttm finalized\n");<br>
>>>> }<br>
>>>> /**<br>
>>>> * amdgpu_ttm_set_buffer_funcs_status - enable/disable use of buffer<br>
>>>> functions<br>
>>>> *<br>
>>>> * @adev: amdgpu_device pointer<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h<br>
>>>> index fe8f276e9811..04557a382b19 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h<br>
>>>> @@ -20,28 +20,20 @@<br>
>>>> * OTHER DEALINGS IN THE SOFTWARE.<br>
>>>> *<br>
>>>> */<br>
>>>> #ifndef __AMDGPU_TTM_H__<br>
>>>> #define __AMDGPU_TTM_H__<br>
>>>> #include "amdgpu.h"<br>
>>>> #include <drm/gpu_scheduler.h><br>
>>>> -#define AMDGPU_PL_GDS (TTM_PL_PRIV + 0)<br>
>>>> -#define AMDGPU_PL_GWS (TTM_PL_PRIV + 1)<br>
>>>> -#define AMDGPU_PL_OA (TTM_PL_PRIV + 2)<br>
>>>> -<br>
>>>> -#define AMDGPU_PL_FLAG_GDS (TTM_PL_FLAG_PRIV << 0)<br>
>>>> -#define AMDGPU_PL_FLAG_GWS (TTM_PL_FLAG_PRIV << 1)<br>
>>>> -#define AMDGPU_PL_FLAG_OA (TTM_PL_FLAG_PRIV << 2)<br>
>>>> -<br>
>>>> #define AMDGPU_GTT_MAX_TRANSFER_SIZE 512<br>
>>>> #define AMDGPU_GTT_NUM_TRANSFER_WINDOWS 2<br>
>>>> struct amdgpu_mman {<br>
>>>> struct ttm_bo_global_ref bo_global_ref;<br>
>>>> struct drm_global_reference mem_global_ref;<br>
>>>> struct ttm_bo_device bdev;<br>
>>>> bool mem_global_referenced;<br>
>>>> bool initialized;<br>
>>>> void __iomem *aper_base_kaddr;<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
>>>> index be1659fedf94..c66f1c6f0ba8 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
>>>> @@ -803,86 +803,69 @@ void amdgpu_vm_check_compute_bug(struct<br>
>>>> amdgpu_device *adev)<br>
>>>> * Returns:<br>
>>>> * True if sync is needed.<br>
>>>> */<br>
>>>> bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,<br>
>>>> struct amdgpu_job *job)<br>
>>>> {<br>
>>>> struct amdgpu_device *adev = ring->adev;<br>
>>>> unsigned vmhub = ring->funcs->vmhub;<br>
>>>> struct amdgpu_vmid_mgr *id_mgr =<br>
>>>> &adev->vm_manager.id_mgr[vmhub];<br>
>>>> struct amdgpu_vmid *id;<br>
>>>> - bool gds_switch_needed;<br>
>>>> bool vm_flush_needed = job->vm_needs_flush ||<br>
>>>> ring->has_compute_vm_bug;<br>
>>>> if (job->vmid == 0)<br>
>>>> return false;<br>
>>>> id = &id_mgr->ids[job->vmid];<br>
>>>> - gds_switch_needed = ring->funcs->emit_gds_switch && (<br>
>>>> - id->gds_base != job->gds_base ||<br>
>>>> - id->gds_size != job->gds_size ||<br>
>>>> - id->gws_base != job->gws_base ||<br>
>>>> - id->gws_size != job->gws_size ||<br>
>>>> - id->oa_base != job->oa_base ||<br>
>>>> - id->oa_size != job->oa_size);<br>
>>>> if (amdgpu_vmid_had_gpu_reset(adev, id))<br>
>>>> return true;<br>
>>>> - return vm_flush_needed || gds_switch_needed;<br>
>>>> + return vm_flush_needed;<br>
>>>> }<br>
>>>> /**<br>
>>>> * amdgpu_vm_flush - hardware flush the vm<br>
>>>> *<br>
>>>> * @ring: ring to use for flush<br>
>>>> * @job: related job<br>
>>>> * @need_pipe_sync: is pipe sync needed<br>
>>>> *<br>
>>>> * Emit a VM flush when it is necessary.<br>
>>>> *<br>
>>>> * Returns:<br>
>>>> * 0 on success, errno otherwise.<br>
>>>> */<br>
>>>> int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,<br>
>>>> bool need_pipe_sync)<br>
>>>> {<br>
>>>> struct amdgpu_device *adev = ring->adev;<br>
>>>> unsigned vmhub = ring->funcs->vmhub;<br>
>>>> struct amdgpu_vmid_mgr *id_mgr =<br>
>>>> &adev->vm_manager.id_mgr[vmhub];<br>
>>>> struct amdgpu_vmid *id = &id_mgr->ids[job->vmid];<br>
>>>> - bool gds_switch_needed = ring->funcs->emit_gds_switch && (<br>
>>>> - id->gds_base != job->gds_base ||<br>
>>>> - id->gds_size != job->gds_size ||<br>
>>>> - id->gws_base != job->gws_base ||<br>
>>>> - id->gws_size != job->gws_size ||<br>
>>>> - id->oa_base != job->oa_base ||<br>
>>>> - id->oa_size != job->oa_size);<br>
>>>> bool vm_flush_needed = job->vm_needs_flush;<br>
>>>> bool pasid_mapping_needed = id->pasid != job->pasid ||<br>
>>>> !id->pasid_mapping ||<br>
>>>> !dma_fence_is_signaled(id->pasid_mapping);<br>
>>>> struct dma_fence *fence = NULL;<br>
>>>> unsigned patch_offset = 0;<br>
>>>> int r;<br>
>>>> if (amdgpu_vmid_had_gpu_reset(adev, id)) {<br>
>>>> - gds_switch_needed = true;<br>
>>>> vm_flush_needed = true;<br>
>>>> pasid_mapping_needed = true;<br>
>>>> }<br>
>>>> - gds_switch_needed &= !!ring->funcs->emit_gds_switch;<br>
>>>> vm_flush_needed &= !!ring->funcs->emit_vm_flush &&<br>
>>>> job->vm_pd_addr != AMDGPU_BO_INVALID_OFFSET;<br>
>>>> pasid_mapping_needed &= adev->gmc.gmc_funcs->emit_pasid_mapping<br>
>>>> &&<br>
>>>> ring->funcs->emit_wreg;<br>
>>>> - if (!vm_flush_needed && !gds_switch_needed && !need_pipe_sync)<br>
>>>> + if (!vm_flush_needed && !need_pipe_sync)<br>
>>>> return 0;<br>
>>>> if (ring->funcs->init_cond_exec)<br>
>>>> patch_offset = amdgpu_ring_init_cond_exec(ring);<br>
>>>> if (need_pipe_sync)<br>
>>>> amdgpu_ring_emit_pipeline_sync(ring);<br>
>>>> if (vm_flush_needed) {<br>
>>>> trace_amdgpu_vm_flush(ring, job->vmid,<br>
>>>> job->vm_pd_addr);<br>
>>>> @@ -907,33 +890,20 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring,<br>
>>>> struct<br>
>>>> amdgpu_job *job, bool need_<br>
>>>> mutex_unlock(&id_mgr->lock);<br>
>>>> }<br>
>>>> if (pasid_mapping_needed) {<br>
>>>> id->pasid = job->pasid;<br>
>>>> dma_fence_put(id->pasid_mapping);<br>
>>>> id->pasid_mapping = dma_fence_get(fence);<br>
>>>> }<br>
>>>> dma_fence_put(fence);<br>
>>>> - if (ring->funcs->emit_gds_switch && gds_switch_needed) {<br>
>>>> - id->gds_base = job->gds_base;<br>
>>>> - id->gds_size = job->gds_size;<br>
>>>> - id->gws_base = job->gws_base;<br>
>>>> - id->gws_size = job->gws_size;<br>
>>>> - id->oa_base = job->oa_base;<br>
>>>> - id->oa_size = job->oa_size;<br>
>>>> - amdgpu_ring_emit_gds_switch(ring, job->vmid,<br>
>>>> job->gds_base,<br>
>>>> - job->gds_size,<br>
>>>> job->gws_base,<br>
>>>> - job->gws_size, job->oa_base,<br>
>>>> - job->oa_size);<br>
>>>> - }<br>
>>>> -<br>
>>>> if (ring->funcs->patch_cond_exec)<br>
>>>> amdgpu_ring_patch_cond_exec(ring, patch_offset);<br>
>>>> /* the double SWITCH_BUFFER here *cannot* be skipped by<br>
>>>> COND_EXEC<br>
>>>> */<br>
>>>> if (ring->funcs->emit_switch_buffer) {<br>
>>>> amdgpu_ring_emit_switch_buffer(ring);<br>
>>>> amdgpu_ring_emit_switch_buffer(ring);<br>
>>>> }<br>
>>>> return 0;<br>
>>>> }<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c<br>
>>>> index a15d9c0f233b..f5228e169c3a 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c<br>
>>>> @@ -1890,21 +1890,21 @@ static void gfx_v7_0_config_init(struct<br>
>>>> amdgpu_device *adev)<br>
>>>> *<br>
>>>> * @adev: amdgpu_device pointer<br>
>>>> *<br>
>>>> * Configures the 3D engine and tiling configuration<br>
>>>> * registers so that the 3D engine is usable.<br>
>>>> */<br>
>>>> static void gfx_v7_0_gpu_init(struct amdgpu_device *adev)<br>
>>>> {<br>
>>>> u32 sh_mem_cfg, sh_static_mem_cfg, sh_mem_base;<br>
>>>> u32 tmp;<br>
>>>> - int i;<br>
>>>> + int i, vmid;<br>
>>>> WREG32(mmGRBM_CNTL, (0xff << GRBM_CNTL__READ_TIMEOUT__SHIFT));<br>
>>>> WREG32(mmGB_ADDR_CONFIG, adev->gfx.config.gb_addr_config);<br>
>>>> WREG32(mmHDP_ADDR_CONFIG, adev->gfx.config.gb_addr_config);<br>
>>>> WREG32(mmDMIF_ADDR_CALC, adev->gfx.config.gb_addr_config);<br>
>>>> gfx_v7_0_tiling_mode_table_init(adev);<br>
>>>> gfx_v7_0_setup_rb(adev);<br>
>>>> @@ -2014,20 +2014,42 @@ static void gfx_v7_0_gpu_init(struct<br>
>>>> amdgpu_device<br>
>>>> *adev)<br>
>>>> tmp = RREG32(mmSPI_ARB_PRIORITY);<br>
>>>> tmp = REG_SET_FIELD(tmp, SPI_ARB_PRIORITY, PIPE_ORDER_TS0, 2);<br>
>>>> tmp = REG_SET_FIELD(tmp, SPI_ARB_PRIORITY, PIPE_ORDER_TS1, 2);<br>
>>>> tmp = REG_SET_FIELD(tmp, SPI_ARB_PRIORITY, PIPE_ORDER_TS2, 2);<br>
>>>> tmp = REG_SET_FIELD(tmp, SPI_ARB_PRIORITY, PIPE_ORDER_TS3, 2);<br>
>>>> WREG32(mmSPI_ARB_PRIORITY, tmp);<br>
>>>> mutex_unlock(&adev->grbm_idx_mutex);<br>
>>>> + for (vmid = 0; vmid < AMDGPU_NUM_VMID; vmid++) {<br>
>>>> + unsigned gds_size, gws_size, oa_size;<br>
>>>> +<br>
>>>> + if (vmid <<br>
>>>> adev->vm_manager.id_mgr[AMDGPU_GFXHUB].num_ids)<br>
>>>> {<br>
>>>> + gds_size = adev->gds.mem.gfx_size_per_vmid;<br>
>>>> + gws_size = adev->gds.gws.gfx_size_per_vmid;<br>
>>>> + oa_size = adev->gds.oa.gfx_size_per_vmid;<br>
>>>> + } else {<br>
>>>> + gds_size = adev->gds.mem.kfd_size_per_vmid;<br>
>>>> + gws_size = adev->gds.gws.kfd_size_per_vmid;<br>
>>>> + oa_size = adev->gds.oa.kfd_size_per_vmid;<br>
>>>> + }<br>
>>>> +<br>
>>>> + WREG32(amdgpu_gds_reg_offset[vmid].mem_base, vmid *<br>
>>>> gds_size);<br>
>>>> + WREG32(amdgpu_gds_reg_offset[vmid].mem_size, gds_size);<br>
>>>> + WREG32(amdgpu_gds_reg_offset[vmid].gws,<br>
>>>> + (vmid * gws_size) |<br>
>>>> + (gws_size << GDS_GWS_VMID0__SIZE__SHIFT));<br>
>>>> + WREG32(amdgpu_gds_reg_offset[vmid].oa,<br>
>>>> + ((1 << oa_size) - 1) << (vmid * oa_size));<br>
>>>> + }<br>
>>>> +<br>
>>>> udelay(50);<br>
>>>> }<br>
>>>> /*<br>
>>>> * GPU scratch registers helpers function.<br>
>>>> */<br>
>>>> /**<br>
>>>> * gfx_v7_0_scratch_init - setup driver info for CP scratch regs<br>
>>>> *<br>
>>>> * @adev: amdgpu_device pointer<br>
>>>> @@ -4157,68 +4179,20 @@ static uint64_t<br>
>>>> gfx_v7_0_get_gpu_clock_counter(struct amdgpu_device *adev)<br>
>>>> uint64_t clock;<br>
>>>> mutex_lock(&adev->gfx.gpu_clock_mutex);<br>
>>>> WREG32(mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);<br>
>>>> clock = (uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_LSB) |<br>
>>>> ((uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL);<br>
>>>> mutex_unlock(&adev->gfx.gpu_clock_mutex);<br>
>>>> return clock;<br>
>>>> }<br>
>>>> -static void gfx_v7_0_ring_emit_gds_switch(struct amdgpu_ring *ring,<br>
>>>> - uint32_t vmid,<br>
>>>> - uint32_t gds_base, uint32_t<br>
>>>> gds_size,<br>
>>>> - uint32_t gws_base, uint32_t<br>
>>>> gws_size,<br>
>>>> - uint32_t oa_base, uint32_t<br>
>>>> oa_size)<br>
>>>> -{<br>
>>>> - gds_base = gds_base >> AMDGPU_GDS_SHIFT;<br>
>>>> - gds_size = gds_size >> AMDGPU_GDS_SHIFT;<br>
>>>> -<br>
>>>> - gws_base = gws_base >> AMDGPU_GWS_SHIFT;<br>
>>>> - gws_size = gws_size >> AMDGPU_GWS_SHIFT;<br>
>>>> -<br>
>>>> - oa_base = oa_base >> AMDGPU_OA_SHIFT;<br>
>>>> - oa_size = oa_size >> AMDGPU_OA_SHIFT;<br>
>>>> -<br>
>>>> - /* GDS Base */<br>
>>>> - amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));<br>
>>>> - amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |<br>
>>>> - WRITE_DATA_DST_SEL(0)));<br>
>>>> - amdgpu_ring_write(ring, amdgpu_gds_reg_offset[vmid].mem_base);<br>
>>>> - amdgpu_ring_write(ring, 0);<br>
>>>> - amdgpu_ring_write(ring, gds_base);<br>
>>>> -<br>
>>>> - /* GDS Size */<br>
>>>> - amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));<br>
>>>> - amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |<br>
>>>> - WRITE_DATA_DST_SEL(0)));<br>
>>>> - amdgpu_ring_write(ring, amdgpu_gds_reg_offset[vmid].mem_size);<br>
>>>> - amdgpu_ring_write(ring, 0);<br>
>>>> - amdgpu_ring_write(ring, gds_size);<br>
>>>> -<br>
>>>> - /* GWS */<br>
>>>> - amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));<br>
>>>> - amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |<br>
>>>> - WRITE_DATA_DST_SEL(0)));<br>
>>>> - amdgpu_ring_write(ring, amdgpu_gds_reg_offset[vmid].gws);<br>
>>>> - amdgpu_ring_write(ring, 0);<br>
>>>> - amdgpu_ring_write(ring, gws_size << GDS_GWS_VMID0__SIZE__SHIFT |<br>
>>>> gws_base);<br>
>>>> -<br>
>>>> - /* OA */<br>
>>>> - amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));<br>
>>>> - amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |<br>
>>>> - WRITE_DATA_DST_SEL(0)));<br>
>>>> - amdgpu_ring_write(ring, amdgpu_gds_reg_offset[vmid].oa);<br>
>>>> - amdgpu_ring_write(ring, 0);<br>
>>>> - amdgpu_ring_write(ring, (1 << (oa_size + oa_base)) - (1 <<<br>
>>>> oa_base));<br>
>>>> -}<br>
>>>> -<br>
>>>> static void gfx_v7_0_ring_soft_recovery(struct amdgpu_ring *ring,<br>
>>>> unsigned vmid)<br>
>>>> {<br>
>>>> struct amdgpu_device *adev = ring->adev;<br>
>>>> uint32_t value = 0;<br>
>>>> value = REG_SET_FIELD(value, SQ_CMD, CMD, 0x03);<br>
>>>> value = REG_SET_FIELD(value, SQ_CMD, MODE, 0x01);<br>
>>>> value = REG_SET_FIELD(value, SQ_CMD, CHECK_VMID, 1);<br>
>>>> value = REG_SET_FIELD(value, SQ_CMD, VM_ID, vmid);<br>
>>>> WREG32(mmSQ_CMD, value);<br>
>>>> @@ -4584,55 +4558,32 @@ static int gfx_v7_0_sw_init(void *handle)<br>
>>>><br>
>>>> ring_id,<br>
>>>> i, k,<br>
>>>> j);<br>
>>>> if (r)<br>
>>>> return r;<br>
>>>> ring_id++;<br>
>>>> }<br>
>>>> }<br>
>>>> }<br>
>>>> - /* reserve GDS, GWS and OA resource for gfx */<br>
>>>> - r = amdgpu_bo_create_kernel(adev,<br>
>>>> adev->gds.mem.gfx_partition_size,<br>
>>>> - PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,<br>
>>>> - &adev->gds.gds_gfx_bo, NULL, NULL);<br>
>>>> - if (r)<br>
>>>> - return r;<br>
>>>> -<br>
>>>> - r = amdgpu_bo_create_kernel(adev,<br>
>>>> adev->gds.gws.gfx_partition_size,<br>
>>>> - PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,<br>
>>>> - &adev->gds.gws_gfx_bo, NULL, NULL);<br>
>>>> - if (r)<br>
>>>> - return r;<br>
>>>> -<br>
>>>> - r = amdgpu_bo_create_kernel(adev,<br>
>>>> adev->gds.oa.gfx_partition_size,<br>
>>>> - PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,<br>
>>>> - &adev->gds.oa_gfx_bo, NULL, NULL);<br>
>>>> - if (r)<br>
>>>> - return r;<br>
>>>> -<br>
>>>> adev->gfx.ce_ram_size = 0x8000;<br>
>>>> gfx_v7_0_gpu_early_init(adev);<br>
>>>> return r;<br>
>>>> }<br>
>>>> static int gfx_v7_0_sw_fini(void *handle)<br>
>>>> {<br>
>>>> int i;<br>
>>>> struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
>>>> - amdgpu_bo_free_kernel(&adev->gds.oa_gfx_bo, NULL, NULL);<br>
>>>> - amdgpu_bo_free_kernel(&adev->gds.gws_gfx_bo, NULL, NULL);<br>
>>>> - amdgpu_bo_free_kernel(&adev->gds.gds_gfx_bo, NULL, NULL);<br>
>>>> -<br>
>>>> for (i = 0; i < adev->gfx.num_gfx_rings; i++)<br>
>>>> amdgpu_ring_fini(&adev->gfx.gfx_ring[i]);<br>
>>>> for (i = 0; i < adev->gfx.num_compute_rings; i++)<br>
>>>> amdgpu_ring_fini(&adev->gfx.compute_ring[i]);<br>
>>>> gfx_v7_0_cp_compute_fini(adev);<br>
>>>> gfx_v7_0_rlc_fini(adev);<br>
>>>> gfx_v7_0_mec_fini(adev);<br>
>>>> amdgpu_bo_free_kernel(&adev->gfx.rlc.clear_state_obj,<br>
>>>> &adev->gfx.rlc.clear_state_gpu_addr,<br>
>>>> @@ -5073,64 +5024,60 @@ static const struct amd_ip_funcs<br>
>>>> gfx_v7_0_ip_funcs<br>
>>>> = {<br>
>>>> static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx = {<br>
>>>> .type = AMDGPU_RING_TYPE_GFX,<br>
>>>> .align_mask = 0xff,<br>
>>>> .nop = PACKET3(PACKET3_NOP, 0x3FFF),<br>
>>>> .support_64bit_ptrs = false,<br>
>>>> .get_rptr = gfx_v7_0_ring_get_rptr,<br>
>>>> .get_wptr = gfx_v7_0_ring_get_wptr_gfx,<br>
>>>> .set_wptr = gfx_v7_0_ring_set_wptr_gfx,<br>
>>>> .emit_frame_size =<br>
>>>> - 20 + /* gfx_v7_0_ring_emit_gds_switch */<br>
>>>> 7 + /* gfx_v7_0_ring_emit_hdp_flush */<br>
>>>> 5 + /* hdp invalidate */<br>
>>>> 12 + 12 + 12 + /* gfx_v7_0_ring_emit_fence_gfx x3 for<br>
>>>> user<br>
>>>> fence, vm fence */<br>
>>>> 7 + 4 + /* gfx_v7_0_ring_emit_pipeline_sync */<br>
>>>> CIK_FLUSH_GPU_TLB_NUM_WREG * 5 + 7 + 6 + /*<br>
>>>> gfx_v7_0_ring_emit_vm_flush */<br>
>>>> 3 + 4, /* gfx_v7_ring_emit_cntxcntl including vgt<br>
>>>> flush*/<br>
>>>> .emit_ib_size = 4, /* gfx_v7_0_ring_emit_ib_gfx */<br>
>>>> .emit_ib = gfx_v7_0_ring_emit_ib_gfx,<br>
>>>> .emit_fence = gfx_v7_0_ring_emit_fence_gfx,<br>
>>>> .emit_pipeline_sync = gfx_v7_0_ring_emit_pipeline_sync,<br>
>>>> .emit_vm_flush = gfx_v7_0_ring_emit_vm_flush,<br>
>>>> - .emit_gds_switch = gfx_v7_0_ring_emit_gds_switch,<br>
>>>> .emit_hdp_flush = gfx_v7_0_ring_emit_hdp_flush,<br>
>>>> .test_ring = gfx_v7_0_ring_test_ring,<br>
>>>> .test_ib = gfx_v7_0_ring_test_ib,<br>
>>>> .insert_nop = amdgpu_ring_insert_nop,<br>
>>>> .pad_ib = amdgpu_ring_generic_pad_ib,<br>
>>>> .emit_cntxcntl = gfx_v7_ring_emit_cntxcntl,<br>
>>>> .emit_wreg = gfx_v7_0_ring_emit_wreg,<br>
>>>> .soft_recovery = gfx_v7_0_ring_soft_recovery,<br>
>>>> };<br>
>>>> static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute =<br>
>>>> {<br>
>>>> .type = AMDGPU_RING_TYPE_COMPUTE,<br>
>>>> .align_mask = 0xff,<br>
>>>> .nop = PACKET3(PACKET3_NOP, 0x3FFF),<br>
>>>> .support_64bit_ptrs = false,<br>
>>>> .get_rptr = gfx_v7_0_ring_get_rptr,<br>
>>>> .get_wptr = gfx_v7_0_ring_get_wptr_compute,<br>
>>>> .set_wptr = gfx_v7_0_ring_set_wptr_compute,<br>
>>>> .emit_frame_size =<br>
>>>> - 20 + /* gfx_v7_0_ring_emit_gds_switch */<br>
>>>> 7 + /* gfx_v7_0_ring_emit_hdp_flush */<br>
>>>> 5 + /* hdp invalidate */<br>
>>>> 7 + /* gfx_v7_0_ring_emit_pipeline_sync */<br>
>>>> CIK_FLUSH_GPU_TLB_NUM_WREG * 5 + 7 + /*<br>
>>>> gfx_v7_0_ring_emit_vm_flush */<br>
>>>> 7 + 7 + 7, /* gfx_v7_0_ring_emit_fence_compute x3 for<br>
>>>> user<br>
>>>> fence, vm fence */<br>
>>>> .emit_ib_size = 4, /* gfx_v7_0_ring_emit_ib_compute */<br>
>>>> .emit_ib = gfx_v7_0_ring_emit_ib_compute,<br>
>>>> .emit_fence = gfx_v7_0_ring_emit_fence_compute,<br>
>>>> .emit_pipeline_sync = gfx_v7_0_ring_emit_pipeline_sync,<br>
>>>> .emit_vm_flush = gfx_v7_0_ring_emit_vm_flush,<br>
>>>> - .emit_gds_switch = gfx_v7_0_ring_emit_gds_switch,<br>
>>>> .emit_hdp_flush = gfx_v7_0_ring_emit_hdp_flush,<br>
>>>> .test_ring = gfx_v7_0_ring_test_ring,<br>
>>>> .test_ib = gfx_v7_0_ring_test_ib,<br>
>>>> .insert_nop = amdgpu_ring_insert_nop,<br>
>>>> .pad_ib = amdgpu_ring_generic_pad_ib,<br>
>>>> .emit_wreg = gfx_v7_0_ring_emit_wreg,<br>
>>>> };<br>
>>>> static void gfx_v7_0_set_ring_funcs(struct amdgpu_device *adev)<br>
>>>> {<br>
>>>> @@ -5169,42 +5116,28 @@ static void gfx_v7_0_set_irq_funcs(struct<br>
>>>> amdgpu_device *adev)<br>
>>>> adev->gfx.priv_inst_irq.funcs = &gfx_v7_0_priv_inst_irq_funcs;<br>
>>>> }<br>
>>>> static void gfx_v7_0_set_gds_init(struct amdgpu_device *adev)<br>
>>>> {<br>
>>>> /* init asci gds info */<br>
>>>> adev->gds.mem.total_size = RREG32(mmGDS_VMID0_SIZE);<br>
>>>> adev->gds.gws.total_size = 64;<br>
>>>> adev->gds.oa.total_size = 16;<br>
>>>> - if (adev->gds.mem.total_size == 64 * 1024) {<br>
>>>> - adev->gds.mem.gfx_partition_size = 4096;<br>
>>>> - adev->gds.mem.cs_partition_size = 4096;<br>
>>>> -<br>
>>>> - adev->gds.gws.gfx_partition_size = 4;<br>
>>>> - adev->gds.gws.cs_partition_size = 4;<br>
>>>> -<br>
>>>> - adev->gds.oa.gfx_partition_size = 4;<br>
>>>> - adev->gds.oa.cs_partition_size = 1;<br>
>>>> - } else {<br>
>>>> - adev->gds.mem.gfx_partition_size = 1024;<br>
>>>> - adev->gds.mem.cs_partition_size = 1024;<br>
>>>> -<br>
>>>> - adev->gds.gws.gfx_partition_size = 16;<br>
>>>> - adev->gds.gws.cs_partition_size = 16;<br>
>>>> -<br>
>>>> - adev->gds.oa.gfx_partition_size = 4;<br>
>>>> - adev->gds.oa.cs_partition_size = 4;<br>
>>>> - }<br>
>>>> + adev->gds.mem.gfx_size_per_vmid = adev->gds.mem.total_size /<br>
>>>> AMDGPU_NUM_VMID;<br>
>>>> + adev->gds.mem.kfd_size_per_vmid = adev->gds.mem.total_size /<br>
>>>> AMDGPU_NUM_VMID;<br>
>>>> + adev->gds.gws.gfx_size_per_vmid = adev->gds.gws.total_size /<br>
>>>> AMDGPU_NUM_VMID;<br>
>>>> + adev->gds.gws.kfd_size_per_vmid = adev->gds.gws.total_size /<br>
>>>> AMDGPU_NUM_VMID;<br>
>>>> + adev->gds.oa.gfx_size_per_vmid = adev->gds.oa.total_size / 8; /*<br>
>>>> gfx only */<br>
>>>> + adev->gds.oa.kfd_size_per_vmid = 0;<br>
>>>> }<br>
>>>> -<br>
>>>> static void gfx_v7_0_get_cu_info(struct amdgpu_device *adev)<br>
>>>> {<br>
>>>> int i, j, k, counter, active_cu_number = 0;<br>
>>>> u32 mask, bitmap, ao_bitmap, ao_cu_mask = 0;<br>
>>>> struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info;<br>
>>>> unsigned disable_masks[4 * 2];<br>
>>>> u32 ao_cu_num;<br>
>>>> if (adev->flags & AMD_IS_APU)<br>
>>>> ao_cu_num = 2;<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
>>>> index 3882689b2d8f..b11a54bd0668 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
>>>> @@ -2154,57 +2154,34 @@ static int gfx_v8_0_sw_init(void *handle)<br>
>>>> kiq = &adev->gfx.kiq;<br>
>>>> r = amdgpu_gfx_kiq_init_ring(adev, &kiq->ring, &kiq->irq);<br>
>>>> if (r)<br>
>>>> return r;<br>
>>>> /* create MQD for all compute queues as well as KIQ for SRIOV<br>
>>>> case<br>
>>>> */<br>
>>>> r = amdgpu_gfx_compute_mqd_sw_init(adev, sizeof(struct<br>
>>>> vi_mqd_allocation));<br>
>>>> if (r)<br>
>>>> return r;<br>
>>>> - /* reserve GDS, GWS and OA resource for gfx */<br>
>>>> - r = amdgpu_bo_create_kernel(adev,<br>
>>>> adev->gds.mem.gfx_partition_size,<br>
>>>> - PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,<br>
>>>> - &adev->gds.gds_gfx_bo, NULL, NULL);<br>
>>>> - if (r)<br>
>>>> - return r;<br>
>>>> -<br>
>>>> - r = amdgpu_bo_create_kernel(adev,<br>
>>>> adev->gds.gws.gfx_partition_size,<br>
>>>> - PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,<br>
>>>> - &adev->gds.gws_gfx_bo, NULL, NULL);<br>
>>>> - if (r)<br>
>>>> - return r;<br>
>>>> -<br>
>>>> - r = amdgpu_bo_create_kernel(adev,<br>
>>>> adev->gds.oa.gfx_partition_size,<br>
>>>> - PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,<br>
>>>> - &adev->gds.oa_gfx_bo, NULL, NULL);<br>
>>>> - if (r)<br>
>>>> - return r;<br>
>>>> -<br>
>>>> adev->gfx.ce_ram_size = 0x8000;<br>
>>>> r = gfx_v8_0_gpu_early_init(adev);<br>
>>>> if (r)<br>
>>>> return r;<br>
>>>> return 0;<br>
>>>> }<br>
>>>> static int gfx_v8_0_sw_fini(void *handle)<br>
>>>> {<br>
>>>> int i;<br>
>>>> struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
>>>> - amdgpu_bo_free_kernel(&adev->gds.oa_gfx_bo, NULL, NULL);<br>
>>>> - amdgpu_bo_free_kernel(&adev->gds.gws_gfx_bo, NULL, NULL);<br>
>>>> - amdgpu_bo_free_kernel(&adev->gds.gds_gfx_bo, NULL, NULL);<br>
>>>> -<br>
>>>> for (i = 0; i < adev->gfx.num_gfx_rings; i++)<br>
>>>> amdgpu_ring_fini(&adev->gfx.gfx_ring[i]);<br>
>>>> for (i = 0; i < adev->gfx.num_compute_rings; i++)<br>
>>>> amdgpu_ring_fini(&adev->gfx.compute_ring[i]);<br>
>>>> amdgpu_gfx_compute_mqd_sw_fini(adev);<br>
>>>> amdgpu_gfx_kiq_free_ring(&adev->gfx.kiq.ring,<br>
>>>> &adev->gfx.kiq.irq);<br>
>>>> amdgpu_gfx_kiq_fini(adev);<br>
>>>> gfx_v8_0_mec_fini(adev);<br>
>>>> @@ -3850,21 +3827,21 @@ static void gfx_v8_0_config_init(struct<br>
>>>> amdgpu_device *adev)<br>
>>>> case CHIP_CARRIZO:<br>
>>>> case CHIP_STONEY:<br>
>>>> adev->gfx.config.double_offchip_lds_buf = 0;<br>
>>>> break;<br>
>>>> }<br>
>>>> }<br>
>>>> static void gfx_v8_0_gpu_init(struct amdgpu_device *adev)<br>
>>>> {<br>
>>>> u32 tmp, sh_static_mem_cfg;<br>
>>>> - int i;<br>
>>>> + int i, vmid;<br>
>>>> WREG32_FIELD(GRBM_CNTL, READ_TIMEOUT, 0xFF);<br>
>>>> WREG32(mmGB_ADDR_CONFIG, adev->gfx.config.gb_addr_config);<br>
>>>> WREG32(mmHDP_ADDR_CONFIG, adev->gfx.config.gb_addr_config);<br>
>>>> WREG32(mmDMIF_ADDR_CALC, adev->gfx.config.gb_addr_config);<br>
>>>> gfx_v8_0_tiling_mode_table_init(adev);<br>
>>>> gfx_v8_0_setup_rb(adev);<br>
>>>> gfx_v8_0_get_cu_info(adev);<br>
>>>> gfx_v8_0_config_init(adev);<br>
>>>> @@ -3927,20 +3904,41 @@ static void gfx_v8_0_gpu_init(struct<br>
>>>> amdgpu_device<br>
>>>> *adev)<br>
>>>> tmp = RREG32(mmSPI_ARB_PRIORITY);<br>
>>>> tmp = REG_SET_FIELD(tmp, SPI_ARB_PRIORITY, PIPE_ORDER_TS0, 2);<br>
>>>> tmp = REG_SET_FIELD(tmp, SPI_ARB_PRIORITY, PIPE_ORDER_TS1, 2);<br>
>>>> tmp = REG_SET_FIELD(tmp, SPI_ARB_PRIORITY, PIPE_ORDER_TS2, 2);<br>
>>>> tmp = REG_SET_FIELD(tmp, SPI_ARB_PRIORITY, PIPE_ORDER_TS3, 2);<br>
>>>> WREG32(mmSPI_ARB_PRIORITY, tmp);<br>
>>>> mutex_unlock(&adev->grbm_idx_mutex);<br>
>>>> + for (vmid = 0; vmid < AMDGPU_NUM_VMID; vmid++) {<br>
>>>> + unsigned gds_size, gws_size, oa_size;<br>
>>>> +<br>
>>>> + if (vmid <<br>
>>>> adev->vm_manager.id_mgr[AMDGPU_GFXHUB].num_ids)<br>
>>>> {<br>
>>>> + gds_size = adev->gds.mem.gfx_size_per_vmid;<br>
>>>> + gws_size = adev->gds.gws.gfx_size_per_vmid;<br>
>>>> + oa_size = adev->gds.oa.gfx_size_per_vmid;<br>
>>>> + } else {<br>
>>>> + gds_size = adev->gds.mem.kfd_size_per_vmid;<br>
>>>> + gws_size = adev->gds.gws.kfd_size_per_vmid;<br>
>>>> + oa_size = adev->gds.oa.kfd_size_per_vmid;<br>
>>>> + }<br>
>>>> +<br>
>>>> + WREG32(amdgpu_gds_reg_offset[vmid].mem_base, vmid *<br>
>>>> gds_size);<br>
>>>> + WREG32(amdgpu_gds_reg_offset[vmid].mem_size, gds_size);<br>
>>>> + WREG32(amdgpu_gds_reg_offset[vmid].gws,<br>
>>>> + (vmid * gws_size) |<br>
>>>> + (gws_size << GDS_GWS_VMID0__SIZE__SHIFT));<br>
>>>> + WREG32(amdgpu_gds_reg_offset[vmid].oa,<br>
>>>> + ((1 << oa_size) - 1) << (vmid * oa_size));<br>
>>>> + }<br>
>>>> }<br>
>>>> static void gfx_v8_0_wait_for_rlc_serdes(struct amdgpu_device<br>
>>>> *adev)<br>
>>>> {<br>
>>>> u32 i, j, k;<br>
>>>> u32 mask;<br>
>>>> mutex_lock(&adev->grbm_idx_mutex);<br>
>>>> for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {<br>
>>>> for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {<br>
>>>> @@ -5383,68 +5381,20 @@ static uint64_t<br>
>>>> gfx_v8_0_get_gpu_clock_counter(struct amdgpu_device *adev)<br>
>>>> uint64_t clock;<br>
>>>> mutex_lock(&adev->gfx.gpu_clock_mutex);<br>
>>>> WREG32(mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);<br>
>>>> clock = (uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_LSB) |<br>
>>>> ((uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL);<br>
>>>> mutex_unlock(&adev->gfx.gpu_clock_mutex);<br>
>>>> return clock;<br>
>>>> }<br>
>>>> -static void gfx_v8_0_ring_emit_gds_switch(struct amdgpu_ring *ring,<br>
>>>> - uint32_t vmid,<br>
>>>> - uint32_t gds_base, uint32_t<br>
>>>> gds_size,<br>
>>>> - uint32_t gws_base, uint32_t<br>
>>>> gws_size,<br>
>>>> - uint32_t oa_base, uint32_t<br>
>>>> oa_size)<br>
>>>> -{<br>
>>>> - gds_base = gds_base >> AMDGPU_GDS_SHIFT;<br>
>>>> - gds_size = gds_size >> AMDGPU_GDS_SHIFT;<br>
>>>> -<br>
>>>> - gws_base = gws_base >> AMDGPU_GWS_SHIFT;<br>
>>>> - gws_size = gws_size >> AMDGPU_GWS_SHIFT;<br>
>>>> -<br>
>>>> - oa_base = oa_base >> AMDGPU_OA_SHIFT;<br>
>>>> - oa_size = oa_size >> AMDGPU_OA_SHIFT;<br>
>>>> -<br>
>>>> - /* GDS Base */<br>
>>>> - amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));<br>
>>>> - amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</body>
</html>