Merge branch 'drm-next-4.9' of git://people.freedesktop.org/~agd5f/linux into drm-next
First drm-next pull for radeon and amdgpu for 4.9. Highlights: - powerplay support for iceland asics - improved GPU reset (both full asic and per block) - UVD and VCE powergating for CZ and ST - VCE clockgating for CZ and ST - Support for pre-initialized (e.g., zeroed) vram buffers - ttm cleanups - virtual display support - core and radeon/amdgpu support for page_flip_target - lots of bug fixes and clean ups * 'drm-next-4.9' of git://people.freedesktop.org/~agd5f/linux: (171 commits) drm/amdgpu: use memcpy_toio for VCE firmware upload drm/amdgpu: use memcpy_to/fromio for UVD fw upload drm/amd/powerplay: delete useless code in iceland_hwmgr.c. drm/radeon: switch UVD code to use UVD_NO_OP for padding drm/amdgpu: switch UVD code to use UVD_NO_OP for padding drm/radeon: add support for UVD_NO_OP register drm/amdgpu: add support for UVD_NO_OP register drm/amdgpu: fix VCE ib alignment value drm/amdgpu: fix IB alignment for UVD drm/amd/amdgpu: Print ring name in amdgpu_ib_schedule() drm/radeon: remove dead code, si_mc_load_microcode (v2) drm/radeon/cik: remove dead code (v2) drm/amd/powerplay: avoid NULL dereference, cz_hwmgr.c drm/amd/powerplay: avoid NULL pointer dereference drm/amdgpu/gmc8: remove dead code (v2) drm/amdgpu/gmc7: remove dead code (v2) drm/amdgpu: Fix indentation in dce_v8_0_audio_write_sad_regs() drm/amdgpu: Use correct mask in dce_v8_0_afmt_setmode() and fix comment typos. drm/amdgpu: cleanup amdgpu_vm_bo_update params drm/amdgpu: stop adding dummy entry in amdgpu_ttm_placement_init ...
This commit is contained in:
commit
e9c3ddee6a
|
@ -163,9 +163,6 @@ config DRM_AMDGPU
|
|||
If M is selected, the module will be called amdgpu.
|
||||
|
||||
source "drivers/gpu/drm/amd/amdgpu/Kconfig"
|
||||
source "drivers/gpu/drm/amd/powerplay/Kconfig"
|
||||
|
||||
source "drivers/gpu/drm/amd/acp/Kconfig"
|
||||
|
||||
source "drivers/gpu/drm/nouveau/Kconfig"
|
||||
|
||||
|
|
|
@ -25,3 +25,5 @@ config DRM_AMDGPU_GART_DEBUGFS
|
|||
Selecting this option creates a debugfs file to inspect the mapped
|
||||
pages. Uses more memory for housekeeping, enable only for debugging.
|
||||
|
||||
source "drivers/gpu/drm/amd/powerplay/Kconfig"
|
||||
source "drivers/gpu/drm/amd/acp/Kconfig"
|
||||
|
|
|
@ -58,7 +58,8 @@ amdgpu-y += \
|
|||
# add DCE block
|
||||
amdgpu-y += \
|
||||
dce_v10_0.o \
|
||||
dce_v11_0.o
|
||||
dce_v11_0.o \
|
||||
dce_virtual.o
|
||||
|
||||
# add GFX block
|
||||
amdgpu-y += \
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
#define ENCODER_OBJECT_ID_INTERNAL_VCE 0x24
|
||||
#define ENCODER_OBJECT_ID_INTERNAL_UNIPHY3 0x25
|
||||
#define ENCODER_OBJECT_ID_INTERNAL_AMCLK 0x27
|
||||
#define ENCODER_OBJECT_ID_VIRTUAL 0x28
|
||||
|
||||
#define ENCODER_OBJECT_ID_GENERAL_EXTERNAL_DVO 0xFF
|
||||
|
||||
|
@ -119,6 +120,7 @@
|
|||
#define CONNECTOR_OBJECT_ID_eDP 0x14
|
||||
#define CONNECTOR_OBJECT_ID_MXM 0x15
|
||||
#define CONNECTOR_OBJECT_ID_LVDS_eDP 0x16
|
||||
#define CONNECTOR_OBJECT_ID_VIRTUAL 0x17
|
||||
|
||||
/* deleted */
|
||||
|
||||
|
@ -147,6 +149,7 @@
|
|||
#define GRAPH_OBJECT_ENUM_ID5 0x05
|
||||
#define GRAPH_OBJECT_ENUM_ID6 0x06
|
||||
#define GRAPH_OBJECT_ENUM_ID7 0x07
|
||||
#define GRAPH_OBJECT_ENUM_VIRTUAL 0x08
|
||||
|
||||
/****************************************************/
|
||||
/* Graphics Object ID Bit definition */
|
||||
|
@ -408,6 +411,10 @@
|
|||
GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\
|
||||
ENCODER_OBJECT_ID_HDMI_ANX9805 << OBJECT_ID_SHIFT)
|
||||
|
||||
#define ENCODER_VIRTUAL_ENUM_VIRTUAL ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\
|
||||
GRAPH_OBJECT_ENUM_VIRTUAL << ENUM_ID_SHIFT |\
|
||||
ENCODER_OBJECT_ID_VIRTUAL << OBJECT_ID_SHIFT)
|
||||
|
||||
/****************************************************/
|
||||
/* Connector Object ID definition - Shared with BIOS */
|
||||
/****************************************************/
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "amdgpu_ih.h"
|
||||
#include "amdgpu_irq.h"
|
||||
#include "amdgpu_ucode.h"
|
||||
#include "amdgpu_ttm.h"
|
||||
#include "amdgpu_gds.h"
|
||||
#include "amd_powerplay.h"
|
||||
#include "amdgpu_acp.h"
|
||||
|
@ -91,6 +92,8 @@ extern unsigned amdgpu_pcie_lane_cap;
|
|||
extern unsigned amdgpu_cg_mask;
|
||||
extern unsigned amdgpu_pg_mask;
|
||||
extern char *amdgpu_disable_cu;
|
||||
extern int amdgpu_sclk_deep_sleep_en;
|
||||
extern char *amdgpu_virtual_display;
|
||||
|
||||
#define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000
|
||||
#define AMDGPU_MAX_USEC_TIMEOUT 100000 /* 100 ms */
|
||||
|
@ -248,10 +251,9 @@ struct amdgpu_vm_pte_funcs {
|
|||
uint64_t pe, uint64_t src,
|
||||
unsigned count);
|
||||
/* write pte one entry at a time with addr mapping */
|
||||
void (*write_pte)(struct amdgpu_ib *ib,
|
||||
const dma_addr_t *pages_addr, uint64_t pe,
|
||||
uint64_t addr, unsigned count,
|
||||
uint32_t incr, uint32_t flags);
|
||||
void (*write_pte)(struct amdgpu_ib *ib, uint64_t pe,
|
||||
uint64_t value, unsigned count,
|
||||
uint32_t incr);
|
||||
/* for linear pte/pde updates without addr mapping */
|
||||
void (*set_pte_pde)(struct amdgpu_ib *ib,
|
||||
uint64_t pe,
|
||||
|
@ -396,46 +398,9 @@ int amdgpu_fence_wait_empty(struct amdgpu_ring *ring);
|
|||
unsigned amdgpu_fence_count_emitted(struct amdgpu_ring *ring);
|
||||
|
||||
/*
|
||||
* TTM.
|
||||
* BO.
|
||||
*/
|
||||
|
||||
#define AMDGPU_TTM_LRU_SIZE 20
|
||||
|
||||
struct amdgpu_mman_lru {
|
||||
struct list_head *lru[TTM_NUM_MEM_TYPES];
|
||||
struct list_head *swap_lru;
|
||||
};
|
||||
|
||||
struct amdgpu_mman {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
struct drm_global_reference mem_global_ref;
|
||||
struct ttm_bo_device bdev;
|
||||
bool mem_global_referenced;
|
||||
bool initialized;
|
||||
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
struct dentry *vram;
|
||||
struct dentry *gtt;
|
||||
#endif
|
||||
|
||||
/* buffer handling */
|
||||
const struct amdgpu_buffer_funcs *buffer_funcs;
|
||||
struct amdgpu_ring *buffer_funcs_ring;
|
||||
/* Scheduler entity for buffer moves */
|
||||
struct amd_sched_entity entity;
|
||||
|
||||
/* custom LRU management */
|
||||
struct amdgpu_mman_lru log2_size[AMDGPU_TTM_LRU_SIZE];
|
||||
};
|
||||
|
||||
int amdgpu_copy_buffer(struct amdgpu_ring *ring,
|
||||
uint64_t src_offset,
|
||||
uint64_t dst_offset,
|
||||
uint32_t byte_count,
|
||||
struct reservation_object *resv,
|
||||
struct fence **fence);
|
||||
int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma);
|
||||
|
||||
struct amdgpu_bo_list_entry {
|
||||
struct amdgpu_bo *robj;
|
||||
struct ttm_validate_buffer tv;
|
||||
|
@ -498,10 +463,12 @@ struct amdgpu_bo {
|
|||
struct amdgpu_device *adev;
|
||||
struct drm_gem_object gem_base;
|
||||
struct amdgpu_bo *parent;
|
||||
struct amdgpu_bo *shadow;
|
||||
|
||||
struct ttm_bo_kmap_obj dma_buf_vmap;
|
||||
struct amdgpu_mn *mn;
|
||||
struct list_head mn_list;
|
||||
struct list_head shadow_list;
|
||||
};
|
||||
#define gem_to_amdgpu_bo(gobj) container_of((gobj), struct amdgpu_bo, gem_base)
|
||||
|
||||
|
@ -677,6 +644,8 @@ struct amdgpu_mc {
|
|||
uint32_t fw_version;
|
||||
struct amdgpu_irq_src vm_fault;
|
||||
uint32_t vram_type;
|
||||
uint32_t srbm_soft_reset;
|
||||
struct amdgpu_mode_mc_save save;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -721,10 +690,11 @@ void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev,
|
|||
*/
|
||||
|
||||
struct amdgpu_flip_work {
|
||||
struct work_struct flip_work;
|
||||
struct delayed_work flip_work;
|
||||
struct work_struct unpin_work;
|
||||
struct amdgpu_device *adev;
|
||||
int crtc_id;
|
||||
u32 target_vblank;
|
||||
uint64_t base;
|
||||
struct drm_pending_vblank_event *event;
|
||||
struct amdgpu_bo *old_rbo;
|
||||
|
@ -815,13 +785,17 @@ struct amdgpu_ring {
|
|||
/* maximum number of VMIDs */
|
||||
#define AMDGPU_NUM_VM 16
|
||||
|
||||
/* Maximum number of PTEs the hardware can write with one command */
|
||||
#define AMDGPU_VM_MAX_UPDATE_SIZE 0x3FFFF
|
||||
|
||||
/* number of entries in page table */
|
||||
#define AMDGPU_VM_PTE_COUNT (1 << amdgpu_vm_block_size)
|
||||
|
||||
/* PTBs (Page Table Blocks) need to be aligned to 32K */
|
||||
#define AMDGPU_VM_PTB_ALIGN_SIZE 32768
|
||||
#define AMDGPU_VM_PTB_ALIGN_MASK (AMDGPU_VM_PTB_ALIGN_SIZE - 1)
|
||||
#define AMDGPU_VM_PTB_ALIGN(a) (((a) + AMDGPU_VM_PTB_ALIGN_MASK) & ~AMDGPU_VM_PTB_ALIGN_MASK)
|
||||
|
||||
/* LOG2 number of continuous pages for the fragment field */
|
||||
#define AMDGPU_LOG2_PAGES_PER_FRAG 4
|
||||
|
||||
#define AMDGPU_PTE_VALID (1 << 0)
|
||||
#define AMDGPU_PTE_SYSTEM (1 << 1)
|
||||
|
@ -833,10 +807,7 @@ struct amdgpu_ring {
|
|||
#define AMDGPU_PTE_READABLE (1 << 5)
|
||||
#define AMDGPU_PTE_WRITEABLE (1 << 6)
|
||||
|
||||
/* PTE (Page Table Entry) fragment field for different page sizes */
|
||||
#define AMDGPU_PTE_FRAG_4KB (0 << 7)
|
||||
#define AMDGPU_PTE_FRAG_64KB (4 << 7)
|
||||
#define AMDGPU_LOG2_PAGES_PER_FRAG 4
|
||||
#define AMDGPU_PTE_FRAG(x) ((x & 0x1f) << 7)
|
||||
|
||||
/* How to programm VM fault handling */
|
||||
#define AMDGPU_VM_FAULT_STOP_NEVER 0
|
||||
|
@ -846,6 +817,7 @@ struct amdgpu_ring {
|
|||
struct amdgpu_vm_pt {
|
||||
struct amdgpu_bo_list_entry entry;
|
||||
uint64_t addr;
|
||||
uint64_t shadow_addr;
|
||||
};
|
||||
|
||||
struct amdgpu_vm {
|
||||
|
@ -948,7 +920,6 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
|
|||
struct amdgpu_job *job);
|
||||
int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job);
|
||||
void amdgpu_vm_reset_id(struct amdgpu_device *adev, unsigned vm_id);
|
||||
uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr);
|
||||
int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
|
||||
struct amdgpu_vm *vm);
|
||||
int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
|
||||
|
@ -957,7 +928,7 @@ int amdgpu_vm_clear_invalids(struct amdgpu_device *adev, struct amdgpu_vm *vm,
|
|||
struct amdgpu_sync *sync);
|
||||
int amdgpu_vm_bo_update(struct amdgpu_device *adev,
|
||||
struct amdgpu_bo_va *bo_va,
|
||||
struct ttm_mem_reg *mem);
|
||||
bool clear);
|
||||
void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,
|
||||
struct amdgpu_bo *bo);
|
||||
struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm,
|
||||
|
@ -1195,6 +1166,10 @@ struct amdgpu_gfx {
|
|||
unsigned ce_ram_size;
|
||||
struct amdgpu_cu_info cu_info;
|
||||
const struct amdgpu_gfx_funcs *funcs;
|
||||
|
||||
/* reset mask */
|
||||
uint32_t grbm_soft_reset;
|
||||
uint32_t srbm_soft_reset;
|
||||
};
|
||||
|
||||
int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,
|
||||
|
@ -1683,6 +1658,7 @@ struct amdgpu_uvd {
|
|||
bool address_64_bit;
|
||||
bool use_ctx_buf;
|
||||
struct amd_sched_entity entity;
|
||||
uint32_t srbm_soft_reset;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -1709,6 +1685,7 @@ struct amdgpu_vce {
|
|||
struct amdgpu_irq_src irq;
|
||||
unsigned harvest_config;
|
||||
struct amd_sched_entity entity;
|
||||
uint32_t srbm_soft_reset;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -1729,6 +1706,7 @@ struct amdgpu_sdma {
|
|||
struct amdgpu_irq_src trap_irq;
|
||||
struct amdgpu_irq_src illegal_inst_irq;
|
||||
int num_instances;
|
||||
uint32_t srbm_soft_reset;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -1956,6 +1934,7 @@ struct amdgpu_ip_block_status {
|
|||
bool valid;
|
||||
bool sw;
|
||||
bool hw;
|
||||
bool hang;
|
||||
};
|
||||
|
||||
struct amdgpu_device {
|
||||
|
@ -2055,6 +2034,7 @@ struct amdgpu_device {
|
|||
atomic_t gpu_reset_counter;
|
||||
|
||||
/* display */
|
||||
bool enable_virtual_display;
|
||||
struct amdgpu_mode_info mode_info;
|
||||
struct work_struct hotplug_work;
|
||||
struct amdgpu_irq_src crtc_irq;
|
||||
|
@ -2117,6 +2097,10 @@ struct amdgpu_device {
|
|||
struct kfd_dev *kfd;
|
||||
|
||||
struct amdgpu_virtualization virtualization;
|
||||
|
||||
/* link all shadow bo */
|
||||
struct list_head shadow_list;
|
||||
struct mutex shadow_list_lock;
|
||||
};
|
||||
|
||||
bool amdgpu_device_is_px(struct drm_device *dev);
|
||||
|
@ -2192,6 +2176,9 @@ void amdgpu_mm_wdoorbell(struct amdgpu_device *adev, u32 index, u32 v);
|
|||
#define REG_GET_FIELD(value, reg, field) \
|
||||
(((value) & REG_FIELD_MASK(reg, field)) >> REG_FIELD_SHIFT(reg, field))
|
||||
|
||||
#define WREG32_FIELD(reg, field, val) \
|
||||
WREG32(mm##reg, (RREG32(mm##reg) & ~REG_FIELD_MASK(reg, field)) | (val) << REG_FIELD_SHIFT(reg, field))
|
||||
|
||||
/*
|
||||
* BIOS helpers.
|
||||
*/
|
||||
|
@ -2242,7 +2229,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
|
|||
#define amdgpu_gart_flush_gpu_tlb(adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid))
|
||||
#define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags))
|
||||
#define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count)))
|
||||
#define amdgpu_vm_write_pte(adev, ib, pa, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pa), (pe), (addr), (count), (incr), (flags)))
|
||||
#define amdgpu_vm_write_pte(adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr)))
|
||||
#define amdgpu_vm_set_pte_pde(adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags)))
|
||||
#define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
|
||||
#define amdgpu_ring_test_ring(r) (r)->funcs->test_ring((r))
|
||||
|
@ -2387,6 +2374,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
|
|||
|
||||
/* Common functions */
|
||||
int amdgpu_gpu_reset(struct amdgpu_device *adev);
|
||||
bool amdgpu_need_backup(struct amdgpu_device *adev);
|
||||
void amdgpu_pci_config_reset(struct amdgpu_device *adev);
|
||||
bool amdgpu_card_posted(struct amdgpu_device *adev);
|
||||
void amdgpu_update_display_priority(struct amdgpu_device *adev);
|
||||
|
@ -2412,6 +2400,8 @@ uint32_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
|
|||
void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 base);
|
||||
void amdgpu_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc);
|
||||
void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size);
|
||||
u64 amdgpu_ttm_get_gtt_mem_size(struct amdgpu_device *adev);
|
||||
int amdgpu_ttm_global_init(struct amdgpu_device *adev);
|
||||
void amdgpu_program_register_sequence(struct amdgpu_device *adev,
|
||||
const u32 *registers,
|
||||
const u32 array_size);
|
||||
|
|
|
@ -259,6 +259,33 @@ static const int object_connector_convert[] = {
|
|||
DRM_MODE_CONNECTOR_Unknown
|
||||
};
|
||||
|
||||
bool amdgpu_atombios_has_dce_engine_info(struct amdgpu_device *adev)
|
||||
{
|
||||
struct amdgpu_mode_info *mode_info = &adev->mode_info;
|
||||
struct atom_context *ctx = mode_info->atom_context;
|
||||
int index = GetIndexIntoMasterTable(DATA, Object_Header);
|
||||
u16 size, data_offset;
|
||||
u8 frev, crev;
|
||||
ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj;
|
||||
ATOM_OBJECT_HEADER *obj_header;
|
||||
|
||||
if (!amdgpu_atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset))
|
||||
return false;
|
||||
|
||||
if (crev < 2)
|
||||
return false;
|
||||
|
||||
obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset);
|
||||
path_obj = (ATOM_DISPLAY_OBJECT_PATH_TABLE *)
|
||||
(ctx->bios + data_offset +
|
||||
le16_to_cpu(obj_header->usDisplayPathTableOffset));
|
||||
|
||||
if (path_obj->ucNumOfDispPath)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *adev)
|
||||
{
|
||||
struct amdgpu_mode_info *mode_info = &adev->mode_info;
|
||||
|
|
|
@ -140,6 +140,8 @@ struct amdgpu_i2c_bus_rec amdgpu_atombios_lookup_i2c_gpio(struct amdgpu_device *
|
|||
uint8_t id);
|
||||
void amdgpu_atombios_i2c_init(struct amdgpu_device *adev);
|
||||
|
||||
bool amdgpu_atombios_has_dce_engine_info(struct amdgpu_device *adev);
|
||||
|
||||
bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *adev);
|
||||
|
||||
int amdgpu_atombios_get_clock_info(struct amdgpu_device *adev);
|
||||
|
|
|
@ -39,7 +39,8 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
|
|||
start_jiffies = jiffies;
|
||||
for (i = 0; i < n; i++) {
|
||||
struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring;
|
||||
r = amdgpu_copy_buffer(ring, saddr, daddr, size, NULL, &fence);
|
||||
r = amdgpu_copy_buffer(ring, saddr, daddr, size, NULL, &fence,
|
||||
false);
|
||||
if (r)
|
||||
goto exit_do_move;
|
||||
r = fence_wait(fence, false);
|
||||
|
|
|
@ -1504,6 +1504,86 @@ static const struct drm_connector_funcs amdgpu_connector_edp_funcs = {
|
|||
.force = amdgpu_connector_dvi_force,
|
||||
};
|
||||
|
||||
static struct drm_encoder *
|
||||
amdgpu_connector_virtual_encoder(struct drm_connector *connector)
|
||||
{
|
||||
int enc_id = connector->encoder_ids[0];
|
||||
struct drm_encoder *encoder;
|
||||
int i;
|
||||
for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
|
||||
if (connector->encoder_ids[i] == 0)
|
||||
break;
|
||||
|
||||
encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
|
||||
if (!encoder)
|
||||
continue;
|
||||
|
||||
if (encoder->encoder_type == DRM_MODE_ENCODER_VIRTUAL)
|
||||
return encoder;
|
||||
}
|
||||
|
||||
/* pick the first one */
|
||||
if (enc_id)
|
||||
return drm_encoder_find(connector->dev, enc_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int amdgpu_connector_virtual_get_modes(struct drm_connector *connector)
|
||||
{
|
||||
struct drm_encoder *encoder = amdgpu_connector_best_single_encoder(connector);
|
||||
|
||||
if (encoder) {
|
||||
amdgpu_connector_add_common_modes(encoder, connector);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int amdgpu_connector_virtual_mode_valid(struct drm_connector *connector,
|
||||
struct drm_display_mode *mode)
|
||||
{
|
||||
return MODE_OK;
|
||||
}
|
||||
|
||||
int amdgpu_connector_virtual_dpms(struct drm_connector *connector, int mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum drm_connector_status
|
||||
|
||||
amdgpu_connector_virtual_detect(struct drm_connector *connector, bool force)
|
||||
{
|
||||
return connector_status_connected;
|
||||
}
|
||||
|
||||
int amdgpu_connector_virtual_set_property(struct drm_connector *connector,
|
||||
struct drm_property *property,
|
||||
uint64_t val)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void amdgpu_connector_virtual_force(struct drm_connector *connector)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static const struct drm_connector_helper_funcs amdgpu_connector_virtual_helper_funcs = {
|
||||
.get_modes = amdgpu_connector_virtual_get_modes,
|
||||
.mode_valid = amdgpu_connector_virtual_mode_valid,
|
||||
.best_encoder = amdgpu_connector_virtual_encoder,
|
||||
};
|
||||
|
||||
static const struct drm_connector_funcs amdgpu_connector_virtual_funcs = {
|
||||
.dpms = amdgpu_connector_virtual_dpms,
|
||||
.detect = amdgpu_connector_virtual_detect,
|
||||
.fill_modes = drm_helper_probe_single_connector_modes,
|
||||
.set_property = amdgpu_connector_virtual_set_property,
|
||||
.destroy = amdgpu_connector_destroy,
|
||||
.force = amdgpu_connector_virtual_force,
|
||||
};
|
||||
|
||||
void
|
||||
amdgpu_connector_add(struct amdgpu_device *adev,
|
||||
uint32_t connector_id,
|
||||
|
@ -1888,6 +1968,17 @@ amdgpu_connector_add(struct amdgpu_device *adev,
|
|||
connector->interlace_allowed = false;
|
||||
connector->doublescan_allowed = false;
|
||||
break;
|
||||
case DRM_MODE_CONNECTOR_VIRTUAL:
|
||||
amdgpu_dig_connector = kzalloc(sizeof(struct amdgpu_connector_atom_dig), GFP_KERNEL);
|
||||
if (!amdgpu_dig_connector)
|
||||
goto failed;
|
||||
amdgpu_connector->con_priv = amdgpu_dig_connector;
|
||||
drm_connector_init(dev, &amdgpu_connector->base, &amdgpu_connector_virtual_funcs, connector_type);
|
||||
drm_connector_helper_add(&amdgpu_connector->base, &amdgpu_connector_virtual_helper_funcs);
|
||||
subpixel_order = SubPixelHorizontalRGB;
|
||||
connector->interlace_allowed = false;
|
||||
connector->doublescan_allowed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -287,18 +287,56 @@ static u64 amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev)
|
|||
return max(bytes_moved_threshold, 1024*1024ull);
|
||||
}
|
||||
|
||||
static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p,
|
||||
struct amdgpu_bo *bo)
|
||||
{
|
||||
u64 initial_bytes_moved;
|
||||
uint32_t domain;
|
||||
int r;
|
||||
|
||||
if (bo->pin_count)
|
||||
return 0;
|
||||
|
||||
/* Avoid moving this one if we have moved too many buffers
|
||||
* for this IB already.
|
||||
*
|
||||
* Note that this allows moving at least one buffer of
|
||||
* any size, because it doesn't take the current "bo"
|
||||
* into account. We don't want to disallow buffer moves
|
||||
* completely.
|
||||
*/
|
||||
if (p->bytes_moved <= p->bytes_moved_threshold)
|
||||
domain = bo->prefered_domains;
|
||||
else
|
||||
domain = bo->allowed_domains;
|
||||
|
||||
retry:
|
||||
amdgpu_ttm_placement_from_domain(bo, domain);
|
||||
initial_bytes_moved = atomic64_read(&bo->adev->num_bytes_moved);
|
||||
r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false);
|
||||
p->bytes_moved += atomic64_read(&bo->adev->num_bytes_moved) -
|
||||
initial_bytes_moved;
|
||||
|
||||
if (unlikely(r)) {
|
||||
if (r != -ERESTARTSYS && domain != bo->allowed_domains) {
|
||||
domain = bo->allowed_domains;
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p,
|
||||
struct list_head *validated)
|
||||
{
|
||||
struct amdgpu_bo_list_entry *lobj;
|
||||
u64 initial_bytes_moved;
|
||||
int r;
|
||||
|
||||
list_for_each_entry(lobj, validated, tv.head) {
|
||||
struct amdgpu_bo *bo = lobj->robj;
|
||||
bool binding_userptr = false;
|
||||
struct mm_struct *usermm;
|
||||
uint32_t domain;
|
||||
|
||||
usermm = amdgpu_ttm_tt_get_usermm(bo->tbo.ttm);
|
||||
if (usermm && usermm != current->mm)
|
||||
|
@ -313,35 +351,13 @@ int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p,
|
|||
binding_userptr = true;
|
||||
}
|
||||
|
||||
if (bo->pin_count)
|
||||
continue;
|
||||
|
||||
/* Avoid moving this one if we have moved too many buffers
|
||||
* for this IB already.
|
||||
*
|
||||
* Note that this allows moving at least one buffer of
|
||||
* any size, because it doesn't take the current "bo"
|
||||
* into account. We don't want to disallow buffer moves
|
||||
* completely.
|
||||
*/
|
||||
if (p->bytes_moved <= p->bytes_moved_threshold)
|
||||
domain = bo->prefered_domains;
|
||||
else
|
||||
domain = bo->allowed_domains;
|
||||
|
||||
retry:
|
||||
amdgpu_ttm_placement_from_domain(bo, domain);
|
||||
initial_bytes_moved = atomic64_read(&bo->adev->num_bytes_moved);
|
||||
r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false);
|
||||
p->bytes_moved += atomic64_read(&bo->adev->num_bytes_moved) -
|
||||
initial_bytes_moved;
|
||||
|
||||
if (unlikely(r)) {
|
||||
if (r != -ERESTARTSYS && domain != bo->allowed_domains) {
|
||||
domain = bo->allowed_domains;
|
||||
goto retry;
|
||||
}
|
||||
r = amdgpu_cs_bo_validate(p, bo);
|
||||
if (r)
|
||||
return r;
|
||||
if (bo->shadow) {
|
||||
r = amdgpu_cs_bo_validate(p, bo);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (binding_userptr) {
|
||||
|
@ -386,8 +402,10 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
|
|||
|
||||
r = ttm_eu_reserve_buffers(&p->ticket, &p->validated, true,
|
||||
&duplicates);
|
||||
if (unlikely(r != 0))
|
||||
if (unlikely(r != 0)) {
|
||||
DRM_ERROR("ttm_eu_reserve_buffers failed.\n");
|
||||
goto error_free_pages;
|
||||
}
|
||||
|
||||
/* Without a BO list we don't have userptr BOs */
|
||||
if (!p->bo_list)
|
||||
|
@ -427,9 +445,10 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
|
|||
/* Unreserve everything again. */
|
||||
ttm_eu_backoff_reservation(&p->ticket, &p->validated);
|
||||
|
||||
/* We tried to often, just abort */
|
||||
/* We tried too many times, just abort */
|
||||
if (!--tries) {
|
||||
r = -EDEADLK;
|
||||
DRM_ERROR("deadlock in %s\n", __func__);
|
||||
goto error_free_pages;
|
||||
}
|
||||
|
||||
|
@ -441,11 +460,13 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
|
|||
sizeof(struct page*));
|
||||
if (!e->user_pages) {
|
||||
r = -ENOMEM;
|
||||
DRM_ERROR("calloc failure in %s\n", __func__);
|
||||
goto error_free_pages;
|
||||
}
|
||||
|
||||
r = amdgpu_ttm_tt_get_user_pages(ttm, e->user_pages);
|
||||
if (r) {
|
||||
DRM_ERROR("amdgpu_ttm_tt_get_user_pages failed.\n");
|
||||
drm_free_large(e->user_pages);
|
||||
e->user_pages = NULL;
|
||||
goto error_free_pages;
|
||||
|
@ -462,12 +483,16 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
|
|||
p->bytes_moved = 0;
|
||||
|
||||
r = amdgpu_cs_list_validate(p, &duplicates);
|
||||
if (r)
|
||||
if (r) {
|
||||
DRM_ERROR("amdgpu_cs_list_validate(duplicates) failed.\n");
|
||||
goto error_validate;
|
||||
}
|
||||
|
||||
r = amdgpu_cs_list_validate(p, &p->validated);
|
||||
if (r)
|
||||
if (r) {
|
||||
DRM_ERROR("amdgpu_cs_list_validate(validated) failed.\n");
|
||||
goto error_validate;
|
||||
}
|
||||
|
||||
fpriv->vm.last_eviction_counter =
|
||||
atomic64_read(&p->adev->num_evictions);
|
||||
|
@ -617,7 +642,7 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p,
|
|||
if (bo_va == NULL)
|
||||
continue;
|
||||
|
||||
r = amdgpu_vm_bo_update(adev, bo_va, &bo->tbo.mem);
|
||||
r = amdgpu_vm_bo_update(adev, bo_va, false);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#endif
|
||||
#include "vi.h"
|
||||
#include "bif/bif_4_1_d.h"
|
||||
#include <linux/pci.h>
|
||||
|
||||
static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev);
|
||||
static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev);
|
||||
|
@ -1181,10 +1182,38 @@ int amdgpu_ip_block_version_cmp(struct amdgpu_device *adev,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void amdgpu_whether_enable_virtual_display(struct amdgpu_device *adev)
|
||||
{
|
||||
adev->enable_virtual_display = false;
|
||||
|
||||
if (amdgpu_virtual_display) {
|
||||
struct drm_device *ddev = adev->ddev;
|
||||
const char *pci_address_name = pci_name(ddev->pdev);
|
||||
char *pciaddstr, *pciaddstr_tmp, *pciaddname;
|
||||
|
||||
pciaddstr = kstrdup(amdgpu_virtual_display, GFP_KERNEL);
|
||||
pciaddstr_tmp = pciaddstr;
|
||||
while ((pciaddname = strsep(&pciaddstr_tmp, ";"))) {
|
||||
if (!strcmp(pci_address_name, pciaddname)) {
|
||||
adev->enable_virtual_display = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DRM_INFO("virtual display string:%s, %s:virtual_display:%d\n",
|
||||
amdgpu_virtual_display, pci_address_name,
|
||||
adev->enable_virtual_display);
|
||||
|
||||
kfree(pciaddstr);
|
||||
}
|
||||
}
|
||||
|
||||
static int amdgpu_early_init(struct amdgpu_device *adev)
|
||||
{
|
||||
int i, r;
|
||||
|
||||
amdgpu_whether_enable_virtual_display(adev);
|
||||
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_TOPAZ:
|
||||
case CHIP_TONGA:
|
||||
|
@ -1521,6 +1550,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
|
|||
spin_lock_init(&adev->gc_cac_idx_lock);
|
||||
spin_lock_init(&adev->audio_endpt_idx_lock);
|
||||
|
||||
INIT_LIST_HEAD(&adev->shadow_list);
|
||||
mutex_init(&adev->shadow_list_lock);
|
||||
|
||||
adev->rmmio_base = pci_resource_start(adev->pdev, 5);
|
||||
adev->rmmio_size = pci_resource_len(adev->pdev, 5);
|
||||
adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size);
|
||||
|
@ -1937,6 +1969,126 @@ int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool amdgpu_check_soft_reset(struct amdgpu_device *adev)
|
||||
{
|
||||
int i;
|
||||
bool asic_hang = false;
|
||||
|
||||
for (i = 0; i < adev->num_ip_blocks; i++) {
|
||||
if (!adev->ip_block_status[i].valid)
|
||||
continue;
|
||||
if (adev->ip_blocks[i].funcs->check_soft_reset)
|
||||
adev->ip_blocks[i].funcs->check_soft_reset(adev);
|
||||
if (adev->ip_block_status[i].hang) {
|
||||
DRM_INFO("IP block:%d is hang!\n", i);
|
||||
asic_hang = true;
|
||||
}
|
||||
}
|
||||
return asic_hang;
|
||||
}
|
||||
|
||||
int amdgpu_pre_soft_reset(struct amdgpu_device *adev)
|
||||
{
|
||||
int i, r = 0;
|
||||
|
||||
for (i = 0; i < adev->num_ip_blocks; i++) {
|
||||
if (!adev->ip_block_status[i].valid)
|
||||
continue;
|
||||
if (adev->ip_block_status[i].hang &&
|
||||
adev->ip_blocks[i].funcs->pre_soft_reset) {
|
||||
r = adev->ip_blocks[i].funcs->pre_soft_reset(adev);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool amdgpu_need_full_reset(struct amdgpu_device *adev)
|
||||
{
|
||||
if (adev->ip_block_status[AMD_IP_BLOCK_TYPE_GMC].hang ||
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_SMC].hang ||
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_ACP].hang ||
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_DCE].hang) {
|
||||
DRM_INFO("Some block need full reset!\n");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int amdgpu_soft_reset(struct amdgpu_device *adev)
|
||||
{
|
||||
int i, r = 0;
|
||||
|
||||
for (i = 0; i < adev->num_ip_blocks; i++) {
|
||||
if (!adev->ip_block_status[i].valid)
|
||||
continue;
|
||||
if (adev->ip_block_status[i].hang &&
|
||||
adev->ip_blocks[i].funcs->soft_reset) {
|
||||
r = adev->ip_blocks[i].funcs->soft_reset(adev);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int amdgpu_post_soft_reset(struct amdgpu_device *adev)
|
||||
{
|
||||
int i, r = 0;
|
||||
|
||||
for (i = 0; i < adev->num_ip_blocks; i++) {
|
||||
if (!adev->ip_block_status[i].valid)
|
||||
continue;
|
||||
if (adev->ip_block_status[i].hang &&
|
||||
adev->ip_blocks[i].funcs->post_soft_reset)
|
||||
r = adev->ip_blocks[i].funcs->post_soft_reset(adev);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool amdgpu_need_backup(struct amdgpu_device *adev)
|
||||
{
|
||||
if (adev->flags & AMD_IS_APU)
|
||||
return false;
|
||||
|
||||
return amdgpu_lockup_timeout > 0 ? true : false;
|
||||
}
|
||||
|
||||
static int amdgpu_recover_vram_from_shadow(struct amdgpu_device *adev,
|
||||
struct amdgpu_ring *ring,
|
||||
struct amdgpu_bo *bo,
|
||||
struct fence **fence)
|
||||
{
|
||||
uint32_t domain;
|
||||
int r;
|
||||
|
||||
if (!bo->shadow)
|
||||
return 0;
|
||||
|
||||
r = amdgpu_bo_reserve(bo, false);
|
||||
if (r)
|
||||
return r;
|
||||
domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
|
||||
/* if bo has been evicted, then no need to recover */
|
||||
if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
|
||||
r = amdgpu_bo_restore_from_shadow(adev, ring, bo,
|
||||
NULL, fence, true);
|
||||
if (r) {
|
||||
DRM_ERROR("recover page table failed!\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
err:
|
||||
amdgpu_bo_unreserve(bo);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_gpu_reset - reset the asic
|
||||
*
|
||||
|
@ -1949,6 +2101,12 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
|
|||
{
|
||||
int i, r;
|
||||
int resched;
|
||||
bool need_full_reset;
|
||||
|
||||
if (!amdgpu_check_soft_reset(adev)) {
|
||||
DRM_INFO("No hardware hang detected. Did some blocks stall?\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
atomic_inc(&adev->gpu_reset_counter);
|
||||
|
||||
|
@ -1967,40 +2125,88 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
|
|||
/* after all hw jobs are reset, hw fence is meaningless, so force_completion */
|
||||
amdgpu_fence_driver_force_completion(adev);
|
||||
|
||||
/* save scratch */
|
||||
amdgpu_atombios_scratch_regs_save(adev);
|
||||
r = amdgpu_suspend(adev);
|
||||
need_full_reset = amdgpu_need_full_reset(adev);
|
||||
|
||||
if (!need_full_reset) {
|
||||
amdgpu_pre_soft_reset(adev);
|
||||
r = amdgpu_soft_reset(adev);
|
||||
amdgpu_post_soft_reset(adev);
|
||||
if (r || amdgpu_check_soft_reset(adev)) {
|
||||
DRM_INFO("soft reset failed, will fallback to full reset!\n");
|
||||
need_full_reset = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (need_full_reset) {
|
||||
/* save scratch */
|
||||
amdgpu_atombios_scratch_regs_save(adev);
|
||||
r = amdgpu_suspend(adev);
|
||||
|
||||
retry:
|
||||
/* Disable fb access */
|
||||
if (adev->mode_info.num_crtc) {
|
||||
struct amdgpu_mode_mc_save save;
|
||||
amdgpu_display_stop_mc_access(adev, &save);
|
||||
amdgpu_wait_for_idle(adev, AMD_IP_BLOCK_TYPE_GMC);
|
||||
}
|
||||
/* Disable fb access */
|
||||
if (adev->mode_info.num_crtc) {
|
||||
struct amdgpu_mode_mc_save save;
|
||||
amdgpu_display_stop_mc_access(adev, &save);
|
||||
amdgpu_wait_for_idle(adev, AMD_IP_BLOCK_TYPE_GMC);
|
||||
}
|
||||
|
||||
r = amdgpu_asic_reset(adev);
|
||||
/* post card */
|
||||
amdgpu_atom_asic_init(adev->mode_info.atom_context);
|
||||
r = amdgpu_asic_reset(adev);
|
||||
/* post card */
|
||||
amdgpu_atom_asic_init(adev->mode_info.atom_context);
|
||||
|
||||
if (!r) {
|
||||
dev_info(adev->dev, "GPU reset succeeded, trying to resume\n");
|
||||
r = amdgpu_resume(adev);
|
||||
if (!r) {
|
||||
dev_info(adev->dev, "GPU reset succeeded, trying to resume\n");
|
||||
r = amdgpu_resume(adev);
|
||||
}
|
||||
/* restore scratch */
|
||||
amdgpu_atombios_scratch_regs_restore(adev);
|
||||
}
|
||||
/* restore scratch */
|
||||
amdgpu_atombios_scratch_regs_restore(adev);
|
||||
if (!r) {
|
||||
amdgpu_irq_gpu_reset_resume_helper(adev);
|
||||
r = amdgpu_ib_ring_tests(adev);
|
||||
if (r) {
|
||||
dev_err(adev->dev, "ib ring test failed (%d).\n", r);
|
||||
r = amdgpu_suspend(adev);
|
||||
need_full_reset = true;
|
||||
goto retry;
|
||||
}
|
||||
/**
|
||||
* recovery vm page tables, since we cannot depend on VRAM is
|
||||
* consistent after gpu full reset.
|
||||
*/
|
||||
if (need_full_reset && amdgpu_need_backup(adev)) {
|
||||
struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring;
|
||||
struct amdgpu_bo *bo, *tmp;
|
||||
struct fence *fence = NULL, *next = NULL;
|
||||
|
||||
DRM_INFO("recover vram bo from shadow\n");
|
||||
mutex_lock(&adev->shadow_list_lock);
|
||||
list_for_each_entry_safe(bo, tmp, &adev->shadow_list, shadow_list) {
|
||||
amdgpu_recover_vram_from_shadow(adev, ring, bo, &next);
|
||||
if (fence) {
|
||||
r = fence_wait(fence, false);
|
||||
if (r) {
|
||||
WARN(r, "recovery from shadow isn't comleted\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fence_put(fence);
|
||||
fence = next;
|
||||
}
|
||||
mutex_unlock(&adev->shadow_list_lock);
|
||||
if (fence) {
|
||||
r = fence_wait(fence, false);
|
||||
if (r)
|
||||
WARN(r, "recovery from shadow isn't comleted\n");
|
||||
}
|
||||
fence_put(fence);
|
||||
}
|
||||
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
|
||||
struct amdgpu_ring *ring = adev->rings[i];
|
||||
if (!ring)
|
||||
continue;
|
||||
|
||||
amd_sched_job_recovery(&ring->sched);
|
||||
kthread_unpark(ring->sched.thread);
|
||||
}
|
||||
|
@ -2020,7 +2226,6 @@ retry:
|
|||
/* bad news, how to tell it to userspace ? */
|
||||
dev_info(adev->dev, "GPU reset failed\n");
|
||||
}
|
||||
amdgpu_irq_gpu_reset_resume_helper(adev);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -2178,22 +2383,26 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
|
|||
struct amdgpu_device *adev = f->f_inode->i_private;
|
||||
ssize_t result = 0;
|
||||
int r;
|
||||
bool use_bank;
|
||||
bool pm_pg_lock, use_bank;
|
||||
unsigned instance_bank, sh_bank, se_bank;
|
||||
|
||||
if (size & 0x3 || *pos & 0x3)
|
||||
return -EINVAL;
|
||||
|
||||
/* are we reading registers for which a PG lock is necessary? */
|
||||
pm_pg_lock = (*pos >> 23) & 1;
|
||||
|
||||
if (*pos & (1ULL << 62)) {
|
||||
se_bank = (*pos >> 24) & 0x3FF;
|
||||
sh_bank = (*pos >> 34) & 0x3FF;
|
||||
instance_bank = (*pos >> 44) & 0x3FF;
|
||||
use_bank = 1;
|
||||
*pos &= 0xFFFFFF;
|
||||
} else {
|
||||
use_bank = 0;
|
||||
}
|
||||
|
||||
*pos &= 0x3FFFF;
|
||||
|
||||
if (use_bank) {
|
||||
if (sh_bank >= adev->gfx.config.max_sh_per_se ||
|
||||
se_bank >= adev->gfx.config.max_shader_engines)
|
||||
|
@ -2203,6 +2412,9 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
|
|||
sh_bank, instance_bank);
|
||||
}
|
||||
|
||||
if (pm_pg_lock)
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
|
||||
while (size) {
|
||||
uint32_t value;
|
||||
|
||||
|
@ -2228,6 +2440,9 @@ end:
|
|||
mutex_unlock(&adev->grbm_idx_mutex);
|
||||
}
|
||||
|
||||
if (pm_pg_lock)
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2443,7 +2658,7 @@ static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf,
|
|||
return -ENOMEM;
|
||||
|
||||
/* version, increment each time something is added */
|
||||
config[no_regs++] = 0;
|
||||
config[no_regs++] = 2;
|
||||
config[no_regs++] = adev->gfx.config.max_shader_engines;
|
||||
config[no_regs++] = adev->gfx.config.max_tile_pipes;
|
||||
config[no_regs++] = adev->gfx.config.max_cu_per_sh;
|
||||
|
@ -2468,6 +2683,15 @@ static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf,
|
|||
config[no_regs++] = adev->gfx.config.gb_addr_config;
|
||||
config[no_regs++] = adev->gfx.config.num_rbs;
|
||||
|
||||
/* rev==1 */
|
||||
config[no_regs++] = adev->rev_id;
|
||||
config[no_regs++] = adev->pg_flags;
|
||||
config[no_regs++] = adev->cg_flags;
|
||||
|
||||
/* rev==2 */
|
||||
config[no_regs++] = adev->family;
|
||||
config[no_regs++] = adev->external_rev_id;
|
||||
|
||||
while (size && (*pos < no_regs * 4)) {
|
||||
uint32_t value;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ static void amdgpu_flip_callback(struct fence *f, struct fence_cb *cb)
|
|||
container_of(cb, struct amdgpu_flip_work, cb);
|
||||
|
||||
fence_put(f);
|
||||
schedule_work(&work->flip_work);
|
||||
schedule_work(&work->flip_work.work);
|
||||
}
|
||||
|
||||
static bool amdgpu_flip_handle_fence(struct amdgpu_flip_work *work,
|
||||
|
@ -63,16 +63,17 @@ static bool amdgpu_flip_handle_fence(struct amdgpu_flip_work *work,
|
|||
|
||||
static void amdgpu_flip_work_func(struct work_struct *__work)
|
||||
{
|
||||
struct delayed_work *delayed_work =
|
||||
container_of(__work, struct delayed_work, work);
|
||||
struct amdgpu_flip_work *work =
|
||||
container_of(__work, struct amdgpu_flip_work, flip_work);
|
||||
container_of(delayed_work, struct amdgpu_flip_work, flip_work);
|
||||
struct amdgpu_device *adev = work->adev;
|
||||
struct amdgpu_crtc *amdgpuCrtc = adev->mode_info.crtcs[work->crtc_id];
|
||||
|
||||
struct drm_crtc *crtc = &amdgpuCrtc->base;
|
||||
unsigned long flags;
|
||||
unsigned i, repcnt = 4;
|
||||
int vpos, hpos, stat, min_udelay = 0;
|
||||
struct drm_vblank_crtc *vblank = &crtc->dev->vblank[work->crtc_id];
|
||||
unsigned i;
|
||||
int vpos, hpos;
|
||||
|
||||
if (amdgpu_flip_handle_fence(work, &work->excl))
|
||||
return;
|
||||
|
@ -81,55 +82,23 @@ static void amdgpu_flip_work_func(struct work_struct *__work)
|
|||
if (amdgpu_flip_handle_fence(work, &work->shared[i]))
|
||||
return;
|
||||
|
||||
/* We borrow the event spin lock for protecting flip_status */
|
||||
spin_lock_irqsave(&crtc->dev->event_lock, flags);
|
||||
|
||||
/* If this happens to execute within the "virtually extended" vblank
|
||||
* interval before the start of the real vblank interval then it needs
|
||||
* to delay programming the mmio flip until the real vblank is entered.
|
||||
* This prevents completing a flip too early due to the way we fudge
|
||||
* our vblank counter and vblank timestamps in order to work around the
|
||||
* problem that the hw fires vblank interrupts before actual start of
|
||||
* vblank (when line buffer refilling is done for a frame). It
|
||||
* complements the fudging logic in amdgpu_get_crtc_scanoutpos() for
|
||||
* timestamping and amdgpu_get_vblank_counter_kms() for vblank counts.
|
||||
*
|
||||
* In practice this won't execute very often unless on very fast
|
||||
* machines because the time window for this to happen is very small.
|
||||
/* Wait until we're out of the vertical blank period before the one
|
||||
* targeted by the flip
|
||||
*/
|
||||
while (amdgpuCrtc->enabled && --repcnt) {
|
||||
/* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank
|
||||
* start in hpos, and to the "fudged earlier" vblank start in
|
||||
* vpos.
|
||||
*/
|
||||
stat = amdgpu_get_crtc_scanoutpos(adev->ddev, work->crtc_id,
|
||||
GET_DISTANCE_TO_VBLANKSTART,
|
||||
&vpos, &hpos, NULL, NULL,
|
||||
&crtc->hwmode);
|
||||
|
||||
if ((stat & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE)) !=
|
||||
(DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE) ||
|
||||
!(vpos >= 0 && hpos <= 0))
|
||||
break;
|
||||
|
||||
/* Sleep at least until estimated real start of hw vblank */
|
||||
min_udelay = (-hpos + 1) * max(vblank->linedur_ns / 1000, 5);
|
||||
if (min_udelay > vblank->framedur_ns / 2000) {
|
||||
/* Don't wait ridiculously long - something is wrong */
|
||||
repcnt = 0;
|
||||
break;
|
||||
}
|
||||
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
|
||||
usleep_range(min_udelay, 2 * min_udelay);
|
||||
spin_lock_irqsave(&crtc->dev->event_lock, flags);
|
||||
if (amdgpuCrtc->enabled &&
|
||||
(amdgpu_get_crtc_scanoutpos(adev->ddev, work->crtc_id, 0,
|
||||
&vpos, &hpos, NULL, NULL,
|
||||
&crtc->hwmode)
|
||||
& (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK)) ==
|
||||
(DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK) &&
|
||||
(int)(work->target_vblank -
|
||||
amdgpu_get_vblank_counter_kms(adev->ddev, amdgpuCrtc->crtc_id)) > 0) {
|
||||
schedule_delayed_work(&work->flip_work, usecs_to_jiffies(1000));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!repcnt)
|
||||
DRM_DEBUG_DRIVER("Delay problem on crtc %d: min_udelay %d, "
|
||||
"framedur %d, linedur %d, stat %d, vpos %d, "
|
||||
"hpos %d\n", work->crtc_id, min_udelay,
|
||||
vblank->framedur_ns / 1000,
|
||||
vblank->linedur_ns / 1000, stat, vpos, hpos);
|
||||
/* We borrow the event spin lock for protecting flip_status */
|
||||
spin_lock_irqsave(&crtc->dev->event_lock, flags);
|
||||
|
||||
/* Do the flip (mmio) */
|
||||
adev->mode_info.funcs->page_flip(adev, work->crtc_id, work->base, work->async);
|
||||
|
@ -169,10 +138,10 @@ static void amdgpu_unpin_work_func(struct work_struct *__work)
|
|||
kfree(work);
|
||||
}
|
||||
|
||||
int amdgpu_crtc_page_flip(struct drm_crtc *crtc,
|
||||
struct drm_framebuffer *fb,
|
||||
struct drm_pending_vblank_event *event,
|
||||
uint32_t page_flip_flags)
|
||||
int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
|
||||
struct drm_framebuffer *fb,
|
||||
struct drm_pending_vblank_event *event,
|
||||
uint32_t page_flip_flags, uint32_t target)
|
||||
{
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct amdgpu_device *adev = dev->dev_private;
|
||||
|
@ -191,7 +160,7 @@ int amdgpu_crtc_page_flip(struct drm_crtc *crtc,
|
|||
if (work == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
INIT_WORK(&work->flip_work, amdgpu_flip_work_func);
|
||||
INIT_DELAYED_WORK(&work->flip_work, amdgpu_flip_work_func);
|
||||
INIT_WORK(&work->unpin_work, amdgpu_unpin_work_func);
|
||||
|
||||
work->event = event;
|
||||
|
@ -237,12 +206,8 @@ int amdgpu_crtc_page_flip(struct drm_crtc *crtc,
|
|||
amdgpu_bo_unreserve(new_rbo);
|
||||
|
||||
work->base = base;
|
||||
|
||||
r = drm_crtc_vblank_get(crtc);
|
||||
if (r) {
|
||||
DRM_ERROR("failed to get vblank before flip\n");
|
||||
goto pflip_cleanup;
|
||||
}
|
||||
work->target_vblank = target - drm_crtc_vblank_count(crtc) +
|
||||
amdgpu_get_vblank_counter_kms(dev, work->crtc_id);
|
||||
|
||||
/* we borrow the event spin lock for protecting flip_wrok */
|
||||
spin_lock_irqsave(&crtc->dev->event_lock, flags);
|
||||
|
@ -250,7 +215,7 @@ int amdgpu_crtc_page_flip(struct drm_crtc *crtc,
|
|||
DRM_DEBUG_DRIVER("flip queue: crtc already busy\n");
|
||||
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
|
||||
r = -EBUSY;
|
||||
goto vblank_cleanup;
|
||||
goto pflip_cleanup;
|
||||
}
|
||||
|
||||
amdgpu_crtc->pflip_status = AMDGPU_FLIP_PENDING;
|
||||
|
@ -262,12 +227,9 @@ int amdgpu_crtc_page_flip(struct drm_crtc *crtc,
|
|||
/* update crtc fb */
|
||||
crtc->primary->fb = fb;
|
||||
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
|
||||
amdgpu_flip_work_func(&work->flip_work);
|
||||
amdgpu_flip_work_func(&work->flip_work.work);
|
||||
return 0;
|
||||
|
||||
vblank_cleanup:
|
||||
drm_crtc_vblank_put(crtc);
|
||||
|
||||
pflip_cleanup:
|
||||
if (unlikely(amdgpu_bo_reserve(new_rbo, false) != 0)) {
|
||||
DRM_ERROR("failed to reserve new rbo in error path\n");
|
||||
|
@ -335,7 +297,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static const char *encoder_names[38] = {
|
||||
static const char *encoder_names[41] = {
|
||||
"NONE",
|
||||
"INTERNAL_LVDS",
|
||||
"INTERNAL_TMDS1",
|
||||
|
@ -374,6 +336,9 @@ static const char *encoder_names[38] = {
|
|||
"TRAVIS",
|
||||
"INTERNAL_VCE",
|
||||
"INTERNAL_UNIPHY3",
|
||||
"HDMI_ANX9805",
|
||||
"INTERNAL_AMCLK",
|
||||
"VIRTUAL",
|
||||
};
|
||||
|
||||
static const char *hpd_names[6] = {
|
||||
|
|
|
@ -53,9 +53,11 @@
|
|||
* - 3.2.0 - GFX8: Uses EOP_TC_WB_ACTION_EN, so UMDs don't have to do the same
|
||||
* at the end of IBs.
|
||||
* - 3.3.0 - Add VM support for UVD on supported hardware.
|
||||
* - 3.4.0 - Add AMDGPU_INFO_NUM_EVICTIONS.
|
||||
* - 3.5.0 - Add support for new UVD_NO_OP register.
|
||||
*/
|
||||
#define KMS_DRIVER_MAJOR 3
|
||||
#define KMS_DRIVER_MINOR 3
|
||||
#define KMS_DRIVER_MINOR 5
|
||||
#define KMS_DRIVER_PATCHLEVEL 0
|
||||
|
||||
int amdgpu_vram_limit = 0;
|
||||
|
@ -84,11 +86,13 @@ int amdgpu_sched_jobs = 32;
|
|||
int amdgpu_sched_hw_submission = 2;
|
||||
int amdgpu_powerplay = -1;
|
||||
int amdgpu_powercontainment = 1;
|
||||
int amdgpu_sclk_deep_sleep_en = 1;
|
||||
unsigned amdgpu_pcie_gen_cap = 0;
|
||||
unsigned amdgpu_pcie_lane_cap = 0;
|
||||
unsigned amdgpu_cg_mask = 0xffffffff;
|
||||
unsigned amdgpu_pg_mask = 0xffffffff;
|
||||
char *amdgpu_disable_cu = NULL;
|
||||
char *amdgpu_virtual_display = NULL;
|
||||
|
||||
MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
|
||||
module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
|
||||
|
@ -170,6 +174,9 @@ MODULE_PARM_DESC(powercontainment, "Power Containment (1 = enable (default), 0 =
|
|||
module_param_named(powercontainment, amdgpu_powercontainment, int, 0444);
|
||||
#endif
|
||||
|
||||
MODULE_PARM_DESC(sclkdeepsleep, "SCLK Deep Sleep (1 = enable (default), 0 = disable)");
|
||||
module_param_named(sclkdeepsleep, amdgpu_sclk_deep_sleep_en, int, 0444);
|
||||
|
||||
MODULE_PARM_DESC(pcie_gen_cap, "PCIE Gen Caps (0: autodetect (default))");
|
||||
module_param_named(pcie_gen_cap, amdgpu_pcie_gen_cap, uint, 0444);
|
||||
|
||||
|
@ -185,6 +192,9 @@ module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444);
|
|||
MODULE_PARM_DESC(disable_cu, "Disable CUs (se.sh.cu,...)");
|
||||
module_param_named(disable_cu, amdgpu_disable_cu, charp, 0444);
|
||||
|
||||
MODULE_PARM_DESC(virtual_display, "Enable virtual display feature (the virtual_display will be set like xxxx:xx:xx.x;xxxx:xx:xx.x)");
|
||||
module_param_named(virtual_display, amdgpu_virtual_display, charp, 0444);
|
||||
|
||||
static const struct pci_device_id pciidlist[] = {
|
||||
#ifdef CONFIG_DRM_AMDGPU_CIK
|
||||
/* Kaveri */
|
||||
|
|
|
@ -31,14 +31,6 @@
|
|||
#define AMDGPU_GWS_SHIFT PAGE_SHIFT
|
||||
#define AMDGPU_OA_SHIFT PAGE_SHIFT
|
||||
|
||||
#define AMDGPU_PL_GDS TTM_PL_PRIV0
|
||||
#define AMDGPU_PL_GWS TTM_PL_PRIV1
|
||||
#define AMDGPU_PL_OA TTM_PL_PRIV2
|
||||
|
||||
#define AMDGPU_PL_FLAG_GDS TTM_PL_FLAG_PRIV0
|
||||
#define AMDGPU_PL_FLAG_GWS TTM_PL_FLAG_PRIV1
|
||||
#define AMDGPU_PL_FLAG_OA TTM_PL_FLAG_PRIV2
|
||||
|
||||
struct amdgpu_ring;
|
||||
struct amdgpu_bo;
|
||||
|
||||
|
|
|
@ -186,10 +186,8 @@ struct amdgpu_i2c_chan *amdgpu_i2c_create(struct drm_device *dev,
|
|||
"AMDGPU i2c hw bus %s", name);
|
||||
i2c->adapter.algo = &amdgpu_atombios_i2c_algo;
|
||||
ret = i2c_add_adapter(&i2c->adapter);
|
||||
if (ret) {
|
||||
DRM_ERROR("Failed to register hw i2c %s\n", name);
|
||||
if (ret)
|
||||
goto out_free;
|
||||
}
|
||||
} else {
|
||||
/* set the amdgpu bit adapter */
|
||||
snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
|
||||
|
|
|
@ -142,7 +142,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
|
|||
}
|
||||
|
||||
if (!ring->ready) {
|
||||
dev_err(adev->dev, "couldn't schedule ib\n");
|
||||
dev_err(adev->dev, "couldn't schedule ib on ring <%s>\n", ring->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,32 +40,15 @@ static int amdgpu_ih_ring_alloc(struct amdgpu_device *adev)
|
|||
|
||||
/* Allocate ring buffer */
|
||||
if (adev->irq.ih.ring_obj == NULL) {
|
||||
r = amdgpu_bo_create(adev, adev->irq.ih.ring_size,
|
||||
PAGE_SIZE, true,
|
||||
AMDGPU_GEM_DOMAIN_GTT, 0,
|
||||
NULL, NULL, &adev->irq.ih.ring_obj);
|
||||
r = amdgpu_bo_create_kernel(adev, adev->irq.ih.ring_size,
|
||||
PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
|
||||
&adev->irq.ih.ring_obj,
|
||||
&adev->irq.ih.gpu_addr,
|
||||
(void **)&adev->irq.ih.ring);
|
||||
if (r) {
|
||||
DRM_ERROR("amdgpu: failed to create ih ring buffer (%d).\n", r);
|
||||
return r;
|
||||
}
|
||||
r = amdgpu_bo_reserve(adev->irq.ih.ring_obj, false);
|
||||
if (unlikely(r != 0))
|
||||
return r;
|
||||
r = amdgpu_bo_pin(adev->irq.ih.ring_obj,
|
||||
AMDGPU_GEM_DOMAIN_GTT,
|
||||
&adev->irq.ih.gpu_addr);
|
||||
if (r) {
|
||||
amdgpu_bo_unreserve(adev->irq.ih.ring_obj);
|
||||
DRM_ERROR("amdgpu: failed to pin ih ring buffer (%d).\n", r);
|
||||
return r;
|
||||
}
|
||||
r = amdgpu_bo_kmap(adev->irq.ih.ring_obj,
|
||||
(void **)&adev->irq.ih.ring);
|
||||
amdgpu_bo_unreserve(adev->irq.ih.ring_obj);
|
||||
if (r) {
|
||||
DRM_ERROR("amdgpu: failed to map ih ring buffer (%d).\n", r);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ struct amdgpu_irq {
|
|||
/* gen irq stuff */
|
||||
struct irq_domain *domain; /* GPU irq controller domain */
|
||||
unsigned virq[AMDGPU_MAX_IRQ_SRC_ID];
|
||||
uint32_t srbm_soft_reset;
|
||||
};
|
||||
|
||||
void amdgpu_irq_preinstall(struct drm_device *dev);
|
||||
|
|
|
@ -292,14 +292,14 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
|
|||
type = AMD_IP_BLOCK_TYPE_UVD;
|
||||
ring_mask = adev->uvd.ring.ready ? 1 : 0;
|
||||
ib_start_alignment = AMDGPU_GPU_PAGE_SIZE;
|
||||
ib_size_alignment = 8;
|
||||
ib_size_alignment = 16;
|
||||
break;
|
||||
case AMDGPU_HW_IP_VCE:
|
||||
type = AMD_IP_BLOCK_TYPE_VCE;
|
||||
for (i = 0; i < AMDGPU_MAX_VCE_RINGS; i++)
|
||||
ring_mask |= ((adev->vce.ring[i].ready ? 1 : 0) << i);
|
||||
ib_start_alignment = AMDGPU_GPU_PAGE_SIZE;
|
||||
ib_size_alignment = 8;
|
||||
ib_size_alignment = 1;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
@ -373,6 +373,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
|
|||
case AMDGPU_INFO_NUM_BYTES_MOVED:
|
||||
ui64 = atomic64_read(&adev->num_bytes_moved);
|
||||
return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
|
||||
case AMDGPU_INFO_NUM_EVICTIONS:
|
||||
ui64 = atomic64_read(&adev->num_evictions);
|
||||
return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
|
||||
case AMDGPU_INFO_VRAM_USAGE:
|
||||
ui64 = atomic64_read(&adev->vram_usage);
|
||||
return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include <drm/drm_plane_helper.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-algo-bit.h>
|
||||
#include <linux/hrtimer.h>
|
||||
#include "amdgpu_irq.h"
|
||||
|
||||
struct amdgpu_bo;
|
||||
struct amdgpu_device;
|
||||
|
@ -339,6 +341,8 @@ struct amdgpu_mode_info {
|
|||
int num_dig; /* number of dig blocks */
|
||||
int disp_priority;
|
||||
const struct amdgpu_display_funcs *funcs;
|
||||
struct hrtimer vblank_timer;
|
||||
enum amdgpu_interrupt_state vsync_timer_enabled;
|
||||
};
|
||||
|
||||
#define AMDGPU_MAX_BL_LEVEL 0xFF
|
||||
|
@ -587,10 +591,10 @@ int amdgpu_align_pitch(struct amdgpu_device *adev, int width, int bpp, bool tile
|
|||
void amdgpu_print_display_setup(struct drm_device *dev);
|
||||
int amdgpu_modeset_create_props(struct amdgpu_device *adev);
|
||||
int amdgpu_crtc_set_config(struct drm_mode_set *set);
|
||||
int amdgpu_crtc_page_flip(struct drm_crtc *crtc,
|
||||
struct drm_framebuffer *fb,
|
||||
struct drm_pending_vblank_event *event,
|
||||
uint32_t page_flip_flags);
|
||||
int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
|
||||
struct drm_framebuffer *fb,
|
||||
struct drm_pending_vblank_event *event,
|
||||
uint32_t page_flip_flags, uint32_t target);
|
||||
extern const struct drm_mode_config_funcs amdgpu_mode_funcs;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,14 +44,13 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev);
|
|||
static u64 amdgpu_get_vis_part_size(struct amdgpu_device *adev,
|
||||
struct ttm_mem_reg *mem)
|
||||
{
|
||||
u64 ret = 0;
|
||||
if (mem->start << PAGE_SHIFT < adev->mc.visible_vram_size) {
|
||||
ret = (u64)((mem->start << PAGE_SHIFT) + mem->size) >
|
||||
adev->mc.visible_vram_size ?
|
||||
adev->mc.visible_vram_size - (mem->start << PAGE_SHIFT) :
|
||||
mem->size;
|
||||
}
|
||||
return ret;
|
||||
if (mem->start << PAGE_SHIFT >= adev->mc.visible_vram_size)
|
||||
return 0;
|
||||
|
||||
return ((mem->start << PAGE_SHIFT) + mem->size) >
|
||||
adev->mc.visible_vram_size ?
|
||||
adev->mc.visible_vram_size - (mem->start << PAGE_SHIFT) :
|
||||
mem->size;
|
||||
}
|
||||
|
||||
static void amdgpu_update_memory_usage(struct amdgpu_device *adev,
|
||||
|
@ -99,6 +98,11 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
|
|||
|
||||
drm_gem_object_release(&bo->gem_base);
|
||||
amdgpu_bo_unref(&bo->parent);
|
||||
if (!list_empty(&bo->shadow_list)) {
|
||||
mutex_lock(&bo->adev->shadow_list_lock);
|
||||
list_del_init(&bo->shadow_list);
|
||||
mutex_unlock(&bo->adev->shadow_list_lock);
|
||||
}
|
||||
kfree(bo->metadata);
|
||||
kfree(bo);
|
||||
}
|
||||
|
@ -112,84 +116,93 @@ bool amdgpu_ttm_bo_is_amdgpu_bo(struct ttm_buffer_object *bo)
|
|||
|
||||
static void amdgpu_ttm_placement_init(struct amdgpu_device *adev,
|
||||
struct ttm_placement *placement,
|
||||
struct ttm_place *placements,
|
||||
struct ttm_place *places,
|
||||
u32 domain, u64 flags)
|
||||
{
|
||||
u32 c = 0, i;
|
||||
|
||||
placement->placement = placements;
|
||||
placement->busy_placement = placements;
|
||||
u32 c = 0;
|
||||
|
||||
if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
|
||||
unsigned visible_pfn = adev->mc.visible_vram_size >> PAGE_SHIFT;
|
||||
|
||||
if (flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS &&
|
||||
adev->mc.visible_vram_size < adev->mc.real_vram_size) {
|
||||
placements[c].fpfn =
|
||||
adev->mc.visible_vram_size >> PAGE_SHIFT;
|
||||
placements[c++].flags = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
|
||||
TTM_PL_FLAG_VRAM | TTM_PL_FLAG_TOPDOWN;
|
||||
!(flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) &&
|
||||
adev->mc.visible_vram_size < adev->mc.real_vram_size) {
|
||||
places[c].fpfn = visible_pfn;
|
||||
places[c].lpfn = 0;
|
||||
places[c].flags = TTM_PL_FLAG_WC |
|
||||
TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_VRAM |
|
||||
TTM_PL_FLAG_TOPDOWN;
|
||||
c++;
|
||||
}
|
||||
placements[c].fpfn = 0;
|
||||
placements[c++].flags = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
|
||||
|
||||
places[c].fpfn = 0;
|
||||
places[c].lpfn = 0;
|
||||
places[c].flags = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED |
|
||||
TTM_PL_FLAG_VRAM;
|
||||
if (!(flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED))
|
||||
placements[c - 1].flags |= TTM_PL_FLAG_TOPDOWN;
|
||||
if (flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED)
|
||||
places[c].lpfn = visible_pfn;
|
||||
else
|
||||
places[c].flags |= TTM_PL_FLAG_TOPDOWN;
|
||||
c++;
|
||||
}
|
||||
|
||||
if (domain & AMDGPU_GEM_DOMAIN_GTT) {
|
||||
if (flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) {
|
||||
placements[c].fpfn = 0;
|
||||
placements[c++].flags = TTM_PL_FLAG_WC | TTM_PL_FLAG_TT |
|
||||
places[c].fpfn = 0;
|
||||
places[c].lpfn = 0;
|
||||
places[c].flags = TTM_PL_FLAG_TT;
|
||||
if (flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC)
|
||||
places[c].flags |= TTM_PL_FLAG_WC |
|
||||
TTM_PL_FLAG_UNCACHED;
|
||||
} else {
|
||||
placements[c].fpfn = 0;
|
||||
placements[c++].flags = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_TT;
|
||||
}
|
||||
else
|
||||
places[c].flags |= TTM_PL_FLAG_CACHED;
|
||||
c++;
|
||||
}
|
||||
|
||||
if (domain & AMDGPU_GEM_DOMAIN_CPU) {
|
||||
if (flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) {
|
||||
placements[c].fpfn = 0;
|
||||
placements[c++].flags = TTM_PL_FLAG_WC | TTM_PL_FLAG_SYSTEM |
|
||||
places[c].fpfn = 0;
|
||||
places[c].lpfn = 0;
|
||||
places[c].flags = TTM_PL_FLAG_SYSTEM;
|
||||
if (flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC)
|
||||
places[c].flags |= TTM_PL_FLAG_WC |
|
||||
TTM_PL_FLAG_UNCACHED;
|
||||
} else {
|
||||
placements[c].fpfn = 0;
|
||||
placements[c++].flags = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_SYSTEM;
|
||||
}
|
||||
else
|
||||
places[c].flags |= TTM_PL_FLAG_CACHED;
|
||||
c++;
|
||||
}
|
||||
|
||||
if (domain & AMDGPU_GEM_DOMAIN_GDS) {
|
||||
placements[c].fpfn = 0;
|
||||
placements[c++].flags = TTM_PL_FLAG_UNCACHED |
|
||||
AMDGPU_PL_FLAG_GDS;
|
||||
places[c].fpfn = 0;
|
||||
places[c].lpfn = 0;
|
||||
places[c].flags = TTM_PL_FLAG_UNCACHED | AMDGPU_PL_FLAG_GDS;
|
||||
c++;
|
||||
}
|
||||
|
||||
if (domain & AMDGPU_GEM_DOMAIN_GWS) {
|
||||
placements[c].fpfn = 0;
|
||||
placements[c++].flags = TTM_PL_FLAG_UNCACHED |
|
||||
AMDGPU_PL_FLAG_GWS;
|
||||
places[c].fpfn = 0;
|
||||
places[c].lpfn = 0;
|
||||
places[c].flags = TTM_PL_FLAG_UNCACHED | AMDGPU_PL_FLAG_GWS;
|
||||
c++;
|
||||
}
|
||||
|
||||
if (domain & AMDGPU_GEM_DOMAIN_OA) {
|
||||
placements[c].fpfn = 0;
|
||||
placements[c++].flags = TTM_PL_FLAG_UNCACHED |
|
||||
AMDGPU_PL_FLAG_OA;
|
||||
places[c].fpfn = 0;
|
||||
places[c].lpfn = 0;
|
||||
places[c].flags = TTM_PL_FLAG_UNCACHED | AMDGPU_PL_FLAG_OA;
|
||||
c++;
|
||||
}
|
||||
|
||||
if (!c) {
|
||||
placements[c].fpfn = 0;
|
||||
placements[c++].flags = TTM_PL_MASK_CACHING |
|
||||
TTM_PL_FLAG_SYSTEM;
|
||||
places[c].fpfn = 0;
|
||||
places[c].lpfn = 0;
|
||||
places[c].flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
|
||||
c++;
|
||||
}
|
||||
placement->num_placement = c;
|
||||
placement->num_busy_placement = c;
|
||||
|
||||
for (i = 0; i < c; i++) {
|
||||
if ((flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) &&
|
||||
(placements[i].flags & TTM_PL_FLAG_VRAM) &&
|
||||
!placements[i].fpfn)
|
||||
placements[i].lpfn =
|
||||
adev->mc.visible_vram_size >> PAGE_SHIFT;
|
||||
else
|
||||
placements[i].lpfn = 0;
|
||||
}
|
||||
placement->num_placement = c;
|
||||
placement->placement = places;
|
||||
|
||||
placement->num_busy_placement = c;
|
||||
placement->busy_placement = places;
|
||||
}
|
||||
|
||||
void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *rbo, u32 domain)
|
||||
|
@ -211,6 +224,69 @@ static void amdgpu_fill_placement_to_bo(struct amdgpu_bo *bo,
|
|||
bo->placement.busy_placement = bo->placements;
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_bo_create_kernel - create BO for kernel use
|
||||
*
|
||||
* @adev: amdgpu device object
|
||||
* @size: size for the new BO
|
||||
* @align: alignment for the new BO
|
||||
* @domain: where to place it
|
||||
* @bo_ptr: resulting BO
|
||||
* @gpu_addr: GPU addr of the pinned BO
|
||||
* @cpu_addr: optional CPU address mapping
|
||||
*
|
||||
* Allocates and pins a BO for kernel internal use.
|
||||
*
|
||||
* Returns 0 on success, negative error code otherwise.
|
||||
*/
|
||||
int amdgpu_bo_create_kernel(struct amdgpu_device *adev,
|
||||
unsigned long size, int align,
|
||||
u32 domain, struct amdgpu_bo **bo_ptr,
|
||||
u64 *gpu_addr, void **cpu_addr)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = amdgpu_bo_create(adev, size, align, true, domain,
|
||||
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
|
||||
NULL, NULL, bo_ptr);
|
||||
if (r) {
|
||||
dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
r = amdgpu_bo_reserve(*bo_ptr, false);
|
||||
if (r) {
|
||||
dev_err(adev->dev, "(%d) failed to reserve kernel bo\n", r);
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
r = amdgpu_bo_pin(*bo_ptr, domain, gpu_addr);
|
||||
if (r) {
|
||||
dev_err(adev->dev, "(%d) kernel bo pin failed\n", r);
|
||||
goto error_unreserve;
|
||||
}
|
||||
|
||||
if (cpu_addr) {
|
||||
r = amdgpu_bo_kmap(*bo_ptr, cpu_addr);
|
||||
if (r) {
|
||||
dev_err(adev->dev, "(%d) kernel bo map failed\n", r);
|
||||
goto error_unreserve;
|
||||
}
|
||||
}
|
||||
|
||||
amdgpu_bo_unreserve(*bo_ptr);
|
||||
|
||||
return 0;
|
||||
|
||||
error_unreserve:
|
||||
amdgpu_bo_unreserve(*bo_ptr);
|
||||
|
||||
error_free:
|
||||
amdgpu_bo_unref(bo_ptr);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
|
||||
unsigned long size, int byte_align,
|
||||
bool kernel, u32 domain, u64 flags,
|
||||
|
@ -250,6 +326,7 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
|
|||
}
|
||||
bo->adev = adev;
|
||||
INIT_LIST_HEAD(&bo->list);
|
||||
INIT_LIST_HEAD(&bo->shadow_list);
|
||||
INIT_LIST_HEAD(&bo->va);
|
||||
bo->prefered_domains = domain & (AMDGPU_GEM_DOMAIN_VRAM |
|
||||
AMDGPU_GEM_DOMAIN_GTT |
|
||||
|
@ -277,11 +354,79 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
|
|||
if (unlikely(r != 0)) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
|
||||
bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) {
|
||||
struct fence *fence;
|
||||
|
||||
if (adev->mman.buffer_funcs_ring == NULL ||
|
||||
!adev->mman.buffer_funcs_ring->ready) {
|
||||
r = -EBUSY;
|
||||
goto fail_free;
|
||||
}
|
||||
|
||||
r = amdgpu_bo_reserve(bo, false);
|
||||
if (unlikely(r != 0))
|
||||
goto fail_free;
|
||||
|
||||
amdgpu_ttm_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_VRAM);
|
||||
r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
|
||||
if (unlikely(r != 0))
|
||||
goto fail_unreserve;
|
||||
|
||||
amdgpu_fill_buffer(bo, 0, bo->tbo.resv, &fence);
|
||||
amdgpu_bo_fence(bo, fence, false);
|
||||
amdgpu_bo_unreserve(bo);
|
||||
fence_put(bo->tbo.moving);
|
||||
bo->tbo.moving = fence_get(fence);
|
||||
fence_put(fence);
|
||||
}
|
||||
*bo_ptr = bo;
|
||||
|
||||
trace_amdgpu_bo_create(bo);
|
||||
|
||||
return 0;
|
||||
|
||||
fail_unreserve:
|
||||
amdgpu_bo_unreserve(bo);
|
||||
fail_free:
|
||||
amdgpu_bo_unref(&bo);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
|
||||
unsigned long size, int byte_align,
|
||||
struct amdgpu_bo *bo)
|
||||
{
|
||||
struct ttm_placement placement = {0};
|
||||
struct ttm_place placements[AMDGPU_GEM_DOMAIN_MAX + 1];
|
||||
int r;
|
||||
|
||||
if (bo->shadow)
|
||||
return 0;
|
||||
|
||||
bo->flags |= AMDGPU_GEM_CREATE_SHADOW;
|
||||
memset(&placements, 0,
|
||||
(AMDGPU_GEM_DOMAIN_MAX + 1) * sizeof(struct ttm_place));
|
||||
|
||||
amdgpu_ttm_placement_init(adev, &placement,
|
||||
placements, AMDGPU_GEM_DOMAIN_GTT,
|
||||
AMDGPU_GEM_CREATE_CPU_GTT_USWC);
|
||||
|
||||
r = amdgpu_bo_create_restricted(adev, size, byte_align, true,
|
||||
AMDGPU_GEM_DOMAIN_GTT,
|
||||
AMDGPU_GEM_CREATE_CPU_GTT_USWC,
|
||||
NULL, &placement,
|
||||
bo->tbo.resv,
|
||||
&bo->shadow);
|
||||
if (!r) {
|
||||
bo->shadow->parent = amdgpu_bo_ref(bo);
|
||||
mutex_lock(&adev->shadow_list_lock);
|
||||
list_add_tail(&bo->shadow_list, &adev->shadow_list);
|
||||
mutex_unlock(&adev->shadow_list_lock);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int amdgpu_bo_create(struct amdgpu_device *adev,
|
||||
|
@ -293,6 +438,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
|
|||
{
|
||||
struct ttm_placement placement = {0};
|
||||
struct ttm_place placements[AMDGPU_GEM_DOMAIN_MAX + 1];
|
||||
int r;
|
||||
|
||||
memset(&placements, 0,
|
||||
(AMDGPU_GEM_DOMAIN_MAX + 1) * sizeof(struct ttm_place));
|
||||
|
@ -300,9 +446,83 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
|
|||
amdgpu_ttm_placement_init(adev, &placement,
|
||||
placements, domain, flags);
|
||||
|
||||
return amdgpu_bo_create_restricted(adev, size, byte_align, kernel,
|
||||
domain, flags, sg, &placement,
|
||||
resv, bo_ptr);
|
||||
r = amdgpu_bo_create_restricted(adev, size, byte_align, kernel,
|
||||
domain, flags, sg, &placement,
|
||||
resv, bo_ptr);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (amdgpu_need_backup(adev) && (flags & AMDGPU_GEM_CREATE_SHADOW)) {
|
||||
r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr));
|
||||
if (r)
|
||||
amdgpu_bo_unref(bo_ptr);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int amdgpu_bo_backup_to_shadow(struct amdgpu_device *adev,
|
||||
struct amdgpu_ring *ring,
|
||||
struct amdgpu_bo *bo,
|
||||
struct reservation_object *resv,
|
||||
struct fence **fence,
|
||||
bool direct)
|
||||
|
||||
{
|
||||
struct amdgpu_bo *shadow = bo->shadow;
|
||||
uint64_t bo_addr, shadow_addr;
|
||||
int r;
|
||||
|
||||
if (!shadow)
|
||||
return -EINVAL;
|
||||
|
||||
bo_addr = amdgpu_bo_gpu_offset(bo);
|
||||
shadow_addr = amdgpu_bo_gpu_offset(bo->shadow);
|
||||
|
||||
r = reservation_object_reserve_shared(bo->tbo.resv);
|
||||
if (r)
|
||||
goto err;
|
||||
|
||||
r = amdgpu_copy_buffer(ring, bo_addr, shadow_addr,
|
||||
amdgpu_bo_size(bo), resv, fence,
|
||||
direct);
|
||||
if (!r)
|
||||
amdgpu_bo_fence(bo, *fence, true);
|
||||
|
||||
err:
|
||||
return r;
|
||||
}
|
||||
|
||||
int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev,
|
||||
struct amdgpu_ring *ring,
|
||||
struct amdgpu_bo *bo,
|
||||
struct reservation_object *resv,
|
||||
struct fence **fence,
|
||||
bool direct)
|
||||
|
||||
{
|
||||
struct amdgpu_bo *shadow = bo->shadow;
|
||||
uint64_t bo_addr, shadow_addr;
|
||||
int r;
|
||||
|
||||
if (!shadow)
|
||||
return -EINVAL;
|
||||
|
||||
bo_addr = amdgpu_bo_gpu_offset(bo);
|
||||
shadow_addr = amdgpu_bo_gpu_offset(bo->shadow);
|
||||
|
||||
r = reservation_object_reserve_shared(bo->tbo.resv);
|
||||
if (r)
|
||||
goto err;
|
||||
|
||||
r = amdgpu_copy_buffer(ring, shadow_addr, bo_addr,
|
||||
amdgpu_bo_size(bo), resv, fence,
|
||||
direct);
|
||||
if (!r)
|
||||
amdgpu_bo_fence(bo, *fence, true);
|
||||
|
||||
err:
|
||||
return r;
|
||||
}
|
||||
|
||||
int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr)
|
||||
|
@ -380,16 +600,17 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
|
|||
return -EINVAL;
|
||||
|
||||
if (bo->pin_count) {
|
||||
uint32_t mem_type = bo->tbo.mem.mem_type;
|
||||
|
||||
if (domain != amdgpu_mem_type_to_domain(mem_type))
|
||||
return -EINVAL;
|
||||
|
||||
bo->pin_count++;
|
||||
if (gpu_addr)
|
||||
*gpu_addr = amdgpu_bo_gpu_offset(bo);
|
||||
|
||||
if (max_offset != 0) {
|
||||
u64 domain_start;
|
||||
if (domain == AMDGPU_GEM_DOMAIN_VRAM)
|
||||
domain_start = bo->adev->mc.vram_start;
|
||||
else
|
||||
domain_start = bo->adev->mc.gtt_start;
|
||||
u64 domain_start = bo->tbo.bdev->man[mem_type].gpu_offset;
|
||||
WARN_ON_ONCE(max_offset <
|
||||
(amdgpu_bo_gpu_offset(bo) - domain_start));
|
||||
}
|
||||
|
@ -401,7 +622,8 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
|
|||
/* force to pin into visible video ram */
|
||||
if ((bo->placements[i].flags & TTM_PL_FLAG_VRAM) &&
|
||||
!(bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) &&
|
||||
(!max_offset || max_offset > bo->adev->mc.visible_vram_size)) {
|
||||
(!max_offset || max_offset >
|
||||
bo->adev->mc.visible_vram_size)) {
|
||||
if (WARN_ON_ONCE(min_offset >
|
||||
bo->adev->mc.visible_vram_size))
|
||||
return -EINVAL;
|
||||
|
@ -420,19 +642,23 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
|
|||
}
|
||||
|
||||
r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
|
||||
if (likely(r == 0)) {
|
||||
bo->pin_count = 1;
|
||||
if (gpu_addr != NULL)
|
||||
*gpu_addr = amdgpu_bo_gpu_offset(bo);
|
||||
if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
|
||||
bo->adev->vram_pin_size += amdgpu_bo_size(bo);
|
||||
if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
|
||||
bo->adev->invisible_pin_size += amdgpu_bo_size(bo);
|
||||
} else
|
||||
bo->adev->gart_pin_size += amdgpu_bo_size(bo);
|
||||
} else {
|
||||
if (unlikely(r)) {
|
||||
dev_err(bo->adev->dev, "%p pin failed\n", bo);
|
||||
goto error;
|
||||
}
|
||||
|
||||
bo->pin_count = 1;
|
||||
if (gpu_addr != NULL)
|
||||
*gpu_addr = amdgpu_bo_gpu_offset(bo);
|
||||
if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
|
||||
bo->adev->vram_pin_size += amdgpu_bo_size(bo);
|
||||
if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
|
||||
bo->adev->invisible_pin_size += amdgpu_bo_size(bo);
|
||||
} else if (domain == AMDGPU_GEM_DOMAIN_GTT) {
|
||||
bo->adev->gart_pin_size += amdgpu_bo_size(bo);
|
||||
}
|
||||
|
||||
error:
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -457,16 +683,20 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo)
|
|||
bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
|
||||
}
|
||||
r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
|
||||
if (likely(r == 0)) {
|
||||
if (bo->tbo.mem.mem_type == TTM_PL_VRAM) {
|
||||
bo->adev->vram_pin_size -= amdgpu_bo_size(bo);
|
||||
if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
|
||||
bo->adev->invisible_pin_size -= amdgpu_bo_size(bo);
|
||||
} else
|
||||
bo->adev->gart_pin_size -= amdgpu_bo_size(bo);
|
||||
} else {
|
||||
if (unlikely(r)) {
|
||||
dev_err(bo->adev->dev, "%p validate failed for unpin\n", bo);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (bo->tbo.mem.mem_type == TTM_PL_VRAM) {
|
||||
bo->adev->vram_pin_size -= amdgpu_bo_size(bo);
|
||||
if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
|
||||
bo->adev->invisible_pin_size -= amdgpu_bo_size(bo);
|
||||
} else {
|
||||
bo->adev->gart_pin_size -= amdgpu_bo_size(bo);
|
||||
}
|
||||
|
||||
error:
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -637,7 +867,8 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
|
|||
for (i = 0; i < abo->placement.num_placement; i++) {
|
||||
/* Force into visible VRAM */
|
||||
if ((abo->placements[i].flags & TTM_PL_FLAG_VRAM) &&
|
||||
(!abo->placements[i].lpfn || abo->placements[i].lpfn > lpfn))
|
||||
(!abo->placements[i].lpfn ||
|
||||
abo->placements[i].lpfn > lpfn))
|
||||
abo->placements[i].lpfn = lpfn;
|
||||
}
|
||||
r = ttm_bo_validate(bo, &abo->placement, false, false);
|
||||
|
@ -674,3 +905,21 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct fence *fence,
|
|||
else
|
||||
reservation_object_add_excl_fence(resv, fence);
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_bo_gpu_offset - return GPU offset of bo
|
||||
* @bo: amdgpu object for which we query the offset
|
||||
*
|
||||
* Returns current GPU offset of the object.
|
||||
*
|
||||
* Note: object should either be pinned or reserved when calling this
|
||||
* function, it might be useful to add check for this for debugging.
|
||||
*/
|
||||
u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)
|
||||
{
|
||||
WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM);
|
||||
WARN_ON_ONCE(!ww_mutex_is_locked(&bo->tbo.resv->lock) &&
|
||||
!bo->pin_count);
|
||||
|
||||
return bo->tbo.offset;
|
||||
}
|
||||
|
|
|
@ -85,21 +85,6 @@ static inline void amdgpu_bo_unreserve(struct amdgpu_bo *bo)
|
|||
ttm_bo_unreserve(&bo->tbo);
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_bo_gpu_offset - return GPU offset of bo
|
||||
* @bo: amdgpu object for which we query the offset
|
||||
*
|
||||
* Returns current GPU offset of the object.
|
||||
*
|
||||
* Note: object should either be pinned or reserved when calling this
|
||||
* function, it might be useful to add check for this for debugging.
|
||||
*/
|
||||
static inline u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)
|
||||
{
|
||||
WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM);
|
||||
return bo->tbo.offset;
|
||||
}
|
||||
|
||||
static inline unsigned long amdgpu_bo_size(struct amdgpu_bo *bo)
|
||||
{
|
||||
return bo->tbo.num_pages << PAGE_SHIFT;
|
||||
|
@ -139,6 +124,10 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
|
|||
struct ttm_placement *placement,
|
||||
struct reservation_object *resv,
|
||||
struct amdgpu_bo **bo_ptr);
|
||||
int amdgpu_bo_create_kernel(struct amdgpu_device *adev,
|
||||
unsigned long size, int align,
|
||||
u32 domain, struct amdgpu_bo **bo_ptr,
|
||||
u64 *gpu_addr, void **cpu_addr);
|
||||
int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr);
|
||||
void amdgpu_bo_kunmap(struct amdgpu_bo *bo);
|
||||
struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo);
|
||||
|
@ -165,6 +154,19 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
|
|||
int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
|
||||
void amdgpu_bo_fence(struct amdgpu_bo *bo, struct fence *fence,
|
||||
bool shared);
|
||||
u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
|
||||
int amdgpu_bo_backup_to_shadow(struct amdgpu_device *adev,
|
||||
struct amdgpu_ring *ring,
|
||||
struct amdgpu_bo *bo,
|
||||
struct reservation_object *resv,
|
||||
struct fence **fence, bool direct);
|
||||
int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev,
|
||||
struct amdgpu_ring *ring,
|
||||
struct amdgpu_bo *bo,
|
||||
struct reservation_object *resv,
|
||||
struct fence **fence,
|
||||
bool direct);
|
||||
|
||||
|
||||
/*
|
||||
* sub allocation
|
||||
|
|
|
@ -1103,54 +1103,46 @@ force:
|
|||
|
||||
void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable)
|
||||
{
|
||||
if (adev->pp_enabled)
|
||||
if (adev->pp_enabled || adev->pm.funcs->powergate_uvd) {
|
||||
/* enable/disable UVD */
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
amdgpu_dpm_powergate_uvd(adev, !enable);
|
||||
else {
|
||||
if (adev->pm.funcs->powergate_uvd) {
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
} else {
|
||||
if (enable) {
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
/* enable/disable UVD */
|
||||
amdgpu_dpm_powergate_uvd(adev, !enable);
|
||||
adev->pm.dpm.uvd_active = true;
|
||||
adev->pm.dpm.state = POWER_STATE_TYPE_INTERNAL_UVD;
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
} else {
|
||||
if (enable) {
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
adev->pm.dpm.uvd_active = true;
|
||||
adev->pm.dpm.state = POWER_STATE_TYPE_INTERNAL_UVD;
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
} else {
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
adev->pm.dpm.uvd_active = false;
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
}
|
||||
amdgpu_pm_compute_clocks(adev);
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
adev->pm.dpm.uvd_active = false;
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
}
|
||||
|
||||
amdgpu_pm_compute_clocks(adev);
|
||||
}
|
||||
}
|
||||
|
||||
void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable)
|
||||
{
|
||||
if (adev->pp_enabled)
|
||||
if (adev->pp_enabled || adev->pm.funcs->powergate_vce) {
|
||||
/* enable/disable VCE */
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
amdgpu_dpm_powergate_vce(adev, !enable);
|
||||
else {
|
||||
if (adev->pm.funcs->powergate_vce) {
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
} else {
|
||||
if (enable) {
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
amdgpu_dpm_powergate_vce(adev, !enable);
|
||||
adev->pm.dpm.vce_active = true;
|
||||
/* XXX select vce level based on ring/task */
|
||||
adev->pm.dpm.vce_level = AMDGPU_VCE_LEVEL_AC_ALL;
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
} else {
|
||||
if (enable) {
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
adev->pm.dpm.vce_active = true;
|
||||
/* XXX select vce level based on ring/task */
|
||||
adev->pm.dpm.vce_level = AMDGPU_VCE_LEVEL_AC_ALL;
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
} else {
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
adev->pm.dpm.vce_active = false;
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
}
|
||||
amdgpu_pm_compute_clocks(adev);
|
||||
mutex_lock(&adev->pm.mutex);
|
||||
adev->pm.dpm.vce_active = false;
|
||||
mutex_unlock(&adev->pm.mutex);
|
||||
}
|
||||
amdgpu_pm_compute_clocks(adev);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,9 @@ static int amdgpu_powerplay_init(struct amdgpu_device *adev)
|
|||
pp_init->chip_family = adev->family;
|
||||
pp_init->chip_id = adev->asic_type;
|
||||
pp_init->device = amdgpu_cgs_create_device(adev);
|
||||
pp_init->powercontainment_enabled = amdgpu_powercontainment;
|
||||
pp_init->rev_id = adev->pdev->revision;
|
||||
pp_init->sub_sys_id = adev->pdev->subsystem_device;
|
||||
pp_init->sub_vendor_id = adev->pdev->subsystem_vendor;
|
||||
|
||||
ret = amd_powerplay_init(pp_init, amd_pp);
|
||||
kfree(pp_init);
|
||||
|
@ -106,11 +108,10 @@ static int amdgpu_pp_early_init(void *handle)
|
|||
break;
|
||||
case CHIP_TONGA:
|
||||
case CHIP_FIJI:
|
||||
adev->pp_enabled = (amdgpu_powerplay == 0) ? false : true;
|
||||
break;
|
||||
case CHIP_TOPAZ:
|
||||
case CHIP_CARRIZO:
|
||||
case CHIP_STONEY:
|
||||
adev->pp_enabled = (amdgpu_powerplay > 0) ? true : false;
|
||||
adev->pp_enabled = (amdgpu_powerplay == 0) ? false : true;
|
||||
break;
|
||||
/* These chips don't have powerplay implemenations */
|
||||
case CHIP_BONAIRE:
|
||||
|
@ -118,7 +119,6 @@ static int amdgpu_pp_early_init(void *handle)
|
|||
case CHIP_KABINI:
|
||||
case CHIP_MULLINS:
|
||||
case CHIP_KAVERI:
|
||||
case CHIP_TOPAZ:
|
||||
default:
|
||||
adev->pp_enabled = false;
|
||||
break;
|
||||
|
|
|
@ -222,33 +222,16 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
|
|||
|
||||
/* Allocate ring buffer */
|
||||
if (ring->ring_obj == NULL) {
|
||||
r = amdgpu_bo_create(adev, ring->ring_size, PAGE_SIZE, true,
|
||||
AMDGPU_GEM_DOMAIN_GTT, 0,
|
||||
NULL, NULL, &ring->ring_obj);
|
||||
r = amdgpu_bo_create_kernel(adev, ring->ring_size, PAGE_SIZE,
|
||||
AMDGPU_GEM_DOMAIN_GTT,
|
||||
&ring->ring_obj,
|
||||
&ring->gpu_addr,
|
||||
(void **)&ring->ring);
|
||||
if (r) {
|
||||
dev_err(adev->dev, "(%d) ring create failed\n", r);
|
||||
return r;
|
||||
}
|
||||
r = amdgpu_bo_reserve(ring->ring_obj, false);
|
||||
if (unlikely(r != 0))
|
||||
return r;
|
||||
r = amdgpu_bo_pin(ring->ring_obj, AMDGPU_GEM_DOMAIN_GTT,
|
||||
&ring->gpu_addr);
|
||||
if (r) {
|
||||
amdgpu_bo_unreserve(ring->ring_obj);
|
||||
dev_err(adev->dev, "(%d) ring pin failed\n", r);
|
||||
return r;
|
||||
}
|
||||
r = amdgpu_bo_kmap(ring->ring_obj,
|
||||
(void **)&ring->ring);
|
||||
|
||||
memset((void *)ring->ring, 0, ring->ring_size);
|
||||
|
||||
amdgpu_bo_unreserve(ring->ring_obj);
|
||||
if (r) {
|
||||
dev_err(adev->dev, "(%d) ring map failed\n", r);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
ring->ptr_mask = (ring->ring_size / 4) - 1;
|
||||
ring->max_dw = max_dw;
|
||||
|
|
|
@ -111,7 +111,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
|
|||
amdgpu_bo_kunmap(gtt_obj[i]);
|
||||
|
||||
r = amdgpu_copy_buffer(ring, gtt_addr, vram_addr,
|
||||
size, NULL, &fence);
|
||||
size, NULL, &fence, false);
|
||||
|
||||
if (r) {
|
||||
DRM_ERROR("Failed GTT->VRAM copy %d\n", i);
|
||||
|
@ -156,7 +156,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
|
|||
amdgpu_bo_kunmap(vram_obj);
|
||||
|
||||
r = amdgpu_copy_buffer(ring, vram_addr, gtt_addr,
|
||||
size, NULL, &fence);
|
||||
size, NULL, &fence, false);
|
||||
|
||||
if (r) {
|
||||
DRM_ERROR("Failed VRAM->GTT copy %d\n", i);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <ttm/ttm_placement.h>
|
||||
#include <ttm/ttm_module.h>
|
||||
#include <ttm/ttm_page_alloc.h>
|
||||
#include <ttm/ttm_memory.h>
|
||||
#include <drm/drmP.h>
|
||||
#include <drm/amdgpu_drm.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
@ -74,7 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref)
|
|||
ttm_mem_global_release(ref->object);
|
||||
}
|
||||
|
||||
static int amdgpu_ttm_global_init(struct amdgpu_device *adev)
|
||||
int amdgpu_ttm_global_init(struct amdgpu_device *adev)
|
||||
{
|
||||
struct drm_global_reference *global_ref;
|
||||
struct amdgpu_ring *ring;
|
||||
|
@ -256,10 +257,8 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
|
|||
|
||||
switch (old_mem->mem_type) {
|
||||
case TTM_PL_VRAM:
|
||||
old_start += adev->mc.vram_start;
|
||||
break;
|
||||
case TTM_PL_TT:
|
||||
old_start += adev->mc.gtt_start;
|
||||
old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;
|
||||
break;
|
||||
default:
|
||||
DRM_ERROR("Unknown placement %d\n", old_mem->mem_type);
|
||||
|
@ -267,10 +266,8 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
|
|||
}
|
||||
switch (new_mem->mem_type) {
|
||||
case TTM_PL_VRAM:
|
||||
new_start += adev->mc.vram_start;
|
||||
break;
|
||||
case TTM_PL_TT:
|
||||
new_start += adev->mc.gtt_start;
|
||||
new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;
|
||||
break;
|
||||
default:
|
||||
DRM_ERROR("Unknown placement %d\n", old_mem->mem_type);
|
||||
|
@ -285,7 +282,7 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
|
|||
|
||||
r = amdgpu_copy_buffer(ring, old_start, new_start,
|
||||
new_mem->num_pages * PAGE_SIZE, /* bytes */
|
||||
bo->resv, &fence);
|
||||
bo->resv, &fence, false);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
@ -335,7 +332,7 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo,
|
|||
if (unlikely(r)) {
|
||||
goto out_cleanup;
|
||||
}
|
||||
r = ttm_bo_move_ttm(bo, true, interruptible, no_wait_gpu, new_mem);
|
||||
r = ttm_bo_move_ttm(bo, interruptible, no_wait_gpu, new_mem);
|
||||
out_cleanup:
|
||||
ttm_bo_mem_put(bo, &tmp_mem);
|
||||
return r;
|
||||
|
@ -368,7 +365,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo,
|
|||
if (unlikely(r)) {
|
||||
return r;
|
||||
}
|
||||
r = ttm_bo_move_ttm(bo, true, interruptible, no_wait_gpu, &tmp_mem);
|
||||
r = ttm_bo_move_ttm(bo, interruptible, no_wait_gpu, &tmp_mem);
|
||||
if (unlikely(r)) {
|
||||
goto out_cleanup;
|
||||
}
|
||||
|
@ -435,8 +432,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo,
|
|||
|
||||
if (r) {
|
||||
memcpy:
|
||||
r = ttm_bo_move_memcpy(bo, evict, interruptible,
|
||||
no_wait_gpu, new_mem);
|
||||
r = ttm_bo_move_memcpy(bo, interruptible, no_wait_gpu, new_mem);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
|
@ -950,6 +946,8 @@ static struct list_head *amdgpu_ttm_lru_tail(struct ttm_buffer_object *tbo)
|
|||
struct list_head *res = lru->lru[tbo->mem.mem_type];
|
||||
|
||||
lru->lru[tbo->mem.mem_type] = &tbo->lru;
|
||||
while ((++lru)->lru[tbo->mem.mem_type] == res)
|
||||
lru->lru[tbo->mem.mem_type] = &tbo->lru;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -960,6 +958,8 @@ static struct list_head *amdgpu_ttm_swap_lru_tail(struct ttm_buffer_object *tbo)
|
|||
struct list_head *res = lru->swap_lru;
|
||||
|
||||
lru->swap_lru = &tbo->swap;
|
||||
while ((++lru)->swap_lru == res)
|
||||
lru->swap_lru = &tbo->swap;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -987,10 +987,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
|
|||
unsigned i, j;
|
||||
int r;
|
||||
|
||||
r = amdgpu_ttm_global_init(adev);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
/* No others user of address space so set it to 0 */
|
||||
r = ttm_bo_device_init(&adev->mman.bdev,
|
||||
adev->mman.bo_global_ref.ref.object,
|
||||
|
@ -1011,6 +1007,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
|
|||
lru->swap_lru = &adev->mman.bdev.glob->swap_lru;
|
||||
}
|
||||
|
||||
for (j = 0; j < TTM_NUM_MEM_TYPES; ++j)
|
||||
adev->mman.guard.lru[j] = NULL;
|
||||
adev->mman.guard.swap_lru = NULL;
|
||||
|
||||
adev->mman.initialized = true;
|
||||
r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM,
|
||||
adev->mc.real_vram_size >> PAGE_SHIFT);
|
||||
|
@ -1151,7 +1151,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring,
|
|||
uint64_t dst_offset,
|
||||
uint32_t byte_count,
|
||||
struct reservation_object *resv,
|
||||
struct fence **fence)
|
||||
struct fence **fence, bool direct_submit)
|
||||
{
|
||||
struct amdgpu_device *adev = ring->adev;
|
||||
struct amdgpu_job *job;
|
||||
|
@ -1193,10 +1193,81 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring,
|
|||
byte_count -= cur_size_in_bytes;
|
||||
}
|
||||
|
||||
amdgpu_ring_pad_ib(ring, &job->ibs[0]);
|
||||
WARN_ON(job->ibs[0].length_dw > num_dw);
|
||||
if (direct_submit) {
|
||||
r = amdgpu_ib_schedule(ring, job->num_ibs, job->ibs,
|
||||
NULL, NULL, fence);
|
||||
job->fence = fence_get(*fence);
|
||||
if (r)
|
||||
DRM_ERROR("Error scheduling IBs (%d)\n", r);
|
||||
amdgpu_job_free(job);
|
||||
} else {
|
||||
r = amdgpu_job_submit(job, ring, &adev->mman.entity,
|
||||
AMDGPU_FENCE_OWNER_UNDEFINED, fence);
|
||||
if (r)
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
return r;
|
||||
|
||||
error_free:
|
||||
amdgpu_job_free(job);
|
||||
return r;
|
||||
}
|
||||
|
||||
int amdgpu_fill_buffer(struct amdgpu_bo *bo,
|
||||
uint32_t src_data,
|
||||
struct reservation_object *resv,
|
||||
struct fence **fence)
|
||||
{
|
||||
struct amdgpu_device *adev = bo->adev;
|
||||
struct amdgpu_job *job;
|
||||
struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring;
|
||||
|
||||
uint32_t max_bytes, byte_count;
|
||||
uint64_t dst_offset;
|
||||
unsigned int num_loops, num_dw;
|
||||
unsigned int i;
|
||||
int r;
|
||||
|
||||
byte_count = bo->tbo.num_pages << PAGE_SHIFT;
|
||||
max_bytes = adev->mman.buffer_funcs->fill_max_bytes;
|
||||
num_loops = DIV_ROUND_UP(byte_count, max_bytes);
|
||||
num_dw = num_loops * adev->mman.buffer_funcs->fill_num_dw;
|
||||
|
||||
/* for IB padding */
|
||||
while (num_dw & 0x7)
|
||||
num_dw++;
|
||||
|
||||
r = amdgpu_job_alloc_with_ib(adev, num_dw * 4, &job);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (resv) {
|
||||
r = amdgpu_sync_resv(adev, &job->sync, resv,
|
||||
AMDGPU_FENCE_OWNER_UNDEFINED);
|
||||
if (r) {
|
||||
DRM_ERROR("sync failed (%d).\n", r);
|
||||
goto error_free;
|
||||
}
|
||||
}
|
||||
|
||||
dst_offset = bo->tbo.mem.start << PAGE_SHIFT;
|
||||
for (i = 0; i < num_loops; i++) {
|
||||
uint32_t cur_size_in_bytes = min(byte_count, max_bytes);
|
||||
|
||||
amdgpu_emit_fill_buffer(adev, &job->ibs[0], src_data,
|
||||
dst_offset, cur_size_in_bytes);
|
||||
|
||||
dst_offset += cur_size_in_bytes;
|
||||
byte_count -= cur_size_in_bytes;
|
||||
}
|
||||
|
||||
amdgpu_ring_pad_ib(ring, &job->ibs[0]);
|
||||
WARN_ON(job->ibs[0].length_dw > num_dw);
|
||||
r = amdgpu_job_submit(job, ring, &adev->mman.entity,
|
||||
AMDGPU_FENCE_OWNER_UNDEFINED, fence);
|
||||
AMDGPU_FENCE_OWNER_UNDEFINED, fence);
|
||||
if (r)
|
||||
goto error_free;
|
||||
|
||||
|
@ -1387,3 +1458,8 @@ static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev)
|
|||
|
||||
#endif
|
||||
}
|
||||
|
||||
u64 amdgpu_ttm_get_gtt_mem_size(struct amdgpu_device *adev)
|
||||
{
|
||||
return ttm_get_kernel_zone_memory_size(adev->mman.mem_global_ref.object);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __AMDGPU_TTM_H__
|
||||
#define __AMDGPU_TTM_H__
|
||||
|
||||
#include "gpu_scheduler.h"
|
||||
|
||||
#define AMDGPU_PL_GDS TTM_PL_PRIV0
|
||||
#define AMDGPU_PL_GWS TTM_PL_PRIV1
|
||||
#define AMDGPU_PL_OA TTM_PL_PRIV2
|
||||
|
||||
#define AMDGPU_PL_FLAG_GDS TTM_PL_FLAG_PRIV0
|
||||
#define AMDGPU_PL_FLAG_GWS TTM_PL_FLAG_PRIV1
|
||||
#define AMDGPU_PL_FLAG_OA TTM_PL_FLAG_PRIV2
|
||||
|
||||
#define AMDGPU_TTM_LRU_SIZE 20
|
||||
|
||||
struct amdgpu_mman_lru {
|
||||
struct list_head *lru[TTM_NUM_MEM_TYPES];
|
||||
struct list_head *swap_lru;
|
||||
};
|
||||
|
||||
struct amdgpu_mman {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
struct drm_global_reference mem_global_ref;
|
||||
struct ttm_bo_device bdev;
|
||||
bool mem_global_referenced;
|
||||
bool initialized;
|
||||
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
struct dentry *vram;
|
||||
struct dentry *gtt;
|
||||
#endif
|
||||
|
||||
/* buffer handling */
|
||||
const struct amdgpu_buffer_funcs *buffer_funcs;
|
||||
struct amdgpu_ring *buffer_funcs_ring;
|
||||
/* Scheduler entity for buffer moves */
|
||||
struct amd_sched_entity entity;
|
||||
|
||||
/* custom LRU management */
|
||||
struct amdgpu_mman_lru log2_size[AMDGPU_TTM_LRU_SIZE];
|
||||
/* guard for log2_size array, don't add anything in between */
|
||||
struct amdgpu_mman_lru guard;
|
||||
};
|
||||
|
||||
int amdgpu_copy_buffer(struct amdgpu_ring *ring,
|
||||
uint64_t src_offset,
|
||||
uint64_t dst_offset,
|
||||
uint32_t byte_count,
|
||||
struct reservation_object *resv,
|
||||
struct fence **fence, bool direct_submit);
|
||||
int amdgpu_fill_buffer(struct amdgpu_bo *bo,
|
||||
uint32_t src_data,
|
||||
struct reservation_object *resv,
|
||||
struct fence **fence);
|
||||
|
||||
int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma);
|
||||
#endif
|
|
@ -201,39 +201,14 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
|
|||
bo_size = AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(hdr->ucode_size_bytes) + 8)
|
||||
+ AMDGPU_UVD_STACK_SIZE + AMDGPU_UVD_HEAP_SIZE
|
||||
+ AMDGPU_UVD_SESSION_SIZE * adev->uvd.max_handles;
|
||||
r = amdgpu_bo_create(adev, bo_size, PAGE_SIZE, true,
|
||||
AMDGPU_GEM_DOMAIN_VRAM,
|
||||
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
|
||||
NULL, NULL, &adev->uvd.vcpu_bo);
|
||||
r = amdgpu_bo_create_kernel(adev, bo_size, PAGE_SIZE,
|
||||
AMDGPU_GEM_DOMAIN_VRAM, &adev->uvd.vcpu_bo,
|
||||
&adev->uvd.gpu_addr, &adev->uvd.cpu_addr);
|
||||
if (r) {
|
||||
dev_err(adev->dev, "(%d) failed to allocate UVD bo\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
r = amdgpu_bo_reserve(adev->uvd.vcpu_bo, false);
|
||||
if (r) {
|
||||
amdgpu_bo_unref(&adev->uvd.vcpu_bo);
|
||||
dev_err(adev->dev, "(%d) failed to reserve UVD bo\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
r = amdgpu_bo_pin(adev->uvd.vcpu_bo, AMDGPU_GEM_DOMAIN_VRAM,
|
||||
&adev->uvd.gpu_addr);
|
||||
if (r) {
|
||||
amdgpu_bo_unreserve(adev->uvd.vcpu_bo);
|
||||
amdgpu_bo_unref(&adev->uvd.vcpu_bo);
|
||||
dev_err(adev->dev, "(%d) UVD bo pin failed\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
r = amdgpu_bo_kmap(adev->uvd.vcpu_bo, &adev->uvd.cpu_addr);
|
||||
if (r) {
|
||||
dev_err(adev->dev, "(%d) UVD map failed\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
amdgpu_bo_unreserve(adev->uvd.vcpu_bo);
|
||||
|
||||
ring = &adev->uvd.ring;
|
||||
rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL];
|
||||
r = amd_sched_entity_init(&ring->sched, &adev->uvd.entity,
|
||||
|
@ -323,7 +298,7 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
|
|||
if (!adev->uvd.saved_bo)
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(adev->uvd.saved_bo, ptr, size);
|
||||
memcpy_fromio(adev->uvd.saved_bo, ptr, size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -340,7 +315,7 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev)
|
|||
ptr = adev->uvd.cpu_addr;
|
||||
|
||||
if (adev->uvd.saved_bo != NULL) {
|
||||
memcpy(ptr, adev->uvd.saved_bo, size);
|
||||
memcpy_toio(ptr, adev->uvd.saved_bo, size);
|
||||
kfree(adev->uvd.saved_bo);
|
||||
adev->uvd.saved_bo = NULL;
|
||||
} else {
|
||||
|
@ -349,11 +324,11 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev)
|
|||
|
||||
hdr = (const struct common_firmware_header *)adev->uvd.fw->data;
|
||||
offset = le32_to_cpu(hdr->ucode_array_offset_bytes);
|
||||
memcpy(adev->uvd.cpu_addr, (adev->uvd.fw->data) + offset,
|
||||
(adev->uvd.fw->size) - offset);
|
||||
memcpy_toio(adev->uvd.cpu_addr, adev->uvd.fw->data + offset,
|
||||
le32_to_cpu(hdr->ucode_size_bytes));
|
||||
size -= le32_to_cpu(hdr->ucode_size_bytes);
|
||||
ptr += le32_to_cpu(hdr->ucode_size_bytes);
|
||||
memset(ptr, 0, size);
|
||||
memset_io(ptr, 0, size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -843,6 +818,7 @@ static int amdgpu_uvd_cs_reg(struct amdgpu_uvd_cs_ctx *ctx,
|
|||
return r;
|
||||
break;
|
||||
case mmUVD_ENGINE_CNTL:
|
||||
case mmUVD_NO_OP:
|
||||
break;
|
||||
default:
|
||||
DRM_ERROR("Invalid reg 0x%X!\n", reg);
|
||||
|
@ -981,8 +957,10 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo,
|
|||
ib->ptr[3] = addr >> 32;
|
||||
ib->ptr[4] = PACKET0(mmUVD_GPCOM_VCPU_CMD, 0);
|
||||
ib->ptr[5] = 0;
|
||||
for (i = 6; i < 16; ++i)
|
||||
ib->ptr[i] = PACKET2(0);
|
||||
for (i = 6; i < 16; i += 2) {
|
||||
ib->ptr[i] = PACKET0(mmUVD_NO_OP, 0);
|
||||
ib->ptr[i+1] = 0;
|
||||
}
|
||||
ib->length_dw = 16;
|
||||
|
||||
if (direct) {
|
||||
|
@ -1114,15 +1092,9 @@ static void amdgpu_uvd_idle_work_handler(struct work_struct *work)
|
|||
{
|
||||
struct amdgpu_device *adev =
|
||||
container_of(work, struct amdgpu_device, uvd.idle_work.work);
|
||||
unsigned i, fences, handles = 0;
|
||||
unsigned fences = amdgpu_fence_count_emitted(&adev->uvd.ring);
|
||||
|
||||
fences = amdgpu_fence_count_emitted(&adev->uvd.ring);
|
||||
|
||||
for (i = 0; i < adev->uvd.max_handles; ++i)
|
||||
if (atomic_read(&adev->uvd.handles[i]))
|
||||
++handles;
|
||||
|
||||
if (fences == 0 && handles == 0) {
|
||||
if (fences == 0) {
|
||||
if (adev->pm.dpm_enabled) {
|
||||
amdgpu_dpm_enable_uvd(adev, false);
|
||||
} else {
|
||||
|
|
|
@ -282,8 +282,8 @@ int amdgpu_vce_resume(struct amdgpu_device *adev)
|
|||
|
||||
hdr = (const struct common_firmware_header *)adev->vce.fw->data;
|
||||
offset = le32_to_cpu(hdr->ucode_array_offset_bytes);
|
||||
memcpy(cpu_addr, (adev->vce.fw->data) + offset,
|
||||
(adev->vce.fw->size) - offset);
|
||||
memcpy_toio(cpu_addr, adev->vce.fw->data + offset,
|
||||
adev->vce.fw->size - offset);
|
||||
|
||||
amdgpu_bo_kunmap(adev->vce.vcpu_bo);
|
||||
|
||||
|
|
|
@ -51,19 +51,22 @@
|
|||
* SI supports 16.
|
||||
*/
|
||||
|
||||
/* Special value that no flush is necessary */
|
||||
#define AMDGPU_VM_NO_FLUSH (~0ll)
|
||||
|
||||
/* Local structure. Encapsulate some VM table update parameters to reduce
|
||||
* the number of function parameters
|
||||
*/
|
||||
struct amdgpu_vm_update_params {
|
||||
struct amdgpu_pte_update_params {
|
||||
/* amdgpu device we do this update for */
|
||||
struct amdgpu_device *adev;
|
||||
/* address where to copy page table entries from */
|
||||
uint64_t src;
|
||||
/* DMA addresses to use for mapping */
|
||||
dma_addr_t *pages_addr;
|
||||
/* indirect buffer to fill with commands */
|
||||
struct amdgpu_ib *ib;
|
||||
/* Function which actually does the update */
|
||||
void (*func)(struct amdgpu_pte_update_params *params, uint64_t pe,
|
||||
uint64_t addr, unsigned count, uint32_t incr,
|
||||
uint32_t flags);
|
||||
/* indicate update pt or its shadow */
|
||||
bool shadow;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -467,10 +470,9 @@ struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm,
|
|||
}
|
||||
|
||||
/**
|
||||
* amdgpu_vm_update_pages - helper to call the right asic function
|
||||
* amdgpu_vm_do_set_ptes - helper to call the right asic function
|
||||
*
|
||||
* @adev: amdgpu_device pointer
|
||||
* @vm_update_params: see amdgpu_vm_update_params definition
|
||||
* @params: see amdgpu_pte_update_params definition
|
||||
* @pe: addr of the page entry
|
||||
* @addr: dst addr to write into pe
|
||||
* @count: number of page entries to update
|
||||
|
@ -480,32 +482,44 @@ struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm,
|
|||
* Traces the parameters and calls the right asic functions
|
||||
* to setup the page table using the DMA.
|
||||
*/
|
||||
static void amdgpu_vm_update_pages(struct amdgpu_device *adev,
|
||||
struct amdgpu_vm_update_params
|
||||
*vm_update_params,
|
||||
static void amdgpu_vm_do_set_ptes(struct amdgpu_pte_update_params *params,
|
||||
uint64_t pe, uint64_t addr,
|
||||
unsigned count, uint32_t incr,
|
||||
uint32_t flags)
|
||||
{
|
||||
trace_amdgpu_vm_set_page(pe, addr, count, incr, flags);
|
||||
|
||||
if (count < 3) {
|
||||
amdgpu_vm_write_pte(params->adev, params->ib, pe,
|
||||
addr | flags, count, incr);
|
||||
|
||||
} else {
|
||||
amdgpu_vm_set_pte_pde(params->adev, params->ib, pe, addr,
|
||||
count, incr, flags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_vm_do_copy_ptes - copy the PTEs from the GART
|
||||
*
|
||||
* @params: see amdgpu_pte_update_params definition
|
||||
* @pe: addr of the page entry
|
||||
* @addr: dst addr to write into pe
|
||||
* @count: number of page entries to update
|
||||
* @incr: increase next addr by incr bytes
|
||||
* @flags: hw access flags
|
||||
*
|
||||
* Traces the parameters and calls the DMA function to copy the PTEs.
|
||||
*/
|
||||
static void amdgpu_vm_do_copy_ptes(struct amdgpu_pte_update_params *params,
|
||||
uint64_t pe, uint64_t addr,
|
||||
unsigned count, uint32_t incr,
|
||||
uint32_t flags)
|
||||
{
|
||||
trace_amdgpu_vm_set_page(pe, addr, count, incr, flags);
|
||||
|
||||
if (vm_update_params->src) {
|
||||
amdgpu_vm_copy_pte(adev, vm_update_params->ib,
|
||||
pe, (vm_update_params->src + (addr >> 12) * 8), count);
|
||||
|
||||
} else if (vm_update_params->pages_addr) {
|
||||
amdgpu_vm_write_pte(adev, vm_update_params->ib,
|
||||
vm_update_params->pages_addr,
|
||||
pe, addr, count, incr, flags);
|
||||
|
||||
} else if (count < 3) {
|
||||
amdgpu_vm_write_pte(adev, vm_update_params->ib, NULL, pe, addr,
|
||||
count, incr, flags);
|
||||
|
||||
} else {
|
||||
amdgpu_vm_set_pte_pde(adev, vm_update_params->ib, pe, addr,
|
||||
count, incr, flags);
|
||||
}
|
||||
amdgpu_vm_copy_pte(params->adev, params->ib, pe,
|
||||
(params->src + (addr >> 12) * 8), count);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -523,12 +537,11 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
|
|||
struct amdgpu_ring *ring;
|
||||
struct fence *fence = NULL;
|
||||
struct amdgpu_job *job;
|
||||
struct amdgpu_vm_update_params vm_update_params;
|
||||
struct amdgpu_pte_update_params params;
|
||||
unsigned entries;
|
||||
uint64_t addr;
|
||||
int r;
|
||||
|
||||
memset(&vm_update_params, 0, sizeof(vm_update_params));
|
||||
ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
|
||||
|
||||
r = reservation_object_reserve_shared(bo->tbo.resv);
|
||||
|
@ -546,9 +559,10 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
|
|||
if (r)
|
||||
goto error;
|
||||
|
||||
vm_update_params.ib = &job->ibs[0];
|
||||
amdgpu_vm_update_pages(adev, &vm_update_params, addr, 0, entries,
|
||||
0, 0);
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
params.adev = adev;
|
||||
params.ib = &job->ibs[0];
|
||||
amdgpu_vm_do_set_ptes(¶ms, addr, 0, entries, 0, 0);
|
||||
amdgpu_ring_pad_ib(ring, &job->ibs[0]);
|
||||
|
||||
WARN_ON(job->ibs[0].length_dw > 64);
|
||||
|
@ -577,55 +591,41 @@ error:
|
|||
* Look up the physical address of the page that the pte resolves
|
||||
* to and return the pointer for the page table entry.
|
||||
*/
|
||||
uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr)
|
||||
static uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr)
|
||||
{
|
||||
uint64_t result;
|
||||
|
||||
if (pages_addr) {
|
||||
/* page table offset */
|
||||
result = pages_addr[addr >> PAGE_SHIFT];
|
||||
/* page table offset */
|
||||
result = pages_addr[addr >> PAGE_SHIFT];
|
||||
|
||||
/* in case cpu page size != gpu page size*/
|
||||
result |= addr & (~PAGE_MASK);
|
||||
|
||||
} else {
|
||||
/* No mapping required */
|
||||
result = addr;
|
||||
}
|
||||
/* in case cpu page size != gpu page size*/
|
||||
result |= addr & (~PAGE_MASK);
|
||||
|
||||
result &= 0xFFFFFFFFFFFFF000ULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_vm_update_pdes - make sure that page directory is valid
|
||||
*
|
||||
* @adev: amdgpu_device pointer
|
||||
* @vm: requested vm
|
||||
* @start: start of GPU address range
|
||||
* @end: end of GPU address range
|
||||
*
|
||||
* Allocates new page tables if necessary
|
||||
* and updates the page directory.
|
||||
* Returns 0 for success, error for failure.
|
||||
*/
|
||||
int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
|
||||
struct amdgpu_vm *vm)
|
||||
static int amdgpu_vm_update_pd_or_shadow(struct amdgpu_device *adev,
|
||||
struct amdgpu_vm *vm,
|
||||
bool shadow)
|
||||
{
|
||||
struct amdgpu_ring *ring;
|
||||
struct amdgpu_bo *pd = vm->page_directory;
|
||||
uint64_t pd_addr = amdgpu_bo_gpu_offset(pd);
|
||||
struct amdgpu_bo *pd = shadow ? vm->page_directory->shadow :
|
||||
vm->page_directory;
|
||||
uint64_t pd_addr;
|
||||
uint32_t incr = AMDGPU_VM_PTE_COUNT * 8;
|
||||
uint64_t last_pde = ~0, last_pt = ~0;
|
||||
unsigned count = 0, pt_idx, ndw;
|
||||
struct amdgpu_job *job;
|
||||
struct amdgpu_vm_update_params vm_update_params;
|
||||
struct amdgpu_pte_update_params params;
|
||||
struct fence *fence = NULL;
|
||||
|
||||
int r;
|
||||
|
||||
memset(&vm_update_params, 0, sizeof(vm_update_params));
|
||||
if (!pd)
|
||||
return 0;
|
||||
pd_addr = amdgpu_bo_gpu_offset(pd);
|
||||
ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
|
||||
|
||||
/* padding, etc. */
|
||||
|
@ -638,7 +638,9 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
|
|||
if (r)
|
||||
return r;
|
||||
|
||||
vm_update_params.ib = &job->ibs[0];
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
params.adev = adev;
|
||||
params.ib = &job->ibs[0];
|
||||
|
||||
/* walk over the address space and update the page directory */
|
||||
for (pt_idx = 0; pt_idx <= vm->max_pde_used; ++pt_idx) {
|
||||
|
@ -649,19 +651,25 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
|
|||
continue;
|
||||
|
||||
pt = amdgpu_bo_gpu_offset(bo);
|
||||
if (vm->page_tables[pt_idx].addr == pt)
|
||||
continue;
|
||||
vm->page_tables[pt_idx].addr = pt;
|
||||
if (!shadow) {
|
||||
if (vm->page_tables[pt_idx].addr == pt)
|
||||
continue;
|
||||
vm->page_tables[pt_idx].addr = pt;
|
||||
} else {
|
||||
if (vm->page_tables[pt_idx].shadow_addr == pt)
|
||||
continue;
|
||||
vm->page_tables[pt_idx].shadow_addr = pt;
|
||||
}
|
||||
|
||||
pde = pd_addr + pt_idx * 8;
|
||||
if (((last_pde + 8 * count) != pde) ||
|
||||
((last_pt + incr * count) != pt)) {
|
||||
((last_pt + incr * count) != pt) ||
|
||||
(count == AMDGPU_VM_MAX_UPDATE_SIZE)) {
|
||||
|
||||
if (count) {
|
||||
amdgpu_vm_update_pages(adev, &vm_update_params,
|
||||
last_pde, last_pt,
|
||||
count, incr,
|
||||
AMDGPU_PTE_VALID);
|
||||
amdgpu_vm_do_set_ptes(¶ms, last_pde,
|
||||
last_pt, count, incr,
|
||||
AMDGPU_PTE_VALID);
|
||||
}
|
||||
|
||||
count = 1;
|
||||
|
@ -673,15 +681,14 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
|
|||
}
|
||||
|
||||
if (count)
|
||||
amdgpu_vm_update_pages(adev, &vm_update_params,
|
||||
last_pde, last_pt,
|
||||
count, incr, AMDGPU_PTE_VALID);
|
||||
amdgpu_vm_do_set_ptes(¶ms, last_pde, last_pt,
|
||||
count, incr, AMDGPU_PTE_VALID);
|
||||
|
||||
if (vm_update_params.ib->length_dw != 0) {
|
||||
amdgpu_ring_pad_ib(ring, vm_update_params.ib);
|
||||
if (params.ib->length_dw != 0) {
|
||||
amdgpu_ring_pad_ib(ring, params.ib);
|
||||
amdgpu_sync_resv(adev, &job->sync, pd->tbo.resv,
|
||||
AMDGPU_FENCE_OWNER_VM);
|
||||
WARN_ON(vm_update_params.ib->length_dw > ndw);
|
||||
WARN_ON(params.ib->length_dw > ndw);
|
||||
r = amdgpu_job_submit(job, ring, &vm->entity,
|
||||
AMDGPU_FENCE_OWNER_VM, &fence);
|
||||
if (r)
|
||||
|
@ -703,21 +710,135 @@ error_free:
|
|||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_vm_frag_ptes - add fragment information to PTEs
|
||||
/*
|
||||
* amdgpu_vm_update_pdes - make sure that page directory is valid
|
||||
*
|
||||
* @adev: amdgpu_device pointer
|
||||
* @vm_update_params: see amdgpu_vm_update_params definition
|
||||
* @pe_start: first PTE to handle
|
||||
* @pe_end: last PTE to handle
|
||||
* @addr: addr those PTEs should point to
|
||||
* @vm: requested vm
|
||||
* @start: start of GPU address range
|
||||
* @end: end of GPU address range
|
||||
*
|
||||
* Allocates new page tables if necessary
|
||||
* and updates the page directory.
|
||||
* Returns 0 for success, error for failure.
|
||||
*/
|
||||
int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
|
||||
struct amdgpu_vm *vm)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = amdgpu_vm_update_pd_or_shadow(adev, vm, true);
|
||||
if (r)
|
||||
return r;
|
||||
return amdgpu_vm_update_pd_or_shadow(adev, vm, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_vm_update_ptes - make sure that page tables are valid
|
||||
*
|
||||
* @params: see amdgpu_pte_update_params definition
|
||||
* @vm: requested vm
|
||||
* @start: start of GPU address range
|
||||
* @end: end of GPU address range
|
||||
* @dst: destination address to map to, the next dst inside the function
|
||||
* @flags: mapping flags
|
||||
*
|
||||
* Update the page tables in the range @start - @end.
|
||||
*/
|
||||
static void amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
|
||||
struct amdgpu_vm *vm,
|
||||
uint64_t start, uint64_t end,
|
||||
uint64_t dst, uint32_t flags)
|
||||
{
|
||||
const uint64_t mask = AMDGPU_VM_PTE_COUNT - 1;
|
||||
|
||||
uint64_t cur_pe_start, cur_nptes, cur_dst;
|
||||
uint64_t addr; /* next GPU address to be updated */
|
||||
uint64_t pt_idx;
|
||||
struct amdgpu_bo *pt;
|
||||
unsigned nptes; /* next number of ptes to be updated */
|
||||
uint64_t next_pe_start;
|
||||
|
||||
/* initialize the variables */
|
||||
addr = start;
|
||||
pt_idx = addr >> amdgpu_vm_block_size;
|
||||
pt = vm->page_tables[pt_idx].entry.robj;
|
||||
if (params->shadow) {
|
||||
if (!pt->shadow)
|
||||
return;
|
||||
pt = vm->page_tables[pt_idx].entry.robj->shadow;
|
||||
}
|
||||
if ((addr & ~mask) == (end & ~mask))
|
||||
nptes = end - addr;
|
||||
else
|
||||
nptes = AMDGPU_VM_PTE_COUNT - (addr & mask);
|
||||
|
||||
cur_pe_start = amdgpu_bo_gpu_offset(pt);
|
||||
cur_pe_start += (addr & mask) * 8;
|
||||
cur_nptes = nptes;
|
||||
cur_dst = dst;
|
||||
|
||||
/* for next ptb*/
|
||||
addr += nptes;
|
||||
dst += nptes * AMDGPU_GPU_PAGE_SIZE;
|
||||
|
||||
/* walk over the address space and update the page tables */
|
||||
while (addr < end) {
|
||||
pt_idx = addr >> amdgpu_vm_block_size;
|
||||
pt = vm->page_tables[pt_idx].entry.robj;
|
||||
if (params->shadow) {
|
||||
if (!pt->shadow)
|
||||
return;
|
||||
pt = vm->page_tables[pt_idx].entry.robj->shadow;
|
||||
}
|
||||
|
||||
if ((addr & ~mask) == (end & ~mask))
|
||||
nptes = end - addr;
|
||||
else
|
||||
nptes = AMDGPU_VM_PTE_COUNT - (addr & mask);
|
||||
|
||||
next_pe_start = amdgpu_bo_gpu_offset(pt);
|
||||
next_pe_start += (addr & mask) * 8;
|
||||
|
||||
if ((cur_pe_start + 8 * cur_nptes) == next_pe_start &&
|
||||
((cur_nptes + nptes) <= AMDGPU_VM_MAX_UPDATE_SIZE)) {
|
||||
/* The next ptb is consecutive to current ptb.
|
||||
* Don't call the update function now.
|
||||
* Will update two ptbs together in future.
|
||||
*/
|
||||
cur_nptes += nptes;
|
||||
} else {
|
||||
params->func(params, cur_pe_start, cur_dst, cur_nptes,
|
||||
AMDGPU_GPU_PAGE_SIZE, flags);
|
||||
|
||||
cur_pe_start = next_pe_start;
|
||||
cur_nptes = nptes;
|
||||
cur_dst = dst;
|
||||
}
|
||||
|
||||
/* for next ptb*/
|
||||
addr += nptes;
|
||||
dst += nptes * AMDGPU_GPU_PAGE_SIZE;
|
||||
}
|
||||
|
||||
params->func(params, cur_pe_start, cur_dst, cur_nptes,
|
||||
AMDGPU_GPU_PAGE_SIZE, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* amdgpu_vm_frag_ptes - add fragment information to PTEs
|
||||
*
|
||||
* @params: see amdgpu_pte_update_params definition
|
||||
* @vm: requested vm
|
||||
* @start: first PTE to handle
|
||||
* @end: last PTE to handle
|
||||
* @dst: addr those PTEs should point to
|
||||
* @flags: hw mapping flags
|
||||
*/
|
||||
static void amdgpu_vm_frag_ptes(struct amdgpu_device *adev,
|
||||
struct amdgpu_vm_update_params
|
||||
*vm_update_params,
|
||||
uint64_t pe_start, uint64_t pe_end,
|
||||
uint64_t addr, uint32_t flags)
|
||||
static void amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params,
|
||||
struct amdgpu_vm *vm,
|
||||
uint64_t start, uint64_t end,
|
||||
uint64_t dst, uint32_t flags)
|
||||
{
|
||||
/**
|
||||
* The MC L1 TLB supports variable sized pages, based on a fragment
|
||||
|
@ -738,138 +859,43 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_device *adev,
|
|||
* allocation size to the fragment size.
|
||||
*/
|
||||
|
||||
/* SI and newer are optimized for 64KB */
|
||||
uint64_t frag_flags = AMDGPU_PTE_FRAG_64KB;
|
||||
uint64_t frag_align = 0x80;
|
||||
const uint64_t frag_align = 1 << AMDGPU_LOG2_PAGES_PER_FRAG;
|
||||
|
||||
uint64_t frag_start = ALIGN(pe_start, frag_align);
|
||||
uint64_t frag_end = pe_end & ~(frag_align - 1);
|
||||
uint64_t frag_start = ALIGN(start, frag_align);
|
||||
uint64_t frag_end = end & ~(frag_align - 1);
|
||||
|
||||
unsigned count;
|
||||
|
||||
/* Abort early if there isn't anything to do */
|
||||
if (pe_start == pe_end)
|
||||
return;
|
||||
uint32_t frag;
|
||||
|
||||
/* system pages are non continuously */
|
||||
if (vm_update_params->src || vm_update_params->pages_addr ||
|
||||
!(flags & AMDGPU_PTE_VALID) || (frag_start >= frag_end)) {
|
||||
if (params->src || !(flags & AMDGPU_PTE_VALID) ||
|
||||
(frag_start >= frag_end)) {
|
||||
|
||||
count = (pe_end - pe_start) / 8;
|
||||
amdgpu_vm_update_pages(adev, vm_update_params, pe_start,
|
||||
addr, count, AMDGPU_GPU_PAGE_SIZE,
|
||||
flags);
|
||||
amdgpu_vm_update_ptes(params, vm, start, end, dst, flags);
|
||||
return;
|
||||
}
|
||||
|
||||
/* use more than 64KB fragment size if possible */
|
||||
frag = lower_32_bits(frag_start | frag_end);
|
||||
frag = likely(frag) ? __ffs(frag) : 31;
|
||||
|
||||
/* handle the 4K area at the beginning */
|
||||
if (pe_start != frag_start) {
|
||||
count = (frag_start - pe_start) / 8;
|
||||
amdgpu_vm_update_pages(adev, vm_update_params, pe_start, addr,
|
||||
count, AMDGPU_GPU_PAGE_SIZE, flags);
|
||||
addr += AMDGPU_GPU_PAGE_SIZE * count;
|
||||
if (start != frag_start) {
|
||||
amdgpu_vm_update_ptes(params, vm, start, frag_start,
|
||||
dst, flags);
|
||||
dst += (frag_start - start) * AMDGPU_GPU_PAGE_SIZE;
|
||||
}
|
||||
|
||||
/* handle the area in the middle */
|
||||
count = (frag_end - frag_start) / 8;
|
||||
amdgpu_vm_update_pages(adev, vm_update_params, frag_start, addr, count,
|
||||
AMDGPU_GPU_PAGE_SIZE, flags | frag_flags);
|
||||
amdgpu_vm_update_ptes(params, vm, frag_start, frag_end, dst,
|
||||
flags | AMDGPU_PTE_FRAG(frag));
|
||||
|
||||
/* handle the 4K area at the end */
|
||||
if (frag_end != pe_end) {
|
||||
addr += AMDGPU_GPU_PAGE_SIZE * count;
|
||||
count = (pe_end - frag_end) / 8;
|
||||
amdgpu_vm_update_pages(adev, vm_update_params, frag_end, addr,
|
||||
count, AMDGPU_GPU_PAGE_SIZE, flags);
|
||||
if (frag_end != end) {
|
||||
dst += (frag_end - frag_start) * AMDGPU_GPU_PAGE_SIZE;
|
||||
amdgpu_vm_update_ptes(params, vm, frag_end, end, dst, flags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_vm_update_ptes - make sure that page tables are valid
|
||||
*
|
||||
* @adev: amdgpu_device pointer
|
||||
* @vm_update_params: see amdgpu_vm_update_params definition
|
||||
* @vm: requested vm
|
||||
* @start: start of GPU address range
|
||||
* @end: end of GPU address range
|
||||
* @dst: destination address to map to, the next dst inside the function
|
||||
* @flags: mapping flags
|
||||
*
|
||||
* Update the page tables in the range @start - @end.
|
||||
*/
|
||||
static void amdgpu_vm_update_ptes(struct amdgpu_device *adev,
|
||||
struct amdgpu_vm_update_params
|
||||
*vm_update_params,
|
||||
struct amdgpu_vm *vm,
|
||||
uint64_t start, uint64_t end,
|
||||
uint64_t dst, uint32_t flags)
|
||||
{
|
||||
const uint64_t mask = AMDGPU_VM_PTE_COUNT - 1;
|
||||
|
||||
uint64_t cur_pe_start, cur_pe_end, cur_dst;
|
||||
uint64_t addr; /* next GPU address to be updated */
|
||||
uint64_t pt_idx;
|
||||
struct amdgpu_bo *pt;
|
||||
unsigned nptes; /* next number of ptes to be updated */
|
||||
uint64_t next_pe_start;
|
||||
|
||||
/* initialize the variables */
|
||||
addr = start;
|
||||
pt_idx = addr >> amdgpu_vm_block_size;
|
||||
pt = vm->page_tables[pt_idx].entry.robj;
|
||||
|
||||
if ((addr & ~mask) == (end & ~mask))
|
||||
nptes = end - addr;
|
||||
else
|
||||
nptes = AMDGPU_VM_PTE_COUNT - (addr & mask);
|
||||
|
||||
cur_pe_start = amdgpu_bo_gpu_offset(pt);
|
||||
cur_pe_start += (addr & mask) * 8;
|
||||
cur_pe_end = cur_pe_start + 8 * nptes;
|
||||
cur_dst = dst;
|
||||
|
||||
/* for next ptb*/
|
||||
addr += nptes;
|
||||
dst += nptes * AMDGPU_GPU_PAGE_SIZE;
|
||||
|
||||
/* walk over the address space and update the page tables */
|
||||
while (addr < end) {
|
||||
pt_idx = addr >> amdgpu_vm_block_size;
|
||||
pt = vm->page_tables[pt_idx].entry.robj;
|
||||
|
||||
if ((addr & ~mask) == (end & ~mask))
|
||||
nptes = end - addr;
|
||||
else
|
||||
nptes = AMDGPU_VM_PTE_COUNT - (addr & mask);
|
||||
|
||||
next_pe_start = amdgpu_bo_gpu_offset(pt);
|
||||
next_pe_start += (addr & mask) * 8;
|
||||
|
||||
if (cur_pe_end == next_pe_start) {
|
||||
/* The next ptb is consecutive to current ptb.
|
||||
* Don't call amdgpu_vm_frag_ptes now.
|
||||
* Will update two ptbs together in future.
|
||||
*/
|
||||
cur_pe_end += 8 * nptes;
|
||||
} else {
|
||||
amdgpu_vm_frag_ptes(adev, vm_update_params,
|
||||
cur_pe_start, cur_pe_end,
|
||||
cur_dst, flags);
|
||||
|
||||
cur_pe_start = next_pe_start;
|
||||
cur_pe_end = next_pe_start + 8 * nptes;
|
||||
cur_dst = dst;
|
||||
}
|
||||
|
||||
/* for next ptb*/
|
||||
addr += nptes;
|
||||
dst += nptes * AMDGPU_GPU_PAGE_SIZE;
|
||||
}
|
||||
|
||||
amdgpu_vm_frag_ptes(adev, vm_update_params, cur_pe_start,
|
||||
cur_pe_end, cur_dst, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_vm_bo_update_mapping - update a mapping in the vm page table
|
||||
*
|
||||
|
@ -900,14 +926,19 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
|
|||
void *owner = AMDGPU_FENCE_OWNER_VM;
|
||||
unsigned nptes, ncmds, ndw;
|
||||
struct amdgpu_job *job;
|
||||
struct amdgpu_vm_update_params vm_update_params;
|
||||
struct amdgpu_pte_update_params params;
|
||||
struct fence *f = NULL;
|
||||
int r;
|
||||
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
params.adev = adev;
|
||||
params.src = src;
|
||||
|
||||
ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
|
||||
memset(&vm_update_params, 0, sizeof(vm_update_params));
|
||||
vm_update_params.src = src;
|
||||
vm_update_params.pages_addr = pages_addr;
|
||||
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
params.adev = adev;
|
||||
params.src = src;
|
||||
|
||||
/* sync to everything on unmapping */
|
||||
if (!(flags & AMDGPU_PTE_VALID))
|
||||
|
@ -924,30 +955,52 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
|
|||
/* padding, etc. */
|
||||
ndw = 64;
|
||||
|
||||
if (vm_update_params.src) {
|
||||
if (src) {
|
||||
/* only copy commands needed */
|
||||
ndw += ncmds * 7;
|
||||
|
||||
} else if (vm_update_params.pages_addr) {
|
||||
/* header for write data commands */
|
||||
ndw += ncmds * 4;
|
||||
params.func = amdgpu_vm_do_copy_ptes;
|
||||
|
||||
/* body of write data command */
|
||||
} else if (pages_addr) {
|
||||
/* copy commands needed */
|
||||
ndw += ncmds * 7;
|
||||
|
||||
/* and also PTEs */
|
||||
ndw += nptes * 2;
|
||||
|
||||
params.func = amdgpu_vm_do_copy_ptes;
|
||||
|
||||
} else {
|
||||
/* set page commands needed */
|
||||
ndw += ncmds * 10;
|
||||
|
||||
/* two extra commands for begin/end of fragment */
|
||||
ndw += 2 * 10;
|
||||
|
||||
params.func = amdgpu_vm_do_set_ptes;
|
||||
}
|
||||
|
||||
r = amdgpu_job_alloc_with_ib(adev, ndw * 4, &job);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
vm_update_params.ib = &job->ibs[0];
|
||||
params.ib = &job->ibs[0];
|
||||
|
||||
if (!src && pages_addr) {
|
||||
uint64_t *pte;
|
||||
unsigned i;
|
||||
|
||||
/* Put the PTEs at the end of the IB. */
|
||||
i = ndw - nptes * 2;
|
||||
pte= (uint64_t *)&(job->ibs->ptr[i]);
|
||||
params.src = job->ibs->gpu_addr + i * 4;
|
||||
|
||||
for (i = 0; i < nptes; ++i) {
|
||||
pte[i] = amdgpu_vm_map_gart(pages_addr, addr + i *
|
||||
AMDGPU_GPU_PAGE_SIZE);
|
||||
pte[i] |= flags;
|
||||
}
|
||||
}
|
||||
|
||||
r = amdgpu_sync_fence(adev, &job->sync, exclusive);
|
||||
if (r)
|
||||
|
@ -962,11 +1015,13 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
|
|||
if (r)
|
||||
goto error_free;
|
||||
|
||||
amdgpu_vm_update_ptes(adev, &vm_update_params, vm, start,
|
||||
last + 1, addr, flags);
|
||||
params.shadow = true;
|
||||
amdgpu_vm_frag_ptes(¶ms, vm, start, last + 1, addr, flags);
|
||||
params.shadow = false;
|
||||
amdgpu_vm_frag_ptes(¶ms, vm, start, last + 1, addr, flags);
|
||||
|
||||
amdgpu_ring_pad_ib(ring, vm_update_params.ib);
|
||||
WARN_ON(vm_update_params.ib->length_dw > ndw);
|
||||
amdgpu_ring_pad_ib(ring, params.ib);
|
||||
WARN_ON(params.ib->length_dw > ndw);
|
||||
r = amdgpu_job_submit(job, ring, &vm->entity,
|
||||
AMDGPU_FENCE_OWNER_VM, &f);
|
||||
if (r)
|
||||
|
@ -1062,28 +1117,32 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
|
|||
*
|
||||
* @adev: amdgpu_device pointer
|
||||
* @bo_va: requested BO and VM object
|
||||
* @mem: ttm mem
|
||||
* @clear: if true clear the entries
|
||||
*
|
||||
* Fill in the page table entries for @bo_va.
|
||||
* Returns 0 for success, -EINVAL for failure.
|
||||
*
|
||||
* Object have to be reserved and mutex must be locked!
|
||||
*/
|
||||
int amdgpu_vm_bo_update(struct amdgpu_device *adev,
|
||||
struct amdgpu_bo_va *bo_va,
|
||||
struct ttm_mem_reg *mem)
|
||||
bool clear)
|
||||
{
|
||||
struct amdgpu_vm *vm = bo_va->vm;
|
||||
struct amdgpu_bo_va_mapping *mapping;
|
||||
dma_addr_t *pages_addr = NULL;
|
||||
uint32_t gtt_flags, flags;
|
||||
struct ttm_mem_reg *mem;
|
||||
struct fence *exclusive;
|
||||
uint64_t addr;
|
||||
int r;
|
||||
|
||||
if (mem) {
|
||||
if (clear) {
|
||||
mem = NULL;
|
||||
addr = 0;
|
||||
exclusive = NULL;
|
||||
} else {
|
||||
struct ttm_dma_tt *ttm;
|
||||
|
||||
mem = &bo_va->bo->tbo.mem;
|
||||
addr = (u64)mem->start << PAGE_SHIFT;
|
||||
switch (mem->mem_type) {
|
||||
case TTM_PL_TT:
|
||||
|
@ -1101,9 +1160,6 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
|
|||
}
|
||||
|
||||
exclusive = reservation_object_get_excl(bo_va->bo->tbo.resv);
|
||||
} else {
|
||||
addr = 0;
|
||||
exclusive = NULL;
|
||||
}
|
||||
|
||||
flags = amdgpu_ttm_tt_pte_flags(adev, bo_va->bo->tbo.ttm, mem);
|
||||
|
@ -1134,7 +1190,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
|
|||
spin_lock(&vm->status_lock);
|
||||
list_splice_init(&bo_va->invalids, &bo_va->valids);
|
||||
list_del_init(&bo_va->vm_status);
|
||||
if (!mem)
|
||||
if (clear)
|
||||
list_add(&bo_va->vm_status, &vm->cleared);
|
||||
spin_unlock(&vm->status_lock);
|
||||
|
||||
|
@ -1197,7 +1253,7 @@ int amdgpu_vm_clear_invalids(struct amdgpu_device *adev,
|
|||
struct amdgpu_bo_va, vm_status);
|
||||
spin_unlock(&vm->status_lock);
|
||||
|
||||
r = amdgpu_vm_bo_update(adev, bo_va, NULL);
|
||||
r = amdgpu_vm_bo_update(adev, bo_va, true);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
@ -1342,7 +1398,8 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
|
|||
r = amdgpu_bo_create(adev, AMDGPU_VM_PTE_COUNT * 8,
|
||||
AMDGPU_GPU_PAGE_SIZE, true,
|
||||
AMDGPU_GEM_DOMAIN_VRAM,
|
||||
AMDGPU_GEM_CREATE_NO_CPU_ACCESS,
|
||||
AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
|
||||
AMDGPU_GEM_CREATE_SHADOW,
|
||||
NULL, resv, &pt);
|
||||
if (r)
|
||||
goto error_free;
|
||||
|
@ -1541,7 +1598,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
|
|||
|
||||
r = amdgpu_bo_create(adev, pd_size, align, true,
|
||||
AMDGPU_GEM_DOMAIN_VRAM,
|
||||
AMDGPU_GEM_CREATE_NO_CPU_ACCESS,
|
||||
AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
|
||||
AMDGPU_GEM_CREATE_SHADOW,
|
||||
NULL, NULL, &vm->page_directory);
|
||||
if (r)
|
||||
goto error_free_sched_entity;
|
||||
|
@ -1597,10 +1655,16 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
|
|||
kfree(mapping);
|
||||
}
|
||||
|
||||
for (i = 0; i < amdgpu_vm_num_pdes(adev); i++)
|
||||
for (i = 0; i < amdgpu_vm_num_pdes(adev); i++) {
|
||||
if (vm->page_tables[i].entry.robj &&
|
||||
vm->page_tables[i].entry.robj->shadow)
|
||||
amdgpu_bo_unref(&vm->page_tables[i].entry.robj->shadow);
|
||||
amdgpu_bo_unref(&vm->page_tables[i].entry.robj);
|
||||
}
|
||||
drm_free_large(vm->page_tables);
|
||||
|
||||
if (vm->page_directory->shadow)
|
||||
amdgpu_bo_unref(&vm->page_directory->shadow);
|
||||
amdgpu_bo_unref(&vm->page_directory);
|
||||
fence_put(vm->page_directory_fence);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,6 @@ static int amdgpu_atombios_dp_process_aux_ch(struct amdgpu_i2c_chan *chan,
|
|||
|
||||
/* timeout */
|
||||
if (args.v2.ucReplyStatus == 1) {
|
||||
DRM_DEBUG_KMS("dp_aux_ch timeout\n");
|
||||
r = -ETIMEDOUT;
|
||||
goto done;
|
||||
}
|
||||
|
@ -339,22 +338,21 @@ int amdgpu_atombios_dp_get_dpcd(struct amdgpu_connector *amdgpu_connector)
|
|||
{
|
||||
struct amdgpu_connector_atom_dig *dig_connector = amdgpu_connector->con_priv;
|
||||
u8 msg[DP_DPCD_SIZE];
|
||||
int ret, i;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < 7; i++) {
|
||||
ret = drm_dp_dpcd_read(&amdgpu_connector->ddc_bus->aux, DP_DPCD_REV, msg,
|
||||
DP_DPCD_SIZE);
|
||||
if (ret == DP_DPCD_SIZE) {
|
||||
memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE);
|
||||
ret = drm_dp_dpcd_read(&amdgpu_connector->ddc_bus->aux, DP_DPCD_REV,
|
||||
msg, DP_DPCD_SIZE);
|
||||
if (ret == DP_DPCD_SIZE) {
|
||||
memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE);
|
||||
|
||||
DRM_DEBUG_KMS("DPCD: %*ph\n", (int)sizeof(dig_connector->dpcd),
|
||||
dig_connector->dpcd);
|
||||
DRM_DEBUG_KMS("DPCD: %*ph\n", (int)sizeof(dig_connector->dpcd),
|
||||
dig_connector->dpcd);
|
||||
|
||||
amdgpu_atombios_dp_probe_oui(amdgpu_connector);
|
||||
amdgpu_atombios_dp_probe_oui(amdgpu_connector);
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
dig_connector->dpcd[0] = 0;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -5874,7 +5874,10 @@ static int ci_dpm_init(struct amdgpu_device *adev)
|
|||
pi->pcie_dpm_key_disabled = 0;
|
||||
pi->thermal_sclk_dpm_enabled = 0;
|
||||
|
||||
pi->caps_sclk_ds = true;
|
||||
if (amdgpu_sclk_deep_sleep_en)
|
||||
pi->caps_sclk_ds = true;
|
||||
else
|
||||
pi->caps_sclk_ds = false;
|
||||
|
||||
pi->mclk_strobe_mode_threshold = 40000;
|
||||
pi->mclk_stutter_mode_threshold = 40000;
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
|
||||
#include "amdgpu_amdkfd.h"
|
||||
#include "amdgpu_powerplay.h"
|
||||
#include "dce_virtual.h"
|
||||
|
||||
/*
|
||||
* Indirect registers accessor
|
||||
|
@ -1708,6 +1709,74 @@ static const struct amdgpu_ip_block_version bonaire_ip_blocks[] =
|
|||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version bonaire_ip_blocks_vd[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_COMMON,
|
||||
.major = 1,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_common_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GMC,
|
||||
.major = 7,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gmc_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_IH,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_ih_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SMC,
|
||||
.major = 7,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &amdgpu_pp_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_DCE,
|
||||
.major = 8,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &dce_virtual_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GFX,
|
||||
.major = 7,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &gfx_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SDMA,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_sdma_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_UVD,
|
||||
.major = 4,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &uvd_v4_2_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_VCE,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vce_v2_0_ip_funcs,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version hawaii_ip_blocks[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
|
@ -1776,6 +1845,74 @@ static const struct amdgpu_ip_block_version hawaii_ip_blocks[] =
|
|||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version hawaii_ip_blocks_vd[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_COMMON,
|
||||
.major = 1,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_common_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GMC,
|
||||
.major = 7,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gmc_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_IH,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_ih_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SMC,
|
||||
.major = 7,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &amdgpu_pp_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_DCE,
|
||||
.major = 8,
|
||||
.minor = 5,
|
||||
.rev = 0,
|
||||
.funcs = &dce_virtual_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GFX,
|
||||
.major = 7,
|
||||
.minor = 3,
|
||||
.rev = 0,
|
||||
.funcs = &gfx_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SDMA,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_sdma_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_UVD,
|
||||
.major = 4,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &uvd_v4_2_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_VCE,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vce_v2_0_ip_funcs,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version kabini_ip_blocks[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
|
@ -1844,6 +1981,74 @@ static const struct amdgpu_ip_block_version kabini_ip_blocks[] =
|
|||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version kabini_ip_blocks_vd[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_COMMON,
|
||||
.major = 1,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_common_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GMC,
|
||||
.major = 7,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gmc_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_IH,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_ih_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SMC,
|
||||
.major = 7,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &amdgpu_pp_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_DCE,
|
||||
.major = 8,
|
||||
.minor = 3,
|
||||
.rev = 0,
|
||||
.funcs = &dce_virtual_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GFX,
|
||||
.major = 7,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &gfx_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SDMA,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_sdma_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_UVD,
|
||||
.major = 4,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &uvd_v4_2_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_VCE,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vce_v2_0_ip_funcs,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version mullins_ip_blocks[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
|
@ -1912,6 +2117,74 @@ static const struct amdgpu_ip_block_version mullins_ip_blocks[] =
|
|||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version mullins_ip_blocks_vd[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_COMMON,
|
||||
.major = 1,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_common_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GMC,
|
||||
.major = 7,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gmc_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_IH,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_ih_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SMC,
|
||||
.major = 7,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &amdgpu_pp_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_DCE,
|
||||
.major = 8,
|
||||
.minor = 3,
|
||||
.rev = 0,
|
||||
.funcs = &dce_virtual_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GFX,
|
||||
.major = 7,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &gfx_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SDMA,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_sdma_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_UVD,
|
||||
.major = 4,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &uvd_v4_2_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_VCE,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vce_v2_0_ip_funcs,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version kaveri_ip_blocks[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
|
@ -1980,32 +2253,128 @@ static const struct amdgpu_ip_block_version kaveri_ip_blocks[] =
|
|||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version kaveri_ip_blocks_vd[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_COMMON,
|
||||
.major = 1,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_common_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GMC,
|
||||
.major = 7,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gmc_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_IH,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_ih_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SMC,
|
||||
.major = 7,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &amdgpu_pp_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_DCE,
|
||||
.major = 8,
|
||||
.minor = 1,
|
||||
.rev = 0,
|
||||
.funcs = &dce_virtual_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GFX,
|
||||
.major = 7,
|
||||
.minor = 1,
|
||||
.rev = 0,
|
||||
.funcs = &gfx_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SDMA,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cik_sdma_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_UVD,
|
||||
.major = 4,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &uvd_v4_2_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_VCE,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vce_v2_0_ip_funcs,
|
||||
},
|
||||
};
|
||||
|
||||
int cik_set_ip_blocks(struct amdgpu_device *adev)
|
||||
{
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_BONAIRE:
|
||||
adev->ip_blocks = bonaire_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(bonaire_ip_blocks);
|
||||
break;
|
||||
case CHIP_HAWAII:
|
||||
adev->ip_blocks = hawaii_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(hawaii_ip_blocks);
|
||||
break;
|
||||
case CHIP_KAVERI:
|
||||
adev->ip_blocks = kaveri_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(kaveri_ip_blocks);
|
||||
break;
|
||||
case CHIP_KABINI:
|
||||
adev->ip_blocks = kabini_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(kabini_ip_blocks);
|
||||
break;
|
||||
case CHIP_MULLINS:
|
||||
adev->ip_blocks = mullins_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(mullins_ip_blocks);
|
||||
break;
|
||||
default:
|
||||
/* FIXME: not supported yet */
|
||||
return -EINVAL;
|
||||
if (adev->enable_virtual_display) {
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_BONAIRE:
|
||||
adev->ip_blocks = bonaire_ip_blocks_vd;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(bonaire_ip_blocks_vd);
|
||||
break;
|
||||
case CHIP_HAWAII:
|
||||
adev->ip_blocks = hawaii_ip_blocks_vd;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(hawaii_ip_blocks_vd);
|
||||
break;
|
||||
case CHIP_KAVERI:
|
||||
adev->ip_blocks = kaveri_ip_blocks_vd;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(kaveri_ip_blocks_vd);
|
||||
break;
|
||||
case CHIP_KABINI:
|
||||
adev->ip_blocks = kabini_ip_blocks_vd;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(kabini_ip_blocks_vd);
|
||||
break;
|
||||
case CHIP_MULLINS:
|
||||
adev->ip_blocks = mullins_ip_blocks_vd;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(mullins_ip_blocks_vd);
|
||||
break;
|
||||
default:
|
||||
/* FIXME: not supported yet */
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_BONAIRE:
|
||||
adev->ip_blocks = bonaire_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(bonaire_ip_blocks);
|
||||
break;
|
||||
case CHIP_HAWAII:
|
||||
adev->ip_blocks = hawaii_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(hawaii_ip_blocks);
|
||||
break;
|
||||
case CHIP_KAVERI:
|
||||
adev->ip_blocks = kaveri_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(kaveri_ip_blocks);
|
||||
break;
|
||||
case CHIP_KABINI:
|
||||
adev->ip_blocks = kabini_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(kabini_ip_blocks);
|
||||
break;
|
||||
case CHIP_MULLINS:
|
||||
adev->ip_blocks = mullins_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(mullins_ip_blocks);
|
||||
break;
|
||||
default:
|
||||
/* FIXME: not supported yet */
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -694,24 +694,16 @@ static void cik_sdma_vm_copy_pte(struct amdgpu_ib *ib,
|
|||
uint64_t pe, uint64_t src,
|
||||
unsigned count)
|
||||
{
|
||||
while (count) {
|
||||
unsigned bytes = count * 8;
|
||||
if (bytes > 0x1FFFF8)
|
||||
bytes = 0x1FFFF8;
|
||||
unsigned bytes = count * 8;
|
||||
|
||||
ib->ptr[ib->length_dw++] = SDMA_PACKET(SDMA_OPCODE_COPY,
|
||||
SDMA_WRITE_SUB_OPCODE_LINEAR, 0);
|
||||
ib->ptr[ib->length_dw++] = bytes;
|
||||
ib->ptr[ib->length_dw++] = 0; /* src/dst endian swap */
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
|
||||
pe += bytes;
|
||||
src += bytes;
|
||||
count -= bytes / 8;
|
||||
}
|
||||
ib->ptr[ib->length_dw++] = SDMA_PACKET(SDMA_OPCODE_COPY,
|
||||
SDMA_WRITE_SUB_OPCODE_LINEAR, 0);
|
||||
ib->ptr[ib->length_dw++] = bytes;
|
||||
ib->ptr[ib->length_dw++] = 0; /* src/dst endian swap */
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -719,39 +711,27 @@ static void cik_sdma_vm_copy_pte(struct amdgpu_ib *ib,
|
|||
*
|
||||
* @ib: indirect buffer to fill with commands
|
||||
* @pe: addr of the page entry
|
||||
* @addr: dst addr to write into pe
|
||||
* @value: dst addr to write into pe
|
||||
* @count: number of page entries to update
|
||||
* @incr: increase next addr by incr bytes
|
||||
* @flags: access flags
|
||||
*
|
||||
* Update PTEs by writing them manually using sDMA (CIK).
|
||||
*/
|
||||
static void cik_sdma_vm_write_pte(struct amdgpu_ib *ib,
|
||||
const dma_addr_t *pages_addr, uint64_t pe,
|
||||
uint64_t addr, unsigned count,
|
||||
uint32_t incr, uint32_t flags)
|
||||
static void cik_sdma_vm_write_pte(struct amdgpu_ib *ib, uint64_t pe,
|
||||
uint64_t value, unsigned count,
|
||||
uint32_t incr)
|
||||
{
|
||||
uint64_t value;
|
||||
unsigned ndw;
|
||||
unsigned ndw = count * 2;
|
||||
|
||||
while (count) {
|
||||
ndw = count * 2;
|
||||
if (ndw > 0xFFFFE)
|
||||
ndw = 0xFFFFE;
|
||||
|
||||
/* for non-physically contiguous pages (system) */
|
||||
ib->ptr[ib->length_dw++] = SDMA_PACKET(SDMA_OPCODE_WRITE,
|
||||
SDMA_WRITE_SUB_OPCODE_LINEAR, 0);
|
||||
ib->ptr[ib->length_dw++] = pe;
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = ndw;
|
||||
for (; ndw > 0; ndw -= 2, --count, pe += 8) {
|
||||
value = amdgpu_vm_map_gart(pages_addr, addr);
|
||||
addr += incr;
|
||||
value |= flags;
|
||||
ib->ptr[ib->length_dw++] = value;
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(value);
|
||||
}
|
||||
ib->ptr[ib->length_dw++] = SDMA_PACKET(SDMA_OPCODE_WRITE,
|
||||
SDMA_WRITE_SUB_OPCODE_LINEAR, 0);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = ndw;
|
||||
for (; ndw > 0; ndw -= 2) {
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(value);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(value);
|
||||
value += incr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -767,40 +747,21 @@ static void cik_sdma_vm_write_pte(struct amdgpu_ib *ib,
|
|||
*
|
||||
* Update the page tables using sDMA (CIK).
|
||||
*/
|
||||
static void cik_sdma_vm_set_pte_pde(struct amdgpu_ib *ib,
|
||||
uint64_t pe,
|
||||
static void cik_sdma_vm_set_pte_pde(struct amdgpu_ib *ib, uint64_t pe,
|
||||
uint64_t addr, unsigned count,
|
||||
uint32_t incr, uint32_t flags)
|
||||
{
|
||||
uint64_t value;
|
||||
unsigned ndw;
|
||||
|
||||
while (count) {
|
||||
ndw = count;
|
||||
if (ndw > 0x7FFFF)
|
||||
ndw = 0x7FFFF;
|
||||
|
||||
if (flags & AMDGPU_PTE_VALID)
|
||||
value = addr;
|
||||
else
|
||||
value = 0;
|
||||
|
||||
/* for physically contiguous pages (vram) */
|
||||
ib->ptr[ib->length_dw++] = SDMA_PACKET(SDMA_OPCODE_GENERATE_PTE_PDE, 0, 0);
|
||||
ib->ptr[ib->length_dw++] = pe; /* dst addr */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = flags; /* mask */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = value; /* value */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(value);
|
||||
ib->ptr[ib->length_dw++] = incr; /* increment size */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = ndw; /* number of entries */
|
||||
|
||||
pe += ndw * 8;
|
||||
addr += ndw * incr;
|
||||
count -= ndw;
|
||||
}
|
||||
/* for physically contiguous pages (vram) */
|
||||
ib->ptr[ib->length_dw++] = SDMA_PACKET(SDMA_OPCODE_GENERATE_PTE_PDE, 0, 0);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe); /* dst addr */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = flags; /* mask */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(addr); /* value */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(addr);
|
||||
ib->ptr[ib->length_dw++] = incr; /* increment size */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = count; /* number of entries */
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -435,7 +435,11 @@ static int cz_dpm_init(struct amdgpu_device *adev)
|
|||
pi->caps_td_ramping = true;
|
||||
pi->caps_tcp_ramping = true;
|
||||
}
|
||||
pi->caps_sclk_ds = true;
|
||||
if (amdgpu_sclk_deep_sleep_en)
|
||||
pi->caps_sclk_ds = true;
|
||||
else
|
||||
pi->caps_sclk_ds = false;
|
||||
|
||||
pi->voting_clients = 0x00c00033;
|
||||
pi->auto_thermal_throttling_enabled = true;
|
||||
pi->bapm_enabled = false;
|
||||
|
@ -2108,29 +2112,58 @@ static void cz_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate)
|
|||
/* disable clockgating so we can properly shut down the block */
|
||||
ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
|
||||
AMD_CG_STATE_UNGATE);
|
||||
if (ret) {
|
||||
DRM_ERROR("UVD DPM Power Gating failed to set clockgating state\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* shutdown the UVD block */
|
||||
ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
|
||||
AMD_PG_STATE_GATE);
|
||||
/* XXX: check for errors */
|
||||
|
||||
if (ret) {
|
||||
DRM_ERROR("UVD DPM Power Gating failed to set powergating state\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
cz_update_uvd_dpm(adev, gate);
|
||||
if (pi->caps_uvd_pg)
|
||||
if (pi->caps_uvd_pg) {
|
||||
/* power off the UVD block */
|
||||
cz_send_msg_to_smc(adev, PPSMC_MSG_UVDPowerOFF);
|
||||
ret = cz_send_msg_to_smc(adev, PPSMC_MSG_UVDPowerOFF);
|
||||
if (ret) {
|
||||
DRM_ERROR("UVD DPM Power Gating failed to send SMU PowerOFF message\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pi->caps_uvd_pg) {
|
||||
/* power on the UVD block */
|
||||
if (pi->uvd_dynamic_pg)
|
||||
cz_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_UVDPowerON, 1);
|
||||
ret = cz_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_UVDPowerON, 1);
|
||||
else
|
||||
cz_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_UVDPowerON, 0);
|
||||
ret = cz_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_UVDPowerON, 0);
|
||||
|
||||
if (ret) {
|
||||
DRM_ERROR("UVD DPM Power Gating Failed to send SMU PowerON message\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* re-init the UVD block */
|
||||
ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
|
||||
AMD_PG_STATE_UNGATE);
|
||||
|
||||
if (ret) {
|
||||
DRM_ERROR("UVD DPM Power Gating Failed to set powergating state\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* enable clockgating. hw will dynamically gate/ungate clocks on the fly */
|
||||
ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
|
||||
AMD_CG_STATE_GATE);
|
||||
/* XXX: check for errors */
|
||||
if (ret) {
|
||||
DRM_ERROR("UVD DPM Power Gating Failed to set clockgating state\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
cz_update_uvd_dpm(adev, gate);
|
||||
}
|
||||
|
|
|
@ -646,8 +646,8 @@ static void dce_v10_0_resume_mc_access(struct amdgpu_device *adev,
|
|||
|
||||
if (save->crtc_enabled[i]) {
|
||||
tmp = RREG32(mmMASTER_UPDATE_MODE + crtc_offsets[i]);
|
||||
if (REG_GET_FIELD(tmp, MASTER_UPDATE_MODE, MASTER_UPDATE_MODE) != 3) {
|
||||
tmp = REG_SET_FIELD(tmp, MASTER_UPDATE_MODE, MASTER_UPDATE_MODE, 3);
|
||||
if (REG_GET_FIELD(tmp, MASTER_UPDATE_MODE, MASTER_UPDATE_MODE) != 0) {
|
||||
tmp = REG_SET_FIELD(tmp, MASTER_UPDATE_MODE, MASTER_UPDATE_MODE, 0);
|
||||
WREG32(mmMASTER_UPDATE_MODE + crtc_offsets[i], tmp);
|
||||
}
|
||||
tmp = RREG32(mmGRPH_UPDATE + crtc_offsets[i]);
|
||||
|
@ -712,6 +712,45 @@ static void dce_v10_0_set_vga_render_state(struct amdgpu_device *adev,
|
|||
WREG32(mmVGA_RENDER_CONTROL, tmp);
|
||||
}
|
||||
|
||||
static int dce_v10_0_get_num_crtc(struct amdgpu_device *adev)
|
||||
{
|
||||
int num_crtc = 0;
|
||||
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_FIJI:
|
||||
case CHIP_TONGA:
|
||||
num_crtc = 6;
|
||||
break;
|
||||
default:
|
||||
num_crtc = 0;
|
||||
}
|
||||
return num_crtc;
|
||||
}
|
||||
|
||||
void dce_v10_0_disable_dce(struct amdgpu_device *adev)
|
||||
{
|
||||
/*Disable VGA render and enabled crtc, if has DCE engine*/
|
||||
if (amdgpu_atombios_has_dce_engine_info(adev)) {
|
||||
u32 tmp;
|
||||
int crtc_enabled, i;
|
||||
|
||||
dce_v10_0_set_vga_render_state(adev, false);
|
||||
|
||||
/*Disable crtc*/
|
||||
for (i = 0; i < dce_v10_0_get_num_crtc(adev); i++) {
|
||||
crtc_enabled = REG_GET_FIELD(RREG32(mmCRTC_CONTROL + crtc_offsets[i]),
|
||||
CRTC_CONTROL, CRTC_MASTER_EN);
|
||||
if (crtc_enabled) {
|
||||
WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1);
|
||||
tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]);
|
||||
tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 0);
|
||||
WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp);
|
||||
WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void dce_v10_0_program_fmt(struct drm_encoder *encoder)
|
||||
{
|
||||
struct drm_device *dev = encoder->dev;
|
||||
|
@ -2277,8 +2316,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
|
|||
WREG32(mmVIEWPORT_SIZE + amdgpu_crtc->crtc_offset,
|
||||
(viewport_w << 16) | viewport_h);
|
||||
|
||||
/* set pageflip to happen only at start of vblank interval (front porch) */
|
||||
WREG32(mmMASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 3);
|
||||
/* set pageflip to happen anywhere in vblank interval */
|
||||
WREG32(mmMASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 0);
|
||||
|
||||
if (!atomic && fb && fb != crtc->primary->fb) {
|
||||
amdgpu_fb = to_amdgpu_framebuffer(fb);
|
||||
|
@ -2700,7 +2739,7 @@ static const struct drm_crtc_funcs dce_v10_0_crtc_funcs = {
|
|||
.gamma_set = dce_v10_0_crtc_gamma_set,
|
||||
.set_config = amdgpu_crtc_set_config,
|
||||
.destroy = dce_v10_0_crtc_destroy,
|
||||
.page_flip = amdgpu_crtc_page_flip,
|
||||
.page_flip_target = amdgpu_crtc_page_flip_target,
|
||||
};
|
||||
|
||||
static void dce_v10_0_crtc_dpms(struct drm_crtc *crtc, int mode)
|
||||
|
@ -2964,10 +3003,11 @@ static int dce_v10_0_early_init(void *handle)
|
|||
dce_v10_0_set_display_funcs(adev);
|
||||
dce_v10_0_set_irq_funcs(adev);
|
||||
|
||||
adev->mode_info.num_crtc = dce_v10_0_get_num_crtc(adev);
|
||||
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_FIJI:
|
||||
case CHIP_TONGA:
|
||||
adev->mode_info.num_crtc = 6; /* XXX 7??? */
|
||||
adev->mode_info.num_hpd = 6;
|
||||
adev->mode_info.num_dig = 7;
|
||||
break;
|
||||
|
@ -3143,11 +3183,26 @@ static int dce_v10_0_wait_for_idle(void *handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int dce_v10_0_check_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
if (dce_v10_0_is_display_hung(adev))
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_DCE].hang = true;
|
||||
else
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_DCE].hang = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_v10_0_soft_reset(void *handle)
|
||||
{
|
||||
u32 srbm_soft_reset = 0, tmp;
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_DCE].hang)
|
||||
return 0;
|
||||
|
||||
if (dce_v10_0_is_display_hung(adev))
|
||||
srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_DC_MASK;
|
||||
|
||||
|
@ -3514,6 +3569,7 @@ const struct amd_ip_funcs dce_v10_0_ip_funcs = {
|
|||
.resume = dce_v10_0_resume,
|
||||
.is_idle = dce_v10_0_is_idle,
|
||||
.wait_for_idle = dce_v10_0_wait_for_idle,
|
||||
.check_soft_reset = dce_v10_0_check_soft_reset,
|
||||
.soft_reset = dce_v10_0_soft_reset,
|
||||
.set_clockgating_state = dce_v10_0_set_clockgating_state,
|
||||
.set_powergating_state = dce_v10_0_set_powergating_state,
|
||||
|
|
|
@ -26,4 +26,6 @@
|
|||
|
||||
extern const struct amd_ip_funcs dce_v10_0_ip_funcs;
|
||||
|
||||
void dce_v10_0_disable_dce(struct amdgpu_device *adev);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -673,6 +673,53 @@ static void dce_v11_0_set_vga_render_state(struct amdgpu_device *adev,
|
|||
WREG32(mmVGA_RENDER_CONTROL, tmp);
|
||||
}
|
||||
|
||||
static int dce_v11_0_get_num_crtc (struct amdgpu_device *adev)
|
||||
{
|
||||
int num_crtc = 0;
|
||||
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_CARRIZO:
|
||||
num_crtc = 3;
|
||||
break;
|
||||
case CHIP_STONEY:
|
||||
num_crtc = 2;
|
||||
break;
|
||||
case CHIP_POLARIS10:
|
||||
num_crtc = 6;
|
||||
break;
|
||||
case CHIP_POLARIS11:
|
||||
num_crtc = 5;
|
||||
break;
|
||||
default:
|
||||
num_crtc = 0;
|
||||
}
|
||||
return num_crtc;
|
||||
}
|
||||
|
||||
void dce_v11_0_disable_dce(struct amdgpu_device *adev)
|
||||
{
|
||||
/*Disable VGA render and enabled crtc, if has DCE engine*/
|
||||
if (amdgpu_atombios_has_dce_engine_info(adev)) {
|
||||
u32 tmp;
|
||||
int crtc_enabled, i;
|
||||
|
||||
dce_v11_0_set_vga_render_state(adev, false);
|
||||
|
||||
/*Disable crtc*/
|
||||
for (i = 0; i < dce_v11_0_get_num_crtc(adev); i++) {
|
||||
crtc_enabled = REG_GET_FIELD(RREG32(mmCRTC_CONTROL + crtc_offsets[i]),
|
||||
CRTC_CONTROL, CRTC_MASTER_EN);
|
||||
if (crtc_enabled) {
|
||||
WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1);
|
||||
tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]);
|
||||
tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 0);
|
||||
WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp);
|
||||
WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void dce_v11_0_program_fmt(struct drm_encoder *encoder)
|
||||
{
|
||||
struct drm_device *dev = encoder->dev;
|
||||
|
@ -2252,8 +2299,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
|
|||
WREG32(mmVIEWPORT_SIZE + amdgpu_crtc->crtc_offset,
|
||||
(viewport_w << 16) | viewport_h);
|
||||
|
||||
/* set pageflip to happen only at start of vblank interval (front porch) */
|
||||
WREG32(mmCRTC_MASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 3);
|
||||
/* set pageflip to happen anywhere in vblank interval */
|
||||
WREG32(mmCRTC_MASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 0);
|
||||
|
||||
if (!atomic && fb && fb != crtc->primary->fb) {
|
||||
amdgpu_fb = to_amdgpu_framebuffer(fb);
|
||||
|
@ -2710,7 +2757,7 @@ static const struct drm_crtc_funcs dce_v11_0_crtc_funcs = {
|
|||
.gamma_set = dce_v11_0_crtc_gamma_set,
|
||||
.set_config = amdgpu_crtc_set_config,
|
||||
.destroy = dce_v11_0_crtc_destroy,
|
||||
.page_flip = amdgpu_crtc_page_flip,
|
||||
.page_flip_target = amdgpu_crtc_page_flip_target,
|
||||
};
|
||||
|
||||
static void dce_v11_0_crtc_dpms(struct drm_crtc *crtc, int mode)
|
||||
|
@ -3001,24 +3048,22 @@ static int dce_v11_0_early_init(void *handle)
|
|||
dce_v11_0_set_display_funcs(adev);
|
||||
dce_v11_0_set_irq_funcs(adev);
|
||||
|
||||
adev->mode_info.num_crtc = dce_v11_0_get_num_crtc(adev);
|
||||
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_CARRIZO:
|
||||
adev->mode_info.num_crtc = 3;
|
||||
adev->mode_info.num_hpd = 6;
|
||||
adev->mode_info.num_dig = 9;
|
||||
break;
|
||||
case CHIP_STONEY:
|
||||
adev->mode_info.num_crtc = 2;
|
||||
adev->mode_info.num_hpd = 6;
|
||||
adev->mode_info.num_dig = 9;
|
||||
break;
|
||||
case CHIP_POLARIS10:
|
||||
adev->mode_info.num_crtc = 6;
|
||||
adev->mode_info.num_hpd = 6;
|
||||
adev->mode_info.num_dig = 6;
|
||||
break;
|
||||
case CHIP_POLARIS11:
|
||||
adev->mode_info.num_crtc = 5;
|
||||
adev->mode_info.num_hpd = 5;
|
||||
adev->mode_info.num_dig = 5;
|
||||
break;
|
||||
|
|
|
@ -26,4 +26,6 @@
|
|||
|
||||
extern const struct amd_ip_funcs dce_v11_0_ip_funcs;
|
||||
|
||||
void dce_v11_0_disable_dce(struct amdgpu_device *adev);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -604,6 +604,52 @@ static void dce_v8_0_set_vga_render_state(struct amdgpu_device *adev,
|
|||
WREG32(mmVGA_RENDER_CONTROL, tmp);
|
||||
}
|
||||
|
||||
static int dce_v8_0_get_num_crtc(struct amdgpu_device *adev)
|
||||
{
|
||||
int num_crtc = 0;
|
||||
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_BONAIRE:
|
||||
case CHIP_HAWAII:
|
||||
num_crtc = 6;
|
||||
break;
|
||||
case CHIP_KAVERI:
|
||||
num_crtc = 4;
|
||||
break;
|
||||
case CHIP_KABINI:
|
||||
case CHIP_MULLINS:
|
||||
num_crtc = 2;
|
||||
break;
|
||||
default:
|
||||
num_crtc = 0;
|
||||
}
|
||||
return num_crtc;
|
||||
}
|
||||
|
||||
void dce_v8_0_disable_dce(struct amdgpu_device *adev)
|
||||
{
|
||||
/*Disable VGA render and enabled crtc, if has DCE engine*/
|
||||
if (amdgpu_atombios_has_dce_engine_info(adev)) {
|
||||
u32 tmp;
|
||||
int crtc_enabled, i;
|
||||
|
||||
dce_v8_0_set_vga_render_state(adev, false);
|
||||
|
||||
/*Disable crtc*/
|
||||
for (i = 0; i < dce_v8_0_get_num_crtc(adev); i++) {
|
||||
crtc_enabled = REG_GET_FIELD(RREG32(mmCRTC_CONTROL + crtc_offsets[i]),
|
||||
CRTC_CONTROL, CRTC_MASTER_EN);
|
||||
if (crtc_enabled) {
|
||||
WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1);
|
||||
tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]);
|
||||
tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 0);
|
||||
WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp);
|
||||
WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void dce_v8_0_program_fmt(struct drm_encoder *encoder)
|
||||
{
|
||||
struct drm_device *dev = encoder->dev;
|
||||
|
@ -1501,13 +1547,13 @@ static void dce_v8_0_audio_write_sad_regs(struct drm_encoder *encoder)
|
|||
|
||||
if (sad->format == eld_reg_to_type[i][1]) {
|
||||
if (sad->channels > max_channels) {
|
||||
value = (sad->channels <<
|
||||
AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0__MAX_CHANNELS__SHIFT) |
|
||||
(sad->byte2 <<
|
||||
AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0__DESCRIPTOR_BYTE_2__SHIFT) |
|
||||
(sad->freq <<
|
||||
AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0__SUPPORTED_FREQUENCIES__SHIFT);
|
||||
max_channels = sad->channels;
|
||||
value = (sad->channels <<
|
||||
AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0__MAX_CHANNELS__SHIFT) |
|
||||
(sad->byte2 <<
|
||||
AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0__DESCRIPTOR_BYTE_2__SHIFT) |
|
||||
(sad->freq <<
|
||||
AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0__SUPPORTED_FREQUENCIES__SHIFT);
|
||||
max_channels = sad->channels;
|
||||
}
|
||||
|
||||
if (sad->format == HDMI_AUDIO_CODING_TYPE_PCM)
|
||||
|
@ -1613,7 +1659,7 @@ static void dce_v8_0_afmt_update_ACR(struct drm_encoder *encoder, uint32_t clock
|
|||
struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
|
||||
uint32_t offset = dig->afmt->offset;
|
||||
|
||||
WREG32(mmHDMI_ACR_32_0 + offset, (acr.cts_32khz << HDMI_ACR_44_0__HDMI_ACR_CTS_44__SHIFT));
|
||||
WREG32(mmHDMI_ACR_32_0 + offset, (acr.cts_32khz << HDMI_ACR_32_0__HDMI_ACR_CTS_32__SHIFT));
|
||||
WREG32(mmHDMI_ACR_32_1 + offset, acr.n_32khz);
|
||||
|
||||
WREG32(mmHDMI_ACR_44_0 + offset, (acr.cts_44_1khz << HDMI_ACR_44_0__HDMI_ACR_CTS_44__SHIFT));
|
||||
|
@ -1693,6 +1739,7 @@ static void dce_v8_0_afmt_setmode(struct drm_encoder *encoder,
|
|||
/* Silent, r600_hdmi_enable will raise WARN for us */
|
||||
if (!dig->afmt->enabled)
|
||||
return;
|
||||
|
||||
offset = dig->afmt->offset;
|
||||
|
||||
/* hdmi deep color mode general control packets setup, if bpc > 8 */
|
||||
|
@ -1817,7 +1864,7 @@ static void dce_v8_0_afmt_setmode(struct drm_encoder *encoder,
|
|||
|
||||
WREG32_OR(mmHDMI_INFOFRAME_CONTROL0 + offset,
|
||||
HDMI_INFOFRAME_CONTROL0__HDMI_AVI_INFO_SEND_MASK | /* enable AVI info frames */
|
||||
HDMI_INFOFRAME_CONTROL0__HDMI_AVI_INFO_SEND_MASK); /* required for audio info values to be updated */
|
||||
HDMI_INFOFRAME_CONTROL0__HDMI_AVI_INFO_CONT_MASK); /* required for audio info values to be updated */
|
||||
|
||||
WREG32_P(mmHDMI_INFOFRAME_CONTROL1 + offset,
|
||||
(2 << HDMI_INFOFRAME_CONTROL1__HDMI_AVI_INFO_LINE__SHIFT), /* anything other than 0 */
|
||||
|
@ -1826,13 +1873,12 @@ static void dce_v8_0_afmt_setmode(struct drm_encoder *encoder,
|
|||
WREG32_OR(mmAFMT_AUDIO_PACKET_CONTROL + offset,
|
||||
AFMT_AUDIO_PACKET_CONTROL__AFMT_AUDIO_SAMPLE_SEND_MASK); /* send audio packets */
|
||||
|
||||
/* it's unknown what these bits do excatly, but it's indeed quite useful for debugging */
|
||||
WREG32(mmAFMT_RAMP_CONTROL0 + offset, 0x00FFFFFF);
|
||||
WREG32(mmAFMT_RAMP_CONTROL1 + offset, 0x007FFFFF);
|
||||
WREG32(mmAFMT_RAMP_CONTROL2 + offset, 0x00000001);
|
||||
WREG32(mmAFMT_RAMP_CONTROL3 + offset, 0x00000001);
|
||||
|
||||
/* enable audio after to setting up hw */
|
||||
/* enable audio after setting up hw */
|
||||
dce_v8_0_audio_enable(adev, dig->afmt->pin, true);
|
||||
}
|
||||
|
||||
|
@ -2000,7 +2046,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
|
|||
case DRM_FORMAT_XRGB4444:
|
||||
case DRM_FORMAT_ARGB4444:
|
||||
fb_format = ((GRPH_DEPTH_16BPP << GRPH_CONTROL__GRPH_DEPTH__SHIFT) |
|
||||
(GRPH_FORMAT_ARGB1555 << GRPH_CONTROL__GRPH_FORMAT__SHIFT));
|
||||
(GRPH_FORMAT_ARGB4444 << GRPH_CONTROL__GRPH_FORMAT__SHIFT));
|
||||
#ifdef __BIG_ENDIAN
|
||||
fb_swap = (GRPH_ENDIAN_8IN16 << GRPH_SWAP_CNTL__GRPH_ENDIAN_SWAP__SHIFT);
|
||||
#endif
|
||||
|
@ -2139,8 +2185,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
|
|||
WREG32(mmVIEWPORT_SIZE + amdgpu_crtc->crtc_offset,
|
||||
(viewport_w << 16) | viewport_h);
|
||||
|
||||
/* set pageflip to happen only at start of vblank interval (front porch) */
|
||||
WREG32(mmMASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 3);
|
||||
/* set pageflip to happen anywhere in vblank interval */
|
||||
WREG32(mmMASTER_UPDATE_MODE + amdgpu_crtc->crtc_offset, 0);
|
||||
|
||||
if (!atomic && fb && fb != crtc->primary->fb) {
|
||||
amdgpu_fb = to_amdgpu_framebuffer(fb);
|
||||
|
@ -2554,7 +2600,7 @@ static const struct drm_crtc_funcs dce_v8_0_crtc_funcs = {
|
|||
.gamma_set = dce_v8_0_crtc_gamma_set,
|
||||
.set_config = amdgpu_crtc_set_config,
|
||||
.destroy = dce_v8_0_crtc_destroy,
|
||||
.page_flip = amdgpu_crtc_page_flip,
|
||||
.page_flip_target = amdgpu_crtc_page_flip_target,
|
||||
};
|
||||
|
||||
static void dce_v8_0_crtc_dpms(struct drm_crtc *crtc, int mode)
|
||||
|
@ -2655,7 +2701,7 @@ static void dce_v8_0_crtc_disable(struct drm_crtc *crtc)
|
|||
case ATOM_PPLL2:
|
||||
/* disable the ppll */
|
||||
amdgpu_atombios_crtc_program_pll(crtc, amdgpu_crtc->crtc_id, amdgpu_crtc->pll_id,
|
||||
0, 0, ATOM_DISABLE, 0, 0, 0, 0, 0, false, &ss);
|
||||
0, 0, ATOM_DISABLE, 0, 0, 0, 0, 0, false, &ss);
|
||||
break;
|
||||
case ATOM_PPLL0:
|
||||
/* disable the ppll */
|
||||
|
@ -2805,21 +2851,20 @@ static int dce_v8_0_early_init(void *handle)
|
|||
dce_v8_0_set_display_funcs(adev);
|
||||
dce_v8_0_set_irq_funcs(adev);
|
||||
|
||||
adev->mode_info.num_crtc = dce_v8_0_get_num_crtc(adev);
|
||||
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_BONAIRE:
|
||||
case CHIP_HAWAII:
|
||||
adev->mode_info.num_crtc = 6;
|
||||
adev->mode_info.num_hpd = 6;
|
||||
adev->mode_info.num_dig = 6;
|
||||
break;
|
||||
case CHIP_KAVERI:
|
||||
adev->mode_info.num_crtc = 4;
|
||||
adev->mode_info.num_hpd = 6;
|
||||
adev->mode_info.num_dig = 7;
|
||||
break;
|
||||
case CHIP_KABINI:
|
||||
case CHIP_MULLINS:
|
||||
adev->mode_info.num_crtc = 2;
|
||||
adev->mode_info.num_hpd = 6;
|
||||
adev->mode_info.num_dig = 6; /* ? */
|
||||
break;
|
||||
|
@ -3238,7 +3283,6 @@ static int dce_v8_0_crtc_irq(struct amdgpu_device *adev,
|
|||
drm_handle_vblank(adev->ddev, crtc);
|
||||
}
|
||||
DRM_DEBUG("IH: D%d vblank\n", crtc + 1);
|
||||
|
||||
break;
|
||||
case 1: /* vline */
|
||||
if (disp_int & interrupt_status_offsets[crtc].vline)
|
||||
|
@ -3247,7 +3291,6 @@ static int dce_v8_0_crtc_irq(struct amdgpu_device *adev,
|
|||
DRM_DEBUG("IH: IH event w/o asserted irq bit?\n");
|
||||
|
||||
DRM_DEBUG("IH: D%d vline\n", crtc + 1);
|
||||
|
||||
break;
|
||||
default:
|
||||
DRM_DEBUG("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data);
|
||||
|
|
|
@ -26,4 +26,6 @@
|
|||
|
||||
extern const struct amd_ip_funcs dce_v8_0_ip_funcs;
|
||||
|
||||
void dce_v8_0_disable_dce(struct amdgpu_device *adev);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,806 @@
|
|||
/*
|
||||
* Copyright 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#include "drmP.h"
|
||||
#include "amdgpu.h"
|
||||
#include "amdgpu_pm.h"
|
||||
#include "amdgpu_i2c.h"
|
||||
#include "atom.h"
|
||||
#include "amdgpu_pll.h"
|
||||
#include "amdgpu_connectors.h"
|
||||
#ifdef CONFIG_DRM_AMDGPU_CIK
|
||||
#include "dce_v8_0.h"
|
||||
#endif
|
||||
#include "dce_v10_0.h"
|
||||
#include "dce_v11_0.h"
|
||||
#include "dce_virtual.h"
|
||||
|
||||
static void dce_virtual_set_display_funcs(struct amdgpu_device *adev);
|
||||
static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev);
|
||||
static int dce_virtual_pageflip_irq(struct amdgpu_device *adev,
|
||||
struct amdgpu_irq_src *source,
|
||||
struct amdgpu_iv_entry *entry);
|
||||
|
||||
/**
|
||||
* dce_virtual_vblank_wait - vblank wait asic callback.
|
||||
*
|
||||
* @adev: amdgpu_device pointer
|
||||
* @crtc: crtc to wait for vblank on
|
||||
*
|
||||
* Wait for vblank on the requested crtc (evergreen+).
|
||||
*/
|
||||
static void dce_virtual_vblank_wait(struct amdgpu_device *adev, int crtc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static u32 dce_virtual_vblank_get_counter(struct amdgpu_device *adev, int crtc)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dce_virtual_page_flip(struct amdgpu_device *adev,
|
||||
int crtc_id, u64 crtc_base, bool async)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int dce_virtual_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc,
|
||||
u32 *vbl, u32 *position)
|
||||
{
|
||||
*vbl = 0;
|
||||
*position = 0;
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static bool dce_virtual_hpd_sense(struct amdgpu_device *adev,
|
||||
enum amdgpu_hpd_id hpd)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static void dce_virtual_hpd_set_polarity(struct amdgpu_device *adev,
|
||||
enum amdgpu_hpd_id hpd)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static u32 dce_virtual_hpd_get_gpio_reg(struct amdgpu_device *adev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool dce_virtual_is_display_hung(struct amdgpu_device *adev)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void dce_virtual_stop_mc_access(struct amdgpu_device *adev,
|
||||
struct amdgpu_mode_mc_save *save)
|
||||
{
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_BONAIRE:
|
||||
case CHIP_HAWAII:
|
||||
case CHIP_KAVERI:
|
||||
case CHIP_KABINI:
|
||||
case CHIP_MULLINS:
|
||||
#ifdef CONFIG_DRM_AMDGPU_CIK
|
||||
dce_v8_0_disable_dce(adev);
|
||||
#endif
|
||||
break;
|
||||
case CHIP_FIJI:
|
||||
case CHIP_TONGA:
|
||||
dce_v10_0_disable_dce(adev);
|
||||
break;
|
||||
case CHIP_CARRIZO:
|
||||
case CHIP_STONEY:
|
||||
case CHIP_POLARIS11:
|
||||
case CHIP_POLARIS10:
|
||||
dce_v11_0_disable_dce(adev);
|
||||
break;
|
||||
case CHIP_TOPAZ:
|
||||
/* no DCE */
|
||||
return;
|
||||
default:
|
||||
DRM_ERROR("Virtual display unsupported ASIC type: 0x%X\n", adev->asic_type);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
void dce_virtual_resume_mc_access(struct amdgpu_device *adev,
|
||||
struct amdgpu_mode_mc_save *save)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void dce_virtual_set_vga_render_state(struct amdgpu_device *adev,
|
||||
bool render)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* dce_virtual_bandwidth_update - program display watermarks
|
||||
*
|
||||
* @adev: amdgpu_device pointer
|
||||
*
|
||||
* Calculate and program the display watermarks and line
|
||||
* buffer allocation (CIK).
|
||||
*/
|
||||
static void dce_virtual_bandwidth_update(struct amdgpu_device *adev)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int dce_virtual_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
|
||||
u16 *green, u16 *blue, uint32_t size)
|
||||
{
|
||||
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
|
||||
int i;
|
||||
|
||||
/* userspace palettes are always correct as is */
|
||||
for (i = 0; i < size; i++) {
|
||||
amdgpu_crtc->lut_r[i] = red[i] >> 6;
|
||||
amdgpu_crtc->lut_g[i] = green[i] >> 6;
|
||||
amdgpu_crtc->lut_b[i] = blue[i] >> 6;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dce_virtual_crtc_destroy(struct drm_crtc *crtc)
|
||||
{
|
||||
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
|
||||
|
||||
drm_crtc_cleanup(crtc);
|
||||
kfree(amdgpu_crtc);
|
||||
}
|
||||
|
||||
static const struct drm_crtc_funcs dce_virtual_crtc_funcs = {
|
||||
.cursor_set2 = NULL,
|
||||
.cursor_move = NULL,
|
||||
.gamma_set = dce_virtual_crtc_gamma_set,
|
||||
.set_config = amdgpu_crtc_set_config,
|
||||
.destroy = dce_virtual_crtc_destroy,
|
||||
.page_flip_target = amdgpu_crtc_page_flip_target,
|
||||
};
|
||||
|
||||
static void dce_virtual_crtc_dpms(struct drm_crtc *crtc, int mode)
|
||||
{
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct amdgpu_device *adev = dev->dev_private;
|
||||
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
|
||||
unsigned type;
|
||||
|
||||
switch (mode) {
|
||||
case DRM_MODE_DPMS_ON:
|
||||
amdgpu_crtc->enabled = true;
|
||||
/* Make sure VBLANK and PFLIP interrupts are still enabled */
|
||||
type = amdgpu_crtc_idx_to_irq_type(adev, amdgpu_crtc->crtc_id);
|
||||
amdgpu_irq_update(adev, &adev->crtc_irq, type);
|
||||
amdgpu_irq_update(adev, &adev->pageflip_irq, type);
|
||||
drm_vblank_on(dev, amdgpu_crtc->crtc_id);
|
||||
break;
|
||||
case DRM_MODE_DPMS_STANDBY:
|
||||
case DRM_MODE_DPMS_SUSPEND:
|
||||
case DRM_MODE_DPMS_OFF:
|
||||
drm_vblank_off(dev, amdgpu_crtc->crtc_id);
|
||||
amdgpu_crtc->enabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void dce_virtual_crtc_prepare(struct drm_crtc *crtc)
|
||||
{
|
||||
dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
|
||||
}
|
||||
|
||||
static void dce_virtual_crtc_commit(struct drm_crtc *crtc)
|
||||
{
|
||||
dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
|
||||
}
|
||||
|
||||
static void dce_virtual_crtc_disable(struct drm_crtc *crtc)
|
||||
{
|
||||
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
|
||||
|
||||
dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
|
||||
if (crtc->primary->fb) {
|
||||
int r;
|
||||
struct amdgpu_framebuffer *amdgpu_fb;
|
||||
struct amdgpu_bo *rbo;
|
||||
|
||||
amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
|
||||
rbo = gem_to_amdgpu_bo(amdgpu_fb->obj);
|
||||
r = amdgpu_bo_reserve(rbo, false);
|
||||
if (unlikely(r))
|
||||
DRM_ERROR("failed to reserve rbo before unpin\n");
|
||||
else {
|
||||
amdgpu_bo_unpin(rbo);
|
||||
amdgpu_bo_unreserve(rbo);
|
||||
}
|
||||
}
|
||||
|
||||
amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
|
||||
amdgpu_crtc->encoder = NULL;
|
||||
amdgpu_crtc->connector = NULL;
|
||||
}
|
||||
|
||||
static int dce_virtual_crtc_mode_set(struct drm_crtc *crtc,
|
||||
struct drm_display_mode *mode,
|
||||
struct drm_display_mode *adjusted_mode,
|
||||
int x, int y, struct drm_framebuffer *old_fb)
|
||||
{
|
||||
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
|
||||
|
||||
/* update the hw version fpr dpm */
|
||||
amdgpu_crtc->hw_mode = *adjusted_mode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool dce_virtual_crtc_mode_fixup(struct drm_crtc *crtc,
|
||||
const struct drm_display_mode *mode,
|
||||
struct drm_display_mode *adjusted_mode)
|
||||
{
|
||||
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct drm_encoder *encoder;
|
||||
|
||||
/* assign the encoder to the amdgpu crtc to avoid repeated lookups later */
|
||||
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
|
||||
if (encoder->crtc == crtc) {
|
||||
amdgpu_crtc->encoder = encoder;
|
||||
amdgpu_crtc->connector = amdgpu_get_connector_for_encoder(encoder);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((amdgpu_crtc->encoder == NULL) || (amdgpu_crtc->connector == NULL)) {
|
||||
amdgpu_crtc->encoder = NULL;
|
||||
amdgpu_crtc->connector = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int dce_virtual_crtc_set_base(struct drm_crtc *crtc, int x, int y,
|
||||
struct drm_framebuffer *old_fb)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dce_virtual_crtc_load_lut(struct drm_crtc *crtc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int dce_virtual_crtc_set_base_atomic(struct drm_crtc *crtc,
|
||||
struct drm_framebuffer *fb,
|
||||
int x, int y, enum mode_set_atomic state)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct drm_crtc_helper_funcs dce_virtual_crtc_helper_funcs = {
|
||||
.dpms = dce_virtual_crtc_dpms,
|
||||
.mode_fixup = dce_virtual_crtc_mode_fixup,
|
||||
.mode_set = dce_virtual_crtc_mode_set,
|
||||
.mode_set_base = dce_virtual_crtc_set_base,
|
||||
.mode_set_base_atomic = dce_virtual_crtc_set_base_atomic,
|
||||
.prepare = dce_virtual_crtc_prepare,
|
||||
.commit = dce_virtual_crtc_commit,
|
||||
.load_lut = dce_virtual_crtc_load_lut,
|
||||
.disable = dce_virtual_crtc_disable,
|
||||
};
|
||||
|
||||
static int dce_virtual_crtc_init(struct amdgpu_device *adev, int index)
|
||||
{
|
||||
struct amdgpu_crtc *amdgpu_crtc;
|
||||
int i;
|
||||
|
||||
amdgpu_crtc = kzalloc(sizeof(struct amdgpu_crtc) +
|
||||
(AMDGPUFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL);
|
||||
if (amdgpu_crtc == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
drm_crtc_init(adev->ddev, &amdgpu_crtc->base, &dce_virtual_crtc_funcs);
|
||||
|
||||
drm_mode_crtc_set_gamma_size(&amdgpu_crtc->base, 256);
|
||||
amdgpu_crtc->crtc_id = index;
|
||||
adev->mode_info.crtcs[index] = amdgpu_crtc;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
amdgpu_crtc->lut_r[i] = i << 2;
|
||||
amdgpu_crtc->lut_g[i] = i << 2;
|
||||
amdgpu_crtc->lut_b[i] = i << 2;
|
||||
}
|
||||
|
||||
amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
|
||||
amdgpu_crtc->encoder = NULL;
|
||||
amdgpu_crtc->connector = NULL;
|
||||
drm_crtc_helper_add(&amdgpu_crtc->base, &dce_virtual_crtc_helper_funcs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_virtual_early_init(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
adev->mode_info.vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
|
||||
dce_virtual_set_display_funcs(adev);
|
||||
dce_virtual_set_irq_funcs(adev);
|
||||
|
||||
adev->mode_info.num_crtc = 1;
|
||||
adev->mode_info.num_hpd = 1;
|
||||
adev->mode_info.num_dig = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool dce_virtual_get_connector_info(struct amdgpu_device *adev)
|
||||
{
|
||||
struct amdgpu_i2c_bus_rec ddc_bus;
|
||||
struct amdgpu_router router;
|
||||
struct amdgpu_hpd hpd;
|
||||
|
||||
/* look up gpio for ddc, hpd */
|
||||
ddc_bus.valid = false;
|
||||
hpd.hpd = AMDGPU_HPD_NONE;
|
||||
/* needed for aux chan transactions */
|
||||
ddc_bus.hpd = hpd.hpd;
|
||||
|
||||
memset(&router, 0, sizeof(router));
|
||||
router.ddc_valid = false;
|
||||
router.cd_valid = false;
|
||||
amdgpu_display_add_connector(adev,
|
||||
0,
|
||||
ATOM_DEVICE_CRT1_SUPPORT,
|
||||
DRM_MODE_CONNECTOR_VIRTUAL, &ddc_bus,
|
||||
CONNECTOR_OBJECT_ID_VIRTUAL,
|
||||
&hpd,
|
||||
&router);
|
||||
|
||||
amdgpu_display_add_encoder(adev, ENCODER_VIRTUAL_ENUM_VIRTUAL,
|
||||
ATOM_DEVICE_CRT1_SUPPORT,
|
||||
0);
|
||||
|
||||
amdgpu_link_encoder_connector(adev->ddev);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int dce_virtual_sw_init(void *handle)
|
||||
{
|
||||
int r, i;
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
r = amdgpu_irq_add_id(adev, 229, &adev->crtc_irq);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
adev->ddev->max_vblank_count = 0;
|
||||
|
||||
adev->ddev->mode_config.funcs = &amdgpu_mode_funcs;
|
||||
|
||||
adev->ddev->mode_config.max_width = 16384;
|
||||
adev->ddev->mode_config.max_height = 16384;
|
||||
|
||||
adev->ddev->mode_config.preferred_depth = 24;
|
||||
adev->ddev->mode_config.prefer_shadow = 1;
|
||||
|
||||
adev->ddev->mode_config.fb_base = adev->mc.aper_base;
|
||||
|
||||
r = amdgpu_modeset_create_props(adev);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
adev->ddev->mode_config.max_width = 16384;
|
||||
adev->ddev->mode_config.max_height = 16384;
|
||||
|
||||
/* allocate crtcs */
|
||||
for (i = 0; i < adev->mode_info.num_crtc; i++) {
|
||||
r = dce_virtual_crtc_init(adev, i);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
|
||||
dce_virtual_get_connector_info(adev);
|
||||
amdgpu_print_display_setup(adev->ddev);
|
||||
|
||||
drm_kms_helper_poll_init(adev->ddev);
|
||||
|
||||
adev->mode_info.mode_config_initialized = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_virtual_sw_fini(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
kfree(adev->mode_info.bios_hardcoded_edid);
|
||||
|
||||
drm_kms_helper_poll_fini(adev->ddev);
|
||||
|
||||
drm_mode_config_cleanup(adev->ddev);
|
||||
adev->mode_info.mode_config_initialized = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_virtual_hw_init(void *handle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_virtual_hw_fini(void *handle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_virtual_suspend(void *handle)
|
||||
{
|
||||
return dce_virtual_hw_fini(handle);
|
||||
}
|
||||
|
||||
static int dce_virtual_resume(void *handle)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = dce_virtual_hw_init(handle);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool dce_virtual_is_idle(void *handle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static int dce_virtual_wait_for_idle(void *handle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_virtual_soft_reset(void *handle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_virtual_set_clockgating_state(void *handle,
|
||||
enum amd_clockgating_state state)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_virtual_set_powergating_state(void *handle,
|
||||
enum amd_powergating_state state)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct amd_ip_funcs dce_virtual_ip_funcs = {
|
||||
.name = "dce_virtual",
|
||||
.early_init = dce_virtual_early_init,
|
||||
.late_init = NULL,
|
||||
.sw_init = dce_virtual_sw_init,
|
||||
.sw_fini = dce_virtual_sw_fini,
|
||||
.hw_init = dce_virtual_hw_init,
|
||||
.hw_fini = dce_virtual_hw_fini,
|
||||
.suspend = dce_virtual_suspend,
|
||||
.resume = dce_virtual_resume,
|
||||
.is_idle = dce_virtual_is_idle,
|
||||
.wait_for_idle = dce_virtual_wait_for_idle,
|
||||
.soft_reset = dce_virtual_soft_reset,
|
||||
.set_clockgating_state = dce_virtual_set_clockgating_state,
|
||||
.set_powergating_state = dce_virtual_set_powergating_state,
|
||||
};
|
||||
|
||||
/* these are handled by the primary encoders */
|
||||
static void dce_virtual_encoder_prepare(struct drm_encoder *encoder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void dce_virtual_encoder_commit(struct drm_encoder *encoder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
dce_virtual_encoder_mode_set(struct drm_encoder *encoder,
|
||||
struct drm_display_mode *mode,
|
||||
struct drm_display_mode *adjusted_mode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void dce_virtual_encoder_disable(struct drm_encoder *encoder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
dce_virtual_encoder_dpms(struct drm_encoder *encoder, int mode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static bool dce_virtual_encoder_mode_fixup(struct drm_encoder *encoder,
|
||||
const struct drm_display_mode *mode,
|
||||
struct drm_display_mode *adjusted_mode)
|
||||
{
|
||||
|
||||
/* set the active encoder to connector routing */
|
||||
amdgpu_encoder_set_active_device(encoder);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static const struct drm_encoder_helper_funcs dce_virtual_encoder_helper_funcs = {
|
||||
.dpms = dce_virtual_encoder_dpms,
|
||||
.mode_fixup = dce_virtual_encoder_mode_fixup,
|
||||
.prepare = dce_virtual_encoder_prepare,
|
||||
.mode_set = dce_virtual_encoder_mode_set,
|
||||
.commit = dce_virtual_encoder_commit,
|
||||
.disable = dce_virtual_encoder_disable,
|
||||
};
|
||||
|
||||
static void dce_virtual_encoder_destroy(struct drm_encoder *encoder)
|
||||
{
|
||||
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
|
||||
|
||||
kfree(amdgpu_encoder->enc_priv);
|
||||
drm_encoder_cleanup(encoder);
|
||||
kfree(amdgpu_encoder);
|
||||
}
|
||||
|
||||
static const struct drm_encoder_funcs dce_virtual_encoder_funcs = {
|
||||
.destroy = dce_virtual_encoder_destroy,
|
||||
};
|
||||
|
||||
static void dce_virtual_encoder_add(struct amdgpu_device *adev,
|
||||
uint32_t encoder_enum,
|
||||
uint32_t supported_device,
|
||||
u16 caps)
|
||||
{
|
||||
struct drm_device *dev = adev->ddev;
|
||||
struct drm_encoder *encoder;
|
||||
struct amdgpu_encoder *amdgpu_encoder;
|
||||
|
||||
/* see if we already added it */
|
||||
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
|
||||
amdgpu_encoder = to_amdgpu_encoder(encoder);
|
||||
if (amdgpu_encoder->encoder_enum == encoder_enum) {
|
||||
amdgpu_encoder->devices |= supported_device;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* add a new one */
|
||||
amdgpu_encoder = kzalloc(sizeof(struct amdgpu_encoder), GFP_KERNEL);
|
||||
if (!amdgpu_encoder)
|
||||
return;
|
||||
|
||||
encoder = &amdgpu_encoder->base;
|
||||
encoder->possible_crtcs = 0x1;
|
||||
amdgpu_encoder->enc_priv = NULL;
|
||||
amdgpu_encoder->encoder_enum = encoder_enum;
|
||||
amdgpu_encoder->encoder_id = (encoder_enum & OBJECT_ID_MASK) >> OBJECT_ID_SHIFT;
|
||||
amdgpu_encoder->devices = supported_device;
|
||||
amdgpu_encoder->rmx_type = RMX_OFF;
|
||||
amdgpu_encoder->underscan_type = UNDERSCAN_OFF;
|
||||
amdgpu_encoder->is_ext_encoder = false;
|
||||
amdgpu_encoder->caps = caps;
|
||||
|
||||
drm_encoder_init(dev, encoder, &dce_virtual_encoder_funcs,
|
||||
DRM_MODE_ENCODER_VIRTUAL, NULL);
|
||||
drm_encoder_helper_add(encoder, &dce_virtual_encoder_helper_funcs);
|
||||
DRM_INFO("[FM]encoder: %d is VIRTUAL\n", amdgpu_encoder->encoder_id);
|
||||
}
|
||||
|
||||
static const struct amdgpu_display_funcs dce_virtual_display_funcs = {
|
||||
.set_vga_render_state = &dce_virtual_set_vga_render_state,
|
||||
.bandwidth_update = &dce_virtual_bandwidth_update,
|
||||
.vblank_get_counter = &dce_virtual_vblank_get_counter,
|
||||
.vblank_wait = &dce_virtual_vblank_wait,
|
||||
.is_display_hung = &dce_virtual_is_display_hung,
|
||||
.backlight_set_level = NULL,
|
||||
.backlight_get_level = NULL,
|
||||
.hpd_sense = &dce_virtual_hpd_sense,
|
||||
.hpd_set_polarity = &dce_virtual_hpd_set_polarity,
|
||||
.hpd_get_gpio_reg = &dce_virtual_hpd_get_gpio_reg,
|
||||
.page_flip = &dce_virtual_page_flip,
|
||||
.page_flip_get_scanoutpos = &dce_virtual_crtc_get_scanoutpos,
|
||||
.add_encoder = &dce_virtual_encoder_add,
|
||||
.add_connector = &amdgpu_connector_add,
|
||||
.stop_mc_access = &dce_virtual_stop_mc_access,
|
||||
.resume_mc_access = &dce_virtual_resume_mc_access,
|
||||
};
|
||||
|
||||
static void dce_virtual_set_display_funcs(struct amdgpu_device *adev)
|
||||
{
|
||||
if (adev->mode_info.funcs == NULL)
|
||||
adev->mode_info.funcs = &dce_virtual_display_funcs;
|
||||
}
|
||||
|
||||
static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer *vblank_timer)
|
||||
{
|
||||
struct amdgpu_mode_info *mode_info = container_of(vblank_timer, struct amdgpu_mode_info ,vblank_timer);
|
||||
struct amdgpu_device *adev = container_of(mode_info, struct amdgpu_device ,mode_info);
|
||||
unsigned crtc = 0;
|
||||
drm_handle_vblank(adev->ddev, crtc);
|
||||
dce_virtual_pageflip_irq(adev, NULL, NULL);
|
||||
hrtimer_start(vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD), HRTIMER_MODE_REL);
|
||||
return HRTIMER_NORESTART;
|
||||
}
|
||||
|
||||
static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *adev,
|
||||
int crtc,
|
||||
enum amdgpu_interrupt_state state)
|
||||
{
|
||||
if (crtc >= adev->mode_info.num_crtc) {
|
||||
DRM_DEBUG("invalid crtc %d\n", crtc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state && !adev->mode_info.vsync_timer_enabled) {
|
||||
DRM_DEBUG("Enable software vsync timer\n");
|
||||
hrtimer_init(&adev->mode_info.vblank_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
|
||||
hrtimer_set_expires(&adev->mode_info.vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD));
|
||||
adev->mode_info.vblank_timer.function = dce_virtual_vblank_timer_handle;
|
||||
hrtimer_start(&adev->mode_info.vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD), HRTIMER_MODE_REL);
|
||||
} else if (!state && adev->mode_info.vsync_timer_enabled) {
|
||||
DRM_DEBUG("Disable software vsync timer\n");
|
||||
hrtimer_cancel(&adev->mode_info.vblank_timer);
|
||||
}
|
||||
|
||||
adev->mode_info.vsync_timer_enabled = state;
|
||||
DRM_DEBUG("[FM]set crtc %d vblank interrupt state %d\n", crtc, state);
|
||||
}
|
||||
|
||||
|
||||
static int dce_virtual_set_crtc_irq_state(struct amdgpu_device *adev,
|
||||
struct amdgpu_irq_src *source,
|
||||
unsigned type,
|
||||
enum amdgpu_interrupt_state state)
|
||||
{
|
||||
switch (type) {
|
||||
case AMDGPU_CRTC_IRQ_VBLANK1:
|
||||
dce_virtual_set_crtc_vblank_interrupt_state(adev, 0, state);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dce_virtual_crtc_vblank_int_ack(struct amdgpu_device *adev,
|
||||
int crtc)
|
||||
{
|
||||
if (crtc >= adev->mode_info.num_crtc) {
|
||||
DRM_DEBUG("invalid crtc %d\n", crtc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static int dce_virtual_crtc_irq(struct amdgpu_device *adev,
|
||||
struct amdgpu_irq_src *source,
|
||||
struct amdgpu_iv_entry *entry)
|
||||
{
|
||||
unsigned crtc = 0;
|
||||
unsigned irq_type = AMDGPU_CRTC_IRQ_VBLANK1;
|
||||
|
||||
dce_virtual_crtc_vblank_int_ack(adev, crtc);
|
||||
|
||||
if (amdgpu_irq_enabled(adev, source, irq_type)) {
|
||||
drm_handle_vblank(adev->ddev, crtc);
|
||||
}
|
||||
dce_virtual_pageflip_irq(adev, NULL, NULL);
|
||||
DRM_DEBUG("IH: D%d vblank\n", crtc + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_virtual_set_pageflip_irq_state(struct amdgpu_device *adev,
|
||||
struct amdgpu_irq_src *src,
|
||||
unsigned type,
|
||||
enum amdgpu_interrupt_state state)
|
||||
{
|
||||
if (type >= adev->mode_info.num_crtc) {
|
||||
DRM_ERROR("invalid pageflip crtc %d\n", type);
|
||||
return -EINVAL;
|
||||
}
|
||||
DRM_DEBUG("[FM]set pageflip irq type %d state %d\n", type, state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dce_virtual_pageflip_irq(struct amdgpu_device *adev,
|
||||
struct amdgpu_irq_src *source,
|
||||
struct amdgpu_iv_entry *entry)
|
||||
{
|
||||
unsigned long flags;
|
||||
unsigned crtc_id = 0;
|
||||
struct amdgpu_crtc *amdgpu_crtc;
|
||||
struct amdgpu_flip_work *works;
|
||||
|
||||
crtc_id = 0;
|
||||
amdgpu_crtc = adev->mode_info.crtcs[crtc_id];
|
||||
|
||||
if (crtc_id >= adev->mode_info.num_crtc) {
|
||||
DRM_ERROR("invalid pageflip crtc %d\n", crtc_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* IRQ could occur when in initial stage */
|
||||
if (amdgpu_crtc == NULL)
|
||||
return 0;
|
||||
|
||||
spin_lock_irqsave(&adev->ddev->event_lock, flags);
|
||||
works = amdgpu_crtc->pflip_works;
|
||||
if (amdgpu_crtc->pflip_status != AMDGPU_FLIP_SUBMITTED) {
|
||||
DRM_DEBUG_DRIVER("amdgpu_crtc->pflip_status = %d != "
|
||||
"AMDGPU_FLIP_SUBMITTED(%d)\n",
|
||||
amdgpu_crtc->pflip_status,
|
||||
AMDGPU_FLIP_SUBMITTED);
|
||||
spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* page flip completed. clean up */
|
||||
amdgpu_crtc->pflip_status = AMDGPU_FLIP_NONE;
|
||||
amdgpu_crtc->pflip_works = NULL;
|
||||
|
||||
/* wakeup usersapce */
|
||||
if (works->event)
|
||||
drm_crtc_send_vblank_event(&amdgpu_crtc->base, works->event);
|
||||
|
||||
spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
|
||||
|
||||
drm_crtc_vblank_put(&amdgpu_crtc->base);
|
||||
schedule_work(&works->unpin_work);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct amdgpu_irq_src_funcs dce_virtual_crtc_irq_funcs = {
|
||||
.set = dce_virtual_set_crtc_irq_state,
|
||||
.process = dce_virtual_crtc_irq,
|
||||
};
|
||||
|
||||
static const struct amdgpu_irq_src_funcs dce_virtual_pageflip_irq_funcs = {
|
||||
.set = dce_virtual_set_pageflip_irq_state,
|
||||
.process = dce_virtual_pageflip_irq,
|
||||
};
|
||||
|
||||
static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev)
|
||||
{
|
||||
adev->crtc_irq.num_types = AMDGPU_CRTC_IRQ_LAST;
|
||||
adev->crtc_irq.funcs = &dce_virtual_crtc_irq_funcs;
|
||||
|
||||
adev->pageflip_irq.num_types = AMDGPU_PAGEFLIP_IRQ_LAST;
|
||||
adev->pageflip_irq.funcs = &dce_virtual_pageflip_irq_funcs;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __DCE_VIRTUAL_H__
|
||||
#define __DCE_VIRTUAL_H__
|
||||
|
||||
extern const struct amd_ip_funcs dce_virtual_ip_funcs;
|
||||
#define DCE_VIRTUAL_VBLANK_PERIOD 16666666
|
||||
|
||||
#endif
|
||||
|
|
@ -4465,24 +4465,21 @@ static int gfx_v7_0_sw_init(void *handle)
|
|||
}
|
||||
|
||||
/* reserve GDS, GWS and OA resource for gfx */
|
||||
r = amdgpu_bo_create(adev, adev->gds.mem.gfx_partition_size,
|
||||
PAGE_SIZE, true,
|
||||
AMDGPU_GEM_DOMAIN_GDS, 0,
|
||||
NULL, NULL, &adev->gds.gds_gfx_bo);
|
||||
r = amdgpu_bo_create_kernel(adev, adev->gds.mem.gfx_partition_size,
|
||||
PAGE_SIZE, AMDGPU_GEM_DOMAIN_GDS,
|
||||
&adev->gds.gds_gfx_bo, NULL, NULL);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
r = amdgpu_bo_create(adev, adev->gds.gws.gfx_partition_size,
|
||||
PAGE_SIZE, true,
|
||||
AMDGPU_GEM_DOMAIN_GWS, 0,
|
||||
NULL, NULL, &adev->gds.gws_gfx_bo);
|
||||
r = amdgpu_bo_create_kernel(adev, adev->gds.gws.gfx_partition_size,
|
||||
PAGE_SIZE, AMDGPU_GEM_DOMAIN_GWS,
|
||||
&adev->gds.gws_gfx_bo, NULL, NULL);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
r = amdgpu_bo_create(adev, adev->gds.oa.gfx_partition_size,
|
||||
PAGE_SIZE, true,
|
||||
AMDGPU_GEM_DOMAIN_OA, 0,
|
||||
NULL, NULL, &adev->gds.oa_gfx_bo);
|
||||
r = amdgpu_bo_create_kernel(adev, adev->gds.oa.gfx_partition_size,
|
||||
PAGE_SIZE, AMDGPU_GEM_DOMAIN_OA,
|
||||
&adev->gds.oa_gfx_bo, NULL, NULL);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,6 +26,4 @@
|
|||
|
||||
extern const struct amd_ip_funcs gfx_v8_0_ip_funcs;
|
||||
|
||||
void gfx_v8_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 sh_num);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -183,7 +183,7 @@ static int gmc_v7_0_mc_load_microcode(struct amdgpu_device *adev)
|
|||
const struct mc_firmware_header_v1_0 *hdr;
|
||||
const __le32 *fw_data = NULL;
|
||||
const __le32 *io_mc_regs = NULL;
|
||||
u32 running, blackout = 0;
|
||||
u32 running;
|
||||
int i, ucode_size, regs_size;
|
||||
|
||||
if (!adev->mc.fw)
|
||||
|
@ -203,11 +203,6 @@ static int gmc_v7_0_mc_load_microcode(struct amdgpu_device *adev)
|
|||
running = REG_GET_FIELD(RREG32(mmMC_SEQ_SUP_CNTL), MC_SEQ_SUP_CNTL, RUN);
|
||||
|
||||
if (running == 0) {
|
||||
if (running) {
|
||||
blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
|
||||
WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout | 1);
|
||||
}
|
||||
|
||||
/* reset the engine and set to writable */
|
||||
WREG32(mmMC_SEQ_SUP_CNTL, 0x00000008);
|
||||
WREG32(mmMC_SEQ_SUP_CNTL, 0x00000010);
|
||||
|
@ -239,9 +234,6 @@ static int gmc_v7_0_mc_load_microcode(struct amdgpu_device *adev)
|
|||
break;
|
||||
udelay(1);
|
||||
}
|
||||
|
||||
if (running)
|
||||
WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -393,7 +385,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
|
|||
* 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 = amdgpu_ttm_get_gtt_mem_size(adev);
|
||||
else
|
||||
adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
|
||||
|
||||
|
@ -953,6 +945,11 @@ static int gmc_v7_0_sw_init(void *handle)
|
|||
return r;
|
||||
}
|
||||
|
||||
r = amdgpu_ttm_global_init(adev);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r = gmc_v7_0_mc_init(adev);
|
||||
if (r)
|
||||
return r;
|
||||
|
|
|
@ -261,7 +261,7 @@ static int gmc_v8_0_mc_load_microcode(struct amdgpu_device *adev)
|
|||
const struct mc_firmware_header_v1_0 *hdr;
|
||||
const __le32 *fw_data = NULL;
|
||||
const __le32 *io_mc_regs = NULL;
|
||||
u32 running, blackout = 0;
|
||||
u32 running;
|
||||
int i, ucode_size, regs_size;
|
||||
|
||||
if (!adev->mc.fw)
|
||||
|
@ -287,11 +287,6 @@ static int gmc_v8_0_mc_load_microcode(struct amdgpu_device *adev)
|
|||
running = REG_GET_FIELD(RREG32(mmMC_SEQ_SUP_CNTL), MC_SEQ_SUP_CNTL, RUN);
|
||||
|
||||
if (running == 0) {
|
||||
if (running) {
|
||||
blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
|
||||
WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout | 1);
|
||||
}
|
||||
|
||||
/* reset the engine and set to writable */
|
||||
WREG32(mmMC_SEQ_SUP_CNTL, 0x00000008);
|
||||
WREG32(mmMC_SEQ_SUP_CNTL, 0x00000010);
|
||||
|
@ -323,9 +318,6 @@ static int gmc_v8_0_mc_load_microcode(struct amdgpu_device *adev)
|
|||
break;
|
||||
udelay(1);
|
||||
}
|
||||
|
||||
if (running)
|
||||
WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -477,7 +469,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
|
|||
* 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 = amdgpu_ttm_get_gtt_mem_size(adev);
|
||||
else
|
||||
adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
|
||||
|
||||
|
@ -957,6 +949,11 @@ static int gmc_v8_0_sw_init(void *handle)
|
|||
return r;
|
||||
}
|
||||
|
||||
r = amdgpu_ttm_global_init(adev);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r = gmc_v8_0_mc_init(adev);
|
||||
if (r)
|
||||
return r;
|
||||
|
@ -1100,9 +1097,8 @@ static int gmc_v8_0_wait_for_idle(void *handle)
|
|||
|
||||
}
|
||||
|
||||
static int gmc_v8_0_soft_reset(void *handle)
|
||||
static int gmc_v8_0_check_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_mode_mc_save save;
|
||||
u32 srbm_soft_reset = 0;
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 tmp = RREG32(mmSRBM_STATUS);
|
||||
|
@ -1117,13 +1113,42 @@ static int gmc_v8_0_soft_reset(void *handle)
|
|||
srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset,
|
||||
SRBM_SOFT_RESET, SOFT_RESET_MC, 1);
|
||||
}
|
||||
if (srbm_soft_reset) {
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_GMC].hang = true;
|
||||
adev->mc.srbm_soft_reset = srbm_soft_reset;
|
||||
} else {
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_GMC].hang = false;
|
||||
adev->mc.srbm_soft_reset = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gmc_v8_0_pre_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_GMC].hang)
|
||||
return 0;
|
||||
|
||||
gmc_v8_0_mc_stop(adev, &adev->mc.save);
|
||||
if (gmc_v8_0_wait_for_idle(adev)) {
|
||||
dev_warn(adev->dev, "Wait for GMC idle timed out !\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gmc_v8_0_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 srbm_soft_reset;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_GMC].hang)
|
||||
return 0;
|
||||
srbm_soft_reset = adev->mc.srbm_soft_reset;
|
||||
|
||||
if (srbm_soft_reset) {
|
||||
gmc_v8_0_mc_stop(adev, &save);
|
||||
if (gmc_v8_0_wait_for_idle((void *)adev)) {
|
||||
dev_warn(adev->dev, "Wait for GMC idle timed out !\n");
|
||||
}
|
||||
|
||||
u32 tmp;
|
||||
|
||||
tmp = RREG32(mmSRBM_SOFT_RESET);
|
||||
tmp |= srbm_soft_reset;
|
||||
|
@ -1139,14 +1164,22 @@ static int gmc_v8_0_soft_reset(void *handle)
|
|||
|
||||
/* Wait a little for things to settle down */
|
||||
udelay(50);
|
||||
|
||||
gmc_v8_0_mc_resume(adev, &save);
|
||||
udelay(50);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gmc_v8_0_post_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_GMC].hang)
|
||||
return 0;
|
||||
|
||||
gmc_v8_0_mc_resume(adev, &adev->mc.save);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gmc_v8_0_vm_fault_interrupt_state(struct amdgpu_device *adev,
|
||||
struct amdgpu_irq_src *src,
|
||||
unsigned type,
|
||||
|
@ -1414,7 +1447,10 @@ const struct amd_ip_funcs gmc_v8_0_ip_funcs = {
|
|||
.resume = gmc_v8_0_resume,
|
||||
.is_idle = gmc_v8_0_is_idle,
|
||||
.wait_for_idle = gmc_v8_0_wait_for_idle,
|
||||
.check_soft_reset = gmc_v8_0_check_soft_reset,
|
||||
.pre_soft_reset = gmc_v8_0_pre_soft_reset,
|
||||
.soft_reset = gmc_v8_0_soft_reset,
|
||||
.post_soft_reset = gmc_v8_0_post_soft_reset,
|
||||
.set_clockgating_state = gmc_v8_0_set_clockgating_state,
|
||||
.set_powergating_state = gmc_v8_0_set_powergating_state,
|
||||
};
|
||||
|
|
|
@ -2845,7 +2845,11 @@ static int kv_dpm_init(struct amdgpu_device *adev)
|
|||
pi->caps_tcp_ramping = true;
|
||||
}
|
||||
|
||||
pi->caps_sclk_ds = true;
|
||||
if (amdgpu_sclk_deep_sleep_en)
|
||||
pi->caps_sclk_ds = true;
|
||||
else
|
||||
pi->caps_sclk_ds = false;
|
||||
|
||||
pi->enable_auto_thermal_throttling = true;
|
||||
pi->disable_nb_ps3_in_battery = false;
|
||||
if (amdgpu_bapm == 0)
|
||||
|
|
|
@ -749,24 +749,16 @@ static void sdma_v2_4_vm_copy_pte(struct amdgpu_ib *ib,
|
|||
uint64_t pe, uint64_t src,
|
||||
unsigned count)
|
||||
{
|
||||
while (count) {
|
||||
unsigned bytes = count * 8;
|
||||
if (bytes > 0x1FFFF8)
|
||||
bytes = 0x1FFFF8;
|
||||
unsigned bytes = count * 8;
|
||||
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_COPY) |
|
||||
SDMA_PKT_HEADER_SUB_OP(SDMA_SUBOP_COPY_LINEAR);
|
||||
ib->ptr[ib->length_dw++] = bytes;
|
||||
ib->ptr[ib->length_dw++] = 0; /* src/dst endian swap */
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
|
||||
pe += bytes;
|
||||
src += bytes;
|
||||
count -= bytes / 8;
|
||||
}
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_COPY) |
|
||||
SDMA_PKT_HEADER_SUB_OP(SDMA_SUBOP_COPY_LINEAR);
|
||||
ib->ptr[ib->length_dw++] = bytes;
|
||||
ib->ptr[ib->length_dw++] = 0; /* src/dst endian swap */
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -774,39 +766,27 @@ static void sdma_v2_4_vm_copy_pte(struct amdgpu_ib *ib,
|
|||
*
|
||||
* @ib: indirect buffer to fill with commands
|
||||
* @pe: addr of the page entry
|
||||
* @addr: dst addr to write into pe
|
||||
* @value: dst addr to write into pe
|
||||
* @count: number of page entries to update
|
||||
* @incr: increase next addr by incr bytes
|
||||
* @flags: access flags
|
||||
*
|
||||
* Update PTEs by writing them manually using sDMA (CIK).
|
||||
*/
|
||||
static void sdma_v2_4_vm_write_pte(struct amdgpu_ib *ib,
|
||||
const dma_addr_t *pages_addr, uint64_t pe,
|
||||
uint64_t addr, unsigned count,
|
||||
uint32_t incr, uint32_t flags)
|
||||
static void sdma_v2_4_vm_write_pte(struct amdgpu_ib *ib, uint64_t pe,
|
||||
uint64_t value, unsigned count,
|
||||
uint32_t incr)
|
||||
{
|
||||
uint64_t value;
|
||||
unsigned ndw;
|
||||
unsigned ndw = count * 2;
|
||||
|
||||
while (count) {
|
||||
ndw = count * 2;
|
||||
if (ndw > 0xFFFFE)
|
||||
ndw = 0xFFFFE;
|
||||
|
||||
/* for non-physically contiguous pages (system) */
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_WRITE) |
|
||||
SDMA_PKT_HEADER_SUB_OP(SDMA_SUBOP_COPY_LINEAR);
|
||||
ib->ptr[ib->length_dw++] = pe;
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = ndw;
|
||||
for (; ndw > 0; ndw -= 2, --count, pe += 8) {
|
||||
value = amdgpu_vm_map_gart(pages_addr, addr);
|
||||
addr += incr;
|
||||
value |= flags;
|
||||
ib->ptr[ib->length_dw++] = value;
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(value);
|
||||
}
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_WRITE) |
|
||||
SDMA_PKT_HEADER_SUB_OP(SDMA_SUBOP_COPY_LINEAR);
|
||||
ib->ptr[ib->length_dw++] = pe;
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = ndw;
|
||||
for (; ndw > 0; ndw -= 2, --count, pe += 8) {
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(value);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(value);
|
||||
value += incr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -822,40 +802,21 @@ static void sdma_v2_4_vm_write_pte(struct amdgpu_ib *ib,
|
|||
*
|
||||
* Update the page tables using sDMA (CIK).
|
||||
*/
|
||||
static void sdma_v2_4_vm_set_pte_pde(struct amdgpu_ib *ib,
|
||||
uint64_t pe,
|
||||
static void sdma_v2_4_vm_set_pte_pde(struct amdgpu_ib *ib, uint64_t pe,
|
||||
uint64_t addr, unsigned count,
|
||||
uint32_t incr, uint32_t flags)
|
||||
{
|
||||
uint64_t value;
|
||||
unsigned ndw;
|
||||
|
||||
while (count) {
|
||||
ndw = count;
|
||||
if (ndw > 0x7FFFF)
|
||||
ndw = 0x7FFFF;
|
||||
|
||||
if (flags & AMDGPU_PTE_VALID)
|
||||
value = addr;
|
||||
else
|
||||
value = 0;
|
||||
|
||||
/* for physically contiguous pages (vram) */
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_GEN_PTEPDE);
|
||||
ib->ptr[ib->length_dw++] = pe; /* dst addr */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = flags; /* mask */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = value; /* value */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(value);
|
||||
ib->ptr[ib->length_dw++] = incr; /* increment size */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = ndw; /* number of entries */
|
||||
|
||||
pe += ndw * 8;
|
||||
addr += ndw * incr;
|
||||
count -= ndw;
|
||||
}
|
||||
/* for physically contiguous pages (vram) */
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_GEN_PTEPDE);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe); /* dst addr */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = flags; /* mask */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(addr); /* value */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(addr);
|
||||
ib->ptr[ib->length_dw++] = incr; /* increment size */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = count; /* number of entries */
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -976,24 +976,16 @@ static void sdma_v3_0_vm_copy_pte(struct amdgpu_ib *ib,
|
|||
uint64_t pe, uint64_t src,
|
||||
unsigned count)
|
||||
{
|
||||
while (count) {
|
||||
unsigned bytes = count * 8;
|
||||
if (bytes > 0x1FFFF8)
|
||||
bytes = 0x1FFFF8;
|
||||
unsigned bytes = count * 8;
|
||||
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_COPY) |
|
||||
SDMA_PKT_HEADER_SUB_OP(SDMA_SUBOP_COPY_LINEAR);
|
||||
ib->ptr[ib->length_dw++] = bytes;
|
||||
ib->ptr[ib->length_dw++] = 0; /* src/dst endian swap */
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
|
||||
pe += bytes;
|
||||
src += bytes;
|
||||
count -= bytes / 8;
|
||||
}
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_COPY) |
|
||||
SDMA_PKT_HEADER_SUB_OP(SDMA_SUBOP_COPY_LINEAR);
|
||||
ib->ptr[ib->length_dw++] = bytes;
|
||||
ib->ptr[ib->length_dw++] = 0; /* src/dst endian swap */
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(src);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1001,39 +993,27 @@ static void sdma_v3_0_vm_copy_pte(struct amdgpu_ib *ib,
|
|||
*
|
||||
* @ib: indirect buffer to fill with commands
|
||||
* @pe: addr of the page entry
|
||||
* @addr: dst addr to write into pe
|
||||
* @value: dst addr to write into pe
|
||||
* @count: number of page entries to update
|
||||
* @incr: increase next addr by incr bytes
|
||||
* @flags: access flags
|
||||
*
|
||||
* Update PTEs by writing them manually using sDMA (CIK).
|
||||
*/
|
||||
static void sdma_v3_0_vm_write_pte(struct amdgpu_ib *ib,
|
||||
const dma_addr_t *pages_addr, uint64_t pe,
|
||||
uint64_t addr, unsigned count,
|
||||
uint32_t incr, uint32_t flags)
|
||||
static void sdma_v3_0_vm_write_pte(struct amdgpu_ib *ib, uint64_t pe,
|
||||
uint64_t value, unsigned count,
|
||||
uint32_t incr)
|
||||
{
|
||||
uint64_t value;
|
||||
unsigned ndw;
|
||||
unsigned ndw = count * 2;
|
||||
|
||||
while (count) {
|
||||
ndw = count * 2;
|
||||
if (ndw > 0xFFFFE)
|
||||
ndw = 0xFFFFE;
|
||||
|
||||
/* for non-physically contiguous pages (system) */
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_WRITE) |
|
||||
SDMA_PKT_HEADER_SUB_OP(SDMA_SUBOP_COPY_LINEAR);
|
||||
ib->ptr[ib->length_dw++] = pe;
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = ndw;
|
||||
for (; ndw > 0; ndw -= 2, --count, pe += 8) {
|
||||
value = amdgpu_vm_map_gart(pages_addr, addr);
|
||||
addr += incr;
|
||||
value |= flags;
|
||||
ib->ptr[ib->length_dw++] = value;
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(value);
|
||||
}
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_WRITE) |
|
||||
SDMA_PKT_HEADER_SUB_OP(SDMA_SUBOP_COPY_LINEAR);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = ndw;
|
||||
for (; ndw > 0; ndw -= 2, --count, pe += 8) {
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(value);
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(value);
|
||||
value += incr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1049,40 +1029,21 @@ static void sdma_v3_0_vm_write_pte(struct amdgpu_ib *ib,
|
|||
*
|
||||
* Update the page tables using sDMA (CIK).
|
||||
*/
|
||||
static void sdma_v3_0_vm_set_pte_pde(struct amdgpu_ib *ib,
|
||||
uint64_t pe,
|
||||
static void sdma_v3_0_vm_set_pte_pde(struct amdgpu_ib *ib, uint64_t pe,
|
||||
uint64_t addr, unsigned count,
|
||||
uint32_t incr, uint32_t flags)
|
||||
{
|
||||
uint64_t value;
|
||||
unsigned ndw;
|
||||
|
||||
while (count) {
|
||||
ndw = count;
|
||||
if (ndw > 0x7FFFF)
|
||||
ndw = 0x7FFFF;
|
||||
|
||||
if (flags & AMDGPU_PTE_VALID)
|
||||
value = addr;
|
||||
else
|
||||
value = 0;
|
||||
|
||||
/* for physically contiguous pages (vram) */
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_GEN_PTEPDE);
|
||||
ib->ptr[ib->length_dw++] = pe; /* dst addr */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = flags; /* mask */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = value; /* value */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(value);
|
||||
ib->ptr[ib->length_dw++] = incr; /* increment size */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = ndw; /* number of entries */
|
||||
|
||||
pe += ndw * 8;
|
||||
addr += ndw * incr;
|
||||
count -= ndw;
|
||||
}
|
||||
/* for physically contiguous pages (vram) */
|
||||
ib->ptr[ib->length_dw++] = SDMA_PKT_HEADER_OP(SDMA_OP_GEN_PTEPDE);
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(pe); /* dst addr */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(pe);
|
||||
ib->ptr[ib->length_dw++] = flags; /* mask */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = lower_32_bits(addr); /* value */
|
||||
ib->ptr[ib->length_dw++] = upper_32_bits(addr);
|
||||
ib->ptr[ib->length_dw++] = incr; /* increment size */
|
||||
ib->ptr[ib->length_dw++] = 0;
|
||||
ib->ptr[ib->length_dw++] = count; /* number of entries */
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1320,27 +1281,78 @@ static int sdma_v3_0_wait_for_idle(void *handle)
|
|||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static int sdma_v3_0_soft_reset(void *handle)
|
||||
static int sdma_v3_0_check_soft_reset(void *handle)
|
||||
{
|
||||
u32 srbm_soft_reset = 0;
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 srbm_soft_reset = 0;
|
||||
u32 tmp = RREG32(mmSRBM_STATUS2);
|
||||
|
||||
if (tmp & SRBM_STATUS2__SDMA_BUSY_MASK) {
|
||||
/* sdma0 */
|
||||
tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
|
||||
tmp = REG_SET_FIELD(tmp, SDMA0_F32_CNTL, HALT, 0);
|
||||
WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
|
||||
if ((tmp & SRBM_STATUS2__SDMA_BUSY_MASK) ||
|
||||
(tmp & SRBM_STATUS2__SDMA1_BUSY_MASK)) {
|
||||
srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
|
||||
}
|
||||
if (tmp & SRBM_STATUS2__SDMA1_BUSY_MASK) {
|
||||
/* sdma1 */
|
||||
tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
|
||||
tmp = REG_SET_FIELD(tmp, SDMA0_F32_CNTL, HALT, 0);
|
||||
WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
|
||||
srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
|
||||
}
|
||||
|
||||
if (srbm_soft_reset) {
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_SDMA].hang = true;
|
||||
adev->sdma.srbm_soft_reset = srbm_soft_reset;
|
||||
} else {
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_SDMA].hang = false;
|
||||
adev->sdma.srbm_soft_reset = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sdma_v3_0_pre_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 srbm_soft_reset = 0;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_SDMA].hang)
|
||||
return 0;
|
||||
|
||||
srbm_soft_reset = adev->sdma.srbm_soft_reset;
|
||||
|
||||
if (REG_GET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_SDMA) ||
|
||||
REG_GET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_SDMA1)) {
|
||||
sdma_v3_0_ctx_switch_enable(adev, false);
|
||||
sdma_v3_0_enable(adev, false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sdma_v3_0_post_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 srbm_soft_reset = 0;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_SDMA].hang)
|
||||
return 0;
|
||||
|
||||
srbm_soft_reset = adev->sdma.srbm_soft_reset;
|
||||
|
||||
if (REG_GET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_SDMA) ||
|
||||
REG_GET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_SDMA1)) {
|
||||
sdma_v3_0_gfx_resume(adev);
|
||||
sdma_v3_0_rlc_resume(adev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sdma_v3_0_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 srbm_soft_reset = 0;
|
||||
u32 tmp;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_SDMA].hang)
|
||||
return 0;
|
||||
|
||||
srbm_soft_reset = adev->sdma.srbm_soft_reset;
|
||||
|
||||
if (srbm_soft_reset) {
|
||||
tmp = RREG32(mmSRBM_SOFT_RESET);
|
||||
tmp |= srbm_soft_reset;
|
||||
|
@ -1559,6 +1571,9 @@ const struct amd_ip_funcs sdma_v3_0_ip_funcs = {
|
|||
.resume = sdma_v3_0_resume,
|
||||
.is_idle = sdma_v3_0_is_idle,
|
||||
.wait_for_idle = sdma_v3_0_wait_for_idle,
|
||||
.check_soft_reset = sdma_v3_0_check_soft_reset,
|
||||
.pre_soft_reset = sdma_v3_0_pre_soft_reset,
|
||||
.post_soft_reset = sdma_v3_0_post_soft_reset,
|
||||
.soft_reset = sdma_v3_0_soft_reset,
|
||||
.set_clockgating_state = sdma_v3_0_set_clockgating_state,
|
||||
.set_powergating_state = sdma_v3_0_set_powergating_state,
|
||||
|
|
|
@ -373,10 +373,10 @@ static int tonga_ih_wait_for_idle(void *handle)
|
|||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static int tonga_ih_soft_reset(void *handle)
|
||||
static int tonga_ih_check_soft_reset(void *handle)
|
||||
{
|
||||
u32 srbm_soft_reset = 0;
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 srbm_soft_reset = 0;
|
||||
u32 tmp = RREG32(mmSRBM_STATUS);
|
||||
|
||||
if (tmp & SRBM_STATUS__IH_BUSY_MASK)
|
||||
|
@ -384,6 +384,48 @@ static int tonga_ih_soft_reset(void *handle)
|
|||
SOFT_RESET_IH, 1);
|
||||
|
||||
if (srbm_soft_reset) {
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_IH].hang = true;
|
||||
adev->irq.srbm_soft_reset = srbm_soft_reset;
|
||||
} else {
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_IH].hang = false;
|
||||
adev->irq.srbm_soft_reset = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tonga_ih_pre_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_IH].hang)
|
||||
return 0;
|
||||
|
||||
return tonga_ih_hw_fini(adev);
|
||||
}
|
||||
|
||||
static int tonga_ih_post_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_IH].hang)
|
||||
return 0;
|
||||
|
||||
return tonga_ih_hw_init(adev);
|
||||
}
|
||||
|
||||
static int tonga_ih_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 srbm_soft_reset;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_IH].hang)
|
||||
return 0;
|
||||
srbm_soft_reset = adev->irq.srbm_soft_reset;
|
||||
|
||||
if (srbm_soft_reset) {
|
||||
u32 tmp;
|
||||
|
||||
tmp = RREG32(mmSRBM_SOFT_RESET);
|
||||
tmp |= srbm_soft_reset;
|
||||
dev_info(adev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp);
|
||||
|
@ -427,7 +469,10 @@ const struct amd_ip_funcs tonga_ih_ip_funcs = {
|
|||
.resume = tonga_ih_resume,
|
||||
.is_idle = tonga_ih_is_idle,
|
||||
.wait_for_idle = tonga_ih_wait_for_idle,
|
||||
.check_soft_reset = tonga_ih_check_soft_reset,
|
||||
.pre_soft_reset = tonga_ih_pre_soft_reset,
|
||||
.soft_reset = tonga_ih_soft_reset,
|
||||
.post_soft_reset = tonga_ih_post_soft_reset,
|
||||
.set_clockgating_state = tonga_ih_set_clockgating_state,
|
||||
.set_powergating_state = tonga_ih_set_powergating_state,
|
||||
};
|
||||
|
|
|
@ -116,7 +116,7 @@ static int uvd_v4_2_sw_init(void *handle)
|
|||
|
||||
ring = &adev->uvd.ring;
|
||||
sprintf(ring->name, "uvd");
|
||||
r = amdgpu_ring_init(adev, ring, 512, CP_PACKET2, 0xf,
|
||||
r = amdgpu_ring_init(adev, ring, 512, PACKET0(mmUVD_NO_OP, 0), 0xf,
|
||||
&adev->uvd.irq, 0, AMDGPU_RING_TYPE_UVD);
|
||||
|
||||
return r;
|
||||
|
|
|
@ -112,7 +112,7 @@ static int uvd_v5_0_sw_init(void *handle)
|
|||
|
||||
ring = &adev->uvd.ring;
|
||||
sprintf(ring->name, "uvd");
|
||||
r = amdgpu_ring_init(adev, ring, 512, CP_PACKET2, 0xf,
|
||||
r = amdgpu_ring_init(adev, ring, 512, PACKET0(mmUVD_NO_OP, 0), 0xf,
|
||||
&adev->uvd.irq, 0, AMDGPU_RING_TYPE_UVD);
|
||||
|
||||
return r;
|
||||
|
|
|
@ -116,7 +116,7 @@ static int uvd_v6_0_sw_init(void *handle)
|
|||
|
||||
ring = &adev->uvd.ring;
|
||||
sprintf(ring->name, "uvd");
|
||||
r = amdgpu_ring_init(adev, ring, 512, CP_PACKET2, 0xf,
|
||||
r = amdgpu_ring_init(adev, ring, 512, PACKET0(mmUVD_NO_OP, 0), 0xf,
|
||||
&adev->uvd.irq, 0, AMDGPU_RING_TYPE_UVD);
|
||||
|
||||
return r;
|
||||
|
@ -396,21 +396,14 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)
|
|||
|
||||
uvd_v6_0_mc_resume(adev);
|
||||
|
||||
/* Set dynamic clock gating in S/W control mode */
|
||||
if (adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG) {
|
||||
uvd_v6_0_set_sw_clock_gating(adev);
|
||||
} else {
|
||||
/* disable clock gating */
|
||||
uint32_t data = RREG32(mmUVD_CGC_CTRL);
|
||||
data &= ~UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK;
|
||||
WREG32(mmUVD_CGC_CTRL, data);
|
||||
}
|
||||
/* disable clock gating */
|
||||
WREG32_FIELD(UVD_CGC_CTRL, DYN_CLOCK_MODE, 0);
|
||||
|
||||
/* disable interupt */
|
||||
WREG32_P(mmUVD_MASTINT_EN, 0, ~UVD_MASTINT_EN__VCPU_EN_MASK);
|
||||
WREG32_FIELD(UVD_MASTINT_EN, VCPU_EN, 0);
|
||||
|
||||
/* stall UMC and register bus before resetting VCPU */
|
||||
WREG32_P(mmUVD_LMI_CTRL2, UVD_LMI_CTRL2__STALL_ARB_UMC_MASK, ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK);
|
||||
WREG32_FIELD(UVD_LMI_CTRL2, STALL_ARB_UMC, 1);
|
||||
mdelay(1);
|
||||
|
||||
/* put LMI, VCPU, RBC etc... into reset */
|
||||
|
@ -426,7 +419,7 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)
|
|||
mdelay(5);
|
||||
|
||||
/* take UVD block out of reset */
|
||||
WREG32_P(mmSRBM_SOFT_RESET, 0, ~SRBM_SOFT_RESET__SOFT_RESET_UVD_MASK);
|
||||
WREG32_FIELD(SRBM_SOFT_RESET, SOFT_RESET_UVD, 0);
|
||||
mdelay(5);
|
||||
|
||||
/* initialize UVD memory controller */
|
||||
|
@ -461,7 +454,7 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)
|
|||
WREG32(mmUVD_VCPU_CNTL, UVD_VCPU_CNTL__CLK_EN_MASK);
|
||||
|
||||
/* enable UMC */
|
||||
WREG32_P(mmUVD_LMI_CTRL2, 0, ~UVD_LMI_CTRL2__STALL_ARB_UMC_MASK);
|
||||
WREG32_FIELD(UVD_LMI_CTRL2, STALL_ARB_UMC, 0);
|
||||
|
||||
/* boot up the VCPU */
|
||||
WREG32(mmUVD_SOFT_RESET, 0);
|
||||
|
@ -481,11 +474,9 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)
|
|||
break;
|
||||
|
||||
DRM_ERROR("UVD not responding, trying to reset the VCPU!!!\n");
|
||||
WREG32_P(mmUVD_SOFT_RESET, UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK,
|
||||
~UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK);
|
||||
WREG32_FIELD(UVD_SOFT_RESET, VCPU_SOFT_RESET, 1);
|
||||
mdelay(10);
|
||||
WREG32_P(mmUVD_SOFT_RESET, 0,
|
||||
~UVD_SOFT_RESET__VCPU_SOFT_RESET_MASK);
|
||||
WREG32_FIELD(UVD_SOFT_RESET, VCPU_SOFT_RESET, 0);
|
||||
mdelay(10);
|
||||
r = -1;
|
||||
}
|
||||
|
@ -502,15 +493,14 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)
|
|||
/* clear the bit 4 of UVD_STATUS */
|
||||
WREG32_P(mmUVD_STATUS, 0, ~(2 << UVD_STATUS__VCPU_REPORT__SHIFT));
|
||||
|
||||
/* force RBC into idle state */
|
||||
rb_bufsz = order_base_2(ring->ring_size);
|
||||
tmp = 0;
|
||||
tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_BUFSZ, rb_bufsz);
|
||||
tmp = REG_SET_FIELD(0, UVD_RBC_RB_CNTL, RB_BUFSZ, rb_bufsz);
|
||||
tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_BLKSZ, 1);
|
||||
tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_NO_FETCH, 1);
|
||||
tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_WPTR_POLL_EN, 0);
|
||||
tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_NO_UPDATE, 1);
|
||||
tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_RPTR_WR_EN, 1);
|
||||
/* force RBC into idle state */
|
||||
WREG32(mmUVD_RBC_RB_CNTL, tmp);
|
||||
|
||||
/* set the write pointer delay */
|
||||
|
@ -531,7 +521,7 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)
|
|||
ring->wptr = RREG32(mmUVD_RBC_RB_RPTR);
|
||||
WREG32(mmUVD_RBC_RB_WPTR, ring->wptr);
|
||||
|
||||
WREG32_P(mmUVD_RBC_RB_CNTL, 0, ~UVD_RBC_RB_CNTL__RB_NO_FETCH_MASK);
|
||||
WREG32_FIELD(UVD_RBC_RB_CNTL, RB_NO_FETCH, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -748,20 +738,82 @@ static int uvd_v6_0_wait_for_idle(void *handle)
|
|||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
for (i = 0; i < adev->usec_timeout; i++) {
|
||||
if (!(RREG32(mmSRBM_STATUS) & SRBM_STATUS__UVD_BUSY_MASK))
|
||||
if (uvd_v6_0_is_idle(handle))
|
||||
return 0;
|
||||
}
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static int uvd_v6_0_soft_reset(void *handle)
|
||||
#define AMDGPU_UVD_STATUS_BUSY_MASK 0xfd
|
||||
static int uvd_v6_0_check_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 srbm_soft_reset = 0;
|
||||
u32 tmp = RREG32(mmSRBM_STATUS);
|
||||
|
||||
if (REG_GET_FIELD(tmp, SRBM_STATUS, UVD_RQ_PENDING) ||
|
||||
REG_GET_FIELD(tmp, SRBM_STATUS, UVD_BUSY) ||
|
||||
(RREG32(mmUVD_STATUS) & AMDGPU_UVD_STATUS_BUSY_MASK))
|
||||
srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_UVD, 1);
|
||||
|
||||
if (srbm_soft_reset) {
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_UVD].hang = true;
|
||||
adev->uvd.srbm_soft_reset = srbm_soft_reset;
|
||||
} else {
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_UVD].hang = false;
|
||||
adev->uvd.srbm_soft_reset = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int uvd_v6_0_pre_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
uvd_v6_0_stop(adev);
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_UVD].hang)
|
||||
return 0;
|
||||
|
||||
uvd_v6_0_stop(adev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uvd_v6_0_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 srbm_soft_reset;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_UVD].hang)
|
||||
return 0;
|
||||
srbm_soft_reset = adev->uvd.srbm_soft_reset;
|
||||
|
||||
if (srbm_soft_reset) {
|
||||
u32 tmp;
|
||||
|
||||
tmp = RREG32(mmSRBM_SOFT_RESET);
|
||||
tmp |= srbm_soft_reset;
|
||||
dev_info(adev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp);
|
||||
WREG32(mmSRBM_SOFT_RESET, tmp);
|
||||
tmp = RREG32(mmSRBM_SOFT_RESET);
|
||||
|
||||
udelay(50);
|
||||
|
||||
tmp &= ~srbm_soft_reset;
|
||||
WREG32(mmSRBM_SOFT_RESET, tmp);
|
||||
tmp = RREG32(mmSRBM_SOFT_RESET);
|
||||
|
||||
/* Wait a little for things to settle down */
|
||||
udelay(50);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uvd_v6_0_post_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_UVD].hang)
|
||||
return 0;
|
||||
|
||||
WREG32_P(mmSRBM_SOFT_RESET, SRBM_SOFT_RESET__SOFT_RESET_UVD_MASK,
|
||||
~SRBM_SOFT_RESET__SOFT_RESET_UVD_MASK);
|
||||
mdelay(5);
|
||||
|
||||
return uvd_v6_0_start(adev);
|
||||
|
@ -902,21 +954,15 @@ static int uvd_v6_0_set_clockgating_state(void *handle,
|
|||
enum amd_clockgating_state state)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
|
||||
static int curstate = -1;
|
||||
|
||||
if (adev->asic_type == CHIP_FIJI ||
|
||||
adev->asic_type == CHIP_POLARIS10)
|
||||
uvd_v6_set_bypass_mode(adev, enable);
|
||||
adev->asic_type == CHIP_POLARIS10)
|
||||
uvd_v6_set_bypass_mode(adev, state == AMD_CG_STATE_GATE ? true : false);
|
||||
|
||||
if (!(adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG))
|
||||
return 0;
|
||||
|
||||
if (curstate == state)
|
||||
return 0;
|
||||
|
||||
curstate = state;
|
||||
if (enable) {
|
||||
if (state == AMD_CG_STATE_GATE) {
|
||||
/* disable HW gating and enable Sw gating */
|
||||
uvd_v6_0_set_sw_clock_gating(adev);
|
||||
} else {
|
||||
|
@ -946,6 +992,8 @@ static int uvd_v6_0_set_powergating_state(void *handle,
|
|||
if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
|
||||
return 0;
|
||||
|
||||
WREG32(mmUVD_POWER_STATUS, UVD_POWER_STATUS__UVD_PG_EN_MASK);
|
||||
|
||||
if (state == AMD_PG_STATE_GATE) {
|
||||
uvd_v6_0_stop(adev);
|
||||
return 0;
|
||||
|
@ -966,7 +1014,10 @@ const struct amd_ip_funcs uvd_v6_0_ip_funcs = {
|
|||
.resume = uvd_v6_0_resume,
|
||||
.is_idle = uvd_v6_0_is_idle,
|
||||
.wait_for_idle = uvd_v6_0_wait_for_idle,
|
||||
.check_soft_reset = uvd_v6_0_check_soft_reset,
|
||||
.pre_soft_reset = uvd_v6_0_pre_soft_reset,
|
||||
.soft_reset = uvd_v6_0_soft_reset,
|
||||
.post_soft_reset = uvd_v6_0_post_soft_reset,
|
||||
.set_clockgating_state = uvd_v6_0_set_clockgating_state,
|
||||
.set_powergating_state = uvd_v6_0_set_powergating_state,
|
||||
};
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define VCE_V2_0_FW_SIZE (256 * 1024)
|
||||
#define VCE_V2_0_STACK_SIZE (64 * 1024)
|
||||
#define VCE_V2_0_DATA_SIZE (23552 * AMDGPU_MAX_VCE_HANDLES)
|
||||
#define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02
|
||||
|
||||
static void vce_v2_0_mc_resume(struct amdgpu_device *adev);
|
||||
static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev);
|
||||
|
@ -96,6 +97,49 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
|
|||
WREG32(mmVCE_RB_WPTR2, ring->wptr);
|
||||
}
|
||||
|
||||
static int vce_v2_0_lmi_clean(struct amdgpu_device *adev)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
for (j = 0; j < 100; ++j) {
|
||||
uint32_t status = RREG32(mmVCE_LMI_STATUS);
|
||||
|
||||
if (status & 0x337f)
|
||||
return 0;
|
||||
mdelay(10);
|
||||
}
|
||||
}
|
||||
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static int vce_v2_0_firmware_loaded(struct amdgpu_device *adev)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
for (j = 0; j < 100; ++j) {
|
||||
uint32_t status = RREG32(mmVCE_STATUS);
|
||||
|
||||
if (status & VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK)
|
||||
return 0;
|
||||
mdelay(10);
|
||||
}
|
||||
|
||||
DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
|
||||
WREG32_P(mmVCE_SOFT_RESET,
|
||||
VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
|
||||
~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
mdelay(10);
|
||||
WREG32_P(mmVCE_SOFT_RESET, 0,
|
||||
~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
mdelay(10);
|
||||
}
|
||||
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
/**
|
||||
* vce_v2_0_start - start VCE block
|
||||
*
|
||||
|
@ -106,7 +150,7 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
|
|||
static int vce_v2_0_start(struct amdgpu_device *adev)
|
||||
{
|
||||
struct amdgpu_ring *ring;
|
||||
int i, j, r;
|
||||
int r;
|
||||
|
||||
vce_v2_0_mc_resume(adev);
|
||||
|
||||
|
@ -127,36 +171,12 @@ static int vce_v2_0_start(struct amdgpu_device *adev)
|
|||
WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
|
||||
WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
|
||||
|
||||
WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);
|
||||
|
||||
WREG32_P(mmVCE_SOFT_RESET,
|
||||
VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
|
||||
~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
|
||||
WREG32_FIELD(VCE_VCPU_CNTL, CLK_EN, 1);
|
||||
WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 1);
|
||||
mdelay(100);
|
||||
WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 0);
|
||||
|
||||
WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
uint32_t status;
|
||||
for (j = 0; j < 100; ++j) {
|
||||
status = RREG32(mmVCE_STATUS);
|
||||
if (status & 2)
|
||||
break;
|
||||
mdelay(10);
|
||||
}
|
||||
r = 0;
|
||||
if (status & 2)
|
||||
break;
|
||||
|
||||
DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
|
||||
WREG32_P(mmVCE_SOFT_RESET, VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
|
||||
~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
mdelay(10);
|
||||
WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
mdelay(10);
|
||||
r = -1;
|
||||
}
|
||||
r = vce_v2_0_firmware_loaded(adev);
|
||||
|
||||
/* clear BUSY flag */
|
||||
WREG32_P(mmVCE_STATUS, 0, ~1);
|
||||
|
@ -338,47 +358,50 @@ static void vce_v2_0_set_sw_cg(struct amdgpu_device *adev, bool gated)
|
|||
|
||||
static void vce_v2_0_set_dyn_cg(struct amdgpu_device *adev, bool gated)
|
||||
{
|
||||
u32 orig, tmp;
|
||||
|
||||
if (gated) {
|
||||
if (vce_v2_0_wait_for_idle(adev)) {
|
||||
DRM_INFO("VCE is busy, Can't set clock gateing");
|
||||
return;
|
||||
}
|
||||
WREG32_P(mmVCE_VCPU_CNTL, 0, ~VCE_VCPU_CNTL__CLK_EN_MASK);
|
||||
WREG32_P(mmVCE_SOFT_RESET, VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
mdelay(100);
|
||||
WREG32(mmVCE_STATUS, 0);
|
||||
} else {
|
||||
WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);
|
||||
WREG32_P(mmVCE_SOFT_RESET, VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
mdelay(100);
|
||||
if (vce_v2_0_wait_for_idle(adev)) {
|
||||
DRM_INFO("VCE is busy, Can't set clock gateing");
|
||||
return;
|
||||
}
|
||||
|
||||
tmp = RREG32(mmVCE_CLOCK_GATING_B);
|
||||
tmp &= ~0x00060006;
|
||||
if (gated) {
|
||||
tmp |= 0xe10000;
|
||||
} else {
|
||||
tmp |= 0xe1;
|
||||
tmp &= ~0xe10000;
|
||||
WREG32_P(mmVCE_LMI_CTRL2, 0x100, ~0x100);
|
||||
|
||||
if (vce_v2_0_lmi_clean(adev)) {
|
||||
DRM_INFO("LMI is busy, Can't set clock gateing");
|
||||
return;
|
||||
}
|
||||
WREG32(mmVCE_CLOCK_GATING_B, tmp);
|
||||
|
||||
orig = tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
|
||||
tmp &= ~0x1fe000;
|
||||
tmp &= ~0xff000000;
|
||||
if (tmp != orig)
|
||||
WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
|
||||
|
||||
orig = tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
|
||||
tmp &= ~0x3fc;
|
||||
if (tmp != orig)
|
||||
WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
|
||||
WREG32_P(mmVCE_VCPU_CNTL, 0, ~VCE_VCPU_CNTL__CLK_EN_MASK);
|
||||
WREG32_P(mmVCE_SOFT_RESET,
|
||||
VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
|
||||
~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
WREG32(mmVCE_STATUS, 0);
|
||||
|
||||
if (gated)
|
||||
WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
|
||||
WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
/* LMI_MC/LMI_UMC always set in dynamic, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {0, 0} */
|
||||
if (gated) {
|
||||
/* Force CLOCK OFF , set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {*, 1} */
|
||||
WREG32(mmVCE_CLOCK_GATING_B, 0xe90010);
|
||||
} else {
|
||||
/* Force CLOCK ON, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {1, 0} */
|
||||
WREG32(mmVCE_CLOCK_GATING_B, 0x800f1);
|
||||
}
|
||||
|
||||
/* Set VCE_UENC_CLOCK_GATING always in dynamic mode {*_FORCE_ON, *_FORCE_OFF} = {0, 0}*/;
|
||||
WREG32(mmVCE_UENC_CLOCK_GATING, 0x40);
|
||||
|
||||
/* set VCE_UENC_REG_CLOCK_GATING always in dynamic mode */
|
||||
WREG32(mmVCE_UENC_REG_CLOCK_GATING, 0x00);
|
||||
|
||||
WREG32_P(mmVCE_LMI_CTRL2, 0, ~0x100);
|
||||
if(!gated) {
|
||||
WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);
|
||||
mdelay(100);
|
||||
WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
|
||||
vce_v2_0_firmware_loaded(adev);
|
||||
WREG32_P(mmVCE_STATUS, 0, ~VCE_STATUS__JOB_BUSY_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
static void vce_v2_0_disable_cg(struct amdgpu_device *adev)
|
||||
|
@ -458,9 +481,7 @@ static void vce_v2_0_mc_resume(struct amdgpu_device *adev)
|
|||
WREG32(mmVCE_VCPU_CACHE_SIZE2, size);
|
||||
|
||||
WREG32_P(mmVCE_LMI_CTRL2, 0x0, ~0x100);
|
||||
|
||||
WREG32_P(mmVCE_SYS_INT_EN, VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK,
|
||||
~VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK);
|
||||
WREG32_FIELD(VCE_SYS_INT_EN, VCE_SYS_INT_TRAP_INTERRUPT_EN, 1);
|
||||
|
||||
vce_v2_0_init_cg(adev);
|
||||
}
|
||||
|
@ -474,11 +495,11 @@ static bool vce_v2_0_is_idle(void *handle)
|
|||
|
||||
static int vce_v2_0_wait_for_idle(void *handle)
|
||||
{
|
||||
unsigned i;
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < adev->usec_timeout; i++) {
|
||||
if (!(RREG32(mmSRBM_STATUS2) & SRBM_STATUS2__VCE_BUSY_MASK))
|
||||
if (vce_v2_0_is_idle(handle))
|
||||
return 0;
|
||||
}
|
||||
return -ETIMEDOUT;
|
||||
|
@ -488,8 +509,7 @@ static int vce_v2_0_soft_reset(void *handle)
|
|||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
WREG32_P(mmSRBM_SOFT_RESET, SRBM_SOFT_RESET__SOFT_RESET_VCE_MASK,
|
||||
~SRBM_SOFT_RESET__SOFT_RESET_VCE_MASK);
|
||||
WREG32_FIELD(SRBM_SOFT_RESET, SOFT_RESET_VCE, 1);
|
||||
mdelay(5);
|
||||
|
||||
return vce_v2_0_start(adev);
|
||||
|
@ -516,10 +536,8 @@ static int vce_v2_0_process_interrupt(struct amdgpu_device *adev,
|
|||
DRM_DEBUG("IH: VCE\n");
|
||||
switch (entry->src_data) {
|
||||
case 0:
|
||||
amdgpu_fence_process(&adev->vce.ring[0]);
|
||||
break;
|
||||
case 1:
|
||||
amdgpu_fence_process(&adev->vce.ring[1]);
|
||||
amdgpu_fence_process(&adev->vce.ring[entry->src_data]);
|
||||
break;
|
||||
default:
|
||||
DRM_ERROR("Unhandled interrupt: %d %d\n",
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
#include "gca/gfx_8_0_d.h"
|
||||
#include "smu/smu_7_1_2_d.h"
|
||||
#include "smu/smu_7_1_2_sh_mask.h"
|
||||
#include "gca/gfx_8_0_d.h"
|
||||
#include "gca/gfx_8_0_sh_mask.h"
|
||||
|
||||
|
||||
#define GRBM_GFX_INDEX__VCE_INSTANCE__SHIFT 0x04
|
||||
#define GRBM_GFX_INDEX__VCE_INSTANCE_MASK 0x10
|
||||
|
@ -107,102 +110,72 @@ static void vce_v3_0_ring_set_wptr(struct amdgpu_ring *ring)
|
|||
|
||||
static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device *adev, bool override)
|
||||
{
|
||||
u32 tmp, data;
|
||||
|
||||
tmp = data = RREG32(mmVCE_RB_ARB_CTRL);
|
||||
if (override)
|
||||
data |= VCE_RB_ARB_CTRL__VCE_CGTT_OVERRIDE_MASK;
|
||||
else
|
||||
data &= ~VCE_RB_ARB_CTRL__VCE_CGTT_OVERRIDE_MASK;
|
||||
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_RB_ARB_CTRL, data);
|
||||
WREG32_FIELD(VCE_RB_ARB_CTRL, VCE_CGTT_OVERRIDE, override ? 1 : 0);
|
||||
}
|
||||
|
||||
static void vce_v3_0_set_vce_sw_clock_gating(struct amdgpu_device *adev,
|
||||
bool gated)
|
||||
{
|
||||
u32 tmp, data;
|
||||
u32 data;
|
||||
|
||||
/* Set Override to disable Clock Gating */
|
||||
vce_v3_0_override_vce_clock_gating(adev, true);
|
||||
|
||||
if (!gated) {
|
||||
/* Force CLOCK ON for VCE_CLOCK_GATING_B,
|
||||
* {*_FORCE_ON, *_FORCE_OFF} = {1, 0}
|
||||
* VREG can be FORCE ON or set to Dynamic, but can't be OFF
|
||||
*/
|
||||
tmp = data = RREG32(mmVCE_CLOCK_GATING_B);
|
||||
/* This function enables MGCG which is controlled by firmware.
|
||||
With the clocks in the gated state the core is still
|
||||
accessible but the firmware will throttle the clocks on the
|
||||
fly as necessary.
|
||||
*/
|
||||
if (gated) {
|
||||
data = RREG32(mmVCE_CLOCK_GATING_B);
|
||||
data |= 0x1ff;
|
||||
data &= ~0xef0000;
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_CLOCK_GATING_B, data);
|
||||
WREG32(mmVCE_CLOCK_GATING_B, data);
|
||||
|
||||
/* Force CLOCK ON for VCE_UENC_CLOCK_GATING,
|
||||
* {*_FORCE_ON, *_FORCE_OFF} = {1, 0}
|
||||
*/
|
||||
tmp = data = RREG32(mmVCE_UENC_CLOCK_GATING);
|
||||
data = RREG32(mmVCE_UENC_CLOCK_GATING);
|
||||
data |= 0x3ff000;
|
||||
data &= ~0xffc00000;
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_UENC_CLOCK_GATING, data);
|
||||
WREG32(mmVCE_UENC_CLOCK_GATING, data);
|
||||
|
||||
/* set VCE_UENC_CLOCK_GATING_2 */
|
||||
tmp = data = RREG32(mmVCE_UENC_CLOCK_GATING_2);
|
||||
data = RREG32(mmVCE_UENC_CLOCK_GATING_2);
|
||||
data |= 0x2;
|
||||
data &= ~0x2;
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_UENC_CLOCK_GATING_2, data);
|
||||
data &= ~0x00010000;
|
||||
WREG32(mmVCE_UENC_CLOCK_GATING_2, data);
|
||||
|
||||
/* Force CLOCK ON for VCE_UENC_REG_CLOCK_GATING */
|
||||
tmp = data = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
|
||||
data = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
|
||||
data |= 0x37f;
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_UENC_REG_CLOCK_GATING, data);
|
||||
WREG32(mmVCE_UENC_REG_CLOCK_GATING, data);
|
||||
|
||||
/* Force VCE_UENC_DMA_DCLK_CTRL Clock ON */
|
||||
tmp = data = RREG32(mmVCE_UENC_DMA_DCLK_CTRL);
|
||||
data = RREG32(mmVCE_UENC_DMA_DCLK_CTRL);
|
||||
data |= VCE_UENC_DMA_DCLK_CTRL__WRDMCLK_FORCEON_MASK |
|
||||
VCE_UENC_DMA_DCLK_CTRL__RDDMCLK_FORCEON_MASK |
|
||||
VCE_UENC_DMA_DCLK_CTRL__REGCLK_FORCEON_MASK |
|
||||
0x8;
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_UENC_DMA_DCLK_CTRL, data);
|
||||
VCE_UENC_DMA_DCLK_CTRL__RDDMCLK_FORCEON_MASK |
|
||||
VCE_UENC_DMA_DCLK_CTRL__REGCLK_FORCEON_MASK |
|
||||
0x8;
|
||||
WREG32(mmVCE_UENC_DMA_DCLK_CTRL, data);
|
||||
} else {
|
||||
/* Force CLOCK OFF for VCE_CLOCK_GATING_B,
|
||||
* {*, *_FORCE_OFF} = {*, 1}
|
||||
* set VREG to Dynamic, as it can't be OFF
|
||||
*/
|
||||
tmp = data = RREG32(mmVCE_CLOCK_GATING_B);
|
||||
data = RREG32(mmVCE_CLOCK_GATING_B);
|
||||
data &= ~0x80010;
|
||||
data |= 0xe70008;
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_CLOCK_GATING_B, data);
|
||||
/* Force CLOCK OFF for VCE_UENC_CLOCK_GATING,
|
||||
* Force ClOCK OFF takes precedent over Force CLOCK ON setting.
|
||||
* {*_FORCE_ON, *_FORCE_OFF} = {*, 1}
|
||||
*/
|
||||
tmp = data = RREG32(mmVCE_UENC_CLOCK_GATING);
|
||||
WREG32(mmVCE_CLOCK_GATING_B, data);
|
||||
|
||||
data = RREG32(mmVCE_UENC_CLOCK_GATING);
|
||||
data |= 0xffc00000;
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_UENC_CLOCK_GATING, data);
|
||||
/* Set VCE_UENC_CLOCK_GATING_2 */
|
||||
tmp = data = RREG32(mmVCE_UENC_CLOCK_GATING_2);
|
||||
WREG32(mmVCE_UENC_CLOCK_GATING, data);
|
||||
|
||||
data = RREG32(mmVCE_UENC_CLOCK_GATING_2);
|
||||
data |= 0x10000;
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_UENC_CLOCK_GATING_2, data);
|
||||
/* Set VCE_UENC_REG_CLOCK_GATING to dynamic */
|
||||
tmp = data = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
|
||||
WREG32(mmVCE_UENC_CLOCK_GATING_2, data);
|
||||
|
||||
data = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
|
||||
data &= ~0xffc00000;
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_UENC_REG_CLOCK_GATING, data);
|
||||
/* Set VCE_UENC_DMA_DCLK_CTRL CG always in dynamic mode */
|
||||
tmp = data = RREG32(mmVCE_UENC_DMA_DCLK_CTRL);
|
||||
WREG32(mmVCE_UENC_REG_CLOCK_GATING, data);
|
||||
|
||||
data = RREG32(mmVCE_UENC_DMA_DCLK_CTRL);
|
||||
data &= ~(VCE_UENC_DMA_DCLK_CTRL__WRDMCLK_FORCEON_MASK |
|
||||
VCE_UENC_DMA_DCLK_CTRL__RDDMCLK_FORCEON_MASK |
|
||||
VCE_UENC_DMA_DCLK_CTRL__REGCLK_FORCEON_MASK |
|
||||
0x8);
|
||||
if (tmp != data)
|
||||
WREG32(mmVCE_UENC_DMA_DCLK_CTRL, data);
|
||||
VCE_UENC_DMA_DCLK_CTRL__RDDMCLK_FORCEON_MASK |
|
||||
VCE_UENC_DMA_DCLK_CTRL__REGCLK_FORCEON_MASK |
|
||||
0x8);
|
||||
WREG32(mmVCE_UENC_DMA_DCLK_CTRL, data);
|
||||
}
|
||||
vce_v3_0_override_vce_clock_gating(adev, false);
|
||||
}
|
||||
|
@ -221,12 +194,9 @@ static int vce_v3_0_firmware_loaded(struct amdgpu_device *adev)
|
|||
}
|
||||
|
||||
DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
|
||||
WREG32_P(mmVCE_SOFT_RESET,
|
||||
VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
|
||||
~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 1);
|
||||
mdelay(10);
|
||||
WREG32_P(mmVCE_SOFT_RESET, 0,
|
||||
~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 0);
|
||||
mdelay(10);
|
||||
}
|
||||
|
||||
|
@ -264,38 +234,22 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
|
|||
if (adev->vce.harvest_config & (1 << idx))
|
||||
continue;
|
||||
|
||||
if (idx == 0)
|
||||
WREG32_P(mmGRBM_GFX_INDEX, 0,
|
||||
~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
|
||||
else
|
||||
WREG32_P(mmGRBM_GFX_INDEX,
|
||||
GRBM_GFX_INDEX__VCE_INSTANCE_MASK,
|
||||
~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
|
||||
|
||||
WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, idx);
|
||||
vce_v3_0_mc_resume(adev, idx);
|
||||
|
||||
WREG32_P(mmVCE_STATUS, VCE_STATUS__JOB_BUSY_MASK,
|
||||
~VCE_STATUS__JOB_BUSY_MASK);
|
||||
WREG32_FIELD(VCE_STATUS, JOB_BUSY, 1);
|
||||
|
||||
if (adev->asic_type >= CHIP_STONEY)
|
||||
WREG32_P(mmVCE_VCPU_CNTL, 1, ~0x200001);
|
||||
else
|
||||
WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK,
|
||||
~VCE_VCPU_CNTL__CLK_EN_MASK);
|
||||
|
||||
WREG32_P(mmVCE_SOFT_RESET, 0,
|
||||
~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
WREG32_FIELD(VCE_VCPU_CNTL, CLK_EN, 1);
|
||||
|
||||
WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 0);
|
||||
mdelay(100);
|
||||
|
||||
r = vce_v3_0_firmware_loaded(adev);
|
||||
|
||||
/* clear BUSY flag */
|
||||
WREG32_P(mmVCE_STATUS, 0, ~VCE_STATUS__JOB_BUSY_MASK);
|
||||
|
||||
/* Set Clock-Gating off */
|
||||
if (adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)
|
||||
vce_v3_0_set_vce_sw_clock_gating(adev, false);
|
||||
WREG32_FIELD(VCE_STATUS, JOB_BUSY, 0);
|
||||
|
||||
if (r) {
|
||||
DRM_ERROR("VCE not responding, giving up!!!\n");
|
||||
|
@ -304,7 +258,7 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
|
|||
}
|
||||
}
|
||||
|
||||
WREG32_P(mmGRBM_GFX_INDEX, 0, ~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
|
||||
WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, 0);
|
||||
mutex_unlock(&adev->grbm_idx_mutex);
|
||||
|
||||
return 0;
|
||||
|
@ -319,33 +273,25 @@ static int vce_v3_0_stop(struct amdgpu_device *adev)
|
|||
if (adev->vce.harvest_config & (1 << idx))
|
||||
continue;
|
||||
|
||||
if (idx == 0)
|
||||
WREG32_P(mmGRBM_GFX_INDEX, 0,
|
||||
~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
|
||||
else
|
||||
WREG32_P(mmGRBM_GFX_INDEX,
|
||||
GRBM_GFX_INDEX__VCE_INSTANCE_MASK,
|
||||
~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
|
||||
WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, idx);
|
||||
|
||||
if (adev->asic_type >= CHIP_STONEY)
|
||||
WREG32_P(mmVCE_VCPU_CNTL, 0, ~0x200001);
|
||||
else
|
||||
WREG32_P(mmVCE_VCPU_CNTL, 0,
|
||||
~VCE_VCPU_CNTL__CLK_EN_MASK);
|
||||
WREG32_FIELD(VCE_VCPU_CNTL, CLK_EN, 0);
|
||||
|
||||
/* hold on ECPU */
|
||||
WREG32_P(mmVCE_SOFT_RESET,
|
||||
VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
|
||||
~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
|
||||
WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 1);
|
||||
|
||||
/* clear BUSY flag */
|
||||
WREG32_P(mmVCE_STATUS, 0, ~VCE_STATUS__JOB_BUSY_MASK);
|
||||
WREG32_FIELD(VCE_STATUS, JOB_BUSY, 0);
|
||||
|
||||
/* Set Clock-Gating off */
|
||||
if (adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)
|
||||
vce_v3_0_set_vce_sw_clock_gating(adev, false);
|
||||
}
|
||||
|
||||
WREG32_P(mmGRBM_GFX_INDEX, 0, ~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
|
||||
WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, 0);
|
||||
mutex_unlock(&adev->grbm_idx_mutex);
|
||||
|
||||
return 0;
|
||||
|
@ -534,7 +480,7 @@ static void vce_v3_0_mc_resume(struct amdgpu_device *adev, int idx)
|
|||
WREG32_P(mmVCE_CLOCK_GATING_A, 0, ~(1 << 16));
|
||||
WREG32_P(mmVCE_UENC_CLOCK_GATING, 0x1FF000, ~0xFF9FF000);
|
||||
WREG32_P(mmVCE_UENC_REG_CLOCK_GATING, 0x3F, ~0x3F);
|
||||
WREG32(mmVCE_CLOCK_GATING_B, 0xf7);
|
||||
WREG32(mmVCE_CLOCK_GATING_B, 0x1FF);
|
||||
|
||||
WREG32(mmVCE_LMI_CTRL, 0x00398000);
|
||||
WREG32_P(mmVCE_LMI_CACHE_CTRL, 0x0, ~0x1);
|
||||
|
@ -573,9 +519,7 @@ static void vce_v3_0_mc_resume(struct amdgpu_device *adev, int idx)
|
|||
}
|
||||
|
||||
WREG32_P(mmVCE_LMI_CTRL2, 0x0, ~0x100);
|
||||
|
||||
WREG32_P(mmVCE_SYS_INT_EN, VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK,
|
||||
~VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK);
|
||||
WREG32_FIELD(VCE_SYS_INT_EN, VCE_SYS_INT_TRAP_INTERRUPT_EN, 1);
|
||||
}
|
||||
|
||||
static bool vce_v3_0_is_idle(void *handle)
|
||||
|
@ -601,20 +545,108 @@ static int vce_v3_0_wait_for_idle(void *handle)
|
|||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
#define VCE_STATUS_VCPU_REPORT_AUTO_BUSY_MASK 0x00000008L /* AUTO_BUSY */
|
||||
#define VCE_STATUS_VCPU_REPORT_RB0_BUSY_MASK 0x00000010L /* RB0_BUSY */
|
||||
#define VCE_STATUS_VCPU_REPORT_RB1_BUSY_MASK 0x00000020L /* RB1_BUSY */
|
||||
#define AMDGPU_VCE_STATUS_BUSY_MASK (VCE_STATUS_VCPU_REPORT_AUTO_BUSY_MASK | \
|
||||
VCE_STATUS_VCPU_REPORT_RB0_BUSY_MASK)
|
||||
|
||||
static int vce_v3_0_check_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 srbm_soft_reset = 0;
|
||||
|
||||
/* According to VCE team , we should use VCE_STATUS instead
|
||||
* SRBM_STATUS.VCE_BUSY bit for busy status checking.
|
||||
* GRBM_GFX_INDEX.INSTANCE_INDEX is used to specify which VCE
|
||||
* instance's registers are accessed
|
||||
* (0 for 1st instance, 10 for 2nd instance).
|
||||
*
|
||||
*VCE_STATUS
|
||||
*|UENC|ACPI|AUTO ACTIVE|RB1 |RB0 |RB2 | |FW_LOADED|JOB |
|
||||
*|----+----+-----------+----+----+----+----------+---------+----|
|
||||
*|bit8|bit7| bit6 |bit5|bit4|bit3| bit2 | bit1 |bit0|
|
||||
*
|
||||
* VCE team suggest use bit 3--bit 6 for busy status check
|
||||
*/
|
||||
mutex_lock(&adev->grbm_idx_mutex);
|
||||
WREG32_FIELD(GRBM_GFX_INDEX, INSTANCE_INDEX, 0);
|
||||
if (RREG32(mmVCE_STATUS) & AMDGPU_VCE_STATUS_BUSY_MASK) {
|
||||
srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE0, 1);
|
||||
srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE1, 1);
|
||||
}
|
||||
WREG32_FIELD(GRBM_GFX_INDEX, INSTANCE_INDEX, 0x10);
|
||||
if (RREG32(mmVCE_STATUS) & AMDGPU_VCE_STATUS_BUSY_MASK) {
|
||||
srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE0, 1);
|
||||
srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset, SRBM_SOFT_RESET, SOFT_RESET_VCE1, 1);
|
||||
}
|
||||
WREG32_FIELD(GRBM_GFX_INDEX, INSTANCE_INDEX, 0);
|
||||
|
||||
if (srbm_soft_reset) {
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_VCE].hang = true;
|
||||
adev->vce.srbm_soft_reset = srbm_soft_reset;
|
||||
} else {
|
||||
adev->ip_block_status[AMD_IP_BLOCK_TYPE_VCE].hang = false;
|
||||
adev->vce.srbm_soft_reset = 0;
|
||||
}
|
||||
mutex_unlock(&adev->grbm_idx_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vce_v3_0_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
u32 mask = 0;
|
||||
u32 srbm_soft_reset;
|
||||
|
||||
mask |= (adev->vce.harvest_config & AMDGPU_VCE_HARVEST_VCE0) ? 0 : SRBM_SOFT_RESET__SOFT_RESET_VCE0_MASK;
|
||||
mask |= (adev->vce.harvest_config & AMDGPU_VCE_HARVEST_VCE1) ? 0 : SRBM_SOFT_RESET__SOFT_RESET_VCE1_MASK;
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_VCE].hang)
|
||||
return 0;
|
||||
srbm_soft_reset = adev->vce.srbm_soft_reset;
|
||||
|
||||
if (srbm_soft_reset) {
|
||||
u32 tmp;
|
||||
|
||||
tmp = RREG32(mmSRBM_SOFT_RESET);
|
||||
tmp |= srbm_soft_reset;
|
||||
dev_info(adev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp);
|
||||
WREG32(mmSRBM_SOFT_RESET, tmp);
|
||||
tmp = RREG32(mmSRBM_SOFT_RESET);
|
||||
|
||||
udelay(50);
|
||||
|
||||
tmp &= ~srbm_soft_reset;
|
||||
WREG32(mmSRBM_SOFT_RESET, tmp);
|
||||
tmp = RREG32(mmSRBM_SOFT_RESET);
|
||||
|
||||
/* Wait a little for things to settle down */
|
||||
udelay(50);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vce_v3_0_pre_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_VCE].hang)
|
||||
return 0;
|
||||
|
||||
WREG32_P(mmSRBM_SOFT_RESET, mask,
|
||||
~(SRBM_SOFT_RESET__SOFT_RESET_VCE0_MASK |
|
||||
SRBM_SOFT_RESET__SOFT_RESET_VCE1_MASK));
|
||||
mdelay(5);
|
||||
|
||||
return vce_v3_0_start(adev);
|
||||
return vce_v3_0_suspend(adev);
|
||||
}
|
||||
|
||||
|
||||
static int vce_v3_0_post_soft_reset(void *handle)
|
||||
{
|
||||
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
|
||||
|
||||
if (!adev->ip_block_status[AMD_IP_BLOCK_TYPE_VCE].hang)
|
||||
return 0;
|
||||
|
||||
mdelay(5);
|
||||
|
||||
return vce_v3_0_resume(adev);
|
||||
}
|
||||
|
||||
static int vce_v3_0_set_interrupt_state(struct amdgpu_device *adev,
|
||||
|
@ -637,9 +669,7 @@ static int vce_v3_0_process_interrupt(struct amdgpu_device *adev,
|
|||
{
|
||||
DRM_DEBUG("IH: VCE\n");
|
||||
|
||||
WREG32_P(mmVCE_SYS_INT_STATUS,
|
||||
VCE_SYS_INT_STATUS__VCE_SYS_INT_TRAP_INTERRUPT_INT_MASK,
|
||||
~VCE_SYS_INT_STATUS__VCE_SYS_INT_TRAP_INTERRUPT_INT_MASK);
|
||||
WREG32_FIELD(VCE_SYS_INT_STATUS, VCE_SYS_INT_TRAP_INTERRUPT_INT, 1);
|
||||
|
||||
switch (entry->src_data) {
|
||||
case 0:
|
||||
|
@ -686,13 +716,7 @@ static int vce_v3_0_set_clockgating_state(void *handle,
|
|||
if (adev->vce.harvest_config & (1 << i))
|
||||
continue;
|
||||
|
||||
if (i == 0)
|
||||
WREG32_P(mmGRBM_GFX_INDEX, 0,
|
||||
~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
|
||||
else
|
||||
WREG32_P(mmGRBM_GFX_INDEX,
|
||||
GRBM_GFX_INDEX__VCE_INSTANCE_MASK,
|
||||
~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
|
||||
WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, i);
|
||||
|
||||
if (enable) {
|
||||
/* initialize VCE_CLOCK_GATING_A: Clock ON/OFF delay */
|
||||
|
@ -711,7 +735,7 @@ static int vce_v3_0_set_clockgating_state(void *handle,
|
|||
vce_v3_0_set_vce_sw_clock_gating(adev, enable);
|
||||
}
|
||||
|
||||
WREG32_P(mmGRBM_GFX_INDEX, 0, ~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
|
||||
WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, 0);
|
||||
mutex_unlock(&adev->grbm_idx_mutex);
|
||||
|
||||
return 0;
|
||||
|
@ -751,7 +775,10 @@ const struct amd_ip_funcs vce_v3_0_ip_funcs = {
|
|||
.resume = vce_v3_0_resume,
|
||||
.is_idle = vce_v3_0_is_idle,
|
||||
.wait_for_idle = vce_v3_0_wait_for_idle,
|
||||
.check_soft_reset = vce_v3_0_check_soft_reset,
|
||||
.pre_soft_reset = vce_v3_0_pre_soft_reset,
|
||||
.soft_reset = vce_v3_0_soft_reset,
|
||||
.post_soft_reset = vce_v3_0_post_soft_reset,
|
||||
.set_clockgating_state = vce_v3_0_set_clockgating_state,
|
||||
.set_powergating_state = vce_v3_0_set_powergating_state,
|
||||
};
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
#if defined(CONFIG_DRM_AMD_ACP)
|
||||
#include "amdgpu_acp.h"
|
||||
#endif
|
||||
#include "dce_virtual.h"
|
||||
|
||||
MODULE_FIRMWARE("amdgpu/polaris10_smc.bin");
|
||||
MODULE_FIRMWARE("amdgpu/polaris10_smc_sk.bin");
|
||||
|
@ -822,6 +823,60 @@ static const struct amdgpu_ip_block_version topaz_ip_blocks[] =
|
|||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version topaz_ip_blocks_vd[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_COMMON,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vi_common_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GMC,
|
||||
.major = 7,
|
||||
.minor = 4,
|
||||
.rev = 0,
|
||||
.funcs = &gmc_v7_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_IH,
|
||||
.major = 2,
|
||||
.minor = 4,
|
||||
.rev = 0,
|
||||
.funcs = &iceland_ih_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SMC,
|
||||
.major = 7,
|
||||
.minor = 1,
|
||||
.rev = 0,
|
||||
.funcs = &amdgpu_pp_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_DCE,
|
||||
.major = 1,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &dce_virtual_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GFX,
|
||||
.major = 8,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gfx_v8_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SDMA,
|
||||
.major = 2,
|
||||
.minor = 4,
|
||||
.rev = 0,
|
||||
.funcs = &sdma_v2_4_ip_funcs,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version tonga_ip_blocks[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
|
@ -890,6 +945,74 @@ static const struct amdgpu_ip_block_version tonga_ip_blocks[] =
|
|||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version tonga_ip_blocks_vd[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_COMMON,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vi_common_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GMC,
|
||||
.major = 8,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gmc_v8_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_IH,
|
||||
.major = 3,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &tonga_ih_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SMC,
|
||||
.major = 7,
|
||||
.minor = 1,
|
||||
.rev = 0,
|
||||
.funcs = &amdgpu_pp_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_DCE,
|
||||
.major = 10,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &dce_virtual_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GFX,
|
||||
.major = 8,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gfx_v8_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SDMA,
|
||||
.major = 3,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &sdma_v3_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_UVD,
|
||||
.major = 5,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &uvd_v5_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_VCE,
|
||||
.major = 3,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vce_v3_0_ip_funcs,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version fiji_ip_blocks[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
|
@ -958,6 +1081,74 @@ static const struct amdgpu_ip_block_version fiji_ip_blocks[] =
|
|||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version fiji_ip_blocks_vd[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_COMMON,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vi_common_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GMC,
|
||||
.major = 8,
|
||||
.minor = 5,
|
||||
.rev = 0,
|
||||
.funcs = &gmc_v8_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_IH,
|
||||
.major = 3,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &tonga_ih_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SMC,
|
||||
.major = 7,
|
||||
.minor = 1,
|
||||
.rev = 0,
|
||||
.funcs = &amdgpu_pp_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_DCE,
|
||||
.major = 10,
|
||||
.minor = 1,
|
||||
.rev = 0,
|
||||
.funcs = &dce_virtual_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GFX,
|
||||
.major = 8,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gfx_v8_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SDMA,
|
||||
.major = 3,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &sdma_v3_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_UVD,
|
||||
.major = 6,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &uvd_v6_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_VCE,
|
||||
.major = 3,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vce_v3_0_ip_funcs,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version polaris11_ip_blocks[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
|
@ -1026,6 +1217,74 @@ static const struct amdgpu_ip_block_version polaris11_ip_blocks[] =
|
|||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version polaris11_ip_blocks_vd[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_COMMON,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vi_common_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GMC,
|
||||
.major = 8,
|
||||
.minor = 1,
|
||||
.rev = 0,
|
||||
.funcs = &gmc_v8_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_IH,
|
||||
.major = 3,
|
||||
.minor = 1,
|
||||
.rev = 0,
|
||||
.funcs = &tonga_ih_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SMC,
|
||||
.major = 7,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &amdgpu_pp_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_DCE,
|
||||
.major = 11,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &dce_virtual_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GFX,
|
||||
.major = 8,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gfx_v8_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SDMA,
|
||||
.major = 3,
|
||||
.minor = 1,
|
||||
.rev = 0,
|
||||
.funcs = &sdma_v3_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_UVD,
|
||||
.major = 6,
|
||||
.minor = 3,
|
||||
.rev = 0,
|
||||
.funcs = &uvd_v6_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_VCE,
|
||||
.major = 3,
|
||||
.minor = 4,
|
||||
.rev = 0,
|
||||
.funcs = &vce_v3_0_ip_funcs,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version cz_ip_blocks[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
|
@ -1103,34 +1362,142 @@ static const struct amdgpu_ip_block_version cz_ip_blocks[] =
|
|||
#endif
|
||||
};
|
||||
|
||||
static const struct amdgpu_ip_block_version cz_ip_blocks_vd[] =
|
||||
{
|
||||
/* ORDER MATTERS! */
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_COMMON,
|
||||
.major = 2,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vi_common_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GMC,
|
||||
.major = 8,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gmc_v8_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_IH,
|
||||
.major = 3,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &cz_ih_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SMC,
|
||||
.major = 8,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &amdgpu_pp_ip_funcs
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_DCE,
|
||||
.major = 11,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &dce_virtual_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_GFX,
|
||||
.major = 8,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &gfx_v8_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_SDMA,
|
||||
.major = 3,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &sdma_v3_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_UVD,
|
||||
.major = 6,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &uvd_v6_0_ip_funcs,
|
||||
},
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_VCE,
|
||||
.major = 3,
|
||||
.minor = 0,
|
||||
.rev = 0,
|
||||
.funcs = &vce_v3_0_ip_funcs,
|
||||
},
|
||||
#if defined(CONFIG_DRM_AMD_ACP)
|
||||
{
|
||||
.type = AMD_IP_BLOCK_TYPE_ACP,
|
||||
.major = 2,
|
||||
.minor = 2,
|
||||
.rev = 0,
|
||||
.funcs = &acp_ip_funcs,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
int vi_set_ip_blocks(struct amdgpu_device *adev)
|
||||
{
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_TOPAZ:
|
||||
adev->ip_blocks = topaz_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(topaz_ip_blocks);
|
||||
break;
|
||||
case CHIP_FIJI:
|
||||
adev->ip_blocks = fiji_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks);
|
||||
break;
|
||||
case CHIP_TONGA:
|
||||
adev->ip_blocks = tonga_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks);
|
||||
break;
|
||||
case CHIP_POLARIS11:
|
||||
case CHIP_POLARIS10:
|
||||
adev->ip_blocks = polaris11_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks);
|
||||
break;
|
||||
case CHIP_CARRIZO:
|
||||
case CHIP_STONEY:
|
||||
adev->ip_blocks = cz_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks);
|
||||
break;
|
||||
default:
|
||||
/* FIXME: not supported yet */
|
||||
return -EINVAL;
|
||||
if (adev->enable_virtual_display) {
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_TOPAZ:
|
||||
adev->ip_blocks = topaz_ip_blocks_vd;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(topaz_ip_blocks_vd);
|
||||
break;
|
||||
case CHIP_FIJI:
|
||||
adev->ip_blocks = fiji_ip_blocks_vd;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks_vd);
|
||||
break;
|
||||
case CHIP_TONGA:
|
||||
adev->ip_blocks = tonga_ip_blocks_vd;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks_vd);
|
||||
break;
|
||||
case CHIP_POLARIS11:
|
||||
case CHIP_POLARIS10:
|
||||
adev->ip_blocks = polaris11_ip_blocks_vd;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks_vd);
|
||||
break;
|
||||
|
||||
case CHIP_CARRIZO:
|
||||
case CHIP_STONEY:
|
||||
adev->ip_blocks = cz_ip_blocks_vd;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks_vd);
|
||||
break;
|
||||
default:
|
||||
/* FIXME: not supported yet */
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
switch (adev->asic_type) {
|
||||
case CHIP_TOPAZ:
|
||||
adev->ip_blocks = topaz_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(topaz_ip_blocks);
|
||||
break;
|
||||
case CHIP_FIJI:
|
||||
adev->ip_blocks = fiji_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks);
|
||||
break;
|
||||
case CHIP_TONGA:
|
||||
adev->ip_blocks = tonga_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks);
|
||||
break;
|
||||
case CHIP_POLARIS11:
|
||||
case CHIP_POLARIS10:
|
||||
adev->ip_blocks = polaris11_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks);
|
||||
break;
|
||||
case CHIP_CARRIZO:
|
||||
case CHIP_STONEY:
|
||||
adev->ip_blocks = cz_ip_blocks;
|
||||
adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks);
|
||||
break;
|
||||
default:
|
||||
/* FIXME: not supported yet */
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1248,8 +1615,17 @@ static int vi_common_early_init(void *handle)
|
|||
AMD_CG_SUPPORT_HDP_MGCG |
|
||||
AMD_CG_SUPPORT_HDP_LS |
|
||||
AMD_CG_SUPPORT_SDMA_MGCG |
|
||||
AMD_CG_SUPPORT_SDMA_LS;
|
||||
AMD_CG_SUPPORT_SDMA_LS |
|
||||
AMD_CG_SUPPORT_VCE_MGCG;
|
||||
/* rev0 hardware requires workarounds to support PG */
|
||||
adev->pg_flags = 0;
|
||||
if (adev->rev_id != 0x00) {
|
||||
adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG |
|
||||
AMD_PG_SUPPORT_GFX_SMG |
|
||||
AMD_PG_SUPPORT_GFX_PIPELINE |
|
||||
AMD_PG_SUPPORT_UVD |
|
||||
AMD_PG_SUPPORT_VCE;
|
||||
}
|
||||
adev->external_rev_id = adev->rev_id + 0x1;
|
||||
break;
|
||||
case CHIP_STONEY:
|
||||
|
@ -1267,7 +1643,13 @@ static int vi_common_early_init(void *handle)
|
|||
AMD_CG_SUPPORT_HDP_MGCG |
|
||||
AMD_CG_SUPPORT_HDP_LS |
|
||||
AMD_CG_SUPPORT_SDMA_MGCG |
|
||||
AMD_CG_SUPPORT_SDMA_LS;
|
||||
AMD_CG_SUPPORT_SDMA_LS |
|
||||
AMD_CG_SUPPORT_VCE_MGCG;
|
||||
adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG |
|
||||
AMD_PG_SUPPORT_GFX_SMG |
|
||||
AMD_PG_SUPPORT_GFX_PIPELINE |
|
||||
AMD_PG_SUPPORT_UVD |
|
||||
AMD_PG_SUPPORT_VCE;
|
||||
adev->external_rev_id = adev->rev_id + 0x1;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -159,8 +159,14 @@ struct amd_ip_funcs {
|
|||
bool (*is_idle)(void *handle);
|
||||
/* poll for idle */
|
||||
int (*wait_for_idle)(void *handle);
|
||||
/* check soft reset the IP block */
|
||||
int (*check_soft_reset)(void *handle);
|
||||
/* pre soft reset the IP block */
|
||||
int (*pre_soft_reset)(void *handle);
|
||||
/* soft reset the IP block */
|
||||
int (*soft_reset)(void *handle);
|
||||
/* post soft reset the IP block */
|
||||
int (*post_soft_reset)(void *handle);
|
||||
/* enable/disable cg for the IP block */
|
||||
int (*set_clockgating_state)(void *handle,
|
||||
enum amd_clockgating_state state);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#define mmUVD_UDEC_ADDR_CONFIG 0x3bd3
|
||||
#define mmUVD_UDEC_DB_ADDR_CONFIG 0x3bd4
|
||||
#define mmUVD_UDEC_DBW_ADDR_CONFIG 0x3bd5
|
||||
#define mmUVD_NO_OP 0x3bff
|
||||
#define mmUVD_SEMA_CNTL 0x3d00
|
||||
#define mmUVD_LMI_EXT40_ADDR 0x3d26
|
||||
#define mmUVD_CTX_INDEX 0x3d28
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#define mmUVD_UDEC_ADDR_CONFIG 0x3bd3
|
||||
#define mmUVD_UDEC_DB_ADDR_CONFIG 0x3bd4
|
||||
#define mmUVD_UDEC_DBW_ADDR_CONFIG 0x3bd5
|
||||
#define mmUVD_NO_OP 0x3bff
|
||||
#define mmUVD_LMI_RBC_RB_64BIT_BAR_LOW 0x3c69
|
||||
#define mmUVD_LMI_RBC_RB_64BIT_BAR_HIGH 0x3c68
|
||||
#define mmUVD_LMI_RBC_IB_64BIT_BAR_LOW 0x3c67
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#define mmUVD_UDEC_DB_ADDR_CONFIG 0x3bd4
|
||||
#define mmUVD_UDEC_DBW_ADDR_CONFIG 0x3bd5
|
||||
#define mmUVD_POWER_STATUS_U 0x3bfd
|
||||
#define mmUVD_NO_OP 0x3bff
|
||||
#define mmUVD_LMI_RBC_RB_64BIT_BAR_LOW 0x3c69
|
||||
#define mmUVD_LMI_RBC_RB_64BIT_BAR_HIGH 0x3c68
|
||||
#define mmUVD_LMI_RBC_IB_64BIT_BAR_LOW 0x3c67
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "eventmanager.h"
|
||||
#include "pp_debug.h"
|
||||
|
||||
|
||||
#define PP_CHECK(handle) \
|
||||
do { \
|
||||
if ((handle) == NULL || (handle)->pp_valid != PP_VALID) \
|
||||
|
@ -162,12 +163,12 @@ static int pp_hw_fini(void *handle)
|
|||
pp_handle = (struct pp_instance *)handle;
|
||||
eventmgr = pp_handle->eventmgr;
|
||||
|
||||
if (eventmgr != NULL || eventmgr->pp_eventmgr_fini != NULL)
|
||||
if (eventmgr != NULL && eventmgr->pp_eventmgr_fini != NULL)
|
||||
eventmgr->pp_eventmgr_fini(eventmgr);
|
||||
|
||||
smumgr = pp_handle->smu_mgr;
|
||||
|
||||
if (smumgr != NULL || smumgr->smumgr_funcs != NULL ||
|
||||
if (smumgr != NULL && smumgr->smumgr_funcs != NULL &&
|
||||
smumgr->smumgr_funcs->smu_fini != NULL)
|
||||
smumgr->smumgr_funcs->smu_fini(smumgr);
|
||||
|
||||
|
|
|
@ -4,13 +4,15 @@
|
|||
|
||||
HARDWARE_MGR = hwmgr.o processpptables.o functiontables.o \
|
||||
hardwaremanager.o pp_acpi.o cz_hwmgr.o \
|
||||
cz_clockpowergating.o \
|
||||
cz_clockpowergating.o tonga_powertune.o\
|
||||
tonga_processpptables.o ppatomctrl.o \
|
||||
tonga_hwmgr.o pppcielanes.o tonga_thermal.o\
|
||||
fiji_powertune.o fiji_hwmgr.o tonga_clockpowergating.o \
|
||||
fiji_clockpowergating.o fiji_thermal.o \
|
||||
polaris10_hwmgr.o polaris10_powertune.o polaris10_thermal.o \
|
||||
polaris10_clockpowergating.o
|
||||
polaris10_clockpowergating.o iceland_hwmgr.o \
|
||||
iceland_clockpowergating.o iceland_thermal.o \
|
||||
iceland_powertune.o
|
||||
|
||||
AMD_PP_HWMGR = $(addprefix $(AMD_PP_PATH)/hwmgr/,$(HARDWARE_MGR))
|
||||
|
||||
|
|
|
@ -178,7 +178,6 @@ static int cz_initialize_dpm_defaults(struct pp_hwmgr *hwmgr)
|
|||
int result;
|
||||
|
||||
cz_hwmgr->gfx_ramp_step = 256*25/100;
|
||||
|
||||
cz_hwmgr->gfx_ramp_delay = 1; /* by default, we delay 1us */
|
||||
|
||||
for (i = 0; i < CZ_MAX_HARDWARE_POWERLEVELS; i++)
|
||||
|
@ -186,33 +185,19 @@ static int cz_initialize_dpm_defaults(struct pp_hwmgr *hwmgr)
|
|||
|
||||
cz_hwmgr->mgcg_cgtt_local0 = 0x00000000;
|
||||
cz_hwmgr->mgcg_cgtt_local1 = 0x00000000;
|
||||
|
||||
cz_hwmgr->clock_slow_down_freq = 25000;
|
||||
|
||||
cz_hwmgr->skip_clock_slow_down = 1;
|
||||
|
||||
cz_hwmgr->enable_nb_ps_policy = 1; /* disable until UNB is ready, Enabled */
|
||||
|
||||
cz_hwmgr->voltage_drop_in_dce_power_gating = 0; /* disable until fully verified */
|
||||
|
||||
cz_hwmgr->voting_rights_clients = 0x00C00033;
|
||||
|
||||
cz_hwmgr->static_screen_threshold = 8;
|
||||
|
||||
cz_hwmgr->ddi_power_gating_disabled = 0;
|
||||
|
||||
cz_hwmgr->bapm_enabled = 1;
|
||||
|
||||
cz_hwmgr->voltage_drop_threshold = 0;
|
||||
|
||||
cz_hwmgr->gfx_power_gating_threshold = 500;
|
||||
|
||||
cz_hwmgr->vce_slow_sclk_threshold = 20000;
|
||||
|
||||
cz_hwmgr->dce_slow_sclk_threshold = 30000;
|
||||
|
||||
cz_hwmgr->disable_driver_thermal_policy = 1;
|
||||
|
||||
cz_hwmgr->disable_nb_ps3_in_battery = 0;
|
||||
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
|
@ -221,9 +206,6 @@ static int cz_initialize_dpm_defaults(struct pp_hwmgr *hwmgr)
|
|||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_NonABMSupportInPPLib);
|
||||
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_SclkDeepSleep);
|
||||
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_DynamicM3Arbiter);
|
||||
|
||||
|
@ -233,9 +215,7 @@ static int cz_initialize_dpm_defaults(struct pp_hwmgr *hwmgr)
|
|||
PHM_PlatformCaps_DynamicPatchPowerState);
|
||||
|
||||
cz_hwmgr->thermal_auto_throttling_treshold = 0;
|
||||
|
||||
cz_hwmgr->tdr_clock = 0;
|
||||
|
||||
cz_hwmgr->disable_gfx_power_gating_in_uvd = 0;
|
||||
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
|
@ -450,19 +430,12 @@ static int cz_construct_boot_state(struct pp_hwmgr *hwmgr)
|
|||
(uint8_t)cz_hwmgr->sys_info.bootup_nb_voltage_index;
|
||||
|
||||
cz_hwmgr->boot_power_level.dsDividerIndex = 0;
|
||||
|
||||
cz_hwmgr->boot_power_level.ssDividerIndex = 0;
|
||||
|
||||
cz_hwmgr->boot_power_level.allowGnbSlow = 1;
|
||||
|
||||
cz_hwmgr->boot_power_level.forceNBPstate = 0;
|
||||
|
||||
cz_hwmgr->boot_power_level.hysteresis_up = 0;
|
||||
|
||||
cz_hwmgr->boot_power_level.numSIMDToPowerDown = 0;
|
||||
|
||||
cz_hwmgr->boot_power_level.display_wm = 0;
|
||||
|
||||
cz_hwmgr->boot_power_level.vce_wm = 0;
|
||||
|
||||
return 0;
|
||||
|
@ -749,7 +722,6 @@ static int cz_tf_update_sclk_limit(struct pp_hwmgr *hwmgr,
|
|||
cz_hwmgr->sclk_dpm.soft_max_clk = table->entries[table->count - 1].clk;
|
||||
|
||||
clock = hwmgr->display_config.min_core_set_clock;
|
||||
;
|
||||
if (clock == 0)
|
||||
printk(KERN_INFO "[ powerplay ] min_core_set_clock not set\n");
|
||||
|
||||
|
@ -832,7 +804,7 @@ static int cz_tf_set_watermark_threshold(struct pp_hwmgr *hwmgr,
|
|||
|
||||
smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
|
||||
PPSMC_MSG_SetWatermarkFrequency,
|
||||
cz_hwmgr->sclk_dpm.soft_max_clk);
|
||||
cz_hwmgr->sclk_dpm.soft_max_clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -858,9 +830,9 @@ static int cz_tf_enable_nb_dpm(struct pp_hwmgr *hwmgr,
|
|||
PP_DBG_LOG("enabling ALL SMU features.\n");
|
||||
dpm_features |= NB_DPM_MASK;
|
||||
ret = smum_send_msg_to_smc_with_parameter(
|
||||
hwmgr->smumgr,
|
||||
PPSMC_MSG_EnableAllSmuFeatures,
|
||||
dpm_features);
|
||||
hwmgr->smumgr,
|
||||
PPSMC_MSG_EnableAllSmuFeatures,
|
||||
dpm_features);
|
||||
if (ret == 0)
|
||||
cz_hwmgr->is_nb_dpm_enabled = true;
|
||||
}
|
||||
|
@ -1246,7 +1218,7 @@ static int cz_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
|
|||
|
||||
static int cz_hwmgr_backend_fini(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
if (hwmgr != NULL || hwmgr->backend != NULL) {
|
||||
if (hwmgr != NULL && hwmgr->backend != NULL) {
|
||||
kfree(hwmgr->backend);
|
||||
kfree(hwmgr);
|
||||
}
|
||||
|
@ -1402,10 +1374,12 @@ int cz_dpm_update_uvd_dpm(struct pp_hwmgr *hwmgr, bool bgate)
|
|||
PPSMC_MSG_SetUvdHardMin));
|
||||
|
||||
cz_enable_disable_uvd_dpm(hwmgr, true);
|
||||
} else
|
||||
} else {
|
||||
cz_enable_disable_uvd_dpm(hwmgr, true);
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
cz_enable_disable_uvd_dpm(hwmgr, false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1690,13 +1664,10 @@ static int cz_store_cc6_data(struct pp_hwmgr *hwmgr, uint32_t separation_time,
|
|||
struct cz_hwmgr *hw_data = (struct cz_hwmgr *)(hwmgr->backend);
|
||||
|
||||
if (separation_time !=
|
||||
hw_data->cc6_settings.cpu_pstate_separation_time
|
||||
|| cc6_disable !=
|
||||
hw_data->cc6_settings.cpu_cc6_disable
|
||||
|| pstate_disable !=
|
||||
hw_data->cc6_settings.cpu_pstate_disable
|
||||
|| pstate_switch_disable !=
|
||||
hw_data->cc6_settings.nb_pstate_switch_disable) {
|
||||
hw_data->cc6_settings.cpu_pstate_separation_time ||
|
||||
cc6_disable != hw_data->cc6_settings.cpu_cc6_disable ||
|
||||
pstate_disable != hw_data->cc6_settings.cpu_pstate_disable ||
|
||||
pstate_switch_disable != hw_data->cc6_settings.nb_pstate_switch_disable) {
|
||||
|
||||
hw_data->cc6_settings.cc6_setting_changed = true;
|
||||
|
||||
|
@ -1799,8 +1770,7 @@ static int cz_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_hw_p
|
|||
ps = cast_const_PhwCzPowerState(state);
|
||||
|
||||
level_index = index > ps->level - 1 ? ps->level - 1 : index;
|
||||
|
||||
level->coreClock = ps->levels[level_index].engineClock;
|
||||
level->coreClock = ps->levels[level_index].engineClock;
|
||||
|
||||
if (designation == PHM_PerformanceLevelDesignation_PowerContainment) {
|
||||
for (i = 1; i < ps->level; i++) {
|
||||
|
|
|
@ -618,9 +618,6 @@ static int fiji_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
|
|||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_TablelessHardwareInterface);
|
||||
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_SclkDeepSleep);
|
||||
|
||||
data->gpio_debug = 0;
|
||||
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
|
|
|
@ -56,8 +56,6 @@ void fiji_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
|
|||
fiji_hwmgr->power_tune_defaults = &fiji_power_tune_data_set_array[0];
|
||||
|
||||
/* Assume disabled */
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_CAC);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
|
@ -77,9 +75,8 @@ void fiji_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
|
|||
|
||||
fiji_hwmgr->fast_watermark_threshold = 100;
|
||||
|
||||
if (hwmgr->powercontainment_enabled) {
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment);
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment)) {
|
||||
tmp = 1;
|
||||
fiji_hwmgr->enable_dte_feature = tmp ? false : true;
|
||||
fiji_hwmgr->enable_tdc_limit_feature = tmp ? true : false;
|
||||
|
|
|
@ -39,6 +39,26 @@ extern int cz_hwmgr_init(struct pp_hwmgr *hwmgr);
|
|||
extern int tonga_hwmgr_init(struct pp_hwmgr *hwmgr);
|
||||
extern int fiji_hwmgr_init(struct pp_hwmgr *hwmgr);
|
||||
extern int polaris10_hwmgr_init(struct pp_hwmgr *hwmgr);
|
||||
extern int iceland_hwmgr_init(struct pp_hwmgr *hwmgr);
|
||||
|
||||
static int hwmgr_set_features_platform_caps(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
if (amdgpu_sclk_deep_sleep_en)
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_SclkDeepSleep);
|
||||
else
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_SclkDeepSleep);
|
||||
|
||||
if (amdgpu_powercontainment)
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment);
|
||||
else
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle)
|
||||
{
|
||||
|
@ -57,9 +77,12 @@ int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle)
|
|||
hwmgr->chip_family = pp_init->chip_family;
|
||||
hwmgr->chip_id = pp_init->chip_id;
|
||||
hwmgr->hw_revision = pp_init->rev_id;
|
||||
hwmgr->sub_sys_id = pp_init->sub_sys_id;
|
||||
hwmgr->sub_vendor_id = pp_init->sub_vendor_id;
|
||||
hwmgr->usec_timeout = AMD_MAX_USEC_TIMEOUT;
|
||||
hwmgr->power_source = PP_PowerSource_AC;
|
||||
hwmgr->powercontainment_enabled = pp_init->powercontainment_enabled;
|
||||
|
||||
hwmgr_set_features_platform_caps(hwmgr);
|
||||
|
||||
switch (hwmgr->chip_family) {
|
||||
case AMDGPU_FAMILY_CZ:
|
||||
|
@ -67,6 +90,9 @@ int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle)
|
|||
break;
|
||||
case AMDGPU_FAMILY_VI:
|
||||
switch (hwmgr->chip_id) {
|
||||
case CHIP_TOPAZ:
|
||||
iceland_hwmgr_init(hwmgr);
|
||||
break;
|
||||
case CHIP_TONGA:
|
||||
tonga_hwmgr_init(hwmgr);
|
||||
break;
|
||||
|
@ -182,29 +208,7 @@ int phm_wait_on_register(struct pp_hwmgr *hwmgr, uint32_t index,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int phm_wait_for_register_unequal(struct pp_hwmgr *hwmgr,
|
||||
uint32_t index, uint32_t value, uint32_t mask)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t cur_value;
|
||||
|
||||
if (hwmgr == NULL || hwmgr->device == NULL) {
|
||||
printk(KERN_ERR "[ powerplay ] Invalid Hardware Manager!");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < hwmgr->usec_timeout; i++) {
|
||||
cur_value = cgs_read_register(hwmgr->device, index);
|
||||
if ((cur_value & mask) != (value & mask))
|
||||
break;
|
||||
udelay(1);
|
||||
}
|
||||
|
||||
/* timeout means wrong logic*/
|
||||
if (i == hwmgr->usec_timeout)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -227,21 +231,7 @@ void phm_wait_on_indirect_register(struct pp_hwmgr *hwmgr,
|
|||
phm_wait_on_register(hwmgr, indirect_port + 1, mask, value);
|
||||
}
|
||||
|
||||
void phm_wait_for_indirect_register_unequal(struct pp_hwmgr *hwmgr,
|
||||
uint32_t indirect_port,
|
||||
uint32_t index,
|
||||
uint32_t value,
|
||||
uint32_t mask)
|
||||
{
|
||||
if (hwmgr == NULL || hwmgr->device == NULL) {
|
||||
printk(KERN_ERR "[ powerplay ] Invalid Hardware Manager!");
|
||||
return;
|
||||
}
|
||||
|
||||
cgs_write_register(hwmgr->device, indirect_port, index);
|
||||
phm_wait_for_register_unequal(hwmgr, indirect_port + 1,
|
||||
value, mask);
|
||||
}
|
||||
|
||||
bool phm_cf_want_uvd_power_gating(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Huang Rui <ray.huang@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hwmgr.h"
|
||||
#include "iceland_clockpowergating.h"
|
||||
#include "ppsmc.h"
|
||||
#include "iceland_hwmgr.h"
|
||||
|
||||
int iceland_phm_powerdown_uvd(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
/* iceland does not have MM hardware block */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_phm_powerup_uvd(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
/* iceland does not have MM hardware block */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_phm_powerdown_vce(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
/* iceland does not have MM hardware block */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_phm_powerup_vce(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
/* iceland does not have MM hardware block */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iceland_phm_set_asic_block_gating(struct pp_hwmgr *hwmgr, enum
|
||||
PHM_AsicBlock block, enum PHM_ClockGateSetting gating)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (block) {
|
||||
case PHM_AsicBlock_UVD_MVC:
|
||||
case PHM_AsicBlock_UVD:
|
||||
case PHM_AsicBlock_UVD_HD:
|
||||
case PHM_AsicBlock_UVD_SD:
|
||||
if (gating == PHM_ClockGateSetting_StaticOff)
|
||||
ret = iceland_phm_powerdown_uvd(hwmgr);
|
||||
else
|
||||
ret = iceland_phm_powerup_uvd(hwmgr);
|
||||
break;
|
||||
case PHM_AsicBlock_GFX:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int iceland_phm_disable_clock_power_gating(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
|
||||
data->uvd_power_gated = false;
|
||||
data->vce_power_gated = false;
|
||||
|
||||
iceland_phm_powerup_uvd(hwmgr);
|
||||
iceland_phm_powerup_vce(hwmgr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iceland_phm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)
|
||||
{
|
||||
if (bgate) {
|
||||
iceland_update_uvd_dpm(hwmgr, true);
|
||||
iceland_phm_powerdown_uvd(hwmgr);
|
||||
} else {
|
||||
iceland_phm_powerup_uvd(hwmgr);
|
||||
iceland_update_uvd_dpm(hwmgr, false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iceland_phm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate)
|
||||
{
|
||||
if (bgate)
|
||||
return iceland_phm_powerdown_vce(hwmgr);
|
||||
else
|
||||
return iceland_phm_powerup_vce(hwmgr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iceland_phm_update_clock_gatings(struct pp_hwmgr *hwmgr,
|
||||
const uint32_t *msg_id)
|
||||
{
|
||||
/* iceland does not have MM hardware block */
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Huang Rui <ray.huang@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ICELAND_CLOCK_POWER_GATING_H_
|
||||
#define _ICELAND_CLOCK_POWER_GATING_H_
|
||||
|
||||
#include "iceland_hwmgr.h"
|
||||
#include "pp_asicblocks.h"
|
||||
|
||||
extern int iceland_phm_set_asic_block_gating(struct pp_hwmgr *hwmgr, enum PHM_AsicBlock block, enum PHM_ClockGateSetting gating);
|
||||
extern int iceland_phm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate);
|
||||
extern int iceland_phm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate);
|
||||
extern int iceland_phm_powerdown_uvd(struct pp_hwmgr *hwmgr);
|
||||
extern int iceland_phm_disable_clock_power_gating(struct pp_hwmgr *hwmgr);
|
||||
extern int iceland_phm_update_clock_gatings(struct pp_hwmgr *hwmgr, const uint32_t *msg_id);
|
||||
#endif /* _ICELAND_CLOCK_POWER_GATING_H_ */
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef ICELAND_DYN_DEFAULTS_H
|
||||
#define ICELAND_DYN_DEFAULTS_H
|
||||
|
||||
enum ICELANDdpm_TrendDetection
|
||||
{
|
||||
ICELANDdpm_TrendDetection_AUTO,
|
||||
ICELANDdpm_TrendDetection_UP,
|
||||
ICELANDdpm_TrendDetection_DOWN
|
||||
};
|
||||
typedef enum ICELANDdpm_TrendDetection ICELANDdpm_TrendDetection;
|
||||
|
||||
|
||||
#define PPICELAND_VOTINGRIGHTSCLIENTS_DFLT0 0x3FFFC102
|
||||
#define PPICELAND_VOTINGRIGHTSCLIENTS_DFLT1 0x000400
|
||||
#define PPICELAND_VOTINGRIGHTSCLIENTS_DFLT2 0xC00080
|
||||
#define PPICELAND_VOTINGRIGHTSCLIENTS_DFLT3 0xC00200
|
||||
#define PPICELAND_VOTINGRIGHTSCLIENTS_DFLT4 0xC01680
|
||||
#define PPICELAND_VOTINGRIGHTSCLIENTS_DFLT5 0xC00033
|
||||
#define PPICELAND_VOTINGRIGHTSCLIENTS_DFLT6 0xC00033
|
||||
#define PPICELAND_VOTINGRIGHTSCLIENTS_DFLT7 0x3FFFC000
|
||||
|
||||
|
||||
#define PPICELAND_THERMALPROTECTCOUNTER_DFLT 0x200
|
||||
|
||||
#define PPICELAND_STATICSCREENTHRESHOLDUNIT_DFLT 0
|
||||
|
||||
#define PPICELAND_STATICSCREENTHRESHOLD_DFLT 0x00C8
|
||||
|
||||
#define PPICELAND_GFXIDLECLOCKSTOPTHRESHOLD_DFLT 0x200
|
||||
|
||||
#define PPICELAND_REFERENCEDIVIDER_DFLT 4
|
||||
|
||||
#define PPICELAND_ULVVOLTAGECHANGEDELAY_DFLT 1687
|
||||
|
||||
#define PPICELAND_CGULVPARAMETER_DFLT 0x00040035
|
||||
#define PPICELAND_CGULVCONTROL_DFLT 0x00007450
|
||||
#define PPICELAND_TARGETACTIVITY_DFLT 30
|
||||
#define PPICELAND_MCLK_TARGETACTIVITY_DFLT 10
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,424 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Huang Rui <ray.huang@amd.com>
|
||||
*
|
||||
*/
|
||||
#ifndef ICELAND_HWMGR_H
|
||||
#define ICELAND_HWMGR_H
|
||||
|
||||
#include "hwmgr.h"
|
||||
#include "ppatomctrl.h"
|
||||
#include "ppinterrupt.h"
|
||||
#include "ppsmc.h"
|
||||
#include "iceland_powertune.h"
|
||||
#include "pp_endian.h"
|
||||
#include "smu71_discrete.h"
|
||||
|
||||
#define ICELAND_MAX_HARDWARE_POWERLEVELS 2
|
||||
#define ICELAND_DYNCLK_NUMBER_OF_TREND_COEFFICIENTS 15
|
||||
|
||||
struct iceland_performance_level {
|
||||
uint32_t memory_clock;
|
||||
uint32_t engine_clock;
|
||||
uint16_t pcie_gen;
|
||||
uint16_t pcie_lane;
|
||||
};
|
||||
|
||||
struct _phw_iceland_bacos {
|
||||
uint32_t best_match;
|
||||
uint32_t baco_flags;
|
||||
struct iceland_performance_level performance_level;
|
||||
};
|
||||
typedef struct _phw_iceland_bacos phw_iceland_bacos;
|
||||
|
||||
struct _phw_iceland_uvd_clocks {
|
||||
uint32_t VCLK;
|
||||
uint32_t DCLK;
|
||||
};
|
||||
|
||||
typedef struct _phw_iceland_uvd_clocks phw_iceland_uvd_clocks;
|
||||
|
||||
struct _phw_iceland_vce_clocks {
|
||||
uint32_t EVCLK;
|
||||
uint32_t ECCLK;
|
||||
};
|
||||
|
||||
typedef struct _phw_iceland_vce_clocks phw_iceland_vce_clocks;
|
||||
|
||||
struct iceland_power_state {
|
||||
uint32_t magic;
|
||||
phw_iceland_uvd_clocks uvd_clocks;
|
||||
phw_iceland_vce_clocks vce_clocks;
|
||||
uint32_t sam_clk;
|
||||
uint32_t acp_clk;
|
||||
uint16_t performance_level_count;
|
||||
bool dc_compatible;
|
||||
uint32_t sclk_threshold;
|
||||
struct iceland_performance_level performance_levels[ICELAND_MAX_HARDWARE_POWERLEVELS];
|
||||
};
|
||||
|
||||
struct _phw_iceland_dpm_level {
|
||||
bool enabled;
|
||||
uint32_t value;
|
||||
uint32_t param1;
|
||||
};
|
||||
typedef struct _phw_iceland_dpm_level phw_iceland_dpm_level;
|
||||
|
||||
#define ICELAND_MAX_DEEPSLEEP_DIVIDER_ID 5
|
||||
#define MAX_REGULAR_DPM_NUMBER 8
|
||||
#define ICELAND_MINIMUM_ENGINE_CLOCK 5000
|
||||
|
||||
struct iceland_single_dpm_table {
|
||||
uint32_t count;
|
||||
phw_iceland_dpm_level dpm_levels[MAX_REGULAR_DPM_NUMBER];
|
||||
};
|
||||
|
||||
struct iceland_dpm_table {
|
||||
struct iceland_single_dpm_table sclk_table;
|
||||
struct iceland_single_dpm_table mclk_table;
|
||||
struct iceland_single_dpm_table pcie_speed_table;
|
||||
struct iceland_single_dpm_table vddc_table;
|
||||
struct iceland_single_dpm_table vdd_gfx_table;
|
||||
struct iceland_single_dpm_table vdd_ci_table;
|
||||
struct iceland_single_dpm_table mvdd_table;
|
||||
};
|
||||
typedef struct _phw_iceland_dpm_table phw_iceland_dpm_table;
|
||||
|
||||
|
||||
struct _phw_iceland_clock_regisiters {
|
||||
uint32_t vCG_SPLL_FUNC_CNTL;
|
||||
uint32_t vCG_SPLL_FUNC_CNTL_2;
|
||||
uint32_t vCG_SPLL_FUNC_CNTL_3;
|
||||
uint32_t vCG_SPLL_FUNC_CNTL_4;
|
||||
uint32_t vCG_SPLL_SPREAD_SPECTRUM;
|
||||
uint32_t vCG_SPLL_SPREAD_SPECTRUM_2;
|
||||
uint32_t vDLL_CNTL;
|
||||
uint32_t vMCLK_PWRMGT_CNTL;
|
||||
uint32_t vMPLL_AD_FUNC_CNTL;
|
||||
uint32_t vMPLL_DQ_FUNC_CNTL;
|
||||
uint32_t vMPLL_FUNC_CNTL;
|
||||
uint32_t vMPLL_FUNC_CNTL_1;
|
||||
uint32_t vMPLL_FUNC_CNTL_2;
|
||||
uint32_t vMPLL_SS1;
|
||||
uint32_t vMPLL_SS2;
|
||||
};
|
||||
typedef struct _phw_iceland_clock_regisiters phw_iceland_clock_registers;
|
||||
|
||||
struct _phw_iceland_voltage_smio_registers {
|
||||
uint32_t vs0_vid_lower_smio_cntl;
|
||||
};
|
||||
typedef struct _phw_iceland_voltage_smio_registers phw_iceland_voltage_smio_registers;
|
||||
|
||||
|
||||
struct _phw_iceland_mc_reg_entry {
|
||||
uint32_t mclk_max;
|
||||
uint32_t mc_data[SMU71_DISCRETE_MC_REGISTER_ARRAY_SIZE];
|
||||
};
|
||||
typedef struct _phw_iceland_mc_reg_entry phw_iceland_mc_reg_entry;
|
||||
|
||||
struct _phw_iceland_mc_reg_table {
|
||||
uint8_t last; /* number of registers*/
|
||||
uint8_t num_entries; /* number of entries in mc_reg_table_entry used*/
|
||||
uint16_t validflag; /* indicate the corresponding register is valid or not. 1: valid, 0: invalid. bit0->address[0], bit1->address[1], etc.*/
|
||||
phw_iceland_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES];
|
||||
SMU71_Discrete_MCRegisterAddress mc_reg_address[SMU71_DISCRETE_MC_REGISTER_ARRAY_SIZE];
|
||||
};
|
||||
typedef struct _phw_iceland_mc_reg_table phw_iceland_mc_reg_table;
|
||||
|
||||
#define DISABLE_MC_LOADMICROCODE 1
|
||||
#define DISABLE_MC_CFGPROGRAMMING 2
|
||||
|
||||
|
||||
/*Ultra Low Voltage parameter structure */
|
||||
struct phw_iceland_ulv_parm{
|
||||
bool ulv_supported;
|
||||
uint32_t ch_ulv_parameter;
|
||||
uint32_t ulv_volt_change_delay;
|
||||
struct iceland_performance_level ulv_power_level;
|
||||
};
|
||||
|
||||
#define ICELAND_MAX_LEAKAGE_COUNT 8
|
||||
|
||||
struct phw_iceland_leakage_voltage {
|
||||
uint16_t count;
|
||||
uint16_t leakage_id[ICELAND_MAX_LEAKAGE_COUNT];
|
||||
uint16_t actual_voltage[ICELAND_MAX_LEAKAGE_COUNT];
|
||||
};
|
||||
|
||||
struct _phw_iceland_display_timing {
|
||||
uint32_t min_clock_insr;
|
||||
uint32_t num_existing_displays;
|
||||
};
|
||||
typedef struct _phw_iceland_display_timing phw_iceland_display_timing;
|
||||
|
||||
|
||||
struct phw_iceland_thermal_temperature_setting
|
||||
{
|
||||
long temperature_low;
|
||||
long temperature_high;
|
||||
long temperature_shutdown;
|
||||
};
|
||||
|
||||
struct _phw_iceland_dpmlevel_enable_mask {
|
||||
uint32_t uvd_dpm_enable_mask;
|
||||
uint32_t vce_dpm_enable_mask;
|
||||
uint32_t acp_dpm_enable_mask;
|
||||
uint32_t samu_dpm_enable_mask;
|
||||
uint32_t sclk_dpm_enable_mask;
|
||||
uint32_t mclk_dpm_enable_mask;
|
||||
uint32_t pcie_dpm_enable_mask;
|
||||
};
|
||||
typedef struct _phw_iceland_dpmlevel_enable_mask phw_iceland_dpmlevel_enable_mask;
|
||||
|
||||
struct _phw_iceland_pcie_perf_range {
|
||||
uint16_t max;
|
||||
uint16_t min;
|
||||
};
|
||||
typedef struct _phw_iceland_pcie_perf_range phw_iceland_pcie_perf_range;
|
||||
|
||||
struct _phw_iceland_vbios_boot_state {
|
||||
uint16_t mvdd_bootup_value;
|
||||
uint16_t vddc_bootup_value;
|
||||
uint16_t vddci_bootup_value;
|
||||
uint16_t vddgfx_bootup_value;
|
||||
uint32_t sclk_bootup_value;
|
||||
uint32_t mclk_bootup_value;
|
||||
uint16_t pcie_gen_bootup_value;
|
||||
uint16_t pcie_lane_bootup_value;
|
||||
};
|
||||
typedef struct _phw_iceland_vbios_boot_state phw_iceland_vbios_boot_state;
|
||||
|
||||
#define DPMTABLE_OD_UPDATE_SCLK 0x00000001
|
||||
#define DPMTABLE_OD_UPDATE_MCLK 0x00000002
|
||||
#define DPMTABLE_UPDATE_SCLK 0x00000004
|
||||
#define DPMTABLE_UPDATE_MCLK 0x00000008
|
||||
|
||||
/* We need to review which fields are needed. */
|
||||
/* This is mostly a copy of the RV7xx/Evergreen structure which is close, but not identical to the N.Islands one. */
|
||||
struct iceland_hwmgr {
|
||||
struct iceland_dpm_table dpm_table;
|
||||
struct iceland_dpm_table golden_dpm_table;
|
||||
|
||||
uint32_t voting_rights_clients0;
|
||||
uint32_t voting_rights_clients1;
|
||||
uint32_t voting_rights_clients2;
|
||||
uint32_t voting_rights_clients3;
|
||||
uint32_t voting_rights_clients4;
|
||||
uint32_t voting_rights_clients5;
|
||||
uint32_t voting_rights_clients6;
|
||||
uint32_t voting_rights_clients7;
|
||||
uint32_t static_screen_threshold_unit;
|
||||
uint32_t static_screen_threshold;
|
||||
uint32_t voltage_control;
|
||||
uint32_t vdd_gfx_control;
|
||||
|
||||
uint32_t vddc_vddci_delta;
|
||||
uint32_t vddc_vddgfx_delta;
|
||||
|
||||
struct pp_interrupt_registration_info internal_high_thermal_interrupt_info;
|
||||
struct pp_interrupt_registration_info internal_low_thermal_interrupt_info;
|
||||
struct pp_interrupt_registration_info smc_to_host_interrupt_info;
|
||||
uint32_t active_auto_throttle_sources;
|
||||
|
||||
struct pp_interrupt_registration_info external_throttle_interrupt;
|
||||
irq_handler_func_t external_throttle_callback;
|
||||
void *external_throttle_context;
|
||||
|
||||
struct pp_interrupt_registration_info ctf_interrupt_info;
|
||||
irq_handler_func_t ctf_callback;
|
||||
void *ctf_context;
|
||||
|
||||
phw_iceland_clock_registers clock_registers;
|
||||
phw_iceland_voltage_smio_registers voltage_smio_registers;
|
||||
|
||||
bool is_memory_GDDR5;
|
||||
uint16_t acpi_vddc;
|
||||
bool pspp_notify_required; /* Flag to indicate if PSPP notification to SBIOS is required */
|
||||
uint16_t force_pcie_gen; /* The forced PCI-E speed if not 0xffff */
|
||||
uint16_t acpi_pcie_gen; /* The PCI-E speed at ACPI time */
|
||||
uint32_t pcie_gen_cap; /* The PCI-E speed capabilities bitmap from CAIL */
|
||||
uint32_t pcie_lane_cap; /* The PCI-E lane capabilities bitmap from CAIL */
|
||||
uint32_t pcie_spc_cap; /* Symbol Per Clock Capabilities from registry */
|
||||
struct phw_iceland_leakage_voltage vddc_leakage; /* The Leakage VDDC supported (based on leakage ID).*/
|
||||
struct phw_iceland_leakage_voltage vddcgfx_leakage; /* The Leakage VDDC supported (based on leakage ID). */
|
||||
struct phw_iceland_leakage_voltage vddci_leakage; /* The Leakage VDDCI supported (based on leakage ID). */
|
||||
|
||||
uint32_t mvdd_control;
|
||||
uint32_t vddc_mask_low;
|
||||
uint32_t mvdd_mask_low;
|
||||
uint16_t max_vddc_in_pp_table; /* the maximum VDDC value in the powerplay table*/
|
||||
uint16_t min_vddc_in_pp_table;
|
||||
uint16_t max_vddci_in_pp_table; /* the maximum VDDCI value in the powerplay table */
|
||||
uint16_t min_vddci_in_pp_table;
|
||||
uint32_t mclk_strobe_mode_threshold;
|
||||
uint32_t mclk_stutter_mode_threshold;
|
||||
uint32_t mclk_edc_enable_threshold;
|
||||
uint32_t mclk_edc_wr_enable_threshold;
|
||||
bool is_uvd_enabled;
|
||||
bool is_xdma_enabled;
|
||||
phw_iceland_vbios_boot_state vbios_boot_state;
|
||||
|
||||
bool battery_state;
|
||||
bool is_tlu_enabled;
|
||||
bool pcie_performance_request;
|
||||
|
||||
/* -------------- SMC SRAM Address of firmware header tables ----------------*/
|
||||
uint32_t sram_end; /* The first address after the SMC SRAM. */
|
||||
uint32_t dpm_table_start; /* The start of the dpm table in the SMC SRAM. */
|
||||
uint32_t soft_regs_start; /* The start of the soft registers in the SMC SRAM. */
|
||||
uint32_t mc_reg_table_start; /* The start of the mc register table in the SMC SRAM. */
|
||||
uint32_t fan_table_start; /* The start of the fan table in the SMC SRAM. */
|
||||
uint32_t arb_table_start; /* The start of the ARB setting table in the SMC SRAM. */
|
||||
uint32_t ulv_settings_start;
|
||||
SMU71_Discrete_DpmTable smc_state_table; /* The carbon copy of the SMC state table. */
|
||||
SMU71_Discrete_MCRegisters mc_reg_table;
|
||||
SMU71_Discrete_Ulv ulv_setting; /* The carbon copy of ULV setting. */
|
||||
|
||||
/* -------------- Stuff originally coming from Evergreen --------------------*/
|
||||
phw_iceland_mc_reg_table iceland_mc_reg_table;
|
||||
uint32_t vdd_ci_control;
|
||||
pp_atomctrl_voltage_table vddc_voltage_table;
|
||||
pp_atomctrl_voltage_table vddci_voltage_table;
|
||||
pp_atomctrl_voltage_table vddgfx_voltage_table;
|
||||
pp_atomctrl_voltage_table mvdd_voltage_table;
|
||||
|
||||
uint32_t mgcg_cgtt_local2;
|
||||
uint32_t mgcg_cgtt_local3;
|
||||
uint32_t gpio_debug;
|
||||
uint32_t mc_micro_code_feature;
|
||||
uint32_t highest_mclk;
|
||||
uint16_t acpi_vdd_ci;
|
||||
uint8_t mvdd_high_index;
|
||||
uint8_t mvdd_low_index;
|
||||
bool dll_defaule_on;
|
||||
bool performance_request_registered;
|
||||
|
||||
/* ----------------- Low Power Features ---------------------*/
|
||||
phw_iceland_bacos bacos;
|
||||
struct phw_iceland_ulv_parm ulv;
|
||||
|
||||
/* ----------------- CAC Stuff ---------------------*/
|
||||
uint32_t cac_table_start;
|
||||
bool cac_configuration_required; /* TRUE if PP_CACConfigurationRequired == 1 */
|
||||
bool driver_calculate_cac_leakage; /* TRUE if PP_DriverCalculateCACLeakage == 1 */
|
||||
bool cac_enabled;
|
||||
|
||||
/* ----------------- DPM2 Parameters ---------------------*/
|
||||
uint32_t power_containment_features;
|
||||
bool enable_bapm_feature;
|
||||
bool enable_dte_feature;
|
||||
bool enable_tdc_limit_feature;
|
||||
bool enable_pkg_pwr_tracking_feature;
|
||||
bool disable_uvd_power_tune_feature;
|
||||
struct iceland_pt_defaults *power_tune_defaults;
|
||||
SMU71_Discrete_PmFuses power_tune_table;
|
||||
uint32_t ul_dte_tj_offset; /* Fudge factor in DPM table to correct HW DTE errors */
|
||||
uint32_t fast_watermark_threshold; /* use fast watermark if clock is equal or above this. In percentage of the target high sclk. */
|
||||
|
||||
/* ----------------- Phase Shedding ---------------------*/
|
||||
bool vddc_phase_shed_control;
|
||||
|
||||
/* --------------------- DI/DT --------------------------*/
|
||||
phw_iceland_display_timing display_timing;
|
||||
|
||||
/* --------- ReadRegistry data for memory and engine clock margins ---- */
|
||||
uint32_t engine_clock_data;
|
||||
uint32_t memory_clock_data;
|
||||
|
||||
/* -------- Thermal Temperature Setting --------------*/
|
||||
struct phw_iceland_thermal_temperature_setting thermal_temp_setting;
|
||||
phw_iceland_dpmlevel_enable_mask dpm_level_enable_mask;
|
||||
|
||||
uint32_t need_update_smu7_dpm_table;
|
||||
uint32_t sclk_dpm_key_disabled;
|
||||
uint32_t mclk_dpm_key_disabled;
|
||||
uint32_t pcie_dpm_key_disabled;
|
||||
/* used to store the previous dal min sclock */
|
||||
uint32_t min_engine_clocks;
|
||||
phw_iceland_pcie_perf_range pcie_gen_performance;
|
||||
phw_iceland_pcie_perf_range pcie_lane_performance;
|
||||
phw_iceland_pcie_perf_range pcie_gen_power_saving;
|
||||
phw_iceland_pcie_perf_range pcie_lane_power_saving;
|
||||
bool use_pcie_performance_levels;
|
||||
bool use_pcie_power_saving_levels;
|
||||
/* percentage value from 0-100, default 50 */
|
||||
uint32_t activity_target[SMU71_MAX_LEVELS_GRAPHICS];
|
||||
uint32_t mclk_activity_target;
|
||||
uint32_t low_sclk_interrupt_threshold;
|
||||
uint32_t last_mclk_dpm_enable_mask;
|
||||
bool uvd_enabled;
|
||||
uint32_t pcc_monitor_enabled;
|
||||
|
||||
/* --------- Power Gating States ------------*/
|
||||
bool uvd_power_gated; /* 1: gated, 0:not gated */
|
||||
bool vce_power_gated; /* 1: gated, 0:not gated */
|
||||
bool samu_power_gated; /* 1: gated, 0:not gated */
|
||||
bool acp_power_gated; /* 1: gated, 0:not gated */
|
||||
bool pg_acp_init;
|
||||
|
||||
/* soft pptable for re-uploading into smu */
|
||||
void *soft_pp_table;
|
||||
};
|
||||
|
||||
typedef struct iceland_hwmgr iceland_hwmgr;
|
||||
|
||||
int iceland_hwmgr_init(struct pp_hwmgr *hwmgr);
|
||||
int iceland_update_uvd_dpm(struct pp_hwmgr *hwmgr, bool bgate);
|
||||
uint32_t iceland_get_xclk(struct pp_hwmgr *hwmgr);
|
||||
int iceland_populate_bapm_vddc_vid_sidd(struct pp_hwmgr *hwmgr);
|
||||
int iceland_populate_vddc_vid(struct pp_hwmgr *hwmgr);
|
||||
|
||||
#define ICELAND_DPM2_NEAR_TDP_DEC 10
|
||||
#define ICELAND_DPM2_ABOVE_SAFE_INC 5
|
||||
#define ICELAND_DPM2_BELOW_SAFE_INC 20
|
||||
|
||||
/*
|
||||
* Log2 of the LTA window size (l2numWin_TDP). Eg. If LTA windows size
|
||||
* is 128, then this value should be Log2(128) = 7.
|
||||
*/
|
||||
#define ICELAND_DPM2_LTA_WINDOW_SIZE 7
|
||||
|
||||
#define ICELAND_DPM2_LTS_TRUNCATE 0
|
||||
|
||||
#define ICELAND_DPM2_TDP_SAFE_LIMIT_PERCENT 80 // Maximum 100
|
||||
|
||||
#define ICELAND_DPM2_MAXPS_PERCENT_H 90 // Maximum 0xFF
|
||||
#define ICELAND_DPM2_MAXPS_PERCENT_M 90 // Maximum 0xFF
|
||||
|
||||
#define ICELAND_DPM2_PWREFFICIENCYRATIO_MARGIN 50
|
||||
|
||||
#define ICELAND_DPM2_SQ_RAMP_MAX_POWER 0x3FFF
|
||||
#define ICELAND_DPM2_SQ_RAMP_MIN_POWER 0x12
|
||||
#define ICELAND_DPM2_SQ_RAMP_MAX_POWER_DELTA 0x15
|
||||
#define ICELAND_DPM2_SQ_RAMP_SHORT_TERM_INTERVAL_SIZE 0x1E
|
||||
#define ICELAND_DPM2_SQ_RAMP_LONG_TERM_INTERVAL_RATIO 0xF
|
||||
|
||||
#define ICELAND_VOLTAGE_CONTROL_NONE 0x0
|
||||
#define ICELAND_VOLTAGE_CONTROL_BY_GPIO 0x1
|
||||
#define ICELAND_VOLTAGE_CONTROL_BY_SVID2 0x2
|
||||
|
||||
/* convert to Q8.8 format for firmware */
|
||||
#define ICELAND_Q88_FORMAT_CONVERSION_UNIT 256
|
||||
|
||||
#define ICELAND_UNUSED_GPIO_PIN 0x7F
|
||||
|
||||
#endif
|
|
@ -0,0 +1,490 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Huang Rui <ray.huang@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "amdgpu.h"
|
||||
#include "hwmgr.h"
|
||||
#include "smumgr.h"
|
||||
#include "iceland_hwmgr.h"
|
||||
#include "iceland_powertune.h"
|
||||
#include "iceland_smumgr.h"
|
||||
#include "smu71_discrete.h"
|
||||
#include "smu71.h"
|
||||
#include "pp_debug.h"
|
||||
#include "cgs_common.h"
|
||||
#include "pp_endian.h"
|
||||
|
||||
#include "bif/bif_5_0_d.h"
|
||||
#include "bif/bif_5_0_sh_mask.h"
|
||||
|
||||
#define VOLTAGE_SCALE 4
|
||||
#define POWERTUNE_DEFAULT_SET_MAX 1
|
||||
|
||||
#define DEVICE_ID_VI_ICELAND_M_6900 0x6900
|
||||
#define DEVICE_ID_VI_ICELAND_M_6901 0x6901
|
||||
#define DEVICE_ID_VI_ICELAND_M_6902 0x6902
|
||||
#define DEVICE_ID_VI_ICELAND_M_6903 0x6903
|
||||
|
||||
|
||||
struct iceland_pt_defaults defaults_iceland =
|
||||
{
|
||||
/*
|
||||
* sviLoadLIneEn, SviLoadLineVddC, TDC_VDDC_ThrottleReleaseLimitPerc,
|
||||
* TDC_MAWt, TdcWaterfallCtl, DTEAmbientTempBase, DisplayCac, BAPM_TEMP_GRADIENT
|
||||
*/
|
||||
1, 0xF, 0xFD, 0x19, 5, 45, 0, 0xB0000,
|
||||
{ 0x79, 0x253, 0x25D, 0xAE, 0x72, 0x80, 0x83, 0x86, 0x6F, 0xC8, 0xC9, 0xC9, 0x2F, 0x4D, 0x61 },
|
||||
{ 0x17C, 0x172, 0x180, 0x1BC, 0x1B3, 0x1BD, 0x206, 0x200, 0x203, 0x25D, 0x25A, 0x255, 0x2C3, 0x2C5, 0x2B4 }
|
||||
};
|
||||
|
||||
/* 35W - XT, XTL */
|
||||
struct iceland_pt_defaults defaults_icelandxt =
|
||||
{
|
||||
/*
|
||||
* sviLoadLIneEn, SviLoadLineVddC,
|
||||
* TDC_VDDC_ThrottleReleaseLimitPerc, TDC_MAWt,
|
||||
* TdcWaterfallCtl, DTEAmbientTempBase, DisplayCac,
|
||||
* BAPM_TEMP_GRADIENT
|
||||
*/
|
||||
1, 0xF, 0xFD, 0x19, 5, 45, 0, 0x0,
|
||||
{ 0xA7, 0x0, 0x0, 0xB5, 0x0, 0x0, 0x9F, 0x0, 0x0, 0xD6, 0x0, 0x0, 0xD7, 0x0, 0x0},
|
||||
{ 0x1EA, 0x0, 0x0, 0x224, 0x0, 0x0, 0x25E, 0x0, 0x0, 0x28E, 0x0, 0x0, 0x2AB, 0x0, 0x0}
|
||||
};
|
||||
|
||||
/* 25W - PRO, LE */
|
||||
struct iceland_pt_defaults defaults_icelandpro =
|
||||
{
|
||||
/*
|
||||
* sviLoadLIneEn, SviLoadLineVddC,
|
||||
* TDC_VDDC_ThrottleReleaseLimitPerc, TDC_MAWt,
|
||||
* TdcWaterfallCtl, DTEAmbientTempBase, DisplayCac,
|
||||
* BAPM_TEMP_GRADIENT
|
||||
*/
|
||||
1, 0xF, 0xFD, 0x19, 5, 45, 0, 0x0,
|
||||
{ 0xB7, 0x0, 0x0, 0xC3, 0x0, 0x0, 0xB5, 0x0, 0x0, 0xEA, 0x0, 0x0, 0xE6, 0x0, 0x0},
|
||||
{ 0x1EA, 0x0, 0x0, 0x224, 0x0, 0x0, 0x25E, 0x0, 0x0, 0x28E, 0x0, 0x0, 0x2AB, 0x0, 0x0}
|
||||
};
|
||||
|
||||
void iceland_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
uint32_t tmp = 0;
|
||||
struct cgs_system_info sys_info = {0};
|
||||
uint32_t pdev_id;
|
||||
|
||||
sys_info.size = sizeof(struct cgs_system_info);
|
||||
sys_info.info_id = CGS_SYSTEM_INFO_PCIE_DEV;
|
||||
cgs_query_system_info(hwmgr->device, &sys_info);
|
||||
pdev_id = (uint32_t)sys_info.value;
|
||||
|
||||
switch (pdev_id) {
|
||||
case DEVICE_ID_VI_ICELAND_M_6900:
|
||||
case DEVICE_ID_VI_ICELAND_M_6903:
|
||||
data->power_tune_defaults = &defaults_icelandxt;
|
||||
break;
|
||||
|
||||
case DEVICE_ID_VI_ICELAND_M_6901:
|
||||
case DEVICE_ID_VI_ICELAND_M_6902:
|
||||
data->power_tune_defaults = &defaults_icelandpro;
|
||||
break;
|
||||
default:
|
||||
/* TODO: need to assign valid defaults */
|
||||
data->power_tune_defaults = &defaults_iceland;
|
||||
pr_warning("Unknown V.I. Device ID.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Assume disabled */
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_CAC);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_SQRamping);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_DBRamping);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_TDRamping);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_TCPRamping);
|
||||
|
||||
data->ul_dte_tj_offset = tmp;
|
||||
|
||||
if (!tmp) {
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_CAC);
|
||||
|
||||
data->fast_watermark_threshold = 100;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment)) {
|
||||
tmp = 1;
|
||||
data->enable_dte_feature = tmp ? false : true;
|
||||
data->enable_tdc_limit_feature = tmp ? true : false;
|
||||
data->enable_pkg_pwr_tracking_feature = tmp ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int iceland_populate_bapm_parameters_in_dpm_table(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
struct iceland_pt_defaults *defaults = data->power_tune_defaults;
|
||||
SMU71_Discrete_DpmTable *dpm_table = &(data->smc_state_table);
|
||||
struct phm_cac_tdp_table *cac_dtp_table = hwmgr->dyn_state.cac_dtp_table;
|
||||
struct phm_ppm_table *ppm = hwmgr->dyn_state.ppm_parameter_table;
|
||||
uint16_t *def1, *def2;
|
||||
int i, j, k;
|
||||
|
||||
/*
|
||||
* TDP number of fraction bits are changed from 8 to 7 for Iceland
|
||||
* as requested by SMC team
|
||||
*/
|
||||
dpm_table->DefaultTdp = PP_HOST_TO_SMC_US((uint16_t)(cac_dtp_table->usTDP * 256));
|
||||
dpm_table->TargetTdp = PP_HOST_TO_SMC_US((uint16_t)(cac_dtp_table->usConfigurableTDP * 256));
|
||||
|
||||
dpm_table->DTETjOffset = (uint8_t)data->ul_dte_tj_offset;
|
||||
|
||||
dpm_table->GpuTjMax = (uint8_t)(data->thermal_temp_setting.temperature_high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES);
|
||||
dpm_table->GpuTjHyst = 8;
|
||||
|
||||
dpm_table->DTEAmbientTempBase = defaults->dte_ambient_temp_base;
|
||||
|
||||
/* The following are for new Iceland Multi-input fan/thermal control */
|
||||
if(NULL != ppm) {
|
||||
dpm_table->PPM_PkgPwrLimit = (uint16_t)ppm->dgpu_tdp * 256 / 1000;
|
||||
dpm_table->PPM_TemperatureLimit = (uint16_t)ppm->tj_max * 256;
|
||||
} else {
|
||||
dpm_table->PPM_PkgPwrLimit = 0;
|
||||
dpm_table->PPM_TemperatureLimit = 0;
|
||||
}
|
||||
|
||||
CONVERT_FROM_HOST_TO_SMC_US(dpm_table->PPM_PkgPwrLimit);
|
||||
CONVERT_FROM_HOST_TO_SMC_US(dpm_table->PPM_TemperatureLimit);
|
||||
|
||||
dpm_table->BAPM_TEMP_GRADIENT = PP_HOST_TO_SMC_UL(defaults->bamp_temp_gradient);
|
||||
def1 = defaults->bapmti_r;
|
||||
def2 = defaults->bapmti_rc;
|
||||
|
||||
for (i = 0; i < SMU71_DTE_ITERATIONS; i++) {
|
||||
for (j = 0; j < SMU71_DTE_SOURCES; j++) {
|
||||
for (k = 0; k < SMU71_DTE_SINKS; k++) {
|
||||
dpm_table->BAPMTI_R[i][j][k] = PP_HOST_TO_SMC_US(*def1);
|
||||
dpm_table->BAPMTI_RC[i][j][k] = PP_HOST_TO_SMC_US(*def2);
|
||||
def1++;
|
||||
def2++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_populate_svi_load_line(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
const struct iceland_pt_defaults *defaults = data->power_tune_defaults;
|
||||
|
||||
data->power_tune_table.SviLoadLineEn = defaults->svi_load_line_en;
|
||||
data->power_tune_table.SviLoadLineVddC = defaults->svi_load_line_vddc;
|
||||
data->power_tune_table.SviLoadLineTrimVddC = 3;
|
||||
data->power_tune_table.SviLoadLineOffsetVddC = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_populate_tdc_limit(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
uint16_t tdc_limit;
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
const struct iceland_pt_defaults *defaults = data->power_tune_defaults;
|
||||
|
||||
/* TDC number of fraction bits are changed from 8 to 7
|
||||
* for Iceland as requested by SMC team
|
||||
*/
|
||||
tdc_limit = (uint16_t)(hwmgr->dyn_state.cac_dtp_table->usTDC * 256);
|
||||
data->power_tune_table.TDC_VDDC_PkgLimit =
|
||||
CONVERT_FROM_HOST_TO_SMC_US(tdc_limit);
|
||||
data->power_tune_table.TDC_VDDC_ThrottleReleaseLimitPerc =
|
||||
defaults->tdc_vddc_throttle_release_limit_perc;
|
||||
data->power_tune_table.TDC_MAWt = defaults->tdc_mawt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_populate_dw8(struct pp_hwmgr *hwmgr, uint32_t fuse_table_offset)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
const struct iceland_pt_defaults *defaults = data->power_tune_defaults;
|
||||
uint32_t temp;
|
||||
|
||||
if (iceland_read_smc_sram_dword(hwmgr->smumgr,
|
||||
fuse_table_offset +
|
||||
offsetof(SMU71_Discrete_PmFuses, TdcWaterfallCtl),
|
||||
(uint32_t *)&temp, data->sram_end))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to read PmFuses.DW6 (SviLoadLineEn) from SMC Failed!",
|
||||
return -EINVAL);
|
||||
else
|
||||
data->power_tune_table.TdcWaterfallCtl = defaults->tdc_waterfall_ctl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_populate_temperature_scaler(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_populate_gnb_lpml(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
int i;
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
|
||||
/* Currently not used. Set all to zero. */
|
||||
for (i = 0; i < 8; i++)
|
||||
data->power_tune_table.GnbLPML[i] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_min_max_vgnb_lpml_id_from_bapm_vddc(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_populate_bapm_vddc_base_leakage_sidd(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
uint16_t HiSidd = data->power_tune_table.BapmVddCBaseLeakageHiSidd;
|
||||
uint16_t LoSidd = data->power_tune_table.BapmVddCBaseLeakageLoSidd;
|
||||
struct phm_cac_tdp_table *cac_table = hwmgr->dyn_state.cac_dtp_table;
|
||||
|
||||
HiSidd = (uint16_t)(cac_table->usHighCACLeakage / 100 * 256);
|
||||
LoSidd = (uint16_t)(cac_table->usLowCACLeakage / 100 * 256);
|
||||
|
||||
data->power_tune_table.BapmVddCBaseLeakageHiSidd =
|
||||
CONVERT_FROM_HOST_TO_SMC_US(HiSidd);
|
||||
data->power_tune_table.BapmVddCBaseLeakageLoSidd =
|
||||
CONVERT_FROM_HOST_TO_SMC_US(LoSidd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iceland_populate_pm_fuses(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
uint32_t pm_fuse_table_offset;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment)) {
|
||||
if (iceland_read_smc_sram_dword(hwmgr->smumgr,
|
||||
SMU71_FIRMWARE_HEADER_LOCATION +
|
||||
offsetof(SMU71_Firmware_Header, PmFuseTable),
|
||||
&pm_fuse_table_offset, data->sram_end))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to get pm_fuse_table_offset Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW0 - DW3 */
|
||||
if (iceland_populate_bapm_vddc_vid_sidd(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate bapm vddc vid Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW4 - DW5 */
|
||||
if (iceland_populate_vddc_vid(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate vddc vid Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW6 */
|
||||
if (iceland_populate_svi_load_line(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate SviLoadLine Failed!",
|
||||
return -EINVAL);
|
||||
/* DW7 */
|
||||
if (iceland_populate_tdc_limit(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate TDCLimit Failed!", return -EINVAL);
|
||||
/* DW8 */
|
||||
if (iceland_populate_dw8(hwmgr, pm_fuse_table_offset))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate TdcWaterfallCtl, "
|
||||
"LPMLTemperature Min and Max Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW9-DW12 */
|
||||
if (0 != iceland_populate_temperature_scaler(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate LPMLTemperatureScaler Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW13-DW16 */
|
||||
if (iceland_populate_gnb_lpml(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate GnbLPML Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW17 */
|
||||
if (iceland_min_max_vgnb_lpml_id_from_bapm_vddc(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate GnbLPML Min and Max Vid Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW18 */
|
||||
if (iceland_populate_bapm_vddc_base_leakage_sidd(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate BapmVddCBaseLeakage Hi and Lo Sidd Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
if (iceland_copy_bytes_to_smc(hwmgr->smumgr, pm_fuse_table_offset,
|
||||
(uint8_t *)&data->power_tune_table,
|
||||
sizeof(struct SMU71_Discrete_PmFuses), data->sram_end))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to download PmFuseTable Failed!",
|
||||
return -EINVAL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iceland_enable_smc_cac(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
int result = 0;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_CAC)) {
|
||||
int smc_result;
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_EnableCac));
|
||||
PP_ASSERT_WITH_CODE((0 == smc_result),
|
||||
"Failed to enable CAC in SMC.", result = -1);
|
||||
|
||||
data->cac_enabled = (0 == smc_result) ? true : false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int iceland_set_power_limit(struct pp_hwmgr *hwmgr, uint32_t n)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
|
||||
if(data->power_containment_features &
|
||||
POWERCONTAINMENT_FEATURE_PkgPwrLimit)
|
||||
return smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
|
||||
PPSMC_MSG_PkgPwrSetLimit, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_set_overdriver_target_tdp(struct pp_hwmgr *pHwMgr, uint32_t target_tdp)
|
||||
{
|
||||
return smum_send_msg_to_smc_with_parameter(pHwMgr->smumgr,
|
||||
PPSMC_MSG_OverDriveSetTargetTdp, target_tdp);
|
||||
}
|
||||
|
||||
int iceland_enable_power_containment(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
SMU71_Discrete_DpmTable *dpm_table = &data->smc_state_table;
|
||||
int smc_result;
|
||||
int result = 0;
|
||||
uint32_t is_asic_kicker;
|
||||
|
||||
data->power_containment_features = 0;
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment)) {
|
||||
is_asic_kicker = cgs_read_register(hwmgr->device, mmCC_BIF_BX_STRAP2);
|
||||
is_asic_kicker = (is_asic_kicker >> 12) & 0x01;
|
||||
|
||||
if (data->enable_bapm_feature &&
|
||||
(!is_asic_kicker ||
|
||||
phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_DisableUsingActualTemperatureForPowerCalc))) {
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_EnableDTE));
|
||||
PP_ASSERT_WITH_CODE((0 == smc_result),
|
||||
"Failed to enable BAPM in SMC.", result = -1;);
|
||||
if (0 == smc_result)
|
||||
data->power_containment_features |= POWERCONTAINMENT_FEATURE_BAPM;
|
||||
}
|
||||
|
||||
if (is_asic_kicker && !phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_DisableUsingActualTemperatureForPowerCalc))
|
||||
dpm_table->DTEMode = 2;
|
||||
|
||||
if (data->enable_tdc_limit_feature) {
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_TDCLimitEnable));
|
||||
PP_ASSERT_WITH_CODE((0 == smc_result),
|
||||
"Failed to enable TDCLimit in SMC.", result = -1;);
|
||||
if (0 == smc_result)
|
||||
data->power_containment_features |=
|
||||
POWERCONTAINMENT_FEATURE_TDCLimit;
|
||||
}
|
||||
|
||||
if (data->enable_pkg_pwr_tracking_feature) {
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_PkgPwrLimitEnable));
|
||||
PP_ASSERT_WITH_CODE((0 == smc_result),
|
||||
"Failed to enable PkgPwrTracking in SMC.", result = -1;);
|
||||
if (0 == smc_result) {
|
||||
struct phm_cac_tdp_table *cac_table =
|
||||
hwmgr->dyn_state.cac_dtp_table;
|
||||
uint32_t default_limit =
|
||||
(uint32_t)(cac_table->usMaximumPowerDeliveryLimit * 256);
|
||||
|
||||
data->power_containment_features |=
|
||||
POWERCONTAINMENT_FEATURE_PkgPwrLimit;
|
||||
|
||||
if (iceland_set_power_limit(hwmgr, default_limit))
|
||||
printk(KERN_ERR "Failed to set Default Power Limit in SMC!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int iceland_power_control_set_level(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct phm_cac_tdp_table *cac_table = hwmgr->dyn_state.cac_dtp_table;
|
||||
int adjust_percent, target_tdp;
|
||||
int result = 0;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment)) {
|
||||
/* adjustment percentage has already been validated */
|
||||
adjust_percent = hwmgr->platform_descriptor.TDPAdjustmentPolarity ?
|
||||
hwmgr->platform_descriptor.TDPAdjustment :
|
||||
(-1 * hwmgr->platform_descriptor.TDPAdjustment);
|
||||
/*
|
||||
* SMC requested that target_tdp to be 7 bit fraction in DPM table
|
||||
* but message to be 8 bit fraction for messages
|
||||
*/
|
||||
target_tdp = ((100 + adjust_percent) * (int)(cac_table->usTDP * 256)) / 100;
|
||||
result = iceland_set_overdriver_target_tdp(hwmgr, (uint32_t)target_tdp);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Huang Rui <ray.huang@amd.com>
|
||||
*
|
||||
*/
|
||||
#ifndef ICELAND_POWERTUNE_H
|
||||
#define ICELAND_POWERTUNE_H
|
||||
|
||||
#include "smu71.h"
|
||||
|
||||
enum iceland_pt_config_reg_type {
|
||||
ICELAND_CONFIGREG_MMR = 0,
|
||||
ICELAND_CONFIGREG_SMC_IND,
|
||||
ICELAND_CONFIGREG_DIDT_IND,
|
||||
ICELAND_CONFIGREG_CACHE,
|
||||
ICELAND_CONFIGREG_MAX
|
||||
};
|
||||
|
||||
/* PowerContainment Features */
|
||||
#define POWERCONTAINMENT_FEATURE_DTE 0x00000001
|
||||
#define POWERCONTAINMENT_FEATURE_TDCLimit 0x00000002
|
||||
#define POWERCONTAINMENT_FEATURE_PkgPwrLimit 0x00000004
|
||||
#define POWERCONTAINMENT_FEATURE_BAPM 0x00000001
|
||||
|
||||
struct iceland_pt_config_reg {
|
||||
uint32_t offset;
|
||||
uint32_t mask;
|
||||
uint32_t shift;
|
||||
uint32_t value;
|
||||
enum iceland_pt_config_reg_type type;
|
||||
};
|
||||
|
||||
struct iceland_pt_defaults
|
||||
{
|
||||
uint8_t svi_load_line_en;
|
||||
uint8_t svi_load_line_vddc;
|
||||
uint8_t tdc_vddc_throttle_release_limit_perc;
|
||||
uint8_t tdc_mawt;
|
||||
uint8_t tdc_waterfall_ctl;
|
||||
uint8_t dte_ambient_temp_base;
|
||||
uint32_t display_cac;
|
||||
uint32_t bamp_temp_gradient;
|
||||
uint16_t bapmti_r[SMU71_DTE_ITERATIONS * SMU71_DTE_SOURCES * SMU71_DTE_SINKS];
|
||||
uint16_t bapmti_rc[SMU71_DTE_ITERATIONS * SMU71_DTE_SOURCES * SMU71_DTE_SINKS];
|
||||
};
|
||||
|
||||
void iceland_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr);
|
||||
int iceland_populate_bapm_parameters_in_dpm_table(struct pp_hwmgr *hwmgr);
|
||||
int iceland_populate_pm_fuses(struct pp_hwmgr *hwmgr);
|
||||
int iceland_enable_smc_cac(struct pp_hwmgr *hwmgr);
|
||||
int iceland_enable_power_containment(struct pp_hwmgr *hwmgr);
|
||||
int iceland_power_control_set_level(struct pp_hwmgr *hwmgr);
|
||||
|
||||
#endif /* ICELAND_POWERTUNE_H */
|
||||
|
|
@ -0,0 +1,595 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Huang Rui <ray.huang@amd.com>
|
||||
*
|
||||
*/
|
||||
#include <asm/div64.h>
|
||||
#include "iceland_thermal.h"
|
||||
#include "iceland_hwmgr.h"
|
||||
#include "iceland_smumgr.h"
|
||||
#include "atombios.h"
|
||||
#include "ppsmc.h"
|
||||
|
||||
#include "gmc/gmc_8_1_d.h"
|
||||
#include "gmc/gmc_8_1_sh_mask.h"
|
||||
|
||||
#include "bif/bif_5_0_d.h"
|
||||
#include "bif/bif_5_0_sh_mask.h"
|
||||
|
||||
#include "smu/smu_7_1_1_d.h"
|
||||
#include "smu/smu_7_1_1_sh_mask.h"
|
||||
|
||||
|
||||
/**
|
||||
* Get Fan Speed Control Parameters.
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param pSpeed is the address of the structure where the result is to be placed.
|
||||
* @exception Always succeeds except if we cannot zero out the output structure.
|
||||
*/
|
||||
int iceland_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr,
|
||||
struct phm_fan_speed_info *fan_speed_info)
|
||||
{
|
||||
|
||||
if (hwmgr->thermal_controller.fanInfo.bNoFan)
|
||||
return 0;
|
||||
|
||||
fan_speed_info->supports_percent_read = true;
|
||||
fan_speed_info->supports_percent_write = true;
|
||||
fan_speed_info->min_percent = 0;
|
||||
fan_speed_info->max_percent = 100;
|
||||
|
||||
if (0 != hwmgr->thermal_controller.fanInfo.ucTachometerPulsesPerRevolution) {
|
||||
fan_speed_info->supports_rpm_read = true;
|
||||
fan_speed_info->supports_rpm_write = true;
|
||||
fan_speed_info->min_rpm = hwmgr->thermal_controller.fanInfo.ulMinRPM;
|
||||
fan_speed_info->max_rpm = hwmgr->thermal_controller.fanInfo.ulMaxRPM;
|
||||
} else {
|
||||
fan_speed_info->min_rpm = 0;
|
||||
fan_speed_info->max_rpm = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fan Speed in percent.
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param pSpeed is the address of the structure where the result is to be placed.
|
||||
* @exception Fails is the 100% setting appears to be 0.
|
||||
*/
|
||||
int iceland_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t *speed)
|
||||
{
|
||||
uint32_t duty100;
|
||||
uint32_t duty;
|
||||
uint64_t tmp64;
|
||||
|
||||
if (hwmgr->thermal_controller.fanInfo.bNoFan)
|
||||
return 0;
|
||||
|
||||
duty100 = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL1, FMAX_DUTY100);
|
||||
duty = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_THERMAL_STATUS, FDO_PWM_DUTY);
|
||||
|
||||
if (0 == duty100)
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
tmp64 = (uint64_t)duty * 100;
|
||||
do_div(tmp64, duty100);
|
||||
*speed = (uint32_t)tmp64;
|
||||
|
||||
if (*speed > 100)
|
||||
*speed = 100;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fan Speed in RPM.
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param speed is the address of the structure where the result is to be placed.
|
||||
* @exception Returns not supported if no fan is found or if pulses per revolution are not set
|
||||
*/
|
||||
int iceland_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fan Speed Control to static mode, so that the user can decide what speed to use.
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* mode the fan control mode, 0 default, 1 by percent, 5, by RPM
|
||||
* @exception Should always succeed.
|
||||
*/
|
||||
int iceland_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode)
|
||||
{
|
||||
|
||||
if (hwmgr->fan_ctrl_is_in_default_mode) {
|
||||
hwmgr->fan_ctrl_default_mode = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, FDO_PWM_MODE);
|
||||
hwmgr->tmin = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, TMIN);
|
||||
hwmgr->fan_ctrl_is_in_default_mode = false;
|
||||
}
|
||||
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, TMIN, 0);
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, FDO_PWM_MODE, mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset Fan Speed Control to default mode.
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @exception Should always succeed.
|
||||
*/
|
||||
static int iceland_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
if (!hwmgr->fan_ctrl_is_in_default_mode) {
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, FDO_PWM_MODE, hwmgr->fan_ctrl_default_mode);
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, TMIN, hwmgr->tmin);
|
||||
hwmgr->fan_ctrl_is_in_default_mode = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iceland_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
return (smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_StartFanControl) == 0) ? 0 : -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
int iceland_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
return (smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_StopFanControl) == 0) ? 0 : -EINVAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fan Speed in percent.
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param speed is the percentage value (0% - 100%) to be set.
|
||||
* @exception Fails is the 100% setting appears to be 0.
|
||||
*/
|
||||
int iceland_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t speed)
|
||||
{
|
||||
uint32_t duty100;
|
||||
uint32_t duty;
|
||||
uint64_t tmp64;
|
||||
|
||||
if (hwmgr->thermal_controller.fanInfo.bNoFan)
|
||||
return -EINVAL;
|
||||
|
||||
if (speed > 100) {
|
||||
pr_warning("Cannot set more than 100%% duty cycle. Set it to 100.\n");
|
||||
speed = 100;
|
||||
}
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl))
|
||||
iceland_fan_ctrl_stop_smc_fan_control(hwmgr);
|
||||
|
||||
duty100 = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL1, FMAX_DUTY100);
|
||||
|
||||
if (0 == duty100)
|
||||
return -EINVAL;
|
||||
|
||||
tmp64 = (uint64_t)speed * duty100;
|
||||
do_div(tmp64, 100);
|
||||
duty = (uint32_t)tmp64;
|
||||
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL0, FDO_STATIC_DUTY, duty);
|
||||
|
||||
return iceland_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset Fan Speed to default.
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @exception Always succeeds.
|
||||
*/
|
||||
int iceland_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (hwmgr->thermal_controller.fanInfo.bNoFan)
|
||||
return 0;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl)) {
|
||||
result = iceland_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC);
|
||||
if (0 == result)
|
||||
result = iceland_fan_ctrl_start_smc_fan_control(hwmgr);
|
||||
} else
|
||||
result = iceland_fan_ctrl_set_default_mode(hwmgr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fan Speed in RPM.
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param speed is the percentage value (min - max) to be set.
|
||||
* @exception Fails is the speed not lie between min and max.
|
||||
*/
|
||||
int iceland_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the remote temperature from the SIslands thermal controller.
|
||||
*
|
||||
* @param hwmgr The address of the hardware manager.
|
||||
*/
|
||||
int iceland_thermal_get_temperature(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
int temp;
|
||||
|
||||
temp = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_MULT_THERMAL_STATUS, CTF_TEMP);
|
||||
|
||||
/*
|
||||
* Bit 9 means the reading is lower than the lowest usable
|
||||
* value.
|
||||
*/
|
||||
if (0 != (0x200 & temp))
|
||||
temp = ICELAND_THERMAL_MAXIMUM_TEMP_READING;
|
||||
else
|
||||
temp = (temp & 0x1ff);
|
||||
|
||||
temp = temp * PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the requested temperature range for high and low alert signals
|
||||
*
|
||||
* @param hwmgr The address of the hardware manager.
|
||||
* @param range Temperature range to be programmed for high and low alert signals
|
||||
* @exception PP_Result_BadInput if the input data is not valid.
|
||||
*/
|
||||
static int iceland_thermal_set_temperature_range(struct pp_hwmgr *hwmgr, uint32_t low_temp, uint32_t high_temp)
|
||||
{
|
||||
uint32_t low = ICELAND_THERMAL_MINIMUM_ALERT_TEMP * PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
|
||||
uint32_t high = ICELAND_THERMAL_MAXIMUM_ALERT_TEMP * PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
|
||||
|
||||
if (low < low_temp)
|
||||
low = low_temp;
|
||||
if (high > high_temp)
|
||||
high = high_temp;
|
||||
|
||||
if (low > high)
|
||||
return -EINVAL;
|
||||
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_THERMAL_INT, DIG_THERM_INTH, (high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_THERMAL_INT, DIG_THERM_INTL, (low / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_THERMAL_CTRL, DIG_THERM_DPM, (high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Programs thermal controller one-time setting registers
|
||||
*
|
||||
* @param hwmgr The address of the hardware manager.
|
||||
*/
|
||||
static int iceland_thermal_initialize(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
if (0 != hwmgr->thermal_controller.fanInfo.ucTachometerPulsesPerRevolution)
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
|
||||
CG_TACH_CTRL, EDGE_PER_REV,
|
||||
hwmgr->thermal_controller.fanInfo.ucTachometerPulsesPerRevolution - 1);
|
||||
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, TACH_PWM_RESP_RATE, 0x28);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable thermal alerts on the RV770 thermal controller.
|
||||
*
|
||||
* @param hwmgr The address of the hardware manager.
|
||||
*/
|
||||
static int iceland_thermal_enable_alert(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
uint32_t alert;
|
||||
|
||||
alert = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_THERMAL_INT, THERM_INT_MASK);
|
||||
alert &= ~(ICELAND_THERMAL_HIGH_ALERT_MASK | ICELAND_THERMAL_LOW_ALERT_MASK);
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_THERMAL_INT, THERM_INT_MASK, alert);
|
||||
|
||||
/* send message to SMU to enable internal thermal interrupts */
|
||||
return (smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_Thermal_Cntl_Enable) == 0) ? 0 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable thermal alerts on the RV770 thermal controller.
|
||||
* @param hwmgr The address of the hardware manager.
|
||||
*/
|
||||
static int iceland_thermal_disable_alert(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
uint32_t alert;
|
||||
|
||||
alert = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_THERMAL_INT, THERM_INT_MASK);
|
||||
alert |= (ICELAND_THERMAL_HIGH_ALERT_MASK | ICELAND_THERMAL_LOW_ALERT_MASK);
|
||||
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_THERMAL_INT, THERM_INT_MASK, alert);
|
||||
|
||||
/* send message to SMU to disable internal thermal interrupts */
|
||||
return (smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_Thermal_Cntl_Disable) == 0) ? 0 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninitialize the thermal controller.
|
||||
* Currently just disables alerts.
|
||||
* @param hwmgr The address of the hardware manager.
|
||||
*/
|
||||
int iceland_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
int result = iceland_thermal_disable_alert(hwmgr);
|
||||
|
||||
if (result)
|
||||
pr_warning("Failed to disable thermal alerts!\n");
|
||||
|
||||
if (hwmgr->thermal_controller.fanInfo.bNoFan)
|
||||
iceland_fan_ctrl_set_default_mode(hwmgr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the fan table to control the fan using the SMC.
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param pInput the pointer to input data
|
||||
* @param pOutput the pointer to output data
|
||||
* @param pStorage the pointer to temporary storage
|
||||
* @param Result the last failure code
|
||||
* @return result from set temperature range routine
|
||||
*/
|
||||
int tf_iceland_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, void *input, void *output, void *storage, int result)
|
||||
{
|
||||
struct iceland_hwmgr *data = (struct iceland_hwmgr *)(hwmgr->backend);
|
||||
SMU71_Discrete_FanTable fan_table = { FDO_MODE_HARDWARE };
|
||||
uint32_t duty100;
|
||||
uint32_t t_diff1, t_diff2, pwm_diff1, pwm_diff2;
|
||||
uint16_t fdo_min, slope1, slope2;
|
||||
uint32_t reference_clock;
|
||||
int res;
|
||||
uint64_t tmp64;
|
||||
|
||||
if (!phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl))
|
||||
return 0;
|
||||
|
||||
if (0 == data->fan_table_start) {
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
duty100 = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL1, FMAX_DUTY100);
|
||||
|
||||
if (0 == duty100) {
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
tmp64 = hwmgr->thermal_controller.advanceFanControlParameters.usPWMMin * duty100;
|
||||
do_div(tmp64, 10000);
|
||||
fdo_min = (uint16_t)tmp64;
|
||||
|
||||
t_diff1 = hwmgr->thermal_controller.advanceFanControlParameters.usTMed - hwmgr->thermal_controller.advanceFanControlParameters.usTMin;
|
||||
t_diff2 = hwmgr->thermal_controller.advanceFanControlParameters.usTHigh - hwmgr->thermal_controller.advanceFanControlParameters.usTMed;
|
||||
|
||||
pwm_diff1 = hwmgr->thermal_controller.advanceFanControlParameters.usPWMMed - hwmgr->thermal_controller.advanceFanControlParameters.usPWMMin;
|
||||
pwm_diff2 = hwmgr->thermal_controller.advanceFanControlParameters.usPWMHigh - hwmgr->thermal_controller.advanceFanControlParameters.usPWMMed;
|
||||
|
||||
slope1 = (uint16_t)((50 + ((16 * duty100 * pwm_diff1) / t_diff1)) / 100);
|
||||
slope2 = (uint16_t)((50 + ((16 * duty100 * pwm_diff2) / t_diff2)) / 100);
|
||||
|
||||
fan_table.TempMin = cpu_to_be16((50 + hwmgr->thermal_controller.advanceFanControlParameters.usTMin) / 100);
|
||||
fan_table.TempMed = cpu_to_be16((50 + hwmgr->thermal_controller.advanceFanControlParameters.usTMed) / 100);
|
||||
fan_table.TempMax = cpu_to_be16((50 + hwmgr->thermal_controller.advanceFanControlParameters.usTMax) / 100);
|
||||
|
||||
fan_table.Slope1 = cpu_to_be16(slope1);
|
||||
fan_table.Slope2 = cpu_to_be16(slope2);
|
||||
|
||||
fan_table.FdoMin = cpu_to_be16(fdo_min);
|
||||
|
||||
fan_table.HystDown = cpu_to_be16(hwmgr->thermal_controller.advanceFanControlParameters.ucTHyst);
|
||||
|
||||
fan_table.HystUp = cpu_to_be16(1);
|
||||
|
||||
fan_table.HystSlope = cpu_to_be16(1);
|
||||
|
||||
fan_table.TempRespLim = cpu_to_be16(5);
|
||||
|
||||
reference_clock = iceland_get_xclk(hwmgr);
|
||||
|
||||
fan_table.RefreshPeriod = cpu_to_be32((hwmgr->thermal_controller.advanceFanControlParameters.ulCycleDelay * reference_clock) / 1600);
|
||||
|
||||
fan_table.FdoMax = cpu_to_be16((uint16_t)duty100);
|
||||
|
||||
fan_table.TempSrc = (uint8_t)PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_MULT_THERMAL_CTRL, TEMP_SEL);
|
||||
|
||||
//fan_table.FanControl_GL_Flag = 1;
|
||||
|
||||
res = iceland_copy_bytes_to_smc(hwmgr->smumgr, data->fan_table_start, (uint8_t *)&fan_table, (uint32_t)sizeof(fan_table), data->sram_end);
|
||||
/* TO DO FOR SOME DEVICE ID 0X692b, send this msg return invalid command.
|
||||
if (res == 0 && hwmgr->thermal_controller.advanceFanControlParameters.ucMinimumPWMLimit != 0)
|
||||
res = (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanMinPwm, \
|
||||
hwmgr->thermal_controller.advanceFanControlParameters.ucMinimumPWMLimit) ? 0 : -1);
|
||||
|
||||
if (res == 0 && hwmgr->thermal_controller.advanceFanControlParameters.ulMinFanSCLKAcousticLimit != 0)
|
||||
res = (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanSclkTarget, \
|
||||
hwmgr->thermal_controller.advanceFanControlParameters.ulMinFanSCLKAcousticLimit) ? 0 : -1);
|
||||
|
||||
if (0 != res)
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl);
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the fan control on the SMC.
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param pInput the pointer to input data
|
||||
* @param pOutput the pointer to output data
|
||||
* @param pStorage the pointer to temporary storage
|
||||
* @param Result the last failure code
|
||||
* @return result from set temperature range routine
|
||||
*/
|
||||
int tf_iceland_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, void *input, void *output, void *storage, int result)
|
||||
{
|
||||
/* If the fantable setup has failed we could have disabled PHM_PlatformCaps_MicrocodeFanControl even after this function was included in the table.
|
||||
* Make sure that we still think controlling the fan is OK.
|
||||
*/
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl)) {
|
||||
iceland_fan_ctrl_start_smc_fan_control(hwmgr);
|
||||
iceland_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set temperature range for high and low alerts
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param pInput the pointer to input data
|
||||
* @param pOutput the pointer to output data
|
||||
* @param pStorage the pointer to temporary storage
|
||||
* @param Result the last failure code
|
||||
* @return result from set temperature range routine
|
||||
*/
|
||||
static int tf_iceland_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
|
||||
void *input, void *output, void *storage, int result)
|
||||
{
|
||||
struct PP_TemperatureRange *range = (struct PP_TemperatureRange *)input;
|
||||
|
||||
if (range == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
return iceland_thermal_set_temperature_range(hwmgr, range->min, range->max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Programs one-time setting registers
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param pInput the pointer to input data
|
||||
* @param pOutput the pointer to output data
|
||||
* @param pStorage the pointer to temporary storage
|
||||
* @param Result the last failure code
|
||||
* @return result from initialize thermal controller routine
|
||||
*/
|
||||
static int tf_iceland_thermal_initialize(struct pp_hwmgr *hwmgr, void *input,
|
||||
void *output, void *storage, int result)
|
||||
{
|
||||
return iceland_thermal_initialize(hwmgr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable high and low alerts
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param pInput the pointer to input data
|
||||
* @param pOutput the pointer to output data
|
||||
* @param pStorage the pointer to temporary storage
|
||||
* @param Result the last failure code
|
||||
* @return result from enable alert routine
|
||||
*/
|
||||
static int tf_iceland_thermal_enable_alert(struct pp_hwmgr *hwmgr,
|
||||
void *input, void *output, void *storage, int result)
|
||||
{
|
||||
return iceland_thermal_enable_alert(hwmgr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable high and low alerts
|
||||
* @param hwmgr the address of the powerplay hardware manager.
|
||||
* @param pInput the pointer to input data
|
||||
* @param pOutput the pointer to output data
|
||||
* @param pStorage the pointer to temporary storage
|
||||
* @param Result the last failure code
|
||||
* @return result from disable alert routine
|
||||
*/
|
||||
static int tf_iceland_thermal_disable_alert(struct pp_hwmgr *hwmgr, void *input, void *output, void *storage, int result)
|
||||
{
|
||||
return iceland_thermal_disable_alert(hwmgr);
|
||||
}
|
||||
|
||||
static const struct phm_master_table_item iceland_thermal_start_thermal_controller_master_list[] = {
|
||||
{ NULL, tf_iceland_thermal_initialize },
|
||||
{ NULL, tf_iceland_thermal_set_temperature_range },
|
||||
{ NULL, tf_iceland_thermal_enable_alert },
|
||||
/*
|
||||
* We should restrict performance levels to low before we halt
|
||||
* the SMC. On the other hand we are still in boot state when
|
||||
* we do this so it would be pointless. If this assumption
|
||||
* changes we have to revisit this table.
|
||||
*/
|
||||
{ NULL, tf_iceland_thermal_setup_fan_table},
|
||||
{ NULL, tf_iceland_thermal_start_smc_fan_control},
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const struct phm_master_table_header iceland_thermal_start_thermal_controller_master = {
|
||||
0,
|
||||
PHM_MasterTableFlag_None,
|
||||
iceland_thermal_start_thermal_controller_master_list
|
||||
};
|
||||
|
||||
static const struct phm_master_table_item iceland_thermal_set_temperature_range_master_list[] = {
|
||||
{ NULL, tf_iceland_thermal_disable_alert},
|
||||
{ NULL, tf_iceland_thermal_set_temperature_range},
|
||||
{ NULL, tf_iceland_thermal_enable_alert},
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const struct phm_master_table_header iceland_thermal_set_temperature_range_master = {
|
||||
0,
|
||||
PHM_MasterTableFlag_None,
|
||||
iceland_thermal_set_temperature_range_master_list
|
||||
};
|
||||
|
||||
int iceland_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
if (!hwmgr->thermal_controller.fanInfo.bNoFan)
|
||||
iceland_fan_ctrl_set_default_mode(hwmgr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the thermal controller related functions in the Hardware Manager structure.
|
||||
* @param hwmgr The address of the hardware manager.
|
||||
* @exception Any error code from the low-level communication.
|
||||
*/
|
||||
int pp_iceland_thermal_initialize(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = phm_construct_table(hwmgr, &iceland_thermal_set_temperature_range_master, &(hwmgr->set_temperature_range));
|
||||
|
||||
if (0 == result) {
|
||||
result = phm_construct_table(hwmgr,
|
||||
&iceland_thermal_start_thermal_controller_master,
|
||||
&(hwmgr->start_thermal_controller));
|
||||
if (0 != result)
|
||||
phm_destroy_table(hwmgr, &(hwmgr->set_temperature_range));
|
||||
}
|
||||
|
||||
if (0 == result)
|
||||
hwmgr->fan_ctrl_is_in_default_mode = true;
|
||||
return result;
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Huang Rui <ray.huang@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICELAND_THERMAL_H
|
||||
#define ICELAND_THERMAL_H
|
||||
|
||||
#include "hwmgr.h"
|
||||
|
||||
#define ICELAND_THERMAL_HIGH_ALERT_MASK 0x1
|
||||
#define ICELAND_THERMAL_LOW_ALERT_MASK 0x2
|
||||
|
||||
#define ICELAND_THERMAL_MINIMUM_TEMP_READING -256
|
||||
#define ICELAND_THERMAL_MAXIMUM_TEMP_READING 255
|
||||
|
||||
#define ICELAND_THERMAL_MINIMUM_ALERT_TEMP 0
|
||||
#define ICELAND_THERMAL_MAXIMUM_ALERT_TEMP 255
|
||||
|
||||
#define FDO_PWM_MODE_STATIC 1
|
||||
#define FDO_PWM_MODE_STATIC_RPM 5
|
||||
|
||||
|
||||
extern int iceland_thermal_get_temperature(struct pp_hwmgr *hwmgr);
|
||||
extern int iceland_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr);
|
||||
extern int iceland_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, struct phm_fan_speed_info *fan_speed_info);
|
||||
extern int iceland_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t *speed);
|
||||
extern int iceland_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode);
|
||||
extern int iceland_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t speed);
|
||||
extern int iceland_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr);
|
||||
extern int pp_iceland_thermal_initialize(struct pp_hwmgr *hwmgr);
|
||||
extern int iceland_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr);
|
||||
extern int iceland_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed);
|
||||
extern int iceland_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed);
|
||||
extern int iceland_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr);
|
||||
|
||||
#endif
|
||||
|
|
@ -97,19 +97,6 @@
|
|||
#define PCIE_BUS_CLK 10000
|
||||
#define TCLK (PCIE_BUS_CLK / 10)
|
||||
|
||||
|
||||
static const uint16_t polaris10_clock_stretcher_lookup_table[2][4] =
|
||||
{ {600, 1050, 3, 0}, {600, 1050, 6, 1} };
|
||||
|
||||
/* [FF, SS] type, [] 4 voltage ranges, and [Floor Freq, Boundary Freq, VID min , VID max] */
|
||||
static const uint32_t polaris10_clock_stretcher_ddt_table[2][4][4] =
|
||||
{ { {265, 529, 120, 128}, {325, 650, 96, 119}, {430, 860, 32, 95}, {0, 0, 0, 31} },
|
||||
{ {275, 550, 104, 112}, {319, 638, 96, 103}, {360, 720, 64, 95}, {384, 768, 32, 63} } };
|
||||
|
||||
/* [Use_For_Low_freq] value, [0%, 5%, 10%, 7.14%, 14.28%, 20%] (coming from PWR_CKS_CNTL.stretch_amount reg spec) */
|
||||
static const uint8_t polaris10_clock_stretch_amount_conversion[2][6] =
|
||||
{ {0, 1, 3, 2, 4, 5}, {0, 2, 4, 5, 6, 5} };
|
||||
|
||||
/** Values for the CG_THERMAL_CTRL::DPM_EVENT_SRC field. */
|
||||
enum DPM_EVENT_SRC {
|
||||
DPM_EVENT_SRC_ANALOG = 0,
|
||||
|
@ -2771,9 +2758,6 @@ int polaris10_set_features_platform_caps(struct pp_hwmgr *hwmgr)
|
|||
{
|
||||
struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend);
|
||||
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_SclkDeepSleep);
|
||||
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_DynamicPatchPowerState);
|
||||
|
||||
|
@ -2819,13 +2803,6 @@ int polaris10_set_features_platform_caps(struct pp_hwmgr *hwmgr)
|
|||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_TCPRamping);
|
||||
|
||||
if (hwmgr->powercontainment_enabled)
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment);
|
||||
else
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment);
|
||||
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_CAC);
|
||||
|
||||
|
@ -2904,8 +2881,8 @@ static int polaris10_get_evv_voltages(struct pp_hwmgr *hwmgr)
|
|||
continue;
|
||||
}
|
||||
|
||||
/* need to make sure vddc is less than 2v or else, it could burn the ASIC.
|
||||
* real voltage level in unit of 0.01mv */
|
||||
/* need to make sure vddc is less than 2V or else, it could burn the ASIC.
|
||||
* real voltage level in unit of 0.01mV */
|
||||
PP_ASSERT_WITH_CODE((vddc < 200000 && vddc != 0),
|
||||
"Invalid VDDC value", result = -EINVAL;);
|
||||
|
||||
|
@ -3142,7 +3119,10 @@ int polaris10_patch_voltage_workaround(struct pp_hwmgr *hwmgr)
|
|||
table_info->vddc_lookup_table;
|
||||
uint32_t i;
|
||||
|
||||
if (hwmgr->chip_id == CHIP_POLARIS10 && hwmgr->hw_revision == 0xC7) {
|
||||
if (hwmgr->chip_id == CHIP_POLARIS10 && hwmgr->hw_revision == 0xC7 &&
|
||||
((hwmgr->sub_sys_id == 0xb37 && hwmgr->sub_vendor_id == 0x1002) ||
|
||||
(hwmgr->sub_sys_id == 0x4a8 && hwmgr->sub_vendor_id == 0x1043) ||
|
||||
(hwmgr->sub_sys_id == 0x9480 && hwmgr->sub_vendor_id == 0x1682))) {
|
||||
if (lookup_table->entries[dep_mclk_table->entries[dep_mclk_table->count-1].vddInd].us_vdd >= 1000)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -301,6 +301,8 @@ void tonga_initialize_dpm_defaults(struct pp_hwmgr *hwmgr)
|
|||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_DisableMemoryTransition);
|
||||
|
||||
tonga_initialize_power_tune_defaults(hwmgr);
|
||||
|
||||
data->mclk_strobe_mode_threshold = 40000;
|
||||
data->mclk_stutter_mode_threshold = 30000;
|
||||
data->mclk_edc_enable_threshold = 40000;
|
||||
|
@ -2478,7 +2480,7 @@ static int tonga_populate_single_graphic_level(struct pp_hwmgr *hwmgr, uint32_t
|
|||
graphic_level->VoltageDownHyst = 0;
|
||||
graphic_level->PowerThrottle = 0;
|
||||
|
||||
threshold = engine_clock * data->fast_watemark_threshold / 100;
|
||||
threshold = engine_clock * data->fast_watermark_threshold / 100;
|
||||
/*
|
||||
*get the DAL clock. do it in funture.
|
||||
PECI_GetMinClockSettings(hwmgr->peci, &minClocks);
|
||||
|
@ -2981,6 +2983,10 @@ int tonga_init_smc_table(struct pp_hwmgr *hwmgr)
|
|||
PP_ASSERT_WITH_CODE(0 == result,
|
||||
"Failed to initialize Boot Level!", return result;);
|
||||
|
||||
result = tonga_populate_bapm_parameters_in_dpm_table(hwmgr);
|
||||
PP_ASSERT_WITH_CODE(result == 0,
|
||||
"Failed to populate BAPM Parameters!", return result);
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_ClockStretcher)) {
|
||||
result = tonga_populate_clock_stretcher_data_table(hwmgr);
|
||||
|
@ -4369,6 +4375,10 @@ int tonga_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
|
|||
PP_ASSERT_WITH_CODE((0 == tmp_result),
|
||||
"Failed to initialize ARB table index!", result = tmp_result);
|
||||
|
||||
tmp_result = tonga_populate_pm_fuses(hwmgr);
|
||||
PP_ASSERT_WITH_CODE((tmp_result == 0),
|
||||
"Failed to populate PM fuses!", result = tmp_result);
|
||||
|
||||
tmp_result = tonga_populate_initial_mc_reg_table(hwmgr);
|
||||
PP_ASSERT_WITH_CODE((0 == tmp_result),
|
||||
"Failed to populate initialize MC Reg table!", result = tmp_result);
|
||||
|
@ -4387,6 +4397,18 @@ int tonga_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
|
|||
PP_ASSERT_WITH_CODE((0 == tmp_result),
|
||||
"Failed to start DPM!", result = tmp_result);
|
||||
|
||||
tmp_result = tonga_enable_smc_cac(hwmgr);
|
||||
PP_ASSERT_WITH_CODE((tmp_result == 0),
|
||||
"Failed to enable SMC CAC!", result = tmp_result);
|
||||
|
||||
tmp_result = tonga_enable_power_containment(hwmgr);
|
||||
PP_ASSERT_WITH_CODE((tmp_result == 0),
|
||||
"Failed to enable power containment!", result = tmp_result);
|
||||
|
||||
tmp_result = tonga_power_control_set_level(hwmgr);
|
||||
PP_ASSERT_WITH_CODE((tmp_result == 0),
|
||||
"Failed to power control set level!", result = tmp_result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -300,6 +300,7 @@ struct tonga_hwmgr {
|
|||
bool dll_defaule_on;
|
||||
bool performance_request_registered;
|
||||
|
||||
|
||||
/* ----------------- Low Power Features ---------------------*/
|
||||
phw_tonga_bacos bacos;
|
||||
phw_tonga_ulv_parm ulv;
|
||||
|
@ -314,10 +315,14 @@ struct tonga_hwmgr {
|
|||
bool enable_tdc_limit_feature;
|
||||
bool enable_pkg_pwr_tracking_feature;
|
||||
bool disable_uvd_power_tune_feature;
|
||||
phw_tonga_pt_defaults *power_tune_defaults;
|
||||
struct tonga_pt_defaults *power_tune_defaults;
|
||||
SMU72_Discrete_PmFuses power_tune_table;
|
||||
uint32_t ul_dte_tj_offset; /* Fudge factor in DPM table to correct HW DTE errors */
|
||||
uint32_t fast_watemark_threshold; /* use fast watermark if clock is equal or above this. In percentage of the target high sclk. */
|
||||
uint32_t dte_tj_offset; /* Fudge factor in DPM table to correct HW DTE errors */
|
||||
uint32_t fast_watermark_threshold; /* use fast watermark if clock is equal or above this. In percentage of the target high sclk. */
|
||||
|
||||
|
||||
bool enable_dte_feature;
|
||||
|
||||
|
||||
/* ----------------- Phase Shedding ---------------------*/
|
||||
bool vddc_phase_shed_control;
|
||||
|
|
|
@ -0,0 +1,498 @@
|
|||
/*
|
||||
* Copyright 2015 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hwmgr.h"
|
||||
#include "smumgr.h"
|
||||
#include "tonga_hwmgr.h"
|
||||
#include "tonga_powertune.h"
|
||||
#include "tonga_smumgr.h"
|
||||
#include "smu72_discrete.h"
|
||||
#include "pp_debug.h"
|
||||
#include "tonga_ppsmc.h"
|
||||
|
||||
#define VOLTAGE_SCALE 4
|
||||
#define POWERTUNE_DEFAULT_SET_MAX 1
|
||||
|
||||
struct tonga_pt_defaults tonga_power_tune_data_set_array[POWERTUNE_DEFAULT_SET_MAX] = {
|
||||
/* sviLoadLIneEn, SviLoadLineVddC, TDC_VDDC_ThrottleReleaseLimitPerc, TDC_MAWt, TdcWaterfallCtl, DTEAmbientTempBase, DisplayCac, BAPM_TEMP_GRADIENT */
|
||||
{1, 0xF, 0xFD, 0x19, 5, 45, 0, 0xB0000,
|
||||
{0x79, 0x253, 0x25D, 0xAE, 0x72, 0x80, 0x83, 0x86, 0x6F, 0xC8, 0xC9, 0xC9, 0x2F, 0x4D, 0x61},
|
||||
{0x17C, 0x172, 0x180, 0x1BC, 0x1B3, 0x1BD, 0x206, 0x200, 0x203, 0x25D, 0x25A, 0x255, 0x2C3, 0x2C5, 0x2B4 } },
|
||||
};
|
||||
|
||||
void tonga_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct tonga_hwmgr *tonga_hwmgr = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
struct phm_ppt_v1_information *table_info =
|
||||
(struct phm_ppt_v1_information *)(hwmgr->pptable);
|
||||
uint32_t tmp = 0;
|
||||
|
||||
if (table_info &&
|
||||
table_info->cac_dtp_table->usPowerTuneDataSetID <= POWERTUNE_DEFAULT_SET_MAX &&
|
||||
table_info->cac_dtp_table->usPowerTuneDataSetID)
|
||||
tonga_hwmgr->power_tune_defaults =
|
||||
&tonga_power_tune_data_set_array
|
||||
[table_info->cac_dtp_table->usPowerTuneDataSetID - 1];
|
||||
else
|
||||
tonga_hwmgr->power_tune_defaults = &tonga_power_tune_data_set_array[0];
|
||||
|
||||
/* Assume disabled */
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_CAC);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_SQRamping);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_DBRamping);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_TDRamping);
|
||||
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_TCPRamping);
|
||||
|
||||
tonga_hwmgr->dte_tj_offset = tmp;
|
||||
|
||||
if (!tmp) {
|
||||
phm_cap_set(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_CAC);
|
||||
|
||||
tonga_hwmgr->fast_watermark_threshold = 100;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment)) {
|
||||
tmp = 1;
|
||||
tonga_hwmgr->enable_dte_feature = tmp ? false : true;
|
||||
tonga_hwmgr->enable_tdc_limit_feature = tmp ? true : false;
|
||||
tonga_hwmgr->enable_pkg_pwr_tracking_feature = tmp ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int tonga_populate_bapm_parameters_in_dpm_table(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
struct tonga_pt_defaults *defaults = data->power_tune_defaults;
|
||||
SMU72_Discrete_DpmTable *dpm_table = &(data->smc_state_table);
|
||||
struct phm_ppt_v1_information *table_info =
|
||||
(struct phm_ppt_v1_information *)(hwmgr->pptable);
|
||||
struct phm_cac_tdp_table *cac_dtp_table = table_info->cac_dtp_table;
|
||||
int i, j, k;
|
||||
uint16_t *pdef1;
|
||||
uint16_t *pdef2;
|
||||
|
||||
|
||||
/* TDP number of fraction bits are changed from 8 to 7 for Fiji
|
||||
* as requested by SMC team
|
||||
*/
|
||||
dpm_table->DefaultTdp = PP_HOST_TO_SMC_US(
|
||||
(uint16_t)(cac_dtp_table->usTDP * 256));
|
||||
dpm_table->TargetTdp = PP_HOST_TO_SMC_US(
|
||||
(uint16_t)(cac_dtp_table->usConfigurableTDP * 256));
|
||||
|
||||
PP_ASSERT_WITH_CODE(cac_dtp_table->usTargetOperatingTemp <= 255,
|
||||
"Target Operating Temp is out of Range!",
|
||||
);
|
||||
|
||||
dpm_table->GpuTjMax = (uint8_t)(cac_dtp_table->usTargetOperatingTemp);
|
||||
dpm_table->GpuTjHyst = 8;
|
||||
|
||||
dpm_table->DTEAmbientTempBase = defaults->dte_ambient_temp_base;
|
||||
|
||||
dpm_table->BAPM_TEMP_GRADIENT = PP_HOST_TO_SMC_UL(defaults->bamp_temp_gradient);
|
||||
pdef1 = defaults->bapmti_r;
|
||||
pdef2 = defaults->bapmti_rc;
|
||||
|
||||
for (i = 0; i < SMU72_DTE_ITERATIONS; i++) {
|
||||
for (j = 0; j < SMU72_DTE_SOURCES; j++) {
|
||||
for (k = 0; k < SMU72_DTE_SINKS; k++) {
|
||||
dpm_table->BAPMTI_R[i][j][k] = PP_HOST_TO_SMC_US(*pdef1);
|
||||
dpm_table->BAPMTI_RC[i][j][k] = PP_HOST_TO_SMC_US(*pdef2);
|
||||
pdef1++;
|
||||
pdef2++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tonga_populate_svi_load_line(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
const struct tonga_pt_defaults *defaults = data->power_tune_defaults;
|
||||
|
||||
data->power_tune_table.SviLoadLineEn = defaults->svi_load_line_en;
|
||||
data->power_tune_table.SviLoadLineVddC = defaults->svi_load_line_vddC;
|
||||
data->power_tune_table.SviLoadLineTrimVddC = 3;
|
||||
data->power_tune_table.SviLoadLineOffsetVddC = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tonga_populate_tdc_limit(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
uint16_t tdc_limit;
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
struct phm_ppt_v1_information *table_info =
|
||||
(struct phm_ppt_v1_information *)(hwmgr->pptable);
|
||||
const struct tonga_pt_defaults *defaults = data->power_tune_defaults;
|
||||
|
||||
/* TDC number of fraction bits are changed from 8 to 7
|
||||
* for Fiji as requested by SMC team
|
||||
*/
|
||||
tdc_limit = (uint16_t)(table_info->cac_dtp_table->usTDC * 256);
|
||||
data->power_tune_table.TDC_VDDC_PkgLimit =
|
||||
CONVERT_FROM_HOST_TO_SMC_US(tdc_limit);
|
||||
data->power_tune_table.TDC_VDDC_ThrottleReleaseLimitPerc =
|
||||
defaults->tdc_vddc_throttle_release_limit_perc;
|
||||
data->power_tune_table.TDC_MAWt = defaults->tdc_mawt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tonga_populate_dw8(struct pp_hwmgr *hwmgr, uint32_t fuse_table_offset)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
const struct tonga_pt_defaults *defaults = data->power_tune_defaults;
|
||||
uint32_t temp;
|
||||
|
||||
if (tonga_read_smc_sram_dword(hwmgr->smumgr,
|
||||
fuse_table_offset +
|
||||
offsetof(SMU72_Discrete_PmFuses, TdcWaterfallCtl),
|
||||
(uint32_t *)&temp, data->sram_end))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to read PmFuses.DW6 (SviLoadLineEn) from SMC Failed!",
|
||||
return -EINVAL);
|
||||
else
|
||||
data->power_tune_table.TdcWaterfallCtl = defaults->tdc_waterfall_ctl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tonga_populate_temperature_scaler(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
int i;
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
|
||||
/* Currently not used. Set all to zero. */
|
||||
for (i = 0; i < 16; i++)
|
||||
data->power_tune_table.LPMLTemperatureScaler[i] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tonga_populate_fuzzy_fan(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
|
||||
if ((hwmgr->thermal_controller.advanceFanControlParameters.
|
||||
usFanOutputSensitivity & (1 << 15)) ||
|
||||
(hwmgr->thermal_controller.advanceFanControlParameters.usFanOutputSensitivity == 0))
|
||||
hwmgr->thermal_controller.advanceFanControlParameters.
|
||||
usFanOutputSensitivity = hwmgr->thermal_controller.
|
||||
advanceFanControlParameters.usDefaultFanOutputSensitivity;
|
||||
|
||||
data->power_tune_table.FuzzyFan_PwmSetDelta =
|
||||
PP_HOST_TO_SMC_US(hwmgr->thermal_controller.
|
||||
advanceFanControlParameters.usFanOutputSensitivity);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tonga_populate_gnb_lpml(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
int i;
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
|
||||
/* Currently not used. Set all to zero. */
|
||||
for (i = 0; i < 16; i++)
|
||||
data->power_tune_table.GnbLPML[i] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tonga_min_max_vgnb_lpml_id_from_bapm_vddc(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tonga_populate_bapm_vddc_base_leakage_sidd(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
struct phm_ppt_v1_information *table_info =
|
||||
(struct phm_ppt_v1_information *)(hwmgr->pptable);
|
||||
uint16_t hi_sidd = data->power_tune_table.BapmVddCBaseLeakageHiSidd;
|
||||
uint16_t lo_sidd = data->power_tune_table.BapmVddCBaseLeakageLoSidd;
|
||||
struct phm_cac_tdp_table *cac_table = table_info->cac_dtp_table;
|
||||
|
||||
hi_sidd = (uint16_t)(cac_table->usHighCACLeakage / 100 * 256);
|
||||
lo_sidd = (uint16_t)(cac_table->usLowCACLeakage / 100 * 256);
|
||||
|
||||
data->power_tune_table.BapmVddCBaseLeakageHiSidd =
|
||||
CONVERT_FROM_HOST_TO_SMC_US(hi_sidd);
|
||||
data->power_tune_table.BapmVddCBaseLeakageLoSidd =
|
||||
CONVERT_FROM_HOST_TO_SMC_US(lo_sidd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tonga_populate_pm_fuses(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
uint32_t pm_fuse_table_offset;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment)) {
|
||||
if (tonga_read_smc_sram_dword(hwmgr->smumgr,
|
||||
SMU72_FIRMWARE_HEADER_LOCATION +
|
||||
offsetof(SMU72_Firmware_Header, PmFuseTable),
|
||||
&pm_fuse_table_offset, data->sram_end))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to get pm_fuse_table_offset Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW6 */
|
||||
if (tonga_populate_svi_load_line(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate SviLoadLine Failed!",
|
||||
return -EINVAL);
|
||||
/* DW7 */
|
||||
if (tonga_populate_tdc_limit(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate TDCLimit Failed!", return -EINVAL);
|
||||
/* DW8 */
|
||||
if (tonga_populate_dw8(hwmgr, pm_fuse_table_offset))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate TdcWaterfallCtl Failed !",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW9-DW12 */
|
||||
if (tonga_populate_temperature_scaler(hwmgr) != 0)
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate LPMLTemperatureScaler Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW13-DW14 */
|
||||
if (tonga_populate_fuzzy_fan(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate Fuzzy Fan Control parameters Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW15-DW18 */
|
||||
if (tonga_populate_gnb_lpml(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate GnbLPML Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW19 */
|
||||
if (tonga_min_max_vgnb_lpml_id_from_bapm_vddc(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate GnbLPML Min and Max Vid Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
/* DW20 */
|
||||
if (tonga_populate_bapm_vddc_base_leakage_sidd(hwmgr))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to populate BapmVddCBaseLeakage Hi and Lo Sidd Failed!",
|
||||
return -EINVAL);
|
||||
|
||||
if (tonga_copy_bytes_to_smc(hwmgr->smumgr, pm_fuse_table_offset,
|
||||
(uint8_t *)&data->power_tune_table,
|
||||
sizeof(struct SMU72_Discrete_PmFuses), data->sram_end))
|
||||
PP_ASSERT_WITH_CODE(false,
|
||||
"Attempt to download PmFuseTable Failed!",
|
||||
return -EINVAL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tonga_enable_smc_cac(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
int result = 0;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_CAC)) {
|
||||
int smc_result;
|
||||
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_EnableCac));
|
||||
PP_ASSERT_WITH_CODE((smc_result == 0),
|
||||
"Failed to enable CAC in SMC.", result = -1);
|
||||
|
||||
data->cac_enabled = (smc_result == 0) ? true : false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int tonga_disable_smc_cac(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
int result = 0;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_CAC) && data->cac_enabled) {
|
||||
int smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_DisableCac));
|
||||
PP_ASSERT_WITH_CODE((smc_result == 0),
|
||||
"Failed to disable CAC in SMC.", result = -1);
|
||||
|
||||
data->cac_enabled = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int tonga_set_power_limit(struct pp_hwmgr *hwmgr, uint32_t n)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
|
||||
if (data->power_containment_features &
|
||||
POWERCONTAINMENT_FEATURE_PkgPwrLimit)
|
||||
return smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
|
||||
PPSMC_MSG_PkgPwrSetLimit, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tonga_set_overdriver_target_tdp(struct pp_hwmgr *pHwMgr, uint32_t target_tdp)
|
||||
{
|
||||
return smum_send_msg_to_smc_with_parameter(pHwMgr->smumgr,
|
||||
PPSMC_MSG_OverDriveSetTargetTdp, target_tdp);
|
||||
}
|
||||
|
||||
int tonga_enable_power_containment(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
struct phm_ppt_v1_information *table_info =
|
||||
(struct phm_ppt_v1_information *)(hwmgr->pptable);
|
||||
int smc_result;
|
||||
int result = 0;
|
||||
|
||||
data->power_containment_features = 0;
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment)) {
|
||||
if (data->enable_dte_feature) {
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_EnableDTE));
|
||||
PP_ASSERT_WITH_CODE((smc_result == 0),
|
||||
"Failed to enable DTE in SMC.", result = -1;);
|
||||
if (smc_result == 0)
|
||||
data->power_containment_features |= POWERCONTAINMENT_FEATURE_DTE;
|
||||
}
|
||||
|
||||
if (data->enable_tdc_limit_feature) {
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_TDCLimitEnable));
|
||||
PP_ASSERT_WITH_CODE((smc_result == 0),
|
||||
"Failed to enable TDCLimit in SMC.", result = -1;);
|
||||
if (smc_result == 0)
|
||||
data->power_containment_features |=
|
||||
POWERCONTAINMENT_FEATURE_TDCLimit;
|
||||
}
|
||||
|
||||
if (data->enable_pkg_pwr_tracking_feature) {
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_PkgPwrLimitEnable));
|
||||
PP_ASSERT_WITH_CODE((smc_result == 0),
|
||||
"Failed to enable PkgPwrTracking in SMC.", result = -1;);
|
||||
if (smc_result == 0) {
|
||||
struct phm_cac_tdp_table *cac_table =
|
||||
table_info->cac_dtp_table;
|
||||
uint32_t default_limit =
|
||||
(uint32_t)(cac_table->usMaximumPowerDeliveryLimit * 256);
|
||||
|
||||
data->power_containment_features |=
|
||||
POWERCONTAINMENT_FEATURE_PkgPwrLimit;
|
||||
|
||||
if (tonga_set_power_limit(hwmgr, default_limit))
|
||||
printk(KERN_ERR "Failed to set Default Power Limit in SMC!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int tonga_disable_power_containment(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
|
||||
int result = 0;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment) &&
|
||||
data->power_containment_features) {
|
||||
int smc_result;
|
||||
|
||||
if (data->power_containment_features &
|
||||
POWERCONTAINMENT_FEATURE_TDCLimit) {
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_TDCLimitDisable));
|
||||
PP_ASSERT_WITH_CODE((smc_result == 0),
|
||||
"Failed to disable TDCLimit in SMC.",
|
||||
result = smc_result);
|
||||
}
|
||||
|
||||
if (data->power_containment_features &
|
||||
POWERCONTAINMENT_FEATURE_DTE) {
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_DisableDTE));
|
||||
PP_ASSERT_WITH_CODE((smc_result == 0),
|
||||
"Failed to disable DTE in SMC.",
|
||||
result = smc_result);
|
||||
}
|
||||
|
||||
if (data->power_containment_features &
|
||||
POWERCONTAINMENT_FEATURE_PkgPwrLimit) {
|
||||
smc_result = smum_send_msg_to_smc(hwmgr->smumgr,
|
||||
(uint16_t)(PPSMC_MSG_PkgPwrLimitDisable));
|
||||
PP_ASSERT_WITH_CODE((smc_result == 0),
|
||||
"Failed to disable PkgPwrTracking in SMC.",
|
||||
result = smc_result);
|
||||
}
|
||||
data->power_containment_features = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int tonga_power_control_set_level(struct pp_hwmgr *hwmgr)
|
||||
{
|
||||
struct phm_ppt_v1_information *table_info =
|
||||
(struct phm_ppt_v1_information *)(hwmgr->pptable);
|
||||
struct phm_cac_tdp_table *cac_table = table_info->cac_dtp_table;
|
||||
int adjust_percent, target_tdp;
|
||||
int result = 0;
|
||||
|
||||
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
|
||||
PHM_PlatformCaps_PowerContainment)) {
|
||||
/* adjustment percentage has already been validated */
|
||||
adjust_percent = hwmgr->platform_descriptor.TDPAdjustmentPolarity ?
|
||||
hwmgr->platform_descriptor.TDPAdjustment :
|
||||
(-1 * hwmgr->platform_descriptor.TDPAdjustment);
|
||||
/* SMC requested that target_tdp to be 7 bit fraction in DPM table
|
||||
* but message to be 8 bit fraction for messages
|
||||
*/
|
||||
target_tdp = ((100 + adjust_percent) * (int)(cac_table->usTDP * 256)) / 100;
|
||||
result = tonga_set_overdriver_target_tdp(hwmgr, (uint32_t)target_tdp);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
|
@ -34,21 +34,24 @@ enum _phw_tonga_ptc_config_reg_type {
|
|||
};
|
||||
typedef enum _phw_tonga_ptc_config_reg_type phw_tonga_ptc_config_reg_type;
|
||||
|
||||
/* PowerContainment Features */
|
||||
#define POWERCONTAINMENT_FEATURE_DTE 0x00000001
|
||||
|
||||
|
||||
/* PowerContainment Features */
|
||||
#define POWERCONTAINMENT_FEATURE_BAPM 0x00000001
|
||||
#define POWERCONTAINMENT_FEATURE_TDCLimit 0x00000002
|
||||
#define POWERCONTAINMENT_FEATURE_PkgPwrLimit 0x00000004
|
||||
|
||||
struct _phw_tonga_pt_config_reg {
|
||||
struct tonga_pt_config_reg {
|
||||
uint32_t Offset;
|
||||
uint32_t Mask;
|
||||
uint32_t Shift;
|
||||
uint32_t Value;
|
||||
phw_tonga_ptc_config_reg_type Type;
|
||||
};
|
||||
typedef struct _phw_tonga_pt_config_reg phw_tonga_pt_config_reg;
|
||||
|
||||
struct _phw_tonga_pt_defaults {
|
||||
struct tonga_pt_defaults {
|
||||
uint8_t svi_load_line_en;
|
||||
uint8_t svi_load_line_vddC;
|
||||
uint8_t tdc_vddc_throttle_release_limit_perc;
|
||||
|
@ -60,7 +63,18 @@ struct _phw_tonga_pt_defaults {
|
|||
uint16_t bapmti_r[SMU72_DTE_ITERATIONS * SMU72_DTE_SOURCES * SMU72_DTE_SINKS];
|
||||
uint16_t bapmti_rc[SMU72_DTE_ITERATIONS * SMU72_DTE_SOURCES * SMU72_DTE_SINKS];
|
||||
};
|
||||
typedef struct _phw_tonga_pt_defaults phw_tonga_pt_defaults;
|
||||
|
||||
|
||||
|
||||
void tonga_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr);
|
||||
int tonga_populate_bapm_parameters_in_dpm_table(struct pp_hwmgr *hwmgr);
|
||||
int tonga_populate_pm_fuses(struct pp_hwmgr *hwmgr);
|
||||
int tonga_enable_smc_cac(struct pp_hwmgr *hwmgr);
|
||||
int tonga_disable_smc_cac(struct pp_hwmgr *hwmgr);
|
||||
int tonga_enable_power_containment(struct pp_hwmgr *hwmgr);
|
||||
int tonga_disable_power_containment(struct pp_hwmgr *hwmgr);
|
||||
int tonga_set_power_limit(struct pp_hwmgr *hwmgr, uint32_t n);
|
||||
int tonga_power_control_set_level(struct pp_hwmgr *hwmgr);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -132,8 +132,10 @@ struct amd_pp_init {
|
|||
uint32_t chip_family;
|
||||
uint32_t chip_id;
|
||||
uint32_t rev_id;
|
||||
bool powercontainment_enabled;
|
||||
uint16_t sub_sys_id;
|
||||
uint16_t sub_vendor_id;
|
||||
};
|
||||
|
||||
enum amd_pp_display_config_type{
|
||||
AMD_PP_DisplayConfigType_None = 0,
|
||||
AMD_PP_DisplayConfigType_DP54 ,
|
||||
|
|
|
@ -41,6 +41,9 @@ struct phm_fan_speed_info;
|
|||
struct pp_atomctrl_voltage_table;
|
||||
|
||||
|
||||
extern int amdgpu_powercontainment;
|
||||
extern int amdgpu_sclk_deep_sleep_en;
|
||||
|
||||
enum DISPLAY_GAP {
|
||||
DISPLAY_GAP_VBLANK_OR_WM = 0, /* Wait for vblank or MCHG watermark. */
|
||||
DISPLAY_GAP_VBLANK = 1, /* Wait for vblank. */
|
||||
|
@ -614,7 +617,6 @@ struct pp_hwmgr {
|
|||
uint32_t num_ps;
|
||||
struct pp_thermal_controller_info thermal_controller;
|
||||
bool fan_ctrl_is_in_default_mode;
|
||||
bool powercontainment_enabled;
|
||||
uint32_t fan_ctrl_default_mode;
|
||||
uint32_t tmin;
|
||||
struct phm_microcode_version_info microcode_version_info;
|
||||
|
@ -637,16 +639,7 @@ extern int hw_init_power_state_table(struct pp_hwmgr *hwmgr);
|
|||
extern int phm_wait_on_register(struct pp_hwmgr *hwmgr, uint32_t index,
|
||||
uint32_t value, uint32_t mask);
|
||||
|
||||
extern int phm_wait_for_register_unequal(struct pp_hwmgr *hwmgr,
|
||||
uint32_t index, uint32_t value, uint32_t mask);
|
||||
|
||||
extern uint32_t phm_read_indirect_register(struct pp_hwmgr *hwmgr,
|
||||
uint32_t indirect_port, uint32_t index);
|
||||
|
||||
extern void phm_write_indirect_register(struct pp_hwmgr *hwmgr,
|
||||
uint32_t indirect_port,
|
||||
uint32_t index,
|
||||
uint32_t value);
|
||||
|
||||
extern void phm_wait_on_indirect_register(struct pp_hwmgr *hwmgr,
|
||||
uint32_t indirect_port,
|
||||
|
@ -654,12 +647,7 @@ extern void phm_wait_on_indirect_register(struct pp_hwmgr *hwmgr,
|
|||
uint32_t value,
|
||||
uint32_t mask);
|
||||
|
||||
extern void phm_wait_for_indirect_register_unequal(
|
||||
struct pp_hwmgr *hwmgr,
|
||||
uint32_t indirect_port,
|
||||
uint32_t index,
|
||||
uint32_t value,
|
||||
uint32_t mask);
|
||||
|
||||
|
||||
extern bool phm_cf_want_uvd_power_gating(struct pp_hwmgr *hwmgr);
|
||||
extern bool phm_cf_want_vce_power_gating(struct pp_hwmgr *hwmgr);
|
||||
|
@ -697,43 +685,7 @@ extern void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr);
|
|||
PHM_FIELD_SHIFT(reg, field))
|
||||
|
||||
|
||||
#define PHM_WAIT_REGISTER_GIVEN_INDEX(hwmgr, index, value, mask) \
|
||||
phm_wait_on_register(hwmgr, index, value, mask)
|
||||
|
||||
#define PHM_WAIT_REGISTER_UNEQUAL_GIVEN_INDEX(hwmgr, index, value, mask) \
|
||||
phm_wait_for_register_unequal(hwmgr, index, value, mask)
|
||||
|
||||
#define PHM_WAIT_INDIRECT_REGISTER_GIVEN_INDEX(hwmgr, port, index, value, mask) \
|
||||
phm_wait_on_indirect_register(hwmgr, mm##port##_INDEX, index, value, mask)
|
||||
|
||||
#define PHM_WAIT_INDIRECT_REGISTER_UNEQUAL_GIVEN_INDEX(hwmgr, port, index, value, mask) \
|
||||
phm_wait_for_indirect_register_unequal(hwmgr, mm##port##_INDEX, index, value, mask)
|
||||
|
||||
#define PHM_WAIT_VFPF_INDIRECT_REGISTER_GIVEN_INDEX(hwmgr, port, index, value, mask) \
|
||||
phm_wait_on_indirect_register(hwmgr, mm##port##_INDEX_0, index, value, mask)
|
||||
|
||||
#define PHM_WAIT_VFPF_INDIRECT_REGISTER_UNEQUAL_GIVEN_INDEX(hwmgr, port, index, value, mask) \
|
||||
phm_wait_for_indirect_register_unequal(hwmgr, mm##port##_INDEX_0, index, value, mask)
|
||||
|
||||
/* Operations on named registers. */
|
||||
|
||||
#define PHM_WAIT_REGISTER(hwmgr, reg, value, mask) \
|
||||
PHM_WAIT_REGISTER_GIVEN_INDEX(hwmgr, mm##reg, value, mask)
|
||||
|
||||
#define PHM_WAIT_REGISTER_UNEQUAL(hwmgr, reg, value, mask) \
|
||||
PHM_WAIT_REGISTER_UNEQUAL_GIVEN_INDEX(hwmgr, mm##reg, value, mask)
|
||||
|
||||
#define PHM_WAIT_INDIRECT_REGISTER(hwmgr, port, reg, value, mask) \
|
||||
PHM_WAIT_INDIRECT_REGISTER_GIVEN_INDEX(hwmgr, port, ix##reg, value, mask)
|
||||
|
||||
#define PHM_WAIT_INDIRECT_REGISTER_UNEQUAL(hwmgr, port, reg, value, mask) \
|
||||
PHM_WAIT_INDIRECT_REGISTER_UNEQUAL_GIVEN_INDEX(hwmgr, port, ix##reg, value, mask)
|
||||
|
||||
#define PHM_WAIT_VFPF_INDIRECT_REGISTER(hwmgr, port, reg, value, mask) \
|
||||
PHM_WAIT_VFPF_INDIRECT_REGISTER_GIVEN_INDEX(hwmgr, port, ix##reg, value, mask)
|
||||
|
||||
#define PHM_WAIT_VFPF_INDIRECT_REGISTER_UNEQUAL(hwmgr, port, reg, value, mask) \
|
||||
PHM_WAIT_VFPF_INDIRECT_REGISTER_UNEQUAL_GIVEN_INDEX(hwmgr, port, ix##reg, value, mask)
|
||||
|
||||
/* Operations on named fields. */
|
||||
|
||||
|
@ -762,60 +714,16 @@ extern void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr);
|
|||
PHM_SET_FIELD(cgs_read_ind_register(device, port, ix##reg), \
|
||||
reg, field, fieldval))
|
||||
|
||||
#define PHM_WAIT_FIELD(hwmgr, reg, field, fieldval) \
|
||||
PHM_WAIT_REGISTER(hwmgr, reg, (fieldval) \
|
||||
<< PHM_FIELD_SHIFT(reg, field), PHM_FIELD_MASK(reg, field))
|
||||
#define PHM_WAIT_INDIRECT_REGISTER_GIVEN_INDEX(hwmgr, port, index, value, mask) \
|
||||
phm_wait_on_indirect_register(hwmgr, mm##port##_INDEX, index, value, mask)
|
||||
|
||||
|
||||
#define PHM_WAIT_INDIRECT_REGISTER(hwmgr, port, reg, value, mask) \
|
||||
PHM_WAIT_INDIRECT_REGISTER_GIVEN_INDEX(hwmgr, port, ix##reg, value, mask)
|
||||
|
||||
#define PHM_WAIT_INDIRECT_FIELD(hwmgr, port, reg, field, fieldval) \
|
||||
PHM_WAIT_INDIRECT_REGISTER(hwmgr, port, reg, (fieldval) \
|
||||
<< PHM_FIELD_SHIFT(reg, field), PHM_FIELD_MASK(reg, field))
|
||||
|
||||
#define PHM_WAIT_VFPF_INDIRECT_FIELD(hwmgr, port, reg, field, fieldval) \
|
||||
PHM_WAIT_VFPF_INDIRECT_REGISTER(hwmgr, port, reg, (fieldval) \
|
||||
<< PHM_FIELD_SHIFT(reg, field), PHM_FIELD_MASK(reg, field))
|
||||
|
||||
#define PHM_WAIT_FIELD_UNEQUAL(hwmgr, reg, field, fieldval) \
|
||||
PHM_WAIT_REGISTER_UNEQUAL(hwmgr, reg, (fieldval) \
|
||||
<< PHM_FIELD_SHIFT(reg, field), PHM_FIELD_MASK(reg, field))
|
||||
|
||||
#define PHM_WAIT_INDIRECT_FIELD_UNEQUAL(hwmgr, port, reg, field, fieldval) \
|
||||
PHM_WAIT_INDIRECT_REGISTER_UNEQUAL(hwmgr, port, reg, (fieldval) \
|
||||
<< PHM_FIELD_SHIFT(reg, field), PHM_FIELD_MASK(reg, field))
|
||||
|
||||
#define PHM_WAIT_VFPF_INDIRECT_FIELD_UNEQUAL(hwmgr, port, reg, field, fieldval) \
|
||||
PHM_WAIT_VFPF_INDIRECT_REGISTER_UNEQUAL(hwmgr, port, reg, (fieldval) \
|
||||
<< PHM_FIELD_SHIFT(reg, field), PHM_FIELD_MASK(reg, field))
|
||||
|
||||
/* Operations on arrays of registers & fields. */
|
||||
|
||||
#define PHM_READ_ARRAY_REGISTER(device, reg, offset) \
|
||||
cgs_read_register(device, mm##reg + (offset))
|
||||
|
||||
#define PHM_WRITE_ARRAY_REGISTER(device, reg, offset, value) \
|
||||
cgs_write_register(device, mm##reg + (offset), value)
|
||||
|
||||
#define PHM_WAIT_ARRAY_REGISTER(hwmgr, reg, offset, value, mask) \
|
||||
PHM_WAIT_REGISTER_GIVEN_INDEX(hwmgr, mm##reg + (offset), value, mask)
|
||||
|
||||
#define PHM_WAIT_ARRAY_REGISTER_UNEQUAL(hwmgr, reg, offset, value, mask) \
|
||||
PHM_WAIT_REGISTER_UNEQUAL_GIVEN_INDEX(hwmgr, mm##reg + (offset), value, mask)
|
||||
|
||||
#define PHM_READ_ARRAY_FIELD(hwmgr, reg, offset, field) \
|
||||
PHM_GET_FIELD(PHM_READ_ARRAY_REGISTER(hwmgr->device, reg, offset), reg, field)
|
||||
|
||||
#define PHM_WRITE_ARRAY_FIELD(hwmgr, reg, offset, field, fieldvalue) \
|
||||
PHM_WRITE_ARRAY_REGISTER(hwmgr->device, reg, offset, \
|
||||
PHM_SET_FIELD(PHM_READ_ARRAY_REGISTER(hwmgr->device, reg, offset), \
|
||||
reg, field, fieldvalue))
|
||||
|
||||
#define PHM_WAIT_ARRAY_FIELD(hwmgr, reg, offset, field, fieldvalue) \
|
||||
PHM_WAIT_REGISTER_GIVEN_INDEX(hwmgr, mm##reg + (offset), \
|
||||
(fieldvalue) << PHM_FIELD_SHIFT(reg, field), \
|
||||
PHM_FIELD_MASK(reg, field))
|
||||
|
||||
#define PHM_WAIT_ARRAY_FIELD_UNEQUAL(hwmgr, reg, offset, field, fieldvalue) \
|
||||
PHM_WAIT_REGISTER_UNEQUAL_GIVEN_INDEX(hwmgr, mm##reg + (offset), \
|
||||
(fieldvalue) << PHM_FIELD_SHIFT(reg, field), \
|
||||
PHM_FIELD_MASK(reg, field))
|
||||
|
||||
#endif /* _HWMGR_H_ */
|
||||
|
|
|
@ -0,0 +1,510 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef SMU71_H
|
||||
#define SMU71_H
|
||||
|
||||
#if !defined(SMC_MICROCODE)
|
||||
#pragma pack(push, 1)
|
||||
#endif
|
||||
|
||||
#define SMU__NUM_PCIE_DPM_LEVELS 8
|
||||
#define SMU__NUM_SCLK_DPM_STATE 8
|
||||
#define SMU__NUM_MCLK_DPM_LEVELS 4
|
||||
#define SMU__VARIANT__ICELAND 1
|
||||
#define SMU__DGPU_ONLY 1
|
||||
#define SMU__DYNAMIC_MCARB_SETTINGS 1
|
||||
|
||||
enum SID_OPTION {
|
||||
SID_OPTION_HI,
|
||||
SID_OPTION_LO,
|
||||
SID_OPTION_COUNT
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t high;
|
||||
uint32_t low;
|
||||
} data_64_t;
|
||||
|
||||
typedef struct {
|
||||
data_64_t high;
|
||||
data_64_t low;
|
||||
} data_128_t;
|
||||
|
||||
#define SMU7_CONTEXT_ID_SMC 1
|
||||
#define SMU7_CONTEXT_ID_VBIOS 2
|
||||
|
||||
#define SMU71_MAX_LEVELS_VDDC 8
|
||||
#define SMU71_MAX_LEVELS_VDDCI 4
|
||||
#define SMU71_MAX_LEVELS_MVDD 4
|
||||
#define SMU71_MAX_LEVELS_VDDNB 8
|
||||
|
||||
#define SMU71_MAX_LEVELS_GRAPHICS SMU__NUM_SCLK_DPM_STATE
|
||||
#define SMU71_MAX_LEVELS_MEMORY SMU__NUM_MCLK_DPM_LEVELS
|
||||
#define SMU71_MAX_LEVELS_GIO SMU__NUM_LCLK_DPM_LEVELS
|
||||
#define SMU71_MAX_LEVELS_LINK SMU__NUM_PCIE_DPM_LEVELS
|
||||
#define SMU71_MAX_ENTRIES_SMIO 32
|
||||
|
||||
#define DPM_NO_LIMIT 0
|
||||
#define DPM_NO_UP 1
|
||||
#define DPM_GO_DOWN 2
|
||||
#define DPM_GO_UP 3
|
||||
|
||||
#define SMU7_FIRST_DPM_GRAPHICS_LEVEL 0
|
||||
#define SMU7_FIRST_DPM_MEMORY_LEVEL 0
|
||||
|
||||
#define GPIO_CLAMP_MODE_VRHOT 1
|
||||
#define GPIO_CLAMP_MODE_THERM 2
|
||||
#define GPIO_CLAMP_MODE_DC 4
|
||||
|
||||
#define SCRATCH_B_TARG_PCIE_INDEX_SHIFT 0
|
||||
#define SCRATCH_B_TARG_PCIE_INDEX_MASK (0x7<<SCRATCH_B_TARG_PCIE_INDEX_SHIFT)
|
||||
#define SCRATCH_B_CURR_PCIE_INDEX_SHIFT 3
|
||||
#define SCRATCH_B_CURR_PCIE_INDEX_MASK (0x7<<SCRATCH_B_CURR_PCIE_INDEX_SHIFT)
|
||||
#define SCRATCH_B_TARG_UVD_INDEX_SHIFT 6
|
||||
#define SCRATCH_B_TARG_UVD_INDEX_MASK (0x7<<SCRATCH_B_TARG_UVD_INDEX_SHIFT)
|
||||
#define SCRATCH_B_CURR_UVD_INDEX_SHIFT 9
|
||||
#define SCRATCH_B_CURR_UVD_INDEX_MASK (0x7<<SCRATCH_B_CURR_UVD_INDEX_SHIFT)
|
||||
#define SCRATCH_B_TARG_VCE_INDEX_SHIFT 12
|
||||
#define SCRATCH_B_TARG_VCE_INDEX_MASK (0x7<<SCRATCH_B_TARG_VCE_INDEX_SHIFT)
|
||||
#define SCRATCH_B_CURR_VCE_INDEX_SHIFT 15
|
||||
#define SCRATCH_B_CURR_VCE_INDEX_MASK (0x7<<SCRATCH_B_CURR_VCE_INDEX_SHIFT)
|
||||
#define SCRATCH_B_TARG_ACP_INDEX_SHIFT 18
|
||||
#define SCRATCH_B_TARG_ACP_INDEX_MASK (0x7<<SCRATCH_B_TARG_ACP_INDEX_SHIFT)
|
||||
#define SCRATCH_B_CURR_ACP_INDEX_SHIFT 21
|
||||
#define SCRATCH_B_CURR_ACP_INDEX_MASK (0x7<<SCRATCH_B_CURR_ACP_INDEX_SHIFT)
|
||||
#define SCRATCH_B_TARG_SAMU_INDEX_SHIFT 24
|
||||
#define SCRATCH_B_TARG_SAMU_INDEX_MASK (0x7<<SCRATCH_B_TARG_SAMU_INDEX_SHIFT)
|
||||
#define SCRATCH_B_CURR_SAMU_INDEX_SHIFT 27
|
||||
#define SCRATCH_B_CURR_SAMU_INDEX_MASK (0x7<<SCRATCH_B_CURR_SAMU_INDEX_SHIFT)
|
||||
|
||||
|
||||
#if defined SMU__DGPU_ONLY
|
||||
#define SMU71_DTE_ITERATIONS 5
|
||||
#define SMU71_DTE_SOURCES 3
|
||||
#define SMU71_DTE_SINKS 1
|
||||
#define SMU71_NUM_CPU_TES 0
|
||||
#define SMU71_NUM_GPU_TES 1
|
||||
#define SMU71_NUM_NON_TES 2
|
||||
|
||||
#endif
|
||||
|
||||
#if defined SMU__FUSION_ONLY
|
||||
#define SMU7_DTE_ITERATIONS 5
|
||||
#define SMU7_DTE_SOURCES 5
|
||||
#define SMU7_DTE_SINKS 3
|
||||
#define SMU7_NUM_CPU_TES 2
|
||||
#define SMU7_NUM_GPU_TES 1
|
||||
#define SMU7_NUM_NON_TES 2
|
||||
|
||||
#endif
|
||||
|
||||
struct SMU71_PIDController
|
||||
{
|
||||
uint32_t Ki;
|
||||
int32_t LFWindupUpperLim;
|
||||
int32_t LFWindupLowerLim;
|
||||
uint32_t StatePrecision;
|
||||
uint32_t LfPrecision;
|
||||
uint32_t LfOffset;
|
||||
uint32_t MaxState;
|
||||
uint32_t MaxLfFraction;
|
||||
uint32_t StateShift;
|
||||
};
|
||||
|
||||
typedef struct SMU71_PIDController SMU71_PIDController;
|
||||
|
||||
struct SMU7_LocalDpmScoreboard
|
||||
{
|
||||
uint32_t PercentageBusy;
|
||||
|
||||
int32_t PIDError;
|
||||
int32_t PIDIntegral;
|
||||
int32_t PIDOutput;
|
||||
|
||||
uint32_t SigmaDeltaAccum;
|
||||
uint32_t SigmaDeltaOutput;
|
||||
uint32_t SigmaDeltaLevel;
|
||||
|
||||
uint32_t UtilizationSetpoint;
|
||||
|
||||
uint8_t TdpClampMode;
|
||||
uint8_t TdcClampMode;
|
||||
uint8_t ThermClampMode;
|
||||
uint8_t VoltageBusy;
|
||||
|
||||
int8_t CurrLevel;
|
||||
int8_t TargLevel;
|
||||
uint8_t LevelChangeInProgress;
|
||||
uint8_t UpHyst;
|
||||
|
||||
uint8_t DownHyst;
|
||||
uint8_t VoltageDownHyst;
|
||||
uint8_t DpmEnable;
|
||||
uint8_t DpmRunning;
|
||||
|
||||
uint8_t DpmForce;
|
||||
uint8_t DpmForceLevel;
|
||||
uint8_t DisplayWatermark;
|
||||
uint8_t McArbIndex;
|
||||
|
||||
uint32_t MinimumPerfSclk;
|
||||
|
||||
uint8_t AcpiReq;
|
||||
uint8_t AcpiAck;
|
||||
uint8_t GfxClkSlow;
|
||||
uint8_t GpioClampMode;
|
||||
|
||||
uint8_t FpsFilterWeight;
|
||||
uint8_t EnabledLevelsChange;
|
||||
uint8_t DteClampMode;
|
||||
uint8_t FpsClampMode;
|
||||
|
||||
uint16_t LevelResidencyCounters [SMU71_MAX_LEVELS_GRAPHICS];
|
||||
uint16_t LevelSwitchCounters [SMU71_MAX_LEVELS_GRAPHICS];
|
||||
|
||||
void (*TargetStateCalculator)(uint8_t);
|
||||
void (*SavedTargetStateCalculator)(uint8_t);
|
||||
|
||||
uint16_t AutoDpmInterval;
|
||||
uint16_t AutoDpmRange;
|
||||
|
||||
uint8_t FpsEnabled;
|
||||
uint8_t MaxPerfLevel;
|
||||
uint8_t AllowLowClkInterruptToHost;
|
||||
uint8_t FpsRunning;
|
||||
|
||||
uint32_t MaxAllowedFrequency;
|
||||
};
|
||||
|
||||
typedef struct SMU7_LocalDpmScoreboard SMU7_LocalDpmScoreboard;
|
||||
|
||||
#define SMU7_MAX_VOLTAGE_CLIENTS 12
|
||||
|
||||
struct SMU7_VoltageScoreboard
|
||||
{
|
||||
uint16_t CurrentVoltage;
|
||||
uint16_t HighestVoltage;
|
||||
uint16_t MaxVid;
|
||||
uint8_t HighestVidOffset;
|
||||
uint8_t CurrentVidOffset;
|
||||
#if defined (SMU__DGPU_ONLY)
|
||||
uint8_t CurrentPhases;
|
||||
uint8_t HighestPhases;
|
||||
#else
|
||||
uint8_t AvsOffset;
|
||||
uint8_t AvsOffsetApplied;
|
||||
#endif
|
||||
uint8_t ControllerBusy;
|
||||
uint8_t CurrentVid;
|
||||
uint16_t RequestedVoltage[SMU7_MAX_VOLTAGE_CLIENTS];
|
||||
#if defined (SMU__DGPU_ONLY)
|
||||
uint8_t RequestedPhases[SMU7_MAX_VOLTAGE_CLIENTS];
|
||||
#endif
|
||||
uint8_t EnabledRequest[SMU7_MAX_VOLTAGE_CLIENTS];
|
||||
uint8_t TargetIndex;
|
||||
uint8_t Delay;
|
||||
uint8_t ControllerEnable;
|
||||
uint8_t ControllerRunning;
|
||||
uint16_t CurrentStdVoltageHiSidd;
|
||||
uint16_t CurrentStdVoltageLoSidd;
|
||||
#if defined (SMU__DGPU_ONLY)
|
||||
uint16_t RequestedVddci;
|
||||
uint16_t CurrentVddci;
|
||||
uint16_t HighestVddci;
|
||||
uint8_t CurrentVddciVid;
|
||||
uint8_t TargetVddciIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct SMU7_VoltageScoreboard SMU7_VoltageScoreboard;
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
#define SMU7_MAX_PCIE_LINK_SPEEDS 3 /* 0:Gen1 1:Gen2 2:Gen3 */
|
||||
|
||||
struct SMU7_PCIeLinkSpeedScoreboard
|
||||
{
|
||||
uint8_t DpmEnable;
|
||||
uint8_t DpmRunning;
|
||||
uint8_t DpmForce;
|
||||
uint8_t DpmForceLevel;
|
||||
|
||||
uint8_t CurrentLinkSpeed;
|
||||
uint8_t EnabledLevelsChange;
|
||||
uint16_t AutoDpmInterval;
|
||||
|
||||
uint16_t AutoDpmRange;
|
||||
uint16_t AutoDpmCount;
|
||||
|
||||
uint8_t DpmMode;
|
||||
uint8_t AcpiReq;
|
||||
uint8_t AcpiAck;
|
||||
uint8_t CurrentLinkLevel;
|
||||
|
||||
};
|
||||
|
||||
typedef struct SMU7_PCIeLinkSpeedScoreboard SMU7_PCIeLinkSpeedScoreboard;
|
||||
|
||||
// -------------------------------------------------------- CAC table ------------------------------------------------------
|
||||
#define SMU7_LKGE_LUT_NUM_OF_TEMP_ENTRIES 16
|
||||
#define SMU7_LKGE_LUT_NUM_OF_VOLT_ENTRIES 16
|
||||
|
||||
#define SMU7_SCALE_I 7
|
||||
#define SMU7_SCALE_R 12
|
||||
|
||||
struct SMU7_PowerScoreboard
|
||||
{
|
||||
uint16_t MinVoltage;
|
||||
uint16_t MaxVoltage;
|
||||
|
||||
uint32_t AvgGpuPower;
|
||||
|
||||
uint16_t VddcLeakagePower[SID_OPTION_COUNT];
|
||||
uint16_t VddcSclkConstantPower[SID_OPTION_COUNT];
|
||||
uint16_t VddcSclkDynamicPower[SID_OPTION_COUNT];
|
||||
uint16_t VddcNonSclkDynamicPower[SID_OPTION_COUNT];
|
||||
uint16_t VddcTotalPower[SID_OPTION_COUNT];
|
||||
uint16_t VddcTotalCurrent[SID_OPTION_COUNT];
|
||||
uint16_t VddcLoadVoltage[SID_OPTION_COUNT];
|
||||
uint16_t VddcNoLoadVoltage[SID_OPTION_COUNT];
|
||||
|
||||
uint16_t DisplayPhyPower;
|
||||
uint16_t PciePhyPower;
|
||||
|
||||
uint16_t VddciTotalPower;
|
||||
uint16_t Vddr1TotalPower;
|
||||
|
||||
uint32_t RocPower;
|
||||
|
||||
uint32_t last_power;
|
||||
uint32_t enableWinAvg;
|
||||
|
||||
uint32_t lkg_acc;
|
||||
uint16_t VoltLkgeScaler;
|
||||
uint16_t TempLkgeScaler;
|
||||
|
||||
uint32_t uvd_cac_dclk;
|
||||
uint32_t uvd_cac_vclk;
|
||||
uint32_t vce_cac_eclk;
|
||||
uint32_t samu_cac_samclk;
|
||||
uint32_t display_cac_dispclk;
|
||||
uint32_t acp_cac_aclk;
|
||||
uint32_t unb_cac;
|
||||
|
||||
uint32_t WinTime;
|
||||
|
||||
uint16_t GpuPwr_MAWt;
|
||||
uint16_t FilteredVddcTotalPower;
|
||||
|
||||
uint8_t CalculationRepeats;
|
||||
uint8_t WaterfallUp;
|
||||
uint8_t WaterfallDown;
|
||||
uint8_t WaterfallLimit;
|
||||
};
|
||||
|
||||
typedef struct SMU7_PowerScoreboard SMU7_PowerScoreboard;
|
||||
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
|
||||
struct SMU7_ThermalScoreboard
|
||||
{
|
||||
int16_t GpuLimit;
|
||||
int16_t GpuHyst;
|
||||
uint16_t CurrGnbTemp;
|
||||
uint16_t FilteredGnbTemp;
|
||||
uint8_t ControllerEnable;
|
||||
uint8_t ControllerRunning;
|
||||
uint8_t WaterfallUp;
|
||||
uint8_t WaterfallDown;
|
||||
uint8_t WaterfallLimit;
|
||||
uint8_t padding[3];
|
||||
};
|
||||
|
||||
typedef struct SMU7_ThermalScoreboard SMU7_ThermalScoreboard;
|
||||
|
||||
// For FeatureEnables:
|
||||
#define SMU7_SCLK_DPM_CONFIG_MASK 0x01
|
||||
#define SMU7_VOLTAGE_CONTROLLER_CONFIG_MASK 0x02
|
||||
#define SMU7_THERMAL_CONTROLLER_CONFIG_MASK 0x04
|
||||
#define SMU7_MCLK_DPM_CONFIG_MASK 0x08
|
||||
#define SMU7_UVD_DPM_CONFIG_MASK 0x10
|
||||
#define SMU7_VCE_DPM_CONFIG_MASK 0x20
|
||||
#define SMU7_ACP_DPM_CONFIG_MASK 0x40
|
||||
#define SMU7_SAMU_DPM_CONFIG_MASK 0x80
|
||||
#define SMU7_PCIEGEN_DPM_CONFIG_MASK 0x100
|
||||
|
||||
#define SMU7_ACP_MCLK_HANDSHAKE_DISABLE 0x00000001
|
||||
#define SMU7_ACP_SCLK_HANDSHAKE_DISABLE 0x00000002
|
||||
#define SMU7_UVD_MCLK_HANDSHAKE_DISABLE 0x00000100
|
||||
#define SMU7_UVD_SCLK_HANDSHAKE_DISABLE 0x00000200
|
||||
#define SMU7_VCE_MCLK_HANDSHAKE_DISABLE 0x00010000
|
||||
#define SMU7_VCE_SCLK_HANDSHAKE_DISABLE 0x00020000
|
||||
|
||||
// All 'soft registers' should be uint32_t.
|
||||
struct SMU71_SoftRegisters
|
||||
{
|
||||
uint32_t RefClockFrequency;
|
||||
uint32_t PmTimerPeriod;
|
||||
uint32_t FeatureEnables;
|
||||
#if defined (SMU__DGPU_ONLY)
|
||||
uint32_t PreVBlankGap;
|
||||
uint32_t VBlankTimeout;
|
||||
uint32_t TrainTimeGap;
|
||||
uint32_t MvddSwitchTime;
|
||||
uint32_t LongestAcpiTrainTime;
|
||||
uint32_t AcpiDelay;
|
||||
uint32_t G5TrainTime;
|
||||
uint32_t DelayMpllPwron;
|
||||
uint32_t VoltageChangeTimeout;
|
||||
#endif
|
||||
uint32_t HandshakeDisables;
|
||||
|
||||
uint8_t DisplayPhy1Config;
|
||||
uint8_t DisplayPhy2Config;
|
||||
uint8_t DisplayPhy3Config;
|
||||
uint8_t DisplayPhy4Config;
|
||||
|
||||
uint8_t DisplayPhy5Config;
|
||||
uint8_t DisplayPhy6Config;
|
||||
uint8_t DisplayPhy7Config;
|
||||
uint8_t DisplayPhy8Config;
|
||||
|
||||
uint32_t AverageGraphicsActivity;
|
||||
uint32_t AverageMemoryActivity;
|
||||
uint32_t AverageGioActivity;
|
||||
|
||||
uint8_t SClkDpmEnabledLevels;
|
||||
uint8_t MClkDpmEnabledLevels;
|
||||
uint8_t LClkDpmEnabledLevels;
|
||||
uint8_t PCIeDpmEnabledLevels;
|
||||
|
||||
uint32_t DRAM_LOG_ADDR_H;
|
||||
uint32_t DRAM_LOG_ADDR_L;
|
||||
uint32_t DRAM_LOG_PHY_ADDR_H;
|
||||
uint32_t DRAM_LOG_PHY_ADDR_L;
|
||||
uint32_t DRAM_LOG_BUFF_SIZE;
|
||||
uint32_t UlvEnterCount;
|
||||
uint32_t UlvTime;
|
||||
uint32_t UcodeLoadStatus;
|
||||
uint8_t DPMFreezeAndForced;
|
||||
uint8_t Activity_Weight;
|
||||
uint8_t Reserved8[2];
|
||||
uint32_t Reserved;
|
||||
};
|
||||
|
||||
typedef struct SMU71_SoftRegisters SMU71_SoftRegisters;
|
||||
|
||||
struct SMU71_Firmware_Header
|
||||
{
|
||||
uint32_t Digest[5];
|
||||
uint32_t Version;
|
||||
uint32_t HeaderSize;
|
||||
uint32_t Flags;
|
||||
uint32_t EntryPoint;
|
||||
uint32_t CodeSize;
|
||||
uint32_t ImageSize;
|
||||
|
||||
uint32_t Rtos;
|
||||
uint32_t SoftRegisters;
|
||||
uint32_t DpmTable;
|
||||
uint32_t FanTable;
|
||||
uint32_t CacConfigTable;
|
||||
uint32_t CacStatusTable;
|
||||
|
||||
uint32_t mcRegisterTable;
|
||||
|
||||
uint32_t mcArbDramTimingTable;
|
||||
|
||||
uint32_t PmFuseTable;
|
||||
uint32_t Globals;
|
||||
uint32_t UvdDpmTable;
|
||||
uint32_t AcpDpmTable;
|
||||
uint32_t VceDpmTable;
|
||||
uint32_t SamuDpmTable;
|
||||
uint32_t UlvSettings;
|
||||
uint32_t Reserved[37];
|
||||
uint32_t Signature;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Firmware_Header SMU71_Firmware_Header;
|
||||
|
||||
struct SMU7_HystController_Data
|
||||
{
|
||||
uint8_t waterfall_up;
|
||||
uint8_t waterfall_down;
|
||||
uint8_t pstate;
|
||||
uint8_t clamp_mode;
|
||||
};
|
||||
|
||||
typedef struct SMU7_HystController_Data SMU7_HystController_Data;
|
||||
|
||||
#define SMU71_FIRMWARE_HEADER_LOCATION 0x20000
|
||||
|
||||
enum DisplayConfig {
|
||||
PowerDown = 1,
|
||||
DP54x4,
|
||||
DP54x2,
|
||||
DP54x1,
|
||||
DP27x4,
|
||||
DP27x2,
|
||||
DP27x1,
|
||||
HDMI297,
|
||||
HDMI162,
|
||||
LVDS,
|
||||
DP324x4,
|
||||
DP324x2,
|
||||
DP324x1
|
||||
};
|
||||
|
||||
//#define SX_BLOCK_COUNT 8
|
||||
//#define MC_BLOCK_COUNT 1
|
||||
//#define CPL_BLOCK_COUNT 27
|
||||
|
||||
#if defined SMU__VARIANT__ICELAND
|
||||
#define SX_BLOCK_COUNT 8
|
||||
#define MC_BLOCK_COUNT 1
|
||||
#define CPL_BLOCK_COUNT 29
|
||||
#endif
|
||||
|
||||
struct SMU7_Local_Cac {
|
||||
uint8_t BlockId;
|
||||
uint8_t SignalId;
|
||||
uint8_t Threshold;
|
||||
uint8_t Padding;
|
||||
};
|
||||
|
||||
typedef struct SMU7_Local_Cac SMU7_Local_Cac;
|
||||
|
||||
struct SMU7_Local_Cac_Table {
|
||||
SMU7_Local_Cac SxLocalCac[SX_BLOCK_COUNT];
|
||||
SMU7_Local_Cac CplLocalCac[CPL_BLOCK_COUNT];
|
||||
SMU7_Local_Cac McLocalCac[MC_BLOCK_COUNT];
|
||||
};
|
||||
|
||||
typedef struct SMU7_Local_Cac_Table SMU7_Local_Cac_Table;
|
||||
|
||||
#if !defined(SMC_MICROCODE)
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,631 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef SMU71_DISCRETE_H
|
||||
#define SMU71_DISCRETE_H
|
||||
|
||||
#include "smu71.h"
|
||||
|
||||
#if !defined(SMC_MICROCODE)
|
||||
#pragma pack(push, 1)
|
||||
#endif
|
||||
|
||||
#define VDDC_ON_SVI2 0x1
|
||||
#define VDDCI_ON_SVI2 0x2
|
||||
#define MVDD_ON_SVI2 0x4
|
||||
|
||||
struct SMU71_Discrete_VoltageLevel
|
||||
{
|
||||
uint16_t Voltage;
|
||||
uint16_t StdVoltageHiSidd;
|
||||
uint16_t StdVoltageLoSidd;
|
||||
uint8_t Smio;
|
||||
uint8_t padding;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_VoltageLevel SMU71_Discrete_VoltageLevel;
|
||||
|
||||
struct SMU71_Discrete_GraphicsLevel
|
||||
{
|
||||
uint32_t MinVddc;
|
||||
uint32_t MinVddcPhases;
|
||||
|
||||
uint32_t SclkFrequency;
|
||||
|
||||
uint8_t pcieDpmLevel;
|
||||
uint8_t DeepSleepDivId;
|
||||
uint16_t ActivityLevel;
|
||||
|
||||
uint32_t CgSpllFuncCntl3;
|
||||
uint32_t CgSpllFuncCntl4;
|
||||
uint32_t SpllSpreadSpectrum;
|
||||
uint32_t SpllSpreadSpectrum2;
|
||||
uint32_t CcPwrDynRm;
|
||||
uint32_t CcPwrDynRm1;
|
||||
uint8_t SclkDid;
|
||||
uint8_t DisplayWatermark;
|
||||
uint8_t EnabledForActivity;
|
||||
uint8_t EnabledForThrottle;
|
||||
uint8_t UpHyst;
|
||||
uint8_t DownHyst;
|
||||
uint8_t VoltageDownHyst;
|
||||
uint8_t PowerThrottle;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_GraphicsLevel SMU71_Discrete_GraphicsLevel;
|
||||
|
||||
struct SMU71_Discrete_ACPILevel
|
||||
{
|
||||
uint32_t Flags;
|
||||
uint32_t MinVddc;
|
||||
uint32_t MinVddcPhases;
|
||||
uint32_t SclkFrequency;
|
||||
uint8_t SclkDid;
|
||||
uint8_t DisplayWatermark;
|
||||
uint8_t DeepSleepDivId;
|
||||
uint8_t padding;
|
||||
uint32_t CgSpllFuncCntl;
|
||||
uint32_t CgSpllFuncCntl2;
|
||||
uint32_t CgSpllFuncCntl3;
|
||||
uint32_t CgSpllFuncCntl4;
|
||||
uint32_t SpllSpreadSpectrum;
|
||||
uint32_t SpllSpreadSpectrum2;
|
||||
uint32_t CcPwrDynRm;
|
||||
uint32_t CcPwrDynRm1;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_ACPILevel SMU71_Discrete_ACPILevel;
|
||||
|
||||
struct SMU71_Discrete_Ulv
|
||||
{
|
||||
uint32_t CcPwrDynRm;
|
||||
uint32_t CcPwrDynRm1;
|
||||
uint16_t VddcOffset;
|
||||
uint8_t VddcOffsetVid;
|
||||
uint8_t VddcPhase;
|
||||
uint32_t Reserved;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_Ulv SMU71_Discrete_Ulv;
|
||||
|
||||
struct SMU71_Discrete_MemoryLevel
|
||||
{
|
||||
uint32_t MinVddc;
|
||||
uint32_t MinVddcPhases;
|
||||
uint32_t MinVddci;
|
||||
uint32_t MinMvdd;
|
||||
|
||||
uint32_t MclkFrequency;
|
||||
|
||||
uint8_t EdcReadEnable;
|
||||
uint8_t EdcWriteEnable;
|
||||
uint8_t RttEnable;
|
||||
uint8_t StutterEnable;
|
||||
|
||||
uint8_t StrobeEnable;
|
||||
uint8_t StrobeRatio;
|
||||
uint8_t EnabledForThrottle;
|
||||
uint8_t EnabledForActivity;
|
||||
|
||||
uint8_t UpHyst;
|
||||
uint8_t DownHyst;
|
||||
uint8_t VoltageDownHyst;
|
||||
uint8_t padding;
|
||||
|
||||
uint16_t ActivityLevel;
|
||||
uint8_t DisplayWatermark;
|
||||
uint8_t padding1;
|
||||
|
||||
uint32_t MpllFuncCntl;
|
||||
uint32_t MpllFuncCntl_1;
|
||||
uint32_t MpllFuncCntl_2;
|
||||
uint32_t MpllAdFuncCntl;
|
||||
uint32_t MpllDqFuncCntl;
|
||||
uint32_t MclkPwrmgtCntl;
|
||||
uint32_t DllCntl;
|
||||
uint32_t MpllSs1;
|
||||
uint32_t MpllSs2;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_MemoryLevel SMU71_Discrete_MemoryLevel;
|
||||
|
||||
struct SMU71_Discrete_LinkLevel
|
||||
{
|
||||
uint8_t PcieGenSpeed; ///< 0:PciE-gen1 1:PciE-gen2 2:PciE-gen3
|
||||
uint8_t PcieLaneCount; ///< 1=x1, 2=x2, 3=x4, 4=x8, 5=x12, 6=x16
|
||||
uint8_t EnabledForActivity;
|
||||
uint8_t SPC;
|
||||
uint32_t DownThreshold;
|
||||
uint32_t UpThreshold;
|
||||
uint32_t Reserved;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_LinkLevel SMU71_Discrete_LinkLevel;
|
||||
|
||||
|
||||
#ifdef SMU__DYNAMIC_MCARB_SETTINGS
|
||||
// MC ARB DRAM Timing registers.
|
||||
struct SMU71_Discrete_MCArbDramTimingTableEntry
|
||||
{
|
||||
uint32_t McArbDramTiming;
|
||||
uint32_t McArbDramTiming2;
|
||||
uint8_t McArbBurstTime;
|
||||
uint8_t padding[3];
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_MCArbDramTimingTableEntry SMU71_Discrete_MCArbDramTimingTableEntry;
|
||||
|
||||
struct SMU71_Discrete_MCArbDramTimingTable
|
||||
{
|
||||
SMU71_Discrete_MCArbDramTimingTableEntry entries[SMU__NUM_SCLK_DPM_STATE][SMU__NUM_MCLK_DPM_LEVELS];
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_MCArbDramTimingTable SMU71_Discrete_MCArbDramTimingTable;
|
||||
#endif
|
||||
|
||||
// UVD VCLK/DCLK state (level) definition.
|
||||
struct SMU71_Discrete_UvdLevel
|
||||
{
|
||||
uint32_t VclkFrequency;
|
||||
uint32_t DclkFrequency;
|
||||
uint16_t MinVddc;
|
||||
uint8_t MinVddcPhases;
|
||||
uint8_t VclkDivider;
|
||||
uint8_t DclkDivider;
|
||||
uint8_t padding[3];
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_UvdLevel SMU71_Discrete_UvdLevel;
|
||||
|
||||
// Clocks for other external blocks (VCE, ACP, SAMU).
|
||||
struct SMU71_Discrete_ExtClkLevel
|
||||
{
|
||||
uint32_t Frequency;
|
||||
uint16_t MinVoltage;
|
||||
uint8_t MinPhases;
|
||||
uint8_t Divider;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_ExtClkLevel SMU71_Discrete_ExtClkLevel;
|
||||
|
||||
// Everything that we need to keep track of about the current state.
|
||||
// Use this instead of copies of the GraphicsLevel and MemoryLevel structures to keep track of state parameters
|
||||
// that need to be checked later.
|
||||
// We don't need to cache everything about a state, just a few parameters.
|
||||
struct SMU71_Discrete_StateInfo
|
||||
{
|
||||
uint32_t SclkFrequency;
|
||||
uint32_t MclkFrequency;
|
||||
uint32_t VclkFrequency;
|
||||
uint32_t DclkFrequency;
|
||||
uint32_t SamclkFrequency;
|
||||
uint32_t AclkFrequency;
|
||||
uint32_t EclkFrequency;
|
||||
uint16_t MvddVoltage;
|
||||
uint16_t padding16;
|
||||
uint8_t DisplayWatermark;
|
||||
uint8_t McArbIndex;
|
||||
uint8_t McRegIndex;
|
||||
uint8_t SeqIndex;
|
||||
uint8_t SclkDid;
|
||||
int8_t SclkIndex;
|
||||
int8_t MclkIndex;
|
||||
uint8_t PCIeGen;
|
||||
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_StateInfo SMU71_Discrete_StateInfo;
|
||||
|
||||
|
||||
struct SMU71_Discrete_DpmTable
|
||||
{
|
||||
// Multi-DPM controller settings
|
||||
SMU71_PIDController GraphicsPIDController;
|
||||
SMU71_PIDController MemoryPIDController;
|
||||
SMU71_PIDController LinkPIDController;
|
||||
|
||||
uint32_t SystemFlags;
|
||||
|
||||
// SMIO masks for voltage and phase controls
|
||||
uint32_t SmioMaskVddcVid;
|
||||
uint32_t SmioMaskVddcPhase;
|
||||
uint32_t SmioMaskVddciVid;
|
||||
uint32_t SmioMaskMvddVid;
|
||||
|
||||
uint32_t VddcLevelCount;
|
||||
uint32_t VddciLevelCount;
|
||||
uint32_t MvddLevelCount;
|
||||
|
||||
SMU71_Discrete_VoltageLevel VddcLevel [SMU71_MAX_LEVELS_VDDC];
|
||||
SMU71_Discrete_VoltageLevel VddciLevel [SMU71_MAX_LEVELS_VDDCI];
|
||||
SMU71_Discrete_VoltageLevel MvddLevel [SMU71_MAX_LEVELS_MVDD];
|
||||
|
||||
uint8_t GraphicsDpmLevelCount;
|
||||
uint8_t MemoryDpmLevelCount;
|
||||
uint8_t LinkLevelCount;
|
||||
uint8_t MasterDeepSleepControl;
|
||||
|
||||
uint32_t Reserved[5];
|
||||
|
||||
// State table entries for each DPM state
|
||||
SMU71_Discrete_GraphicsLevel GraphicsLevel [SMU71_MAX_LEVELS_GRAPHICS];
|
||||
SMU71_Discrete_MemoryLevel MemoryACPILevel;
|
||||
SMU71_Discrete_MemoryLevel MemoryLevel [SMU71_MAX_LEVELS_MEMORY];
|
||||
SMU71_Discrete_LinkLevel LinkLevel [SMU71_MAX_LEVELS_LINK];
|
||||
SMU71_Discrete_ACPILevel ACPILevel;
|
||||
|
||||
uint32_t SclkStepSize;
|
||||
uint32_t Smio [SMU71_MAX_ENTRIES_SMIO];
|
||||
|
||||
uint8_t GraphicsBootLevel;
|
||||
uint8_t GraphicsVoltageChangeEnable;
|
||||
uint8_t GraphicsThermThrottleEnable;
|
||||
uint8_t GraphicsInterval;
|
||||
|
||||
uint8_t VoltageInterval;
|
||||
uint8_t ThermalInterval;
|
||||
uint16_t TemperatureLimitHigh;
|
||||
|
||||
uint16_t TemperatureLimitLow;
|
||||
uint8_t MemoryBootLevel;
|
||||
uint8_t MemoryVoltageChangeEnable;
|
||||
|
||||
uint8_t MemoryInterval;
|
||||
uint8_t MemoryThermThrottleEnable;
|
||||
uint8_t MergedVddci;
|
||||
uint8_t padding2;
|
||||
|
||||
uint16_t VoltageResponseTime;
|
||||
uint16_t PhaseResponseTime;
|
||||
|
||||
uint8_t PCIeBootLinkLevel;
|
||||
uint8_t PCIeGenInterval;
|
||||
uint8_t DTEInterval;
|
||||
uint8_t DTEMode;
|
||||
|
||||
uint8_t SVI2Enable;
|
||||
uint8_t VRHotGpio;
|
||||
uint8_t AcDcGpio;
|
||||
uint8_t ThermGpio;
|
||||
|
||||
uint32_t DisplayCac;
|
||||
|
||||
uint16_t MaxPwr;
|
||||
uint16_t NomPwr;
|
||||
|
||||
uint16_t FpsHighThreshold;
|
||||
uint16_t FpsLowThreshold;
|
||||
|
||||
uint16_t BAPMTI_R [SMU71_DTE_ITERATIONS][SMU71_DTE_SOURCES][SMU71_DTE_SINKS];
|
||||
uint16_t BAPMTI_RC [SMU71_DTE_ITERATIONS][SMU71_DTE_SOURCES][SMU71_DTE_SINKS];
|
||||
|
||||
uint8_t DTEAmbientTempBase;
|
||||
uint8_t DTETjOffset;
|
||||
uint8_t GpuTjMax;
|
||||
uint8_t GpuTjHyst;
|
||||
|
||||
uint16_t BootVddc;
|
||||
uint16_t BootVddci;
|
||||
|
||||
uint16_t BootMVdd;
|
||||
uint16_t padding;
|
||||
|
||||
uint32_t BAPM_TEMP_GRADIENT;
|
||||
|
||||
uint32_t LowSclkInterruptThreshold;
|
||||
uint32_t VddGfxReChkWait;
|
||||
|
||||
uint16_t PPM_PkgPwrLimit;
|
||||
uint16_t PPM_TemperatureLimit;
|
||||
|
||||
uint16_t DefaultTdp;
|
||||
uint16_t TargetTdp;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_DpmTable SMU71_Discrete_DpmTable;
|
||||
|
||||
// --------------------------------------------------- AC Timing Parameters ------------------------------------------------
|
||||
#define SMU71_DISCRETE_MC_REGISTER_ARRAY_SIZE 16
|
||||
#define SMU71_DISCRETE_MC_REGISTER_ARRAY_SET_COUNT SMU71_MAX_LEVELS_MEMORY
|
||||
|
||||
struct SMU71_Discrete_MCRegisterAddress
|
||||
{
|
||||
uint16_t s0;
|
||||
uint16_t s1;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_MCRegisterAddress SMU71_Discrete_MCRegisterAddress;
|
||||
|
||||
struct SMU71_Discrete_MCRegisterSet
|
||||
{
|
||||
uint32_t value[SMU71_DISCRETE_MC_REGISTER_ARRAY_SIZE];
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_MCRegisterSet SMU71_Discrete_MCRegisterSet;
|
||||
|
||||
struct SMU71_Discrete_MCRegisters
|
||||
{
|
||||
uint8_t last;
|
||||
uint8_t reserved[3];
|
||||
SMU71_Discrete_MCRegisterAddress address[SMU71_DISCRETE_MC_REGISTER_ARRAY_SIZE];
|
||||
SMU71_Discrete_MCRegisterSet data[SMU71_DISCRETE_MC_REGISTER_ARRAY_SET_COUNT];
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_MCRegisters SMU71_Discrete_MCRegisters;
|
||||
|
||||
|
||||
// --------------------------------------------------- Fan Table -----------------------------------------------------------
|
||||
struct SMU71_Discrete_FanTable
|
||||
{
|
||||
uint16_t FdoMode;
|
||||
int16_t TempMin;
|
||||
int16_t TempMed;
|
||||
int16_t TempMax;
|
||||
int16_t Slope1;
|
||||
int16_t Slope2;
|
||||
int16_t FdoMin;
|
||||
int16_t HystUp;
|
||||
int16_t HystDown;
|
||||
int16_t HystSlope;
|
||||
int16_t TempRespLim;
|
||||
int16_t TempCurr;
|
||||
int16_t SlopeCurr;
|
||||
int16_t PwmCurr;
|
||||
uint32_t RefreshPeriod;
|
||||
int16_t FdoMax;
|
||||
uint8_t TempSrc;
|
||||
int8_t Padding;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_FanTable SMU71_Discrete_FanTable;
|
||||
|
||||
#define SMU7_DISCRETE_GPIO_SCLK_DEBUG 4
|
||||
#define SMU7_DISCRETE_GPIO_SCLK_DEBUG_BIT (0x1 << SMU7_DISCRETE_GPIO_SCLK_DEBUG)
|
||||
|
||||
struct SMU71_MclkDpmScoreboard
|
||||
{
|
||||
|
||||
uint32_t PercentageBusy;
|
||||
|
||||
int32_t PIDError;
|
||||
int32_t PIDIntegral;
|
||||
int32_t PIDOutput;
|
||||
|
||||
uint32_t SigmaDeltaAccum;
|
||||
uint32_t SigmaDeltaOutput;
|
||||
uint32_t SigmaDeltaLevel;
|
||||
|
||||
uint32_t UtilizationSetpoint;
|
||||
|
||||
uint8_t TdpClampMode;
|
||||
uint8_t TdcClampMode;
|
||||
uint8_t ThermClampMode;
|
||||
uint8_t VoltageBusy;
|
||||
|
||||
int8_t CurrLevel;
|
||||
int8_t TargLevel;
|
||||
uint8_t LevelChangeInProgress;
|
||||
uint8_t UpHyst;
|
||||
|
||||
uint8_t DownHyst;
|
||||
uint8_t VoltageDownHyst;
|
||||
uint8_t DpmEnable;
|
||||
uint8_t DpmRunning;
|
||||
|
||||
uint8_t DpmForce;
|
||||
uint8_t DpmForceLevel;
|
||||
uint8_t DisplayWatermark;
|
||||
uint8_t McArbIndex;
|
||||
|
||||
uint32_t MinimumPerfMclk;
|
||||
|
||||
uint8_t AcpiReq;
|
||||
uint8_t AcpiAck;
|
||||
uint8_t MclkSwitchInProgress;
|
||||
uint8_t MclkSwitchCritical;
|
||||
|
||||
uint8_t TargetMclkIndex;
|
||||
uint8_t TargetMvddIndex;
|
||||
uint8_t MclkSwitchResult;
|
||||
|
||||
uint8_t EnabledLevelsChange;
|
||||
|
||||
uint16_t LevelResidencyCounters [SMU71_MAX_LEVELS_MEMORY];
|
||||
uint16_t LevelSwitchCounters [SMU71_MAX_LEVELS_MEMORY];
|
||||
|
||||
void (*TargetStateCalculator)(uint8_t);
|
||||
void (*SavedTargetStateCalculator)(uint8_t);
|
||||
|
||||
uint16_t AutoDpmInterval;
|
||||
uint16_t AutoDpmRange;
|
||||
|
||||
uint16_t MclkSwitchingTime;
|
||||
uint8_t padding[2];
|
||||
};
|
||||
|
||||
typedef struct SMU71_MclkDpmScoreboard SMU71_MclkDpmScoreboard;
|
||||
|
||||
struct SMU71_UlvScoreboard
|
||||
{
|
||||
uint8_t EnterUlv;
|
||||
uint8_t ExitUlv;
|
||||
uint8_t UlvActive;
|
||||
uint8_t WaitingForUlv;
|
||||
uint8_t UlvEnable;
|
||||
uint8_t UlvRunning;
|
||||
uint8_t UlvMasterEnable;
|
||||
uint8_t padding;
|
||||
uint32_t UlvAbortedCount;
|
||||
uint32_t UlvTimeStamp;
|
||||
};
|
||||
|
||||
typedef struct SMU71_UlvScoreboard SMU71_UlvScoreboard;
|
||||
|
||||
struct SMU71_VddGfxScoreboard
|
||||
{
|
||||
uint8_t VddGfxEnable;
|
||||
uint8_t VddGfxActive;
|
||||
uint8_t padding[2];
|
||||
|
||||
uint32_t VddGfxEnteredCount;
|
||||
uint32_t VddGfxAbortedCount;
|
||||
};
|
||||
|
||||
typedef struct SMU71_VddGfxScoreboard SMU71_VddGfxScoreboard;
|
||||
|
||||
struct SMU71_AcpiScoreboard {
|
||||
uint32_t SavedInterruptMask[2];
|
||||
uint8_t LastACPIRequest;
|
||||
uint8_t CgBifResp;
|
||||
uint8_t RequestType;
|
||||
uint8_t Padding;
|
||||
SMU71_Discrete_ACPILevel D0Level;
|
||||
};
|
||||
|
||||
typedef struct SMU71_AcpiScoreboard SMU71_AcpiScoreboard;
|
||||
|
||||
|
||||
struct SMU71_Discrete_PmFuses {
|
||||
// dw0-dw1
|
||||
uint8_t BapmVddCVidHiSidd[8];
|
||||
|
||||
// dw2-dw3
|
||||
uint8_t BapmVddCVidLoSidd[8];
|
||||
|
||||
// dw4-dw5
|
||||
uint8_t VddCVid[8];
|
||||
|
||||
// dw6
|
||||
uint8_t SviLoadLineEn;
|
||||
uint8_t SviLoadLineVddC;
|
||||
uint8_t SviLoadLineTrimVddC;
|
||||
uint8_t SviLoadLineOffsetVddC;
|
||||
|
||||
// dw7
|
||||
uint16_t TDC_VDDC_PkgLimit;
|
||||
uint8_t TDC_VDDC_ThrottleReleaseLimitPerc;
|
||||
uint8_t TDC_MAWt;
|
||||
|
||||
// dw8
|
||||
uint8_t TdcWaterfallCtl;
|
||||
uint8_t LPMLTemperatureMin;
|
||||
uint8_t LPMLTemperatureMax;
|
||||
uint8_t Reserved;
|
||||
|
||||
// dw9-dw12
|
||||
uint8_t LPMLTemperatureScaler[16];
|
||||
|
||||
// dw13-dw14
|
||||
int16_t FuzzyFan_ErrorSetDelta;
|
||||
int16_t FuzzyFan_ErrorRateSetDelta;
|
||||
int16_t FuzzyFan_PwmSetDelta;
|
||||
uint16_t Reserved6;
|
||||
|
||||
// dw15
|
||||
uint8_t GnbLPML[16];
|
||||
|
||||
// dw15
|
||||
uint8_t GnbLPMLMaxVid;
|
||||
uint8_t GnbLPMLMinVid;
|
||||
uint8_t Reserved1[2];
|
||||
|
||||
// dw16
|
||||
uint16_t BapmVddCBaseLeakageHiSidd;
|
||||
uint16_t BapmVddCBaseLeakageLoSidd;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_PmFuses SMU71_Discrete_PmFuses;
|
||||
|
||||
struct SMU71_Discrete_Log_Header_Table {
|
||||
uint32_t version;
|
||||
uint32_t asic_id;
|
||||
uint16_t flags;
|
||||
uint16_t entry_size;
|
||||
uint32_t total_size;
|
||||
uint32_t num_of_entries;
|
||||
uint8_t type;
|
||||
uint8_t mode;
|
||||
uint8_t filler_0[2];
|
||||
uint32_t filler_1[2];
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_Log_Header_Table SMU71_Discrete_Log_Header_Table;
|
||||
|
||||
struct SMU71_Discrete_Log_Cntl {
|
||||
uint8_t Enabled;
|
||||
uint8_t Type;
|
||||
uint8_t padding[2];
|
||||
uint32_t BufferSize;
|
||||
uint32_t SamplesLogged;
|
||||
uint32_t SampleSize;
|
||||
uint32_t AddrL;
|
||||
uint32_t AddrH;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_Log_Cntl SMU71_Discrete_Log_Cntl;
|
||||
|
||||
#if defined SMU__DGPU_ONLY
|
||||
#define CAC_ACC_NW_NUM_OF_SIGNALS 83
|
||||
#endif
|
||||
|
||||
|
||||
struct SMU71_Discrete_Cac_Collection_Table {
|
||||
uint32_t temperature;
|
||||
uint32_t cac_acc_nw[CAC_ACC_NW_NUM_OF_SIGNALS];
|
||||
uint32_t filler[4];
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_Cac_Collection_Table SMU71_Discrete_Cac_Collection_Table;
|
||||
|
||||
struct SMU71_Discrete_Cac_Verification_Table {
|
||||
uint32_t VddcTotalPower;
|
||||
uint32_t VddcLeakagePower;
|
||||
uint32_t VddcConstantPower;
|
||||
uint32_t VddcGfxDynamicPower;
|
||||
uint32_t VddcUvdDynamicPower;
|
||||
uint32_t VddcVceDynamicPower;
|
||||
uint32_t VddcAcpDynamicPower;
|
||||
uint32_t VddcPcieDynamicPower;
|
||||
uint32_t VddcDceDynamicPower;
|
||||
uint32_t VddcCurrent;
|
||||
uint32_t VddcVoltage;
|
||||
uint32_t VddciTotalPower;
|
||||
uint32_t VddciLeakagePower;
|
||||
uint32_t VddciConstantPower;
|
||||
uint32_t VddciDynamicPower;
|
||||
uint32_t Vddr1TotalPower;
|
||||
uint32_t Vddr1LeakagePower;
|
||||
uint32_t Vddr1ConstantPower;
|
||||
uint32_t Vddr1DynamicPower;
|
||||
uint32_t spare[8];
|
||||
uint32_t temperature;
|
||||
};
|
||||
|
||||
typedef struct SMU71_Discrete_Cac_Verification_Table SMU71_Discrete_Cac_Verification_Table;
|
||||
|
||||
#if !defined(SMC_MICROCODE)
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -2,7 +2,8 @@
|
|||
# Makefile for the 'smu manager' sub-component of powerplay.
|
||||
# It provides the smu management services for the driver.
|
||||
|
||||
SMU_MGR = smumgr.o cz_smumgr.o tonga_smumgr.o fiji_smumgr.o polaris10_smumgr.o
|
||||
SMU_MGR = smumgr.o cz_smumgr.o tonga_smumgr.o fiji_smumgr.o \
|
||||
polaris10_smumgr.o iceland_smumgr.o
|
||||
|
||||
AMD_PP_SMUMGR = $(addprefix $(AMD_PP_PATH)/smumgr/,$(SMU_MGR))
|
||||
|
||||
|
|
|
@ -0,0 +1,713 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Huang Rui <ray.huang@amd.com>
|
||||
*
|
||||
*/
|
||||
#include <linux/types.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/gfp.h>
|
||||
|
||||
#include "smumgr.h"
|
||||
#include "iceland_smumgr.h"
|
||||
#include "pp_debug.h"
|
||||
#include "smu_ucode_xfer_vi.h"
|
||||
#include "ppsmc.h"
|
||||
#include "smu/smu_7_1_1_d.h"
|
||||
#include "smu/smu_7_1_1_sh_mask.h"
|
||||
#include "cgs_common.h"
|
||||
|
||||
#define ICELAND_SMC_SIZE 0x20000
|
||||
#define BUFFER_SIZE 80000
|
||||
#define MAX_STRING_SIZE 15
|
||||
#define BUFFER_SIZETWO 131072 /*128 *1024*/
|
||||
|
||||
/**
|
||||
* Set the address for reading/writing the SMC SRAM space.
|
||||
* @param smumgr the address of the powerplay hardware manager.
|
||||
* @param smcAddress the address in the SMC RAM to access.
|
||||
*/
|
||||
static int iceland_set_smc_sram_address(struct pp_smumgr *smumgr,
|
||||
uint32_t smcAddress, uint32_t limit)
|
||||
{
|
||||
if (smumgr == NULL || smumgr->device == NULL)
|
||||
return -EINVAL;
|
||||
PP_ASSERT_WITH_CODE((0 == (3 & smcAddress)),
|
||||
"SMC address must be 4 byte aligned.",
|
||||
return -1;);
|
||||
|
||||
PP_ASSERT_WITH_CODE((limit > (smcAddress + 3)),
|
||||
"SMC address is beyond the SMC RAM area.",
|
||||
return -1;);
|
||||
|
||||
cgs_write_register(smumgr->device, mmSMC_IND_INDEX_0, smcAddress);
|
||||
SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy bytes from an array into the SMC RAM space.
|
||||
*
|
||||
* @param smumgr the address of the powerplay SMU manager.
|
||||
* @param smcStartAddress the start address in the SMC RAM to copy bytes to.
|
||||
* @param src the byte array to copy the bytes from.
|
||||
* @param byteCount the number of bytes to copy.
|
||||
*/
|
||||
int iceland_copy_bytes_to_smc(struct pp_smumgr *smumgr,
|
||||
uint32_t smcStartAddress, const uint8_t *src,
|
||||
uint32_t byteCount, uint32_t limit)
|
||||
{
|
||||
uint32_t addr;
|
||||
uint32_t data, orig_data;
|
||||
int result = 0;
|
||||
uint32_t extra_shift;
|
||||
|
||||
if (smumgr == NULL || smumgr->device == NULL)
|
||||
return -EINVAL;
|
||||
PP_ASSERT_WITH_CODE((0 == (3 & smcStartAddress)),
|
||||
"SMC address must be 4 byte aligned.",
|
||||
return 0;);
|
||||
|
||||
PP_ASSERT_WITH_CODE((limit > (smcStartAddress + byteCount)),
|
||||
"SMC address is beyond the SMC RAM area.",
|
||||
return 0;);
|
||||
|
||||
addr = smcStartAddress;
|
||||
|
||||
while (byteCount >= 4) {
|
||||
/*
|
||||
* Bytes are written into the
|
||||
* SMC address space with the MSB first
|
||||
*/
|
||||
data = (src[0] << 24) + (src[1] << 16) + (src[2] << 8) + src[3];
|
||||
|
||||
result = iceland_set_smc_sram_address(smumgr, addr, limit);
|
||||
|
||||
if (result)
|
||||
goto out;
|
||||
|
||||
cgs_write_register(smumgr->device, mmSMC_IND_DATA_0, data);
|
||||
|
||||
src += 4;
|
||||
byteCount -= 4;
|
||||
addr += 4;
|
||||
}
|
||||
|
||||
if (0 != byteCount) {
|
||||
/* Now write odd bytes left, do a read modify write cycle */
|
||||
data = 0;
|
||||
|
||||
result = iceland_set_smc_sram_address(smumgr, addr, limit);
|
||||
if (result)
|
||||
goto out;
|
||||
|
||||
orig_data = cgs_read_register(smumgr->device,
|
||||
mmSMC_IND_DATA_0);
|
||||
extra_shift = 8 * (4 - byteCount);
|
||||
|
||||
while (byteCount > 0) {
|
||||
data = (data << 8) + *src++;
|
||||
byteCount--;
|
||||
}
|
||||
|
||||
data <<= extra_shift;
|
||||
data |= (orig_data & ~((~0UL) << extra_shift));
|
||||
|
||||
result = iceland_set_smc_sram_address(smumgr, addr, limit);
|
||||
if (result)
|
||||
goto out;
|
||||
|
||||
cgs_write_register(smumgr->device, mmSMC_IND_DATA_0, data);
|
||||
}
|
||||
|
||||
out:
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deassert the reset'pin' (set it to high).
|
||||
*
|
||||
* @param smumgr the address of the powerplay hardware manager.
|
||||
*/
|
||||
static int iceland_start_smc(struct pp_smumgr *smumgr)
|
||||
{
|
||||
SMUM_WRITE_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC,
|
||||
SMC_SYSCON_RESET_CNTL, rst_reg, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void iceland_pp_reset_smc(struct pp_smumgr *smumgr)
|
||||
{
|
||||
SMUM_WRITE_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC,
|
||||
SMC_SYSCON_RESET_CNTL,
|
||||
rst_reg, 1);
|
||||
}
|
||||
|
||||
int iceland_program_jump_on_start(struct pp_smumgr *smumgr)
|
||||
{
|
||||
static const unsigned char pData[] = { 0xE0, 0x00, 0x80, 0x40 };
|
||||
|
||||
iceland_copy_bytes_to_smc(smumgr, 0x0, pData, 4, sizeof(pData)+1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if the SMC is currently running.
|
||||
*
|
||||
* @param smumgr the address of the powerplay hardware manager.
|
||||
*/
|
||||
bool iceland_is_smc_ram_running(struct pp_smumgr *smumgr)
|
||||
{
|
||||
uint32_t val1, val2;
|
||||
|
||||
val1 = SMUM_READ_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC,
|
||||
SMC_SYSCON_CLOCK_CNTL_0, ck_disable);
|
||||
val2 = cgs_read_ind_register(smumgr->device, CGS_IND_REG__SMC,
|
||||
ixSMC_PC_C);
|
||||
|
||||
return ((0 == val1) && (0x20100 <= val2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the SMC, and wait for its response.
|
||||
*
|
||||
* @param smumgr the address of the powerplay hardware manager.
|
||||
* @param msg the message to send.
|
||||
* @return The response that came from the SMC.
|
||||
*/
|
||||
static int iceland_send_msg_to_smc(struct pp_smumgr *smumgr, uint16_t msg)
|
||||
{
|
||||
if (smumgr == NULL || smumgr->device == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
if (!iceland_is_smc_ram_running(smumgr))
|
||||
return -EINVAL;
|
||||
|
||||
SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0);
|
||||
PP_ASSERT_WITH_CODE(
|
||||
1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP),
|
||||
"Failed to send Previous Message.",
|
||||
);
|
||||
|
||||
cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg);
|
||||
|
||||
SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0);
|
||||
PP_ASSERT_WITH_CODE(
|
||||
1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP),
|
||||
"Failed to send Message.",
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the SMC with parameter
|
||||
*
|
||||
* @param smumgr: the address of the powerplay hardware manager.
|
||||
* @param msg: the message to send.
|
||||
* @param parameter: the parameter to send
|
||||
* @return The response that came from the SMC.
|
||||
*/
|
||||
static int iceland_send_msg_to_smc_with_parameter(struct pp_smumgr *smumgr,
|
||||
uint16_t msg, uint32_t parameter)
|
||||
{
|
||||
if (smumgr == NULL || smumgr->device == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
cgs_write_register(smumgr->device, mmSMC_MSG_ARG_0, parameter);
|
||||
|
||||
return iceland_send_msg_to_smc(smumgr, msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a 32bit value from the SMC SRAM space.
|
||||
* ALL PARAMETERS ARE IN HOST BYTE ORDER.
|
||||
* @param smumgr the address of the powerplay hardware manager.
|
||||
* @param smcAddress the address in the SMC RAM to access.
|
||||
* @param value and output parameter for the data read from the SMC SRAM.
|
||||
*/
|
||||
int iceland_read_smc_sram_dword(struct pp_smumgr *smumgr,
|
||||
uint32_t smcAddress, uint32_t *value,
|
||||
uint32_t limit)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = iceland_set_smc_sram_address(smumgr, smcAddress, limit);
|
||||
|
||||
if (0 != result)
|
||||
return result;
|
||||
|
||||
*value = cgs_read_register(smumgr->device, mmSMC_IND_DATA_0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a 32bit value to the SMC SRAM space.
|
||||
* ALL PARAMETERS ARE IN HOST BYTE ORDER.
|
||||
* @param smumgr the address of the powerplay hardware manager.
|
||||
* @param smcAddress the address in the SMC RAM to access.
|
||||
* @param value to write to the SMC SRAM.
|
||||
*/
|
||||
int iceland_write_smc_sram_dword(struct pp_smumgr *smumgr,
|
||||
uint32_t smcAddress, uint32_t value,
|
||||
uint32_t limit)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = iceland_set_smc_sram_address(smumgr, smcAddress, limit);
|
||||
|
||||
if (0 != result)
|
||||
return result;
|
||||
|
||||
cgs_write_register(smumgr->device, mmSMC_IND_DATA_0, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_smu_fini(struct pp_smumgr *smumgr)
|
||||
{
|
||||
struct iceland_smumgr *priv = (struct iceland_smumgr *)(smumgr->backend);
|
||||
|
||||
smu_free_memory(smumgr->device, (void *)priv->header_buffer.handle);
|
||||
|
||||
if (smumgr->backend != NULL) {
|
||||
kfree(smumgr->backend);
|
||||
smumgr->backend = NULL;
|
||||
}
|
||||
|
||||
cgs_rel_firmware(smumgr->device, CGS_UCODE_ID_SMU);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static enum cgs_ucode_id iceland_convert_fw_type_to_cgs(uint32_t fw_type)
|
||||
{
|
||||
enum cgs_ucode_id result = CGS_UCODE_ID_MAXIMUM;
|
||||
|
||||
switch (fw_type) {
|
||||
case UCODE_ID_SMU:
|
||||
result = CGS_UCODE_ID_SMU;
|
||||
break;
|
||||
case UCODE_ID_SDMA0:
|
||||
result = CGS_UCODE_ID_SDMA0;
|
||||
break;
|
||||
case UCODE_ID_SDMA1:
|
||||
result = CGS_UCODE_ID_SDMA1;
|
||||
break;
|
||||
case UCODE_ID_CP_CE:
|
||||
result = CGS_UCODE_ID_CP_CE;
|
||||
break;
|
||||
case UCODE_ID_CP_PFP:
|
||||
result = CGS_UCODE_ID_CP_PFP;
|
||||
break;
|
||||
case UCODE_ID_CP_ME:
|
||||
result = CGS_UCODE_ID_CP_ME;
|
||||
break;
|
||||
case UCODE_ID_CP_MEC:
|
||||
result = CGS_UCODE_ID_CP_MEC;
|
||||
break;
|
||||
case UCODE_ID_CP_MEC_JT1:
|
||||
result = CGS_UCODE_ID_CP_MEC_JT1;
|
||||
break;
|
||||
case UCODE_ID_CP_MEC_JT2:
|
||||
result = CGS_UCODE_ID_CP_MEC_JT2;
|
||||
break;
|
||||
case UCODE_ID_RLC_G:
|
||||
result = CGS_UCODE_ID_RLC_G;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the PPIRI firmware type to SMU type mask.
|
||||
* For MEC, we need to check all MEC related type
|
||||
*/
|
||||
static uint16_t iceland_get_mask_for_firmware_type(uint16_t firmwareType)
|
||||
{
|
||||
uint16_t result = 0;
|
||||
|
||||
switch (firmwareType) {
|
||||
case UCODE_ID_SDMA0:
|
||||
result = UCODE_ID_SDMA0_MASK;
|
||||
break;
|
||||
case UCODE_ID_SDMA1:
|
||||
result = UCODE_ID_SDMA1_MASK;
|
||||
break;
|
||||
case UCODE_ID_CP_CE:
|
||||
result = UCODE_ID_CP_CE_MASK;
|
||||
break;
|
||||
case UCODE_ID_CP_PFP:
|
||||
result = UCODE_ID_CP_PFP_MASK;
|
||||
break;
|
||||
case UCODE_ID_CP_ME:
|
||||
result = UCODE_ID_CP_ME_MASK;
|
||||
break;
|
||||
case UCODE_ID_CP_MEC:
|
||||
case UCODE_ID_CP_MEC_JT1:
|
||||
case UCODE_ID_CP_MEC_JT2:
|
||||
result = UCODE_ID_CP_MEC_MASK;
|
||||
break;
|
||||
case UCODE_ID_RLC_G:
|
||||
result = UCODE_ID_RLC_G_MASK;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the FW has been loaded,
|
||||
* SMU will not return if loading has not finished.
|
||||
*/
|
||||
static int iceland_check_fw_load_finish(struct pp_smumgr *smumgr, uint32_t fwType)
|
||||
{
|
||||
uint16_t fwMask = iceland_get_mask_for_firmware_type(fwType);
|
||||
|
||||
if (0 != SMUM_WAIT_VFPF_INDIRECT_REGISTER(smumgr, SMC_IND,
|
||||
SOFT_REGISTERS_TABLE_27, fwMask, fwMask)) {
|
||||
pr_err("[ powerplay ] check firmware loading failed\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Populate one firmware image to the data structure */
|
||||
static int iceland_populate_single_firmware_entry(struct pp_smumgr *smumgr,
|
||||
uint16_t firmware_type,
|
||||
struct SMU_Entry *pentry)
|
||||
{
|
||||
int result;
|
||||
struct cgs_firmware_info info = {0};
|
||||
|
||||
result = cgs_get_firmware_info(
|
||||
smumgr->device,
|
||||
iceland_convert_fw_type_to_cgs(firmware_type),
|
||||
&info);
|
||||
|
||||
if (result == 0) {
|
||||
pentry->version = 0;
|
||||
pentry->id = (uint16_t)firmware_type;
|
||||
pentry->image_addr_high = smu_upper_32_bits(info.mc_addr);
|
||||
pentry->image_addr_low = smu_lower_32_bits(info.mc_addr);
|
||||
pentry->meta_data_addr_high = 0;
|
||||
pentry->meta_data_addr_low = 0;
|
||||
pentry->data_size_byte = info.image_size;
|
||||
pentry->num_register_entries = 0;
|
||||
|
||||
if (firmware_type == UCODE_ID_RLC_G)
|
||||
pentry->flags = 1;
|
||||
else
|
||||
pentry->flags = 0;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void iceland_pp_stop_smc_clock(struct pp_smumgr *smumgr)
|
||||
{
|
||||
SMUM_WRITE_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC,
|
||||
SMC_SYSCON_CLOCK_CNTL_0,
|
||||
ck_disable, 1);
|
||||
}
|
||||
|
||||
static void iceland_start_smc_clock(struct pp_smumgr *smumgr)
|
||||
{
|
||||
SMUM_WRITE_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC,
|
||||
SMC_SYSCON_CLOCK_CNTL_0,
|
||||
ck_disable, 0);
|
||||
}
|
||||
|
||||
int iceland_smu_start_smc(struct pp_smumgr *smumgr)
|
||||
{
|
||||
/* set smc instruct start point at 0x0 */
|
||||
iceland_program_jump_on_start(smumgr);
|
||||
|
||||
/* enable smc clock */
|
||||
iceland_start_smc_clock(smumgr);
|
||||
|
||||
/* de-assert reset */
|
||||
iceland_start_smc(smumgr);
|
||||
|
||||
SMUM_WAIT_INDIRECT_FIELD(smumgr, SMC_IND, FIRMWARE_FLAGS,
|
||||
INTERRUPTS_ENABLED, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload the SMC firmware to the SMC microcontroller.
|
||||
*
|
||||
* @param smumgr the address of the powerplay hardware manager.
|
||||
* @param pFirmware the data structure containing the various sections of the firmware.
|
||||
*/
|
||||
int iceland_smu_upload_firmware_image(struct pp_smumgr *smumgr)
|
||||
{
|
||||
const uint8_t *src;
|
||||
uint32_t byte_count, val;
|
||||
uint32_t data;
|
||||
struct cgs_firmware_info info = {0};
|
||||
|
||||
if (smumgr == NULL || smumgr->device == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
/* load SMC firmware */
|
||||
cgs_get_firmware_info(smumgr->device,
|
||||
iceland_convert_fw_type_to_cgs(UCODE_ID_SMU), &info);
|
||||
|
||||
if (info.image_size & 3) {
|
||||
pr_err("[ powerplay ] SMC ucode is not 4 bytes aligned\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (info.image_size > ICELAND_SMC_SIZE) {
|
||||
pr_err("[ powerplay ] SMC address is beyond the SMC RAM area\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* wait for smc boot up */
|
||||
SMUM_WAIT_INDIRECT_FIELD_UNEQUAL(smumgr, SMC_IND,
|
||||
RCU_UC_EVENTS, boot_seq_done, 0);
|
||||
|
||||
/* clear firmware interrupt enable flag */
|
||||
val = cgs_read_ind_register(smumgr->device, CGS_IND_REG__SMC,
|
||||
ixSMC_SYSCON_MISC_CNTL);
|
||||
cgs_write_ind_register(smumgr->device, CGS_IND_REG__SMC,
|
||||
ixSMC_SYSCON_MISC_CNTL, val | 1);
|
||||
|
||||
/* stop smc clock */
|
||||
iceland_pp_stop_smc_clock(smumgr);
|
||||
|
||||
/* reset smc */
|
||||
iceland_pp_reset_smc(smumgr);
|
||||
|
||||
cgs_write_register(smumgr->device, mmSMC_IND_INDEX_0,
|
||||
info.ucode_start_address);
|
||||
|
||||
SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL,
|
||||
AUTO_INCREMENT_IND_0, 1);
|
||||
|
||||
byte_count = info.image_size;
|
||||
src = (const uint8_t *)info.kptr;
|
||||
|
||||
while (byte_count >= 4) {
|
||||
data = (src[0] << 24) + (src[1] << 16) + (src[2] << 8) + src[3];
|
||||
cgs_write_register(smumgr->device, mmSMC_IND_DATA_0, data);
|
||||
src += 4;
|
||||
byte_count -= 4;
|
||||
}
|
||||
|
||||
SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL,
|
||||
AUTO_INCREMENT_IND_0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_request_smu_reload_fw(struct pp_smumgr *smumgr)
|
||||
{
|
||||
struct iceland_smumgr *iceland_smu =
|
||||
(struct iceland_smumgr *)(smumgr->backend);
|
||||
uint16_t fw_to_load;
|
||||
int result = 0;
|
||||
struct SMU_DRAMData_TOC *toc;
|
||||
|
||||
toc = (struct SMU_DRAMData_TOC *)iceland_smu->pHeader;
|
||||
toc->num_entries = 0;
|
||||
toc->structure_version = 1;
|
||||
|
||||
PP_ASSERT_WITH_CODE(
|
||||
0 == iceland_populate_single_firmware_entry(smumgr,
|
||||
UCODE_ID_RLC_G,
|
||||
&toc->entry[toc->num_entries++]),
|
||||
"Failed to Get Firmware Entry.\n",
|
||||
return -1);
|
||||
PP_ASSERT_WITH_CODE(
|
||||
0 == iceland_populate_single_firmware_entry(smumgr,
|
||||
UCODE_ID_CP_CE,
|
||||
&toc->entry[toc->num_entries++]),
|
||||
"Failed to Get Firmware Entry.\n",
|
||||
return -1);
|
||||
PP_ASSERT_WITH_CODE(
|
||||
0 == iceland_populate_single_firmware_entry
|
||||
(smumgr, UCODE_ID_CP_PFP, &toc->entry[toc->num_entries++]),
|
||||
"Failed to Get Firmware Entry.\n", return -1);
|
||||
PP_ASSERT_WITH_CODE(
|
||||
0 == iceland_populate_single_firmware_entry
|
||||
(smumgr, UCODE_ID_CP_ME, &toc->entry[toc->num_entries++]),
|
||||
"Failed to Get Firmware Entry.\n", return -1);
|
||||
PP_ASSERT_WITH_CODE(
|
||||
0 == iceland_populate_single_firmware_entry
|
||||
(smumgr, UCODE_ID_CP_MEC, &toc->entry[toc->num_entries++]),
|
||||
"Failed to Get Firmware Entry.\n", return -1);
|
||||
PP_ASSERT_WITH_CODE(
|
||||
0 == iceland_populate_single_firmware_entry
|
||||
(smumgr, UCODE_ID_CP_MEC_JT1, &toc->entry[toc->num_entries++]),
|
||||
"Failed to Get Firmware Entry.\n", return -1);
|
||||
PP_ASSERT_WITH_CODE(
|
||||
0 == iceland_populate_single_firmware_entry
|
||||
(smumgr, UCODE_ID_CP_MEC_JT2, &toc->entry[toc->num_entries++]),
|
||||
"Failed to Get Firmware Entry.\n", return -1);
|
||||
PP_ASSERT_WITH_CODE(
|
||||
0 == iceland_populate_single_firmware_entry
|
||||
(smumgr, UCODE_ID_SDMA0, &toc->entry[toc->num_entries++]),
|
||||
"Failed to Get Firmware Entry.\n", return -1);
|
||||
PP_ASSERT_WITH_CODE(
|
||||
0 == iceland_populate_single_firmware_entry
|
||||
(smumgr, UCODE_ID_SDMA1, &toc->entry[toc->num_entries++]),
|
||||
"Failed to Get Firmware Entry.\n", return -1);
|
||||
|
||||
if (!iceland_is_smc_ram_running(smumgr)) {
|
||||
result = iceland_smu_upload_firmware_image(smumgr);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
result = iceland_smu_start_smc(smumgr);
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
|
||||
iceland_send_msg_to_smc_with_parameter(smumgr,
|
||||
PPSMC_MSG_DRV_DRAM_ADDR_HI,
|
||||
iceland_smu->header_buffer.mc_addr_high);
|
||||
|
||||
iceland_send_msg_to_smc_with_parameter(smumgr,
|
||||
PPSMC_MSG_DRV_DRAM_ADDR_LO,
|
||||
iceland_smu->header_buffer.mc_addr_low);
|
||||
|
||||
fw_to_load = UCODE_ID_RLC_G_MASK
|
||||
+ UCODE_ID_SDMA0_MASK
|
||||
+ UCODE_ID_SDMA1_MASK
|
||||
+ UCODE_ID_CP_CE_MASK
|
||||
+ UCODE_ID_CP_ME_MASK
|
||||
+ UCODE_ID_CP_PFP_MASK
|
||||
+ UCODE_ID_CP_MEC_MASK
|
||||
+ UCODE_ID_CP_MEC_JT1_MASK
|
||||
+ UCODE_ID_CP_MEC_JT2_MASK;
|
||||
|
||||
PP_ASSERT_WITH_CODE(
|
||||
0 == iceland_send_msg_to_smc_with_parameter(
|
||||
smumgr, PPSMC_MSG_LoadUcodes, fw_to_load),
|
||||
"Fail to Request SMU Load uCode", return 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int iceland_request_smu_load_specific_fw(struct pp_smumgr *smumgr,
|
||||
uint32_t firmwareType)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iceland_start_smu(struct pp_smumgr *smumgr)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = iceland_smu_upload_firmware_image(smumgr);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
result = iceland_smu_start_smc(smumgr);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
result = iceland_request_smu_reload_fw(smumgr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a 32bit value to the SMC SRAM space.
|
||||
* ALL PARAMETERS ARE IN HOST BYTE ORDER.
|
||||
* @param smumgr the address of the powerplay hardware manager.
|
||||
* @param smcAddress the address in the SMC RAM to access.
|
||||
* @param value to write to the SMC SRAM.
|
||||
*/
|
||||
static int iceland_smu_init(struct pp_smumgr *smumgr)
|
||||
{
|
||||
struct iceland_smumgr *iceland_smu;
|
||||
uint64_t mc_addr = 0;
|
||||
|
||||
/* Allocate memory for backend private data */
|
||||
iceland_smu = (struct iceland_smumgr *)(smumgr->backend);
|
||||
iceland_smu->header_buffer.data_size =
|
||||
((sizeof(struct SMU_DRAMData_TOC) / 4096) + 1) * 4096;
|
||||
|
||||
smu_allocate_memory(smumgr->device,
|
||||
iceland_smu->header_buffer.data_size,
|
||||
CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,
|
||||
PAGE_SIZE,
|
||||
&mc_addr,
|
||||
&iceland_smu->header_buffer.kaddr,
|
||||
&iceland_smu->header_buffer.handle);
|
||||
|
||||
iceland_smu->pHeader = iceland_smu->header_buffer.kaddr;
|
||||
iceland_smu->header_buffer.mc_addr_high = smu_upper_32_bits(mc_addr);
|
||||
iceland_smu->header_buffer.mc_addr_low = smu_lower_32_bits(mc_addr);
|
||||
|
||||
PP_ASSERT_WITH_CODE((NULL != iceland_smu->pHeader),
|
||||
"Out of memory.",
|
||||
kfree(smumgr->backend);
|
||||
cgs_free_gpu_mem(smumgr->device,
|
||||
(cgs_handle_t)iceland_smu->header_buffer.handle);
|
||||
return -1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pp_smumgr_func iceland_smu_funcs = {
|
||||
.smu_init = &iceland_smu_init,
|
||||
.smu_fini = &iceland_smu_fini,
|
||||
.start_smu = &iceland_start_smu,
|
||||
.check_fw_load_finish = &iceland_check_fw_load_finish,
|
||||
.request_smu_load_fw = &iceland_request_smu_reload_fw,
|
||||
.request_smu_load_specific_fw = &iceland_request_smu_load_specific_fw,
|
||||
.send_msg_to_smc = &iceland_send_msg_to_smc,
|
||||
.send_msg_to_smc_with_parameter = &iceland_send_msg_to_smc_with_parameter,
|
||||
.download_pptable_settings = NULL,
|
||||
.upload_pptable_settings = NULL,
|
||||
};
|
||||
|
||||
int iceland_smum_init(struct pp_smumgr *smumgr)
|
||||
{
|
||||
struct iceland_smumgr *iceland_smu = NULL;
|
||||
|
||||
iceland_smu = kzalloc(sizeof(struct iceland_smumgr), GFP_KERNEL);
|
||||
|
||||
if (iceland_smu == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
smumgr->backend = iceland_smu;
|
||||
smumgr->smumgr_funcs = &iceland_smu_funcs;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright 2016 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Author: Huang Rui <ray.huang@amd.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ICELAND_SMUMGR_H_
|
||||
#define _ICELAND_SMUMGR_H_
|
||||
|
||||
struct iceland_buffer_entry {
|
||||
uint32_t data_size;
|
||||
uint32_t mc_addr_low;
|
||||
uint32_t mc_addr_high;
|
||||
void *kaddr;
|
||||
unsigned long handle;
|
||||
};
|
||||
|
||||
/* Iceland only has header_buffer, don't have smu buffer. */
|
||||
struct iceland_smumgr {
|
||||
uint8_t *pHeader;
|
||||
uint8_t *pMecImage;
|
||||
uint32_t ulSoftRegsStart;
|
||||
|
||||
struct iceland_buffer_entry header_buffer;
|
||||
};
|
||||
|
||||
extern int iceland_smum_init(struct pp_smumgr *smumgr);
|
||||
extern int iceland_copy_bytes_to_smc(struct pp_smumgr *smumgr,
|
||||
uint32_t smcStartAddress,
|
||||
const uint8_t *src,
|
||||
uint32_t byteCount, uint32_t limit);
|
||||
|
||||
extern int iceland_smu_start_smc(struct pp_smumgr *smumgr);
|
||||
|
||||
extern int iceland_read_smc_sram_dword(struct pp_smumgr *smumgr,
|
||||
uint32_t smcAddress,
|
||||
uint32_t *value, uint32_t limit);
|
||||
extern int iceland_write_smc_sram_dword(struct pp_smumgr *smumgr,
|
||||
uint32_t smcAddress,
|
||||
uint32_t value, uint32_t limit);
|
||||
|
||||
extern bool iceland_is_smc_ram_running(struct pp_smumgr *smumgr);
|
||||
extern int iceland_smu_upload_firmware_image(struct pp_smumgr *smumgr);
|
||||
|
||||
#endif
|
|
@ -978,7 +978,7 @@ static int polaris10_smu_init(struct pp_smumgr *smumgr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct pp_smumgr_func ellsemere_smu_funcs = {
|
||||
static const struct pp_smumgr_func polaris10_smu_funcs = {
|
||||
.smu_init = polaris10_smu_init,
|
||||
.smu_fini = polaris10_smu_fini,
|
||||
.start_smu = polaris10_start_smu,
|
||||
|
@ -1001,7 +1001,7 @@ int polaris10_smum_init(struct pp_smumgr *smumgr)
|
|||
return -1;
|
||||
|
||||
smumgr->backend = polaris10_smu;
|
||||
smumgr->smumgr_funcs = &ellsemere_smu_funcs;
|
||||
smumgr->smumgr_funcs = &polaris10_smu_funcs;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "linux/delay.h"
|
||||
#include "cz_smumgr.h"
|
||||
#include "tonga_smumgr.h"
|
||||
#include "iceland_smumgr.h"
|
||||
#include "fiji_smumgr.h"
|
||||
#include "polaris10_smumgr.h"
|
||||
|
||||
|
@ -58,6 +59,9 @@ int smum_init(struct amd_pp_init *pp_init, struct pp_instance *handle)
|
|||
break;
|
||||
case AMDGPU_FAMILY_VI:
|
||||
switch (smumgr->chip_id) {
|
||||
case CHIP_TOPAZ:
|
||||
iceland_smum_init(smumgr);
|
||||
break;
|
||||
case CHIP_TONGA:
|
||||
tonga_smum_init(smumgr);
|
||||
break;
|
||||
|
|
|
@ -3480,14 +3480,23 @@ out:
|
|||
int drm_mode_page_flip_ioctl(struct drm_device *dev,
|
||||
void *data, struct drm_file *file_priv)
|
||||
{
|
||||
struct drm_mode_crtc_page_flip *page_flip = data;
|
||||
struct drm_mode_crtc_page_flip_target *page_flip = data;
|
||||
struct drm_crtc *crtc;
|
||||
struct drm_framebuffer *fb = NULL;
|
||||
struct drm_pending_vblank_event *e = NULL;
|
||||
u32 target_vblank = page_flip->sequence;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS ||
|
||||
page_flip->reserved != 0)
|
||||
if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS)
|
||||
return -EINVAL;
|
||||
|
||||
if (page_flip->sequence != 0 && !(page_flip->flags & DRM_MODE_PAGE_FLIP_TARGET))
|
||||
return -EINVAL;
|
||||
|
||||
/* Only one of the DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags
|
||||
* can be specified
|
||||
*/
|
||||
if ((page_flip->flags & DRM_MODE_PAGE_FLIP_TARGET) == DRM_MODE_PAGE_FLIP_TARGET)
|
||||
return -EINVAL;
|
||||
|
||||
if ((page_flip->flags & DRM_MODE_PAGE_FLIP_ASYNC) && !dev->mode_config.async_page_flip)
|
||||
|
@ -3497,6 +3506,45 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
|
|||
if (!crtc)
|
||||
return -ENOENT;
|
||||
|
||||
if (crtc->funcs->page_flip_target) {
|
||||
u32 current_vblank;
|
||||
int r;
|
||||
|
||||
r = drm_crtc_vblank_get(crtc);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
current_vblank = drm_crtc_vblank_count(crtc);
|
||||
|
||||
switch (page_flip->flags & DRM_MODE_PAGE_FLIP_TARGET) {
|
||||
case DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE:
|
||||
if ((int)(target_vblank - current_vblank) > 1) {
|
||||
DRM_DEBUG("Invalid absolute flip target %u, "
|
||||
"must be <= %u\n", target_vblank,
|
||||
current_vblank + 1);
|
||||
drm_crtc_vblank_put(crtc);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case DRM_MODE_PAGE_FLIP_TARGET_RELATIVE:
|
||||
if (target_vblank != 0 && target_vblank != 1) {
|
||||
DRM_DEBUG("Invalid relative flip target %u, "
|
||||
"must be 0 or 1\n", target_vblank);
|
||||
drm_crtc_vblank_put(crtc);
|
||||
return -EINVAL;
|
||||
}
|
||||
target_vblank += current_vblank;
|
||||
break;
|
||||
default:
|
||||
target_vblank = current_vblank +
|
||||
!(page_flip->flags & DRM_MODE_PAGE_FLIP_ASYNC);
|
||||
break;
|
||||
}
|
||||
} else if (crtc->funcs->page_flip == NULL ||
|
||||
(page_flip->flags & DRM_MODE_PAGE_FLIP_TARGET)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
drm_modeset_lock_crtc(crtc, crtc->primary);
|
||||
if (crtc->primary->fb == NULL) {
|
||||
/* The framebuffer is currently unbound, presumably
|
||||
|
@ -3507,9 +3555,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (crtc->funcs->page_flip == NULL)
|
||||
goto out;
|
||||
|
||||
fb = drm_framebuffer_lookup(dev, page_flip->fb_id);
|
||||
if (!fb) {
|
||||
ret = -ENOENT;
|
||||
|
@ -3550,7 +3595,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
|
|||
}
|
||||
|
||||
crtc->primary->old_fb = crtc->primary->fb;
|
||||
ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags);
|
||||
if (crtc->funcs->page_flip_target)
|
||||
ret = crtc->funcs->page_flip_target(crtc, fb, e,
|
||||
page_flip->flags,
|
||||
target_vblank);
|
||||
else
|
||||
ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags);
|
||||
if (ret) {
|
||||
if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT)
|
||||
drm_event_cancel_free(dev, &e->base);
|
||||
|
@ -3563,6 +3613,8 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
|
|||
}
|
||||
|
||||
out:
|
||||
if (ret)
|
||||
drm_crtc_vblank_put(crtc);
|
||||
if (fb)
|
||||
drm_framebuffer_unreference(fb);
|
||||
if (crtc->primary->old_fb)
|
||||
|
|
|
@ -228,6 +228,7 @@ static int drm_getstats(struct drm_device *dev, void *data,
|
|||
static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||
{
|
||||
struct drm_get_cap *req = data;
|
||||
struct drm_crtc *crtc;
|
||||
|
||||
req->value = 0;
|
||||
switch (req->capability) {
|
||||
|
@ -254,6 +255,13 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
|
|||
case DRM_CAP_ASYNC_PAGE_FLIP:
|
||||
req->value = dev->mode_config.async_page_flip;
|
||||
break;
|
||||
case DRM_CAP_PAGE_FLIP_TARGET:
|
||||
req->value = 1;
|
||||
drm_for_each_crtc(crtc, dev) {
|
||||
if (!crtc->funcs->page_flip_target)
|
||||
req->value = 0;
|
||||
}
|
||||
break;
|
||||
case DRM_CAP_CURSOR_WIDTH:
|
||||
if (dev->mode_config.cursor_width)
|
||||
req->value = dev->mode_config.cursor_width;
|
||||
|
|
|
@ -1151,7 +1151,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
|
|||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = ttm_bo_move_ttm(bo, true, intr, no_wait_gpu, new_mem);
|
||||
ret = ttm_bo_move_ttm(bo, intr, no_wait_gpu, new_mem);
|
||||
out:
|
||||
ttm_bo_mem_put(bo, &tmp_mem);
|
||||
return ret;
|
||||
|
@ -1179,7 +1179,7 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ttm_bo_move_ttm(bo, true, intr, no_wait_gpu, &tmp_mem);
|
||||
ret = ttm_bo_move_ttm(bo, intr, no_wait_gpu, &tmp_mem);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
|
@ -1297,7 +1297,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
|
|||
/* Fallback to software copy. */
|
||||
ret = ttm_bo_wait(bo, intr, no_wait_gpu);
|
||||
if (ret == 0)
|
||||
ret = ttm_bo_move_memcpy(bo, evict, intr, no_wait_gpu, new_mem);
|
||||
ret = ttm_bo_move_memcpy(bo, intr, no_wait_gpu, new_mem);
|
||||
|
||||
out:
|
||||
if (drm->device.info.family < NV_DEVICE_INFO_V0_TESLA) {
|
||||
|
|
|
@ -361,8 +361,8 @@ static int qxl_bo_move(struct ttm_buffer_object *bo,
|
|||
qxl_move_null(bo, new_mem);
|
||||
return 0;
|
||||
}
|
||||
return ttm_bo_move_memcpy(bo, evict, interruptible,
|
||||
no_wait_gpu, new_mem);
|
||||
return ttm_bo_move_memcpy(bo, interruptible, no_wait_gpu,
|
||||
new_mem);
|
||||
}
|
||||
|
||||
static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
|
||||
|
|
|
@ -1435,8 +1435,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
|
|||
WREG32(EVERGREEN_VIEWPORT_SIZE + radeon_crtc->crtc_offset,
|
||||
(viewport_w << 16) | viewport_h);
|
||||
|
||||
/* set pageflip to happen only at start of vblank interval (front porch) */
|
||||
WREG32(EVERGREEN_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 3);
|
||||
/* set pageflip to happen anywhere in vblank interval */
|
||||
WREG32(EVERGREEN_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 0);
|
||||
|
||||
if (!atomic && fb && fb != crtc->primary->fb) {
|
||||
radeon_fb = to_radeon_framebuffer(fb);
|
||||
|
@ -1636,8 +1636,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
|
|||
WREG32(AVIVO_D1MODE_VIEWPORT_SIZE + radeon_crtc->crtc_offset,
|
||||
(viewport_w << 16) | viewport_h);
|
||||
|
||||
/* set pageflip to happen only at start of vblank interval (front porch) */
|
||||
WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 3);
|
||||
/* set pageflip to happen anywhere in vblank interval */
|
||||
WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 0);
|
||||
|
||||
if (!atomic && fb && fb != crtc->primary->fb) {
|
||||
radeon_fb = to_radeon_framebuffer(fb);
|
||||
|
|
|
@ -389,22 +389,21 @@ bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector)
|
|||
{
|
||||
struct radeon_connector_atom_dig *dig_connector = radeon_connector->con_priv;
|
||||
u8 msg[DP_DPCD_SIZE];
|
||||
int ret, i;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < 7; i++) {
|
||||
ret = drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_DPCD_REV, msg,
|
||||
DP_DPCD_SIZE);
|
||||
if (ret == DP_DPCD_SIZE) {
|
||||
memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE);
|
||||
ret = drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_DPCD_REV, msg,
|
||||
DP_DPCD_SIZE);
|
||||
if (ret == DP_DPCD_SIZE) {
|
||||
memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE);
|
||||
|
||||
DRM_DEBUG_KMS("DPCD: %*ph\n", (int)sizeof(dig_connector->dpcd),
|
||||
dig_connector->dpcd);
|
||||
DRM_DEBUG_KMS("DPCD: %*ph\n", (int)sizeof(dig_connector->dpcd),
|
||||
dig_connector->dpcd);
|
||||
|
||||
radeon_dp_probe_oui(radeon_connector);
|
||||
radeon_dp_probe_oui(radeon_connector);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
dig_connector->dpcd[0] = 0;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1871,7 +1871,7 @@ int ci_mc_load_microcode(struct radeon_device *rdev)
|
|||
{
|
||||
const __be32 *fw_data = NULL;
|
||||
const __le32 *new_fw_data = NULL;
|
||||
u32 running, blackout = 0, tmp;
|
||||
u32 running, tmp;
|
||||
u32 *io_mc_regs = NULL;
|
||||
const __le32 *new_io_mc_regs = NULL;
|
||||
int i, regs_size, ucode_size;
|
||||
|
@ -1912,11 +1912,6 @@ int ci_mc_load_microcode(struct radeon_device *rdev)
|
|||
running = RREG32(MC_SEQ_SUP_CNTL) & RUN_MASK;
|
||||
|
||||
if (running == 0) {
|
||||
if (running) {
|
||||
blackout = RREG32(MC_SHARED_BLACKOUT_CNTL);
|
||||
WREG32(MC_SHARED_BLACKOUT_CNTL, blackout | 1);
|
||||
}
|
||||
|
||||
/* reset the engine and set to writable */
|
||||
WREG32(MC_SEQ_SUP_CNTL, 0x00000008);
|
||||
WREG32(MC_SEQ_SUP_CNTL, 0x00000010);
|
||||
|
@ -1964,9 +1959,6 @@ int ci_mc_load_microcode(struct radeon_device *rdev)
|
|||
break;
|
||||
udelay(1);
|
||||
}
|
||||
|
||||
if (running)
|
||||
WREG32(MC_SHARED_BLACKOUT_CNTL, blackout);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -8215,7 +8207,7 @@ static void cik_uvd_resume(struct radeon_device *rdev)
|
|||
return;
|
||||
|
||||
ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX];
|
||||
r = radeon_ring_init(rdev, ring, ring->ring_size, 0, RADEON_CP_PACKET2);
|
||||
r = radeon_ring_init(rdev, ring, ring->ring_size, 0, PACKET0(UVD_NO_OP, 0));
|
||||
if (r) {
|
||||
dev_err(rdev->dev, "failed initializing UVD ring (%d).\n", r);
|
||||
return;
|
||||
|
|
|
@ -2069,6 +2069,7 @@
|
|||
#define UVD_UDEC_ADDR_CONFIG 0xef4c
|
||||
#define UVD_UDEC_DB_ADDR_CONFIG 0xef50
|
||||
#define UVD_UDEC_DBW_ADDR_CONFIG 0xef54
|
||||
#define UVD_NO_OP 0xeffc
|
||||
|
||||
#define UVD_LMI_EXT40_ADDR 0xf498
|
||||
#define UVD_GP_SCRATCH4 0xf4e0
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue