Merge remote-tracking branch 'airlied/drm-next' into drm-misc-next
authorSean Paul <seanpaul@chromium.org>
Thu, 18 May 2017 13:24:30 +0000 (09:24 -0400)
committerSean Paul <seanpaul@chromium.org>
Thu, 18 May 2017 13:24:30 +0000 (09:24 -0400)
Picking up drm-next @ 4.12-rc1 in order to apply Michal Hocko's vmalloc patch set

Signed-off-by: Sean Paul <seanpaul@chromium.org>
20 files changed:
1  2 
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/amd/amdgpu/ci_dpm.c
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
drivers/gpu/drm/amd/amdgpu/dce_virtual.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
drivers/gpu/drm/amd/amdgpu/soc15.c
drivers/gpu/drm/radeon/cik.c
drivers/gpu/drm/sti/sti_compositor.c

  #include <linux/hashtable.h>
  #include <linux/dma-fence.h>
  
 -#include <ttm/ttm_bo_api.h>
 -#include <ttm/ttm_bo_driver.h>
 -#include <ttm/ttm_placement.h>
 -#include <ttm/ttm_module.h>
 -#include <ttm/ttm_execbuf_util.h>
 +#include <drm/ttm/ttm_bo_api.h>
 +#include <drm/ttm/ttm_bo_driver.h>
 +#include <drm/ttm/ttm_placement.h>
 +#include <drm/ttm/ttm_module.h>
 +#include <drm/ttm/ttm_execbuf_util.h>
  
  #include <drm/drmP.h>
  #include <drm/drm_gem.h>
@@@ -110,6 -110,7 +110,7 @@@ extern int amdgpu_pos_buf_per_se
  extern int amdgpu_cntl_sb_buf_per_se;
  extern int amdgpu_param_buf_per_se;
  
+ #define AMDGPU_DEFAULT_GTT_SIZE_MB            3072ULL /* 3GB by default */
  #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS                3000
  #define AMDGPU_MAX_USEC_TIMEOUT                       100000  /* 100 ms */
  #define AMDGPU_FENCE_JIFFIES_TIMEOUT          (HZ / 2)
@@@ -966,6 -967,8 +967,8 @@@ struct amdgpu_gfx_config 
        unsigned mc_arb_ramcfg;
        unsigned gb_addr_config;
        unsigned num_rbs;
+       unsigned gs_vgt_table_depth;
+       unsigned gs_prim_buffer_depth;
  
        uint32_t tile_mode_array[32];
        uint32_t macrotile_mode_array[16];
  struct amdgpu_cu_info {
        uint32_t number; /* total active CU number */
        uint32_t ao_cu_mask;
+       uint32_t wave_front_size;
        uint32_t bitmap[4][4];
  };
  
@@@ -1000,10 -1004,10 +1004,10 @@@ struct amdgpu_ngg_buf 
  };
  
  enum {
-       PRIM = 0,
-       POS,
-       CNTL,
-       PARAM,
+       NGG_PRIM = 0,
+       NGG_POS,
+       NGG_CNTL,
+       NGG_PARAM,
        NGG_BUF_MAX
  };
  
@@@ -1125,6 -1129,7 +1129,7 @@@ struct amdgpu_job 
        void                    *owner;
        uint64_t                fence_ctx; /* the fence_context this job uses */
        bool                    vm_needs_flush;
+       bool                    need_pipeline_sync;
        unsigned                vm_id;
        uint64_t                vm_pd_addr;
        uint32_t                gds_base, gds_size;
@@@ -1704,9 -1709,6 +1709,6 @@@ void amdgpu_mm_wdoorbell64(struct amdgp
  #define WREG32_FIELD_OFFSET(reg, offset, field, val)  \
        WREG32(mm##reg + offset, (RREG32(mm##reg + offset) & ~REG_FIELD_MASK(reg, field)) | (val) << REG_FIELD_SHIFT(reg, field))
  
- #define WREG32_FIELD15(ip, idx, reg, field, val)      \
-       WREG32(SOC15_REG_OFFSET(ip, idx, mm##reg), (RREG32(SOC15_REG_OFFSET(ip, idx, mm##reg)) & ~REG_FIELD_MASK(reg, field)) | (val) << REG_FIELD_SHIFT(reg, field))
  /*
   * BIOS helpers.
   */
@@@ -39,7 -39,7 +39,7 @@@
  #include <linux/module.h>
  #include <linux/pm_runtime.h>
  #include <linux/vga_switcheroo.h>
 -#include "drm_crtc_helper.h"
 +#include <drm/drm_crtc_helper.h>
  
  #include "amdgpu.h"
  #include "amdgpu_irq.h"
   * - 3.11.0 - Add support for sensor query info (clocks, temp, etc).
   * - 3.12.0 - Add query for double offchip LDS buffers
   * - 3.13.0 - Add PRT support
+  * - 3.14.0 - Fix race in amdgpu_ctx_get_fence() and note new functionality
+  * - 3.15.0 - Export more gpu info for gfx9
   */
  #define KMS_DRIVER_MAJOR      3
- #define KMS_DRIVER_MINOR      13
+ #define KMS_DRIVER_MINOR      15
  #define KMS_DRIVER_PATCHLEVEL 0
  
  int amdgpu_vram_limit = 0;
@@@ -453,7 -455,9 +455,9 @@@ static const struct pci_device_id pciid
        {0x1002, 0x6861, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT},
        {0x1002, 0x6862, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT},
        {0x1002, 0x6863, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT},
+       {0x1002, 0x6864, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT},
        {0x1002, 0x6867, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT},
+       {0x1002, 0x6868, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT},
        {0x1002, 0x686c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT},
        {0x1002, 0x687f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT},
        {0, 0, 0}
@@@ -24,7 -24,7 +24,7 @@@
   */
  
  #include <linux/firmware.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_psp.h"
  #include "amdgpu_ucode.h"
@@@ -55,6 -55,8 +55,8 @@@ static int psp_sw_init(void *handle
                psp->bootloader_load_sos = psp_v3_1_bootloader_load_sos;
                psp->prep_cmd_buf = psp_v3_1_prep_cmd_buf;
                psp->ring_init = psp_v3_1_ring_init;
+               psp->ring_create = psp_v3_1_ring_create;
+               psp->ring_destroy = psp_v3_1_ring_destroy;
                psp->cmd_submit = psp_v3_1_cmd_submit;
                psp->compare_sram_data = psp_v3_1_compare_sram_data;
                psp->smu_reload_quirk = psp_v3_1_smu_reload_quirk;
@@@ -152,11 -154,6 +154,6 @@@ static void psp_prep_tmr_cmd_buf(struc
  static int psp_tmr_init(struct psp_context *psp)
  {
        int ret;
-       struct psp_gfx_cmd_resp *cmd;
-       cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
-       if (!cmd)
-               return -ENOMEM;
  
        /*
         * Allocate 3M memory aligned to 1M from Frame Buffer (local
        ret = amdgpu_bo_create_kernel(psp->adev, 0x300000, 0x100000,
                                      AMDGPU_GEM_DOMAIN_VRAM,
                                      &psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
-       if (ret)
-               goto failed;
+       return ret;
+ }
+ static int psp_tmr_load(struct psp_context *psp)
+ {
+       int ret;
+       struct psp_gfx_cmd_resp *cmd;
+       cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
+       if (!cmd)
+               return -ENOMEM;
  
        psp_prep_tmr_cmd_buf(cmd, psp->tmr_mc_addr, 0x300000);
  
        ret = psp_cmd_submit_buf(psp, NULL, cmd,
                                 psp->fence_buf_mc_addr, 1);
        if (ret)
-               goto failed_mem;
+               goto failed;
  
        kfree(cmd);
  
        return 0;
  
- failed_mem:
-       amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
  failed:
        kfree(cmd);
        return ret;
@@@ -203,104 -208,78 +208,78 @@@ static void psp_prep_asd_cmd_buf(struc
        cmd->cmd.cmd_load_ta.cmd_buf_len = shared_size;
  }
  
- static int psp_asd_load(struct psp_context *psp)
+ static int psp_asd_init(struct psp_context *psp)
  {
        int ret;
-       struct amdgpu_bo *asd_bo, *asd_shared_bo;
-       uint64_t asd_mc_addr, asd_shared_mc_addr;
-       void *asd_buf, *asd_shared_buf;
-       struct psp_gfx_cmd_resp *cmd;
-       cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
-       if (!cmd)
-               return -ENOMEM;
  
        /*
         * Allocate 16k memory aligned to 4k from Frame Buffer (local
         * physical) for shared ASD <-> Driver
         */
-       ret = amdgpu_bo_create_kernel(psp->adev, PSP_ASD_SHARED_MEM_SIZE, PAGE_SIZE,
-                                     AMDGPU_GEM_DOMAIN_VRAM,
-                                     &asd_shared_bo, &asd_shared_mc_addr, &asd_buf);
-       if (ret)
-               goto failed;
+       ret = amdgpu_bo_create_kernel(psp->adev, PSP_ASD_SHARED_MEM_SIZE,
+                                     PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM,
+                                     &psp->asd_shared_bo,
+                                     &psp->asd_shared_mc_addr,
+                                     &psp->asd_shared_buf);
  
-       /*
-        * Allocate 256k memory aligned to 4k from Frame Buffer (local
-        * physical) for ASD firmware
-        */
-       ret = amdgpu_bo_create_kernel(psp->adev, PSP_ASD_BIN_SIZE, PAGE_SIZE,
-                                     AMDGPU_GEM_DOMAIN_VRAM,
-                                     &asd_bo, &asd_mc_addr, &asd_buf);
-       if (ret)
-               goto failed_mem;
+       return ret;
+ }
+ static int psp_asd_load(struct psp_context *psp)
+ {
+       int ret;
+       struct psp_gfx_cmd_resp *cmd;
+       cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
+       if (!cmd)
+               return -ENOMEM;
  
-       memcpy(asd_buf, psp->asd_start_addr, psp->asd_ucode_size);
+       memset(psp->fw_pri_buf, 0, PSP_1_MEG);
+       memcpy(psp->fw_pri_buf, psp->asd_start_addr, psp->asd_ucode_size);
  
-       psp_prep_asd_cmd_buf(cmd, asd_mc_addr, asd_shared_mc_addr,
+       psp_prep_asd_cmd_buf(cmd, psp->fw_pri_mc_addr, psp->asd_shared_mc_addr,
                             psp->asd_ucode_size, PSP_ASD_SHARED_MEM_SIZE);
  
        ret = psp_cmd_submit_buf(psp, NULL, cmd,
                                 psp->fence_buf_mc_addr, 2);
-       if (ret)
-               goto failed_mem1;
  
-       amdgpu_bo_free_kernel(&asd_bo, &asd_mc_addr, &asd_buf);
-       amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf);
        kfree(cmd);
  
-       return 0;
- failed_mem1:
-       amdgpu_bo_free_kernel(&asd_bo, &asd_mc_addr, &asd_buf);
- failed_mem:
-       amdgpu_bo_free_kernel(&asd_shared_bo, &asd_shared_mc_addr, &asd_shared_buf);
- failed:
-       kfree(cmd);
        return ret;
  }
  
- static int psp_load_fw(struct amdgpu_device *adev)
+ static int psp_hw_start(struct psp_context *psp)
  {
        int ret;
-       struct psp_gfx_cmd_resp *cmd;
-       int i;
-       struct amdgpu_firmware_info *ucode;
-       struct psp_context *psp = &adev->psp;
-       cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
-       if (!cmd)
-               return -ENOMEM;
  
        ret = psp_bootloader_load_sysdrv(psp);
        if (ret)
-               goto failed;
+               return ret;
  
        ret = psp_bootloader_load_sos(psp);
        if (ret)
-               goto failed;
-       ret = psp_ring_init(psp, PSP_RING_TYPE__KM);
-       if (ret)
-               goto failed;
+               return ret;
  
-       ret = amdgpu_bo_create_kernel(adev, PSP_FENCE_BUFFER_SIZE, PAGE_SIZE,
-                                     AMDGPU_GEM_DOMAIN_VRAM,
-                                     &psp->fence_buf_bo,
-                                     &psp->fence_buf_mc_addr,
-                                     &psp->fence_buf);
+       ret = psp_ring_create(psp, PSP_RING_TYPE__KM);
        if (ret)
-               goto failed;
-       memset(psp->fence_buf, 0, PSP_FENCE_BUFFER_SIZE);
+               return ret;
  
-       ret = psp_tmr_init(psp);
+       ret = psp_tmr_load(psp);
        if (ret)
-               goto failed_mem;
+               return ret;
  
        ret = psp_asd_load(psp);
        if (ret)
-               goto failed_mem;
+               return ret;
+       return 0;
+ }
+ static int psp_np_fw_load(struct psp_context *psp)
+ {
+       int i, ret;
+       struct amdgpu_firmware_info *ucode;
+       struct amdgpu_device* adev = psp->adev;
  
        for (i = 0; i < adev->firmware.max_ucodes; i++) {
                ucode = &adev->firmware.ucode[i];
                if (ucode->ucode_id == AMDGPU_UCODE_ID_SMC &&
                    psp_smu_reload_quirk(psp))
                        continue;
+               if (amdgpu_sriov_vf(adev) &&
+                  (ucode->ucode_id == AMDGPU_UCODE_ID_SDMA0
+                   || ucode->ucode_id == AMDGPU_UCODE_ID_SDMA1
+                   || ucode->ucode_id == AMDGPU_UCODE_ID_RLC_G))
+                       /*skip ucode loading in SRIOV VF */
+                       continue;
  
-               ret = psp_prep_cmd_buf(ucode, cmd);
+               ret = psp_prep_cmd_buf(ucode, psp->cmd);
                if (ret)
-                       goto failed_mem;
+                       return ret;
  
-               ret = psp_cmd_submit_buf(psp, ucode, cmd,
+               ret = psp_cmd_submit_buf(psp, ucode, psp->cmd,
                                         psp->fence_buf_mc_addr, i + 3);
                if (ret)
-                       goto failed_mem;
+                       return ret;
  
  #if 0
                /* check if firmware loaded sucessfully */
  #endif
        }
  
-       amdgpu_bo_free_kernel(&psp->fence_buf_bo,
-                             &psp->fence_buf_mc_addr, &psp->fence_buf);
+       return 0;
+ }
+ static int psp_load_fw(struct amdgpu_device *adev)
+ {
+       int ret;
+       struct psp_context *psp = &adev->psp;
+       struct psp_gfx_cmd_resp *cmd;
+       cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
+       if (!cmd)
+               return -ENOMEM;
+       psp->cmd = cmd;
+       ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,
+                                     AMDGPU_GEM_DOMAIN_GTT,
+                                     &psp->fw_pri_bo,
+                                     &psp->fw_pri_mc_addr,
+                                     &psp->fw_pri_buf);
+       if (ret)
+               goto failed;
+       ret = amdgpu_bo_create_kernel(adev, PSP_FENCE_BUFFER_SIZE, PAGE_SIZE,
+                                     AMDGPU_GEM_DOMAIN_VRAM,
+                                     &psp->fence_buf_bo,
+                                     &psp->fence_buf_mc_addr,
+                                     &psp->fence_buf);
+       if (ret)
+               goto failed_mem1;
+       memset(psp->fence_buf, 0, PSP_FENCE_BUFFER_SIZE);
+       ret = psp_ring_init(psp, PSP_RING_TYPE__KM);
+       if (ret)
+               goto failed_mem1;
+       ret = psp_tmr_init(psp);
+       if (ret)
+               goto failed_mem;
+       ret = psp_asd_init(psp);
+       if (ret)
+               goto failed_mem;
+       ret = psp_hw_start(psp);
+       if (ret)
+               goto failed_mem;
+       ret = psp_np_fw_load(psp);
+       if (ret)
+               goto failed_mem;
        kfree(cmd);
  
        return 0;
  failed_mem:
        amdgpu_bo_free_kernel(&psp->fence_buf_bo,
                              &psp->fence_buf_mc_addr, &psp->fence_buf);
+ failed_mem1:
+       amdgpu_bo_free_kernel(&psp->fw_pri_bo,
+                             &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
  failed:
        kfree(cmd);
        return ret;
@@@ -379,12 -418,24 +418,24 @@@ static int psp_hw_fini(void *handle
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
        struct psp_context *psp = &adev->psp;
  
-       if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)
-               amdgpu_ucode_fini_bo(adev);
+       if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
+               return 0;
+       amdgpu_ucode_fini_bo(adev);
+       psp_ring_destroy(psp, PSP_RING_TYPE__KM);
  
        if (psp->tmr_buf)
                amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
  
+       if (psp->fw_pri_buf)
+               amdgpu_bo_free_kernel(&psp->fw_pri_bo,
+                                     &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
+       if (psp->fence_buf_bo)
+               amdgpu_bo_free_kernel(&psp->fence_buf_bo,
+                                     &psp->fence_buf_mc_addr, &psp->fence_buf);
        return 0;
  }
  
@@@ -397,18 -448,30 +448,30 @@@ static int psp_resume(void *handle
  {
        int ret;
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+       struct psp_context *psp = &adev->psp;
  
        if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
                return 0;
  
+       DRM_INFO("PSP is resuming...\n");
        mutex_lock(&adev->firmware.mutex);
  
-       ret = psp_load_fw(adev);
+       ret = psp_hw_start(psp);
        if (ret)
-               DRM_ERROR("PSP resume failed\n");
+               goto failed;
+       ret = psp_np_fw_load(psp);
+       if (ret)
+               goto failed;
  
        mutex_unlock(&adev->firmware.mutex);
  
+       return 0;
+ failed:
+       DRM_ERROR("PSP resume failed\n");
+       mutex_unlock(&adev->firmware.mutex);
        return ret;
  }
  
   *    Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
   *    Dave Airlie
   */
 -#include <ttm/ttm_bo_api.h>
 -#include <ttm/ttm_bo_driver.h>
 -#include <ttm/ttm_placement.h>
 -#include <ttm/ttm_module.h>
 -#include <ttm/ttm_page_alloc.h>
 +#include <drm/ttm/ttm_bo_api.h>
 +#include <drm/ttm/ttm_bo_driver.h>
 +#include <drm/ttm/ttm_placement.h>
 +#include <drm/ttm/ttm_module.h>
 +#include <drm/ttm/ttm_page_alloc.h>
  #include <drm/drmP.h>
  #include <drm/amdgpu_drm.h>
  #include <linux/seq_file.h>
@@@ -203,7 -203,9 +203,9 @@@ static void amdgpu_evict_flags(struct t
        abo = container_of(bo, struct amdgpu_bo, tbo);
        switch (bo->mem.mem_type) {
        case TTM_PL_VRAM:
-               if (adev->mman.buffer_funcs_ring->ready == false) {
+               if (adev->mman.buffer_funcs &&
+                   adev->mman.buffer_funcs_ring &&
+                   adev->mman.buffer_funcs_ring->ready == false) {
                        amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU);
                } else {
                        amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT);
@@@ -763,7 -765,7 +765,7 @@@ int amdgpu_ttm_recover_gart(struct amdg
  {
        struct amdgpu_ttm_tt *gtt, *tmp;
        struct ttm_mem_reg bo_mem;
-       uint32_t flags;
+       uint64_t flags;
        int r;
  
        bo_mem.mem_type = TTM_PL_TT;
@@@ -1038,11 -1040,17 +1040,17 @@@ uint64_t amdgpu_ttm_tt_pte_flags(struc
  static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
                                            const struct ttm_place *place)
  {
-       if (bo->mem.mem_type == TTM_PL_VRAM &&
-           bo->mem.start == AMDGPU_BO_INVALID_OFFSET) {
-               unsigned long num_pages = bo->mem.num_pages;
-               struct drm_mm_node *node = bo->mem.mm_node;
+       unsigned long num_pages = bo->mem.num_pages;
+       struct drm_mm_node *node = bo->mem.mm_node;
+       if (bo->mem.start != AMDGPU_BO_INVALID_OFFSET)
+               return ttm_bo_eviction_valuable(bo, place);
+       switch (bo->mem.mem_type) {
+       case TTM_PL_TT:
+               return true;
  
+       case TTM_PL_VRAM:
                /* Check each drm MM node individually */
                while (num_pages) {
                        if (place->fpfn < (node->start + node->size) &&
                        num_pages -= node->size;
                        ++node;
                }
+               break;
  
-               return false;
+       default:
+               break;
        }
  
        return ttm_bo_eviction_valuable(bo, place);
@@@ -1188,7 -1198,7 +1198,7 @@@ void amdgpu_ttm_fini(struct amdgpu_devi
                return;
        amdgpu_ttm_debugfs_fini(adev);
        if (adev->stollen_vga_memory) {
-               r = amdgpu_bo_reserve(adev->stollen_vga_memory, false);
+               r = amdgpu_bo_reserve(adev->stollen_vga_memory, true);
                if (r == 0) {
                        amdgpu_bo_unpin(adev->stollen_vga_memory);
                        amdgpu_bo_unreserve(adev->stollen_vga_memory);
@@@ -1401,6 -1411,8 +1411,8 @@@ error_free
  
  #if defined(CONFIG_DEBUG_FS)
  
+ extern void amdgpu_gtt_mgr_print(struct seq_file *m, struct ttm_mem_type_manager
+                                *man);
  static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
  {
        struct drm_info_node *node = (struct drm_info_node *)m->private;
        spin_lock(&glob->lru_lock);
        drm_mm_print(mm, &p);
        spin_unlock(&glob->lru_lock);
-       if (ttm_pl == TTM_PL_VRAM)
+       switch (ttm_pl) {
+       case TTM_PL_VRAM:
                seq_printf(m, "man size:%llu pages, ram usage:%lluMB, vis usage:%lluMB\n",
                           adev->mman.bdev.man[ttm_pl].size,
                           (u64)atomic64_read(&adev->vram_usage) >> 20,
                           (u64)atomic64_read(&adev->vram_vis_usage) >> 20);
+               break;
+       case TTM_PL_TT:
+               amdgpu_gtt_mgr_print(m, &adev->mman.bdev.man[TTM_PL_TT]);
+               break;
+       }
        return 0;
  }
  
@@@ -22,7 -22,7 +22,7 @@@
   */
  
  #include <linux/firmware.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_pm.h"
  #include "amdgpu_ucode.h"
@@@ -1267,30 -1267,33 +1267,33 @@@ static int ci_dpm_set_fan_speed_percent
  
  static void ci_dpm_set_fan_control_mode(struct amdgpu_device *adev, u32 mode)
  {
-       if (mode) {
-               /* stop auto-manage */
+       switch (mode) {
+       case AMD_FAN_CTRL_NONE:
                if (adev->pm.dpm.fan.ucode_fan_control)
                        ci_fan_ctrl_stop_smc_fan_control(adev);
-               ci_fan_ctrl_set_static_mode(adev, mode);
-       } else {
-               /* restart auto-manage */
+               ci_dpm_set_fan_speed_percent(adev, 100);
+               break;
+       case AMD_FAN_CTRL_MANUAL:
+               if (adev->pm.dpm.fan.ucode_fan_control)
+                       ci_fan_ctrl_stop_smc_fan_control(adev);
+               break;
+       case AMD_FAN_CTRL_AUTO:
                if (adev->pm.dpm.fan.ucode_fan_control)
                        ci_thermal_start_smc_fan_control(adev);
-               else
-                       ci_fan_ctrl_set_default_mode(adev);
+               break;
+       default:
+               break;
        }
  }
  
  static u32 ci_dpm_get_fan_control_mode(struct amdgpu_device *adev)
  {
        struct ci_power_info *pi = ci_get_pi(adev);
-       u32 tmp;
  
        if (pi->fan_is_controlled_by_smc)
-               return 0;
-       tmp = RREG32_SMC(ixCG_FDO_CTRL2) & CG_FDO_CTRL2__FDO_PWM_MODE_MASK;
-       return (tmp >> CG_FDO_CTRL2__FDO_PWM_MODE__SHIFT);
+               return AMD_FAN_CTRL_AUTO;
+       else
+               return AMD_FAN_CTRL_MANUAL;
  }
  
  #if 0
@@@ -3036,6 -3039,7 +3039,7 @@@ static int ci_populate_single_memory_le
                                                      memory_clock,
                                                      &memory_level->MinVddcPhases);
  
+       memory_level->EnabledForActivity = 1;
        memory_level->EnabledForThrottle = 1;
        memory_level->UpH = 0;
        memory_level->DownH = 100;
@@@ -3468,8 -3472,6 +3472,6 @@@ static int ci_populate_all_memory_level
                        return ret;
        }
  
-       pi->smc_state_table.MemoryLevel[0].EnabledForActivity = 1;
        if ((dpm_table->mclk_table.count >= 2) &&
            ((adev->pdev->device == 0x67B0) || (adev->pdev->device == 0x67B1))) {
                pi->smc_state_table.MemoryLevel[1].MinVddc =
@@@ -20,7 -20,7 +20,7 @@@
   * OTHER DEALINGS IN THE SOFTWARE.
   *
   */
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_pm.h"
  #include "amdgpu_i2c.h"
@@@ -2230,7 -2230,7 +2230,7 @@@ static int dce_v10_0_crtc_do_set_base(s
        if (!atomic && fb && fb != crtc->primary->fb) {
                amdgpu_fb = to_amdgpu_framebuffer(fb);
                abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
-               r = amdgpu_bo_reserve(abo, false);
+               r = amdgpu_bo_reserve(abo, true);
                if (unlikely(r != 0))
                        return r;
                amdgpu_bo_unpin(abo);
@@@ -2589,7 -2589,7 +2589,7 @@@ static int dce_v10_0_crtc_cursor_set2(s
  unpin:
        if (amdgpu_crtc->cursor_bo) {
                struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo);
-               ret = amdgpu_bo_reserve(aobj, false);
+               ret = amdgpu_bo_reserve(aobj, true);
                if (likely(ret == 0)) {
                        amdgpu_bo_unpin(aobj);
                        amdgpu_bo_unreserve(aobj);
@@@ -2720,7 -2720,7 +2720,7 @@@ static void dce_v10_0_crtc_disable(stru
  
                amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
                abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
-               r = amdgpu_bo_reserve(abo, false);
+               r = amdgpu_bo_reserve(abo, true);
                if (unlikely(r))
                        DRM_ERROR("failed to reserve abo before unpin\n");
                else {
@@@ -20,7 -20,7 +20,7 @@@
   * OTHER DEALINGS IN THE SOFTWARE.
   *
   */
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_pm.h"
  #include "amdgpu_i2c.h"
@@@ -2214,7 -2214,7 +2214,7 @@@ static int dce_v11_0_crtc_do_set_base(s
        if (!atomic && fb && fb != crtc->primary->fb) {
                amdgpu_fb = to_amdgpu_framebuffer(fb);
                abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
-               r = amdgpu_bo_reserve(abo, false);
+               r = amdgpu_bo_reserve(abo, true);
                if (unlikely(r != 0))
                        return r;
                amdgpu_bo_unpin(abo);
@@@ -2609,7 -2609,7 +2609,7 @@@ static int dce_v11_0_crtc_cursor_set2(s
  unpin:
        if (amdgpu_crtc->cursor_bo) {
                struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo);
-               ret = amdgpu_bo_reserve(aobj, false);
+               ret = amdgpu_bo_reserve(aobj, true);
                if (likely(ret == 0)) {
                        amdgpu_bo_unpin(aobj);
                        amdgpu_bo_unreserve(aobj);
@@@ -2740,7 -2740,7 +2740,7 @@@ static void dce_v11_0_crtc_disable(stru
  
                amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
                abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
-               r = amdgpu_bo_reserve(abo, false);
+               r = amdgpu_bo_reserve(abo, true);
                if (unlikely(r))
                        DRM_ERROR("failed to reserve abo before unpin\n");
                else {
@@@ -20,7 -20,7 +20,7 @@@
   * OTHER DEALINGS IN THE SOFTWARE.
   *
   */
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_pm.h"
  #include "amdgpu_i2c.h"
@@@ -979,7 -979,7 +979,7 @@@ static void dce_v6_0_program_watermarks
        u32 priority_a_mark = 0, priority_b_mark = 0;
        u32 priority_a_cnt = PRIORITY_OFF;
        u32 priority_b_cnt = PRIORITY_OFF;
-       u32 tmp, arb_control3;
+       u32 tmp, arb_control3, lb_vblank_lead_lines = 0;
        fixed20_12 a, b, c;
  
        if (amdgpu_crtc->base.enabled && num_heads && mode) {
                c.full = dfixed_div(c, a);
                priority_b_mark = dfixed_trunc(c);
                priority_b_cnt |= priority_b_mark & PRIORITY_MARK_MASK;
+               lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode->crtc_hdisplay);
        }
  
        /* select wm A */
        /* save values for DPM */
        amdgpu_crtc->line_time = line_time;
        amdgpu_crtc->wm_high = latency_watermark_a;
+       /* Save number of lines the linebuffer leads before the scanout */
+       amdgpu_crtc->lb_vblank_lead_lines = lb_vblank_lead_lines;
  }
  
  /* watermark setup */
@@@ -1640,7 -1645,7 +1645,7 @@@ static int dce_v6_0_crtc_do_set_base(st
        if (!atomic && fb && fb != crtc->primary->fb) {
                amdgpu_fb = to_amdgpu_framebuffer(fb);
                abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
-               r = amdgpu_bo_reserve(abo, false);
+               r = amdgpu_bo_reserve(abo, true);
                if (unlikely(r != 0))
                        return r;
                amdgpu_bo_unpin(abo);
@@@ -1957,7 -1962,7 +1962,7 @@@ static int dce_v6_0_crtc_cursor_set2(st
  unpin:
        if (amdgpu_crtc->cursor_bo) {
                struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo);
-               ret = amdgpu_bo_reserve(aobj, false);
+               ret = amdgpu_bo_reserve(aobj, true);
                if (likely(ret == 0)) {
                        amdgpu_bo_unpin(aobj);
                        amdgpu_bo_unreserve(aobj);
@@@ -2083,7 -2088,7 +2088,7 @@@ static void dce_v6_0_crtc_disable(struc
  
                amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
                abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
-               r = amdgpu_bo_reserve(abo, false);
+               r = amdgpu_bo_reserve(abo, true);
                if (unlikely(r))
                        DRM_ERROR("failed to reserve abo before unpin\n");
                else {
@@@ -20,7 -20,7 +20,7 @@@
   * OTHER DEALINGS IN THE SOFTWARE.
   *
   */
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_pm.h"
  #include "amdgpu_i2c.h"
@@@ -2089,7 -2089,7 +2089,7 @@@ static int dce_v8_0_crtc_do_set_base(st
        if (!atomic && fb && fb != crtc->primary->fb) {
                amdgpu_fb = to_amdgpu_framebuffer(fb);
                abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
-               r = amdgpu_bo_reserve(abo, false);
+               r = amdgpu_bo_reserve(abo, true);
                if (unlikely(r != 0))
                        return r;
                amdgpu_bo_unpin(abo);
@@@ -2440,7 -2440,7 +2440,7 @@@ static int dce_v8_0_crtc_cursor_set2(st
  unpin:
        if (amdgpu_crtc->cursor_bo) {
                struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo);
-               ret = amdgpu_bo_reserve(aobj, false);
+               ret = amdgpu_bo_reserve(aobj, true);
                if (likely(ret == 0)) {
                        amdgpu_bo_unpin(aobj);
                        amdgpu_bo_unreserve(aobj);
@@@ -2571,7 -2571,7 +2571,7 @@@ static void dce_v8_0_crtc_disable(struc
  
                amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
                abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
-               r = amdgpu_bo_reserve(abo, false);
+               r = amdgpu_bo_reserve(abo, true);
                if (unlikely(r))
                        DRM_ERROR("failed to reserve abo before unpin\n");
                else {
@@@ -20,7 -20,7 +20,7 @@@
   * OTHER DEALINGS IN THE SOFTWARE.
   *
   */
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_pm.h"
  #include "amdgpu_i2c.h"
@@@ -248,7 -248,7 +248,7 @@@ static void dce_virtual_crtc_disable(st
  
                amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
                abo = gem_to_amdgpu_bo(amdgpu_fb->obj);
-               r = amdgpu_bo_reserve(abo, false);
+               r = amdgpu_bo_reserve(abo, true);
                if (unlikely(r))
                        DRM_ERROR("failed to reserve abo before unpin\n");
                else {
@@@ -21,7 -21,7 +21,7 @@@
   *
   */
  #include <linux/firmware.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_ih.h"
  #include "amdgpu_gfx.h"
@@@ -1935,7 -1935,7 +1935,7 @@@ static void gfx_v7_0_gpu_init(struct am
                                   INDEX_STRIDE, 3);
  
        mutex_lock(&adev->srbm_mutex);
-       for (i = 0; i < adev->vm_manager.num_ids; i++) {
+       for (i = 0; i < adev->vm_manager.id_mgr[0].num_ids; i++) {
                if (i == 0)
                        sh_mem_base = 0;
                else
@@@ -2792,7 -2792,7 +2792,7 @@@ static void gfx_v7_0_cp_compute_fini(st
                struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];
  
                if (ring->mqd_obj) {
-                       r = amdgpu_bo_reserve(ring->mqd_obj, false);
+                       r = amdgpu_bo_reserve(ring->mqd_obj, true);
                        if (unlikely(r != 0))
                                dev_warn(adev->dev, "(%d) reserve MQD bo failed\n", r);
  
@@@ -2810,7 -2810,7 +2810,7 @@@ static void gfx_v7_0_mec_fini(struct am
        int r;
  
        if (adev->gfx.mec.hpd_eop_obj) {
-               r = amdgpu_bo_reserve(adev->gfx.mec.hpd_eop_obj, false);
+               r = amdgpu_bo_reserve(adev->gfx.mec.hpd_eop_obj, true);
                if (unlikely(r != 0))
                        dev_warn(adev->dev, "(%d) reserve HPD EOP bo failed\n", r);
                amdgpu_bo_unpin(adev->gfx.mec.hpd_eop_obj);
@@@ -3359,7 -3359,7 +3359,7 @@@ static void gfx_v7_0_rlc_fini(struct am
  
        /* save restore block */
        if (adev->gfx.rlc.save_restore_obj) {
-               r = amdgpu_bo_reserve(adev->gfx.rlc.save_restore_obj, false);
+               r = amdgpu_bo_reserve(adev->gfx.rlc.save_restore_obj, true);
                if (unlikely(r != 0))
                        dev_warn(adev->dev, "(%d) reserve RLC sr bo failed\n", r);
                amdgpu_bo_unpin(adev->gfx.rlc.save_restore_obj);
  
        /* clear state block */
        if (adev->gfx.rlc.clear_state_obj) {
-               r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, false);
+               r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, true);
                if (unlikely(r != 0))
                        dev_warn(adev->dev, "(%d) reserve RLC c bo failed\n", r);
                amdgpu_bo_unpin(adev->gfx.rlc.clear_state_obj);
  
        /* clear state block */
        if (adev->gfx.rlc.cp_table_obj) {
-               r = amdgpu_bo_reserve(adev->gfx.rlc.cp_table_obj, false);
+               r = amdgpu_bo_reserve(adev->gfx.rlc.cp_table_obj, true);
                if (unlikely(r != 0))
                        dev_warn(adev->dev, "(%d) reserve RLC cp table bo failed\n", r);
                amdgpu_bo_unpin(adev->gfx.rlc.cp_table_obj);
@@@ -21,7 -21,7 +21,7 @@@
   *
   */
  #include <linux/firmware.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_gfx.h"
  #include "vi.h"
@@@ -1239,7 -1239,7 +1239,7 @@@ static void gfx_v8_0_rlc_fini(struct am
  
        /* clear state block */
        if (adev->gfx.rlc.clear_state_obj) {
-               r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, false);
+               r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, true);
                if (unlikely(r != 0))
                        dev_warn(adev->dev, "(%d) reserve RLC cbs bo failed\n", r);
                amdgpu_bo_unpin(adev->gfx.rlc.clear_state_obj);
  
        /* jump table block */
        if (adev->gfx.rlc.cp_table_obj) {
-               r = amdgpu_bo_reserve(adev->gfx.rlc.cp_table_obj, false);
+               r = amdgpu_bo_reserve(adev->gfx.rlc.cp_table_obj, true);
                if (unlikely(r != 0))
                        dev_warn(adev->dev, "(%d) reserve RLC cp table bo failed\n", r);
                amdgpu_bo_unpin(adev->gfx.rlc.cp_table_obj);
@@@ -1363,7 -1363,7 +1363,7 @@@ static void gfx_v8_0_mec_fini(struct am
        int r;
  
        if (adev->gfx.mec.hpd_eop_obj) {
-               r = amdgpu_bo_reserve(adev->gfx.mec.hpd_eop_obj, false);
+               r = amdgpu_bo_reserve(adev->gfx.mec.hpd_eop_obj, true);
                if (unlikely(r != 0))
                        dev_warn(adev->dev, "(%d) reserve HPD EOP bo failed\n", r);
                amdgpu_bo_unpin(adev->gfx.mec.hpd_eop_obj);
@@@ -1490,7 -1490,7 +1490,7 @@@ static int gfx_v8_0_kiq_init(struct amd
  
        memset(hpd, 0, MEC_HPD_SIZE);
  
-       r = amdgpu_bo_reserve(kiq->eop_obj, false);
+       r = amdgpu_bo_reserve(kiq->eop_obj, true);
        if (unlikely(r != 0))
                dev_warn(adev->dev, "(%d) reserve kiq eop bo failed\n", r);
        amdgpu_bo_kunmap(kiq->eop_obj);
@@@ -1932,6 -1932,7 +1932,7 @@@ static int gfx_v8_0_gpu_early_init(stru
                case 0xca:
                case 0xce:
                case 0x88:
+               case 0xe6:
                        /* B6 */
                        adev->gfx.config.max_cu_per_sh = 6;
                        break;
                adev->gfx.config.max_backends_per_se = 1;
  
                switch (adev->pdev->revision) {
+               case 0x80:
+               case 0x81:
                case 0xc0:
                case 0xc1:
                case 0xc2:
                case 0xc4:
                case 0xc8:
                case 0xc9:
+               case 0xd6:
+               case 0xda:
+               case 0xe9:
+               case 0xea:
                        adev->gfx.config.max_cu_per_sh = 3;
                        break;
+               case 0x83:
                case 0xd0:
                case 0xd1:
                case 0xd2:
+               case 0xd4:
+               case 0xdb:
+               case 0xe1:
+               case 0xe2:
                default:
                        adev->gfx.config.max_cu_per_sh = 2;
                        break;
@@@ -3890,7 -3902,7 +3902,7 @@@ static void gfx_v8_0_gpu_init(struct am
        sh_static_mem_cfg = REG_SET_FIELD(sh_static_mem_cfg, SH_STATIC_MEM_CONFIG,
                                   INDEX_STRIDE, 3);
        mutex_lock(&adev->srbm_mutex);
-       for (i = 0; i < adev->vm_manager.num_ids; i++) {
+       for (i = 0; i < adev->vm_manager.id_mgr[0].num_ids; i++) {
                vi_srbm_select(adev, 0, 0, 0, i);
                /* CP and shaders */
                if (i == 0) {
@@@ -21,7 -21,7 +21,7 @@@
   *
   */
  #include <linux/firmware.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_gfx.h"
  #include "soc15.h"
@@@ -39,7 -39,6 +39,6 @@@
  
  #define GFX9_NUM_GFX_RINGS     1
  #define GFX9_NUM_COMPUTE_RINGS 8
- #define GFX9_NUM_SE           4
  #define RLCG_UCODE_LOADING_START_ADDRESS 0x2000
  
  MODULE_FIRMWARE("amdgpu/vega10_ce.bin");
@@@ -453,7 -452,7 +452,7 @@@ static void gfx_v9_0_mec_fini(struct am
        int r;
  
        if (adev->gfx.mec.hpd_eop_obj) {
-               r = amdgpu_bo_reserve(adev->gfx.mec.hpd_eop_obj, false);
+               r = amdgpu_bo_reserve(adev->gfx.mec.hpd_eop_obj, true);
                if (unlikely(r != 0))
                        dev_warn(adev->dev, "(%d) reserve HPD EOP bo failed\n", r);
                amdgpu_bo_unpin(adev->gfx.mec.hpd_eop_obj);
                adev->gfx.mec.hpd_eop_obj = NULL;
        }
        if (adev->gfx.mec.mec_fw_obj) {
-               r = amdgpu_bo_reserve(adev->gfx.mec.mec_fw_obj, false);
+               r = amdgpu_bo_reserve(adev->gfx.mec.mec_fw_obj, true);
                if (unlikely(r != 0))
                        dev_warn(adev->dev, "(%d) reserve mec firmware bo failed\n", r);
                amdgpu_bo_unpin(adev->gfx.mec.mec_fw_obj);
@@@ -599,7 -598,7 +598,7 @@@ static int gfx_v9_0_kiq_init(struct amd
  
        memset(hpd, 0, MEC_HPD_SIZE);
  
-       r = amdgpu_bo_reserve(kiq->eop_obj, false);
+       r = amdgpu_bo_reserve(kiq->eop_obj, true);
        if (unlikely(r != 0))
                dev_warn(adev->dev, "(%d) reserve kiq eop bo failed\n", r);
        amdgpu_bo_kunmap(kiq->eop_obj);
@@@ -631,7 -630,6 +630,6 @@@ static int gfx_v9_0_kiq_init_ring(struc
                ring->pipe = 1;
        }
  
-       irq->data = ring;
        ring->queue = 0;
        ring->eop_gpu_addr = kiq->eop_gpu_addr;
        sprintf(ring->name, "kiq %d.%d.%d", ring->me, ring->pipe, ring->queue);
@@@ -647,7 -645,6 +645,6 @@@ static void gfx_v9_0_kiq_free_ring(stru
  {
        amdgpu_wb_free(ring->adev, ring->adev->virt.reg_val_offs);
        amdgpu_ring_fini(ring);
-       irq->data = NULL;
  }
  
  /* create MQD for each compute queue */
@@@ -705,19 -702,19 +702,19 @@@ static void gfx_v9_0_compute_mqd_sw_fin
  
  static uint32_t wave_read_ind(struct amdgpu_device *adev, uint32_t simd, uint32_t wave, uint32_t address)
  {
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_IND_INDEX),
+       WREG32_SOC15(GC, 0, mmSQ_IND_INDEX,
                (wave << SQ_IND_INDEX__WAVE_ID__SHIFT) |
                (simd << SQ_IND_INDEX__SIMD_ID__SHIFT) |
                (address << SQ_IND_INDEX__INDEX__SHIFT) |
                (SQ_IND_INDEX__FORCE_READ_MASK));
-       return RREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_IND_DATA));
+       return RREG32_SOC15(GC, 0, mmSQ_IND_DATA);
  }
  
  static void wave_read_regs(struct amdgpu_device *adev, uint32_t simd,
                           uint32_t wave, uint32_t thread,
                           uint32_t regno, uint32_t num, uint32_t *out)
  {
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_IND_INDEX),
+       WREG32_SOC15(GC, 0, mmSQ_IND_INDEX,
                (wave << SQ_IND_INDEX__WAVE_ID__SHIFT) |
                (simd << SQ_IND_INDEX__SIMD_ID__SHIFT) |
                (regno << SQ_IND_INDEX__INDEX__SHIFT) |
                (SQ_IND_INDEX__FORCE_READ_MASK) |
                (SQ_IND_INDEX__AUTO_INCR_MASK));
        while (num--)
-               *(out++) = RREG32(SOC15_REG_OFFSET(GC, 0, mmSQ_IND_DATA));
+               *(out++) = RREG32_SOC15(GC, 0, mmSQ_IND_DATA);
  }
  
  static void gfx_v9_0_read_wave_data(struct amdgpu_device *adev, uint32_t simd, uint32_t wave, uint32_t *dst, int *no_fields)
@@@ -774,7 -771,6 +771,6 @@@ static void gfx_v9_0_gpu_early_init(str
        switch (adev->asic_type) {
        case CHIP_VEGA10:
                adev->gfx.config.max_shader_engines = 4;
-               adev->gfx.config.max_tile_pipes = 8; //??
                adev->gfx.config.max_cu_per_sh = 16;
                adev->gfx.config.max_sh_per_se = 1;
                adev->gfx.config.max_backends_per_se = 4;
                adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
                adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
                adev->gfx.config.sc_earlyz_tile_fifo_size = 0x4C0;
+               adev->gfx.config.gs_vgt_table_depth = 32;
+               adev->gfx.config.gs_prim_buffer_depth = 1792;
                gb_addr_config = VEGA10_GB_ADDR_CONFIG_GOLDEN;
                break;
        default:
                                        adev->gfx.config.gb_addr_config,
                                        GB_ADDR_CONFIG,
                                        NUM_PIPES);
+       adev->gfx.config.max_tile_pipes =
+               adev->gfx.config.gb_addr_config_fields.num_pipes;
        adev->gfx.config.gb_addr_config_fields.num_banks = 1 <<
                        REG_GET_FIELD(
                                        adev->gfx.config.gb_addr_config,
@@@ -841,7 -843,7 +843,7 @@@ static int gfx_v9_0_ngg_create_buf(stru
        }
        size_se = size_se ? size_se : default_size_se;
  
-       ngg_buf->size = size_se * GFX9_NUM_SE;
+       ngg_buf->size = size_se * adev->gfx.config.max_shader_engines;
        r = amdgpu_bo_create_kernel(adev, ngg_buf->size,
                                    PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM,
                                    &ngg_buf->bo,
@@@ -888,7 -890,7 +890,7 @@@ static int gfx_v9_0_ngg_init(struct amd
        adev->gfx.ngg.gds_reserve_addr += adev->gds.mem.gfx_partition_size;
  
        /* Primitive Buffer */
-       r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[PRIM],
+       r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PRIM],
                                    amdgpu_prim_buf_per_se,
                                    64 * 1024);
        if (r) {
        }
  
        /* Position Buffer */
-       r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[POS],
+       r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_POS],
                                    amdgpu_pos_buf_per_se,
                                    256 * 1024);
        if (r) {
        }
  
        /* Control Sideband */
-       r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[CNTL],
+       r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_CNTL],
                                    amdgpu_cntl_sb_buf_per_se,
                                    256);
        if (r) {
        if (amdgpu_param_buf_per_se <= 0)
                goto out;
  
-       r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[PARAM],
+       r = gfx_v9_0_ngg_create_buf(adev, &adev->gfx.ngg.buf[NGG_PARAM],
                                    amdgpu_param_buf_per_se,
                                    512 * 1024);
        if (r) {
@@@ -947,47 -949,47 +949,47 @@@ static int gfx_v9_0_ngg_en(struct amdgp
  
        /* Program buffer size */
        data = 0;
-       size = adev->gfx.ngg.buf[PRIM].size / 256;
+       size = adev->gfx.ngg.buf[NGG_PRIM].size / 256;
        data = REG_SET_FIELD(data, WD_BUF_RESOURCE_1, INDEX_BUF_SIZE, size);
  
-       size = adev->gfx.ngg.buf[POS].size / 256;
+       size = adev->gfx.ngg.buf[NGG_POS].size / 256;
        data = REG_SET_FIELD(data, WD_BUF_RESOURCE_1, POS_BUF_SIZE, size);
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmWD_BUF_RESOURCE_1), data);
+       WREG32_SOC15(GC, 0, mmWD_BUF_RESOURCE_1, data);
  
        data = 0;
-       size = adev->gfx.ngg.buf[CNTL].size / 256;
+       size = adev->gfx.ngg.buf[NGG_CNTL].size / 256;
        data = REG_SET_FIELD(data, WD_BUF_RESOURCE_2, CNTL_SB_BUF_SIZE, size);
  
-       size = adev->gfx.ngg.buf[PARAM].size / 1024;
+       size = adev->gfx.ngg.buf[NGG_PARAM].size / 1024;
        data = REG_SET_FIELD(data, WD_BUF_RESOURCE_2, PARAM_BUF_SIZE, size);
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmWD_BUF_RESOURCE_2), data);
+       WREG32_SOC15(GC, 0, mmWD_BUF_RESOURCE_2, data);
  
        /* Program buffer base address */
-       base = lower_32_bits(adev->gfx.ngg.buf[PRIM].gpu_addr);
+       base = lower_32_bits(adev->gfx.ngg.buf[NGG_PRIM].gpu_addr);
        data = REG_SET_FIELD(0, WD_INDEX_BUF_BASE, BASE, base);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmWD_INDEX_BUF_BASE), data);
+       WREG32_SOC15(GC, 0, mmWD_INDEX_BUF_BASE, data);
  
-       base = upper_32_bits(adev->gfx.ngg.buf[PRIM].gpu_addr);
+       base = upper_32_bits(adev->gfx.ngg.buf[NGG_PRIM].gpu_addr);
        data = REG_SET_FIELD(0, WD_INDEX_BUF_BASE_HI, BASE_HI, base);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmWD_INDEX_BUF_BASE_HI), data);
+       WREG32_SOC15(GC, 0, mmWD_INDEX_BUF_BASE_HI, data);
  
-       base = lower_32_bits(adev->gfx.ngg.buf[POS].gpu_addr);
+       base = lower_32_bits(adev->gfx.ngg.buf[NGG_POS].gpu_addr);
        data = REG_SET_FIELD(0, WD_POS_BUF_BASE, BASE, base);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmWD_POS_BUF_BASE), data);
+       WREG32_SOC15(GC, 0, mmWD_POS_BUF_BASE, data);
  
-       base = upper_32_bits(adev->gfx.ngg.buf[POS].gpu_addr);
+       base = upper_32_bits(adev->gfx.ngg.buf[NGG_POS].gpu_addr);
        data = REG_SET_FIELD(0, WD_POS_BUF_BASE_HI, BASE_HI, base);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmWD_POS_BUF_BASE_HI), data);
+       WREG32_SOC15(GC, 0, mmWD_POS_BUF_BASE_HI, data);
  
-       base = lower_32_bits(adev->gfx.ngg.buf[CNTL].gpu_addr);
+       base = lower_32_bits(adev->gfx.ngg.buf[NGG_CNTL].gpu_addr);
        data = REG_SET_FIELD(0, WD_CNTL_SB_BUF_BASE, BASE, base);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmWD_CNTL_SB_BUF_BASE), data);
+       WREG32_SOC15(GC, 0, mmWD_CNTL_SB_BUF_BASE, data);
  
-       base = upper_32_bits(adev->gfx.ngg.buf[CNTL].gpu_addr);
+       base = upper_32_bits(adev->gfx.ngg.buf[NGG_CNTL].gpu_addr);
        data = REG_SET_FIELD(0, WD_CNTL_SB_BUF_BASE_HI, BASE_HI, base);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmWD_CNTL_SB_BUF_BASE_HI), data);
+       WREG32_SOC15(GC, 0, mmWD_CNTL_SB_BUF_BASE_HI, data);
  
        /* Clear GDS reserved memory */
        r = amdgpu_ring_alloc(ring, 17);
@@@ -1096,7 -1098,7 +1098,7 @@@ static int gfx_v9_0_sw_init(void *handl
                ring->pipe = i / 8;
                ring->queue = i % 8;
                ring->eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr + (i * MEC_HPD_SIZE);
-               sprintf(ring->name, "comp %d.%d.%d", ring->me, ring->pipe, ring->queue);
+               sprintf(ring->name, "comp_%d.%d.%d", ring->me, ring->pipe, ring->queue);
                irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + ring->pipe;
                /* type-2 packets are deprecated on MEC, use type-3 instead */
                r = amdgpu_ring_init(adev, ring, 1024,
@@@ -1203,7 -1205,7 +1205,7 @@@ static void gfx_v9_0_select_se_sh(struc
                data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_INDEX, sh_num);
                data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_INDEX, se_num);
        }
-       WREG32( SOC15_REG_OFFSET(GC, 0, mmGRBM_GFX_INDEX), data);
+       WREG32_SOC15(GC, 0, mmGRBM_GFX_INDEX, data);
  }
  
  static u32 gfx_v9_0_create_bitmask(u32 bit_width)
@@@ -1215,8 -1217,8 +1217,8 @@@ static u32 gfx_v9_0_get_rb_active_bitma
  {
        u32 data, mask;
  
-       data = RREG32(SOC15_REG_OFFSET(GC, 0, mmCC_RB_BACKEND_DISABLE));
-       data |= RREG32(SOC15_REG_OFFSET(GC, 0, mmGC_USER_RB_BACKEND_DISABLE));
+       data = RREG32_SOC15(GC, 0, mmCC_RB_BACKEND_DISABLE);
+       data |= RREG32_SOC15(GC, 0, mmGC_USER_RB_BACKEND_DISABLE);
  
        data &= CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK;
        data >>= GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT;
@@@ -1276,8 -1278,8 +1278,8 @@@ static void gfx_v9_0_init_compute_vmid(
        for (i = FIRST_COMPUTE_VMID; i < LAST_COMPUTE_VMID; i++) {
                soc15_grbm_select(adev, 0, 0, 0, i);
                /* CP and shaders */
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmSH_MEM_CONFIG), sh_mem_config);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmSH_MEM_BASES), sh_mem_bases);
+               WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, sh_mem_config);
+               WREG32_SOC15(GC, 0, mmSH_MEM_BASES, sh_mem_bases);
        }
        soc15_grbm_select(adev, 0, 0, 0, 0);
        mutex_unlock(&adev->srbm_mutex);
@@@ -1304,8 -1306,8 +1306,8 @@@ static void gfx_v9_0_gpu_init(struct am
                tmp = 0;
                tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, ALIGNMENT_MODE,
                                    SH_MEM_ALIGNMENT_MODE_UNALIGNED);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmSH_MEM_CONFIG), tmp);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmSH_MEM_BASES), 0);
+               WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, tmp);
+               WREG32_SOC15(GC, 0, mmSH_MEM_BASES, 0);
        }
        soc15_grbm_select(adev, 0, 0, 0, 0);
  
         */
        gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmPA_SC_FIFO_SIZE),
+       WREG32_SOC15(GC, 0, mmPA_SC_FIFO_SIZE,
                   (adev->gfx.config.sc_prim_fifo_size_frontend <<
                        PA_SC_FIFO_SIZE__SC_FRONTEND_PRIM_FIFO_SIZE__SHIFT) |
                   (adev->gfx.config.sc_prim_fifo_size_backend <<
@@@ -1343,7 -1345,7 +1345,7 @@@ static void gfx_v9_0_wait_for_rlc_serde
                for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
                        gfx_v9_0_select_se_sh(adev, i, j, 0xffffffff);
                        for (k = 0; k < adev->usec_timeout; k++) {
-                               if (RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SERDES_CU_MASTER_BUSY)) == 0)
+                               if (RREG32_SOC15(GC, 0, mmRLC_SERDES_CU_MASTER_BUSY) == 0)
                                        break;
                                udelay(1);
                        }
                RLC_SERDES_NONCU_MASTER_BUSY__TC0_MASTER_BUSY_MASK |
                RLC_SERDES_NONCU_MASTER_BUSY__TC1_MASTER_BUSY_MASK;
        for (k = 0; k < adev->usec_timeout; k++) {
-               if ((RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SERDES_NONCU_MASTER_BUSY)) & mask) == 0)
+               if ((RREG32_SOC15(GC, 0, mmRLC_SERDES_NONCU_MASTER_BUSY) & mask) == 0)
                        break;
                udelay(1);
        }
  static void gfx_v9_0_enable_gui_idle_interrupt(struct amdgpu_device *adev,
                                               bool enable)
  {
-       u32 tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_INT_CNTL_RING0));
+       u32 tmp = RREG32_SOC15(GC, 0, mmCP_INT_CNTL_RING0);
  
        if (enable)
                return;
        tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CMP_BUSY_INT_ENABLE, enable ? 1 : 0);
        tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, GFX_IDLE_INT_ENABLE, enable ? 1 : 0);
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_INT_CNTL_RING0), tmp);
+       WREG32_SOC15(GC, 0, mmCP_INT_CNTL_RING0, tmp);
  }
  
  void gfx_v9_0_rlc_stop(struct amdgpu_device *adev)
  {
-       u32 tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CNTL));
+       u32 tmp = RREG32_SOC15(GC, 0, mmRLC_CNTL);
  
        tmp = REG_SET_FIELD(tmp, RLC_CNTL, RLC_ENABLE_F32, 0);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CNTL), tmp);
+       WREG32_SOC15(GC, 0, mmRLC_CNTL, tmp);
  
        gfx_v9_0_enable_gui_idle_interrupt(adev, false);
  
@@@ -1415,17 -1417,17 +1417,17 @@@ static void gfx_v9_0_rlc_start(struct a
  
  #ifdef AMDGPU_RLC_DEBUG_RETRY
        /* RLC_GPM_GENERAL_6 : RLC Ucode version */
-       rlc_ucode_ver = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_GENERAL_6));
+       rlc_ucode_ver = RREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_6);
        if(rlc_ucode_ver == 0x108) {
                DRM_INFO("Using rlc debug ucode. mmRLC_GPM_GENERAL_6 ==0x08%x / fw_ver == %i \n",
                                rlc_ucode_ver, adev->gfx.rlc_fw_version);
                /* RLC_GPM_TIMER_INT_3 : Timer interval in RefCLK cycles,
                 * default is 0x9C4 to create a 100us interval */
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_TIMER_INT_3), 0x9C4);
+               WREG32_SOC15(GC, 0, mmRLC_GPM_TIMER_INT_3, 0x9C4);
                /* RLC_GPM_GENERAL_12 : Minimum gap between wptr and rptr
                 * to disable the page fault retry interrupts, default is 
                 * 0x100 (256) */
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_GENERAL_12), 0x100);
+               WREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_12, 0x100);
        }
  #endif
  }
@@@ -1446,11 -1448,11 +1448,11 @@@ static int gfx_v9_0_rlc_load_microcode(
                           le32_to_cpu(hdr->header.ucode_array_offset_bytes));
        fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_UCODE_ADDR),
+       WREG32_SOC15(GC, 0, mmRLC_GPM_UCODE_ADDR,
                        RLCG_UCODE_LOADING_START_ADDRESS);
        for (i = 0; i < fw_size; i++)
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_UCODE_DATA), le32_to_cpup(fw_data++));
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_UCODE_ADDR), adev->gfx.rlc_fw_version);
+               WREG32_SOC15(GC, 0, mmRLC_GPM_UCODE_DATA, le32_to_cpup(fw_data++));
+       WREG32_SOC15(GC, 0, mmRLC_GPM_UCODE_ADDR, adev->gfx.rlc_fw_version);
  
        return 0;
  }
@@@ -1465,10 -1467,10 +1467,10 @@@ static int gfx_v9_0_rlc_resume(struct a
        gfx_v9_0_rlc_stop(adev);
  
        /* disable CG */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL), 0);
+       WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL, 0);
  
        /* disable PG */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_CNTL), 0);
+       WREG32_SOC15(GC, 0, mmRLC_PG_CNTL, 0);
  
        gfx_v9_0_rlc_reset(adev);
  
  static void gfx_v9_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable)
  {
        int i;
-       u32 tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_ME_CNTL));
+       u32 tmp = RREG32_SOC15(GC, 0, mmCP_ME_CNTL);
  
        tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, ME_HALT, enable ? 0 : 1);
        tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, enable ? 0 : 1);
                for (i = 0; i < adev->gfx.num_gfx_rings; i++)
                        adev->gfx.gfx_ring[i].ready = false;
        }
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_ME_CNTL), tmp);
+       WREG32_SOC15(GC, 0, mmCP_ME_CNTL, tmp);
        udelay(50);
  }
  
@@@ -1529,30 -1531,30 +1531,30 @@@ static int gfx_v9_0_cp_gfx_load_microco
                (adev->gfx.pfp_fw->data +
                 le32_to_cpu(pfp_hdr->header.ucode_array_offset_bytes));
        fw_size = le32_to_cpu(pfp_hdr->header.ucode_size_bytes) / 4;
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_PFP_UCODE_ADDR), 0);
+       WREG32_SOC15(GC, 0, mmCP_PFP_UCODE_ADDR, 0);
        for (i = 0; i < fw_size; i++)
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_PFP_UCODE_DATA), le32_to_cpup(fw_data++));
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_PFP_UCODE_ADDR), adev->gfx.pfp_fw_version);
+               WREG32_SOC15(GC, 0, mmCP_PFP_UCODE_DATA, le32_to_cpup(fw_data++));
+       WREG32_SOC15(GC, 0, mmCP_PFP_UCODE_ADDR, adev->gfx.pfp_fw_version);
  
        /* CE */
        fw_data = (const __le32 *)
                (adev->gfx.ce_fw->data +
                 le32_to_cpu(ce_hdr->header.ucode_array_offset_bytes));
        fw_size = le32_to_cpu(ce_hdr->header.ucode_size_bytes) / 4;
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_CE_UCODE_ADDR), 0);
+       WREG32_SOC15(GC, 0, mmCP_CE_UCODE_ADDR, 0);
        for (i = 0; i < fw_size; i++)
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_CE_UCODE_DATA), le32_to_cpup(fw_data++));
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_CE_UCODE_ADDR), adev->gfx.ce_fw_version);
+               WREG32_SOC15(GC, 0, mmCP_CE_UCODE_DATA, le32_to_cpup(fw_data++));
+       WREG32_SOC15(GC, 0, mmCP_CE_UCODE_ADDR, adev->gfx.ce_fw_version);
  
        /* ME */
        fw_data = (const __le32 *)
                (adev->gfx.me_fw->data +
                 le32_to_cpu(me_hdr->header.ucode_array_offset_bytes));
        fw_size = le32_to_cpu(me_hdr->header.ucode_size_bytes) / 4;
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_ME_RAM_WADDR), 0);
+       WREG32_SOC15(GC, 0, mmCP_ME_RAM_WADDR, 0);
        for (i = 0; i < fw_size; i++)
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_ME_RAM_DATA), le32_to_cpup(fw_data++));
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_ME_RAM_WADDR), adev->gfx.me_fw_version);
+               WREG32_SOC15(GC, 0, mmCP_ME_RAM_DATA, le32_to_cpup(fw_data++));
+       WREG32_SOC15(GC, 0, mmCP_ME_RAM_WADDR, adev->gfx.me_fw_version);
  
        return 0;
  }
@@@ -1594,8 -1596,8 +1596,8 @@@ static int gfx_v9_0_cp_gfx_start(struc
        int r, i;
  
        /* init the CP */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MAX_CONTEXT), adev->gfx.config.max_hw_contexts - 1);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_DEVICE_ID), 1);
+       WREG32_SOC15(GC, 0, mmCP_MAX_CONTEXT, adev->gfx.config.max_hw_contexts - 1);
+       WREG32_SOC15(GC, 0, mmCP_DEVICE_ID, 1);
  
        gfx_v9_0_cp_gfx_enable(adev, true);
  
@@@ -1650,10 -1652,10 +1652,10 @@@ static int gfx_v9_0_cp_gfx_resume(struc
        u64 rb_addr, rptr_addr, wptr_gpu_addr;
  
        /* Set the write pointer delay */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_WPTR_DELAY), 0);
+       WREG32_SOC15(GC, 0, mmCP_RB_WPTR_DELAY, 0);
  
        /* set the RB to use vmid 0 */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_VMID), 0);
+       WREG32_SOC15(GC, 0, mmCP_RB_VMID, 0);
  
        /* Set ring buffer size */
        ring = &adev->gfx.gfx_ring[0];
  #ifdef __BIG_ENDIAN
        tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, BUF_SWAP, 1);
  #endif
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_CNTL), tmp);
+       WREG32_SOC15(GC, 0, mmCP_RB0_CNTL, tmp);
  
        /* Initialize the ring buffer's write pointers */
        ring->wptr = 0;
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_WPTR), lower_32_bits(ring->wptr));
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_WPTR_HI), upper_32_bits(ring->wptr));
+       WREG32_SOC15(GC, 0, mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
+       WREG32_SOC15(GC, 0, mmCP_RB0_WPTR_HI, upper_32_bits(ring->wptr));
  
        /* set the wb address wether it's enabled or not */
        rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_RPTR_ADDR), lower_32_bits(rptr_addr));
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_RPTR_ADDR_HI), upper_32_bits(rptr_addr) & CP_RB_RPTR_ADDR_HI__RB_RPTR_ADDR_HI_MASK);
+       WREG32_SOC15(GC, 0, mmCP_RB0_RPTR_ADDR, lower_32_bits(rptr_addr));
+       WREG32_SOC15(GC, 0, mmCP_RB0_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & CP_RB_RPTR_ADDR_HI__RB_RPTR_ADDR_HI_MASK);
  
        wptr_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_WPTR_POLL_ADDR_LO), lower_32_bits(wptr_gpu_addr));
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_WPTR_POLL_ADDR_HI), upper_32_bits(wptr_gpu_addr));
+       WREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_ADDR_LO, lower_32_bits(wptr_gpu_addr));
+       WREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_ADDR_HI, upper_32_bits(wptr_gpu_addr));
  
        mdelay(1);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_CNTL), tmp);
+       WREG32_SOC15(GC, 0, mmCP_RB0_CNTL, tmp);
  
        rb_addr = ring->gpu_addr >> 8;
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_BASE), rb_addr);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_BASE_HI), upper_32_bits(rb_addr));
+       WREG32_SOC15(GC, 0, mmCP_RB0_BASE, rb_addr);
+       WREG32_SOC15(GC, 0, mmCP_RB0_BASE_HI, upper_32_bits(rb_addr));
  
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_DOORBELL_CONTROL));
+       tmp = RREG32_SOC15(GC, 0, mmCP_RB_DOORBELL_CONTROL);
        if (ring->use_doorbell) {
                tmp = REG_SET_FIELD(tmp, CP_RB_DOORBELL_CONTROL,
                                    DOORBELL_OFFSET, ring->doorbell_index);
        } else {
                tmp = REG_SET_FIELD(tmp, CP_RB_DOORBELL_CONTROL, DOORBELL_EN, 0);
        }
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_DOORBELL_CONTROL), tmp);
+       WREG32_SOC15(GC, 0, mmCP_RB_DOORBELL_CONTROL, tmp);
  
        tmp = REG_SET_FIELD(0, CP_RB_DOORBELL_RANGE_LOWER,
                        DOORBELL_RANGE_LOWER, ring->doorbell_index);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_DOORBELL_RANGE_LOWER), tmp);
+       WREG32_SOC15(GC, 0, mmCP_RB_DOORBELL_RANGE_LOWER, tmp);
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_DOORBELL_RANGE_UPPER),
+       WREG32_SOC15(GC, 0, mmCP_RB_DOORBELL_RANGE_UPPER,
                       CP_RB_DOORBELL_RANGE_UPPER__DOORBELL_RANGE_UPPER_MASK);
  
  
@@@ -1717,9 -1719,9 +1719,9 @@@ static void gfx_v9_0_cp_compute_enable(
        int i;
  
        if (enable) {
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEC_CNTL), 0);
+               WREG32_SOC15(GC, 0, mmCP_MEC_CNTL, 0);
        } else {
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEC_CNTL),
+               WREG32_SOC15(GC, 0, mmCP_MEC_CNTL,
                        (CP_MEC_CNTL__MEC_ME1_HALT_MASK | CP_MEC_CNTL__MEC_ME2_HALT_MASK));
                for (i = 0; i < adev->gfx.num_compute_rings; i++)
                        adev->gfx.compute_ring[i].ready = false;
@@@ -1756,21 -1758,21 +1758,21 @@@ static int gfx_v9_0_cp_compute_load_mic
        tmp = 0;
        tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, VMID, 0);
        tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, CACHE_POLICY, 0);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_CPC_IC_BASE_CNTL), tmp);
+       WREG32_SOC15(GC, 0, mmCP_CPC_IC_BASE_CNTL, tmp);
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_CPC_IC_BASE_LO),
+       WREG32_SOC15(GC, 0, mmCP_CPC_IC_BASE_LO,
                adev->gfx.mec.mec_fw_gpu_addr & 0xFFFFF000);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_CPC_IC_BASE_HI),
+       WREG32_SOC15(GC, 0, mmCP_CPC_IC_BASE_HI,
                upper_32_bits(adev->gfx.mec.mec_fw_gpu_addr));
   
        /* MEC1 */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEC_ME1_UCODE_ADDR),
+       WREG32_SOC15(GC, 0, mmCP_MEC_ME1_UCODE_ADDR,
                         mec_hdr->jt_offset);
        for (i = 0; i < mec_hdr->jt_size; i++)
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEC_ME1_UCODE_DATA),
+               WREG32_SOC15(GC, 0, mmCP_MEC_ME1_UCODE_DATA,
                        le32_to_cpup(fw_data + mec_hdr->jt_offset + i));
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEC_ME1_UCODE_ADDR),
+       WREG32_SOC15(GC, 0, mmCP_MEC_ME1_UCODE_ADDR,
                        adev->gfx.mec_fw_version);
        /* Todo : Loading MEC2 firmware is only necessary if MEC2 should run different microcode than MEC1. */
  
@@@ -1785,7 -1787,7 +1787,7 @@@ static void gfx_v9_0_cp_compute_fini(st
                struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];
  
                if (ring->mqd_obj) {
-                       r = amdgpu_bo_reserve(ring->mqd_obj, false);
+                       r = amdgpu_bo_reserve(ring->mqd_obj, true);
                        if (unlikely(r != 0))
                                dev_warn(adev->dev, "(%d) reserve MQD bo failed\n", r);
  
@@@ -1823,12 -1825,12 +1825,12 @@@ static void gfx_v9_0_kiq_setting(struc
        struct amdgpu_device *adev = ring->adev;
  
        /* tell RLC which is KIQ queue */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CP_SCHEDULERS));
+       tmp = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS);
        tmp &= 0xffffff00;
        tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CP_SCHEDULERS), tmp);
+       WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp);
        tmp |= 0x80;
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CP_SCHEDULERS), tmp);
+       WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp);
  }
  
  static void gfx_v9_0_kiq_enable(struct amdgpu_ring *ring)
@@@ -1898,14 -1900,14 +1900,14 @@@ static int gfx_v9_0_mqd_init(struct amd
        mqd->cp_hqd_eop_base_addr_hi = upper_32_bits(eop_base_addr);
  
        /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_EOP_CONTROL));
+       tmp = RREG32_SOC15(GC, 0, mmCP_HQD_EOP_CONTROL);
        tmp = REG_SET_FIELD(tmp, CP_HQD_EOP_CONTROL, EOP_SIZE,
                        (order_base_2(MEC_HPD_SIZE / 4) - 1));
  
        mqd->cp_hqd_eop_control = tmp;
  
        /* enable doorbell? */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL));
+       tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL);
  
        if (ring->use_doorbell) {
                tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
        mqd->cp_mqd_base_addr_hi = upper_32_bits(ring->mqd_gpu_addr);
  
        /* set MQD vmid to 0 */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MQD_CONTROL));
+       tmp = RREG32_SOC15(GC, 0, mmCP_MQD_CONTROL);
        tmp = REG_SET_FIELD(tmp, CP_MQD_CONTROL, VMID, 0);
        mqd->cp_mqd_control = tmp;
  
        mqd->cp_hqd_pq_base_hi = upper_32_bits(hqd_gpu_addr);
  
        /* set up the HQD, this is similar to CP_RB0_CNTL */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_CONTROL));
+       tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_CONTROL);
        tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, QUEUE_SIZE,
                            (order_base_2(ring->ring_size / 4) - 1));
        tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, RPTR_BLOCK_SIZE,
        tmp = 0;
        /* enable the doorbell if requested */
        if (ring->use_doorbell) {
-               tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL));
+               tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL);
                tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
                                DOORBELL_OFFSET, ring->doorbell_index);
  
  
        /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
        ring->wptr = 0;
-       mqd->cp_hqd_pq_rptr = RREG32(mmCP_HQD_PQ_RPTR);
+       mqd->cp_hqd_pq_rptr = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR);
  
        /* set the vmid for the queue */
        mqd->cp_hqd_vmid = 0;
  
-       tmp = RREG32(mmCP_HQD_PERSISTENT_STATE);
+       tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PERSISTENT_STATE);
        tmp = REG_SET_FIELD(tmp, CP_HQD_PERSISTENT_STATE, PRELOAD_SIZE, 0x53);
        mqd->cp_hqd_persistent_state = tmp;
  
+       /* set MIN_IB_AVAIL_SIZE */
+       tmp = RREG32_SOC15(GC, 0, mmCP_HQD_IB_CONTROL);
+       tmp = REG_SET_FIELD(tmp, CP_HQD_IB_CONTROL, MIN_IB_AVAIL_SIZE, 3);
+       mqd->cp_hqd_ib_control = tmp;
        /* activate the queue */
        mqd->cp_hqd_active = 1;
  
@@@ -2013,94 -2020,94 +2020,94 @@@ static int gfx_v9_0_kiq_init_register(s
        /* disable wptr polling */
        WREG32_FIELD15(GC, 0, CP_PQ_WPTR_POLL_CNTL, EN, 0);
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_EOP_BASE_ADDR),
+       WREG32_SOC15(GC, 0, mmCP_HQD_EOP_BASE_ADDR,
               mqd->cp_hqd_eop_base_addr_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_EOP_BASE_ADDR_HI),
+       WREG32_SOC15(GC, 0, mmCP_HQD_EOP_BASE_ADDR_HI,
               mqd->cp_hqd_eop_base_addr_hi);
  
        /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_EOP_CONTROL),
+       WREG32_SOC15(GC, 0, mmCP_HQD_EOP_CONTROL,
               mqd->cp_hqd_eop_control);
  
        /* enable doorbell? */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
               mqd->cp_hqd_pq_doorbell_control);
  
        /* disable the queue if it's active */
-       if (RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_ACTIVE)) & 1) {
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_DEQUEUE_REQUEST), 1);
+       if (RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1) {
+               WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 1);
                for (j = 0; j < adev->usec_timeout; j++) {
-                       if (!(RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_ACTIVE)) & 1))
+                       if (!(RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1))
                                break;
                        udelay(1);
                }
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_DEQUEUE_REQUEST),
+               WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST,
                       mqd->cp_hqd_dequeue_request);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_RPTR),
+               WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR,
                       mqd->cp_hqd_pq_rptr);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_LO),
+               WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO,
                       mqd->cp_hqd_pq_wptr_lo);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_HI),
+               WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI,
                       mqd->cp_hqd_pq_wptr_hi);
        }
  
        /* set the pointer to the MQD */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MQD_BASE_ADDR),
+       WREG32_SOC15(GC, 0, mmCP_MQD_BASE_ADDR,
               mqd->cp_mqd_base_addr_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MQD_BASE_ADDR_HI),
+       WREG32_SOC15(GC, 0, mmCP_MQD_BASE_ADDR_HI,
               mqd->cp_mqd_base_addr_hi);
  
        /* set MQD vmid to 0 */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MQD_CONTROL),
+       WREG32_SOC15(GC, 0, mmCP_MQD_CONTROL,
               mqd->cp_mqd_control);
  
        /* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_BASE),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_BASE,
               mqd->cp_hqd_pq_base_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_BASE_HI),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_BASE_HI,
               mqd->cp_hqd_pq_base_hi);
  
        /* set up the HQD, this is similar to CP_RB0_CNTL */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_CONTROL),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_CONTROL,
               mqd->cp_hqd_pq_control);
  
        /* set the wb address whether it's enabled or not */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR,
                                mqd->cp_hqd_pq_rptr_report_addr_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI,
                                mqd->cp_hqd_pq_rptr_report_addr_hi);
  
        /* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR,
               mqd->cp_hqd_pq_wptr_poll_addr_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR_HI),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR_HI,
               mqd->cp_hqd_pq_wptr_poll_addr_hi);
  
        /* enable the doorbell if requested */
        if (ring->use_doorbell) {
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER),
+               WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER,
                                        (AMDGPU_DOORBELL64_KIQ *2) << 2);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER),
+               WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER,
                                        (AMDGPU_DOORBELL64_USERQUEUE_END * 2) << 2);
        }
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
               mqd->cp_hqd_pq_doorbell_control);
  
        /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_LO),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO,
               mqd->cp_hqd_pq_wptr_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_HI),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI,
               mqd->cp_hqd_pq_wptr_hi);
  
        /* set the vmid for the queue */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_VMID), mqd->cp_hqd_vmid);
+       WREG32_SOC15(GC, 0, mmCP_HQD_VMID, mqd->cp_hqd_vmid);
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PERSISTENT_STATE),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PERSISTENT_STATE,
               mqd->cp_hqd_persistent_state);
  
        /* activate the queue */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_ACTIVE),
+       WREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE,
               mqd->cp_hqd_active);
  
        if (ring->use_doorbell)
@@@ -2323,7 -2330,7 +2330,7 @@@ static bool gfx_v9_0_is_idle(void *hand
  {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  
-       if (REG_GET_FIELD(RREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_STATUS)), 
+       if (REG_GET_FIELD(RREG32_SOC15(GC, 0, mmGRBM_STATUS),
                                GRBM_STATUS, GUI_ACTIVE))
                return false;
        else
@@@ -2338,7 -2345,7 +2345,7 @@@ static int gfx_v9_0_wait_for_idle(void 
  
        for (i = 0; i < adev->usec_timeout; i++) {
                /* read MC_STATUS */
-               tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_STATUS)) & 
+               tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS) &
                        GRBM_STATUS__GUI_ACTIVE_MASK;
  
                if (!REG_GET_FIELD(tmp, GRBM_STATUS, GUI_ACTIVE))
@@@ -2355,7 -2362,7 +2362,7 @@@ static int gfx_v9_0_soft_reset(void *ha
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  
        /* GRBM_STATUS */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_STATUS));
+       tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS);
        if (tmp & (GRBM_STATUS__PA_BUSY_MASK | GRBM_STATUS__SC_BUSY_MASK |
                   GRBM_STATUS__BCI_BUSY_MASK | GRBM_STATUS__SX_BUSY_MASK |
                   GRBM_STATUS__TA_BUSY_MASK | GRBM_STATUS__VGT_BUSY_MASK |
        }
  
        /* GRBM_STATUS2 */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_STATUS2));
+       tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS2);
        if (REG_GET_FIELD(tmp, GRBM_STATUS2, RLC_BUSY))
                grbm_soft_reset = REG_SET_FIELD(grbm_soft_reset,
                                                GRBM_SOFT_RESET, SOFT_RESET_RLC, 1);
                gfx_v9_0_cp_compute_enable(adev, false);
  
                if (grbm_soft_reset) {
-                       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_SOFT_RESET));
+                       tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
                        tmp |= grbm_soft_reset;
                        dev_info(adev->dev, "GRBM_SOFT_RESET=0x%08X\n", tmp);
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_SOFT_RESET), tmp);
-                       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_SOFT_RESET));
+                       WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, tmp);
+                       tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
  
                        udelay(50);
  
                        tmp &= ~grbm_soft_reset;
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_SOFT_RESET), tmp);
-                       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_SOFT_RESET));
+                       WREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET, tmp);
+                       tmp = RREG32_SOC15(GC, 0, mmGRBM_SOFT_RESET);
                }
  
                /* Wait a little for things to settle down */
@@@ -2415,9 -2422,9 +2422,9 @@@ static uint64_t gfx_v9_0_get_gpu_clock_
        uint64_t clock;
  
        mutex_lock(&adev->gfx.gpu_clock_mutex);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CAPTURE_GPU_CLOCK_COUNT), 1);
-       clock = (uint64_t)RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPU_CLOCK_COUNT_LSB)) |
-               ((uint64_t)RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPU_CLOCK_COUNT_MSB)) << 32ULL);
+       WREG32_SOC15(GC, 0, mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);
+       clock = (uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_LSB) |
+               ((uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL);
        mutex_unlock(&adev->gfx.gpu_clock_mutex);
        return clock;
  }
@@@ -2497,7 -2504,7 +2504,7 @@@ static void gfx_v9_0_enter_rlc_safe_mod
                return;
  
        /* if RLC is not enabled, do nothing */
-       rlc_setting = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CNTL));
+       rlc_setting = RREG32_SOC15(GC, 0, mmRLC_CNTL);
        if (!(rlc_setting & RLC_CNTL__RLC_ENABLE_F32_MASK))
                return;
  
             AMD_CG_SUPPORT_GFX_3D_CGCG)) {
                data = RLC_SAFE_MODE__CMD_MASK;
                data |= (1 << RLC_SAFE_MODE__MESSAGE__SHIFT);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SAFE_MODE), data);
+               WREG32_SOC15(GC, 0, mmRLC_SAFE_MODE, data);
  
                /* wait for RLC_SAFE_MODE */
                for (i = 0; i < adev->usec_timeout; i++) {
@@@ -2526,7 -2533,7 +2533,7 @@@ static void gfx_v9_0_exit_rlc_safe_mode
                return;
  
        /* if RLC is not enabled, do nothing */
-       rlc_setting = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CNTL));
+       rlc_setting = RREG32_SOC15(GC, 0, mmRLC_CNTL);
        if (!(rlc_setting & RLC_CNTL__RLC_ENABLE_F32_MASK))
                return;
  
                 * mode.
                 */
                data = RLC_SAFE_MODE__CMD_MASK;
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SAFE_MODE), data);
+               WREG32_SOC15(GC, 0, mmRLC_SAFE_MODE, data);
                adev->gfx.rlc.in_safe_mode = false;
        }
  }
@@@ -2550,7 -2557,7 +2557,7 @@@ static void gfx_v9_0_update_medium_grai
        /* It is disabled by HW by default */
        if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGCG)) {
                /* 1 - RLC_CGTT_MGCG_OVERRIDE */
-               def = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE));
+               def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
                data &= ~(RLC_CGTT_MGCG_OVERRIDE__CPF_CGTT_SCLK_OVERRIDE_MASK |
                          RLC_CGTT_MGCG_OVERRIDE__GRBM_CGTT_SCLK_OVERRIDE_MASK |
                          RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGCG_OVERRIDE_MASK |
                data |= RLC_CGTT_MGCG_OVERRIDE__RLC_CGTT_SCLK_OVERRIDE_MASK;
  
                if (def != data)
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE), data);
+                       WREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE, data);
  
                /* MGLS is a global flag to control all MGLS in GFX */
                if (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGLS) {
                        /* 2 - RLC memory Light sleep */
                        if (adev->cg_flags & AMD_CG_SUPPORT_GFX_RLC_LS) {
-                               def = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_MEM_SLP_CNTL));
+                               def = data = RREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL);
                                data |= RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK;
                                if (def != data)
-                                       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_MEM_SLP_CNTL), data);
+                                       WREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL, data);
                        }
                        /* 3 - CP memory Light sleep */
                        if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CP_LS) {
-                               def = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEM_SLP_CNTL));
+                               def = data = RREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL);
                                data |= CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK;
                                if (def != data)
-                                       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEM_SLP_CNTL), data);
+                                       WREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL, data);
                        }
                }
        } else {
                /* 1 - MGCG_OVERRIDE */
-               def = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE));
+               def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
                data |= (RLC_CGTT_MGCG_OVERRIDE__CPF_CGTT_SCLK_OVERRIDE_MASK |
                         RLC_CGTT_MGCG_OVERRIDE__RLC_CGTT_SCLK_OVERRIDE_MASK |
                         RLC_CGTT_MGCG_OVERRIDE__GRBM_CGTT_SCLK_OVERRIDE_MASK |
                         RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGCG_OVERRIDE_MASK |
                         RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGLS_OVERRIDE_MASK);
                if (def != data)
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE), data);
+                       WREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE, data);
  
                /* 2 - disable MGLS in RLC */
-               data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_MEM_SLP_CNTL));
+               data = RREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL);
                if (data & RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK) {
                        data &= ~RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK;
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_MEM_SLP_CNTL), data);
+                       WREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL, data);
                }
  
                /* 3 - disable MGLS in CP */
-               data = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEM_SLP_CNTL));
+               data = RREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL);
                if (data & CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK) {
                        data &= ~CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK;
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEM_SLP_CNTL), data);
+                       WREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL, data);
                }
        }
  }
@@@ -2616,37 -2623,37 +2623,37 @@@ static void gfx_v9_0_update_3d_clock_ga
        /* Enable 3D CGCG/CGLS */
        if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_3D_CGCG)) {
                /* write cmd to clear cgcg/cgls ov */
-               def = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE));
+               def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
                /* unset CGCG override */
                data &= ~RLC_CGTT_MGCG_OVERRIDE__GFXIP_GFX3D_CG_OVERRIDE_MASK;
                /* update CGCG and CGLS override bits */
                if (def != data)
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE), data);
+                       WREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE, data);
                /* enable 3Dcgcg FSM(0x0020003f) */
-               def = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D));
+               def = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D);
                data = (0x2000 << RLC_CGCG_CGLS_CTRL_3D__CGCG_GFX_IDLE_THRESHOLD__SHIFT) |
                        RLC_CGCG_CGLS_CTRL_3D__CGCG_EN_MASK;
                if (adev->cg_flags & AMD_CG_SUPPORT_GFX_3D_CGLS)
                        data |= (0x000F << RLC_CGCG_CGLS_CTRL_3D__CGLS_REP_COMPANSAT_DELAY__SHIFT) |
                                RLC_CGCG_CGLS_CTRL_3D__CGLS_EN_MASK;
                if (def != data)
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D), data);
+                       WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D, data);
  
                /* set IDLE_POLL_COUNT(0x00900100) */
-               def = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_WPTR_POLL_CNTL));
+               def = RREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_CNTL);
                data = (0x0100 << CP_RB_WPTR_POLL_CNTL__POLL_FREQUENCY__SHIFT) |
                        (0x0090 << CP_RB_WPTR_POLL_CNTL__IDLE_POLL_COUNT__SHIFT);
                if (def != data)
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_WPTR_POLL_CNTL), data);
+                       WREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_CNTL, data);
        } else {
                /* Disable CGCG/CGLS */
-               def = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D));
+               def = data = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D);
                /* disable cgcg, cgls should be disabled */
                data &= ~(RLC_CGCG_CGLS_CTRL_3D__CGCG_EN_MASK |
                          RLC_CGCG_CGLS_CTRL_3D__CGLS_EN_MASK);
                /* disable cgcg and cgls in FSM */
                if (def != data)
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D), data);
+                       WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D, data);
        }
  
        adev->gfx.rlc.funcs->exit_safe_mode(adev);
@@@ -2660,7 -2667,7 +2667,7 @@@ static void gfx_v9_0_update_coarse_grai
        adev->gfx.rlc.funcs->enter_safe_mode(adev);
  
        if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGCG)) {
-               def = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE));
+               def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
                /* unset CGCG override */
                data &= ~RLC_CGTT_MGCG_OVERRIDE__GFXIP_CGCG_OVERRIDE_MASK;
                if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGLS)
                        data |= RLC_CGTT_MGCG_OVERRIDE__GFXIP_CGLS_OVERRIDE_MASK;
                /* update CGCG and CGLS override bits */
                if (def != data)
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE), data);
+                       WREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE, data);
  
                /* enable cgcg FSM(0x0020003F) */
-               def = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL));
+               def = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL);
                data = (0x2000 << RLC_CGCG_CGLS_CTRL__CGCG_GFX_IDLE_THRESHOLD__SHIFT) |
                        RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK;
                if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGLS)
                        data |= (0x000F << RLC_CGCG_CGLS_CTRL__CGLS_REP_COMPANSAT_DELAY__SHIFT) |
                                RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK;
                if (def != data)
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL), data);
+                       WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL, data);
  
                /* set IDLE_POLL_COUNT(0x00900100) */
-               def = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_WPTR_POLL_CNTL));
+               def = RREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_CNTL);
                data = (0x0100 << CP_RB_WPTR_POLL_CNTL__POLL_FREQUENCY__SHIFT) |
                        (0x0090 << CP_RB_WPTR_POLL_CNTL__IDLE_POLL_COUNT__SHIFT);
                if (def != data)
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB_WPTR_POLL_CNTL), data);
+                       WREG32_SOC15(GC, 0, mmCP_RB_WPTR_POLL_CNTL, data);
        } else {
-               def = data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL));
+               def = data = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL);
                /* reset CGCG/CGLS bits */
                data &= ~(RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK | RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK);
                /* disable cgcg and cgls in FSM */
                if (def != data)
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL), data);
+                       WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL, data);
        }
  
        adev->gfx.rlc.funcs->exit_safe_mode(adev);
@@@ -2740,6 -2747,9 +2747,9 @@@ static int gfx_v9_0_set_clockgating_sta
  {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  
+       if (amdgpu_sriov_vf(adev))
+               return 0;
        switch (adev->asic_type) {
        case CHIP_VEGA10:
                gfx_v9_0_update_gfx_clock_gating(adev,
@@@ -2760,12 -2770,12 +2770,12 @@@ static void gfx_v9_0_get_clockgating_st
                *flags = 0;
  
        /* AMD_CG_SUPPORT_GFX_MGCG */
-       data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE));
+       data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
        if (!(data & RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGCG_OVERRIDE_MASK))
                *flags |= AMD_CG_SUPPORT_GFX_MGCG;
  
        /* AMD_CG_SUPPORT_GFX_CGCG */
-       data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL));
+       data = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL);
        if (data & RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK)
                *flags |= AMD_CG_SUPPORT_GFX_CGCG;
  
                *flags |= AMD_CG_SUPPORT_GFX_CGLS;
  
        /* AMD_CG_SUPPORT_GFX_RLC_LS */
-       data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_MEM_SLP_CNTL));
+       data = RREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL);
        if (data & RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK)
                *flags |= AMD_CG_SUPPORT_GFX_RLC_LS | AMD_CG_SUPPORT_GFX_MGLS;
  
        /* AMD_CG_SUPPORT_GFX_CP_LS */
-       data = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEM_SLP_CNTL));
+       data = RREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL);
        if (data & CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK)
                *flags |= AMD_CG_SUPPORT_GFX_CP_LS | AMD_CG_SUPPORT_GFX_MGLS;
  
        /* AMD_CG_SUPPORT_GFX_3D_CGCG */
-       data = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D));
+       data = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D);
        if (data & RLC_CGCG_CGLS_CTRL_3D__CGCG_EN_MASK)
                *flags |= AMD_CG_SUPPORT_GFX_3D_CGCG;
  
@@@ -2807,8 -2817,8 +2817,8 @@@ static u64 gfx_v9_0_ring_get_wptr_gfx(s
        if (ring->use_doorbell) {
                wptr = atomic64_read((atomic64_t *)&adev->wb.wb[ring->wptr_offs]);
        } else {
-               wptr = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_WPTR));
-               wptr += (u64)RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_WPTR_HI)) << 32;
+               wptr = RREG32_SOC15(GC, 0, mmCP_RB0_WPTR);
+               wptr += (u64)RREG32_SOC15(GC, 0, mmCP_RB0_WPTR_HI) << 32;
        }
  
        return wptr;
@@@ -2823,8 -2833,8 +2833,8 @@@ static void gfx_v9_0_ring_set_wptr_gfx(
                atomic64_set((atomic64_t*)&adev->wb.wb[ring->wptr_offs], ring->wptr);
                WDOORBELL64(ring->doorbell_index, ring->wptr);
        } else {
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_WPTR), lower_32_bits(ring->wptr));
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_RB0_WPTR_HI), upper_32_bits(ring->wptr));
+               WREG32_SOC15(GC, 0, mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
+               WREG32_SOC15(GC, 0, mmCP_RB0_WPTR_HI, upper_32_bits(ring->wptr));
        }
  }
  
@@@ -2956,35 -2966,29 +2966,29 @@@ static void gfx_v9_0_ring_emit_pipeline
  static void gfx_v9_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
                                        unsigned vm_id, uint64_t pd_addr)
  {
+       struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub];
        int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX);
        uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
-       unsigned eng = ring->idx;
-       unsigned i;
+       unsigned eng = ring->vm_inv_eng;
  
        pd_addr = pd_addr | 0x1; /* valid bit */
        /* now only use physical base address of PDE and valid */
        BUG_ON(pd_addr & 0xFFFF00000000003EULL);
  
-       for (i = 0; i < AMDGPU_MAX_VMHUBS; ++i) {
-               struct amdgpu_vmhub *hub = &ring->adev->vmhub[i];
-               gfx_v9_0_write_data_to_reg(ring, usepfp, true,
-                                          hub->ctx0_ptb_addr_lo32
-                                          + (2 * vm_id),
-                                          lower_32_bits(pd_addr));
+       gfx_v9_0_write_data_to_reg(ring, usepfp, true,
+                                  hub->ctx0_ptb_addr_lo32 + (2 * vm_id),
+                                  lower_32_bits(pd_addr));
  
-               gfx_v9_0_write_data_to_reg(ring, usepfp, true,
-                                          hub->ctx0_ptb_addr_hi32
-                                          + (2 * vm_id),
-                                          upper_32_bits(pd_addr));
+       gfx_v9_0_write_data_to_reg(ring, usepfp, true,
+                                  hub->ctx0_ptb_addr_hi32 + (2 * vm_id),
+                                  upper_32_bits(pd_addr));
  
-               gfx_v9_0_write_data_to_reg(ring, usepfp, true,
-                                          hub->vm_inv_eng0_req + eng, req);
+       gfx_v9_0_write_data_to_reg(ring, usepfp, true,
+                                  hub->vm_inv_eng0_req + eng, req);
  
-               /* wait for the invalidate to complete */
-               gfx_v9_0_wait_reg_mem(ring, 0, 0, 0, hub->vm_inv_eng0_ack +
-                                     eng, 0, 1 << vm_id, 1 << vm_id, 0x20);
-       }
+       /* wait for the invalidate to complete */
+       gfx_v9_0_wait_reg_mem(ring, 0, 0, 0, hub->vm_inv_eng0_ack +
+                             eng, 0, 1 << vm_id, 1 << vm_id, 0x20);
  
        /* compute doesn't have PFP */
        if (usepfp) {
@@@ -3373,9 -3377,7 +3377,7 @@@ static int gfx_v9_0_kiq_set_interrupt_s
                                            enum amdgpu_interrupt_state state)
  {
        uint32_t tmp, target;
-       struct amdgpu_ring *ring = (struct amdgpu_ring *)src->data;
-       BUG_ON(!ring || (ring->funcs->type != AMDGPU_RING_TYPE_KIQ));
+       struct amdgpu_ring *ring = &(adev->gfx.kiq.ring);
  
        if (ring->me == 1)
                target = SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE0_INT_CNTL);
        switch (type) {
        case AMDGPU_CP_KIQ_IRQ_DRIVER0:
                if (state == AMDGPU_IRQ_STATE_DISABLE) {
-                       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCPC_INT_CNTL));
+                       tmp = RREG32_SOC15(GC, 0, mmCPC_INT_CNTL);
                        tmp = REG_SET_FIELD(tmp, CPC_INT_CNTL,
                                                 GENERIC2_INT_ENABLE, 0);
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmCPC_INT_CNTL), tmp);
+                       WREG32_SOC15(GC, 0, mmCPC_INT_CNTL, tmp);
  
                        tmp = RREG32(target);
                        tmp = REG_SET_FIELD(tmp, CP_ME2_PIPE0_INT_CNTL,
                                                 GENERIC2_INT_ENABLE, 0);
                        WREG32(target, tmp);
                } else {
-                       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCPC_INT_CNTL));
+                       tmp = RREG32_SOC15(GC, 0, mmCPC_INT_CNTL);
                        tmp = REG_SET_FIELD(tmp, CPC_INT_CNTL,
                                                 GENERIC2_INT_ENABLE, 1);
-                       WREG32(SOC15_REG_OFFSET(GC, 0, mmCPC_INT_CNTL), tmp);
+                       WREG32_SOC15(GC, 0, mmCPC_INT_CNTL, tmp);
  
                        tmp = RREG32(target);
                        tmp = REG_SET_FIELD(tmp, CP_ME2_PIPE0_INT_CNTL,
@@@ -3419,9 -3421,7 +3421,7 @@@ static int gfx_v9_0_kiq_irq(struct amdg
                            struct amdgpu_iv_entry *entry)
  {
        u8 me_id, pipe_id, queue_id;
-       struct amdgpu_ring *ring = (struct amdgpu_ring *)source->data;
-       BUG_ON(!ring || (ring->funcs->type != AMDGPU_RING_TYPE_KIQ));
+       struct amdgpu_ring *ring = &(adev->gfx.kiq.ring);
  
        me_id = (entry->ring_id & 0x0c) >> 2;
        pipe_id = (entry->ring_id & 0x03) >> 0;
@@@ -3456,13 -3456,14 +3456,14 @@@ static const struct amdgpu_ring_funcs g
        .align_mask = 0xff,
        .nop = PACKET3(PACKET3_NOP, 0x3FFF),
        .support_64bit_ptrs = true,
+       .vmhub = AMDGPU_GFXHUB,
        .get_rptr = gfx_v9_0_ring_get_rptr_gfx,
        .get_wptr = gfx_v9_0_ring_get_wptr_gfx,
        .set_wptr = gfx_v9_0_ring_set_wptr_gfx,
        .emit_frame_size = /* totally 242 maximum if 16 IBs */
                5 +  /* COND_EXEC */
                7 +  /* PIPELINE_SYNC */
-               46 + /* VM_FLUSH */
+               24 + /* VM_FLUSH */
                8 +  /* FENCE for VM_FLUSH */
                20 + /* GDS switch */
                4 + /* double SWITCH_BUFFER,
@@@ -3500,6 -3501,7 +3501,7 @@@ static const struct amdgpu_ring_funcs g
        .align_mask = 0xff,
        .nop = PACKET3(PACKET3_NOP, 0x3FFF),
        .support_64bit_ptrs = true,
+       .vmhub = AMDGPU_GFXHUB,
        .get_rptr = gfx_v9_0_ring_get_rptr_compute,
        .get_wptr = gfx_v9_0_ring_get_wptr_compute,
        .set_wptr = gfx_v9_0_ring_set_wptr_compute,
                7 + /* gfx_v9_0_ring_emit_hdp_flush */
                5 + /* gfx_v9_0_ring_emit_hdp_invalidate */
                7 + /* gfx_v9_0_ring_emit_pipeline_sync */
-               64 + /* gfx_v9_0_ring_emit_vm_flush */
+               24 + /* gfx_v9_0_ring_emit_vm_flush */
                8 + 8 + 8, /* gfx_v9_0_ring_emit_fence x3 for user fence, vm fence */
        .emit_ib_size = 4, /* gfx_v9_0_ring_emit_ib_compute */
        .emit_ib = gfx_v9_0_ring_emit_ib_compute,
@@@ -3529,6 -3531,7 +3531,7 @@@ static const struct amdgpu_ring_funcs g
        .align_mask = 0xff,
        .nop = PACKET3(PACKET3_NOP, 0x3FFF),
        .support_64bit_ptrs = true,
+       .vmhub = AMDGPU_GFXHUB,
        .get_rptr = gfx_v9_0_ring_get_rptr_compute,
        .get_wptr = gfx_v9_0_ring_get_wptr_compute,
        .set_wptr = gfx_v9_0_ring_set_wptr_compute,
                7 + /* gfx_v9_0_ring_emit_hdp_flush */
                5 + /* gfx_v9_0_ring_emit_hdp_invalidate */
                7 + /* gfx_v9_0_ring_emit_pipeline_sync */
-               64 + /* gfx_v9_0_ring_emit_vm_flush */
+               24 + /* gfx_v9_0_ring_emit_vm_flush */
                8 + 8 + 8, /* gfx_v9_0_ring_emit_fence_kiq x3 for user fence, vm fence */
        .emit_ib_size = 4, /* gfx_v9_0_ring_emit_ib_compute */
        .emit_ib = gfx_v9_0_ring_emit_ib_compute,
@@@ -3612,7 -3615,7 +3615,7 @@@ static void gfx_v9_0_set_rlc_funcs(stru
  static void gfx_v9_0_set_gds_init(struct amdgpu_device *adev)
  {
        /* init asci gds info */
-       adev->gds.mem.total_size = RREG32(SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE));
+       adev->gds.mem.total_size = RREG32_SOC15(GC, 0, mmGDS_VMID0_SIZE);
        adev->gds.gws.total_size = 64;
        adev->gds.oa.total_size = 16;
  
@@@ -3641,8 -3644,8 +3644,8 @@@ static u32 gfx_v9_0_get_cu_active_bitma
  {
        u32 data, mask;
  
-       data = RREG32(SOC15_REG_OFFSET(GC, 0, mmCC_GC_SHADER_ARRAY_CONFIG));
-       data |= RREG32(SOC15_REG_OFFSET(GC, 0, mmGC_USER_SHADER_ARRAY_CONFIG));
+       data = RREG32_SOC15(GC, 0, mmCC_GC_SHADER_ARRAY_CONFIG);
+       data |= RREG32_SOC15(GC, 0, mmGC_USER_SHADER_ARRAY_CONFIG);
  
        data &= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK;
        data >>= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT;
@@@ -3763,25 -3766,25 +3766,25 @@@ static int gfx_v9_0_init_queue(struct a
        eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr + (ring->queue * MEC_HPD_SIZE);
        eop_gpu_addr >>= 8;
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_EOP_BASE_ADDR), lower_32_bits(eop_gpu_addr));
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_EOP_BASE_ADDR_HI), upper_32_bits(eop_gpu_addr));
+       WREG32_SOC15(GC, 0, mmCP_HQD_EOP_BASE_ADDR, lower_32_bits(eop_gpu_addr));
+       WREG32_SOC15(GC, 0, mmCP_HQD_EOP_BASE_ADDR_HI, upper_32_bits(eop_gpu_addr));
        mqd->cp_hqd_eop_base_addr_lo = lower_32_bits(eop_gpu_addr);
        mqd->cp_hqd_eop_base_addr_hi = upper_32_bits(eop_gpu_addr);
  
        /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_EOP_CONTROL));
+       tmp = RREG32_SOC15(GC, 0, mmCP_HQD_EOP_CONTROL);
        tmp = REG_SET_FIELD(tmp, CP_HQD_EOP_CONTROL, EOP_SIZE,
                                    (order_base_2(MEC_HPD_SIZE / 4) - 1));
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_EOP_CONTROL), tmp);
+       WREG32_SOC15(GC, 0, mmCP_HQD_EOP_CONTROL, tmp);
  
        /* enable doorbell? */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL));
+       tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL);
        if (use_doorbell)
                tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);
        else
                tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 0);
  
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL), tmp);
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, tmp);
        mqd->cp_hqd_pq_doorbell_control = tmp;
  
        /* disable the queue if it's active */
        mqd->cp_hqd_pq_rptr = 0;
        mqd->cp_hqd_pq_wptr_lo = 0;
        mqd->cp_hqd_pq_wptr_hi = 0;
-       if (RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_ACTIVE)) & 1) {
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_DEQUEUE_REQUEST), 1);
+       if (RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1) {
+               WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 1);
                for (j = 0; j < adev->usec_timeout; j++) {
-                       if (!(RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_ACTIVE)) & 1))
+                       if (!(RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE) & 1))
                                break;
                        udelay(1);
                }
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_DEQUEUE_REQUEST), mqd->cp_hqd_dequeue_request);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_RPTR), mqd->cp_hqd_pq_rptr);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_LO), mqd->cp_hqd_pq_wptr_lo);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_HI), mqd->cp_hqd_pq_wptr_hi);
+               WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, mqd->cp_hqd_dequeue_request);
+               WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR, mqd->cp_hqd_pq_rptr);
+               WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO, mqd->cp_hqd_pq_wptr_lo);
+               WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI, mqd->cp_hqd_pq_wptr_hi);
        }
  
        /* set the pointer to the MQD */
        mqd->cp_mqd_base_addr_lo = mqd_gpu_addr & 0xfffffffc;
        mqd->cp_mqd_base_addr_hi = upper_32_bits(mqd_gpu_addr);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MQD_BASE_ADDR), mqd->cp_mqd_base_addr_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MQD_BASE_ADDR_HI), mqd->cp_mqd_base_addr_hi);
+       WREG32_SOC15(GC, 0, mmCP_MQD_BASE_ADDR, mqd->cp_mqd_base_addr_lo);
+       WREG32_SOC15(GC, 0, mmCP_MQD_BASE_ADDR_HI, mqd->cp_mqd_base_addr_hi);
  
        /* set MQD vmid to 0 */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MQD_CONTROL));
+       tmp = RREG32_SOC15(GC, 0, mmCP_MQD_CONTROL);
        tmp = REG_SET_FIELD(tmp, CP_MQD_CONTROL, VMID, 0);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MQD_CONTROL), tmp);
+       WREG32_SOC15(GC, 0, mmCP_MQD_CONTROL, tmp);
        mqd->cp_mqd_control = tmp;
  
        /* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */
        hqd_gpu_addr = ring->gpu_addr >> 8;
        mqd->cp_hqd_pq_base_lo = hqd_gpu_addr;
        mqd->cp_hqd_pq_base_hi = upper_32_bits(hqd_gpu_addr);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_BASE), mqd->cp_hqd_pq_base_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_BASE_HI), mqd->cp_hqd_pq_base_hi);
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_BASE, mqd->cp_hqd_pq_base_lo);
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_BASE_HI, mqd->cp_hqd_pq_base_hi);
  
        /* set up the HQD, this is similar to CP_RB0_CNTL */
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_CONTROL));
+       tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_CONTROL);
        tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, QUEUE_SIZE,
                (order_base_2(ring->ring_size / 4) - 1));
        tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, RPTR_BLOCK_SIZE,
        tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ROQ_PQ_IB_FLIP, 0);
        tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
        tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_CONTROL), tmp);
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_CONTROL, tmp);
        mqd->cp_hqd_pq_control = tmp;
  
        /* set the wb address wether it's enabled or not */
        mqd->cp_hqd_pq_rptr_report_addr_lo = wb_gpu_addr & 0xfffffffc;
        mqd->cp_hqd_pq_rptr_report_addr_hi =
        upper_32_bits(wb_gpu_addr) & 0xffff;
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR,
                mqd->cp_hqd_pq_rptr_report_addr_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI,
                mqd->cp_hqd_pq_rptr_report_addr_hi);
  
        /* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */
        wb_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);
        mqd->cp_hqd_pq_wptr_poll_addr_lo = wb_gpu_addr & 0xfffffffc;
        mqd->cp_hqd_pq_wptr_poll_addr_hi = upper_32_bits(wb_gpu_addr) & 0xffff;
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR,
                mqd->cp_hqd_pq_wptr_poll_addr_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR_HI),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_POLL_ADDR_HI,
                mqd->cp_hqd_pq_wptr_poll_addr_hi);
  
        /* enable the doorbell if requested */
        if (use_doorbell) {
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER),
+               WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER,
                        (AMDGPU_DOORBELL64_KIQ * 2) << 2);
-               WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER),
+               WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER,
                        (AMDGPU_DOORBELL64_MEC_RING7 * 2) << 2);
-               tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL));
+               tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL);
                tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
                        DOORBELL_OFFSET, ring->doorbell_index);
                tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);
        } else {
                mqd->cp_hqd_pq_doorbell_control = 0;
        }
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL),
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
                mqd->cp_hqd_pq_doorbell_control);
  
        /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_LO), mqd->cp_hqd_pq_wptr_lo);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PQ_WPTR_HI), mqd->cp_hqd_pq_wptr_hi);
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_LO, mqd->cp_hqd_pq_wptr_lo);
+       WREG32_SOC15(GC, 0, mmCP_HQD_PQ_WPTR_HI, mqd->cp_hqd_pq_wptr_hi);
  
        /* set the vmid for the queue */
        mqd->cp_hqd_vmid = 0;
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_VMID), mqd->cp_hqd_vmid);
+       WREG32_SOC15(GC, 0, mmCP_HQD_VMID, mqd->cp_hqd_vmid);
  
-       tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PERSISTENT_STATE));
+       tmp = RREG32_SOC15(GC, 0, mmCP_HQD_PERSISTENT_STATE);
        tmp = REG_SET_FIELD(tmp, CP_HQD_PERSISTENT_STATE, PRELOAD_SIZE, 0x53);
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_PERSISTENT_STATE), tmp);
+       WREG32_SOC15(GC, 0, mmCP_HQD_PERSISTENT_STATE, tmp);
        mqd->cp_hqd_persistent_state = tmp;
  
        /* activate the queue */
        mqd->cp_hqd_active = 1;
-       WREG32(SOC15_REG_OFFSET(GC, 0, mmCP_HQD_ACTIVE), mqd->cp_hqd_active);
+       WREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE, mqd->cp_hqd_active);
  
        soc15_grbm_select(adev, 0, 0, 0, 0);
        mutex_unlock(&adev->srbm_mutex);
@@@ -21,7 -21,7 +21,7 @@@
   *
   */
  #include <linux/firmware.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "gmc_v6_0.h"
  #include "amdgpu_ucode.h"
@@@ -346,7 -346,8 +346,8 @@@ static int gmc_v6_0_mc_init(struct amdg
         * size equal to the 1024 or vram, whichever is larger.
         */
        if (amdgpu_gart_size == -1)
-               adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size);
+               adev->mc.gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20),
+                                       adev->mc.mc_vram_size);
        else
                adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
  
@@@ -621,7 -622,7 +622,7 @@@ static int gmc_v6_0_vm_init(struct amdg
         * amdgpu graphics/compute will use VMIDs 1-7
         * amdkfd will use VMIDs 8-15
         */
-       adev->vm_manager.num_ids = AMDGPU_NUM_OF_VMIDS;
+       adev->vm_manager.id_mgr[0].num_ids = AMDGPU_NUM_OF_VMIDS;
        adev->vm_manager.num_level = 1;
        amdgpu_vm_manager_init(adev);
  
@@@ -21,7 -21,7 +21,7 @@@
   *
   */
  #include <linux/firmware.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "cikd.h"
  #include "cik.h"
@@@ -395,7 -395,8 +395,8 @@@ static int gmc_v7_0_mc_init(struct amdg
         * size equal to the 1024 or vram, whichever is larger.
         */
        if (amdgpu_gart_size == -1)
-               adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size);
+               adev->mc.gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20),
+                                       adev->mc.mc_vram_size);
        else
                adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
  
@@@ -746,7 -747,7 +747,7 @@@ static int gmc_v7_0_vm_init(struct amdg
         * amdgpu graphics/compute will use VMIDs 1-7
         * amdkfd will use VMIDs 8-15
         */
-       adev->vm_manager.num_ids = AMDGPU_NUM_OF_VMIDS;
+       adev->vm_manager.id_mgr[0].num_ids = AMDGPU_NUM_OF_VMIDS;
        adev->vm_manager.num_level = 1;
        amdgpu_vm_manager_init(adev);
  
@@@ -21,7 -21,7 +21,7 @@@
   *
   */
  #include <linux/firmware.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "gmc_v8_0.h"
  #include "amdgpu_ucode.h"
@@@ -557,7 -557,8 +557,8 @@@ static int gmc_v8_0_mc_init(struct amdg
         * size equal to the 1024 or vram, whichever is larger.
         */
        if (amdgpu_gart_size == -1)
-               adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size);
+               adev->mc.gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20),
+                                       adev->mc.mc_vram_size);
        else
                adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
  
@@@ -949,7 -950,7 +950,7 @@@ static int gmc_v8_0_vm_init(struct amdg
         * amdgpu graphics/compute will use VMIDs 1-7
         * amdkfd will use VMIDs 8-15
         */
-       adev->vm_manager.num_ids = AMDGPU_NUM_OF_VMIDS;
+       adev->vm_manager.id_mgr[0].num_ids = AMDGPU_NUM_OF_VMIDS;
        adev->vm_manager.num_level = 1;
        amdgpu_vm_manager_init(adev);
  
@@@ -24,7 -24,7 +24,7 @@@
   */
  
  #include <linux/firmware.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
  #include "amdgpu_psp.h"
  #include "amdgpu_ucode.h"
@@@ -166,11 -166,8 +166,8 @@@ int psp_v3_1_bootloader_load_sysdrv(str
  {
        int ret;
        uint32_t psp_gfxdrv_command_reg = 0;
-       struct amdgpu_bo *psp_sysdrv;
-       void *psp_sysdrv_virt = NULL;
-       uint64_t psp_sysdrv_mem;
        struct amdgpu_device *adev = psp->adev;
-       uint32_t size, sol_reg;
+       uint32_t sol_reg;
  
        /* Check sOS sign of life register to confirm sys driver and sOS
         * are already been loaded.
        if (ret)
                return ret;
  
-       /*
-        * Create a 1 meg GART memory to store the psp sys driver
-        * binary with a 1 meg aligned address
-        */
-       size = (psp->sys_bin_size + (PSP_BOOTLOADER_1_MEG_ALIGNMENT - 1)) &
-               (~(PSP_BOOTLOADER_1_MEG_ALIGNMENT - 1));
-       ret = amdgpu_bo_create_kernel(adev, size, PSP_BOOTLOADER_1_MEG_ALIGNMENT,
-                                     AMDGPU_GEM_DOMAIN_GTT,
-                                     &psp_sysdrv,
-                                     &psp_sysdrv_mem,
-                                     &psp_sysdrv_virt);
-       if (ret)
-               return ret;
+       memset(psp->fw_pri_buf, 0, PSP_1_MEG);
  
        /* Copy PSP System Driver binary to memory */
-       memcpy(psp_sysdrv_virt, psp->sys_start_addr, psp->sys_bin_size);
+       memcpy(psp->fw_pri_buf, psp->sys_start_addr, psp->sys_bin_size);
  
        /* Provide the sys driver to bootrom */
        WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_36),
-              (uint32_t)(psp_sysdrv_mem >> 20));
+              (uint32_t)(psp->fw_pri_mc_addr >> 20));
        psp_gfxdrv_command_reg = 1 << 16;
        WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_35),
               psp_gfxdrv_command_reg);
        ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_35),
                           0x80000000, 0x80000000, false);
  
-       amdgpu_bo_free_kernel(&psp_sysdrv, &psp_sysdrv_mem, &psp_sysdrv_virt);
        return ret;
  }
  
@@@ -225,11 -207,8 +207,8 @@@ int psp_v3_1_bootloader_load_sos(struc
  {
        int ret;
        unsigned int psp_gfxdrv_command_reg = 0;
-       struct amdgpu_bo *psp_sos;
-       void *psp_sos_virt = NULL;
-       uint64_t psp_sos_mem;
        struct amdgpu_device *adev = psp->adev;
-       uint32_t size, sol_reg;
+       uint32_t sol_reg;
  
        /* Check sOS sign of life register to confirm sys driver and sOS
         * are already been loaded.
        if (ret)
                return ret;
  
-       size = (psp->sos_bin_size + (PSP_BOOTLOADER_1_MEG_ALIGNMENT - 1)) &
-               (~((uint64_t)PSP_BOOTLOADER_1_MEG_ALIGNMENT - 1));
-       ret = amdgpu_bo_create_kernel(adev, size, PSP_BOOTLOADER_1_MEG_ALIGNMENT,
-                                     AMDGPU_GEM_DOMAIN_GTT,
-                                     &psp_sos,
-                                     &psp_sos_mem,
-                                     &psp_sos_virt);
-       if (ret)
-               return ret;
+       memset(psp->fw_pri_buf, 0, PSP_1_MEG);
  
        /* Copy Secure OS binary to PSP memory */
-       memcpy(psp_sos_virt, psp->sos_start_addr, psp->sos_bin_size);
+       memcpy(psp->fw_pri_buf, psp->sos_start_addr, psp->sos_bin_size);
  
        /* Provide the PSP secure OS to bootrom */
        WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_36),
-              (uint32_t)(psp_sos_mem >> 20));
+              (uint32_t)(psp->fw_pri_mc_addr >> 20));
        psp_gfxdrv_command_reg = 2 << 16;
        WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_35),
               psp_gfxdrv_command_reg);
                           0, true);
  #endif
  
-       amdgpu_bo_free_kernel(&psp_sos, &psp_sos_mem, &psp_sos_virt);
        return ret;
  }
  
@@@ -300,7 -268,6 +268,6 @@@ int psp_v3_1_prep_cmd_buf(struct amdgpu
  int psp_v3_1_ring_init(struct psp_context *psp, enum psp_ring_type ring_type)
  {
        int ret = 0;
-       unsigned int psp_ring_reg = 0;
        struct psp_ring *ring;
        struct amdgpu_device *adev = psp->adev;
  
                return ret;
        }
  
+       return 0;
+ }
+ int psp_v3_1_ring_create(struct psp_context *psp, enum psp_ring_type ring_type)
+ {
+       int ret = 0;
+       unsigned int psp_ring_reg = 0;
+       struct psp_ring *ring = &psp->km_ring;
+       struct amdgpu_device *adev = psp->adev;
        /* Write low address of the ring to C2PMSG_69 */
        psp_ring_reg = lower_32_bits(ring->ring_mem_mc_addr);
        WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_69), psp_ring_reg);
        return ret;
  }
  
+ int psp_v3_1_ring_destroy(struct psp_context *psp, enum psp_ring_type ring_type)
+ {
+       int ret = 0;
+       struct psp_ring *ring;
+       unsigned int psp_ring_reg = 0;
+       struct amdgpu_device *adev = psp->adev;
+       ring = &psp->km_ring;
+       /* Write the ring destroy command to C2PMSG_64 */
+       psp_ring_reg = 3 << 16;
+       WREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64), psp_ring_reg);
+       /* there might be handshake issue with hardware which needs delay */
+       mdelay(20);
+       /* Wait for response flag (bit 31) in C2PMSG_64 */
+       ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64),
+                          0x80000000, 0x80000000, false);
+       if (ring->ring_mem)
+               amdgpu_bo_free_kernel(&adev->firmware.rbuf,
+                                     &ring->ring_mem_mc_addr,
+                                     (void **)&ring->ring_mem);
+       return ret;
+ }
  int psp_v3_1_cmd_submit(struct psp_context *psp,
                        struct amdgpu_firmware_info *ucode,
                        uint64_t cmd_buf_mc_addr, uint64_t fence_mc_addr,
@@@ -23,9 -23,9 +23,9 @@@
  #include <linux/firmware.h>
  #include <linux/slab.h>
  #include <linux/module.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "amdgpu.h"
- #include "amdgpu_atombios.h"
+ #include "amdgpu_atomfirmware.h"
  #include "amdgpu_ih.h"
  #include "amdgpu_uvd.h"
  #include "amdgpu_vce.h"
@@@ -405,11 -405,11 +405,11 @@@ static void soc15_gpu_pci_config_reset(
  
  static int soc15_asic_reset(struct amdgpu_device *adev)
  {
-       amdgpu_atombios_scratch_regs_engine_hung(adev, true);
+       amdgpu_atomfirmware_scratch_regs_engine_hung(adev, true);
  
        soc15_gpu_pci_config_reset(adev);
  
-       amdgpu_atombios_scratch_regs_engine_hung(adev, false);
+       amdgpu_atomfirmware_scratch_regs_engine_hung(adev, false);
  
        return 0;
  }
@@@ -505,8 -505,7 +505,7 @@@ int soc15_set_ip_blocks(struct amdgpu_d
                        amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
                amdgpu_ip_block_add(adev, &gfx_v9_0_ip_block);
                amdgpu_ip_block_add(adev, &sdma_v4_0_ip_block);
-               if (!amdgpu_sriov_vf(adev))
-                       amdgpu_ip_block_add(adev, &uvd_v7_0_ip_block);
+               amdgpu_ip_block_add(adev, &uvd_v7_0_ip_block);
                amdgpu_ip_block_add(adev, &vce_v4_0_ip_block);
                break;
        default:
@@@ -24,7 -24,7 +24,7 @@@
  #include <linux/firmware.h>
  #include <linux/slab.h>
  #include <linux/module.h>
 -#include "drmP.h"
 +#include <drm/drmP.h>
  #include "radeon.h"
  #include "radeon_asic.h"
  #include "radeon_audio.h"
@@@ -9150,23 -9150,10 +9150,10 @@@ static u32 dce8_latency_watermark(struc
        a.full = dfixed_const(available_bandwidth);
        b.full = dfixed_const(wm->num_heads);
        a.full = dfixed_div(a, b);
+       tmp = div_u64((u64) dmif_size * (u64) wm->disp_clk, mc_latency + 512);
+       tmp = min(dfixed_trunc(a), tmp);
  
-       b.full = dfixed_const(mc_latency + 512);
-       c.full = dfixed_const(wm->disp_clk);
-       b.full = dfixed_div(b, c);
-       c.full = dfixed_const(dmif_size);
-       b.full = dfixed_div(c, b);
-       tmp = min(dfixed_trunc(a), dfixed_trunc(b));
-       b.full = dfixed_const(1000);
-       c.full = dfixed_const(wm->disp_clk);
-       b.full = dfixed_div(c, b);
-       c.full = dfixed_const(wm->bytes_per_pixel);
-       b.full = dfixed_mul(b, c);
-       lb_fill_bw = min(tmp, dfixed_trunc(b));
+       lb_fill_bw = min(tmp, wm->disp_clk * wm->bytes_per_pixel / 1000);
  
        a.full = dfixed_const(max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel);
        b.full = dfixed_const(1000);
@@@ -9274,14 -9261,14 +9261,14 @@@ static void dce8_program_watermarks(str
  {
        struct drm_display_mode *mode = &radeon_crtc->base.mode;
        struct dce8_wm_params wm_low, wm_high;
-       u32 pixel_period;
+       u32 active_time;
        u32 line_time = 0;
        u32 latency_watermark_a = 0, latency_watermark_b = 0;
        u32 tmp, wm_mask;
  
        if (radeon_crtc->base.enabled && num_heads && mode) {
-               pixel_period = 1000000 / (u32)mode->clock;
-               line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535);
+               active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock;
+               line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535);
  
                /* watermark for high clocks */
                if ((rdev->pm.pm_method == PM_METHOD_DPM) &&
  
                wm_high.disp_clk = mode->clock;
                wm_high.src_width = mode->crtc_hdisplay;
-               wm_high.active_time = mode->crtc_hdisplay * pixel_period;
+               wm_high.active_time = active_time;
                wm_high.blank_time = line_time - wm_high.active_time;
                wm_high.interlaced = false;
                if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  
                wm_low.disp_clk = mode->clock;
                wm_low.src_width = mode->crtc_hdisplay;
-               wm_low.active_time = mode->crtc_hdisplay * pixel_period;
+               wm_low.active_time = active_time;
                wm_low.blank_time = line_time - wm_low.active_time;
                wm_low.interlaced = false;
                if (mode->flags & DRM_MODE_FLAG_INTERLACE)
@@@ -89,7 -89,7 +89,7 @@@ static int sti_compositor_bind(struct d
                        /* Nothing to do, wait for the second round */
                        break;
                default:
-                       DRM_ERROR("Unknow subdev compoment type\n");
+                       DRM_ERROR("Unknown subdev component type\n");
                        return 1;
                }
        }
                        }
                        break;
                default:
 -                      DRM_ERROR("Unknown subdev compoment type\n");
 +                      DRM_ERROR("Unknown subdev component type\n");
                        return 1;
                }