aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c54
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c11
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c108
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h9
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.h1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c27
-rw-r--r--drivers/gpu/drm/amd/amdgpu/ci_dpm.c14
-rw-r--r--drivers/gpu/drm/amd/amdgpu/cik_ih.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/cz_dpm.c273
-rw-r--r--drivers/gpu/drm/amd/amdgpu/cz_dpm.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/cz_ih.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/dce_v11_0.c16
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/iceland_ih.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/tonga_ih.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/vce_v3_0.c89
-rw-r--r--drivers/gpu/drm/amd/include/cgs_common.h34
-rw-r--r--drivers/gpu/drm/amd/powerplay/amd_powerplay.c32
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c1
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.c9
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/psm.c3
-rw-r--r--drivers/gpu/drm/amd/powerplay/eventmgr/psm.h2
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c75
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c64
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/fiji_powertune.c12
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/fiji_thermal.c2
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c13
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c18
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c3
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h555
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c15
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c40
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c20
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/tonga_thermal.c2
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h2
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/hwmgr.h6
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/pp_instance.h3
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c2
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c10
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c8
-rw-r--r--drivers/gpu/drm/drm_dp_mst_topology.c141
-rw-r--r--drivers/gpu/drm/nouveau/Kbuild1
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl0002.h66
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl0046.h28
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl006b.h11
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl0080.h45
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl506e.h12
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl506f.h13
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl5070.h99
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl507a.h11
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl507b.h11
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl507c.h12
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl507d.h11
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl507e.h12
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl826e.h14
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl826f.h15
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl906f.h14
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cl9097.h44
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/cla06f.h21
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/class.h701
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/device.h3
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/if0000.h12
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/if0001.h46
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/if0002.h38
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/if0003.h33
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/if0004.h13
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/if0005.h4
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/ioctl.h8
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/unpack.h34
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/perf.h2
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/subdev/clk.h5
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/subdev/ibus.h1
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/subdev/ltc.h1
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h16
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_abi16.c22
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_chan.c7
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.c29
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_debugfs.c224
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_debugfs.h35
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.c19
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.h2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fence.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_hwmon.c50
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_platform.c11
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_sysfs.c197
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_sysfs.h21
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_usif.c25
-rw-r--r--drivers/gpu/drm/nouveau/nv04_fence.c2
-rw-r--r--drivers/gpu/drm/nouveau/nv17_fence.c1
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c23
-rw-r--r--drivers/gpu/drm/nouveau/nv50_fence.c1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/core/client.c9
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/core/ioctl.c56
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/ce/gk104.c54
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/base.c43
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c15
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/user.c17
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c9
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/basenv50.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/cursnv50.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c10
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagf119.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagt215.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/oimmnv50.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/ovlynv50.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c7
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv04.c9
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c19
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/chang84.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c7
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv10.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv17.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv40.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c24
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.h5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c22
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c7
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c13
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c13
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgk20a.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h332
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c116
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c34
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sw/gf100.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sw/nv04.c7
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sw/nv10.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sw/nv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/bios/dcb.c11
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/bios/perf.c16
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/clk/gf100.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk104.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk104.c8
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/ibus/Kbuild1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gm204.c40
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/ibus/priv.h1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c192
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/ltc/Kbuild1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm107.c12
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm204.c63
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/ltc/priv.h6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild3
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c14
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pci/g84.c92
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pci/g94.c18
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pci/gf100.c57
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pci/gf106.c49
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pci/gk104.c228
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pci/pcie.c165
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pci/priv.h33
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf100.fuc3.h1366
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf119.fuc4.h1284
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gk208.fuc5.h338
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gt215.fuc3.h1516
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/kernel.fuc14
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c2
-rw-r--r--drivers/gpu/drm/radeon/r100.c5
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c2
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c31
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c6
-rw-r--r--include/drm/drm_dp_mst_helper.h2
-rw-r--r--include/drm/ttm/ttm_bo_api.h10
195 files changed, 6121 insertions, 4240 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 003959f99251..313b0cc8d676 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -987,6 +987,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
987 struct list_head *validated, 987 struct list_head *validated,
988 struct amdgpu_bo_list_entry *entry); 988 struct amdgpu_bo_list_entry *entry);
989void amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm, struct list_head *duplicates); 989void amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm, struct list_head *duplicates);
990void amdgpu_vm_move_pt_bos_in_lru(struct amdgpu_device *adev,
991 struct amdgpu_vm *vm);
990int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, 992int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
991 struct amdgpu_sync *sync); 993 struct amdgpu_sync *sync);
992void amdgpu_vm_flush(struct amdgpu_ring *ring, 994void amdgpu_vm_flush(struct amdgpu_ring *ring,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
index 6fa0feac27f8..a081dda9fa2f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -398,6 +398,41 @@ static void amdgpu_cgs_write_pci_config_dword(void *cgs_device, unsigned addr,
398 WARN(ret, "pci_write_config_dword error"); 398 WARN(ret, "pci_write_config_dword error");
399} 399}
400 400
401
402static int amdgpu_cgs_get_pci_resource(void *cgs_device,
403 enum cgs_resource_type resource_type,
404 uint64_t size,
405 uint64_t offset,
406 uint64_t *resource_base)
407{
408 CGS_FUNC_ADEV;
409
410 if (resource_base == NULL)
411 return -EINVAL;
412
413 switch (resource_type) {
414 case CGS_RESOURCE_TYPE_MMIO:
415 if (adev->rmmio_size == 0)
416 return -ENOENT;
417 if ((offset + size) > adev->rmmio_size)
418 return -EINVAL;
419 *resource_base = adev->rmmio_base;
420 return 0;
421 case CGS_RESOURCE_TYPE_DOORBELL:
422 if (adev->doorbell.size == 0)
423 return -ENOENT;
424 if ((offset + size) > adev->doorbell.size)
425 return -EINVAL;
426 *resource_base = adev->doorbell.base;
427 return 0;
428 case CGS_RESOURCE_TYPE_FB:
429 case CGS_RESOURCE_TYPE_IO:
430 case CGS_RESOURCE_TYPE_ROM:
431 default:
432 return -EINVAL;
433 }
434}
435
401static const void *amdgpu_cgs_atom_get_data_table(void *cgs_device, 436static const void *amdgpu_cgs_atom_get_data_table(void *cgs_device,
402 unsigned table, uint16_t *size, 437 unsigned table, uint16_t *size,
403 uint8_t *frev, uint8_t *crev) 438 uint8_t *frev, uint8_t *crev)
@@ -843,15 +878,15 @@ static int amdgpu_cgs_acpi_eval_object(void *cgs_device,
843 if (info->input_count > 0) { 878 if (info->input_count > 0) {
844 if (info->pinput_argument == NULL) 879 if (info->pinput_argument == NULL)
845 return -EINVAL; 880 return -EINVAL;
846 argument = info->pinput_argument; 881 argument = info->pinput_argument;
847 func_no = argument->value; 882 func_no = argument->value;
848 for (i = 0; i < info->input_count; i++) { 883 for (i = 0; i < info->input_count; i++) {
849 if (((argument->type == ACPI_TYPE_STRING) || 884 if (((argument->type == ACPI_TYPE_STRING) ||
850 (argument->type == ACPI_TYPE_BUFFER)) 885 (argument->type == ACPI_TYPE_BUFFER)) &&
851 && (argument->pointer == NULL)) 886 (argument->pointer == NULL))
852 return -EINVAL; 887 return -EINVAL;
853 argument++; 888 argument++;
854 } 889 }
855 } 890 }
856 891
857 if (info->output_count > 0) { 892 if (info->output_count > 0) {
@@ -1041,6 +1076,7 @@ static const struct cgs_ops amdgpu_cgs_ops = {
1041 amdgpu_cgs_write_pci_config_byte, 1076 amdgpu_cgs_write_pci_config_byte,
1042 amdgpu_cgs_write_pci_config_word, 1077 amdgpu_cgs_write_pci_config_word,
1043 amdgpu_cgs_write_pci_config_dword, 1078 amdgpu_cgs_write_pci_config_dword,
1079 amdgpu_cgs_get_pci_resource,
1044 amdgpu_cgs_atom_get_data_table, 1080 amdgpu_cgs_atom_get_data_table,
1045 amdgpu_cgs_atom_get_cmd_table_revs, 1081 amdgpu_cgs_atom_get_cmd_table_revs,
1046 amdgpu_cgs_atom_exec_cmd_table, 1082 amdgpu_cgs_atom_exec_cmd_table,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index ce0254d4dcd7..6f89f8e034d0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -421,15 +421,17 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p)
421 421
422 amdgpu_vm_get_pt_bos(&fpriv->vm, &duplicates); 422 amdgpu_vm_get_pt_bos(&fpriv->vm, &duplicates);
423 423
424 r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &p->validated); 424 r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &duplicates);
425 if (r) 425 if (r)
426 goto error_validate; 426 goto error_validate;
427 427
428 r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &duplicates); 428 r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &p->validated);
429 429
430error_validate: 430error_validate:
431 if (r) 431 if (r) {
432 amdgpu_vm_move_pt_bos_in_lru(p->adev, &fpriv->vm);
432 ttm_eu_backoff_reservation(&p->ticket, &p->validated); 433 ttm_eu_backoff_reservation(&p->ticket, &p->validated);
434 }
433 435
434error_reserve: 436error_reserve:
435 if (need_mmap_lock) 437 if (need_mmap_lock)
@@ -473,8 +475,11 @@ static int cmp_size_smaller_first(void *priv, struct list_head *a,
473 **/ 475 **/
474static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bool backoff) 476static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bool backoff)
475{ 477{
478 struct amdgpu_fpriv *fpriv = parser->filp->driver_priv;
476 unsigned i; 479 unsigned i;
477 480
481 amdgpu_vm_move_pt_bos_in_lru(parser->adev, &fpriv->vm);
482
478 if (!error) { 483 if (!error) {
479 /* Sort the buffer list from the smallest to largest buffer, 484 /* Sort the buffer list from the smallest to largest buffer,
480 * which affects the order of buffers in the LRU list. 485 * which affects the order of buffers in the LRU list.
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 7c42ff670080..3006182c5d0d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -312,6 +312,7 @@ int amdgpu_irq_add_id(struct amdgpu_device *adev, unsigned src_id,
312 } 312 }
313 313
314 adev->irq.sources[src_id] = source; 314 adev->irq.sources[src_id] = source;
315
315 return 0; 316 return 0;
316} 317}
317 318
@@ -335,15 +336,19 @@ void amdgpu_irq_dispatch(struct amdgpu_device *adev,
335 return; 336 return;
336 } 337 }
337 338
338 src = adev->irq.sources[src_id]; 339 if (adev->irq.virq[src_id]) {
339 if (!src) { 340 generic_handle_irq(irq_find_mapping(adev->irq.domain, src_id));
340 DRM_DEBUG("Unhandled interrupt src_id: %d\n", src_id); 341 } else {
341 return; 342 src = adev->irq.sources[src_id];
342 } 343 if (!src) {
344 DRM_DEBUG("Unhandled interrupt src_id: %d\n", src_id);
345 return;
346 }
343 347
344 r = src->funcs->process(adev, src, entry); 348 r = src->funcs->process(adev, src, entry);
345 if (r) 349 if (r)
346 DRM_ERROR("error processing interrupt (%d)\n", r); 350 DRM_ERROR("error processing interrupt (%d)\n", r);
351 }
347} 352}
348 353
349/** 354/**
@@ -461,3 +466,90 @@ bool amdgpu_irq_enabled(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
461 466
462 return !!atomic_read(&src->enabled_types[type]); 467 return !!atomic_read(&src->enabled_types[type]);
463} 468}
469
470/* gen irq */
471static void amdgpu_irq_mask(struct irq_data *irqd)
472{
473 /* XXX */
474}
475
476static void amdgpu_irq_unmask(struct irq_data *irqd)
477{
478 /* XXX */
479}
480
481static struct irq_chip amdgpu_irq_chip = {
482 .name = "amdgpu-ih",
483 .irq_mask = amdgpu_irq_mask,
484 .irq_unmask = amdgpu_irq_unmask,
485};
486
487static int amdgpu_irqdomain_map(struct irq_domain *d,
488 unsigned int irq, irq_hw_number_t hwirq)
489{
490 if (hwirq >= AMDGPU_MAX_IRQ_SRC_ID)
491 return -EPERM;
492
493 irq_set_chip_and_handler(irq,
494 &amdgpu_irq_chip, handle_simple_irq);
495 return 0;
496}
497
498static struct irq_domain_ops amdgpu_hw_irqdomain_ops = {
499 .map = amdgpu_irqdomain_map,
500};
501
502/**
503 * amdgpu_irq_add_domain - create a linear irq domain
504 *
505 * @adev: amdgpu device pointer
506 *
507 * Create an irq domain for GPU interrupt sources
508 * that may be driven by another driver (e.g., ACP).
509 */
510int amdgpu_irq_add_domain(struct amdgpu_device *adev)
511{
512 adev->irq.domain = irq_domain_add_linear(NULL, AMDGPU_MAX_IRQ_SRC_ID,
513 &amdgpu_hw_irqdomain_ops, adev);
514 if (!adev->irq.domain) {
515 DRM_ERROR("GPU irq add domain failed\n");
516 return -ENODEV;
517 }
518
519 return 0;
520}
521
522/**
523 * amdgpu_irq_remove_domain - remove the irq domain
524 *
525 * @adev: amdgpu device pointer
526 *
527 * Remove the irq domain for GPU interrupt sources
528 * that may be driven by another driver (e.g., ACP).
529 */
530void amdgpu_irq_remove_domain(struct amdgpu_device *adev)
531{
532 if (adev->irq.domain) {
533 irq_domain_remove(adev->irq.domain);
534 adev->irq.domain = NULL;
535 }
536}
537
538/**
539 * amdgpu_irq_create_mapping - create a mapping between a domain irq and a
540 * Linux irq
541 *
542 * @adev: amdgpu device pointer
543 * @src_id: IH source id
544 *
545 * Create a mapping between a domain irq (GPU IH src id) and a Linux irq
546 * Use this for components that generate a GPU interrupt, but are driven
547 * by a different driver (e.g., ACP).
548 * Returns the Linux irq.
549 */
550unsigned amdgpu_irq_create_mapping(struct amdgpu_device *adev, unsigned src_id)
551{
552 adev->irq.virq[src_id] = irq_create_mapping(adev->irq.domain, src_id);
553
554 return adev->irq.virq[src_id];
555}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h
index 17b01aef4278..e124b59f39c1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h
@@ -24,6 +24,7 @@
24#ifndef __AMDGPU_IRQ_H__ 24#ifndef __AMDGPU_IRQ_H__
25#define __AMDGPU_IRQ_H__ 25#define __AMDGPU_IRQ_H__
26 26
27#include <linux/irqdomain.h>
27#include "amdgpu_ih.h" 28#include "amdgpu_ih.h"
28 29
29#define AMDGPU_MAX_IRQ_SRC_ID 0x100 30#define AMDGPU_MAX_IRQ_SRC_ID 0x100
@@ -65,6 +66,10 @@ struct amdgpu_irq {
65 /* interrupt ring */ 66 /* interrupt ring */
66 struct amdgpu_ih_ring ih; 67 struct amdgpu_ih_ring ih;
67 const struct amdgpu_ih_funcs *ih_funcs; 68 const struct amdgpu_ih_funcs *ih_funcs;
69
70 /* gen irq stuff */
71 struct irq_domain *domain; /* GPU irq controller domain */
72 unsigned virq[AMDGPU_MAX_IRQ_SRC_ID];
68}; 73};
69 74
70void amdgpu_irq_preinstall(struct drm_device *dev); 75void amdgpu_irq_preinstall(struct drm_device *dev);
@@ -90,4 +95,8 @@ int amdgpu_irq_put(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
90bool amdgpu_irq_enabled(struct amdgpu_device *adev, struct amdgpu_irq_src *src, 95bool amdgpu_irq_enabled(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
91 unsigned type); 96 unsigned type);
92 97
98int amdgpu_irq_add_domain(struct amdgpu_device *adev);
99void amdgpu_irq_remove_domain(struct amdgpu_device *adev);
100unsigned amdgpu_irq_create_mapping(struct amdgpu_device *adev, unsigned src_id);
101
93#endif 102#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index ea756e77b023..5107fb291bdb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -96,6 +96,7 @@ static inline void amdgpu_bo_unreserve(struct amdgpu_bo *bo)
96 */ 96 */
97static inline u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) 97static inline u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)
98{ 98{
99 WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM);
99 return bo->tbo.offset; 100 return bo->tbo.offset;
100} 101}
101 102
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 3b78982abaf1..7d8d84eaea4a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -326,7 +326,7 @@ static struct attribute *hwmon_attributes[] = {
326static umode_t hwmon_attributes_visible(struct kobject *kobj, 326static umode_t hwmon_attributes_visible(struct kobject *kobj,
327 struct attribute *attr, int index) 327 struct attribute *attr, int index)
328{ 328{
329 struct device *dev = container_of(kobj, struct device, kobj); 329 struct device *dev = kobj_to_dev(kobj);
330 struct amdgpu_device *adev = dev_get_drvdata(dev); 330 struct amdgpu_device *adev = dev_get_drvdata(dev);
331 umode_t effective_mode = attr->mode; 331 umode_t effective_mode = attr->mode;
332 332
@@ -807,7 +807,7 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
807 struct amdgpu_ring *ring = adev->rings[i]; 807 struct amdgpu_ring *ring = adev->rings[i];
808 if (ring && ring->ready) 808 if (ring && ring->ready)
809 amdgpu_fence_wait_empty(ring); 809 amdgpu_fence_wait_empty(ring);
810 } 810 }
811 mutex_unlock(&adev->ring_lock); 811 mutex_unlock(&adev->ring_lock);
812 812
813 amdgpu_dpm_dispatch_task(adev, AMD_PP_EVENT_DISPLAY_CONFIG_CHANGE, NULL, NULL); 813 amdgpu_dpm_dispatch_task(adev, AMD_PP_EVENT_DISPLAY_CONFIG_CHANGE, NULL, NULL);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
index dd005c336c97..181ce39ef5e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -293,7 +293,8 @@ int amdgpu_sync_rings(struct amdgpu_sync *sync,
293 fence = to_amdgpu_fence(sync->sync_to[i]); 293 fence = to_amdgpu_fence(sync->sync_to[i]);
294 294
295 /* check if we really need to sync */ 295 /* check if we really need to sync */
296 if (!amdgpu_fence_need_sync(fence, ring)) 296 if (!amdgpu_enable_scheduler &&
297 !amdgpu_fence_need_sync(fence, ring))
297 continue; 298 continue;
298 299
299 /* prevent GPU deadlocks */ 300 /* prevent GPU deadlocks */
@@ -303,7 +304,7 @@ int amdgpu_sync_rings(struct amdgpu_sync *sync,
303 } 304 }
304 305
305 if (amdgpu_enable_scheduler || !amdgpu_enable_semaphores) { 306 if (amdgpu_enable_scheduler || !amdgpu_enable_semaphores) {
306 r = fence_wait(&fence->base, true); 307 r = fence_wait(sync->sync_to[i], true);
307 if (r) 308 if (r)
308 return r; 309 return r;
309 continue; 310 continue;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 8f7688e598a1..aefc668e6b5d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -119,6 +119,33 @@ void amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm, struct list_head *duplicates)
119 119
120 list_add(&entry->tv.head, duplicates); 120 list_add(&entry->tv.head, duplicates);
121 } 121 }
122
123}
124
125/**
126 * amdgpu_vm_move_pt_bos_in_lru - move the PT BOs to the LRU tail
127 *
128 * @adev: amdgpu device instance
129 * @vm: vm providing the BOs
130 *
131 * Move the PT BOs to the tail of the LRU.
132 */
133void amdgpu_vm_move_pt_bos_in_lru(struct amdgpu_device *adev,
134 struct amdgpu_vm *vm)
135{
136 struct ttm_bo_global *glob = adev->mman.bdev.glob;
137 unsigned i;
138
139 spin_lock(&glob->lru_lock);
140 for (i = 0; i <= vm->max_pde_used; ++i) {
141 struct amdgpu_bo_list_entry *entry = &vm->page_tables[i].entry;
142
143 if (!entry->robj)
144 continue;
145
146 ttm_bo_move_to_lru_tail(&entry->robj->tbo);
147 }
148 spin_unlock(&glob->lru_lock);
122} 149}
123 150
124/** 151/**
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
index 57a2e347f04d..8b4731d4e10e 100644
--- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
@@ -1395,7 +1395,6 @@ static void ci_thermal_stop_thermal_controller(struct amdgpu_device *adev)
1395 ci_fan_ctrl_set_default_mode(adev); 1395 ci_fan_ctrl_set_default_mode(adev);
1396} 1396}
1397 1397
1398#if 0
1399static int ci_read_smc_soft_register(struct amdgpu_device *adev, 1398static int ci_read_smc_soft_register(struct amdgpu_device *adev,
1400 u16 reg_offset, u32 *value) 1399 u16 reg_offset, u32 *value)
1401{ 1400{
@@ -1405,7 +1404,6 @@ static int ci_read_smc_soft_register(struct amdgpu_device *adev,
1405 pi->soft_regs_start + reg_offset, 1404 pi->soft_regs_start + reg_offset,
1406 value, pi->sram_end); 1405 value, pi->sram_end);
1407} 1406}
1408#endif
1409 1407
1410static int ci_write_smc_soft_register(struct amdgpu_device *adev, 1408static int ci_write_smc_soft_register(struct amdgpu_device *adev,
1411 u16 reg_offset, u32 value) 1409 u16 reg_offset, u32 value)
@@ -6084,11 +6082,23 @@ ci_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev,
6084 struct amdgpu_ps *rps = &pi->current_rps; 6082 struct amdgpu_ps *rps = &pi->current_rps;
6085 u32 sclk = ci_get_average_sclk_freq(adev); 6083 u32 sclk = ci_get_average_sclk_freq(adev);
6086 u32 mclk = ci_get_average_mclk_freq(adev); 6084 u32 mclk = ci_get_average_mclk_freq(adev);
6085 u32 activity_percent = 50;
6086 int ret;
6087
6088 ret = ci_read_smc_soft_register(adev, offsetof(SMU7_SoftRegisters, AverageGraphicsA),
6089 &activity_percent);
6090
6091 if (ret == 0) {
6092 activity_percent += 0x80;
6093 activity_percent >>= 8;
6094 activity_percent = activity_percent > 100 ? 100 : activity_percent;
6095 }
6087 6096
6088 seq_printf(m, "uvd %sabled\n", pi->uvd_enabled ? "en" : "dis"); 6097 seq_printf(m, "uvd %sabled\n", pi->uvd_enabled ? "en" : "dis");
6089 seq_printf(m, "vce %sabled\n", rps->vce_active ? "en" : "dis"); 6098 seq_printf(m, "vce %sabled\n", rps->vce_active ? "en" : "dis");
6090 seq_printf(m, "power level avg sclk: %u mclk: %u\n", 6099 seq_printf(m, "power level avg sclk: %u mclk: %u\n",
6091 sclk, mclk); 6100 sclk, mclk);
6101 seq_printf(m, "GPU load: %u %%\n", activity_percent);
6092} 6102}
6093 6103
6094static void ci_dpm_print_power_state(struct amdgpu_device *adev, 6104static void ci_dpm_print_power_state(struct amdgpu_device *adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_ih.c b/drivers/gpu/drm/amd/amdgpu/cik_ih.c
index 8993c50cb89f..30c9b3beeef9 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_ih.c
@@ -274,6 +274,11 @@ static void cik_ih_set_rptr(struct amdgpu_device *adev)
274static int cik_ih_early_init(void *handle) 274static int cik_ih_early_init(void *handle)
275{ 275{
276 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 276 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
277 int ret;
278
279 ret = amdgpu_irq_add_domain(adev);
280 if (ret)
281 return ret;
277 282
278 cik_ih_set_interrupt_funcs(adev); 283 cik_ih_set_interrupt_funcs(adev);
279 284
@@ -300,6 +305,7 @@ static int cik_ih_sw_fini(void *handle)
300 305
301 amdgpu_irq_fini(adev); 306 amdgpu_irq_fini(adev);
302 amdgpu_ih_ring_fini(adev); 307 amdgpu_ih_ring_fini(adev);
308 amdgpu_irq_remove_domain(adev);
303 309
304 return 0; 310 return 0;
305} 311}
diff --git a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c
index 8035d4d6a4f5..4dd17f2dd905 100644
--- a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c
@@ -1078,6 +1078,37 @@ static uint32_t cz_get_eclk_level(struct amdgpu_device *adev,
1078 return i; 1078 return i;
1079} 1079}
1080 1080
1081static uint32_t cz_get_uvd_level(struct amdgpu_device *adev,
1082 uint32_t clock, uint16_t msg)
1083{
1084 int i = 0;
1085 struct amdgpu_uvd_clock_voltage_dependency_table *table =
1086 &adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table;
1087
1088 switch (msg) {
1089 case PPSMC_MSG_SetUvdSoftMin:
1090 case PPSMC_MSG_SetUvdHardMin:
1091 for (i = 0; i < table->count; i++)
1092 if (clock <= table->entries[i].vclk)
1093 break;
1094 if (i == table->count)
1095 i = table->count - 1;
1096 break;
1097 case PPSMC_MSG_SetUvdSoftMax:
1098 case PPSMC_MSG_SetUvdHardMax:
1099 for (i = table->count - 1; i >= 0; i--)
1100 if (clock >= table->entries[i].vclk)
1101 break;
1102 if (i < 0)
1103 i = 0;
1104 break;
1105 default:
1106 break;
1107 }
1108
1109 return i;
1110}
1111
1081static int cz_program_bootup_state(struct amdgpu_device *adev) 1112static int cz_program_bootup_state(struct amdgpu_device *adev)
1082{ 1113{
1083 struct cz_power_info *pi = cz_get_pi(adev); 1114 struct cz_power_info *pi = cz_get_pi(adev);
@@ -1739,6 +1770,200 @@ static int cz_dpm_unforce_dpm_levels(struct amdgpu_device *adev)
1739 return 0; 1770 return 0;
1740} 1771}
1741 1772
1773static int cz_dpm_uvd_force_highest(struct amdgpu_device *adev)
1774{
1775 struct cz_power_info *pi = cz_get_pi(adev);
1776 int ret = 0;
1777
1778 if (pi->uvd_dpm.soft_min_clk != pi->uvd_dpm.soft_max_clk) {
1779 pi->uvd_dpm.soft_min_clk =
1780 pi->uvd_dpm.soft_max_clk;
1781 ret = cz_send_msg_to_smc_with_parameter(adev,
1782 PPSMC_MSG_SetUvdSoftMin,
1783 cz_get_uvd_level(adev,
1784 pi->uvd_dpm.soft_min_clk,
1785 PPSMC_MSG_SetUvdSoftMin));
1786 if (ret)
1787 return ret;
1788 }
1789
1790 return ret;
1791}
1792
1793static int cz_dpm_uvd_force_lowest(struct amdgpu_device *adev)
1794{
1795 struct cz_power_info *pi = cz_get_pi(adev);
1796 int ret = 0;
1797
1798 if (pi->uvd_dpm.soft_max_clk != pi->uvd_dpm.soft_min_clk) {
1799 pi->uvd_dpm.soft_max_clk = pi->uvd_dpm.soft_min_clk;
1800 ret = cz_send_msg_to_smc_with_parameter(adev,
1801 PPSMC_MSG_SetUvdSoftMax,
1802 cz_get_uvd_level(adev,
1803 pi->uvd_dpm.soft_max_clk,
1804 PPSMC_MSG_SetUvdSoftMax));
1805 if (ret)
1806 return ret;
1807 }
1808
1809 return ret;
1810}
1811
1812static uint32_t cz_dpm_get_max_uvd_level(struct amdgpu_device *adev)
1813{
1814 struct cz_power_info *pi = cz_get_pi(adev);
1815
1816 if (!pi->max_uvd_level) {
1817 cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxUvdLevel);
1818 pi->max_uvd_level = cz_get_argument(adev) + 1;
1819 }
1820
1821 if (pi->max_uvd_level > CZ_MAX_HARDWARE_POWERLEVELS) {
1822 DRM_ERROR("Invalid max uvd level!\n");
1823 return -EINVAL;
1824 }
1825
1826 return pi->max_uvd_level;
1827}
1828
1829static int cz_dpm_unforce_uvd_dpm_levels(struct amdgpu_device *adev)
1830{
1831 struct cz_power_info *pi = cz_get_pi(adev);
1832 struct amdgpu_uvd_clock_voltage_dependency_table *dep_table =
1833 &adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table;
1834 uint32_t level = 0;
1835 int ret = 0;
1836
1837 pi->uvd_dpm.soft_min_clk = dep_table->entries[0].vclk;
1838 level = cz_dpm_get_max_uvd_level(adev) - 1;
1839 if (level < dep_table->count)
1840 pi->uvd_dpm.soft_max_clk = dep_table->entries[level].vclk;
1841 else
1842 pi->uvd_dpm.soft_max_clk =
1843 dep_table->entries[dep_table->count - 1].vclk;
1844
1845 /* get min/max sclk soft value
1846 * notify SMU to execute */
1847 ret = cz_send_msg_to_smc_with_parameter(adev,
1848 PPSMC_MSG_SetUvdSoftMin,
1849 cz_get_uvd_level(adev,
1850 pi->uvd_dpm.soft_min_clk,
1851 PPSMC_MSG_SetUvdSoftMin));
1852 if (ret)
1853 return ret;
1854
1855 ret = cz_send_msg_to_smc_with_parameter(adev,
1856 PPSMC_MSG_SetUvdSoftMax,
1857 cz_get_uvd_level(adev,
1858 pi->uvd_dpm.soft_max_clk,
1859 PPSMC_MSG_SetUvdSoftMax));
1860 if (ret)
1861 return ret;
1862
1863 DRM_DEBUG("DPM uvd unforce state min=%d, max=%d.\n",
1864 pi->uvd_dpm.soft_min_clk,
1865 pi->uvd_dpm.soft_max_clk);
1866
1867 return 0;
1868}
1869
1870static int cz_dpm_vce_force_highest(struct amdgpu_device *adev)
1871{
1872 struct cz_power_info *pi = cz_get_pi(adev);
1873 int ret = 0;
1874
1875 if (pi->vce_dpm.soft_min_clk != pi->vce_dpm.soft_max_clk) {
1876 pi->vce_dpm.soft_min_clk =
1877 pi->vce_dpm.soft_max_clk;
1878 ret = cz_send_msg_to_smc_with_parameter(adev,
1879 PPSMC_MSG_SetEclkSoftMin,
1880 cz_get_eclk_level(adev,
1881 pi->vce_dpm.soft_min_clk,
1882 PPSMC_MSG_SetEclkSoftMin));
1883 if (ret)
1884 return ret;
1885 }
1886
1887 return ret;
1888}
1889
1890static int cz_dpm_vce_force_lowest(struct amdgpu_device *adev)
1891{
1892 struct cz_power_info *pi = cz_get_pi(adev);
1893 int ret = 0;
1894
1895 if (pi->vce_dpm.soft_max_clk != pi->vce_dpm.soft_min_clk) {
1896 pi->vce_dpm.soft_max_clk = pi->vce_dpm.soft_min_clk;
1897 ret = cz_send_msg_to_smc_with_parameter(adev,
1898 PPSMC_MSG_SetEclkSoftMax,
1899 cz_get_uvd_level(adev,
1900 pi->vce_dpm.soft_max_clk,
1901 PPSMC_MSG_SetEclkSoftMax));
1902 if (ret)
1903 return ret;
1904 }
1905
1906 return ret;
1907}
1908
1909static uint32_t cz_dpm_get_max_vce_level(struct amdgpu_device *adev)
1910{
1911 struct cz_power_info *pi = cz_get_pi(adev);
1912
1913 if (!pi->max_vce_level) {
1914 cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxEclkLevel);
1915 pi->max_vce_level = cz_get_argument(adev) + 1;
1916 }
1917
1918 if (pi->max_vce_level > CZ_MAX_HARDWARE_POWERLEVELS) {
1919 DRM_ERROR("Invalid max vce level!\n");
1920 return -EINVAL;
1921 }
1922
1923 return pi->max_vce_level;
1924}
1925
1926static int cz_dpm_unforce_vce_dpm_levels(struct amdgpu_device *adev)
1927{
1928 struct cz_power_info *pi = cz_get_pi(adev);
1929 struct amdgpu_vce_clock_voltage_dependency_table *dep_table =
1930 &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table;
1931 uint32_t level = 0;
1932 int ret = 0;
1933
1934 pi->vce_dpm.soft_min_clk = dep_table->entries[0].ecclk;
1935 level = cz_dpm_get_max_vce_level(adev) - 1;
1936 if (level < dep_table->count)
1937 pi->vce_dpm.soft_max_clk = dep_table->entries[level].ecclk;
1938 else
1939 pi->vce_dpm.soft_max_clk =
1940 dep_table->entries[dep_table->count - 1].ecclk;
1941
1942 /* get min/max sclk soft value
1943 * notify SMU to execute */
1944 ret = cz_send_msg_to_smc_with_parameter(adev,
1945 PPSMC_MSG_SetEclkSoftMin,
1946 cz_get_eclk_level(adev,
1947 pi->vce_dpm.soft_min_clk,
1948 PPSMC_MSG_SetEclkSoftMin));
1949 if (ret)
1950 return ret;
1951
1952 ret = cz_send_msg_to_smc_with_parameter(adev,
1953 PPSMC_MSG_SetEclkSoftMax,
1954 cz_get_eclk_level(adev,
1955 pi->vce_dpm.soft_max_clk,
1956 PPSMC_MSG_SetEclkSoftMax));
1957 if (ret)
1958 return ret;
1959
1960 DRM_DEBUG("DPM vce unforce state min=%d, max=%d.\n",
1961 pi->vce_dpm.soft_min_clk,
1962 pi->vce_dpm.soft_max_clk);
1963
1964 return 0;
1965}
1966
1742static int cz_dpm_force_dpm_level(struct amdgpu_device *adev, 1967static int cz_dpm_force_dpm_level(struct amdgpu_device *adev,
1743 enum amdgpu_dpm_forced_level level) 1968 enum amdgpu_dpm_forced_level level)
1744{ 1969{
@@ -1746,25 +1971,70 @@ static int cz_dpm_force_dpm_level(struct amdgpu_device *adev,
1746 1971
1747 switch (level) { 1972 switch (level) {
1748 case AMDGPU_DPM_FORCED_LEVEL_HIGH: 1973 case AMDGPU_DPM_FORCED_LEVEL_HIGH:
1974 /* sclk */
1749 ret = cz_dpm_unforce_dpm_levels(adev); 1975 ret = cz_dpm_unforce_dpm_levels(adev);
1750 if (ret) 1976 if (ret)
1751 return ret; 1977 return ret;
1752 ret = cz_dpm_force_highest(adev); 1978 ret = cz_dpm_force_highest(adev);
1753 if (ret) 1979 if (ret)
1754 return ret; 1980 return ret;
1981
1982 /* uvd */
1983 ret = cz_dpm_unforce_uvd_dpm_levels(adev);
1984 if (ret)
1985 return ret;
1986 ret = cz_dpm_uvd_force_highest(adev);
1987 if (ret)
1988 return ret;
1989
1990 /* vce */
1991 ret = cz_dpm_unforce_vce_dpm_levels(adev);
1992 if (ret)
1993 return ret;
1994 ret = cz_dpm_vce_force_highest(adev);
1995 if (ret)
1996 return ret;
1755 break; 1997 break;
1756 case AMDGPU_DPM_FORCED_LEVEL_LOW: 1998 case AMDGPU_DPM_FORCED_LEVEL_LOW:
1999 /* sclk */
1757 ret = cz_dpm_unforce_dpm_levels(adev); 2000 ret = cz_dpm_unforce_dpm_levels(adev);
1758 if (ret) 2001 if (ret)
1759 return ret; 2002 return ret;
1760 ret = cz_dpm_force_lowest(adev); 2003 ret = cz_dpm_force_lowest(adev);
1761 if (ret) 2004 if (ret)
1762 return ret; 2005 return ret;
2006
2007 /* uvd */
2008 ret = cz_dpm_unforce_uvd_dpm_levels(adev);
2009 if (ret)
2010 return ret;
2011 ret = cz_dpm_uvd_force_lowest(adev);
2012 if (ret)
2013 return ret;
2014
2015 /* vce */
2016 ret = cz_dpm_unforce_vce_dpm_levels(adev);
2017 if (ret)
2018 return ret;
2019 ret = cz_dpm_vce_force_lowest(adev);
2020 if (ret)
2021 return ret;
1763 break; 2022 break;
1764 case AMDGPU_DPM_FORCED_LEVEL_AUTO: 2023 case AMDGPU_DPM_FORCED_LEVEL_AUTO:
2024 /* sclk */
1765 ret = cz_dpm_unforce_dpm_levels(adev); 2025 ret = cz_dpm_unforce_dpm_levels(adev);
1766 if (ret) 2026 if (ret)
1767 return ret; 2027 return ret;
2028
2029 /* uvd */
2030 ret = cz_dpm_unforce_uvd_dpm_levels(adev);
2031 if (ret)
2032 return ret;
2033
2034 /* vce */
2035 ret = cz_dpm_unforce_vce_dpm_levels(adev);
2036 if (ret)
2037 return ret;
1768 break; 2038 break;
1769 default: 2039 default:
1770 break; 2040 break;
@@ -1905,7 +2175,8 @@ static int cz_update_vce_dpm(struct amdgpu_device *adev)
1905 pi->vce_dpm.hard_min_clk = table->entries[table->count-1].ecclk; 2175 pi->vce_dpm.hard_min_clk = table->entries[table->count-1].ecclk;
1906 2176
1907 } else { /* non-stable p-state cases. without vce.Arbiter.EcclkHardMin */ 2177 } else { /* non-stable p-state cases. without vce.Arbiter.EcclkHardMin */
1908 pi->vce_dpm.hard_min_clk = table->entries[0].ecclk; 2178 /* leave it as set by user */
2179 /*pi->vce_dpm.hard_min_clk = table->entries[0].ecclk;*/
1909 } 2180 }
1910 2181
1911 cz_send_msg_to_smc_with_parameter(adev, 2182 cz_send_msg_to_smc_with_parameter(adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/cz_dpm.h b/drivers/gpu/drm/amd/amdgpu/cz_dpm.h
index 99e1afc89629..5df8c1faab51 100644
--- a/drivers/gpu/drm/amd/amdgpu/cz_dpm.h
+++ b/drivers/gpu/drm/amd/amdgpu/cz_dpm.h
@@ -183,6 +183,8 @@ struct cz_power_info {
183 uint32_t voltage_drop_threshold; 183 uint32_t voltage_drop_threshold;
184 uint32_t gfx_pg_threshold; 184 uint32_t gfx_pg_threshold;
185 uint32_t max_sclk_level; 185 uint32_t max_sclk_level;
186 uint32_t max_uvd_level;
187 uint32_t max_vce_level;
186 /* flags */ 188 /* flags */
187 bool didt_enabled; 189 bool didt_enabled;
188 bool video_start; 190 bool video_start;
diff --git a/drivers/gpu/drm/amd/amdgpu/cz_ih.c b/drivers/gpu/drm/amd/amdgpu/cz_ih.c
index bc751bfbcae2..c79638f8e732 100644
--- a/drivers/gpu/drm/amd/amdgpu/cz_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/cz_ih.c
@@ -253,8 +253,14 @@ static void cz_ih_set_rptr(struct amdgpu_device *adev)
253static int cz_ih_early_init(void *handle) 253static int cz_ih_early_init(void *handle)
254{ 254{
255 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 255 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
256 int ret;
257
258 ret = amdgpu_irq_add_domain(adev);
259 if (ret)
260 return ret;
256 261
257 cz_ih_set_interrupt_funcs(adev); 262 cz_ih_set_interrupt_funcs(adev);
263
258 return 0; 264 return 0;
259} 265}
260 266
@@ -278,6 +284,7 @@ static int cz_ih_sw_fini(void *handle)
278 284
279 amdgpu_irq_fini(adev); 285 amdgpu_irq_fini(adev);
280 amdgpu_ih_ring_fini(adev); 286 amdgpu_ih_ring_fini(adev);
287 amdgpu_irq_remove_domain(adev);
281 288
282 return 0; 289 return 0;
283} 290}
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 8701661a8868..8e67249d4367 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -211,9 +211,9 @@ static bool dce_v11_0_is_counter_moving(struct amdgpu_device *adev, int crtc)
211 */ 211 */
212static void dce_v11_0_vblank_wait(struct amdgpu_device *adev, int crtc) 212static void dce_v11_0_vblank_wait(struct amdgpu_device *adev, int crtc)
213{ 213{
214 unsigned i = 0; 214 unsigned i = 100;
215 215
216 if (crtc >= adev->mode_info.num_crtc) 216 if (crtc < 0 || crtc >= adev->mode_info.num_crtc)
217 return; 217 return;
218 218
219 if (!(RREG32(mmCRTC_CONTROL + crtc_offsets[crtc]) & CRTC_CONTROL__CRTC_MASTER_EN_MASK)) 219 if (!(RREG32(mmCRTC_CONTROL + crtc_offsets[crtc]) & CRTC_CONTROL__CRTC_MASTER_EN_MASK))
@@ -223,14 +223,16 @@ static void dce_v11_0_vblank_wait(struct amdgpu_device *adev, int crtc)
223 * wait for another frame. 223 * wait for another frame.
224 */ 224 */
225 while (dce_v11_0_is_in_vblank(adev, crtc)) { 225 while (dce_v11_0_is_in_vblank(adev, crtc)) {
226 if (i++ % 100 == 0) { 226 if (i++ == 100) {
227 i = 0;
227 if (!dce_v11_0_is_counter_moving(adev, crtc)) 228 if (!dce_v11_0_is_counter_moving(adev, crtc))
228 break; 229 break;
229 } 230 }
230 } 231 }
231 232
232 while (!dce_v11_0_is_in_vblank(adev, crtc)) { 233 while (!dce_v11_0_is_in_vblank(adev, crtc)) {
233 if (i++ % 100 == 0) { 234 if (i++ == 100) {
235 i = 0;
234 if (!dce_v11_0_is_counter_moving(adev, crtc)) 236 if (!dce_v11_0_is_counter_moving(adev, crtc))
235 break; 237 break;
236 } 238 }
@@ -239,7 +241,7 @@ static void dce_v11_0_vblank_wait(struct amdgpu_device *adev, int crtc)
239 241
240static u32 dce_v11_0_vblank_get_counter(struct amdgpu_device *adev, int crtc) 242static u32 dce_v11_0_vblank_get_counter(struct amdgpu_device *adev, int crtc)
241{ 243{
242 if (crtc >= adev->mode_info.num_crtc) 244 if (crtc < 0 || crtc >= adev->mode_info.num_crtc)
243 return 0; 245 return 0;
244 else 246 else
245 return RREG32(mmCRTC_STATUS_FRAME_COUNT + crtc_offsets[crtc]); 247 return RREG32(mmCRTC_STATUS_FRAME_COUNT + crtc_offsets[crtc]);
@@ -3384,7 +3386,7 @@ static void dce_v11_0_crtc_vblank_int_ack(struct amdgpu_device *adev,
3384{ 3386{
3385 u32 tmp; 3387 u32 tmp;
3386 3388
3387 if (crtc >= adev->mode_info.num_crtc) { 3389 if (crtc < 0 || crtc >= adev->mode_info.num_crtc) {
3388 DRM_DEBUG("invalid crtc %d\n", crtc); 3390 DRM_DEBUG("invalid crtc %d\n", crtc);
3389 return; 3391 return;
3390 } 3392 }
@@ -3399,7 +3401,7 @@ static void dce_v11_0_crtc_vline_int_ack(struct amdgpu_device *adev,
3399{ 3401{
3400 u32 tmp; 3402 u32 tmp;
3401 3403
3402 if (crtc >= adev->mode_info.num_crtc) { 3404 if (crtc < 0 || crtc >= adev->mode_info.num_crtc) {
3403 DRM_DEBUG("invalid crtc %d\n", crtc); 3405 DRM_DEBUG("invalid crtc %d\n", crtc);
3404 return; 3406 return;
3405 } 3407 }
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
index dababe40a685..3f956065d069 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
@@ -1016,7 +1016,6 @@ static int gmc_v7_0_suspend(void *handle)
1016 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1016 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1017 1017
1018 if (adev->vm_manager.enabled) { 1018 if (adev->vm_manager.enabled) {
1019 amdgpu_vm_manager_fini(adev);
1020 gmc_v7_0_vm_fini(adev); 1019 gmc_v7_0_vm_fini(adev);
1021 adev->vm_manager.enabled = false; 1020 adev->vm_manager.enabled = false;
1022 } 1021 }
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index adc25f87fc18..c0c9a0101eb4 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -1037,7 +1037,6 @@ static int gmc_v8_0_suspend(void *handle)
1037 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1037 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1038 1038
1039 if (adev->vm_manager.enabled) { 1039 if (adev->vm_manager.enabled) {
1040 amdgpu_vm_manager_fini(adev);
1041 gmc_v8_0_vm_fini(adev); 1040 gmc_v8_0_vm_fini(adev);
1042 adev->vm_manager.enabled = false; 1041 adev->vm_manager.enabled = false;
1043 } 1042 }
diff --git a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c
index 779532d350ff..679e7394a495 100644
--- a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c
@@ -253,8 +253,14 @@ static void iceland_ih_set_rptr(struct amdgpu_device *adev)
253static int iceland_ih_early_init(void *handle) 253static int iceland_ih_early_init(void *handle)
254{ 254{
255 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 255 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
256 int ret;
257
258 ret = amdgpu_irq_add_domain(adev);
259 if (ret)
260 return ret;
256 261
257 iceland_ih_set_interrupt_funcs(adev); 262 iceland_ih_set_interrupt_funcs(adev);
263
258 return 0; 264 return 0;
259} 265}
260 266
@@ -278,6 +284,7 @@ static int iceland_ih_sw_fini(void *handle)
278 284
279 amdgpu_irq_fini(adev); 285 amdgpu_irq_fini(adev);
280 amdgpu_ih_ring_fini(adev); 286 amdgpu_ih_ring_fini(adev);
287 amdgpu_irq_remove_domain(adev);
281 288
282 return 0; 289 return 0;
283} 290}
diff --git a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
index 743c372837aa..b6f7d7bff929 100644
--- a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
@@ -273,8 +273,14 @@ static void tonga_ih_set_rptr(struct amdgpu_device *adev)
273static int tonga_ih_early_init(void *handle) 273static int tonga_ih_early_init(void *handle)
274{ 274{
275 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 275 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
276 int ret;
277
278 ret = amdgpu_irq_add_domain(adev);
279 if (ret)
280 return ret;
276 281
277 tonga_ih_set_interrupt_funcs(adev); 282 tonga_ih_set_interrupt_funcs(adev);
283
278 return 0; 284 return 0;
279} 285}
280 286
@@ -301,6 +307,7 @@ static int tonga_ih_sw_fini(void *handle)
301 307
302 amdgpu_irq_fini(adev); 308 amdgpu_irq_fini(adev);
303 amdgpu_ih_ring_fini(adev); 309 amdgpu_ih_ring_fini(adev);
310 amdgpu_irq_add_domain(adev);
304 311
305 return 0; 312 return 0;
306} 313}
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
index 35f48ad7644d..e99af81e4aec 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
@@ -314,14 +314,11 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
314static unsigned vce_v3_0_get_harvest_config(struct amdgpu_device *adev) 314static unsigned vce_v3_0_get_harvest_config(struct amdgpu_device *adev)
315{ 315{
316 u32 tmp; 316 u32 tmp;
317 unsigned ret;
318 317
319 /* Fiji, Stoney are single pipe */ 318 /* Fiji, Stoney are single pipe */
320 if ((adev->asic_type == CHIP_FIJI) || 319 if ((adev->asic_type == CHIP_FIJI) ||
321 (adev->asic_type == CHIP_STONEY)){ 320 (adev->asic_type == CHIP_STONEY))
322 ret = AMDGPU_VCE_HARVEST_VCE1; 321 return AMDGPU_VCE_HARVEST_VCE1;
323 return ret;
324 }
325 322
326 /* Tonga and CZ are dual or single pipe */ 323 /* Tonga and CZ are dual or single pipe */
327 if (adev->flags & AMD_IS_APU) 324 if (adev->flags & AMD_IS_APU)
@@ -335,19 +332,14 @@ static unsigned vce_v3_0_get_harvest_config(struct amdgpu_device *adev)
335 332
336 switch (tmp) { 333 switch (tmp) {
337 case 1: 334 case 1:
338 ret = AMDGPU_VCE_HARVEST_VCE0; 335 return AMDGPU_VCE_HARVEST_VCE0;
339 break;
340 case 2: 336 case 2:
341 ret = AMDGPU_VCE_HARVEST_VCE1; 337 return AMDGPU_VCE_HARVEST_VCE1;
342 break;
343 case 3: 338 case 3:
344 ret = AMDGPU_VCE_HARVEST_VCE0 | AMDGPU_VCE_HARVEST_VCE1; 339 return AMDGPU_VCE_HARVEST_VCE0 | AMDGPU_VCE_HARVEST_VCE1;
345 break;
346 default: 340 default:
347 ret = 0; 341 return 0;
348 } 342 }
349
350 return ret;
351} 343}
352 344
353static int vce_v3_0_early_init(void *handle) 345static int vce_v3_0_early_init(void *handle)
@@ -422,28 +414,22 @@ static int vce_v3_0_sw_fini(void *handle)
422 414
423static int vce_v3_0_hw_init(void *handle) 415static int vce_v3_0_hw_init(void *handle)
424{ 416{
425 struct amdgpu_ring *ring; 417 int r, i;
426 int r;
427 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 418 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
428 419
429 r = vce_v3_0_start(adev); 420 r = vce_v3_0_start(adev);
430 if (r) 421 if (r)
431 return r; 422 return r;
432 423
433 ring = &adev->vce.ring[0]; 424 adev->vce.ring[0].ready = false;
434 ring->ready = true; 425 adev->vce.ring[1].ready = false;
435 r = amdgpu_ring_test_ring(ring);
436 if (r) {
437 ring->ready = false;
438 return r;
439 }
440 426
441 ring = &adev->vce.ring[1]; 427 for (i = 0; i < 2; i++) {
442 ring->ready = true; 428 r = amdgpu_ring_test_ring(&adev->vce.ring[i]);
443 r = amdgpu_ring_test_ring(ring); 429 if (r)
444 if (r) { 430 return r;
445 ring->ready = false; 431 else
446 return r; 432 adev->vce.ring[i].ready = true;
447 } 433 }
448 434
449 DRM_INFO("VCE initialized successfully.\n"); 435 DRM_INFO("VCE initialized successfully.\n");
@@ -543,17 +529,9 @@ static bool vce_v3_0_is_idle(void *handle)
543{ 529{
544 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 530 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
545 u32 mask = 0; 531 u32 mask = 0;
546 int idx;
547 532
548 for (idx = 0; idx < 2; ++idx) { 533 mask |= (adev->vce.harvest_config & AMDGPU_VCE_HARVEST_VCE0) ? 0 : SRBM_STATUS2__VCE0_BUSY_MASK;
549 if (adev->vce.harvest_config & (1 << idx)) 534 mask |= (adev->vce.harvest_config & AMDGPU_VCE_HARVEST_VCE1) ? 0 : SRBM_STATUS2__VCE1_BUSY_MASK;
550 continue;
551
552 if (idx == 0)
553 mask |= SRBM_STATUS2__VCE0_BUSY_MASK;
554 else
555 mask |= SRBM_STATUS2__VCE1_BUSY_MASK;
556 }
557 535
558 return !(RREG32(mmSRBM_STATUS2) & mask); 536 return !(RREG32(mmSRBM_STATUS2) & mask);
559} 537}
@@ -562,23 +540,11 @@ static int vce_v3_0_wait_for_idle(void *handle)
562{ 540{
563 unsigned i; 541 unsigned i;
564 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 542 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
565 u32 mask = 0;
566 int idx;
567
568 for (idx = 0; idx < 2; ++idx) {
569 if (adev->vce.harvest_config & (1 << idx))
570 continue;
571
572 if (idx == 0)
573 mask |= SRBM_STATUS2__VCE0_BUSY_MASK;
574 else
575 mask |= SRBM_STATUS2__VCE1_BUSY_MASK;
576 }
577 543
578 for (i = 0; i < adev->usec_timeout; i++) { 544 for (i = 0; i < adev->usec_timeout; i++)
579 if (!(RREG32(mmSRBM_STATUS2) & mask)) 545 if (vce_v3_0_is_idle(handle))
580 return 0; 546 return 0;
581 } 547
582 return -ETIMEDOUT; 548 return -ETIMEDOUT;
583} 549}
584 550
@@ -586,17 +552,10 @@ static int vce_v3_0_soft_reset(void *handle)
586{ 552{
587 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 553 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
588 u32 mask = 0; 554 u32 mask = 0;
589 int idx;
590 555
591 for (idx = 0; idx < 2; ++idx) { 556 mask |= (adev->vce.harvest_config & AMDGPU_VCE_HARVEST_VCE0) ? 0 : SRBM_SOFT_RESET__SOFT_RESET_VCE0_MASK;
592 if (adev->vce.harvest_config & (1 << idx)) 557 mask |= (adev->vce.harvest_config & AMDGPU_VCE_HARVEST_VCE1) ? 0 : SRBM_SOFT_RESET__SOFT_RESET_VCE1_MASK;
593 continue;
594 558
595 if (idx == 0)
596 mask |= SRBM_SOFT_RESET__SOFT_RESET_VCE0_MASK;
597 else
598 mask |= SRBM_SOFT_RESET__SOFT_RESET_VCE1_MASK;
599 }
600 WREG32_P(mmSRBM_SOFT_RESET, mask, 559 WREG32_P(mmSRBM_SOFT_RESET, mask,
601 ~(SRBM_SOFT_RESET__SOFT_RESET_VCE0_MASK | 560 ~(SRBM_SOFT_RESET__SOFT_RESET_VCE0_MASK |
602 SRBM_SOFT_RESET__SOFT_RESET_VCE1_MASK)); 561 SRBM_SOFT_RESET__SOFT_RESET_VCE1_MASK));
@@ -698,10 +657,8 @@ static int vce_v3_0_process_interrupt(struct amdgpu_device *adev,
698 657
699 switch (entry->src_data) { 658 switch (entry->src_data) {
700 case 0: 659 case 0:
701 amdgpu_fence_process(&adev->vce.ring[0]);
702 break;
703 case 1: 660 case 1:
704 amdgpu_fence_process(&adev->vce.ring[1]); 661 amdgpu_fence_process(&adev->vce.ring[entry->src_data]);
705 break; 662 break;
706 default: 663 default:
707 DRM_ERROR("Unhandled interrupt: %d %d\n", 664 DRM_ERROR("Unhandled interrupt: %d %d\n",
diff --git a/drivers/gpu/drm/amd/include/cgs_common.h b/drivers/gpu/drm/amd/include/cgs_common.h
index 03affb348f69..713aec954692 100644
--- a/drivers/gpu/drm/amd/include/cgs_common.h
+++ b/drivers/gpu/drm/amd/include/cgs_common.h
@@ -122,6 +122,17 @@ struct cgs_system_info {
122 uint64_t padding[13]; 122 uint64_t padding[13];
123}; 123};
124 124
125/*
126 * enum cgs_resource_type - GPU resource type
127 */
128enum cgs_resource_type {
129 CGS_RESOURCE_TYPE_MMIO = 0,
130 CGS_RESOURCE_TYPE_FB,
131 CGS_RESOURCE_TYPE_IO,
132 CGS_RESOURCE_TYPE_DOORBELL,
133 CGS_RESOURCE_TYPE_ROM,
134};
135
125/** 136/**
126 * struct cgs_clock_limits - Clock limits 137 * struct cgs_clock_limits - Clock limits
127 * 138 *
@@ -417,6 +428,23 @@ typedef void (*cgs_write_pci_config_word_t)(void *cgs_device, unsigned addr,
417typedef void (*cgs_write_pci_config_dword_t)(void *cgs_device, unsigned addr, 428typedef void (*cgs_write_pci_config_dword_t)(void *cgs_device, unsigned addr,
418 uint32_t value); 429 uint32_t value);
419 430
431
432/**
433 * cgs_get_pci_resource() - provide access to a device resource (PCI BAR)
434 * @cgs_device: opaque device handle
435 * @resource_type: Type of Resource (MMIO, IO, ROM, FB, DOORBELL)
436 * @size: size of the region
437 * @offset: offset from the start of the region
438 * @resource_base: base address (not including offset) returned
439 *
440 * Return: 0 on success, -errno otherwise
441 */
442typedef int (*cgs_get_pci_resource_t)(void *cgs_device,
443 enum cgs_resource_type resource_type,
444 uint64_t size,
445 uint64_t offset,
446 uint64_t *resource_base);
447
420/** 448/**
421 * cgs_atom_get_data_table() - Get a pointer to an ATOM BIOS data table 449 * cgs_atom_get_data_table() - Get a pointer to an ATOM BIOS data table
422 * @cgs_device: opaque device handle 450 * @cgs_device: opaque device handle
@@ -593,6 +621,8 @@ struct cgs_ops {
593 cgs_write_pci_config_byte_t write_pci_config_byte; 621 cgs_write_pci_config_byte_t write_pci_config_byte;
594 cgs_write_pci_config_word_t write_pci_config_word; 622 cgs_write_pci_config_word_t write_pci_config_word;
595 cgs_write_pci_config_dword_t write_pci_config_dword; 623 cgs_write_pci_config_dword_t write_pci_config_dword;
624 /* PCI resources */
625 cgs_get_pci_resource_t get_pci_resource;
596 /* ATOM BIOS */ 626 /* ATOM BIOS */
597 cgs_atom_get_data_table_t atom_get_data_table; 627 cgs_atom_get_data_table_t atom_get_data_table;
598 cgs_atom_get_cmd_table_revs_t atom_get_cmd_table_revs; 628 cgs_atom_get_cmd_table_revs_t atom_get_cmd_table_revs;
@@ -708,5 +738,9 @@ struct cgs_device
708 CGS_CALL(call_acpi_method, dev, acpi_method, acpi_function, pintput, poutput, output_count, input_size, output_size) 738 CGS_CALL(call_acpi_method, dev, acpi_method, acpi_function, pintput, poutput, output_count, input_size, output_size)
709#define cgs_query_system_info(dev, sys_info) \ 739#define cgs_query_system_info(dev, sys_info) \
710 CGS_CALL(query_system_info, dev, sys_info) 740 CGS_CALL(query_system_info, dev, sys_info)
741#define cgs_get_pci_resource(cgs_device, resource_type, size, offset, \
742 resource_base) \
743 CGS_CALL(get_pci_resource, cgs_device, resource_type, size, offset, \
744 resource_base)
711 745
712#endif /* _CGS_COMMON_H */ 746#endif /* _CGS_COMMON_H */
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index db0370bd60e3..8f5d5edcf193 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -30,6 +30,12 @@
30#include "power_state.h" 30#include "power_state.h"
31#include "eventmanager.h" 31#include "eventmanager.h"
32 32
33#define PP_CHECK(handle) \
34 do { \
35 if ((handle) == NULL || (handle)->pp_valid != PP_VALID) \
36 return -EINVAL; \
37 } while (0)
38
33static int pp_early_init(void *handle) 39static int pp_early_init(void *handle)
34{ 40{
35 return 0; 41 return 0;
@@ -197,13 +203,29 @@ static int pp_resume(void *handle)
197 struct pp_instance *pp_handle; 203 struct pp_instance *pp_handle;
198 struct pp_eventmgr *eventmgr; 204 struct pp_eventmgr *eventmgr;
199 struct pem_event_data event_data = { {0} }; 205 struct pem_event_data event_data = { {0} };
206 struct pp_smumgr *smumgr;
207 int ret;
200 208
201 if (handle == NULL) 209 if (handle == NULL)
202 return -EINVAL; 210 return -EINVAL;
203 211
204 pp_handle = (struct pp_instance *)handle; 212 pp_handle = (struct pp_instance *)handle;
213 smumgr = pp_handle->smu_mgr;
214
215 if (smumgr == NULL || smumgr->smumgr_funcs == NULL ||
216 smumgr->smumgr_funcs->start_smu == NULL)
217 return -EINVAL;
218
219 ret = smumgr->smumgr_funcs->start_smu(smumgr);
220 if (ret) {
221 printk(KERN_ERR "[ powerplay ] smc start failed\n");
222 smumgr->smumgr_funcs->smu_fini(smumgr);
223 return ret;
224 }
225
205 eventmgr = pp_handle->eventmgr; 226 eventmgr = pp_handle->eventmgr;
206 pem_handle_event(eventmgr, AMD_PP_EVENT_RESUME, &event_data); 227 pem_handle_event(eventmgr, AMD_PP_EVENT_RESUME, &event_data);
228
207 return 0; 229 return 0;
208} 230}
209 231
@@ -537,6 +559,8 @@ static int amd_pp_instance_init(struct amd_pp_init *pp_init,
537 if (handle == NULL) 559 if (handle == NULL)
538 return -ENOMEM; 560 return -ENOMEM;
539 561
562 handle->pp_valid = PP_VALID;
563
540 ret = smum_init(pp_init, handle); 564 ret = smum_init(pp_init, handle);
541 if (ret) 565 if (ret)
542 goto fail_smum; 566 goto fail_smum;
@@ -611,12 +635,12 @@ int amd_powerplay_display_configuration_change(void *handle, const void *input)
611 struct pp_hwmgr *hwmgr; 635 struct pp_hwmgr *hwmgr;
612 const struct amd_pp_display_configuration *display_config = input; 636 const struct amd_pp_display_configuration *display_config = input;
613 637
614 if (handle == NULL) 638 PP_CHECK((struct pp_instance *)handle);
615 return -EINVAL;
616 639
617 hwmgr = ((struct pp_instance *)handle)->hwmgr; 640 hwmgr = ((struct pp_instance *)handle)->hwmgr;
618 641
619 phm_store_dal_configuration_data(hwmgr, display_config); 642 phm_store_dal_configuration_data(hwmgr, display_config);
643
620 return 0; 644 return 0;
621} 645}
622 646
@@ -625,7 +649,9 @@ int amd_powerplay_get_display_power_level(void *handle,
625{ 649{
626 struct pp_hwmgr *hwmgr; 650 struct pp_hwmgr *hwmgr;
627 651
628 if (handle == NULL || output == NULL) 652 PP_CHECK((struct pp_instance *)handle);
653
654 if (output == NULL)
629 return -EINVAL; 655 return -EINVAL;
630 656
631 hwmgr = ((struct pp_instance *)handle)->hwmgr; 657 hwmgr = ((struct pp_instance *)handle)->hwmgr;
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c b/drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c
index 9458394aec05..83be3cf210e0 100644
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c
+++ b/drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c
@@ -143,6 +143,7 @@ static const pem_event_action *resume_event[] = {
143 enable_dynamic_state_management_tasks, 143 enable_dynamic_state_management_tasks,
144 enable_clock_power_gatings_tasks, 144 enable_clock_power_gatings_tasks,
145 enable_disable_bapm_tasks, 145 enable_disable_bapm_tasks,
146 initialize_thermal_controller_tasks,
146 reset_boot_state_tasks, 147 reset_boot_state_tasks,
147 adjust_power_state_tasks, 148 adjust_power_state_tasks,
148 enable_disable_fps_tasks, 149 enable_disable_fps_tasks,
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.c b/drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.c
index f0700d077925..5cd123472db4 100644
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.c
+++ b/drivers/gpu/drm/amd/powerplay/eventmgr/eventtasks.c
@@ -68,13 +68,14 @@ int pem_task_adjust_power_state(struct pp_eventmgr *eventmgr, struct pem_event_d
68 68
69int pem_task_power_down_asic(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data) 69int pem_task_power_down_asic(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
70{ 70{
71 /* TODO */ 71 return phm_power_down_asic(eventmgr->hwmgr);
72 return 0;
73} 72}
74 73
75int pem_task_set_boot_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data) 74int pem_task_set_boot_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
76{ 75{
77 /* TODO */ 76 if (pem_is_event_data_valid(event_data->valid_fields, PEM_EventDataValid_RequestedStateID))
77 return psm_set_states(eventmgr, &(event_data->requested_state_id));
78
78 return 0; 79 return 0;
79} 80}
80 81
@@ -343,7 +344,7 @@ int pem_task_disable_gfx_clock_gating(struct pp_eventmgr *eventmgr, struct pem_e
343int pem_task_set_performance_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data) 344int pem_task_set_performance_state(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data)
344{ 345{
345 if (pem_is_event_data_valid(event_data->valid_fields, PEM_EventDataValid_RequestedStateID)) 346 if (pem_is_event_data_valid(event_data->valid_fields, PEM_EventDataValid_RequestedStateID))
346 return psm_set_performance_states(eventmgr, &(event_data->requested_state_id)); 347 return psm_set_states(eventmgr, &(event_data->requested_state_id));
347 348
348 return 0; 349 return 0;
349} 350}
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c b/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c
index 5740fbfcbeab..a46225c0fc01 100644
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c
+++ b/drivers/gpu/drm/amd/powerplay/eventmgr/psm.c
@@ -62,7 +62,7 @@ int psm_get_state_by_classification(struct pp_eventmgr *eventmgr, enum PP_StateC
62 return -1; 62 return -1;
63} 63}
64 64
65int psm_set_performance_states(struct pp_eventmgr *eventmgr, unsigned long *state_id) 65int psm_set_states(struct pp_eventmgr *eventmgr, unsigned long *state_id)
66{ 66{
67 struct pp_power_state *state; 67 struct pp_power_state *state;
68 int table_entries; 68 int table_entries;
@@ -82,7 +82,6 @@ int psm_set_performance_states(struct pp_eventmgr *eventmgr, unsigned long *stat
82 return -1; 82 return -1;
83} 83}
84 84
85
86int psm_adjust_power_state_dynamic(struct pp_eventmgr *eventmgr, bool skip) 85int psm_adjust_power_state_dynamic(struct pp_eventmgr *eventmgr, bool skip)
87{ 86{
88 87
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/psm.h b/drivers/gpu/drm/amd/powerplay/eventmgr/psm.h
index 1380470fdb1c..fbdff3e02aa3 100644
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/psm.h
+++ b/drivers/gpu/drm/amd/powerplay/eventmgr/psm.h
@@ -31,7 +31,7 @@ int psm_get_ui_state(struct pp_eventmgr *eventmgr, enum PP_StateUILabel ui_label
31 31
32int psm_get_state_by_classification(struct pp_eventmgr *eventmgr, enum PP_StateClassificationFlag flag, unsigned long *state_id); 32int psm_get_state_by_classification(struct pp_eventmgr *eventmgr, enum PP_StateClassificationFlag flag, unsigned long *state_id);
33 33
34int psm_set_performance_states(struct pp_eventmgr *eventmgr, unsigned long *state_id); 34int psm_set_states(struct pp_eventmgr *eventmgr, unsigned long *state_id);
35 35
36int psm_adjust_power_state_dynamic(struct pp_eventmgr *eventmgr, bool skip); 36int psm_adjust_power_state_dynamic(struct pp_eventmgr *eventmgr, bool skip);
37 37
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
index 5bac36baa13c..0874ab42ee95 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
@@ -579,7 +579,7 @@ static int cz_tf_init_sclk_limit(struct pp_hwmgr *hwmgr, void *input,
579 hwmgr->dyn_state.vddc_dependency_on_sclk; 579 hwmgr->dyn_state.vddc_dependency_on_sclk;
580 unsigned long clock = 0, level; 580 unsigned long clock = 0, level;
581 581
582 if (NULL == table && table->count <= 0) 582 if (NULL == table || table->count <= 0)
583 return -EINVAL; 583 return -EINVAL;
584 584
585 cz_hwmgr->sclk_dpm.soft_min_clk = table->entries[0].clk; 585 cz_hwmgr->sclk_dpm.soft_min_clk = table->entries[0].clk;
@@ -606,7 +606,7 @@ static int cz_tf_init_uvd_limit(struct pp_hwmgr *hwmgr, void *input,
606 hwmgr->dyn_state.uvd_clock_voltage_dependency_table; 606 hwmgr->dyn_state.uvd_clock_voltage_dependency_table;
607 unsigned long clock = 0, level; 607 unsigned long clock = 0, level;
608 608
609 if (NULL == table && table->count <= 0) 609 if (NULL == table || table->count <= 0)
610 return -EINVAL; 610 return -EINVAL;
611 611
612 cz_hwmgr->uvd_dpm.soft_min_clk = 0; 612 cz_hwmgr->uvd_dpm.soft_min_clk = 0;
@@ -634,7 +634,7 @@ static int cz_tf_init_vce_limit(struct pp_hwmgr *hwmgr, void *input,
634 hwmgr->dyn_state.vce_clock_voltage_dependency_table; 634 hwmgr->dyn_state.vce_clock_voltage_dependency_table;
635 unsigned long clock = 0, level; 635 unsigned long clock = 0, level;
636 636
637 if (NULL == table && table->count <= 0) 637 if (NULL == table || table->count <= 0)
638 return -EINVAL; 638 return -EINVAL;
639 639
640 cz_hwmgr->vce_dpm.soft_min_clk = 0; 640 cz_hwmgr->vce_dpm.soft_min_clk = 0;
@@ -662,7 +662,7 @@ static int cz_tf_init_acp_limit(struct pp_hwmgr *hwmgr, void *input,
662 hwmgr->dyn_state.acp_clock_voltage_dependency_table; 662 hwmgr->dyn_state.acp_clock_voltage_dependency_table;
663 unsigned long clock = 0, level; 663 unsigned long clock = 0, level;
664 664
665 if (NULL == table && table->count <= 0) 665 if (NULL == table || table->count <= 0)
666 return -EINVAL; 666 return -EINVAL;
667 667
668 cz_hwmgr->acp_dpm.soft_min_clk = 0; 668 cz_hwmgr->acp_dpm.soft_min_clk = 0;
@@ -925,6 +925,54 @@ static struct phm_master_table_header cz_setup_asic_master = {
925 cz_setup_asic_list 925 cz_setup_asic_list
926}; 926};
927 927
928static int cz_tf_power_up_display_clock_sys_pll(struct pp_hwmgr *hwmgr,
929 void *input, void *output,
930 void *storage, int result)
931{
932 struct cz_hwmgr *hw_data = (struct cz_hwmgr *)(hwmgr->backend);
933 hw_data->disp_clk_bypass_pending = false;
934 hw_data->disp_clk_bypass = false;
935
936 return 0;
937}
938
939static int cz_tf_clear_nb_dpm_flag(struct pp_hwmgr *hwmgr,
940 void *input, void *output,
941 void *storage, int result)
942{
943 struct cz_hwmgr *hw_data = (struct cz_hwmgr *)(hwmgr->backend);
944 hw_data->is_nb_dpm_enabled = false;
945
946 return 0;
947}
948
949static int cz_tf_reset_cc6_data(struct pp_hwmgr *hwmgr,
950 void *input, void *output,
951 void *storage, int result)
952{
953 struct cz_hwmgr *hw_data = (struct cz_hwmgr *)(hwmgr->backend);
954
955 hw_data->cc6_settings.cc6_setting_changed = false;
956 hw_data->cc6_settings.cpu_pstate_separation_time = 0;
957 hw_data->cc6_settings.cpu_cc6_disable = false;
958 hw_data->cc6_settings.cpu_pstate_disable = false;
959
960 return 0;
961}
962
963static struct phm_master_table_item cz_power_down_asic_list[] = {
964 {NULL, cz_tf_power_up_display_clock_sys_pll},
965 {NULL, cz_tf_clear_nb_dpm_flag},
966 {NULL, cz_tf_reset_cc6_data},
967 {NULL, NULL}
968};
969
970static struct phm_master_table_header cz_power_down_asic_master = {
971 0,
972 PHM_MasterTableFlag_None,
973 cz_power_down_asic_list
974};
975
928static int cz_tf_program_voting_clients(struct pp_hwmgr *hwmgr, void *input, 976static int cz_tf_program_voting_clients(struct pp_hwmgr *hwmgr, void *input,
929 void *output, void *storage, int result) 977 void *output, void *storage, int result)
930{ 978{
@@ -1126,6 +1174,13 @@ static int cz_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
1126 return result; 1174 return result;
1127 } 1175 }
1128 1176
1177 result = phm_construct_table(hwmgr, &cz_power_down_asic_master,
1178 &(hwmgr->power_down_asic));
1179 if (result != 0) {
1180 printk(KERN_ERR "[ powerplay ] Fail to construct power down ASIC\n");
1181 return result;
1182 }
1183
1129 result = phm_construct_table(hwmgr, &cz_disable_dpm_master, 1184 result = phm_construct_table(hwmgr, &cz_disable_dpm_master,
1130 &(hwmgr->disable_dynamic_state_management)); 1185 &(hwmgr->disable_dynamic_state_management));
1131 if (result != 0) { 1186 if (result != 0) {
@@ -1183,7 +1238,7 @@ int cz_phm_unforce_dpm_levels(struct pp_hwmgr *hwmgr)
1183 hwmgr->dyn_state.vddc_dependency_on_sclk; 1238 hwmgr->dyn_state.vddc_dependency_on_sclk;
1184 unsigned long clock = 0, level; 1239 unsigned long clock = 0, level;
1185 1240
1186 if (NULL == table && table->count <= 0) 1241 if (NULL == table || table->count <= 0)
1187 return -EINVAL; 1242 return -EINVAL;
1188 1243
1189 cz_hwmgr->sclk_dpm.soft_min_clk = table->entries[0].clk; 1244 cz_hwmgr->sclk_dpm.soft_min_clk = table->entries[0].clk;
@@ -1494,7 +1549,7 @@ cz_print_current_perforce_level(struct pp_hwmgr *hwmgr, struct seq_file *m)
1494 uint32_t vce_index = PHM_GET_FIELD(cgs_read_ind_register(hwmgr->device, CGS_IND_REG__SMC, ixTARGET_AND_CURRENT_PROFILE_INDEX_2), 1549 uint32_t vce_index = PHM_GET_FIELD(cgs_read_ind_register(hwmgr->device, CGS_IND_REG__SMC, ixTARGET_AND_CURRENT_PROFILE_INDEX_2),
1495 TARGET_AND_CURRENT_PROFILE_INDEX_2, CURR_VCE_INDEX); 1550 TARGET_AND_CURRENT_PROFILE_INDEX_2, CURR_VCE_INDEX);
1496 1551
1497 uint32_t sclk, vclk, dclk, ecclk, tmp, active_percent; 1552 uint32_t sclk, vclk, dclk, ecclk, tmp, activity_percent;
1498 uint16_t vddnb, vddgfx; 1553 uint16_t vddnb, vddgfx;
1499 int result; 1554 int result;
1500 1555
@@ -1536,13 +1591,13 @@ cz_print_current_perforce_level(struct pp_hwmgr *hwmgr, struct seq_file *m)
1536 1591
1537 result = smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_GetAverageGraphicsActivity); 1592 result = smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_GetAverageGraphicsActivity);
1538 if (0 == result) { 1593 if (0 == result) {
1539 active_percent = cgs_read_register(hwmgr->device, mmSMU_MP1_SRBM2P_ARG_0); 1594 activity_percent = cgs_read_register(hwmgr->device, mmSMU_MP1_SRBM2P_ARG_0);
1540 active_percent = active_percent > 100 ? 100 : active_percent; 1595 activity_percent = activity_percent > 100 ? 100 : activity_percent;
1541 } else { 1596 } else {
1542 active_percent = 50; 1597 activity_percent = 50;
1543 } 1598 }
1544 1599
1545 seq_printf(m, "\n [GPU load]: %u %%\n\n", active_percent); 1600 seq_printf(m, "\n [GPU load]: %u %%\n\n", activity_percent);
1546} 1601}
1547 1602
1548static void cz_hw_print_display_cfg( 1603static void cz_hw_print_display_cfg(
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c
index 94f404c121b7..28031a7eddba 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c
@@ -914,7 +914,7 @@ static int fiji_trim_voltage_table(struct pp_hwmgr *hwmgr,
914 GFP_KERNEL); 914 GFP_KERNEL);
915 915
916 if (NULL == table) 916 if (NULL == table)
917 return -EINVAL; 917 return -ENOMEM;
918 918
919 table->mask_low = vol_table->mask_low; 919 table->mask_low = vol_table->mask_low;
920 table->phase_delay = vol_table->phase_delay; 920 table->phase_delay = vol_table->phase_delay;
@@ -941,8 +941,9 @@ static int fiji_trim_voltage_table(struct pp_hwmgr *hwmgr,
941 memcpy(vol_table, table, sizeof(struct pp_atomctrl_voltage_table)); 941 memcpy(vol_table, table, sizeof(struct pp_atomctrl_voltage_table));
942 kfree(table); 942 kfree(table);
943 943
944 return 0; 944 return 0;
945} 945}
946
946static int fiji_get_svi2_mvdd_voltage_table(struct pp_hwmgr *hwmgr, 947static int fiji_get_svi2_mvdd_voltage_table(struct pp_hwmgr *hwmgr,
947 phm_ppt_v1_clock_voltage_dependency_table *dep_table) 948 phm_ppt_v1_clock_voltage_dependency_table *dep_table)
948{ 949{
@@ -1112,7 +1113,7 @@ static int fiji_construct_voltage_tables(struct pp_hwmgr *hwmgr)
1112 fiji_trim_voltage_table_to_fit_state_table(hwmgr, 1113 fiji_trim_voltage_table_to_fit_state_table(hwmgr,
1113 SMU73_MAX_LEVELS_MVDD, &(data->mvdd_voltage_table))); 1114 SMU73_MAX_LEVELS_MVDD, &(data->mvdd_voltage_table)));
1114 1115
1115 return 0; 1116 return 0;
1116} 1117}
1117 1118
1118static int fiji_initialize_mc_reg_table(struct pp_hwmgr *hwmgr) 1119static int fiji_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
@@ -1158,7 +1159,7 @@ static int fiji_program_static_screen_threshold_parameters(
1158 CG_STATIC_SCREEN_PARAMETER, STATIC_SCREEN_THRESHOLD, 1159 CG_STATIC_SCREEN_PARAMETER, STATIC_SCREEN_THRESHOLD,
1159 data->static_screen_threshold); 1160 data->static_screen_threshold);
1160 1161
1161 return 0; 1162 return 0;
1162} 1163}
1163 1164
1164/** 1165/**
@@ -1295,7 +1296,7 @@ static int fiji_process_firmware_header(struct pp_hwmgr *hwmgr)
1295 1296
1296 error |= (0 != result); 1297 error |= (0 != result);
1297 1298
1298 return error ? -1 : 0; 1299 return error ? -1 : 0;
1299} 1300}
1300 1301
1301/* Copy one arb setting to another and then switch the active set. 1302/* Copy one arb setting to another and then switch the active set.
@@ -1339,12 +1340,12 @@ static int fiji_copy_and_switch_arb_sets(struct pp_hwmgr *hwmgr,
1339 return -EINVAL; 1340 return -EINVAL;
1340 } 1341 }
1341 1342
1342 mc_cg_config = cgs_read_register(hwmgr->device, mmMC_CG_CONFIG); 1343 mc_cg_config = cgs_read_register(hwmgr->device, mmMC_CG_CONFIG);
1343 mc_cg_config |= 0x0000000F; 1344 mc_cg_config |= 0x0000000F;
1344 cgs_write_register(hwmgr->device, mmMC_CG_CONFIG, mc_cg_config); 1345 cgs_write_register(hwmgr->device, mmMC_CG_CONFIG, mc_cg_config);
1345 PHM_WRITE_FIELD(hwmgr->device, MC_ARB_CG, CG_ARB_REQ, arb_dest); 1346 PHM_WRITE_FIELD(hwmgr->device, MC_ARB_CG, CG_ARB_REQ, arb_dest);
1346 1347
1347 return 0; 1348 return 0;
1348} 1349}
1349 1350
1350/** 1351/**
@@ -1927,17 +1928,17 @@ static int fiji_populate_single_graphic_level(struct pp_hwmgr *hwmgr,
1927 1928
1928 threshold = clock * data->fast_watermark_threshold / 100; 1929 threshold = clock * data->fast_watermark_threshold / 100;
1929 1930
1930 /* 1931 /*
1931 * TODO: get minimum clocks from dal configaration 1932 * TODO: get minimum clocks from dal configaration
1932 * PECI_GetMinClockSettings(hwmgr->pPECI, &minClocks); 1933 * PECI_GetMinClockSettings(hwmgr->pPECI, &minClocks);
1933 */ 1934 */
1934 /* data->DisplayTiming.minClockInSR = minClocks.engineClockInSR; */ 1935 /* data->DisplayTiming.minClockInSR = minClocks.engineClockInSR; */
1935 1936
1936 /* get level->DeepSleepDivId 1937 /* get level->DeepSleepDivId
1937 if (phm_cap_enabled(hwmgr->platformDescriptor.platformCaps, PHM_PlatformCaps_SclkDeepSleep)) 1938 if (phm_cap_enabled(hwmgr->platformDescriptor.platformCaps, PHM_PlatformCaps_SclkDeepSleep))
1938 { 1939 {
1939 level->DeepSleepDivId = PhwFiji_GetSleepDividerIdFromClock(hwmgr, clock, minClocks.engineClockInSR); 1940 level->DeepSleepDivId = PhwFiji_GetSleepDividerIdFromClock(hwmgr, clock, minClocks.engineClockInSR);
1940 } */ 1941 } */
1941 1942
1942 /* Default to slow, highest DPM level will be 1943 /* Default to slow, highest DPM level will be
1943 * set to PPSMC_DISPLAY_WATERMARK_LOW later. 1944 * set to PPSMC_DISPLAY_WATERMARK_LOW later.
@@ -2756,7 +2757,7 @@ static int fiji_populate_clock_stretcher_data_table(struct pp_hwmgr *hwmgr)
2756 SclkFrequency) / 100); 2757 SclkFrequency) / 100);
2757 if (fiji_clock_stretcher_lookup_table[stretch_amount2][0] < 2758 if (fiji_clock_stretcher_lookup_table[stretch_amount2][0] <
2758 clock_freq_u16 && 2759 clock_freq_u16 &&
2759 fiji_clock_stretcher_lookup_table[stretch_amount2][1] > 2760 fiji_clock_stretcher_lookup_table[stretch_amount2][1] >
2760 clock_freq_u16) { 2761 clock_freq_u16) {
2761 /* Program PWR_CKS_CNTL. CKS_USE_FOR_LOW_FREQ */ 2762 /* Program PWR_CKS_CNTL. CKS_USE_FOR_LOW_FREQ */
2762 value |= (fiji_clock_stretcher_lookup_table[stretch_amount2][3]) << 16; 2763 value |= (fiji_clock_stretcher_lookup_table[stretch_amount2][3]) << 16;
@@ -3172,9 +3173,9 @@ static int fiji_enable_sclk_mclk_dpm(struct pp_hwmgr *hwmgr)
3172 /* enable SCLK dpm */ 3173 /* enable SCLK dpm */
3173 if(!data->sclk_dpm_key_disabled) 3174 if(!data->sclk_dpm_key_disabled)
3174 PP_ASSERT_WITH_CODE( 3175 PP_ASSERT_WITH_CODE(
3175 (0 == smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_DPM_Enable)), 3176 (0 == smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_DPM_Enable)),
3176 "Failed to enable SCLK DPM during DPM Start Function!", 3177 "Failed to enable SCLK DPM during DPM Start Function!",
3177 return -1); 3178 return -1);
3178 3179
3179 /* enable MCLK dpm */ 3180 /* enable MCLK dpm */
3180 if(0 == data->mclk_dpm_key_disabled) { 3181 if(0 == data->mclk_dpm_key_disabled) {
@@ -3320,7 +3321,7 @@ static int fiji_start_dpm(struct pp_hwmgr *hwmgr)
3320 return -1); 3321 return -1);
3321 } 3322 }
3322 3323
3323 return 0; 3324 return 0;
3324} 3325}
3325 3326
3326static void fiji_set_dpm_event_sources(struct pp_hwmgr *hwmgr, 3327static void fiji_set_dpm_event_sources(struct pp_hwmgr *hwmgr,
@@ -3378,7 +3379,7 @@ static int fiji_enable_auto_throttle_source(struct pp_hwmgr *hwmgr,
3378 3379
3379static int fiji_enable_thermal_auto_throttle(struct pp_hwmgr *hwmgr) 3380static int fiji_enable_thermal_auto_throttle(struct pp_hwmgr *hwmgr)
3380{ 3381{
3381 return fiji_enable_auto_throttle_source(hwmgr, PHM_AutoThrottleSource_Thermal); 3382 return fiji_enable_auto_throttle_source(hwmgr, PHM_AutoThrottleSource_Thermal);
3382} 3383}
3383 3384
3384static int fiji_enable_dpm_tasks(struct pp_hwmgr *hwmgr) 3385static int fiji_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
@@ -4865,7 +4866,9 @@ static int fiji_dpm_get_mclk(struct pp_hwmgr *hwmgr, bool low)
4865static void fiji_print_current_perforce_level( 4866static void fiji_print_current_perforce_level(
4866 struct pp_hwmgr *hwmgr, struct seq_file *m) 4867 struct pp_hwmgr *hwmgr, struct seq_file *m)
4867{ 4868{
4868 uint32_t sclk, mclk; 4869 uint32_t sclk, mclk, activity_percent = 0;
4870 uint32_t offset;
4871 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend);
4869 4872
4870 smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_API_GetSclkFrequency); 4873 smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_API_GetSclkFrequency);
4871 4874
@@ -4876,6 +4879,13 @@ static void fiji_print_current_perforce_level(
4876 mclk = cgs_read_register(hwmgr->device, mmSMC_MSG_ARG_0); 4879 mclk = cgs_read_register(hwmgr->device, mmSMC_MSG_ARG_0);
4877 seq_printf(m, "\n [ mclk ]: %u MHz\n\n [ sclk ]: %u MHz\n", 4880 seq_printf(m, "\n [ mclk ]: %u MHz\n\n [ sclk ]: %u MHz\n",
4878 mclk / 100, sclk / 100); 4881 mclk / 100, sclk / 100);
4882
4883 offset = data->soft_regs_start + offsetof(SMU73_SoftRegisters, AverageGraphicsActivity);
4884 activity_percent = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__SMC, offset);
4885 activity_percent += 0x80;
4886 activity_percent >>= 8;
4887
4888 seq_printf(m, "\n [GPU load]: %u%%\n\n", activity_percent > 100 ? 100 : activity_percent);
4879} 4889}
4880 4890
4881static int fiji_program_display_gap(struct pp_hwmgr *hwmgr) 4891static int fiji_program_display_gap(struct pp_hwmgr *hwmgr)
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_powertune.c b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_powertune.c
index f89c98fd759e..6efcb2bac45f 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_powertune.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_powertune.c
@@ -93,9 +93,9 @@ void fiji_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
93 */ 93 */
94static uint16_t scale_fan_gain_settings(uint16_t raw_setting) 94static uint16_t scale_fan_gain_settings(uint16_t raw_setting)
95{ 95{
96 uint32_t tmp; 96 uint32_t tmp;
97 tmp = raw_setting * 4096 / 100; 97 tmp = raw_setting * 4096 / 100;
98 return (uint16_t)tmp; 98 return (uint16_t)tmp;
99} 99}
100 100
101static void get_scl_sda_value(uint8_t line, uint8_t *scl, uint8_t* sda) 101static void get_scl_sda_value(uint8_t line, uint8_t *scl, uint8_t* sda)
@@ -546,8 +546,8 @@ int fiji_power_control_set_level(struct pp_hwmgr *hwmgr)
546 * but message to be 8 bit fraction for messages 546 * but message to be 8 bit fraction for messages
547 */ 547 */
548 target_tdp = ((100 + adjust_percent) * (int)(cac_table->usTDP * 256)) / 100; 548 target_tdp = ((100 + adjust_percent) * (int)(cac_table->usTDP * 256)) / 100;
549 result = fiji_set_overdriver_target_tdp(hwmgr, (uint32_t)target_tdp); 549 result = fiji_set_overdriver_target_tdp(hwmgr, (uint32_t)target_tdp);
550 } 550 }
551 551
552 return result; 552 return result;
553} 553}
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_thermal.c
index def57d0675ed..e76a7de9aa32 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_thermal.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_thermal.c
@@ -20,7 +20,7 @@
20 * OTHER DEALINGS IN THE SOFTWARE. 20 * OTHER DEALINGS IN THE SOFTWARE.
21 * 21 *
22 */ 22 */
23 23#include <asm/div64.h>
24#include "fiji_thermal.h" 24#include "fiji_thermal.h"
25#include "fiji_hwmgr.h" 25#include "fiji_hwmgr.h"
26#include "fiji_smumgr.h" 26#include "fiji_smumgr.h"
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c
index 5abde8f6d108..9deadabbc81c 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/functiontables.c
@@ -66,7 +66,7 @@ int phm_dispatch_table(struct pp_hwmgr *hwmgr,
66 temp_storage = kzalloc(rt_table->storage_size, GFP_KERNEL); 66 temp_storage = kzalloc(rt_table->storage_size, GFP_KERNEL);
67 if (temp_storage == NULL) { 67 if (temp_storage == NULL) {
68 printk(KERN_ERR "[ powerplay ] Could not allocate table temporary storage\n"); 68 printk(KERN_ERR "[ powerplay ] Could not allocate table temporary storage\n");
69 return -1; 69 return -ENOMEM;
70 } 70 }
71 } 71 }
72 72
@@ -90,7 +90,7 @@ int phm_construct_table(struct pp_hwmgr *hwmgr,
90 90
91 if (hwmgr == NULL || master_table == NULL || rt_table == NULL) { 91 if (hwmgr == NULL || master_table == NULL || rt_table == NULL) {
92 printk(KERN_ERR "[ powerplay ] Invalid Parameter!\n"); 92 printk(KERN_ERR "[ powerplay ] Invalid Parameter!\n");
93 return -1; 93 return -EINVAL;
94 } 94 }
95 95
96 for (table_item = master_table->master_list; 96 for (table_item = master_table->master_list;
@@ -102,8 +102,9 @@ int phm_construct_table(struct pp_hwmgr *hwmgr,
102 102
103 size = (function_count + 1) * sizeof(phm_table_function); 103 size = (function_count + 1) * sizeof(phm_table_function);
104 run_time_list = kzalloc(size, GFP_KERNEL); 104 run_time_list = kzalloc(size, GFP_KERNEL);
105
105 if (NULL == run_time_list) 106 if (NULL == run_time_list)
106 return -1; 107 return -ENOMEM;
107 108
108 rtf = run_time_list; 109 rtf = run_time_list;
109 for (table_item = master_table->master_list; 110 for (table_item = master_table->master_list;
@@ -111,7 +112,7 @@ int phm_construct_table(struct pp_hwmgr *hwmgr,
111 if ((rtf - run_time_list) > function_count) { 112 if ((rtf - run_time_list) > function_count) {
112 printk(KERN_ERR "[ powerplay ] Check function results have changed\n"); 113 printk(KERN_ERR "[ powerplay ] Check function results have changed\n");
113 kfree(run_time_list); 114 kfree(run_time_list);
114 return -1; 115 return -EINVAL;
115 } 116 }
116 117
117 if ((NULL == table_item->isFunctionNeededInRuntimeTable) || 118 if ((NULL == table_item->isFunctionNeededInRuntimeTable) ||
@@ -123,7 +124,7 @@ int phm_construct_table(struct pp_hwmgr *hwmgr,
123 if ((rtf - run_time_list) > function_count) { 124 if ((rtf - run_time_list) > function_count) {
124 printk(KERN_ERR "[ powerplay ] Check function results have changed\n"); 125 printk(KERN_ERR "[ powerplay ] Check function results have changed\n");
125 kfree(run_time_list); 126 kfree(run_time_list);
126 return -1; 127 return -EINVAL;
127 } 128 }
128 129
129 *rtf = NULL; 130 *rtf = NULL;
@@ -138,7 +139,7 @@ int phm_destroy_table(struct pp_hwmgr *hwmgr,
138{ 139{
139 if (hwmgr == NULL || rt_table == NULL) { 140 if (hwmgr == NULL || rt_table == NULL) {
140 printk(KERN_ERR "[ powerplay ] Invalid Parameter\n"); 141 printk(KERN_ERR "[ powerplay ] Invalid Parameter\n");
141 return -1; 142 return -EINVAL;
142 } 143 }
143 144
144 if (NULL == rt_table->function_list) 145 if (NULL == rt_table->function_list)
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
index 001b8bb4143d..0f2d5e4bc241 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
@@ -90,6 +90,22 @@ int phm_setup_asic(struct pp_hwmgr *hwmgr)
90 return 0; 90 return 0;
91} 91}
92 92
93int phm_power_down_asic(struct pp_hwmgr *hwmgr)
94{
95 PHM_FUNC_CHECK(hwmgr);
96
97 if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
98 PHM_PlatformCaps_TablelessHardwareInterface)) {
99 if (NULL != hwmgr->hwmgr_func->power_off_asic)
100 return hwmgr->hwmgr_func->power_off_asic(hwmgr);
101 } else {
102 return phm_dispatch_table(hwmgr, &(hwmgr->power_down_asic),
103 NULL, NULL);
104 }
105
106 return 0;
107}
108
93int phm_set_power_state(struct pp_hwmgr *hwmgr, 109int phm_set_power_state(struct pp_hwmgr *hwmgr,
94 const struct pp_hw_power_state *pcurrent_state, 110 const struct pp_hw_power_state *pcurrent_state,
95 const struct pp_hw_power_state *pnew_power_state) 111 const struct pp_hw_power_state *pnew_power_state)
@@ -247,7 +263,6 @@ int phm_register_thermal_interrupt(struct pp_hwmgr *hwmgr, const void *info)
247*/ 263*/
248int phm_start_thermal_controller(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *temperature_range) 264int phm_start_thermal_controller(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *temperature_range)
249{ 265{
250
251 return phm_dispatch_table(hwmgr, &(hwmgr->start_thermal_controller), temperature_range, NULL); 266 return phm_dispatch_table(hwmgr, &(hwmgr->start_thermal_controller), temperature_range, NULL);
252} 267}
253 268
@@ -317,4 +332,3 @@ int phm_set_cpu_power_state(struct pp_hwmgr *hwmgr)
317 332
318 return 0; 333 return 0;
319} 334}
320
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index ca4554b402f9..5fb98aa2e719 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
@@ -111,6 +111,9 @@ int hw_init_power_state_table(struct pp_hwmgr *hwmgr)
111 111
112 hwmgr->ps = kzalloc(size * table_entries, GFP_KERNEL); 112 hwmgr->ps = kzalloc(size * table_entries, GFP_KERNEL);
113 113
114 if (hwmgr->ps == NULL)
115 return -ENOMEM;
116
114 state = hwmgr->ps; 117 state = hwmgr->ps;
115 118
116 for (i = 0; i < table_entries; i++) { 119 for (i = 0; i < table_entries; i++) {
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h b/drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h
index 42f2423cddea..b7429a527828 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h
@@ -117,379 +117,380 @@ int GetRoundedValue(fInt); /* Incomplete function - Usef
117 */ 117 */
118fInt fExponential(fInt exponent) /*Can be used to calculate e^exponent*/ 118fInt fExponential(fInt exponent) /*Can be used to calculate e^exponent*/
119{ 119{
120 uint32_t i; 120 uint32_t i;
121 bool bNegated = false; 121 bool bNegated = false;
122 122
123 fInt fPositiveOne = ConvertToFraction(1); 123 fInt fPositiveOne = ConvertToFraction(1);
124 fInt fZERO = ConvertToFraction(0); 124 fInt fZERO = ConvertToFraction(0);
125 125
126 fInt lower_bound = Divide(78, 10000); 126 fInt lower_bound = Divide(78, 10000);
127 fInt solution = fPositiveOne; /*Starting off with baseline of 1 */ 127 fInt solution = fPositiveOne; /*Starting off with baseline of 1 */
128 fInt error_term; 128 fInt error_term;
129 129
130 uint32_t k_array[11] = {55452, 27726, 13863, 6931, 4055, 2231, 1178, 606, 308, 155, 78}; 130 uint32_t k_array[11] = {55452, 27726, 13863, 6931, 4055, 2231, 1178, 606, 308, 155, 78};
131 uint32_t expk_array[11] = {2560000, 160000, 40000, 20000, 15000, 12500, 11250, 10625, 10313, 10156, 10078}; 131 uint32_t expk_array[11] = {2560000, 160000, 40000, 20000, 15000, 12500, 11250, 10625, 10313, 10156, 10078};
132 132
133 if (GreaterThan(fZERO, exponent)) { 133 if (GreaterThan(fZERO, exponent)) {
134 exponent = fNegate(exponent); 134 exponent = fNegate(exponent);
135 bNegated = true; 135 bNegated = true;
136 } 136 }
137 137
138 while (GreaterThan(exponent, lower_bound)) { 138 while (GreaterThan(exponent, lower_bound)) {
139 for (i = 0; i < 11; i++) { 139 for (i = 0; i < 11; i++) {
140 if (GreaterThan(exponent, GetScaledFraction(k_array[i], 10000))) { 140 if (GreaterThan(exponent, GetScaledFraction(k_array[i], 10000))) {
141 exponent = fSubtract(exponent, GetScaledFraction(k_array[i], 10000)); 141 exponent = fSubtract(exponent, GetScaledFraction(k_array[i], 10000));
142 solution = fMultiply(solution, GetScaledFraction(expk_array[i], 10000)); 142 solution = fMultiply(solution, GetScaledFraction(expk_array[i], 10000));
143 } 143 }
144 } 144 }
145 } 145 }
146 146
147 error_term = fAdd(fPositiveOne, exponent); 147 error_term = fAdd(fPositiveOne, exponent);
148 148
149 solution = fMultiply(solution, error_term); 149 solution = fMultiply(solution, error_term);
150 150
151 if (bNegated) 151 if (bNegated)
152 solution = fDivide(fPositiveOne, solution); 152 solution = fDivide(fPositiveOne, solution);
153 153
154 return solution; 154 return solution;
155} 155}
156 156
157fInt fNaturalLog(fInt value) 157fInt fNaturalLog(fInt value)
158{ 158{
159 uint32_t i; 159 uint32_t i;
160 fInt upper_bound = Divide(8, 1000); 160 fInt upper_bound = Divide(8, 1000);
161 fInt fNegativeOne = ConvertToFraction(-1); 161 fInt fNegativeOne = ConvertToFraction(-1);
162 fInt solution = ConvertToFraction(0); /*Starting off with baseline of 0 */ 162 fInt solution = ConvertToFraction(0); /*Starting off with baseline of 0 */
163 fInt error_term; 163 fInt error_term;
164 164
165 uint32_t k_array[10] = {160000, 40000, 20000, 15000, 12500, 11250, 10625, 10313, 10156, 10078}; 165 uint32_t k_array[10] = {160000, 40000, 20000, 15000, 12500, 11250, 10625, 10313, 10156, 10078};
166 uint32_t logk_array[10] = {27726, 13863, 6931, 4055, 2231, 1178, 606, 308, 155, 78}; 166 uint32_t logk_array[10] = {27726, 13863, 6931, 4055, 2231, 1178, 606, 308, 155, 78};
167 167
168 while (GreaterThan(fAdd(value, fNegativeOne), upper_bound)) { 168 while (GreaterThan(fAdd(value, fNegativeOne), upper_bound)) {
169 for (i = 0; i < 10; i++) { 169 for (i = 0; i < 10; i++) {
170 if (GreaterThan(value, GetScaledFraction(k_array[i], 10000))) { 170 if (GreaterThan(value, GetScaledFraction(k_array[i], 10000))) {
171 value = fDivide(value, GetScaledFraction(k_array[i], 10000)); 171 value = fDivide(value, GetScaledFraction(k_array[i], 10000));
172 solution = fAdd(solution, GetScaledFraction(logk_array[i], 10000)); 172 solution = fAdd(solution, GetScaledFraction(logk_array[i], 10000));
173 } 173 }
174 } 174 }
175 } 175 }
176 176
177 error_term = fAdd(fNegativeOne, value); 177 error_term = fAdd(fNegativeOne, value);
178 178
179 return (fAdd(solution, error_term)); 179 return (fAdd(solution, error_term));
180} 180}
181 181
182fInt fDecodeLinearFuse(uint32_t fuse_value, fInt f_min, fInt f_range, uint32_t bitlength) 182fInt fDecodeLinearFuse(uint32_t fuse_value, fInt f_min, fInt f_range, uint32_t bitlength)
183{ 183{
184 fInt f_fuse_value = Convert_ULONG_ToFraction(fuse_value); 184 fInt f_fuse_value = Convert_ULONG_ToFraction(fuse_value);
185 fInt f_bit_max_value = Convert_ULONG_ToFraction((uPow(2, bitlength)) - 1); 185 fInt f_bit_max_value = Convert_ULONG_ToFraction((uPow(2, bitlength)) - 1);
186 186
187 fInt f_decoded_value; 187 fInt f_decoded_value;
188 188
189 f_decoded_value = fDivide(f_fuse_value, f_bit_max_value); 189 f_decoded_value = fDivide(f_fuse_value, f_bit_max_value);
190 f_decoded_value = fMultiply(f_decoded_value, f_range); 190 f_decoded_value = fMultiply(f_decoded_value, f_range);
191 f_decoded_value = fAdd(f_decoded_value, f_min); 191 f_decoded_value = fAdd(f_decoded_value, f_min);
192 192
193 return f_decoded_value; 193 return f_decoded_value;
194} 194}
195 195
196 196
197fInt fDecodeLogisticFuse(uint32_t fuse_value, fInt f_average, fInt f_range, uint32_t bitlength) 197fInt fDecodeLogisticFuse(uint32_t fuse_value, fInt f_average, fInt f_range, uint32_t bitlength)
198{ 198{
199 fInt f_fuse_value = Convert_ULONG_ToFraction(fuse_value); 199 fInt f_fuse_value = Convert_ULONG_ToFraction(fuse_value);
200 fInt f_bit_max_value = Convert_ULONG_ToFraction((uPow(2, bitlength)) - 1); 200 fInt f_bit_max_value = Convert_ULONG_ToFraction((uPow(2, bitlength)) - 1);
201 201
202 fInt f_CONSTANT_NEG13 = ConvertToFraction(-13); 202 fInt f_CONSTANT_NEG13 = ConvertToFraction(-13);
203 fInt f_CONSTANT1 = ConvertToFraction(1); 203 fInt f_CONSTANT1 = ConvertToFraction(1);
204 204
205 fInt f_decoded_value; 205 fInt f_decoded_value;
206 206
207 f_decoded_value = fSubtract(fDivide(f_bit_max_value, f_fuse_value), f_CONSTANT1); 207 f_decoded_value = fSubtract(fDivide(f_bit_max_value, f_fuse_value), f_CONSTANT1);
208 f_decoded_value = fNaturalLog(f_decoded_value); 208 f_decoded_value = fNaturalLog(f_decoded_value);
209 f_decoded_value = fMultiply(f_decoded_value, fDivide(f_range, f_CONSTANT_NEG13)); 209 f_decoded_value = fMultiply(f_decoded_value, fDivide(f_range, f_CONSTANT_NEG13));
210 f_decoded_value = fAdd(f_decoded_value, f_average); 210 f_decoded_value = fAdd(f_decoded_value, f_average);
211 211
212 return f_decoded_value; 212 return f_decoded_value;
213} 213}
214 214
215fInt fDecodeLeakageID (uint32_t leakageID_fuse, fInt ln_max_div_min, fInt f_min, uint32_t bitlength) 215fInt fDecodeLeakageID (uint32_t leakageID_fuse, fInt ln_max_div_min, fInt f_min, uint32_t bitlength)
216{ 216{
217 fInt fLeakage; 217 fInt fLeakage;
218 fInt f_bit_max_value = Convert_ULONG_ToFraction((uPow(2, bitlength)) - 1); 218 fInt f_bit_max_value = Convert_ULONG_ToFraction((uPow(2, bitlength)) - 1);
219 219
220 fLeakage = fMultiply(ln_max_div_min, Convert_ULONG_ToFraction(leakageID_fuse)); 220 fLeakage = fMultiply(ln_max_div_min, Convert_ULONG_ToFraction(leakageID_fuse));
221 fLeakage = fDivide(fLeakage, f_bit_max_value); 221 fLeakage = fDivide(fLeakage, f_bit_max_value);
222 fLeakage = fExponential(fLeakage); 222 fLeakage = fExponential(fLeakage);
223 fLeakage = fMultiply(fLeakage, f_min); 223 fLeakage = fMultiply(fLeakage, f_min);
224 224
225 return fLeakage; 225 return fLeakage;
226} 226}
227 227
228fInt ConvertToFraction(int X) /*Add all range checking here. Is it possible to make fInt a private declaration? */ 228fInt ConvertToFraction(int X) /*Add all range checking here. Is it possible to make fInt a private declaration? */
229{ 229{
230 fInt temp; 230 fInt temp;
231 231
232 if (X <= MAX) 232 if (X <= MAX)
233 temp.full = (X << SHIFT_AMOUNT); 233 temp.full = (X << SHIFT_AMOUNT);
234 else 234 else
235 temp.full = 0; 235 temp.full = 0;
236 236
237 return temp; 237 return temp;
238} 238}
239 239
240fInt fNegate(fInt X) 240fInt fNegate(fInt X)
241{ 241{
242 fInt CONSTANT_NEGONE = ConvertToFraction(-1); 242 fInt CONSTANT_NEGONE = ConvertToFraction(-1);
243 return (fMultiply(X, CONSTANT_NEGONE)); 243 return (fMultiply(X, CONSTANT_NEGONE));
244} 244}
245 245
246fInt Convert_ULONG_ToFraction(uint32_t X) 246fInt Convert_ULONG_ToFraction(uint32_t X)
247{ 247{
248 fInt temp; 248 fInt temp;
249 249
250 if (X <= MAX) 250 if (X <= MAX)
251 temp.full = (X << SHIFT_AMOUNT); 251 temp.full = (X << SHIFT_AMOUNT);
252 else 252 else
253 temp.full = 0; 253 temp.full = 0;
254 254
255 return temp; 255 return temp;
256} 256}
257 257
258fInt GetScaledFraction(int X, int factor) 258fInt GetScaledFraction(int X, int factor)
259{ 259{
260 int times_shifted, factor_shifted; 260 int times_shifted, factor_shifted;
261 bool bNEGATED; 261 bool bNEGATED;
262 fInt fValue; 262 fInt fValue;
263 263
264 times_shifted = 0; 264 times_shifted = 0;
265 factor_shifted = 0; 265 factor_shifted = 0;
266 bNEGATED = false; 266 bNEGATED = false;
267 267
268 if (X < 0) { 268 if (X < 0) {
269 X = -1*X; 269 X = -1*X;
270 bNEGATED = true; 270 bNEGATED = true;
271 } 271 }
272 272
273 if (factor < 0) { 273 if (factor < 0) {
274 factor = -1*factor; 274 factor = -1*factor;
275 275 bNEGATED = !bNEGATED; /*If bNEGATED = true due to X < 0, this will cover the case of negative cancelling negative */
276 bNEGATED = !bNEGATED; /*If bNEGATED = true due to X < 0, this will cover the case of negative cancelling negative */ 276 }
277 } 277
278 278 if ((X > MAX) || factor > MAX) {
279 if ((X > MAX) || factor > MAX) { 279 if ((X/factor) <= MAX) {
280 if ((X/factor) <= MAX) { 280 while (X > MAX) {
281 while (X > MAX) { 281 X = X >> 1;
282 X = X >> 1; 282 times_shifted++;
283 times_shifted++; 283 }
284 } 284
285 285 while (factor > MAX) {
286 while (factor > MAX) { 286 factor = factor >> 1;
287 factor = factor >> 1; 287 factor_shifted++;
288 factor_shifted++; 288 }
289 } 289 } else {
290 } else { 290 fValue.full = 0;
291 fValue.full = 0; 291 return fValue;
292 return fValue; 292 }
293 } 293 }
294 } 294
295 295 if (factor == 1)
296 if (factor == 1) 296 return (ConvertToFraction(X));
297 return (ConvertToFraction(X)); 297
298 298 fValue = fDivide(ConvertToFraction(X * uPow(-1, bNEGATED)), ConvertToFraction(factor));
299 fValue = fDivide(ConvertToFraction(X * uPow(-1, bNEGATED)), ConvertToFraction(factor)); 299
300 300 fValue.full = fValue.full << times_shifted;
301 fValue.full = fValue.full << times_shifted; 301 fValue.full = fValue.full >> factor_shifted;
302 fValue.full = fValue.full >> factor_shifted; 302
303 303 return fValue;
304 return fValue;
305} 304}
306 305
307/* Addition using two fInts */ 306/* Addition using two fInts */
308fInt fAdd (fInt X, fInt Y) 307fInt fAdd (fInt X, fInt Y)
309{ 308{
310 fInt Sum; 309 fInt Sum;
311 310
312 Sum.full = X.full + Y.full; 311 Sum.full = X.full + Y.full;
313 312
314 return Sum; 313 return Sum;
315} 314}
316 315
317/* Addition using two fInts */ 316/* Addition using two fInts */
318fInt fSubtract (fInt X, fInt Y) 317fInt fSubtract (fInt X, fInt Y)
319{ 318{
320 fInt Difference; 319 fInt Difference;
321 320
322 Difference.full = X.full - Y.full; 321 Difference.full = X.full - Y.full;
323 322
324 return Difference; 323 return Difference;
325} 324}
326 325
327bool Equal(fInt A, fInt B) 326bool Equal(fInt A, fInt B)
328{ 327{
329 if (A.full == B.full) 328 if (A.full == B.full)
330 return true; 329 return true;
331 else 330 else
332 return false; 331 return false;
333} 332}
334 333
335bool GreaterThan(fInt A, fInt B) 334bool GreaterThan(fInt A, fInt B)
336{ 335{
337 if (A.full > B.full) 336 if (A.full > B.full)
338 return true; 337 return true;
339 else 338 else
340 return false; 339 return false;
341} 340}
342 341
343fInt fMultiply (fInt X, fInt Y) /* Uses 64-bit integers (int64_t) */ 342fInt fMultiply (fInt X, fInt Y) /* Uses 64-bit integers (int64_t) */
344{ 343{
345 fInt Product; 344 fInt Product;
346 int64_t tempProduct; 345 int64_t tempProduct;
347 bool X_LessThanOne, Y_LessThanOne; 346 bool X_LessThanOne, Y_LessThanOne;
348 347
349 X_LessThanOne = (X.partial.real == 0 && X.partial.decimal != 0 && X.full >= 0); 348 X_LessThanOne = (X.partial.real == 0 && X.partial.decimal != 0 && X.full >= 0);
350 Y_LessThanOne = (Y.partial.real == 0 && Y.partial.decimal != 0 && Y.full >= 0); 349 Y_LessThanOne = (Y.partial.real == 0 && Y.partial.decimal != 0 && Y.full >= 0);
351 350
352 /*The following is for a very specific common case: Non-zero number with ONLY fractional portion*/ 351 /*The following is for a very specific common case: Non-zero number with ONLY fractional portion*/
353 /* TEMPORARILY DISABLED - CAN BE USED TO IMPROVE PRECISION 352 /* TEMPORARILY DISABLED - CAN BE USED TO IMPROVE PRECISION
354 353
355 if (X_LessThanOne && Y_LessThanOne) { 354 if (X_LessThanOne && Y_LessThanOne) {
356 Product.full = X.full * Y.full; 355 Product.full = X.full * Y.full;
357 return Product 356 return Product
358 }*/ 357 }*/
359 358
360 tempProduct = ((int64_t)X.full) * ((int64_t)Y.full); /*Q(16,16)*Q(16,16) = Q(32, 32) - Might become a negative number! */ 359 tempProduct = ((int64_t)X.full) * ((int64_t)Y.full); /*Q(16,16)*Q(16,16) = Q(32, 32) - Might become a negative number! */
361 tempProduct = tempProduct >> 16; /*Remove lagging 16 bits - Will lose some precision from decimal; */ 360 tempProduct = tempProduct >> 16; /*Remove lagging 16 bits - Will lose some precision from decimal; */
362 Product.full = (int)tempProduct; /*The int64_t will lose the leading 16 bits that were part of the integer portion */ 361 Product.full = (int)tempProduct; /*The int64_t will lose the leading 16 bits that were part of the integer portion */
363 362
364 return Product; 363 return Product;
365} 364}
366 365
367fInt fDivide (fInt X, fInt Y) 366fInt fDivide (fInt X, fInt Y)
368{ 367{
369 fInt fZERO, fQuotient; 368 fInt fZERO, fQuotient;
370 int64_t longlongX, longlongY; 369 int64_t longlongX, longlongY;
371 370
372 fZERO = ConvertToFraction(0); 371 fZERO = ConvertToFraction(0);
373 372
374 if (Equal(Y, fZERO)) 373 if (Equal(Y, fZERO))
375 return fZERO; 374 return fZERO;
376 375
377 longlongX = (int64_t)X.full; 376 longlongX = (int64_t)X.full;
378 longlongY = (int64_t)Y.full; 377 longlongY = (int64_t)Y.full;
379 378
380 longlongX = longlongX << 16; /*Q(16,16) -> Q(32,32) */ 379 longlongX = longlongX << 16; /*Q(16,16) -> Q(32,32) */
381 380
382 do_div(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */ 381 div64_s64(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */
383 382
384 fQuotient.full = (int)longlongX; 383 fQuotient.full = (int)longlongX;
385 return fQuotient; 384 return fQuotient;
386} 385}
387 386
388int ConvertBackToInteger (fInt A) /*THIS is the function that will be used to check with the Golden settings table*/ 387int ConvertBackToInteger (fInt A) /*THIS is the function that will be used to check with the Golden settings table*/
389{ 388{
390 fInt fullNumber, scaledDecimal, scaledReal; 389 fInt fullNumber, scaledDecimal, scaledReal;
391 390
392 scaledReal.full = GetReal(A) * uPow(10, PRECISION-1); /* DOUBLE CHECK THISSSS!!! */ 391 scaledReal.full = GetReal(A) * uPow(10, PRECISION-1); /* DOUBLE CHECK THISSSS!!! */
393 392
394 scaledDecimal.full = uGetScaledDecimal(A); 393 scaledDecimal.full = uGetScaledDecimal(A);
395 394
396 fullNumber = fAdd(scaledDecimal,scaledReal); 395 fullNumber = fAdd(scaledDecimal,scaledReal);
397 396
398 return fullNumber.full; 397 return fullNumber.full;
399} 398}
400 399
401fInt fGetSquare(fInt A) 400fInt fGetSquare(fInt A)
402{ 401{
403 return fMultiply(A,A); 402 return fMultiply(A,A);
404} 403}
405 404
406/* x_new = x_old - (x_old^2 - C) / (2 * x_old) */ 405/* x_new = x_old - (x_old^2 - C) / (2 * x_old) */
407fInt fSqrt(fInt num) 406fInt fSqrt(fInt num)
408{ 407{
409 fInt F_divide_Fprime, Fprime; 408 fInt F_divide_Fprime, Fprime;
410 fInt test; 409 fInt test;
411 fInt twoShifted; 410 fInt twoShifted;
412 int seed, counter, error; 411 int seed, counter, error;
413 fInt x_new, x_old, C, y; 412 fInt x_new, x_old, C, y;
414 413
415 fInt fZERO = ConvertToFraction(0); 414 fInt fZERO = ConvertToFraction(0);
416 /* (0 > num) is the same as (num < 0), i.e., num is negative */
417 if (GreaterThan(fZERO, num) || Equal(fZERO, num))
418 return fZERO;
419 415
420 C = num; 416 /* (0 > num) is the same as (num < 0), i.e., num is negative */
421 417
422 if (num.partial.real > 3000) 418 if (GreaterThan(fZERO, num) || Equal(fZERO, num))
423 seed = 60; 419 return fZERO;
424 else if (num.partial.real > 1000)
425 seed = 30;
426 else if (num.partial.real > 100)
427 seed = 10;
428 else
429 seed = 2;
430 420
431 counter = 0; 421 C = num;
432 422
433 if (Equal(num, fZERO)) /*Square Root of Zero is zero */ 423 if (num.partial.real > 3000)
434 return fZERO; 424 seed = 60;
425 else if (num.partial.real > 1000)
426 seed = 30;
427 else if (num.partial.real > 100)
428 seed = 10;
429 else
430 seed = 2;
431
432 counter = 0;
435 433
436 twoShifted = ConvertToFraction(2); 434 if (Equal(num, fZERO)) /*Square Root of Zero is zero */
437 x_new = ConvertToFraction(seed); 435 return fZERO;
438 436
439 do { 437 twoShifted = ConvertToFraction(2);
440 counter++; 438 x_new = ConvertToFraction(seed);
441 439
442 x_old.full = x_new.full; 440 do {
441 counter++;
443 442
444 test = fGetSquare(x_old); /*1.75*1.75 is reverting back to 1 when shifted down */ 443 x_old.full = x_new.full;
445 y = fSubtract(test, C); /*y = f(x) = x^2 - C; */
446 444
447 Fprime = fMultiply(twoShifted, x_old); 445 test = fGetSquare(x_old); /*1.75*1.75 is reverting back to 1 when shifted down */
448 F_divide_Fprime = fDivide(y, Fprime); 446 y = fSubtract(test, C); /*y = f(x) = x^2 - C; */
449 447
450 x_new = fSubtract(x_old, F_divide_Fprime); 448 Fprime = fMultiply(twoShifted, x_old);
449 F_divide_Fprime = fDivide(y, Fprime);
451 450
452 error = ConvertBackToInteger(x_new) - ConvertBackToInteger(x_old); 451 x_new = fSubtract(x_old, F_divide_Fprime);
453 452
454 if (counter > 20) /*20 is already way too many iterations. If we dont have an answer by then, we never will*/ 453 error = ConvertBackToInteger(x_new) - ConvertBackToInteger(x_old);
455 return x_new;
456 454
457 } while (uAbs(error) > 0); 455 if (counter > 20) /*20 is already way too many iterations. If we dont have an answer by then, we never will*/
456 return x_new;
458 457
459 return (x_new); 458 } while (uAbs(error) > 0);
459
460 return (x_new);
460} 461}
461 462
462void SolveQuadracticEqn(fInt A, fInt B, fInt C, fInt Roots[]) 463void SolveQuadracticEqn(fInt A, fInt B, fInt C, fInt Roots[])
463{ 464{
464 fInt* pRoots = &Roots[0]; 465 fInt *pRoots = &Roots[0];
465 fInt temp, root_first, root_second; 466 fInt temp, root_first, root_second;
466 fInt f_CONSTANT10, f_CONSTANT100; 467 fInt f_CONSTANT10, f_CONSTANT100;
467 468
468 f_CONSTANT100 = ConvertToFraction(100); 469 f_CONSTANT100 = ConvertToFraction(100);
469 f_CONSTANT10 = ConvertToFraction(10); 470 f_CONSTANT10 = ConvertToFraction(10);
470 471
471 while(GreaterThan(A, f_CONSTANT100) || GreaterThan(B, f_CONSTANT100) || GreaterThan(C, f_CONSTANT100)) { 472 while(GreaterThan(A, f_CONSTANT100) || GreaterThan(B, f_CONSTANT100) || GreaterThan(C, f_CONSTANT100)) {
472 A = fDivide(A, f_CONSTANT10); 473 A = fDivide(A, f_CONSTANT10);
473 B = fDivide(B, f_CONSTANT10); 474 B = fDivide(B, f_CONSTANT10);
474 C = fDivide(C, f_CONSTANT10); 475 C = fDivide(C, f_CONSTANT10);
475 } 476 }
476 477
477 temp = fMultiply(ConvertToFraction(4), A); /* root = 4*A */ 478 temp = fMultiply(ConvertToFraction(4), A); /* root = 4*A */
478 temp = fMultiply(temp, C); /* root = 4*A*C */ 479 temp = fMultiply(temp, C); /* root = 4*A*C */
479 temp = fSubtract(fGetSquare(B), temp); /* root = b^2 - 4AC */ 480 temp = fSubtract(fGetSquare(B), temp); /* root = b^2 - 4AC */
480 temp = fSqrt(temp); /*root = Sqrt (b^2 - 4AC); */ 481 temp = fSqrt(temp); /*root = Sqrt (b^2 - 4AC); */
481 482
482 root_first = fSubtract(fNegate(B), temp); /* b - Sqrt(b^2 - 4AC) */ 483 root_first = fSubtract(fNegate(B), temp); /* b - Sqrt(b^2 - 4AC) */
483 root_second = fAdd(fNegate(B), temp); /* b + Sqrt(b^2 - 4AC) */ 484 root_second = fAdd(fNegate(B), temp); /* b + Sqrt(b^2 - 4AC) */
484 485
485 root_first = fDivide(root_first, ConvertToFraction(2)); /* [b +- Sqrt(b^2 - 4AC)]/[2] */ 486 root_first = fDivide(root_first, ConvertToFraction(2)); /* [b +- Sqrt(b^2 - 4AC)]/[2] */
486 root_first = fDivide(root_first, A); /*[b +- Sqrt(b^2 - 4AC)]/[2*A] */ 487 root_first = fDivide(root_first, A); /*[b +- Sqrt(b^2 - 4AC)]/[2*A] */
487 488
488 root_second = fDivide(root_second, ConvertToFraction(2)); /* [b +- Sqrt(b^2 - 4AC)]/[2] */ 489 root_second = fDivide(root_second, ConvertToFraction(2)); /* [b +- Sqrt(b^2 - 4AC)]/[2] */
489 root_second = fDivide(root_second, A); /*[b +- Sqrt(b^2 - 4AC)]/[2*A] */ 490 root_second = fDivide(root_second, A); /*[b +- Sqrt(b^2 - 4AC)]/[2*A] */
490 491
491 *(pRoots + 0) = root_first; 492 *(pRoots + 0) = root_first;
492 *(pRoots + 1) = root_second; 493 *(pRoots + 1) = root_second;
493} 494}
494 495
495/* ----------------------------------------------------------------------------- 496/* -----------------------------------------------------------------------------
@@ -500,61 +501,58 @@ void SolveQuadracticEqn(fInt A, fInt B, fInt C, fInt Roots[])
500/* Addition using two normal ints - Temporary - Use only for testing purposes?. */ 501/* Addition using two normal ints - Temporary - Use only for testing purposes?. */
501fInt Add (int X, int Y) 502fInt Add (int X, int Y)
502{ 503{
503 fInt A, B, Sum; 504 fInt A, B, Sum;
504 505
505 A.full = (X << SHIFT_AMOUNT); 506 A.full = (X << SHIFT_AMOUNT);
506 B.full = (Y << SHIFT_AMOUNT); 507 B.full = (Y << SHIFT_AMOUNT);
507 508
508 Sum.full = A.full + B.full; 509 Sum.full = A.full + B.full;
509 510
510 return Sum; 511 return Sum;
511} 512}
512 513
513/* Conversion Functions */ 514/* Conversion Functions */
514int GetReal (fInt A) 515int GetReal (fInt A)
515{ 516{
516 return (A.full >> SHIFT_AMOUNT); 517 return (A.full >> SHIFT_AMOUNT);
517} 518}
518 519
519/* Temporarily Disabled */ 520/* Temporarily Disabled */
520int GetRoundedValue(fInt A) /*For now, round the 3rd decimal place */ 521int GetRoundedValue(fInt A) /*For now, round the 3rd decimal place */
521{ 522{
522 /* ROUNDING TEMPORARLY DISABLED 523 /* ROUNDING TEMPORARLY DISABLED
523 int temp = A.full; 524 int temp = A.full;
524 525 int decimal_cutoff, decimal_mask = 0x000001FF;
525 int decimal_cutoff, decimal_mask = 0x000001FF; 526 decimal_cutoff = temp & decimal_mask;
526 527 if (decimal_cutoff > 0x147) {
527 decimal_cutoff = temp & decimal_mask; 528 temp += 673;
528 529 }*/
529 530
530 if (decimal_cutoff > 0x147) { 531 return ConvertBackToInteger(A)/10000; /*Temporary - in case this was used somewhere else */
531 temp += 673;
532 }*/
533
534 return ConvertBackToInteger(A)/10000; /*Temporary - in case this was used somewhere else */
535} 532}
536 533
537fInt Multiply (int X, int Y) 534fInt Multiply (int X, int Y)
538{ 535{
539 fInt A, B, Product; 536 fInt A, B, Product;
540 537
541 A.full = X << SHIFT_AMOUNT; 538 A.full = X << SHIFT_AMOUNT;
542 B.full = Y << SHIFT_AMOUNT; 539 B.full = Y << SHIFT_AMOUNT;
543 540
544 Product = fMultiply(A, B); 541 Product = fMultiply(A, B);
545 542
546 return Product; 543 return Product;
547} 544}
545
548fInt Divide (int X, int Y) 546fInt Divide (int X, int Y)
549{ 547{
550 fInt A, B, Quotient; 548 fInt A, B, Quotient;
551 549
552 A.full = X << SHIFT_AMOUNT; 550 A.full = X << SHIFT_AMOUNT;
553 B.full = Y << SHIFT_AMOUNT; 551 B.full = Y << SHIFT_AMOUNT;
554 552
555 Quotient = fDivide(A, B); 553 Quotient = fDivide(A, B);
556 554
557 return Quotient; 555 return Quotient;
558} 556}
559 557
560int uGetScaledDecimal (fInt A) /*Converts the fractional portion to whole integers - Costly function */ 558int uGetScaledDecimal (fInt A) /*Converts the fractional portion to whole integers - Costly function */
@@ -563,16 +561,13 @@ int uGetScaledDecimal (fInt A) /*Converts the fractional portion to whole intege
563 int i, scaledDecimal = 0, tmp = A.partial.decimal; 561 int i, scaledDecimal = 0, tmp = A.partial.decimal;
564 562
565 for (i = 0; i < PRECISION; i++) { 563 for (i = 0; i < PRECISION; i++) {
566 dec[i] = tmp / (1 << SHIFT_AMOUNT); 564 dec[i] = tmp / (1 << SHIFT_AMOUNT);
567 565 tmp = tmp - ((1 << SHIFT_AMOUNT)*dec[i]);
568 tmp = tmp - ((1 << SHIFT_AMOUNT)*dec[i]); 566 tmp *= 10;
569 567 scaledDecimal = scaledDecimal + dec[i]*uPow(10, PRECISION - 1 -i);
570 tmp *= 10; 568 }
571
572 scaledDecimal = scaledDecimal + dec[i]*uPow(10, PRECISION - 1 -i);
573 }
574 569
575 return scaledDecimal; 570 return scaledDecimal;
576} 571}
577 572
578int uPow(int base, int power) 573int uPow(int base, int power)
@@ -601,17 +596,17 @@ int uAbs(int X)
601 596
602fInt fRoundUpByStepSize(fInt A, fInt fStepSize, bool error_term) 597fInt fRoundUpByStepSize(fInt A, fInt fStepSize, bool error_term)
603{ 598{
604 fInt solution; 599 fInt solution;
605 600
606 solution = fDivide(A, fStepSize); 601 solution = fDivide(A, fStepSize);
607 solution.partial.decimal = 0; /*All fractional digits changes to 0 */ 602 solution.partial.decimal = 0; /*All fractional digits changes to 0 */
608 603
609 if (error_term) 604 if (error_term)
610 solution.partial.real += 1; /*Error term of 1 added */ 605 solution.partial.real += 1; /*Error term of 1 added */
611 606
612 solution = fMultiply(solution, fStepSize); 607 solution = fMultiply(solution, fStepSize);
613 solution = fAdd(solution, fStepSize); 608 solution = fAdd(solution, fStepSize);
614 609
615 return solution; 610 return solution;
616} 611}
617 612
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c
index 1d385f473776..2f1a14fe05b1 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c
@@ -735,8 +735,8 @@ static int init_non_clock_fields(struct pp_hwmgr *hwmgr,
735 735
736 ps->memory.dllOff = (0 != tmp); 736 ps->memory.dllOff = (0 != tmp);
737 737
738 ps->memory.m3arb = (uint8_t)(le32_to_cpu(pnon_clock_info->ulCapsAndSettings) & 738 ps->memory.m3arb = (le32_to_cpu(pnon_clock_info->ulCapsAndSettings) &
739 ATOM_PPLIB_M3ARB_MASK) >> ATOM_PPLIB_M3ARB_SHIFT; 739 ATOM_PPLIB_M3ARB_MASK) >> ATOM_PPLIB_M3ARB_SHIFT;
740 740
741 ps->temperatures.min = PP_TEMPERATURE_UNITS_PER_CENTIGRADES * 741 ps->temperatures.min = PP_TEMPERATURE_UNITS_PER_CENTIGRADES *
742 pnon_clock_info->ucMinTemperature; 742 pnon_clock_info->ucMinTemperature;
@@ -1322,11 +1322,17 @@ static int get_cac_leakage_table(struct pp_hwmgr *hwmgr,
1322 struct phm_cac_leakage_table *cac_leakage_table; 1322 struct phm_cac_leakage_table *cac_leakage_table;
1323 unsigned long table_size, i; 1323 unsigned long table_size, i;
1324 1324
1325 if (hwmgr == NULL || table == NULL || ptable == NULL)
1326 return -EINVAL;
1327
1325 table_size = sizeof(ULONG) + 1328 table_size = sizeof(ULONG) +
1326 (sizeof(struct phm_cac_leakage_table) * table->ucNumEntries); 1329 (sizeof(struct phm_cac_leakage_table) * table->ucNumEntries);
1327 1330
1328 cac_leakage_table = kzalloc(table_size, GFP_KERNEL); 1331 cac_leakage_table = kzalloc(table_size, GFP_KERNEL);
1329 1332
1333 if (cac_leakage_table == NULL)
1334 return -ENOMEM;
1335
1330 cac_leakage_table->count = (ULONG)table->ucNumEntries; 1336 cac_leakage_table->count = (ULONG)table->ucNumEntries;
1331 1337
1332 for (i = 0; i < cac_leakage_table->count; i++) { 1338 for (i = 0; i < cac_leakage_table->count; i++) {
@@ -1349,7 +1355,7 @@ static int get_cac_leakage_table(struct pp_hwmgr *hwmgr,
1349static int get_platform_power_management_table(struct pp_hwmgr *hwmgr, 1355static int get_platform_power_management_table(struct pp_hwmgr *hwmgr,
1350 ATOM_PPLIB_PPM_Table *atom_ppm_table) 1356 ATOM_PPLIB_PPM_Table *atom_ppm_table)
1351{ 1357{
1352 struct phm_ppm_table *ptr = kzalloc(sizeof(ATOM_PPLIB_PPM_Table), GFP_KERNEL); 1358 struct phm_ppm_table *ptr = kzalloc(sizeof(struct phm_ppm_table), GFP_KERNEL);
1353 1359
1354 if (NULL == ptr) 1360 if (NULL == ptr)
1355 return -ENOMEM; 1361 return -ENOMEM;
@@ -1466,6 +1472,9 @@ static int init_phase_shedding_table(struct pp_hwmgr *hwmgr,
1466 1472
1467 table = kzalloc(size, GFP_KERNEL); 1473 table = kzalloc(size, GFP_KERNEL);
1468 1474
1475 if (table == NULL)
1476 return -ENOMEM;
1477
1469 table->count = (unsigned long)ptable->ucNumEntries; 1478 table->count = (unsigned long)ptable->ucNumEntries;
1470 1479
1471 for (i = 0; i < table->count; i++) { 1480 for (i = 0; i < table->count; i++) {
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
index 3cb5d041b3cf..44a925006479 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
@@ -115,9 +115,12 @@ const unsigned long PhwTonga_Magic = (unsigned long)(PHM_VIslands_Magic);
115struct tonga_power_state *cast_phw_tonga_power_state( 115struct tonga_power_state *cast_phw_tonga_power_state(
116 struct pp_hw_power_state *hw_ps) 116 struct pp_hw_power_state *hw_ps)
117{ 117{
118 if (hw_ps == NULL)
119 return NULL;
120
118 PP_ASSERT_WITH_CODE((PhwTonga_Magic == hw_ps->magic), 121 PP_ASSERT_WITH_CODE((PhwTonga_Magic == hw_ps->magic),
119 "Invalid Powerstate Type!", 122 "Invalid Powerstate Type!",
120 return NULL;); 123 return NULL);
121 124
122 return (struct tonga_power_state *)hw_ps; 125 return (struct tonga_power_state *)hw_ps;
123} 126}
@@ -125,9 +128,12 @@ struct tonga_power_state *cast_phw_tonga_power_state(
125const struct tonga_power_state *cast_const_phw_tonga_power_state( 128const struct tonga_power_state *cast_const_phw_tonga_power_state(
126 const struct pp_hw_power_state *hw_ps) 129 const struct pp_hw_power_state *hw_ps)
127{ 130{
131 if (hw_ps == NULL)
132 return NULL;
133
128 PP_ASSERT_WITH_CODE((PhwTonga_Magic == hw_ps->magic), 134 PP_ASSERT_WITH_CODE((PhwTonga_Magic == hw_ps->magic),
129 "Invalid Powerstate Type!", 135 "Invalid Powerstate Type!",
130 return NULL;); 136 return NULL);
131 137
132 return (const struct tonga_power_state *)hw_ps; 138 return (const struct tonga_power_state *)hw_ps;
133} 139}
@@ -1678,9 +1684,9 @@ static int tonga_populate_smc_uvd_level(struct pp_hwmgr *hwmgr,
1678 CONVERT_FROM_HOST_TO_SMC_UL(table->UvdLevel[count].VclkFrequency); 1684 CONVERT_FROM_HOST_TO_SMC_UL(table->UvdLevel[count].VclkFrequency);
1679 CONVERT_FROM_HOST_TO_SMC_UL(table->UvdLevel[count].DclkFrequency); 1685 CONVERT_FROM_HOST_TO_SMC_UL(table->UvdLevel[count].DclkFrequency);
1680 //CONVERT_FROM_HOST_TO_SMC_UL((uint32_t)table->UvdLevel[count].MinVoltage); 1686 //CONVERT_FROM_HOST_TO_SMC_UL((uint32_t)table->UvdLevel[count].MinVoltage);
1681 } 1687 }
1682 1688
1683 return result; 1689 return result;
1684 1690
1685} 1691}
1686 1692
@@ -1719,7 +1725,7 @@ static int tonga_populate_smc_vce_level(struct pp_hwmgr *hwmgr,
1719 PP_ASSERT_WITH_CODE((0 == result), 1725 PP_ASSERT_WITH_CODE((0 == result),
1720 "can not find divide id for VCE engine clock", return result); 1726 "can not find divide id for VCE engine clock", return result);
1721 1727
1722 table->VceLevel[count].Divider = (uint8_t)dividers.pll_post_divider; 1728 table->VceLevel[count].Divider = (uint8_t)dividers.pll_post_divider;
1723 1729
1724 CONVERT_FROM_HOST_TO_SMC_UL(table->VceLevel[count].Frequency); 1730 CONVERT_FROM_HOST_TO_SMC_UL(table->VceLevel[count].Frequency);
1725 } 1731 }
@@ -1804,7 +1810,7 @@ static int tonga_populate_smc_samu_level(struct pp_hwmgr *hwmgr,
1804 PP_ASSERT_WITH_CODE((0 == result), 1810 PP_ASSERT_WITH_CODE((0 == result),
1805 "can not find divide id for samu clock", return result); 1811 "can not find divide id for samu clock", return result);
1806 1812
1807 table->SamuLevel[count].Divider = (uint8_t)dividers.pll_post_divider; 1813 table->SamuLevel[count].Divider = (uint8_t)dividers.pll_post_divider;
1808 1814
1809 CONVERT_FROM_HOST_TO_SMC_UL(table->SamuLevel[count].Frequency); 1815 CONVERT_FROM_HOST_TO_SMC_UL(table->SamuLevel[count].Frequency);
1810 } 1816 }
@@ -1847,7 +1853,7 @@ static int tonga_calculate_mclk_params(
1847 "Error retrieving Memory Clock Parameters from VBIOS.", return result); 1853 "Error retrieving Memory Clock Parameters from VBIOS.", return result);
1848 1854
1849 /* MPLL_FUNC_CNTL setup*/ 1855 /* MPLL_FUNC_CNTL setup*/
1850 mpll_func_cntl = PHM_SET_FIELD(mpll_func_cntl, MPLL_FUNC_CNTL, BWCTRL, mpll_param.bw_ctrl); 1856 mpll_func_cntl = PHM_SET_FIELD(mpll_func_cntl, MPLL_FUNC_CNTL, BWCTRL, mpll_param.bw_ctrl);
1851 1857
1852 /* MPLL_FUNC_CNTL_1 setup*/ 1858 /* MPLL_FUNC_CNTL_1 setup*/
1853 mpll_func_cntl_1 = PHM_SET_FIELD(mpll_func_cntl_1, 1859 mpll_func_cntl_1 = PHM_SET_FIELD(mpll_func_cntl_1,
@@ -3864,6 +3870,7 @@ int tonga_copy_vbios_smc_reg_table(const pp_atomctrl_mc_reg_table *table, phw_to
3864 table->mc_reg_table_entry[i].mc_data[j]; 3870 table->mc_reg_table_entry[i].mc_data[j];
3865 } 3871 }
3866 } 3872 }
3873
3867 ni_table->num_entries = table->num_entries; 3874 ni_table->num_entries = table->num_entries;
3868 3875
3869 return 0; 3876 return 0;
@@ -3989,7 +3996,7 @@ int tonga_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
3989 table = kzalloc(sizeof(pp_atomctrl_mc_reg_table), GFP_KERNEL); 3996 table = kzalloc(sizeof(pp_atomctrl_mc_reg_table), GFP_KERNEL);
3990 3997
3991 if (NULL == table) 3998 if (NULL == table)
3992 return -1; 3999 return -ENOMEM;
3993 4000
3994 /* Program additional LP registers that are no longer programmed by VBIOS */ 4001 /* Program additional LP registers that are no longer programmed by VBIOS */
3995 cgs_write_register(hwmgr->device, mmMC_SEQ_RAS_TIMING_LP, cgs_read_register(hwmgr->device, mmMC_SEQ_RAS_TIMING)); 4002 cgs_write_register(hwmgr->device, mmMC_SEQ_RAS_TIMING_LP, cgs_read_register(hwmgr->device, mmMC_SEQ_RAS_TIMING));
@@ -5150,7 +5157,7 @@ static int tonga_get_pp_table_entry(struct pp_hwmgr *hwmgr,
5150static void 5157static void
5151tonga_print_current_perforce_level(struct pp_hwmgr *hwmgr, struct seq_file *m) 5158tonga_print_current_perforce_level(struct pp_hwmgr *hwmgr, struct seq_file *m)
5152{ 5159{
5153 uint32_t sclk, mclk, active_percent; 5160 uint32_t sclk, mclk, activity_percent;
5154 uint32_t offset; 5161 uint32_t offset;
5155 struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend); 5162 struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
5156 5163
@@ -5165,11 +5172,11 @@ tonga_print_current_perforce_level(struct pp_hwmgr *hwmgr, struct seq_file *m)
5165 5172
5166 5173
5167 offset = data->soft_regs_start + offsetof(SMU72_SoftRegisters, AverageGraphicsActivity); 5174 offset = data->soft_regs_start + offsetof(SMU72_SoftRegisters, AverageGraphicsActivity);
5168 active_percent = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__SMC, offset); 5175 activity_percent = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__SMC, offset);
5169 active_percent += 80; 5176 activity_percent += 0x80;
5170 active_percent >>= 8; 5177 activity_percent >>= 8;
5171 5178
5172 seq_printf(m, "\n [GPU load]: %u%%\n\n", active_percent > 100 ? 100 : active_percent); 5179 seq_printf(m, "\n [GPU load]: %u%%\n\n", activity_percent > 100 ? 100 : activity_percent);
5173 5180
5174} 5181}
5175 5182
@@ -5470,7 +5477,6 @@ static int tonga_generate_dpm_level_enable_mask(struct pp_hwmgr *hwmgr, const vo
5470 struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend); 5477 struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
5471 const struct tonga_power_state *tonga_ps = cast_const_phw_tonga_power_state(states->pnew_state); 5478 const struct tonga_power_state *tonga_ps = cast_const_phw_tonga_power_state(states->pnew_state);
5472 5479
5473
5474 result = tonga_trim_dpm_states(hwmgr, tonga_ps); 5480 result = tonga_trim_dpm_states(hwmgr, tonga_ps);
5475 if (0 != result) 5481 if (0 != result)
5476 return result; 5482 return result;
@@ -5732,7 +5738,7 @@ static int tonga_set_max_fan_pwm_output(struct pp_hwmgr *hwmgr, uint16_t us_max_
5732 if (phm_is_hw_access_blocked(hwmgr)) 5738 if (phm_is_hw_access_blocked(hwmgr))
5733 return 0; 5739 return 0;
5734 5740
5735 return (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanPwmMax, us_max_fan_pwm) ? 0 : -EINVAL); 5741 return (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanPwmMax, us_max_fan_pwm) ? 0 : -1);
5736} 5742}
5737 5743
5738int tonga_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr) 5744int tonga_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr)
@@ -5826,7 +5832,7 @@ static int tonga_set_max_fan_rpm_output(struct pp_hwmgr *hwmgr, uint16_t us_max_
5826 if (phm_is_hw_access_blocked(hwmgr)) 5832 if (phm_is_hw_access_blocked(hwmgr))
5827 return 0; 5833 return 0;
5828 5834
5829 return (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanRpmMax, us_max_fan_pwm) ? 0 : -EINVAL); 5835 return (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanRpmMax, us_max_fan_pwm) ? 0 : -1);
5830} 5836}
5831 5837
5832uint32_t tonga_get_xclk(struct pp_hwmgr *hwmgr) 5838uint32_t tonga_get_xclk(struct pp_hwmgr *hwmgr)
@@ -5962,7 +5968,7 @@ int tonga_check_states_equal(struct pp_hwmgr *hwmgr, const struct pp_hw_power_st
5962 const struct tonga_power_state *psb = cast_const_phw_tonga_power_state(pstate2); 5968 const struct tonga_power_state *psb = cast_const_phw_tonga_power_state(pstate2);
5963 int i; 5969 int i;
5964 5970
5965 if (pstate1 == NULL || pstate2 == NULL || equal == NULL) 5971 if (equal == NULL || psa == NULL || psb == NULL)
5966 return -EINVAL; 5972 return -EINVAL;
5967 5973
5968 /* If the two states don't even have the same number of performance levels they cannot be the same state. */ 5974 /* If the two states don't even have the same number of performance levels they cannot be the same state. */
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c
index ae216fe8547d..34f4bef3691f 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c
@@ -168,7 +168,7 @@ static int get_vddc_lookup_table(
168 kzalloc(table_size, GFP_KERNEL); 168 kzalloc(table_size, GFP_KERNEL);
169 169
170 if (NULL == table) 170 if (NULL == table)
171 return -1; 171 return -ENOMEM;
172 172
173 memset(table, 0x00, table_size); 173 memset(table, 0x00, table_size);
174 174
@@ -206,7 +206,7 @@ static int get_platform_power_management_table(
206 (struct phm_ppt_v1_information *)(hwmgr->pptable); 206 (struct phm_ppt_v1_information *)(hwmgr->pptable);
207 207
208 if (NULL == ptr) 208 if (NULL == ptr)
209 return -1; 209 return -ENOMEM;
210 210
211 ptr->ppm_design 211 ptr->ppm_design
212 = atom_ppm_table->ucPpmDesign; 212 = atom_ppm_table->ucPpmDesign;
@@ -327,7 +327,7 @@ static int get_valid_clk(
327 table = (struct phm_clock_array *)kzalloc(table_size, GFP_KERNEL); 327 table = (struct phm_clock_array *)kzalloc(table_size, GFP_KERNEL);
328 328
329 if (NULL == table) 329 if (NULL == table)
330 return -1; 330 return -ENOMEM;
331 331
332 memset(table, 0x00, table_size); 332 memset(table, 0x00, table_size);
333 333
@@ -378,7 +378,7 @@ static int get_mclk_voltage_dependency_table(
378 kzalloc(table_size, GFP_KERNEL); 378 kzalloc(table_size, GFP_KERNEL);
379 379
380 if (NULL == mclk_table) 380 if (NULL == mclk_table)
381 return -1; 381 return -ENOMEM;
382 382
383 memset(mclk_table, 0x00, table_size); 383 memset(mclk_table, 0x00, table_size);
384 384
@@ -421,7 +421,7 @@ static int get_sclk_voltage_dependency_table(
421 kzalloc(table_size, GFP_KERNEL); 421 kzalloc(table_size, GFP_KERNEL);
422 422
423 if (NULL == sclk_table) 423 if (NULL == sclk_table)
424 return -1; 424 return -ENOMEM;
425 425
426 memset(sclk_table, 0x00, table_size); 426 memset(sclk_table, 0x00, table_size);
427 427
@@ -464,7 +464,7 @@ static int get_pcie_table(
464 pcie_table = (phm_ppt_v1_pcie_table *)kzalloc(table_size, GFP_KERNEL); 464 pcie_table = (phm_ppt_v1_pcie_table *)kzalloc(table_size, GFP_KERNEL);
465 465
466 if (NULL == pcie_table) 466 if (NULL == pcie_table)
467 return -1; 467 return -ENOMEM;
468 468
469 memset(pcie_table, 0x00, table_size); 469 memset(pcie_table, 0x00, table_size);
470 470
@@ -506,14 +506,14 @@ static int get_cac_tdp_table(
506 tdp_table = kzalloc(table_size, GFP_KERNEL); 506 tdp_table = kzalloc(table_size, GFP_KERNEL);
507 507
508 if (NULL == tdp_table) 508 if (NULL == tdp_table)
509 return -1; 509 return -ENOMEM;
510 510
511 memset(tdp_table, 0x00, table_size); 511 memset(tdp_table, 0x00, table_size);
512 512
513 hwmgr->dyn_state.cac_dtp_table = kzalloc(table_size, GFP_KERNEL); 513 hwmgr->dyn_state.cac_dtp_table = kzalloc(table_size, GFP_KERNEL);
514 514
515 if (NULL == hwmgr->dyn_state.cac_dtp_table) 515 if (NULL == hwmgr->dyn_state.cac_dtp_table)
516 return -1; 516 return -ENOMEM;
517 517
518 memset(hwmgr->dyn_state.cac_dtp_table, 0x00, table_size); 518 memset(hwmgr->dyn_state.cac_dtp_table, 0x00, table_size);
519 519
@@ -614,7 +614,7 @@ static int get_mm_clock_voltage_table(
614 kzalloc(table_size, GFP_KERNEL); 614 kzalloc(table_size, GFP_KERNEL);
615 615
616 if (NULL == mm_table) 616 if (NULL == mm_table)
617 return -1; 617 return -ENOMEM;
618 618
619 memset(mm_table, 0x00, table_size); 619 memset(mm_table, 0x00, table_size);
620 620
@@ -943,7 +943,7 @@ int tonga_pp_tables_initialize(struct pp_hwmgr *hwmgr)
943 hwmgr->pptable = kzalloc(sizeof(struct phm_ppt_v1_information), GFP_KERNEL); 943 hwmgr->pptable = kzalloc(sizeof(struct phm_ppt_v1_information), GFP_KERNEL);
944 944
945 PP_ASSERT_WITH_CODE((NULL != hwmgr->pptable), 945 PP_ASSERT_WITH_CODE((NULL != hwmgr->pptable),
946 "Failed to allocate hwmgr->pptable!", return -1); 946 "Failed to allocate hwmgr->pptable!", return -ENOMEM);
947 947
948 memset(hwmgr->pptable, 0x00, sizeof(struct phm_ppt_v1_information)); 948 memset(hwmgr->pptable, 0x00, sizeof(struct phm_ppt_v1_information));
949 949
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_thermal.c
index 2e159b003e71..a188174747c9 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_thermal.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_thermal.c
@@ -20,7 +20,7 @@
20 * OTHER DEALINGS IN THE SOFTWARE. 20 * OTHER DEALINGS IN THE SOFTWARE.
21 * 21 *
22 */ 22 */
23 23#include <asm/div64.h>
24#include "tonga_thermal.h" 24#include "tonga_thermal.h"
25#include "tonga_hwmgr.h" 25#include "tonga_hwmgr.h"
26#include "tonga_smumgr.h" 26#include "tonga_smumgr.h"
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h
index a503306c3d0e..91795efe1336 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h
@@ -379,5 +379,7 @@ extern int phm_get_dal_power_level(struct pp_hwmgr *hwmgr,
379 379
380extern int phm_set_cpu_power_state(struct pp_hwmgr *hwmgr); 380extern int phm_set_cpu_power_state(struct pp_hwmgr *hwmgr);
381 381
382extern int phm_power_down_asic(struct pp_hwmgr *hwmgr);
383
382#endif /* _HARDWARE_MANAGER_H_ */ 384#endif /* _HARDWARE_MANAGER_H_ */
383 385
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index eb0f1b22d42d..aeaa3dbba525 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -325,7 +325,8 @@ struct pp_hwmgr_func {
325 bool cc6_disable, bool pstate_disable, 325 bool cc6_disable, bool pstate_disable,
326 bool pstate_switch_disable); 326 bool pstate_switch_disable);
327 int (*get_dal_power_level)(struct pp_hwmgr *hwmgr, 327 int (*get_dal_power_level)(struct pp_hwmgr *hwmgr,
328 struct amd_pp_dal_clock_info*info); 328 struct amd_pp_dal_clock_info *info);
329 int (*power_off_asic)(struct pp_hwmgr *hwmgr);
329}; 330};
330 331
331struct pp_table_func { 332struct pp_table_func {
@@ -576,9 +577,10 @@ struct pp_hwmgr {
576 void *pptable; 577 void *pptable;
577 struct phm_platform_descriptor platform_descriptor; 578 struct phm_platform_descriptor platform_descriptor;
578 void *backend; 579 void *backend;
579 enum PP_DAL_POWERLEVEL dal_power_level; 580 enum PP_DAL_POWERLEVEL dal_power_level;
580 struct phm_dynamic_state_info dyn_state; 581 struct phm_dynamic_state_info dyn_state;
581 struct phm_runtime_table_header setup_asic; 582 struct phm_runtime_table_header setup_asic;
583 struct phm_runtime_table_header power_down_asic;
582 struct phm_runtime_table_header disable_dynamic_state_management; 584 struct phm_runtime_table_header disable_dynamic_state_management;
583 struct phm_runtime_table_header enable_dynamic_state_management; 585 struct phm_runtime_table_header enable_dynamic_state_management;
584 struct phm_runtime_table_header set_power_state; 586 struct phm_runtime_table_header set_power_state;
diff --git a/drivers/gpu/drm/amd/powerplay/inc/pp_instance.h b/drivers/gpu/drm/amd/powerplay/inc/pp_instance.h
index 7b60b617dff6..4d8ed1f33de4 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/pp_instance.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/pp_instance.h
@@ -27,7 +27,10 @@
27#include "hwmgr.h" 27#include "hwmgr.h"
28#include "eventmgr.h" 28#include "eventmgr.h"
29 29
30#define PP_VALID 0x1F1F1F1F
31
30struct pp_instance { 32struct pp_instance {
33 uint32_t pp_valid;
31 struct pp_smumgr *smu_mgr; 34 struct pp_smumgr *smu_mgr;
32 struct pp_hwmgr *hwmgr; 35 struct pp_hwmgr *hwmgr;
33 struct pp_eventmgr *eventmgr; 36 struct pp_eventmgr *eventmgr;
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
index e74023bd4e0d..873a8d264d5c 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
@@ -818,7 +818,7 @@ static int cz_smu_fini(struct pp_smumgr *smumgr)
818 return -EINVAL; 818 return -EINVAL;
819 819
820 cz_smu = (struct cz_smumgr *)smumgr->backend; 820 cz_smu = (struct cz_smumgr *)smumgr->backend;
821 if (!cz_smu) { 821 if (cz_smu) {
822 cgs_free_gpu_mem(smumgr->device, 822 cgs_free_gpu_mem(smumgr->device,
823 cz_smu->toc_buffer.handle); 823 cz_smu->toc_buffer.handle);
824 cgs_free_gpu_mem(smumgr->device, 824 cgs_free_gpu_mem(smumgr->device,
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
index 45997e609fd6..cdbb9f89bf36 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
@@ -228,9 +228,9 @@ int fiji_send_msg_to_smc(struct pp_smumgr *smumgr, uint16_t msg)
228 } 228 }
229 229
230 cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg); 230 cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg);
231 SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0); 231 SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0);
232 232
233 return 0; 233 return 0;
234} 234}
235 235
236/** 236/**
@@ -557,7 +557,7 @@ static int fiji_request_smu_specific_fw_load(struct pp_smumgr *smumgr, uint32_t
557 /* For non-virtualization cases, 557 /* For non-virtualization cases,
558 * SMU loads all FWs at once in fiji_request_smu_load_fw. 558 * SMU loads all FWs at once in fiji_request_smu_load_fw.
559 */ 559 */
560 return 0; 560 return 0;
561} 561}
562 562
563static int fiji_start_smu_in_protection_mode(struct pp_smumgr *smumgr) 563static int fiji_start_smu_in_protection_mode(struct pp_smumgr *smumgr)
@@ -723,7 +723,7 @@ static int fiji_start_avfs_btc(struct pp_smumgr *smumgr)
723 /* clear reset */ 723 /* clear reset */
724 cgs_write_register(smumgr->device, mmGRBM_SOFT_RESET, 0); 724 cgs_write_register(smumgr->device, mmGRBM_SOFT_RESET, 0);
725 725
726 return result; 726 return result;
727} 727}
728 728
729int fiji_setup_pm_fuse_for_avfs(struct pp_smumgr *smumgr) 729int fiji_setup_pm_fuse_for_avfs(struct pp_smumgr *smumgr)
@@ -1033,7 +1033,7 @@ int fiji_smum_init(struct pp_smumgr *smumgr)
1033 fiji_smu = kzalloc(sizeof(struct fiji_smumgr), GFP_KERNEL); 1033 fiji_smu = kzalloc(sizeof(struct fiji_smumgr), GFP_KERNEL);
1034 1034
1035 if (fiji_smu == NULL) 1035 if (fiji_smu == NULL)
1036 return -1; 1036 return -ENOMEM;
1037 1037
1038 smumgr->backend = fiji_smu; 1038 smumgr->backend = fiji_smu;
1039 smumgr->smumgr_funcs = &fiji_smu_funcs; 1039 smumgr->smumgr_funcs = &fiji_smu_funcs;
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
index 62ff76010aa6..ebdb43a8daef 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
@@ -199,7 +199,7 @@ static int tonga_send_msg_to_smc(struct pp_smumgr *smumgr, uint16_t msg)
199 PP_ASSERT_WITH_CODE( 199 PP_ASSERT_WITH_CODE(
200 1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP), 200 1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP),
201 "Failed to send Previous Message.", 201 "Failed to send Previous Message.",
202 return 1); 202 );
203 203
204 cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg); 204 cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg);
205 205
@@ -207,7 +207,7 @@ static int tonga_send_msg_to_smc(struct pp_smumgr *smumgr, uint16_t msg)
207 PP_ASSERT_WITH_CODE( 207 PP_ASSERT_WITH_CODE(
208 1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP), 208 1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP),
209 "Failed to send Message.", 209 "Failed to send Message.",
210 return 1); 210 );
211 211
212 return 0; 212 return 0;
213} 213}
@@ -229,7 +229,7 @@ static int tonga_send_msg_to_smc_without_waiting
229 PP_ASSERT_WITH_CODE( 229 PP_ASSERT_WITH_CODE(
230 1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP), 230 1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP),
231 "Failed to send Previous Message.", 231 "Failed to send Previous Message.",
232 return 0); 232 );
233 cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg); 233 cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg);
234 234
235 return 0; 235 return 0;
@@ -810,7 +810,7 @@ int tonga_smum_init(struct pp_smumgr *smumgr)
810 tonga_smu = kzalloc(sizeof(struct tonga_smumgr), GFP_KERNEL); 810 tonga_smu = kzalloc(sizeof(struct tonga_smumgr), GFP_KERNEL);
811 811
812 if (tonga_smu == NULL) 812 if (tonga_smu == NULL)
813 return -1; 813 return -ENOMEM;
814 814
815 smumgr->backend = tonga_smu; 815 smumgr->backend = tonga_smu;
816 smumgr->smumgr_funcs = &tonga_smu_funcs; 816 smumgr->smumgr_funcs = &tonga_smu_funcs;
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index c5a942b15d63..6ed90a2437e5 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -978,17 +978,17 @@ static struct drm_dp_mst_port *drm_dp_get_port(struct drm_dp_mst_branch *mstb, u
978static u8 drm_dp_calculate_rad(struct drm_dp_mst_port *port, 978static u8 drm_dp_calculate_rad(struct drm_dp_mst_port *port,
979 u8 *rad) 979 u8 *rad)
980{ 980{
981 int lct = port->parent->lct; 981 int parent_lct = port->parent->lct;
982 int shift = 4; 982 int shift = 4;
983 int idx = lct / 2; 983 int idx = (parent_lct - 1) / 2;
984 if (lct > 1) { 984 if (parent_lct > 1) {
985 memcpy(rad, port->parent->rad, idx); 985 memcpy(rad, port->parent->rad, idx + 1);
986 shift = (lct % 2) ? 4 : 0; 986 shift = (parent_lct % 2) ? 4 : 0;
987 } else 987 } else
988 rad[0] = 0; 988 rad[0] = 0;
989 989
990 rad[idx] |= port->port_num << shift; 990 rad[idx] |= port->port_num << shift;
991 return lct + 1; 991 return parent_lct + 1;
992} 992}
993 993
994/* 994/*
@@ -1044,7 +1044,7 @@ static void build_mst_prop_path(const struct drm_dp_mst_branch *mstb,
1044 snprintf(proppath, proppath_size, "mst:%d", mstb->mgr->conn_base_id); 1044 snprintf(proppath, proppath_size, "mst:%d", mstb->mgr->conn_base_id);
1045 for (i = 0; i < (mstb->lct - 1); i++) { 1045 for (i = 0; i < (mstb->lct - 1); i++) {
1046 int shift = (i % 2) ? 0 : 4; 1046 int shift = (i % 2) ? 0 : 4;
1047 int port_num = mstb->rad[i / 2] >> shift; 1047 int port_num = (mstb->rad[i / 2] >> shift) & 0xf;
1048 snprintf(temp, sizeof(temp), "-%d", port_num); 1048 snprintf(temp, sizeof(temp), "-%d", port_num);
1049 strlcat(proppath, temp, proppath_size); 1049 strlcat(proppath, temp, proppath_size);
1050 } 1050 }
@@ -1195,7 +1195,7 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
1195 1195
1196 for (i = 0; i < lct - 1; i++) { 1196 for (i = 0; i < lct - 1; i++) {
1197 int shift = (i % 2) ? 0 : 4; 1197 int shift = (i % 2) ? 0 : 4;
1198 int port_num = rad[i / 2] >> shift; 1198 int port_num = (rad[i / 2] >> shift) & 0xf;
1199 1199
1200 list_for_each_entry(port, &mstb->ports, next) { 1200 list_for_each_entry(port, &mstb->ports, next) {
1201 if (port->port_num == port_num) { 1201 if (port->port_num == port_num) {
@@ -1215,6 +1215,50 @@ out:
1215 return mstb; 1215 return mstb;
1216} 1216}
1217 1217
1218static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper(
1219 struct drm_dp_mst_branch *mstb,
1220 uint8_t *guid)
1221{
1222 struct drm_dp_mst_branch *found_mstb;
1223 struct drm_dp_mst_port *port;
1224
1225 list_for_each_entry(port, &mstb->ports, next) {
1226 if (!port->mstb)
1227 continue;
1228
1229 if (port->guid_valid && memcmp(port->guid, guid, 16) == 0)
1230 return port->mstb;
1231
1232 found_mstb = get_mst_branch_device_by_guid_helper(port->mstb, guid);
1233
1234 if (found_mstb)
1235 return found_mstb;
1236 }
1237
1238 return NULL;
1239}
1240
1241static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device_by_guid(
1242 struct drm_dp_mst_topology_mgr *mgr,
1243 uint8_t *guid)
1244{
1245 struct drm_dp_mst_branch *mstb;
1246
1247 /* find the port by iterating down */
1248 mutex_lock(&mgr->lock);
1249
1250 if (mgr->guid_valid && memcmp(mgr->guid, guid, 16) == 0)
1251 mstb = mgr->mst_primary;
1252 else
1253 mstb = get_mst_branch_device_by_guid_helper(mgr->mst_primary, guid);
1254
1255 if (mstb)
1256 kref_get(&mstb->kref);
1257
1258 mutex_unlock(&mgr->lock);
1259 return mstb;
1260}
1261
1218static void drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr *mgr, 1262static void drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
1219 struct drm_dp_mst_branch *mstb) 1263 struct drm_dp_mst_branch *mstb)
1220{ 1264{
@@ -1325,6 +1369,7 @@ static int set_hdr_from_dst_qlock(struct drm_dp_sideband_msg_hdr *hdr,
1325 struct drm_dp_sideband_msg_tx *txmsg) 1369 struct drm_dp_sideband_msg_tx *txmsg)
1326{ 1370{
1327 struct drm_dp_mst_branch *mstb = txmsg->dst; 1371 struct drm_dp_mst_branch *mstb = txmsg->dst;
1372 u8 req_type;
1328 1373
1329 /* both msg slots are full */ 1374 /* both msg slots are full */
1330 if (txmsg->seqno == -1) { 1375 if (txmsg->seqno == -1) {
@@ -1341,7 +1386,13 @@ static int set_hdr_from_dst_qlock(struct drm_dp_sideband_msg_hdr *hdr,
1341 txmsg->seqno = 1; 1386 txmsg->seqno = 1;
1342 mstb->tx_slots[txmsg->seqno] = txmsg; 1387 mstb->tx_slots[txmsg->seqno] = txmsg;
1343 } 1388 }
1344 hdr->broadcast = 0; 1389
1390 req_type = txmsg->msg[0] & 0x7f;
1391 if (req_type == DP_CONNECTION_STATUS_NOTIFY ||
1392 req_type == DP_RESOURCE_STATUS_NOTIFY)
1393 hdr->broadcast = 1;
1394 else
1395 hdr->broadcast = 0;
1345 hdr->path_msg = txmsg->path_msg; 1396 hdr->path_msg = txmsg->path_msg;
1346 hdr->lct = mstb->lct; 1397 hdr->lct = mstb->lct;
1347 hdr->lcr = mstb->lct - 1; 1398 hdr->lcr = mstb->lct - 1;
@@ -1443,26 +1494,18 @@ static void process_single_down_tx_qlock(struct drm_dp_mst_topology_mgr *mgr)
1443} 1494}
1444 1495
1445/* called holding qlock */ 1496/* called holding qlock */
1446static void process_single_up_tx_qlock(struct drm_dp_mst_topology_mgr *mgr) 1497static void process_single_up_tx_qlock(struct drm_dp_mst_topology_mgr *mgr,
1498 struct drm_dp_sideband_msg_tx *txmsg)
1447{ 1499{
1448 struct drm_dp_sideband_msg_tx *txmsg;
1449 int ret; 1500 int ret;
1450 1501
1451 /* construct a chunk from the first msg in the tx_msg queue */ 1502 /* construct a chunk from the first msg in the tx_msg queue */
1452 if (list_empty(&mgr->tx_msg_upq)) {
1453 mgr->tx_up_in_progress = false;
1454 return;
1455 }
1456
1457 txmsg = list_first_entry(&mgr->tx_msg_upq, struct drm_dp_sideband_msg_tx, next);
1458 ret = process_single_tx_qlock(mgr, txmsg, true); 1503 ret = process_single_tx_qlock(mgr, txmsg, true);
1459 if (ret == 1) { 1504
1460 /* up txmsgs aren't put in slots - so free after we send it */ 1505 if (ret != 1)
1461 list_del(&txmsg->next);
1462 kfree(txmsg);
1463 } else if (ret)
1464 DRM_DEBUG_KMS("failed to send msg in q %d\n", ret); 1506 DRM_DEBUG_KMS("failed to send msg in q %d\n", ret);
1465 mgr->tx_up_in_progress = true; 1507
1508 txmsg->dst->tx_slots[txmsg->seqno] = NULL;
1466} 1509}
1467 1510
1468static void drm_dp_queue_down_tx(struct drm_dp_mst_topology_mgr *mgr, 1511static void drm_dp_queue_down_tx(struct drm_dp_mst_topology_mgr *mgr,
@@ -1856,11 +1899,12 @@ static int drm_dp_send_up_ack_reply(struct drm_dp_mst_topology_mgr *mgr,
1856 drm_dp_encode_up_ack_reply(txmsg, req_type); 1899 drm_dp_encode_up_ack_reply(txmsg, req_type);
1857 1900
1858 mutex_lock(&mgr->qlock); 1901 mutex_lock(&mgr->qlock);
1859 list_add_tail(&txmsg->next, &mgr->tx_msg_upq); 1902
1860 if (!mgr->tx_up_in_progress) { 1903 process_single_up_tx_qlock(mgr, txmsg);
1861 process_single_up_tx_qlock(mgr); 1904
1862 }
1863 mutex_unlock(&mgr->qlock); 1905 mutex_unlock(&mgr->qlock);
1906
1907 kfree(txmsg);
1864 return 0; 1908 return 0;
1865} 1909}
1866 1910
@@ -2157,28 +2201,50 @@ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)
2157 2201
2158 if (mgr->up_req_recv.have_eomt) { 2202 if (mgr->up_req_recv.have_eomt) {
2159 struct drm_dp_sideband_msg_req_body msg; 2203 struct drm_dp_sideband_msg_req_body msg;
2160 struct drm_dp_mst_branch *mstb; 2204 struct drm_dp_mst_branch *mstb = NULL;
2161 bool seqno; 2205 bool seqno;
2162 mstb = drm_dp_get_mst_branch_device(mgr, 2206
2163 mgr->up_req_recv.initial_hdr.lct, 2207 if (!mgr->up_req_recv.initial_hdr.broadcast) {
2164 mgr->up_req_recv.initial_hdr.rad); 2208 mstb = drm_dp_get_mst_branch_device(mgr,
2165 if (!mstb) { 2209 mgr->up_req_recv.initial_hdr.lct,
2166 DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct); 2210 mgr->up_req_recv.initial_hdr.rad);
2167 memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx)); 2211 if (!mstb) {
2168 return 0; 2212 DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct);
2213 memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
2214 return 0;
2215 }
2169 } 2216 }
2170 2217
2171 seqno = mgr->up_req_recv.initial_hdr.seqno; 2218 seqno = mgr->up_req_recv.initial_hdr.seqno;
2172 drm_dp_sideband_parse_req(&mgr->up_req_recv, &msg); 2219 drm_dp_sideband_parse_req(&mgr->up_req_recv, &msg);
2173 2220
2174 if (msg.req_type == DP_CONNECTION_STATUS_NOTIFY) { 2221 if (msg.req_type == DP_CONNECTION_STATUS_NOTIFY) {
2175 drm_dp_send_up_ack_reply(mgr, mstb, msg.req_type, seqno, false); 2222 drm_dp_send_up_ack_reply(mgr, mgr->mst_primary, msg.req_type, seqno, false);
2223
2224 if (!mstb)
2225 mstb = drm_dp_get_mst_branch_device_by_guid(mgr, msg.u.conn_stat.guid);
2226
2227 if (!mstb) {
2228 DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct);
2229 memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
2230 return 0;
2231 }
2232
2176 drm_dp_update_port(mstb, &msg.u.conn_stat); 2233 drm_dp_update_port(mstb, &msg.u.conn_stat);
2177 DRM_DEBUG_KMS("Got CSN: pn: %d ldps:%d ddps: %d mcs: %d ip: %d pdt: %d\n", msg.u.conn_stat.port_number, msg.u.conn_stat.legacy_device_plug_status, msg.u.conn_stat.displayport_device_plug_status, msg.u.conn_stat.message_capability_status, msg.u.conn_stat.input_port, msg.u.conn_stat.peer_device_type); 2234 DRM_DEBUG_KMS("Got CSN: pn: %d ldps:%d ddps: %d mcs: %d ip: %d pdt: %d\n", msg.u.conn_stat.port_number, msg.u.conn_stat.legacy_device_plug_status, msg.u.conn_stat.displayport_device_plug_status, msg.u.conn_stat.message_capability_status, msg.u.conn_stat.input_port, msg.u.conn_stat.peer_device_type);
2178 (*mgr->cbs->hotplug)(mgr); 2235 (*mgr->cbs->hotplug)(mgr);
2179 2236
2180 } else if (msg.req_type == DP_RESOURCE_STATUS_NOTIFY) { 2237 } else if (msg.req_type == DP_RESOURCE_STATUS_NOTIFY) {
2181 drm_dp_send_up_ack_reply(mgr, mstb, msg.req_type, seqno, false); 2238 drm_dp_send_up_ack_reply(mgr, mgr->mst_primary, msg.req_type, seqno, false);
2239 if (!mstb)
2240 mstb = drm_dp_get_mst_branch_device_by_guid(mgr, msg.u.resource_stat.guid);
2241
2242 if (!mstb) {
2243 DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct);
2244 memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
2245 return 0;
2246 }
2247
2182 DRM_DEBUG_KMS("Got RSN: pn: %d avail_pbn %d\n", msg.u.resource_stat.port_number, msg.u.resource_stat.available_pbn); 2248 DRM_DEBUG_KMS("Got RSN: pn: %d avail_pbn %d\n", msg.u.resource_stat.port_number, msg.u.resource_stat.available_pbn);
2183 } 2249 }
2184 2250
@@ -2770,7 +2836,6 @@ int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr,
2770 mutex_init(&mgr->qlock); 2836 mutex_init(&mgr->qlock);
2771 mutex_init(&mgr->payload_lock); 2837 mutex_init(&mgr->payload_lock);
2772 mutex_init(&mgr->destroy_connector_lock); 2838 mutex_init(&mgr->destroy_connector_lock);
2773 INIT_LIST_HEAD(&mgr->tx_msg_upq);
2774 INIT_LIST_HEAD(&mgr->tx_msg_downq); 2839 INIT_LIST_HEAD(&mgr->tx_msg_downq);
2775 INIT_LIST_HEAD(&mgr->destroy_connector_list); 2840 INIT_LIST_HEAD(&mgr->destroy_connector_list);
2776 INIT_WORK(&mgr->work, drm_dp_mst_link_probe_work); 2841 INIT_WORK(&mgr->work, drm_dp_mst_link_probe_work);
diff --git a/drivers/gpu/drm/nouveau/Kbuild b/drivers/gpu/drm/nouveau/Kbuild
index a34b437dbc8f..2527bf4ca5d9 100644
--- a/drivers/gpu/drm/nouveau/Kbuild
+++ b/drivers/gpu/drm/nouveau/Kbuild
@@ -24,7 +24,6 @@ nouveau-y += nouveau_hwmon.o
24nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o 24nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
25nouveau-y += nouveau_nvif.o 25nouveau-y += nouveau_nvif.o
26nouveau-$(CONFIG_NOUVEAU_PLATFORM_DRIVER) += nouveau_platform.o 26nouveau-$(CONFIG_NOUVEAU_PLATFORM_DRIVER) += nouveau_platform.o
27nouveau-y += nouveau_sysfs.o
28nouveau-y += nouveau_usif.o # userspace <-> nvif 27nouveau-y += nouveau_usif.o # userspace <-> nvif
29nouveau-y += nouveau_vga.o 28nouveau-y += nouveau_vga.o
30 29
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0002.h b/drivers/gpu/drm/nouveau/include/nvif/cl0002.h
new file mode 100644
index 000000000000..6d72ed38da32
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0002.h
@@ -0,0 +1,66 @@
1#ifndef __NVIF_CL0002_H__
2#define __NVIF_CL0002_H__
3
4struct nv_dma_v0 {
5 __u8 version;
6#define NV_DMA_V0_TARGET_VM 0x00
7#define NV_DMA_V0_TARGET_VRAM 0x01
8#define NV_DMA_V0_TARGET_PCI 0x02
9#define NV_DMA_V0_TARGET_PCI_US 0x03
10#define NV_DMA_V0_TARGET_AGP 0x04
11 __u8 target;
12#define NV_DMA_V0_ACCESS_VM 0x00
13#define NV_DMA_V0_ACCESS_RD 0x01
14#define NV_DMA_V0_ACCESS_WR 0x02
15#define NV_DMA_V0_ACCESS_RDWR (NV_DMA_V0_ACCESS_RD | NV_DMA_V0_ACCESS_WR)
16 __u8 access;
17 __u8 pad03[5];
18 __u64 start;
19 __u64 limit;
20 /* ... chipset-specific class data */
21};
22
23struct nv50_dma_v0 {
24 __u8 version;
25#define NV50_DMA_V0_PRIV_VM 0x00
26#define NV50_DMA_V0_PRIV_US 0x01
27#define NV50_DMA_V0_PRIV__S 0x02
28 __u8 priv;
29#define NV50_DMA_V0_PART_VM 0x00
30#define NV50_DMA_V0_PART_256 0x01
31#define NV50_DMA_V0_PART_1KB 0x02
32 __u8 part;
33#define NV50_DMA_V0_COMP_NONE 0x00
34#define NV50_DMA_V0_COMP_1 0x01
35#define NV50_DMA_V0_COMP_2 0x02
36#define NV50_DMA_V0_COMP_VM 0x03
37 __u8 comp;
38#define NV50_DMA_V0_KIND_PITCH 0x00
39#define NV50_DMA_V0_KIND_VM 0x7f
40 __u8 kind;
41 __u8 pad05[3];
42};
43
44struct gf100_dma_v0 {
45 __u8 version;
46#define GF100_DMA_V0_PRIV_VM 0x00
47#define GF100_DMA_V0_PRIV_US 0x01
48#define GF100_DMA_V0_PRIV__S 0x02
49 __u8 priv;
50#define GF100_DMA_V0_KIND_PITCH 0x00
51#define GF100_DMA_V0_KIND_VM 0xff
52 __u8 kind;
53 __u8 pad03[5];
54};
55
56struct gf119_dma_v0 {
57 __u8 version;
58#define GF119_DMA_V0_PAGE_LP 0x00
59#define GF119_DMA_V0_PAGE_SP 0x01
60 __u8 page;
61#define GF119_DMA_V0_KIND_PITCH 0x00
62#define GF119_DMA_V0_KIND_VM 0xff
63 __u8 kind;
64 __u8 pad03[5];
65};
66#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0046.h b/drivers/gpu/drm/nouveau/include/nvif/cl0046.h
new file mode 100644
index 000000000000..a6a71f4ad91e
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0046.h
@@ -0,0 +1,28 @@
1#ifndef __NVIF_CL0046_H__
2#define __NVIF_CL0046_H__
3
4#define NV04_DISP_NTFY_VBLANK 0x00
5#define NV04_DISP_NTFY_CONN 0x01
6
7struct nv04_disp_mthd_v0 {
8 __u8 version;
9#define NV04_DISP_SCANOUTPOS 0x00
10 __u8 method;
11 __u8 head;
12 __u8 pad03[5];
13};
14
15struct nv04_disp_scanoutpos_v0 {
16 __u8 version;
17 __u8 pad01[7];
18 __s64 time[2];
19 __u16 vblanks;
20 __u16 vblanke;
21 __u16 vtotal;
22 __u16 vline;
23 __u16 hblanks;
24 __u16 hblanke;
25 __u16 htotal;
26 __u16 hline;
27};
28#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl006b.h b/drivers/gpu/drm/nouveau/include/nvif/cl006b.h
new file mode 100644
index 000000000000..309ab8a3d9e8
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl006b.h
@@ -0,0 +1,11 @@
1#ifndef __NVIF_CL006B_H__
2#define __NVIF_CL006B_H__
3
4struct nv03_channel_dma_v0 {
5 __u8 version;
6 __u8 chid;
7 __u8 pad02[2];
8 __u32 offset;
9 __u64 pushbuf;
10};
11#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl0080.h b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
new file mode 100644
index 000000000000..331620a52afa
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl0080.h
@@ -0,0 +1,45 @@
1#ifndef __NVIF_CL0080_H__
2#define __NVIF_CL0080_H__
3
4struct nv_device_v0 {
5 __u8 version;
6 __u8 pad01[7];
7 __u64 device; /* device identifier, ~0 for client default */
8};
9
10#define NV_DEVICE_V0_INFO 0x00
11#define NV_DEVICE_V0_TIME 0x01
12
13struct nv_device_info_v0 {
14 __u8 version;
15#define NV_DEVICE_INFO_V0_IGP 0x00
16#define NV_DEVICE_INFO_V0_PCI 0x01
17#define NV_DEVICE_INFO_V0_AGP 0x02
18#define NV_DEVICE_INFO_V0_PCIE 0x03
19#define NV_DEVICE_INFO_V0_SOC 0x04
20 __u8 platform;
21 __u16 chipset; /* from NV_PMC_BOOT_0 */
22 __u8 revision; /* from NV_PMC_BOOT_0 */
23#define NV_DEVICE_INFO_V0_TNT 0x01
24#define NV_DEVICE_INFO_V0_CELSIUS 0x02
25#define NV_DEVICE_INFO_V0_KELVIN 0x03
26#define NV_DEVICE_INFO_V0_RANKINE 0x04
27#define NV_DEVICE_INFO_V0_CURIE 0x05
28#define NV_DEVICE_INFO_V0_TESLA 0x06
29#define NV_DEVICE_INFO_V0_FERMI 0x07
30#define NV_DEVICE_INFO_V0_KEPLER 0x08
31#define NV_DEVICE_INFO_V0_MAXWELL 0x09
32 __u8 family;
33 __u8 pad06[2];
34 __u64 ram_size;
35 __u64 ram_user;
36 char chip[16];
37 char name[64];
38};
39
40struct nv_device_time_v0 {
41 __u8 version;
42 __u8 pad01[7];
43 __u64 time;
44};
45#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl506e.h b/drivers/gpu/drm/nouveau/include/nvif/cl506e.h
new file mode 100644
index 000000000000..aa94b8cf9679
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl506e.h
@@ -0,0 +1,12 @@
1#ifndef __NVIF_CL506E_H__
2#define __NVIF_CL506E_H__
3
4struct nv50_channel_dma_v0 {
5 __u8 version;
6 __u8 chid;
7 __u8 pad02[6];
8 __u64 vm;
9 __u64 pushbuf;
10 __u64 offset;
11};
12#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl506f.h b/drivers/gpu/drm/nouveau/include/nvif/cl506f.h
new file mode 100644
index 000000000000..3b7101966de4
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl506f.h
@@ -0,0 +1,13 @@
1#ifndef __NVIF_CL506F_H__
2#define __NVIF_CL506F_H__
3
4struct nv50_channel_gpfifo_v0 {
5 __u8 version;
6 __u8 chid;
7 __u8 pad02[2];
8 __u32 ilength;
9 __u64 ioffset;
10 __u64 pushbuf;
11 __u64 vm;
12};
13#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl5070.h b/drivers/gpu/drm/nouveau/include/nvif/cl5070.h
new file mode 100644
index 000000000000..d15c296b5f33
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl5070.h
@@ -0,0 +1,99 @@
1#ifndef __NVIF_CL5070_H__
2#define __NVIF_CL5070_H__
3
4#define NV50_DISP_MTHD 0x00
5
6struct nv50_disp_mthd_v0 {
7 __u8 version;
8#define NV50_DISP_SCANOUTPOS 0x00
9 __u8 method;
10 __u8 head;
11 __u8 pad03[5];
12};
13
14struct nv50_disp_scanoutpos_v0 {
15 __u8 version;
16 __u8 pad01[7];
17 __s64 time[2];
18 __u16 vblanks;
19 __u16 vblanke;
20 __u16 vtotal;
21 __u16 vline;
22 __u16 hblanks;
23 __u16 hblanke;
24 __u16 htotal;
25 __u16 hline;
26};
27
28struct nv50_disp_mthd_v1 {
29 __u8 version;
30#define NV50_DISP_MTHD_V1_DAC_PWR 0x10
31#define NV50_DISP_MTHD_V1_DAC_LOAD 0x11
32#define NV50_DISP_MTHD_V1_SOR_PWR 0x20
33#define NV50_DISP_MTHD_V1_SOR_HDA_ELD 0x21
34#define NV50_DISP_MTHD_V1_SOR_HDMI_PWR 0x22
35#define NV50_DISP_MTHD_V1_SOR_LVDS_SCRIPT 0x23
36#define NV50_DISP_MTHD_V1_SOR_DP_PWR 0x24
37#define NV50_DISP_MTHD_V1_PIOR_PWR 0x30
38 __u8 method;
39 __u16 hasht;
40 __u16 hashm;
41 __u8 pad06[2];
42};
43
44struct nv50_disp_dac_pwr_v0 {
45 __u8 version;
46 __u8 state;
47 __u8 data;
48 __u8 vsync;
49 __u8 hsync;
50 __u8 pad05[3];
51};
52
53struct nv50_disp_dac_load_v0 {
54 __u8 version;
55 __u8 load;
56 __u8 pad02[2];
57 __u32 data;
58};
59
60struct nv50_disp_sor_pwr_v0 {
61 __u8 version;
62 __u8 state;
63 __u8 pad02[6];
64};
65
66struct nv50_disp_sor_hda_eld_v0 {
67 __u8 version;
68 __u8 pad01[7];
69 __u8 data[];
70};
71
72struct nv50_disp_sor_hdmi_pwr_v0 {
73 __u8 version;
74 __u8 state;
75 __u8 max_ac_packet;
76 __u8 rekey;
77 __u8 pad04[4];
78};
79
80struct nv50_disp_sor_lvds_script_v0 {
81 __u8 version;
82 __u8 pad01[1];
83 __u16 script;
84 __u8 pad04[4];
85};
86
87struct nv50_disp_sor_dp_pwr_v0 {
88 __u8 version;
89 __u8 state;
90 __u8 pad02[6];
91};
92
93struct nv50_disp_pior_pwr_v0 {
94 __u8 version;
95 __u8 state;
96 __u8 type;
97 __u8 pad03[5];
98};
99#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl507a.h b/drivers/gpu/drm/nouveau/include/nvif/cl507a.h
new file mode 100644
index 000000000000..12e0643b78bd
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl507a.h
@@ -0,0 +1,11 @@
1#ifndef __NVIF_CL507A_H__
2#define __NVIF_CL507A_H__
3
4struct nv50_disp_cursor_v0 {
5 __u8 version;
6 __u8 head;
7 __u8 pad02[6];
8};
9
10#define NV50_DISP_CURSOR_V0_NTFY_UEVENT 0x00
11#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl507b.h b/drivers/gpu/drm/nouveau/include/nvif/cl507b.h
new file mode 100644
index 000000000000..99e9d8c47f60
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl507b.h
@@ -0,0 +1,11 @@
1#ifndef __NVIF_CL507B_H__
2#define __NVIF_CL507B_H__
3
4struct nv50_disp_overlay_v0 {
5 __u8 version;
6 __u8 head;
7 __u8 pad02[6];
8};
9
10#define NV50_DISP_OVERLAY_V0_NTFY_UEVENT 0x00
11#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl507c.h b/drivers/gpu/drm/nouveau/include/nvif/cl507c.h
new file mode 100644
index 000000000000..6af70dbdfd9f
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl507c.h
@@ -0,0 +1,12 @@
1#ifndef __NVIF_CL507C_H__
2#define __NVIF_CL507C_H__
3
4struct nv50_disp_base_channel_dma_v0 {
5 __u8 version;
6 __u8 head;
7 __u8 pad02[6];
8 __u64 pushbuf;
9};
10
11#define NV50_DISP_BASE_CHANNEL_DMA_V0_NTFY_UEVENT 0x00
12#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl507d.h b/drivers/gpu/drm/nouveau/include/nvif/cl507d.h
new file mode 100644
index 000000000000..5ab0c9e4c6a3
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl507d.h
@@ -0,0 +1,11 @@
1#ifndef __NVIF_CL507D_H__
2#define __NVIF_CL507D_H__
3
4struct nv50_disp_core_channel_dma_v0 {
5 __u8 version;
6 __u8 pad01[7];
7 __u64 pushbuf;
8};
9
10#define NV50_DISP_CORE_CHANNEL_DMA_V0_NTFY_UEVENT 0x00
11#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl507e.h b/drivers/gpu/drm/nouveau/include/nvif/cl507e.h
new file mode 100644
index 000000000000..c06209f3cac4
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl507e.h
@@ -0,0 +1,12 @@
1#ifndef __NVIF_CL507E_H__
2#define __NVIF_CL507E_H__
3
4struct nv50_disp_overlay_channel_dma_v0 {
5 __u8 version;
6 __u8 head;
7 __u8 pad02[6];
8 __u64 pushbuf;
9};
10
11#define NV50_DISP_OVERLAY_CHANNEL_DMA_V0_NTFY_UEVENT 0x00
12#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl826e.h b/drivers/gpu/drm/nouveau/include/nvif/cl826e.h
new file mode 100644
index 000000000000..05e6ef7cd190
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl826e.h
@@ -0,0 +1,14 @@
1#ifndef __NVIF_CL826E_H__
2#define __NVIF_CL826E_H__
3
4struct g82_channel_dma_v0 {
5 __u8 version;
6 __u8 chid;
7 __u8 pad02[6];
8 __u64 vm;
9 __u64 pushbuf;
10 __u64 offset;
11};
12
13#define G82_CHANNEL_DMA_V0_NTFY_UEVENT 0x00
14#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl826f.h b/drivers/gpu/drm/nouveau/include/nvif/cl826f.h
new file mode 100644
index 000000000000..cecafcb1e954
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl826f.h
@@ -0,0 +1,15 @@
1#ifndef __NVIF_CL826F_H__
2#define __NVIF_CL826F_H__
3
4struct g82_channel_gpfifo_v0 {
5 __u8 version;
6 __u8 chid;
7 __u8 pad02[2];
8 __u32 ilength;
9 __u64 ioffset;
10 __u64 pushbuf;
11 __u64 vm;
12};
13
14#define G82_CHANNEL_GPFIFO_V0_NTFY_UEVENT 0x00
15#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl906f.h b/drivers/gpu/drm/nouveau/include/nvif/cl906f.h
new file mode 100644
index 000000000000..2caf0838fcfd
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl906f.h
@@ -0,0 +1,14 @@
1#ifndef __NVIF_CL906F_H__
2#define __NVIF_CL906F_H__
3
4struct fermi_channel_gpfifo_v0 {
5 __u8 version;
6 __u8 chid;
7 __u8 pad02[2];
8 __u32 ilength;
9 __u64 ioffset;
10 __u64 vm;
11};
12
13#define FERMI_CHANNEL_GPFIFO_V0_NTFY_UEVENT 0x00
14#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cl9097.h b/drivers/gpu/drm/nouveau/include/nvif/cl9097.h
new file mode 100644
index 000000000000..4057676d2981
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cl9097.h
@@ -0,0 +1,44 @@
1#ifndef __NVIF_CL9097_H__
2#define __NVIF_CL9097_H__
3
4#define FERMI_A_ZBC_COLOR 0x00
5#define FERMI_A_ZBC_DEPTH 0x01
6
7struct fermi_a_zbc_color_v0 {
8 __u8 version;
9#define FERMI_A_ZBC_COLOR_V0_FMT_ZERO 0x01
10#define FERMI_A_ZBC_COLOR_V0_FMT_UNORM_ONE 0x02
11#define FERMI_A_ZBC_COLOR_V0_FMT_RF32_GF32_BF32_AF32 0x04
12#define FERMI_A_ZBC_COLOR_V0_FMT_R16_G16_B16_A16 0x08
13#define FERMI_A_ZBC_COLOR_V0_FMT_RN16_GN16_BN16_AN16 0x0c
14#define FERMI_A_ZBC_COLOR_V0_FMT_RS16_GS16_BS16_AS16 0x10
15#define FERMI_A_ZBC_COLOR_V0_FMT_RU16_GU16_BU16_AU16 0x14
16#define FERMI_A_ZBC_COLOR_V0_FMT_RF16_GF16_BF16_AF16 0x16
17#define FERMI_A_ZBC_COLOR_V0_FMT_A8R8G8B8 0x18
18#define FERMI_A_ZBC_COLOR_V0_FMT_A8RL8GL8BL8 0x1c
19#define FERMI_A_ZBC_COLOR_V0_FMT_A2B10G10R10 0x20
20#define FERMI_A_ZBC_COLOR_V0_FMT_AU2BU10GU10RU10 0x24
21#define FERMI_A_ZBC_COLOR_V0_FMT_A8B8G8R8 0x28
22#define FERMI_A_ZBC_COLOR_V0_FMT_A8BL8GL8RL8 0x2c
23#define FERMI_A_ZBC_COLOR_V0_FMT_AN8BN8GN8RN8 0x30
24#define FERMI_A_ZBC_COLOR_V0_FMT_AS8BS8GS8RS8 0x34
25#define FERMI_A_ZBC_COLOR_V0_FMT_AU8BU8GU8RU8 0x38
26#define FERMI_A_ZBC_COLOR_V0_FMT_A2R10G10B10 0x3c
27#define FERMI_A_ZBC_COLOR_V0_FMT_BF10GF11RF11 0x40
28 __u8 format;
29 __u8 index;
30 __u8 pad03[5];
31 __u32 ds[4];
32 __u32 l2[4];
33};
34
35struct fermi_a_zbc_depth_v0 {
36 __u8 version;
37#define FERMI_A_ZBC_DEPTH_V0_FMT_FP32 0x01
38 __u8 format;
39 __u8 index;
40 __u8 pad03[5];
41 __u32 ds;
42 __u32 l2;
43};
44#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/cla06f.h b/drivers/gpu/drm/nouveau/include/nvif/cla06f.h
new file mode 100644
index 000000000000..85b7827eb782
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/cla06f.h
@@ -0,0 +1,21 @@
1#ifndef __NVIF_CLA06F_H__
2#define __NVIF_CLA06F_H__
3
4struct kepler_channel_gpfifo_a_v0 {
5 __u8 version;
6#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_GR 0x01
7#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_MSPDEC 0x02
8#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_MSPPP 0x04
9#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_MSVLD 0x08
10#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE0 0x10
11#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE1 0x20
12#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_ENC 0x40
13 __u8 engine;
14 __u16 chid;
15 __u32 ilength;
16 __u64 ioffset;
17 __u64 vm;
18};
19
20#define KEPLER_CHANNEL_GPFIFO_A_V0_NTFY_UEVENT 0x00
21#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/class.h b/drivers/gpu/drm/nouveau/include/nvif/class.h
index 95a64d89547c..4179cd65ac0a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/class.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/class.h
@@ -1,16 +1,21 @@
1#ifndef __NVIF_CLASS_H__ 1#ifndef __NVIF_CLASS_H__
2#define __NVIF_CLASS_H__ 2#define __NVIF_CLASS_H__
3 3
4/******************************************************************************* 4/* these class numbers are made up by us, and not nvidia-assigned */
5 * class identifiers 5#define NVIF_CLASS_CONTROL /* if0001.h */ -1
6 ******************************************************************************/ 6#define NVIF_CLASS_PERFMON /* if0002.h */ -2
7#define NVIF_CLASS_PERFDOM /* if0003.h */ -3
8#define NVIF_CLASS_SW_NV04 /* if0004.h */ -4
9#define NVIF_CLASS_SW_NV10 /* if0005.h */ -5
10#define NVIF_CLASS_SW_NV50 /* if0005.h */ -6
11#define NVIF_CLASS_SW_GF100 /* if0005.h */ -7
7 12
8/* the below match nvidia-assigned (either in hw, or sw) class numbers */ 13/* the below match nvidia-assigned (either in hw, or sw) class numbers */
9#define NV_DEVICE 0x00000080 14#define NV_DEVICE /* cl0080.h */ 0x00000080
10 15
11#define NV_DMA_FROM_MEMORY 0x00000002 16#define NV_DMA_FROM_MEMORY /* cl0002.h */ 0x00000002
12#define NV_DMA_TO_MEMORY 0x00000003 17#define NV_DMA_TO_MEMORY /* cl0002.h */ 0x00000003
13#define NV_DMA_IN_MEMORY 0x0000003d 18#define NV_DMA_IN_MEMORY /* cl0002.h */ 0x0000003d
14 19
15#define FERMI_TWOD_A 0x0000902d 20#define FERMI_TWOD_A 0x0000902d
16 21
@@ -19,85 +24,85 @@
19#define KEPLER_INLINE_TO_MEMORY_A 0x0000a040 24#define KEPLER_INLINE_TO_MEMORY_A 0x0000a040
20#define KEPLER_INLINE_TO_MEMORY_B 0x0000a140 25#define KEPLER_INLINE_TO_MEMORY_B 0x0000a140
21 26
22#define NV04_DISP 0x00000046 27#define NV04_DISP /* cl0046.h */ 0x00000046
23 28
24#define NV03_CHANNEL_DMA 0x0000006b 29#define NV03_CHANNEL_DMA /* cl506b.h */ 0x0000006b
25#define NV10_CHANNEL_DMA 0x0000006e 30#define NV10_CHANNEL_DMA /* cl506b.h */ 0x0000006e
26#define NV17_CHANNEL_DMA 0x0000176e 31#define NV17_CHANNEL_DMA /* cl506b.h */ 0x0000176e
27#define NV40_CHANNEL_DMA 0x0000406e 32#define NV40_CHANNEL_DMA /* cl506b.h */ 0x0000406e
28#define NV50_CHANNEL_DMA 0x0000506e 33#define NV50_CHANNEL_DMA /* cl506e.h */ 0x0000506e
29#define G82_CHANNEL_DMA 0x0000826e 34#define G82_CHANNEL_DMA /* cl826e.h */ 0x0000826e
30 35
31#define NV50_CHANNEL_GPFIFO 0x0000506f 36#define NV50_CHANNEL_GPFIFO /* cl506f.h */ 0x0000506f
32#define G82_CHANNEL_GPFIFO 0x0000826f 37#define G82_CHANNEL_GPFIFO /* cl826f.h */ 0x0000826f
33#define FERMI_CHANNEL_GPFIFO 0x0000906f 38#define FERMI_CHANNEL_GPFIFO /* cl906f.h */ 0x0000906f
34#define KEPLER_CHANNEL_GPFIFO_A 0x0000a06f 39#define KEPLER_CHANNEL_GPFIFO_A /* cla06f.h */ 0x0000a06f
35#define MAXWELL_CHANNEL_GPFIFO_A 0x0000b06f 40#define MAXWELL_CHANNEL_GPFIFO_A /* cla06f.h */ 0x0000b06f
36 41
37#define NV50_DISP 0x00005070 42#define NV50_DISP /* cl5070.h */ 0x00005070
38#define G82_DISP 0x00008270 43#define G82_DISP /* cl5070.h */ 0x00008270
39#define GT200_DISP 0x00008370 44#define GT200_DISP /* cl5070.h */ 0x00008370
40#define GT214_DISP 0x00008570 45#define GT214_DISP /* cl5070.h */ 0x00008570
41#define GT206_DISP 0x00008870 46#define GT206_DISP /* cl5070.h */ 0x00008870
42#define GF110_DISP 0x00009070 47#define GF110_DISP /* cl5070.h */ 0x00009070
43#define GK104_DISP 0x00009170 48#define GK104_DISP /* cl5070.h */ 0x00009170
44#define GK110_DISP 0x00009270 49#define GK110_DISP /* cl5070.h */ 0x00009270
45#define GM107_DISP 0x00009470 50#define GM107_DISP /* cl5070.h */ 0x00009470
46#define GM204_DISP 0x00009570 51#define GM204_DISP /* cl5070.h */ 0x00009570
47 52
48#define NV31_MPEG 0x00003174 53#define NV31_MPEG 0x00003174
49#define G82_MPEG 0x00008274 54#define G82_MPEG 0x00008274
50 55
51#define NV74_VP2 0x00007476 56#define NV74_VP2 0x00007476
52 57
53#define NV50_DISP_CURSOR 0x0000507a 58#define NV50_DISP_CURSOR /* cl507a.h */ 0x0000507a
54#define G82_DISP_CURSOR 0x0000827a 59#define G82_DISP_CURSOR /* cl507a.h */ 0x0000827a
55#define GT214_DISP_CURSOR 0x0000857a 60#define GT214_DISP_CURSOR /* cl507a.h */ 0x0000857a
56#define GF110_DISP_CURSOR 0x0000907a 61#define GF110_DISP_CURSOR /* cl507a.h */ 0x0000907a
57#define GK104_DISP_CURSOR 0x0000917a 62#define GK104_DISP_CURSOR /* cl507a.h */ 0x0000917a
58 63
59#define NV50_DISP_OVERLAY 0x0000507b 64#define NV50_DISP_OVERLAY /* cl507b.h */ 0x0000507b
60#define G82_DISP_OVERLAY 0x0000827b 65#define G82_DISP_OVERLAY /* cl507b.h */ 0x0000827b
61#define GT214_DISP_OVERLAY 0x0000857b 66#define GT214_DISP_OVERLAY /* cl507b.h */ 0x0000857b
62#define GF110_DISP_OVERLAY 0x0000907b 67#define GF110_DISP_OVERLAY /* cl507b.h */ 0x0000907b
63#define GK104_DISP_OVERLAY 0x0000917b 68#define GK104_DISP_OVERLAY /* cl507b.h */ 0x0000917b
64 69
65#define NV50_DISP_BASE_CHANNEL_DMA 0x0000507c 70#define NV50_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000507c
66#define G82_DISP_BASE_CHANNEL_DMA 0x0000827c 71#define G82_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000827c
67#define GT200_DISP_BASE_CHANNEL_DMA 0x0000837c 72#define GT200_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000837c
68#define GT214_DISP_BASE_CHANNEL_DMA 0x0000857c 73#define GT214_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000857c
69#define GF110_DISP_BASE_CHANNEL_DMA 0x0000907c 74#define GF110_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000907c
70#define GK104_DISP_BASE_CHANNEL_DMA 0x0000917c 75#define GK104_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000917c
71#define GK110_DISP_BASE_CHANNEL_DMA 0x0000927c 76#define GK110_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000927c
72 77
73#define NV50_DISP_CORE_CHANNEL_DMA 0x0000507d 78#define NV50_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000507d
74#define G82_DISP_CORE_CHANNEL_DMA 0x0000827d 79#define G82_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000827d
75#define GT200_DISP_CORE_CHANNEL_DMA 0x0000837d 80#define GT200_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000837d
76#define GT214_DISP_CORE_CHANNEL_DMA 0x0000857d 81#define GT214_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000857d
77#define GT206_DISP_CORE_CHANNEL_DMA 0x0000887d 82#define GT206_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000887d
78#define GF110_DISP_CORE_CHANNEL_DMA 0x0000907d 83#define GF110_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000907d
79#define GK104_DISP_CORE_CHANNEL_DMA 0x0000917d 84#define GK104_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000917d
80#define GK110_DISP_CORE_CHANNEL_DMA 0x0000927d 85#define GK110_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000927d
81#define GM107_DISP_CORE_CHANNEL_DMA 0x0000947d 86#define GM107_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000947d
82#define GM204_DISP_CORE_CHANNEL_DMA 0x0000957d 87#define GM204_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000957d
83 88
84#define NV50_DISP_OVERLAY_CHANNEL_DMA 0x0000507e 89#define NV50_DISP_OVERLAY_CHANNEL_DMA /* cl507e.h */ 0x0000507e
85#define G82_DISP_OVERLAY_CHANNEL_DMA 0x0000827e 90#define G82_DISP_OVERLAY_CHANNEL_DMA /* cl507e.h */ 0x0000827e
86#define GT200_DISP_OVERLAY_CHANNEL_DMA 0x0000837e 91#define GT200_DISP_OVERLAY_CHANNEL_DMA /* cl507e.h */ 0x0000837e
87#define GT214_DISP_OVERLAY_CHANNEL_DMA 0x0000857e 92#define GT214_DISP_OVERLAY_CHANNEL_DMA /* cl507e.h */ 0x0000857e
88#define GF110_DISP_OVERLAY_CONTROL_DMA 0x0000907e 93#define GF110_DISP_OVERLAY_CONTROL_DMA /* cl507e.h */ 0x0000907e
89#define GK104_DISP_OVERLAY_CONTROL_DMA 0x0000917e 94#define GK104_DISP_OVERLAY_CONTROL_DMA /* cl507e.h */ 0x0000917e
90 95
91#define FERMI_A 0x00009097 96#define FERMI_A /* cl9097.h */ 0x00009097
92#define FERMI_B 0x00009197 97#define FERMI_B /* cl9097.h */ 0x00009197
93#define FERMI_C 0x00009297 98#define FERMI_C /* cl9097.h */ 0x00009297
94 99
95#define KEPLER_A 0x0000a097 100#define KEPLER_A /* cl9097.h */ 0x0000a097
96#define KEPLER_B 0x0000a197 101#define KEPLER_B /* cl9097.h */ 0x0000a197
97#define KEPLER_C 0x0000a297 102#define KEPLER_C /* cl9097.h */ 0x0000a297
98 103
99#define MAXWELL_A 0x0000b097 104#define MAXWELL_A /* cl9097.h */ 0x0000b097
100#define MAXWELL_B 0x0000b197 105#define MAXWELL_B /* cl9097.h */ 0x0000b197
101 106
102#define NV74_BSP 0x000074b0 107#define NV74_BSP 0x000074b0
103 108
@@ -133,540 +138,4 @@
133#define MAXWELL_COMPUTE_B 0x0000b1c0 138#define MAXWELL_COMPUTE_B 0x0000b1c0
134 139
135#define NV74_CIPHER 0x000074c1 140#define NV74_CIPHER 0x000074c1
136
137/*******************************************************************************
138 * client
139 ******************************************************************************/
140
141#define NV_CLIENT_DEVLIST 0x00
142
143struct nv_client_devlist_v0 {
144 __u8 version;
145 __u8 count;
146 __u8 pad02[6];
147 __u64 device[];
148};
149
150
151/*******************************************************************************
152 * device
153 ******************************************************************************/
154
155struct nv_device_v0 {
156 __u8 version;
157 __u8 pad01[7];
158 __u64 device; /* device identifier, ~0 for client default */
159};
160
161#define NV_DEVICE_V0_INFO 0x00
162#define NV_DEVICE_V0_TIME 0x01
163
164struct nv_device_info_v0 {
165 __u8 version;
166#define NV_DEVICE_INFO_V0_IGP 0x00
167#define NV_DEVICE_INFO_V0_PCI 0x01
168#define NV_DEVICE_INFO_V0_AGP 0x02
169#define NV_DEVICE_INFO_V0_PCIE 0x03
170#define NV_DEVICE_INFO_V0_SOC 0x04
171 __u8 platform;
172 __u16 chipset; /* from NV_PMC_BOOT_0 */
173 __u8 revision; /* from NV_PMC_BOOT_0 */
174#define NV_DEVICE_INFO_V0_TNT 0x01
175#define NV_DEVICE_INFO_V0_CELSIUS 0x02
176#define NV_DEVICE_INFO_V0_KELVIN 0x03
177#define NV_DEVICE_INFO_V0_RANKINE 0x04
178#define NV_DEVICE_INFO_V0_CURIE 0x05
179#define NV_DEVICE_INFO_V0_TESLA 0x06
180#define NV_DEVICE_INFO_V0_FERMI 0x07
181#define NV_DEVICE_INFO_V0_KEPLER 0x08
182#define NV_DEVICE_INFO_V0_MAXWELL 0x09
183 __u8 family;
184 __u8 pad06[2];
185 __u64 ram_size;
186 __u64 ram_user;
187 char chip[16];
188 char name[64];
189};
190
191struct nv_device_time_v0 {
192 __u8 version;
193 __u8 pad01[7];
194 __u64 time;
195};
196
197
198/*******************************************************************************
199 * context dma
200 ******************************************************************************/
201
202struct nv_dma_v0 {
203 __u8 version;
204#define NV_DMA_V0_TARGET_VM 0x00
205#define NV_DMA_V0_TARGET_VRAM 0x01
206#define NV_DMA_V0_TARGET_PCI 0x02
207#define NV_DMA_V0_TARGET_PCI_US 0x03
208#define NV_DMA_V0_TARGET_AGP 0x04
209 __u8 target;
210#define NV_DMA_V0_ACCESS_VM 0x00
211#define NV_DMA_V0_ACCESS_RD 0x01
212#define NV_DMA_V0_ACCESS_WR 0x02
213#define NV_DMA_V0_ACCESS_RDWR (NV_DMA_V0_ACCESS_RD | NV_DMA_V0_ACCESS_WR)
214 __u8 access;
215 __u8 pad03[5];
216 __u64 start;
217 __u64 limit;
218 /* ... chipset-specific class data */
219};
220
221struct nv50_dma_v0 {
222 __u8 version;
223#define NV50_DMA_V0_PRIV_VM 0x00
224#define NV50_DMA_V0_PRIV_US 0x01
225#define NV50_DMA_V0_PRIV__S 0x02
226 __u8 priv;
227#define NV50_DMA_V0_PART_VM 0x00
228#define NV50_DMA_V0_PART_256 0x01
229#define NV50_DMA_V0_PART_1KB 0x02
230 __u8 part;
231#define NV50_DMA_V0_COMP_NONE 0x00
232#define NV50_DMA_V0_COMP_1 0x01
233#define NV50_DMA_V0_COMP_2 0x02
234#define NV50_DMA_V0_COMP_VM 0x03
235 __u8 comp;
236#define NV50_DMA_V0_KIND_PITCH 0x00
237#define NV50_DMA_V0_KIND_VM 0x7f
238 __u8 kind;
239 __u8 pad05[3];
240};
241
242struct gf100_dma_v0 {
243 __u8 version;
244#define GF100_DMA_V0_PRIV_VM 0x00
245#define GF100_DMA_V0_PRIV_US 0x01
246#define GF100_DMA_V0_PRIV__S 0x02
247 __u8 priv;
248#define GF100_DMA_V0_KIND_PITCH 0x00
249#define GF100_DMA_V0_KIND_VM 0xff
250 __u8 kind;
251 __u8 pad03[5];
252};
253
254struct gf119_dma_v0 {
255 __u8 version;
256#define GF119_DMA_V0_PAGE_LP 0x00
257#define GF119_DMA_V0_PAGE_SP 0x01
258 __u8 page;
259#define GF119_DMA_V0_KIND_PITCH 0x00
260#define GF119_DMA_V0_KIND_VM 0xff
261 __u8 kind;
262 __u8 pad03[5];
263};
264
265
266/*******************************************************************************
267 * perfmon
268 ******************************************************************************/
269
270#define NVIF_PERFMON_V0_QUERY_DOMAIN 0x00
271#define NVIF_PERFMON_V0_QUERY_SIGNAL 0x01
272#define NVIF_PERFMON_V0_QUERY_SOURCE 0x02
273
274struct nvif_perfmon_query_domain_v0 {
275 __u8 version;
276 __u8 id;
277 __u8 counter_nr;
278 __u8 iter;
279 __u16 signal_nr;
280 __u8 pad05[2];
281 char name[64];
282};
283
284struct nvif_perfmon_query_signal_v0 {
285 __u8 version;
286 __u8 domain;
287 __u16 iter;
288 __u8 signal;
289 __u8 source_nr;
290 __u8 pad05[2];
291 char name[64];
292};
293
294struct nvif_perfmon_query_source_v0 {
295 __u8 version;
296 __u8 domain;
297 __u8 signal;
298 __u8 iter;
299 __u8 pad04[4];
300 __u32 source;
301 __u32 mask;
302 char name[64];
303};
304
305
306/*******************************************************************************
307 * perfdom
308 ******************************************************************************/
309
310struct nvif_perfdom_v0 {
311 __u8 version;
312 __u8 domain;
313 __u8 mode;
314 __u8 pad03[1];
315 struct {
316 __u8 signal[4];
317 __u64 source[4][8];
318 __u16 logic_op;
319 } ctr[4];
320};
321
322#define NVIF_PERFDOM_V0_INIT 0x00
323#define NVIF_PERFDOM_V0_SAMPLE 0x01
324#define NVIF_PERFDOM_V0_READ 0x02
325
326struct nvif_perfdom_init {
327};
328
329struct nvif_perfdom_sample {
330};
331
332struct nvif_perfdom_read_v0 {
333 __u8 version;
334 __u8 pad01[7];
335 __u32 ctr[4];
336 __u32 clk;
337 __u8 pad04[4];
338};
339
340
341/*******************************************************************************
342 * device control
343 ******************************************************************************/
344
345#define NVIF_CONTROL_PSTATE_INFO 0x00
346#define NVIF_CONTROL_PSTATE_ATTR 0x01
347#define NVIF_CONTROL_PSTATE_USER 0x02
348
349struct nvif_control_pstate_info_v0 {
350 __u8 version;
351 __u8 count; /* out: number of power states */
352#define NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE (-1)
353#define NVIF_CONTROL_PSTATE_INFO_V0_USTATE_PERFMON (-2)
354 __s8 ustate_ac; /* out: target pstate index */
355 __s8 ustate_dc; /* out: target pstate index */
356 __s8 pwrsrc; /* out: current power source */
357#define NVIF_CONTROL_PSTATE_INFO_V0_PSTATE_UNKNOWN (-1)
358#define NVIF_CONTROL_PSTATE_INFO_V0_PSTATE_PERFMON (-2)
359 __s8 pstate; /* out: current pstate index */
360 __u8 pad06[2];
361};
362
363struct nvif_control_pstate_attr_v0 {
364 __u8 version;
365#define NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT (-1)
366 __s8 state; /* in: index of pstate to query
367 * out: pstate identifier
368 */
369 __u8 index; /* in: index of attribute to query
370 * out: index of next attribute, or 0 if no more
371 */
372 __u8 pad03[5];
373 __u32 min;
374 __u32 max;
375 char name[32];
376 char unit[16];
377};
378
379struct nvif_control_pstate_user_v0 {
380 __u8 version;
381#define NVIF_CONTROL_PSTATE_USER_V0_STATE_UNKNOWN (-1)
382#define NVIF_CONTROL_PSTATE_USER_V0_STATE_PERFMON (-2)
383 __s8 ustate; /* in: pstate identifier */
384 __s8 pwrsrc; /* in: target power source */
385 __u8 pad03[5];
386};
387
388
389/*******************************************************************************
390 * DMA FIFO channels
391 ******************************************************************************/
392
393struct nv03_channel_dma_v0 {
394 __u8 version;
395 __u8 chid;
396 __u8 pad02[2];
397 __u32 offset;
398 __u64 pushbuf;
399};
400
401struct nv50_channel_dma_v0 {
402 __u8 version;
403 __u8 chid;
404 __u8 pad02[6];
405 __u64 vm;
406 __u64 pushbuf;
407 __u64 offset;
408};
409
410#define G82_CHANNEL_DMA_V0_NTFY_UEVENT 0x00
411
412/*******************************************************************************
413 * GPFIFO channels
414 ******************************************************************************/
415
416struct nv50_channel_gpfifo_v0 {
417 __u8 version;
418 __u8 chid;
419 __u8 pad02[2];
420 __u32 ilength;
421 __u64 ioffset;
422 __u64 pushbuf;
423 __u64 vm;
424};
425
426struct fermi_channel_gpfifo_v0 {
427 __u8 version;
428 __u8 chid;
429 __u8 pad02[2];
430 __u32 ilength;
431 __u64 ioffset;
432 __u64 vm;
433};
434
435struct kepler_channel_gpfifo_a_v0 {
436 __u8 version;
437#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_GR 0x01
438#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_MSPDEC 0x02
439#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_MSPPP 0x04
440#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_MSVLD 0x08
441#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE0 0x10
442#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE1 0x20
443#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_ENC 0x40
444 __u8 engine;
445 __u16 chid;
446 __u32 ilength;
447 __u64 ioffset;
448 __u64 vm;
449};
450
451/*******************************************************************************
452 * legacy display
453 ******************************************************************************/
454
455#define NV04_DISP_NTFY_VBLANK 0x00
456#define NV04_DISP_NTFY_CONN 0x01
457
458struct nv04_disp_mthd_v0 {
459 __u8 version;
460#define NV04_DISP_SCANOUTPOS 0x00
461 __u8 method;
462 __u8 head;
463 __u8 pad03[5];
464};
465
466struct nv04_disp_scanoutpos_v0 {
467 __u8 version;
468 __u8 pad01[7];
469 __s64 time[2];
470 __u16 vblanks;
471 __u16 vblanke;
472 __u16 vtotal;
473 __u16 vline;
474 __u16 hblanks;
475 __u16 hblanke;
476 __u16 htotal;
477 __u16 hline;
478};
479
480/*******************************************************************************
481 * display
482 ******************************************************************************/
483
484#define NV50_DISP_MTHD 0x00
485
486struct nv50_disp_mthd_v0 {
487 __u8 version;
488#define NV50_DISP_SCANOUTPOS 0x00
489 __u8 method;
490 __u8 head;
491 __u8 pad03[5];
492};
493
494struct nv50_disp_mthd_v1 {
495 __u8 version;
496#define NV50_DISP_MTHD_V1_DAC_PWR 0x10
497#define NV50_DISP_MTHD_V1_DAC_LOAD 0x11
498#define NV50_DISP_MTHD_V1_SOR_PWR 0x20
499#define NV50_DISP_MTHD_V1_SOR_HDA_ELD 0x21
500#define NV50_DISP_MTHD_V1_SOR_HDMI_PWR 0x22
501#define NV50_DISP_MTHD_V1_SOR_LVDS_SCRIPT 0x23
502#define NV50_DISP_MTHD_V1_SOR_DP_PWR 0x24
503#define NV50_DISP_MTHD_V1_PIOR_PWR 0x30
504 __u8 method;
505 __u16 hasht;
506 __u16 hashm;
507 __u8 pad06[2];
508};
509
510struct nv50_disp_dac_pwr_v0 {
511 __u8 version;
512 __u8 state;
513 __u8 data;
514 __u8 vsync;
515 __u8 hsync;
516 __u8 pad05[3];
517};
518
519struct nv50_disp_dac_load_v0 {
520 __u8 version;
521 __u8 load;
522 __u8 pad02[2];
523 __u32 data;
524};
525
526struct nv50_disp_sor_pwr_v0 {
527 __u8 version;
528 __u8 state;
529 __u8 pad02[6];
530};
531
532struct nv50_disp_sor_hda_eld_v0 {
533 __u8 version;
534 __u8 pad01[7];
535 __u8 data[];
536};
537
538struct nv50_disp_sor_hdmi_pwr_v0 {
539 __u8 version;
540 __u8 state;
541 __u8 max_ac_packet;
542 __u8 rekey;
543 __u8 pad04[4];
544};
545
546struct nv50_disp_sor_lvds_script_v0 {
547 __u8 version;
548 __u8 pad01[1];
549 __u16 script;
550 __u8 pad04[4];
551};
552
553struct nv50_disp_sor_dp_pwr_v0 {
554 __u8 version;
555 __u8 state;
556 __u8 pad02[6];
557};
558
559struct nv50_disp_pior_pwr_v0 {
560 __u8 version;
561 __u8 state;
562 __u8 type;
563 __u8 pad03[5];
564};
565
566/* core */
567struct nv50_disp_core_channel_dma_v0 {
568 __u8 version;
569 __u8 pad01[7];
570 __u64 pushbuf;
571};
572
573#define NV50_DISP_CORE_CHANNEL_DMA_V0_NTFY_UEVENT 0x00
574
575/* cursor immediate */
576struct nv50_disp_cursor_v0 {
577 __u8 version;
578 __u8 head;
579 __u8 pad02[6];
580};
581
582#define NV50_DISP_CURSOR_V0_NTFY_UEVENT 0x00
583
584/* base */
585struct nv50_disp_base_channel_dma_v0 {
586 __u8 version;
587 __u8 head;
588 __u8 pad02[6];
589 __u64 pushbuf;
590};
591
592#define NV50_DISP_BASE_CHANNEL_DMA_V0_NTFY_UEVENT 0x00
593
594/* overlay */
595struct nv50_disp_overlay_channel_dma_v0 {
596 __u8 version;
597 __u8 head;
598 __u8 pad02[6];
599 __u64 pushbuf;
600};
601
602#define NV50_DISP_OVERLAY_CHANNEL_DMA_V0_NTFY_UEVENT 0x00
603
604/* overlay immediate */
605struct nv50_disp_overlay_v0 {
606 __u8 version;
607 __u8 head;
608 __u8 pad02[6];
609};
610
611#define NV50_DISP_OVERLAY_V0_NTFY_UEVENT 0x00
612
613/*******************************************************************************
614 * software
615 ******************************************************************************/
616
617#define NVSW_NTFY_UEVENT 0x00
618
619#define NV04_NVSW_GET_REF 0x00
620
621struct nv04_nvsw_get_ref_v0 {
622 __u8 version;
623 __u8 pad01[3];
624 __u32 ref;
625};
626
627/*******************************************************************************
628 * fermi
629 ******************************************************************************/
630
631#define FERMI_A_ZBC_COLOR 0x00
632#define FERMI_A_ZBC_DEPTH 0x01
633
634struct fermi_a_zbc_color_v0 {
635 __u8 version;
636#define FERMI_A_ZBC_COLOR_V0_FMT_ZERO 0x01
637#define FERMI_A_ZBC_COLOR_V0_FMT_UNORM_ONE 0x02
638#define FERMI_A_ZBC_COLOR_V0_FMT_RF32_GF32_BF32_AF32 0x04
639#define FERMI_A_ZBC_COLOR_V0_FMT_R16_G16_B16_A16 0x08
640#define FERMI_A_ZBC_COLOR_V0_FMT_RN16_GN16_BN16_AN16 0x0c
641#define FERMI_A_ZBC_COLOR_V0_FMT_RS16_GS16_BS16_AS16 0x10
642#define FERMI_A_ZBC_COLOR_V0_FMT_RU16_GU16_BU16_AU16 0x14
643#define FERMI_A_ZBC_COLOR_V0_FMT_RF16_GF16_BF16_AF16 0x16
644#define FERMI_A_ZBC_COLOR_V0_FMT_A8R8G8B8 0x18
645#define FERMI_A_ZBC_COLOR_V0_FMT_A8RL8GL8BL8 0x1c
646#define FERMI_A_ZBC_COLOR_V0_FMT_A2B10G10R10 0x20
647#define FERMI_A_ZBC_COLOR_V0_FMT_AU2BU10GU10RU10 0x24
648#define FERMI_A_ZBC_COLOR_V0_FMT_A8B8G8R8 0x28
649#define FERMI_A_ZBC_COLOR_V0_FMT_A8BL8GL8RL8 0x2c
650#define FERMI_A_ZBC_COLOR_V0_FMT_AN8BN8GN8RN8 0x30
651#define FERMI_A_ZBC_COLOR_V0_FMT_AS8BS8GS8RS8 0x34
652#define FERMI_A_ZBC_COLOR_V0_FMT_AU8BU8GU8RU8 0x38
653#define FERMI_A_ZBC_COLOR_V0_FMT_A2R10G10B10 0x3c
654#define FERMI_A_ZBC_COLOR_V0_FMT_BF10GF11RF11 0x40
655 __u8 format;
656 __u8 index;
657 __u8 pad03[5];
658 __u32 ds[4];
659 __u32 l2[4];
660};
661
662struct fermi_a_zbc_depth_v0 {
663 __u8 version;
664#define FERMI_A_ZBC_DEPTH_V0_FMT_FP32 0x01
665 __u8 format;
666 __u8 index;
667 __u8 pad03[5];
668 __u32 ds;
669 __u32 l2;
670};
671
672#endif 141#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/device.h b/drivers/gpu/drm/nouveau/include/nvif/device.h
index 700a9b206726..e0ed2f4b2f43 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/device.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/device.h
@@ -2,7 +2,7 @@
2#define __NVIF_DEVICE_H__ 2#define __NVIF_DEVICE_H__
3 3
4#include <nvif/object.h> 4#include <nvif/object.h>
5#include <nvif/class.h> 5#include <nvif/cl0080.h>
6 6
7struct nvif_device { 7struct nvif_device {
8 struct nvif_object object; 8 struct nvif_object object;
@@ -63,6 +63,7 @@ u64 nvif_device_time(struct nvif_device *);
63#define nvxx_clk(a) nvxx_device(a)->clk 63#define nvxx_clk(a) nvxx_device(a)->clk
64#define nvxx_i2c(a) nvxx_device(a)->i2c 64#define nvxx_i2c(a) nvxx_device(a)->i2c
65#define nvxx_therm(a) nvxx_device(a)->therm 65#define nvxx_therm(a) nvxx_device(a)->therm
66#define nvxx_volt(a) nvxx_device(a)->volt
66 67
67#include <core/device.h> 68#include <core/device.h>
68#include <engine/fifo.h> 69#include <engine/fifo.h>
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0000.h b/drivers/gpu/drm/nouveau/include/nvif/if0000.h
new file mode 100644
index 000000000000..85c44e8a1201
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0000.h
@@ -0,0 +1,12 @@
1#ifndef __NVIF_IF0000_H__
2#define __NVIF_IF0000_H__
3
4#define NV_CLIENT_DEVLIST 0x00
5
6struct nv_client_devlist_v0 {
7 __u8 version;
8 __u8 count;
9 __u8 pad02[6];
10 __u64 device[];
11};
12#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0001.h b/drivers/gpu/drm/nouveau/include/nvif/if0001.h
new file mode 100644
index 000000000000..bd5b64125eed
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0001.h
@@ -0,0 +1,46 @@
1#ifndef __NVIF_IF0001_H__
2#define __NVIF_IF0001_H__
3
4#define NVIF_CONTROL_PSTATE_INFO 0x00
5#define NVIF_CONTROL_PSTATE_ATTR 0x01
6#define NVIF_CONTROL_PSTATE_USER 0x02
7
8struct nvif_control_pstate_info_v0 {
9 __u8 version;
10 __u8 count; /* out: number of power states */
11#define NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE (-1)
12#define NVIF_CONTROL_PSTATE_INFO_V0_USTATE_PERFMON (-2)
13 __s8 ustate_ac; /* out: target pstate index */
14 __s8 ustate_dc; /* out: target pstate index */
15 __s8 pwrsrc; /* out: current power source */
16#define NVIF_CONTROL_PSTATE_INFO_V0_PSTATE_UNKNOWN (-1)
17#define NVIF_CONTROL_PSTATE_INFO_V0_PSTATE_PERFMON (-2)
18 __s8 pstate; /* out: current pstate index */
19 __u8 pad06[2];
20};
21
22struct nvif_control_pstate_attr_v0 {
23 __u8 version;
24#define NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT (-1)
25 __s8 state; /* in: index of pstate to query
26 * out: pstate identifier
27 */
28 __u8 index; /* in: index of attribute to query
29 * out: index of next attribute, or 0 if no more
30 */
31 __u8 pad03[5];
32 __u32 min;
33 __u32 max;
34 char name[32];
35 char unit[16];
36};
37
38struct nvif_control_pstate_user_v0 {
39 __u8 version;
40#define NVIF_CONTROL_PSTATE_USER_V0_STATE_UNKNOWN (-1)
41#define NVIF_CONTROL_PSTATE_USER_V0_STATE_PERFMON (-2)
42 __s8 ustate; /* in: pstate identifier */
43 __s8 pwrsrc; /* in: target power source */
44 __u8 pad03[5];
45};
46#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0002.h b/drivers/gpu/drm/nouveau/include/nvif/if0002.h
new file mode 100644
index 000000000000..c04c91d0b818
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0002.h
@@ -0,0 +1,38 @@
1#ifndef __NVIF_IF0002_H__
2#define __NVIF_IF0002_H__
3
4#define NVIF_PERFMON_V0_QUERY_DOMAIN 0x00
5#define NVIF_PERFMON_V0_QUERY_SIGNAL 0x01
6#define NVIF_PERFMON_V0_QUERY_SOURCE 0x02
7
8struct nvif_perfmon_query_domain_v0 {
9 __u8 version;
10 __u8 id;
11 __u8 counter_nr;
12 __u8 iter;
13 __u16 signal_nr;
14 __u8 pad05[2];
15 char name[64];
16};
17
18struct nvif_perfmon_query_signal_v0 {
19 __u8 version;
20 __u8 domain;
21 __u16 iter;
22 __u8 signal;
23 __u8 source_nr;
24 __u8 pad05[2];
25 char name[64];
26};
27
28struct nvif_perfmon_query_source_v0 {
29 __u8 version;
30 __u8 domain;
31 __u8 signal;
32 __u8 iter;
33 __u8 pad04[4];
34 __u32 source;
35 __u32 mask;
36 char name[64];
37};
38#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0003.h b/drivers/gpu/drm/nouveau/include/nvif/if0003.h
new file mode 100644
index 000000000000..0cd03efb80a1
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0003.h
@@ -0,0 +1,33 @@
1#ifndef __NVIF_IF0003_H__
2#define __NVIF_IF0003_H__
3
4struct nvif_perfdom_v0 {
5 __u8 version;
6 __u8 domain;
7 __u8 mode;
8 __u8 pad03[1];
9 struct {
10 __u8 signal[4];
11 __u64 source[4][8];
12 __u16 logic_op;
13 } ctr[4];
14};
15
16#define NVIF_PERFDOM_V0_INIT 0x00
17#define NVIF_PERFDOM_V0_SAMPLE 0x01
18#define NVIF_PERFDOM_V0_READ 0x02
19
20struct nvif_perfdom_init {
21};
22
23struct nvif_perfdom_sample {
24};
25
26struct nvif_perfdom_read_v0 {
27 __u8 version;
28 __u8 pad01[7];
29 __u32 ctr[4];
30 __u32 clk;
31 __u8 pad04[4];
32};
33#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0004.h b/drivers/gpu/drm/nouveau/include/nvif/if0004.h
new file mode 100644
index 000000000000..bd5cd428cfd7
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0004.h
@@ -0,0 +1,13 @@
1#ifndef __NVIF_IF0004_H__
2#define __NVIF_IF0004_H__
3
4#define NV04_NVSW_NTFY_UEVENT 0x00
5
6#define NV04_NVSW_GET_REF 0x00
7
8struct nv04_nvsw_get_ref_v0 {
9 __u8 version;
10 __u8 pad01[3];
11 __u32 ref;
12};
13#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0005.h b/drivers/gpu/drm/nouveau/include/nvif/if0005.h
new file mode 100644
index 000000000000..abfd373bb68b
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0005.h
@@ -0,0 +1,4 @@
1#ifndef __NVIF_IF0005_H__
2#define __NVIF_IF0005_H__
3#define NV10_NVSW_NTFY_UEVENT 0x00
4#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvif/ioctl.h b/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
index b0ac0215ebf9..c5f5eb83a594 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/ioctl.h
@@ -55,14 +55,6 @@ struct nvif_ioctl_new_v0 {
55 __u64 token; 55 __u64 token;
56 __u64 object; 56 __u64 object;
57 __u32 handle; 57 __u32 handle;
58/* these class numbers are made up by us, and not nvidia-assigned */
59#define NVIF_IOCTL_NEW_V0_CONTROL -1
60#define NVIF_IOCTL_NEW_V0_PERFMON -2
61#define NVIF_IOCTL_NEW_V0_PERFDOM -3
62#define NVIF_IOCTL_NEW_V0_SW_NV04 -4
63#define NVIF_IOCTL_NEW_V0_SW_NV10 -5
64#define NVIF_IOCTL_NEW_V0_SW_NV50 -6
65#define NVIF_IOCTL_NEW_V0_SW_GF100 -7
66 __s32 oclass; 58 __s32 oclass;
67 __u8 data[]; /* class data (class.h) */ 59 __u8 data[]; /* class data (class.h) */
68}; 60};
diff --git a/drivers/gpu/drm/nouveau/include/nvif/unpack.h b/drivers/gpu/drm/nouveau/include/nvif/unpack.h
index 5933188b4a77..751bcf4930a7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/unpack.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/unpack.h
@@ -1,24 +1,28 @@
1#ifndef __NVIF_UNPACK_H__ 1#ifndef __NVIF_UNPACK_H__
2#define __NVIF_UNPACK_H__ 2#define __NVIF_UNPACK_H__
3 3
4#define nvif_unvers(d) ({ \ 4#define nvif_unvers(r,d,s,m) ({ \
5 ret = (size == sizeof(d)) ? 0 : -ENOSYS; \ 5 void **_data = (d); __u32 *_size = (s); int _ret = (r); \
6 (ret == 0); \ 6 if (_ret == -ENOSYS && *_size == sizeof(m)) { \
7 *_data = NULL; \
8 *_size = _ret = 0; \
9 } \
10 _ret; \
7}) 11})
8 12
9#define nvif_unpack(d,vl,vh,m) ({ \ 13#define nvif_unpack(r,d,s,m,vl,vh,x) ({ \
10 if ((vl) == 0 || ret == -ENOSYS) { \ 14 void **_data = (d); __u32 *_size = (s); \
11 int _size = sizeof(d); \ 15 int _ret = (r), _vl = (vl), _vh = (vh); \
12 if (_size <= size && (d).version >= (vl) && \ 16 if (_ret == -ENOSYS && *_size >= sizeof(m) && \
13 (d).version <= (vh)) { \ 17 (m).version >= _vl && (m).version <= _vh) { \
14 data = (u8 *)data + _size; \ 18 *_data = (__u8 *)*_data + sizeof(m); \
15 size = size - _size; \ 19 *_size = *_size - sizeof(m); \
16 ret = ((m) || !size) ? 0 : -E2BIG; \ 20 if (_ret = 0, !(x)) { \
17 } else { \ 21 _ret = *_size ? -E2BIG : 0; \
18 ret = -ENOSYS; \ 22 *_data = NULL; \
23 *_size = 0; \
19 } \ 24 } \
20 } \ 25 } \
21 (ret == 0); \ 26 _ret; \
22}) 27})
23
24#endif 28#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/perf.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/perf.h
index 7cc2becabc69..d3bd250103d5 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/perf.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/perf.h
@@ -13,6 +13,8 @@ struct nvbios_perfE {
13 u32 vdec; 13 u32 vdec;
14 u32 disp; 14 u32 disp;
15 u32 script; 15 u32 script;
16 u8 pcie_speed;
17 u8 pcie_width;
16}; 18};
17 19
18u16 nvbios_perf_entry(struct nvkm_bios *, int idx, 20u16 nvbios_perf_entry(struct nvkm_bios *, int idx,
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/clk.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/clk.h
index 8708f0a4e188..6b33bc058924 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/clk.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/clk.h
@@ -2,6 +2,7 @@
2#define __NVKM_CLK_H__ 2#define __NVKM_CLK_H__
3#include <core/subdev.h> 3#include <core/subdev.h>
4#include <core/notify.h> 4#include <core/notify.h>
5#include <subdev/pci.h>
5struct nvbios_pll; 6struct nvbios_pll;
6struct nvkm_pll_vals; 7struct nvkm_pll_vals;
7 8
@@ -38,7 +39,7 @@ enum nv_clk_src {
38 nv_clk_src_hubk06, 39 nv_clk_src_hubk06,
39 nv_clk_src_hubk07, 40 nv_clk_src_hubk07,
40 nv_clk_src_copy, 41 nv_clk_src_copy,
41 nv_clk_src_daemon, 42 nv_clk_src_pmu,
42 nv_clk_src_disp, 43 nv_clk_src_disp,
43 nv_clk_src_vdec, 44 nv_clk_src_vdec,
44 45
@@ -59,6 +60,8 @@ struct nvkm_pstate {
59 struct nvkm_cstate base; 60 struct nvkm_cstate base;
60 u8 pstate; 61 u8 pstate;
61 u8 fanspeed; 62 u8 fanspeed;
63 enum nvkm_pcie_speed pcie_speed;
64 u8 pcie_width;
62}; 65};
63 66
64struct nvkm_domain { 67struct nvkm_domain {
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/ibus.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/ibus.h
index c4dcd2680fe1..ea23e24a246c 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/ibus.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/ibus.h
@@ -6,4 +6,5 @@ int gf100_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
6int gf117_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **); 6int gf117_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
7int gk104_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **); 7int gk104_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
8int gk20a_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **); 8int gk20a_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
9int gm204_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
9#endif 10#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/ltc.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/ltc.h
index 3d4dbbf9aab3..0ffa2ec106d6 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/ltc.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/ltc.h
@@ -37,4 +37,5 @@ int gf100_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
37int gk104_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **); 37int gk104_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
38int gk20a_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **); 38int gk20a_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
39int gm107_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **); 39int gm107_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
40int gm204_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
40#endif 41#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h
index fee0a97c44c5..ddb913889d7e 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h
@@ -2,6 +2,12 @@
2#define __NVKM_PCI_H__ 2#define __NVKM_PCI_H__
3#include <core/subdev.h> 3#include <core/subdev.h>
4 4
5enum nvkm_pcie_speed {
6 NVKM_PCIE_SPEED_2_5,
7 NVKM_PCIE_SPEED_5_0,
8 NVKM_PCIE_SPEED_8_0,
9};
10
5struct nvkm_pci { 11struct nvkm_pci {
6 const struct nvkm_pci_func *func; 12 const struct nvkm_pci_func *func;
7 struct nvkm_subdev subdev; 13 struct nvkm_subdev subdev;
@@ -18,6 +24,11 @@ struct nvkm_pci {
18 bool acquired; 24 bool acquired;
19 } agp; 25 } agp;
20 26
27 struct {
28 enum nvkm_pcie_speed speed;
29 u8 width;
30 } pcie;
31
21 bool msi; 32 bool msi;
22}; 33};
23 34
@@ -34,4 +45,9 @@ int nv4c_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
34int g84_pci_new(struct nvkm_device *, int, struct nvkm_pci **); 45int g84_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
35int g94_pci_new(struct nvkm_device *, int, struct nvkm_pci **); 46int g94_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
36int gf100_pci_new(struct nvkm_device *, int, struct nvkm_pci **); 47int gf100_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
48int gf106_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
49int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
50
51/* pcie functions */
52int nvkm_pcie_set_link(struct nvkm_pci *, enum nvkm_pcie_speed, u8 width);
37#endif 53#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 7f50cf5f929e..50f52ffe5b0c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -25,6 +25,8 @@
25#include <nvif/driver.h> 25#include <nvif/driver.h>
26#include <nvif/ioctl.h> 26#include <nvif/ioctl.h>
27#include <nvif/class.h> 27#include <nvif/class.h>
28#include <nvif/cl0002.h>
29#include <nvif/cla06f.h>
28#include <nvif/unpack.h> 30#include <nvif/unpack.h>
29 31
30#include "nouveau_drm.h" 32#include "nouveau_drm.h"
@@ -87,18 +89,18 @@ nouveau_abi16_swclass(struct nouveau_drm *drm)
87{ 89{
88 switch (drm->device.info.family) { 90 switch (drm->device.info.family) {
89 case NV_DEVICE_INFO_V0_TNT: 91 case NV_DEVICE_INFO_V0_TNT:
90 return NVIF_IOCTL_NEW_V0_SW_NV04; 92 return NVIF_CLASS_SW_NV04;
91 case NV_DEVICE_INFO_V0_CELSIUS: 93 case NV_DEVICE_INFO_V0_CELSIUS:
92 case NV_DEVICE_INFO_V0_KELVIN: 94 case NV_DEVICE_INFO_V0_KELVIN:
93 case NV_DEVICE_INFO_V0_RANKINE: 95 case NV_DEVICE_INFO_V0_RANKINE:
94 case NV_DEVICE_INFO_V0_CURIE: 96 case NV_DEVICE_INFO_V0_CURIE:
95 return NVIF_IOCTL_NEW_V0_SW_NV10; 97 return NVIF_CLASS_SW_NV10;
96 case NV_DEVICE_INFO_V0_TESLA: 98 case NV_DEVICE_INFO_V0_TESLA:
97 return NVIF_IOCTL_NEW_V0_SW_NV50; 99 return NVIF_CLASS_SW_NV50;
98 case NV_DEVICE_INFO_V0_FERMI: 100 case NV_DEVICE_INFO_V0_FERMI:
99 case NV_DEVICE_INFO_V0_KEPLER: 101 case NV_DEVICE_INFO_V0_KEPLER:
100 case NV_DEVICE_INFO_V0_MAXWELL: 102 case NV_DEVICE_INFO_V0_MAXWELL:
101 return NVIF_IOCTL_NEW_V0_SW_GF100; 103 return NVIF_CLASS_SW_GF100;
102 } 104 }
103 105
104 return 0x0000; 106 return 0x0000;
@@ -355,9 +357,9 @@ nouveau_abi16_usif(struct drm_file *file_priv, void *data, u32 size)
355 } *args = data; 357 } *args = data;
356 struct nouveau_abi16_chan *chan; 358 struct nouveau_abi16_chan *chan;
357 struct nouveau_abi16 *abi16; 359 struct nouveau_abi16 *abi16;
358 int ret; 360 int ret = -ENOSYS;
359 361
360 if (nvif_unpack(args->v0, 0, 0, true)) { 362 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
361 switch (args->v0.type) { 363 switch (args->v0.type) {
362 case NVIF_IOCTL_V0_NEW: 364 case NVIF_IOCTL_V0_NEW:
363 case NVIF_IOCTL_V0_MTHD: 365 case NVIF_IOCTL_V0_MTHD:
@@ -433,10 +435,10 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
433 /* nvsw: compatibility with older 0x*6e class identifier */ 435 /* nvsw: compatibility with older 0x*6e class identifier */
434 for (i = 0; !oclass && i < ret; i++) { 436 for (i = 0; !oclass && i < ret; i++) {
435 switch (sclass[i].oclass) { 437 switch (sclass[i].oclass) {
436 case NVIF_IOCTL_NEW_V0_SW_NV04: 438 case NVIF_CLASS_SW_NV04:
437 case NVIF_IOCTL_NEW_V0_SW_NV10: 439 case NVIF_CLASS_SW_NV10:
438 case NVIF_IOCTL_NEW_V0_SW_NV50: 440 case NVIF_CLASS_SW_NV50:
439 case NVIF_IOCTL_NEW_V0_SW_GF100: 441 case NVIF_CLASS_SW_GF100:
440 oclass = sclass[i].oclass; 442 oclass = sclass[i].oclass;
441 break; 443 break;
442 default: 444 default:
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index 1860f389f21f..3f804a8c590c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -24,6 +24,11 @@
24 24
25#include <nvif/os.h> 25#include <nvif/os.h>
26#include <nvif/class.h> 26#include <nvif/class.h>
27#include <nvif/cl0002.h>
28#include <nvif/cl006b.h>
29#include <nvif/cl506f.h>
30#include <nvif/cl906f.h>
31#include <nvif/cla06f.h>
27#include <nvif/ioctl.h> 32#include <nvif/ioctl.h>
28 33
29/*XXX*/ 34/*XXX*/
@@ -378,7 +383,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
378 /* allocate software object class (used for fences on <= nv05) */ 383 /* allocate software object class (used for fences on <= nv05) */
379 if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) { 384 if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) {
380 ret = nvif_object_init(&chan->user, 0x006e, 385 ret = nvif_object_init(&chan->user, 0x006e,
381 NVIF_IOCTL_NEW_V0_SW_NV04, 386 NVIF_CLASS_SW_NV04,
382 NULL, 0, &chan->nvsw); 387 NULL, 0, &chan->nvsw);
383 if (ret) 388 if (ret)
384 return ret; 389 return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 5dd1d0111cac..fcebfae5d426 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -42,6 +42,8 @@
42#include "nouveau_encoder.h" 42#include "nouveau_encoder.h"
43#include "nouveau_crtc.h" 43#include "nouveau_crtc.h"
44 44
45#include <nvif/class.h>
46#include <nvif/cl0046.h>
45#include <nvif/event.h> 47#include <nvif/event.h>
46 48
47MODULE_PARM_DESC(tv_disable, "Disable TV-out detection"); 49MODULE_PARM_DESC(tv_disable, "Disable TV-out detection");
@@ -56,6 +58,10 @@ MODULE_PARM_DESC(duallink, "Allow dual-link TMDS (default: enabled)");
56int nouveau_duallink = 1; 58int nouveau_duallink = 1;
57module_param_named(duallink, nouveau_duallink, int, 0400); 59module_param_named(duallink, nouveau_duallink, int, 0400);
58 60
61MODULE_PARM_DESC(hdmimhz, "Force a maximum HDMI pixel clock (in MHz)");
62int nouveau_hdmimhz = 0;
63module_param_named(hdmimhz, nouveau_hdmimhz, int, 0400);
64
59struct nouveau_encoder * 65struct nouveau_encoder *
60find_encoder(struct drm_connector *connector, int type) 66find_encoder(struct drm_connector *connector, int type)
61{ 67{
@@ -809,12 +815,23 @@ nouveau_connector_get_modes(struct drm_connector *connector)
809} 815}
810 816
811static unsigned 817static unsigned
812get_tmds_link_bandwidth(struct drm_connector *connector) 818get_tmds_link_bandwidth(struct drm_connector *connector, bool hdmi)
813{ 819{
814 struct nouveau_connector *nv_connector = nouveau_connector(connector); 820 struct nouveau_connector *nv_connector = nouveau_connector(connector);
815 struct nouveau_drm *drm = nouveau_drm(connector->dev); 821 struct nouveau_drm *drm = nouveau_drm(connector->dev);
816 struct dcb_output *dcb = nv_connector->detected_encoder->dcb; 822 struct dcb_output *dcb = nv_connector->detected_encoder->dcb;
817 823
824 if (hdmi) {
825 if (nouveau_hdmimhz > 0)
826 return nouveau_hdmimhz * 1000;
827 /* Note: these limits are conservative, some Fermi's
828 * can do 297 MHz. Unclear how this can be determined.
829 */
830 if (drm->device.info.family >= NV_DEVICE_INFO_V0_KEPLER)
831 return 297000;
832 if (drm->device.info.family >= NV_DEVICE_INFO_V0_FERMI)
833 return 225000;
834 }
818 if (dcb->location != DCB_LOC_ON_CHIP || 835 if (dcb->location != DCB_LOC_ON_CHIP ||
819 drm->device.info.chipset >= 0x46) 836 drm->device.info.chipset >= 0x46)
820 return 165000; 837 return 165000;
@@ -835,6 +852,7 @@ nouveau_connector_mode_valid(struct drm_connector *connector,
835 struct drm_encoder *encoder = to_drm_encoder(nv_encoder); 852 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
836 unsigned min_clock = 25000, max_clock = min_clock; 853 unsigned min_clock = 25000, max_clock = min_clock;
837 unsigned clock = mode->clock; 854 unsigned clock = mode->clock;
855 bool hdmi;
838 856
839 switch (nv_encoder->dcb->type) { 857 switch (nv_encoder->dcb->type) {
840 case DCB_OUTPUT_LVDS: 858 case DCB_OUTPUT_LVDS:
@@ -847,8 +865,10 @@ nouveau_connector_mode_valid(struct drm_connector *connector,
847 max_clock = 400000; 865 max_clock = 400000;
848 break; 866 break;
849 case DCB_OUTPUT_TMDS: 867 case DCB_OUTPUT_TMDS:
850 max_clock = get_tmds_link_bandwidth(connector); 868 hdmi = drm_detect_hdmi_monitor(nv_connector->edid);
851 if (nouveau_duallink && nv_encoder->dcb->duallink_possible) 869 max_clock = get_tmds_link_bandwidth(connector, hdmi);
870 if (!hdmi && nouveau_duallink &&
871 nv_encoder->dcb->duallink_possible)
852 max_clock *= 2; 872 max_clock *= 2;
853 break; 873 break;
854 case DCB_OUTPUT_ANALOG: 874 case DCB_OUTPUT_ANALOG:
@@ -963,10 +983,13 @@ nouveau_connector_hotplug(struct nvif_notify *notify)
963 983
964 NV_DEBUG(drm, "%splugged %s\n", plugged ? "" : "un", name); 984 NV_DEBUG(drm, "%splugged %s\n", plugged ? "" : "un", name);
965 985
986 mutex_lock(&drm->dev->mode_config.mutex);
966 if (plugged) 987 if (plugged)
967 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); 988 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
968 else 989 else
969 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); 990 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
991 mutex_unlock(&drm->dev->mode_config.mutex);
992
970 drm_helper_hpd_irq_event(connector->dev); 993 drm_helper_hpd_irq_event(connector->dev);
971 } 994 }
972 995
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index 5392e07edfc6..3d0dc199b253 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -28,6 +28,9 @@
28 * Ben Skeggs <bskeggs@redhat.com> 28 * Ben Skeggs <bskeggs@redhat.com>
29 */ 29 */
30 30
31#include <linux/debugfs.h>
32#include <nvif/class.h>
33#include <nvif/if0001.h>
31#include "nouveau_debugfs.h" 34#include "nouveau_debugfs.h"
32#include "nouveau_drm.h" 35#include "nouveau_drm.h"
33 36
@@ -43,22 +46,233 @@ nouveau_debugfs_vbios_image(struct seq_file *m, void *data)
43 return 0; 46 return 0;
44} 47}
45 48
49static int
50nouveau_debugfs_pstate_get(struct seq_file *m, void *data)
51{
52 struct drm_info_node *node = (struct drm_info_node *) m->private;
53 struct nouveau_debugfs *debugfs = nouveau_debugfs(node->minor->dev);
54 struct nvif_object *ctrl = &debugfs->ctrl;
55 struct nvif_control_pstate_info_v0 info = {};
56 int ret, i;
57
58 if (!debugfs)
59 return -ENODEV;
60
61 ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_INFO, &info, sizeof(info));
62 if (ret)
63 return ret;
64
65 for (i = 0; i < info.count + 1; i++) {
66 const s32 state = i < info.count ? i :
67 NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT;
68 struct nvif_control_pstate_attr_v0 attr = {
69 .state = state,
70 .index = 0,
71 };
72
73 ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_ATTR,
74 &attr, sizeof(attr));
75 if (ret)
76 return ret;
77
78 if (i < info.count)
79 seq_printf(m, "%02x:", attr.state);
80 else
81 seq_printf(m, "%s:", info.pwrsrc == 0 ? "DC" :
82 info.pwrsrc == 1 ? "AC" : "--");
83
84 attr.index = 0;
85 do {
86 attr.state = state;
87 ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_ATTR,
88 &attr, sizeof(attr));
89 if (ret)
90 return ret;
91
92 seq_printf(m, " %s %d", attr.name, attr.min);
93 if (attr.min != attr.max)
94 seq_printf(m, "-%d", attr.max);
95 seq_printf(m, " %s", attr.unit);
96 } while (attr.index);
97
98 if (state >= 0) {
99 if (info.ustate_ac == state)
100 seq_printf(m, " AC");
101 if (info.ustate_dc == state)
102 seq_printf(m, " DC");
103 if (info.pstate == state)
104 seq_printf(m, " *");
105 } else {
106 if (info.ustate_ac < -1)
107 seq_printf(m, " AC");
108 if (info.ustate_dc < -1)
109 seq_printf(m, " DC");
110 }
111
112 seq_printf(m, "\n");
113 }
114
115 return 0;
116}
117
118static ssize_t
119nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf,
120 size_t len, loff_t *offp)
121{
122 struct seq_file *m = file->private_data;
123 struct drm_info_node *node = (struct drm_info_node *) m->private;
124 struct nouveau_debugfs *debugfs = nouveau_debugfs(node->minor->dev);
125 struct nvif_object *ctrl = &debugfs->ctrl;
126 struct nvif_control_pstate_user_v0 args = { .pwrsrc = -EINVAL };
127 char buf[32] = {}, *tmp, *cur = buf;
128 long value, ret;
129
130 if (!debugfs)
131 return -ENODEV;
132
133 if (len >= sizeof(buf))
134 return -EINVAL;
135
136 if (copy_from_user(buf, ubuf, len))
137 return -EFAULT;
138
139 if ((tmp = strchr(buf, '\n')))
140 *tmp = '\0';
141
142 if (!strncasecmp(cur, "dc:", 3)) {
143 args.pwrsrc = 0;
144 cur += 3;
145 } else
146 if (!strncasecmp(cur, "ac:", 3)) {
147 args.pwrsrc = 1;
148 cur += 3;
149 }
150
151 if (!strcasecmp(cur, "none"))
152 args.ustate = NVIF_CONTROL_PSTATE_USER_V0_STATE_UNKNOWN;
153 else
154 if (!strcasecmp(cur, "auto"))
155 args.ustate = NVIF_CONTROL_PSTATE_USER_V0_STATE_PERFMON;
156 else {
157 ret = kstrtol(cur, 16, &value);
158 if (ret)
159 return ret;
160 args.ustate = value;
161 }
162
163 ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_USER, &args, sizeof(args));
164 if (ret < 0)
165 return ret;
166
167 return len;
168}
169
170static int
171nouveau_debugfs_pstate_open(struct inode *inode, struct file *file)
172{
173 return single_open(file, nouveau_debugfs_pstate_get, inode->i_private);
174}
175
176static const struct file_operations nouveau_pstate_fops = {
177 .owner = THIS_MODULE,
178 .open = nouveau_debugfs_pstate_open,
179 .read = seq_read,
180 .write = nouveau_debugfs_pstate_set,
181};
182
46static struct drm_info_list nouveau_debugfs_list[] = { 183static struct drm_info_list nouveau_debugfs_list[] = {
47 { "vbios.rom", nouveau_debugfs_vbios_image, 0, NULL }, 184 { "vbios.rom", nouveau_debugfs_vbios_image, 0, NULL },
48}; 185};
49#define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list) 186#define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)
50 187
51int 188static const struct nouveau_debugfs_files {
52nouveau_debugfs_init(struct drm_minor *minor) 189 const char *name;
190 const struct file_operations *fops;
191} nouveau_debugfs_files[] = {
192 {"pstate", &nouveau_pstate_fops},
193};
194
195static int
196nouveau_debugfs_create_file(struct drm_minor *minor,
197 const struct nouveau_debugfs_files *ndf)
53{ 198{
54 drm_debugfs_create_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES, 199 struct drm_info_node *node;
55 minor->debugfs_root, minor); 200
201 node = kmalloc(sizeof(*node), GFP_KERNEL);
202 if (node == NULL)
203 return -ENOMEM;
204
205 node->minor = minor;
206 node->info_ent = (const void *)ndf->fops;
207 node->dent = debugfs_create_file(ndf->name, S_IRUGO | S_IWUSR,
208 minor->debugfs_root, node, ndf->fops);
209 if (!node->dent) {
210 kfree(node);
211 return -ENOMEM;
212 }
213
214 mutex_lock(&minor->debugfs_lock);
215 list_add(&node->list, &minor->debugfs_list);
216 mutex_unlock(&minor->debugfs_lock);
56 return 0; 217 return 0;
57} 218}
58 219
220int
221nouveau_drm_debugfs_init(struct drm_minor *minor)
222{
223 int i, ret;
224
225 for (i = 0; i < ARRAY_SIZE(nouveau_debugfs_files); i++) {
226 ret = nouveau_debugfs_create_file(minor,
227 &nouveau_debugfs_files[i]);
228
229 if (ret)
230 return ret;
231 }
232
233 return drm_debugfs_create_files(nouveau_debugfs_list,
234 NOUVEAU_DEBUGFS_ENTRIES,
235 minor->debugfs_root, minor);
236}
237
59void 238void
60nouveau_debugfs_takedown(struct drm_minor *minor) 239nouveau_drm_debugfs_cleanup(struct drm_minor *minor)
61{ 240{
241 int i;
242
62 drm_debugfs_remove_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES, 243 drm_debugfs_remove_files(nouveau_debugfs_list, NOUVEAU_DEBUGFS_ENTRIES,
63 minor); 244 minor);
245
246 for (i = 0; i < ARRAY_SIZE(nouveau_debugfs_files); i++) {
247 drm_debugfs_remove_files((struct drm_info_list *)
248 nouveau_debugfs_files[i].fops,
249 1, minor);
250 }
251}
252
253int
254nouveau_debugfs_init(struct nouveau_drm *drm)
255{
256 int ret;
257
258 drm->debugfs = kzalloc(sizeof(*drm->debugfs), GFP_KERNEL);
259 if (!drm->debugfs)
260 return -ENOMEM;
261
262 ret = nvif_object_init(&drm->device.object, 0, NVIF_CLASS_CONTROL,
263 NULL, 0, &drm->debugfs->ctrl);
264 if (ret)
265 return ret;
266
267 return 0;
268}
269
270void
271nouveau_debugfs_fini(struct nouveau_drm *drm)
272{
273 if (drm->debugfs && drm->debugfs->ctrl.priv)
274 nvif_object_fini(&drm->debugfs->ctrl);
275
276 kfree(drm->debugfs);
277 drm->debugfs = NULL;
64} 278}
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.h b/drivers/gpu/drm/nouveau/nouveau_debugfs.h
index a62af6fb5f99..b8c03ff5bf05 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.h
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.h
@@ -4,16 +4,43 @@
4#include <drm/drmP.h> 4#include <drm/drmP.h>
5 5
6#if defined(CONFIG_DEBUG_FS) 6#if defined(CONFIG_DEBUG_FS)
7extern int nouveau_debugfs_init(struct drm_minor *); 7
8extern void nouveau_debugfs_takedown(struct drm_minor *); 8#include "nouveau_drm.h"
9
10struct nouveau_debugfs {
11 struct nvif_object ctrl;
12};
13
14static inline struct nouveau_debugfs *
15nouveau_debugfs(struct drm_device *dev)
16{
17 return nouveau_drm(dev)->debugfs;
18}
19
20extern int nouveau_drm_debugfs_init(struct drm_minor *);
21extern void nouveau_drm_debugfs_cleanup(struct drm_minor *);
22extern int nouveau_debugfs_init(struct nouveau_drm *);
23extern void nouveau_debugfs_fini(struct nouveau_drm *);
9#else 24#else
10static inline int 25static inline int
11nouveau_debugfs_init(struct drm_minor *minor) 26nouveau_drm_debugfs_init(struct drm_minor *minor)
12{ 27{
13 return 0; 28 return 0;
14} 29}
15 30
16static inline void nouveau_debugfs_takedown(struct drm_minor *minor) 31static inline void
32nouveau_drm_debugfs_cleanup(struct drm_minor *minor)
33{
34}
35
36static inline int
37nouveau_debugfs_init(struct nouveau_drm *drm)
38{
39 return 0;
40}
41
42static inline void
43nouveau_debugfs_fini(struct nouveau_drm *drm)
17{ 44{
18} 45}
19 46
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 18676b8c1721..24be27d3cd18 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -39,6 +39,7 @@
39 39
40#include "nouveau_fence.h" 40#include "nouveau_fence.h"
41 41
42#include <nvif/cl0046.h>
42#include <nvif/event.h> 43#include <nvif/event.h>
43 44
44static int 45static int
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index b3a563c44bcd..2f2f252e3fb6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -37,12 +37,16 @@
37#include <core/pci.h> 37#include <core/pci.h>
38#include <core/tegra.h> 38#include <core/tegra.h>
39 39
40#include <nvif/class.h>
41#include <nvif/cl0002.h>
42#include <nvif/cla06f.h>
43#include <nvif/if0004.h>
44
40#include "nouveau_drm.h" 45#include "nouveau_drm.h"
41#include "nouveau_dma.h" 46#include "nouveau_dma.h"
42#include "nouveau_ttm.h" 47#include "nouveau_ttm.h"
43#include "nouveau_gem.h" 48#include "nouveau_gem.h"
44#include "nouveau_vga.h" 49#include "nouveau_vga.h"
45#include "nouveau_sysfs.h"
46#include "nouveau_hwmon.h" 50#include "nouveau_hwmon.h"
47#include "nouveau_acpi.h" 51#include "nouveau_acpi.h"
48#include "nouveau_bios.h" 52#include "nouveau_bios.h"
@@ -256,8 +260,8 @@ nouveau_accel_init(struct nouveau_drm *drm)
256 } 260 }
257 261
258 ret = nvif_notify_init(&drm->nvsw, nouveau_flip_complete, 262 ret = nvif_notify_init(&drm->nvsw, nouveau_flip_complete,
259 false, NVSW_NTFY_UEVENT, NULL, 0, 0, 263 false, NV04_NVSW_NTFY_UEVENT,
260 &drm->flip); 264 NULL, 0, 0, &drm->flip);
261 if (ret == 0) 265 if (ret == 0)
262 ret = nvif_notify_get(&drm->flip); 266 ret = nvif_notify_get(&drm->flip);
263 if (ret) { 267 if (ret) {
@@ -448,7 +452,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
448 goto fail_dispinit; 452 goto fail_dispinit;
449 } 453 }
450 454
451 nouveau_sysfs_init(dev); 455 nouveau_debugfs_init(drm);
452 nouveau_hwmon_init(dev); 456 nouveau_hwmon_init(dev);
453 nouveau_accel_init(drm); 457 nouveau_accel_init(drm);
454 nouveau_fbcon_init(dev); 458 nouveau_fbcon_init(dev);
@@ -486,7 +490,7 @@ nouveau_drm_unload(struct drm_device *dev)
486 nouveau_fbcon_fini(dev); 490 nouveau_fbcon_fini(dev);
487 nouveau_accel_fini(drm); 491 nouveau_accel_fini(drm);
488 nouveau_hwmon_fini(dev); 492 nouveau_hwmon_fini(dev);
489 nouveau_sysfs_fini(dev); 493 nouveau_debugfs_fini(drm);
490 494
491 if (dev->mode_config.num_crtc) 495 if (dev->mode_config.num_crtc)
492 nouveau_display_fini(dev); 496 nouveau_display_fini(dev);
@@ -928,8 +932,8 @@ driver_stub = {
928 .lastclose = nouveau_vga_lastclose, 932 .lastclose = nouveau_vga_lastclose,
929 933
930#if defined(CONFIG_DEBUG_FS) 934#if defined(CONFIG_DEBUG_FS)
931 .debugfs_init = nouveau_debugfs_init, 935 .debugfs_init = nouveau_drm_debugfs_init,
932 .debugfs_cleanup = nouveau_debugfs_takedown, 936 .debugfs_cleanup = nouveau_drm_debugfs_cleanup,
933#endif 937#endif
934 938
935 .get_vblank_counter = drm_vblank_no_hw_counter, 939 .get_vblank_counter = drm_vblank_no_hw_counter,
@@ -1003,7 +1007,6 @@ static void nouveau_display_options(void)
1003 DRM_DEBUG_DRIVER("... modeset : %d\n", nouveau_modeset); 1007 DRM_DEBUG_DRIVER("... modeset : %d\n", nouveau_modeset);
1004 DRM_DEBUG_DRIVER("... runpm : %d\n", nouveau_runtime_pm); 1008 DRM_DEBUG_DRIVER("... runpm : %d\n", nouveau_runtime_pm);
1005 DRM_DEBUG_DRIVER("... vram_pushbuf : %d\n", nouveau_vram_pushbuf); 1009 DRM_DEBUG_DRIVER("... vram_pushbuf : %d\n", nouveau_vram_pushbuf);
1006 DRM_DEBUG_DRIVER("... pstate : %d\n", nouveau_pstate);
1007} 1010}
1008 1011
1009static const struct dev_pm_ops nouveau_pm_ops = { 1012static const struct dev_pm_ops nouveau_pm_ops = {
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
index a02813e994ec..5c363ed1c842 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
@@ -164,7 +164,7 @@ struct nouveau_drm {
164 164
165 /* power management */ 165 /* power management */
166 struct nouveau_hwmon *hwmon; 166 struct nouveau_hwmon *hwmon;
167 struct nouveau_sysfs *sysfs; 167 struct nouveau_debugfs *debugfs;
168 168
169 /* display power reference */ 169 /* display power reference */
170 bool have_disp_power_ref; 170 bool have_disp_power_ref;
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 574c36b492ee..9a8c5b727f59 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -30,6 +30,7 @@
30#include <linux/hrtimer.h> 30#include <linux/hrtimer.h>
31#include <trace/events/fence.h> 31#include <trace/events/fence.h>
32 32
33#include <nvif/cl826e.h>
33#include <nvif/notify.h> 34#include <nvif/notify.h>
34#include <nvif/event.h> 35#include <nvif/event.h>
35 36
diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
index 491c7149d197..8e13467d0ddb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
@@ -34,6 +34,8 @@
34#include "nouveau_drm.h" 34#include "nouveau_drm.h"
35#include "nouveau_hwmon.h" 35#include "nouveau_hwmon.h"
36 36
37#include <nvkm/subdev/volt.h>
38
37#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)) 39#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
38static ssize_t 40static ssize_t
39nouveau_hwmon_show_temp(struct device *d, struct device_attribute *a, char *buf) 41nouveau_hwmon_show_temp(struct device *d, struct device_attribute *a, char *buf)
@@ -512,6 +514,35 @@ static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO | S_IWUSR,
512 nouveau_hwmon_get_pwm1_max, 514 nouveau_hwmon_get_pwm1_max,
513 nouveau_hwmon_set_pwm1_max, 0); 515 nouveau_hwmon_set_pwm1_max, 0);
514 516
517static ssize_t
518nouveau_hwmon_get_in0_input(struct device *d,
519 struct device_attribute *a, char *buf)
520{
521 struct drm_device *dev = dev_get_drvdata(d);
522 struct nouveau_drm *drm = nouveau_drm(dev);
523 struct nvkm_volt *volt = nvxx_volt(&drm->device);
524 int ret;
525
526 ret = nvkm_volt_get(volt);
527 if (ret < 0)
528 return ret;
529
530 return sprintf(buf, "%i\n", ret / 1000);
531}
532
533static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO,
534 nouveau_hwmon_get_in0_input, NULL, 0);
535
536static ssize_t
537nouveau_hwmon_get_in0_label(struct device *d,
538 struct device_attribute *a, char *buf)
539{
540 return sprintf(buf, "GPU core\n");
541}
542
543static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO,
544 nouveau_hwmon_get_in0_label, NULL, 0);
545
515static struct attribute *hwmon_default_attributes[] = { 546static struct attribute *hwmon_default_attributes[] = {
516 &sensor_dev_attr_name.dev_attr.attr, 547 &sensor_dev_attr_name.dev_attr.attr,
517 &sensor_dev_attr_update_rate.dev_attr.attr, 548 &sensor_dev_attr_update_rate.dev_attr.attr,
@@ -542,6 +573,12 @@ static struct attribute *hwmon_pwm_fan_attributes[] = {
542 NULL 573 NULL
543}; 574};
544 575
576static struct attribute *hwmon_in0_attributes[] = {
577 &sensor_dev_attr_in0_input.dev_attr.attr,
578 &sensor_dev_attr_in0_label.dev_attr.attr,
579 NULL
580};
581
545static const struct attribute_group hwmon_default_attrgroup = { 582static const struct attribute_group hwmon_default_attrgroup = {
546 .attrs = hwmon_default_attributes, 583 .attrs = hwmon_default_attributes,
547}; 584};
@@ -554,6 +591,9 @@ static const struct attribute_group hwmon_fan_rpm_attrgroup = {
554static const struct attribute_group hwmon_pwm_fan_attrgroup = { 591static const struct attribute_group hwmon_pwm_fan_attrgroup = {
555 .attrs = hwmon_pwm_fan_attributes, 592 .attrs = hwmon_pwm_fan_attributes,
556}; 593};
594static const struct attribute_group hwmon_in0_attrgroup = {
595 .attrs = hwmon_in0_attributes,
596};
557#endif 597#endif
558 598
559int 599int
@@ -562,6 +602,7 @@ nouveau_hwmon_init(struct drm_device *dev)
562#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)) 602#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
563 struct nouveau_drm *drm = nouveau_drm(dev); 603 struct nouveau_drm *drm = nouveau_drm(dev);
564 struct nvkm_therm *therm = nvxx_therm(&drm->device); 604 struct nvkm_therm *therm = nvxx_therm(&drm->device);
605 struct nvkm_volt *volt = nvxx_volt(&drm->device);
565 struct nouveau_hwmon *hwmon; 606 struct nouveau_hwmon *hwmon;
566 struct device *hwmon_dev; 607 struct device *hwmon_dev;
567 int ret = 0; 608 int ret = 0;
@@ -613,6 +654,14 @@ nouveau_hwmon_init(struct drm_device *dev)
613 goto error; 654 goto error;
614 } 655 }
615 656
657 if (volt && nvkm_volt_get(volt) >= 0) {
658 ret = sysfs_create_group(&hwmon_dev->kobj,
659 &hwmon_in0_attrgroup);
660
661 if (ret)
662 goto error;
663 }
664
616 hwmon->hwmon = hwmon_dev; 665 hwmon->hwmon = hwmon_dev;
617 666
618 return 0; 667 return 0;
@@ -638,6 +687,7 @@ nouveau_hwmon_fini(struct drm_device *dev)
638 sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_temp_attrgroup); 687 sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_temp_attrgroup);
639 sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_pwm_fan_attrgroup); 688 sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_pwm_fan_attrgroup);
640 sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_fan_rpm_attrgroup); 689 sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_fan_rpm_attrgroup);
690 sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_in0_attrgroup);
641 691
642 hwmon_device_unregister(hwmon->hwmon); 692 hwmon_device_unregister(hwmon->hwmon);
643 } 693 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/nouveau/nouveau_platform.c
index 60e32c4e4e49..8a70cec59bcd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_platform.c
+++ b/drivers/gpu/drm/nouveau/nouveau_platform.c
@@ -78,3 +78,14 @@ struct platform_driver nouveau_platform_driver = {
78 .probe = nouveau_platform_probe, 78 .probe = nouveau_platform_probe,
79 .remove = nouveau_platform_remove, 79 .remove = nouveau_platform_remove,
80}; 80};
81
82#if IS_ENABLED(CONFIG_ARCH_TEGRA_124_SOC) || IS_ENABLED(CONFIG_ARCH_TEGRA_132_SOC)
83MODULE_FIRMWARE("nvidia/gk20a/fecs_data.bin");
84MODULE_FIRMWARE("nvidia/gk20a/fecs_inst.bin");
85MODULE_FIRMWARE("nvidia/gk20a/gpccs_data.bin");
86MODULE_FIRMWARE("nvidia/gk20a/gpccs_inst.bin");
87MODULE_FIRMWARE("nvidia/gk20a/sw_bundle_init.bin");
88MODULE_FIRMWARE("nvidia/gk20a/sw_ctx.bin");
89MODULE_FIRMWARE("nvidia/gk20a/sw_method_init.bin");
90MODULE_FIRMWARE("nvidia/gk20a/sw_nonctx.bin");
91#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_sysfs.c b/drivers/gpu/drm/nouveau/nouveau_sysfs.c
deleted file mode 100644
index 5dac3546c1b8..000000000000
--- a/drivers/gpu/drm/nouveau/nouveau_sysfs.c
+++ /dev/null
@@ -1,197 +0,0 @@
1/*
2 * Copyright 2013 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24
25#include <nvif/os.h>
26#include <nvif/class.h>
27#include <nvif/ioctl.h>
28
29#include "nouveau_sysfs.h"
30
31MODULE_PARM_DESC(pstate, "enable sysfs pstate file, which will be moved in the future");
32int nouveau_pstate;
33module_param_named(pstate, nouveau_pstate, int, 0400);
34
35static inline struct drm_device *
36drm_device(struct device *d)
37{
38 return dev_get_drvdata(d);
39}
40
41#define snappendf(p,r,f,a...) do { \
42 snprintf(p, r, f, ##a); \
43 r -= strlen(p); \
44 p += strlen(p); \
45} while(0)
46
47static ssize_t
48nouveau_sysfs_pstate_get(struct device *d, struct device_attribute *a, char *b)
49{
50 struct nouveau_sysfs *sysfs = nouveau_sysfs(drm_device(d));
51 struct nvif_control_pstate_info_v0 info = {};
52 size_t cnt = PAGE_SIZE;
53 char *buf = b;
54 int ret, i;
55
56 ret = nvif_mthd(&sysfs->ctrl, NVIF_CONTROL_PSTATE_INFO,
57 &info, sizeof(info));
58 if (ret)
59 return ret;
60
61 for (i = 0; i < info.count + 1; i++) {
62 const s32 state = i < info.count ? i :
63 NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT;
64 struct nvif_control_pstate_attr_v0 attr = {
65 .state = state,
66 .index = 0,
67 };
68
69 ret = nvif_mthd(&sysfs->ctrl, NVIF_CONTROL_PSTATE_ATTR,
70 &attr, sizeof(attr));
71 if (ret)
72 return ret;
73
74 if (i < info.count)
75 snappendf(buf, cnt, "%02x:", attr.state);
76 else
77 snappendf(buf, cnt, "%s:", info.pwrsrc == 0 ? "DC" :
78 info.pwrsrc == 1 ? "AC" :
79 "--");
80
81 attr.index = 0;
82 do {
83 attr.state = state;
84 ret = nvif_mthd(&sysfs->ctrl,
85 NVIF_CONTROL_PSTATE_ATTR,
86 &attr, sizeof(attr));
87 if (ret)
88 return ret;
89
90 snappendf(buf, cnt, " %s %d", attr.name, attr.min);
91 if (attr.min != attr.max)
92 snappendf(buf, cnt, "-%d", attr.max);
93 snappendf(buf, cnt, " %s", attr.unit);
94 } while (attr.index);
95
96 if (state >= 0) {
97 if (info.ustate_ac == state)
98 snappendf(buf, cnt, " AC");
99 if (info.ustate_dc == state)
100 snappendf(buf, cnt, " DC");
101 if (info.pstate == state)
102 snappendf(buf, cnt, " *");
103 } else {
104 if (info.ustate_ac < -1)
105 snappendf(buf, cnt, " AC");
106 if (info.ustate_dc < -1)
107 snappendf(buf, cnt, " DC");
108 }
109
110 snappendf(buf, cnt, "\n");
111 }
112
113 return strlen(b);
114}
115
116static ssize_t
117nouveau_sysfs_pstate_set(struct device *d, struct device_attribute *a,
118 const char *buf, size_t count)
119{
120 struct nouveau_sysfs *sysfs = nouveau_sysfs(drm_device(d));
121 struct nvif_control_pstate_user_v0 args = { .pwrsrc = -EINVAL };
122 long value, ret;
123 char *tmp;
124
125 if ((tmp = strchr(buf, '\n')))
126 *tmp = '\0';
127
128 if (!strncasecmp(buf, "dc:", 3)) {
129 args.pwrsrc = 0;
130 buf += 3;
131 } else
132 if (!strncasecmp(buf, "ac:", 3)) {
133 args.pwrsrc = 1;
134 buf += 3;
135 }
136
137 if (!strcasecmp(buf, "none"))
138 args.ustate = NVIF_CONTROL_PSTATE_USER_V0_STATE_UNKNOWN;
139 else
140 if (!strcasecmp(buf, "auto"))
141 args.ustate = NVIF_CONTROL_PSTATE_USER_V0_STATE_PERFMON;
142 else {
143 ret = kstrtol(buf, 16, &value);
144 if (ret)
145 return ret;
146 args.ustate = value;
147 }
148
149 ret = nvif_mthd(&sysfs->ctrl, NVIF_CONTROL_PSTATE_USER,
150 &args, sizeof(args));
151 if (ret < 0)
152 return ret;
153
154 return count;
155}
156
157static DEVICE_ATTR(pstate, S_IRUGO | S_IWUSR,
158 nouveau_sysfs_pstate_get, nouveau_sysfs_pstate_set);
159
160void
161nouveau_sysfs_fini(struct drm_device *dev)
162{
163 struct nouveau_sysfs *sysfs = nouveau_sysfs(dev);
164 struct nouveau_drm *drm = nouveau_drm(dev);
165 struct nvif_device *device = &drm->device;
166
167 if (sysfs && sysfs->ctrl.priv) {
168 device_remove_file(nvxx_device(device)->dev, &dev_attr_pstate);
169 nvif_object_fini(&sysfs->ctrl);
170 }
171
172 drm->sysfs = NULL;
173 kfree(sysfs);
174}
175
176int
177nouveau_sysfs_init(struct drm_device *dev)
178{
179 struct nouveau_drm *drm = nouveau_drm(dev);
180 struct nvif_device *device = &drm->device;
181 struct nouveau_sysfs *sysfs;
182 int ret;
183
184 if (!nouveau_pstate)
185 return 0;
186
187 sysfs = drm->sysfs = kzalloc(sizeof(*sysfs), GFP_KERNEL);
188 if (!sysfs)
189 return -ENOMEM;
190
191 ret = nvif_object_init(&device->object, 0, NVIF_IOCTL_NEW_V0_CONTROL,
192 NULL, 0, &sysfs->ctrl);
193 if (ret == 0)
194 device_create_file(nvxx_device(device)->dev, &dev_attr_pstate);
195
196 return 0;
197}
diff --git a/drivers/gpu/drm/nouveau/nouveau_sysfs.h b/drivers/gpu/drm/nouveau/nouveau_sysfs.h
deleted file mode 100644
index 4e5ea9241b28..000000000000
--- a/drivers/gpu/drm/nouveau/nouveau_sysfs.h
+++ /dev/null
@@ -1,21 +0,0 @@
1#ifndef __NOUVEAU_SYSFS_H__
2#define __NOUVEAU_SYSFS_H__
3
4#include "nouveau_drm.h"
5
6struct nouveau_sysfs {
7 struct nvif_object ctrl;
8};
9
10static inline struct nouveau_sysfs *
11nouveau_sysfs(struct drm_device *dev)
12{
13 return nouveau_drm(dev)->sysfs;
14}
15
16int nouveau_sysfs_init(struct drm_device *);
17void nouveau_sysfs_fini(struct drm_device *);
18
19extern int nouveau_pstate;
20
21#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c b/drivers/gpu/drm/nouveau/nouveau_usif.c
index 6ae1b3494bcd..e9f52ef0be83 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -130,20 +130,21 @@ usif_notify_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
130 struct nvif_notify_req_v0 v0; 130 struct nvif_notify_req_v0 v0;
131 } *req; 131 } *req;
132 struct usif_notify *ntfy; 132 struct usif_notify *ntfy;
133 int ret; 133 int ret = -ENOSYS;
134 134
135 if (nvif_unpack(args->v0, 0, 0, true)) { 135 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
136 if (usif_notify_find(f, args->v0.index)) 136 if (usif_notify_find(f, args->v0.index))
137 return -EEXIST; 137 return -EEXIST;
138 } else 138 } else
139 return ret; 139 return ret;
140 req = data; 140 req = data;
141 ret = -ENOSYS;
141 142
142 if (!(ntfy = kmalloc(sizeof(*ntfy), GFP_KERNEL))) 143 if (!(ntfy = kmalloc(sizeof(*ntfy), GFP_KERNEL)))
143 return -ENOMEM; 144 return -ENOMEM;
144 atomic_set(&ntfy->enabled, 0); 145 atomic_set(&ntfy->enabled, 0);
145 146
146 if (nvif_unpack(req->v0, 0, 0, true)) { 147 if (!(ret = nvif_unpack(ret, &data, &size, req->v0, 0, 0, true))) {
147 ntfy->reply = sizeof(struct nvif_notify_rep_v0) + req->v0.reply; 148 ntfy->reply = sizeof(struct nvif_notify_rep_v0) + req->v0.reply;
148 ntfy->route = req->v0.route; 149 ntfy->route = req->v0.route;
149 ntfy->token = req->v0.token; 150 ntfy->token = req->v0.token;
@@ -171,9 +172,9 @@ usif_notify_del(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
171 struct nvif_ioctl_ntfy_del_v0 v0; 172 struct nvif_ioctl_ntfy_del_v0 v0;
172 } *args = data; 173 } *args = data;
173 struct usif_notify *ntfy; 174 struct usif_notify *ntfy;
174 int ret; 175 int ret = -ENOSYS;
175 176
176 if (nvif_unpack(args->v0, 0, 0, true)) { 177 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
177 if (!(ntfy = usif_notify_find(f, args->v0.index))) 178 if (!(ntfy = usif_notify_find(f, args->v0.index)))
178 return -ENOENT; 179 return -ENOENT;
179 } else 180 } else
@@ -194,9 +195,9 @@ usif_notify_get(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
194 struct nvif_ioctl_ntfy_del_v0 v0; 195 struct nvif_ioctl_ntfy_del_v0 v0;
195 } *args = data; 196 } *args = data;
196 struct usif_notify *ntfy; 197 struct usif_notify *ntfy;
197 int ret; 198 int ret = -ENOSYS;
198 199
199 if (nvif_unpack(args->v0, 0, 0, true)) { 200 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
200 if (!(ntfy = usif_notify_find(f, args->v0.index))) 201 if (!(ntfy = usif_notify_find(f, args->v0.index)))
201 return -ENOENT; 202 return -ENOENT;
202 } else 203 } else
@@ -233,9 +234,9 @@ usif_notify_put(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
233 struct nvif_ioctl_ntfy_put_v0 v0; 234 struct nvif_ioctl_ntfy_put_v0 v0;
234 } *args = data; 235 } *args = data;
235 struct usif_notify *ntfy; 236 struct usif_notify *ntfy;
236 int ret; 237 int ret = -ENOSYS;
237 238
238 if (nvif_unpack(args->v0, 0, 0, true)) { 239 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
239 if (!(ntfy = usif_notify_find(f, args->v0.index))) 240 if (!(ntfy = usif_notify_find(f, args->v0.index)))
240 return -ENOENT; 241 return -ENOENT;
241 } else 242 } else
@@ -270,13 +271,13 @@ usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
270 struct nvif_ioctl_new_v0 v0; 271 struct nvif_ioctl_new_v0 v0;
271 } *args = data; 272 } *args = data;
272 struct usif_object *object; 273 struct usif_object *object;
273 int ret; 274 int ret = -ENOSYS;
274 275
275 if (!(object = kmalloc(sizeof(*object), GFP_KERNEL))) 276 if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
276 return -ENOMEM; 277 return -ENOMEM;
277 list_add(&object->head, &cli->objects); 278 list_add(&object->head, &cli->objects);
278 279
279 if (nvif_unpack(args->v0, 0, 0, true)) { 280 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
280 object->route = args->v0.route; 281 object->route = args->v0.route;
281 object->token = args->v0.token; 282 object->token = args->v0.token;
282 args->v0.route = NVDRM_OBJECT_USIF; 283 args->v0.route = NVDRM_OBJECT_USIF;
@@ -310,7 +311,7 @@ usif_ioctl(struct drm_file *filp, void __user *user, u32 argc)
310 if (ret = -EFAULT, copy_from_user(argv, user, size)) 311 if (ret = -EFAULT, copy_from_user(argv, user, size))
311 goto done; 312 goto done;
312 313
313 if (nvif_unpack(argv->v0, 0, 0, true)) { 314 if (!(ret = nvif_unpack(-ENOSYS, &data, &size, argv->v0, 0, 0, true))) {
314 /* block access to objects not created via this interface */ 315 /* block access to objects not created via this interface */
315 owner = argv->v0.owner; 316 owner = argv->v0.owner;
316 if (argv->v0.object == 0ULL) 317 if (argv->v0.object == 0ULL)
diff --git a/drivers/gpu/drm/nouveau/nv04_fence.c b/drivers/gpu/drm/nouveau/nv04_fence.c
index f3d705d67738..3022d24ed88b 100644
--- a/drivers/gpu/drm/nouveau/nv04_fence.c
+++ b/drivers/gpu/drm/nouveau/nv04_fence.c
@@ -26,6 +26,8 @@
26#include "nouveau_dma.h" 26#include "nouveau_dma.h"
27#include "nouveau_fence.h" 27#include "nouveau_fence.h"
28 28
29#include <nvif/if0004.h>
30
29struct nv04_fence_chan { 31struct nv04_fence_chan {
30 struct nouveau_fence_chan base; 32 struct nouveau_fence_chan base;
31}; 33};
diff --git a/drivers/gpu/drm/nouveau/nv17_fence.c b/drivers/gpu/drm/nouveau/nv17_fence.c
index 80b6eb8b3d02..6a141c9bf5b7 100644
--- a/drivers/gpu/drm/nouveau/nv17_fence.c
+++ b/drivers/gpu/drm/nouveau/nv17_fence.c
@@ -24,6 +24,7 @@
24 24
25#include <nvif/os.h> 25#include <nvif/os.h>
26#include <nvif/class.h> 26#include <nvif/class.h>
27#include <nvif/cl0002.h>
27 28
28#include "nouveau_drm.h" 29#include "nouveau_drm.h"
29#include "nouveau_dma.h" 30#include "nouveau_dma.h"
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 44e1952582aa..ea3921652449 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -31,6 +31,13 @@
31#include <drm/drm_fb_helper.h> 31#include <drm/drm_fb_helper.h>
32 32
33#include <nvif/class.h> 33#include <nvif/class.h>
34#include <nvif/cl0002.h>
35#include <nvif/cl5070.h>
36#include <nvif/cl507a.h>
37#include <nvif/cl507b.h>
38#include <nvif/cl507c.h>
39#include <nvif/cl507d.h>
40#include <nvif/cl507e.h>
34 41
35#include "nouveau_drm.h" 42#include "nouveau_drm.h"
36#include "nouveau_dma.h" 43#include "nouveau_dma.h"
@@ -774,7 +781,6 @@ nv50_crtc_set_scale(struct nouveau_crtc *nv_crtc, bool update)
774 */ 781 */
775 if (nv_connector && ( nv_connector->underscan == UNDERSCAN_ON || 782 if (nv_connector && ( nv_connector->underscan == UNDERSCAN_ON ||
776 (nv_connector->underscan == UNDERSCAN_AUTO && 783 (nv_connector->underscan == UNDERSCAN_AUTO &&
777 nv_connector->edid &&
778 drm_detect_hdmi_monitor(nv_connector->edid)))) { 784 drm_detect_hdmi_monitor(nv_connector->edid)))) {
779 u32 bX = nv_connector->underscan_hborder; 785 u32 bX = nv_connector->underscan_hborder;
780 u32 bY = nv_connector->underscan_vborder; 786 u32 bY = nv_connector->underscan_vborder;
@@ -1962,10 +1968,17 @@ nv50_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *umode,
1962 switch (nv_encoder->dcb->type) { 1968 switch (nv_encoder->dcb->type) {
1963 case DCB_OUTPUT_TMDS: 1969 case DCB_OUTPUT_TMDS:
1964 if (nv_encoder->dcb->sorconf.link & 1) { 1970 if (nv_encoder->dcb->sorconf.link & 1) {
1965 if (mode->clock < 165000) 1971 proto = 0x1;
1966 proto = 0x1; 1972 /* Only enable dual-link if:
1967 else 1973 * - Need to (i.e. rate > 165MHz)
1968 proto = 0x5; 1974 * - DCB says we can
1975 * - Not an HDMI monitor, since there's no dual-link
1976 * on HDMI.
1977 */
1978 if (mode->clock >= 165000 &&
1979 nv_encoder->dcb->duallink_possible &&
1980 !drm_detect_hdmi_monitor(nv_connector->edid))
1981 proto |= 0x4;
1969 } else { 1982 } else {
1970 proto = 0x2; 1983 proto = 0x2;
1971 } 1984 }
diff --git a/drivers/gpu/drm/nouveau/nv50_fence.c b/drivers/gpu/drm/nouveau/nv50_fence.c
index f0d96e5da6b4..3695ccce68c7 100644
--- a/drivers/gpu/drm/nouveau/nv50_fence.c
+++ b/drivers/gpu/drm/nouveau/nv50_fence.c
@@ -24,6 +24,7 @@
24 24
25#include <nvif/os.h> 25#include <nvif/os.h>
26#include <nvif/class.h> 26#include <nvif/class.h>
27#include <nvif/cl0002.h>
27 28
28#include "nouveau_drm.h" 29#include "nouveau_drm.h"
29#include "nouveau_dma.h" 30#include "nouveau_dma.h"
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index 297e1e953fa6..e1943910858e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -28,6 +28,7 @@
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/event.h> 30#include <nvif/event.h>
31#include <nvif/if0000.h>
31#include <nvif/unpack.h> 32#include <nvif/unpack.h>
32 33
33struct nvkm_client_notify { 34struct nvkm_client_notify {
@@ -96,7 +97,7 @@ nvkm_client_notify_new(struct nvkm_object *object,
96 struct nvif_notify_req_v0 v0; 97 struct nvif_notify_req_v0 v0;
97 } *req = data; 98 } *req = data;
98 u8 index, reply; 99 u8 index, reply;
99 int ret; 100 int ret = -ENOSYS;
100 101
101 for (index = 0; index < ARRAY_SIZE(client->notify); index++) { 102 for (index = 0; index < ARRAY_SIZE(client->notify); index++) {
102 if (!client->notify[index]) 103 if (!client->notify[index])
@@ -111,7 +112,7 @@ nvkm_client_notify_new(struct nvkm_object *object,
111 return -ENOMEM; 112 return -ENOMEM;
112 113
113 nvif_ioctl(object, "notify new size %d\n", size); 114 nvif_ioctl(object, "notify new size %d\n", size);
114 if (nvif_unpack(req->v0, 0, 0, true)) { 115 if (!(ret = nvif_unpack(ret, &data, &size, req->v0, 0, 0, true))) {
115 nvif_ioctl(object, "notify new vers %d reply %d route %02x " 116 nvif_ioctl(object, "notify new vers %d reply %d route %02x "
116 "token %llx\n", req->v0.version, 117 "token %llx\n", req->v0.version,
117 req->v0.reply, req->v0.route, req->v0.token); 118 req->v0.reply, req->v0.route, req->v0.token);
@@ -143,10 +144,10 @@ nvkm_client_mthd_devlist(struct nvkm_object *object, void *data, u32 size)
143 union { 144 union {
144 struct nv_client_devlist_v0 v0; 145 struct nv_client_devlist_v0 v0;
145 } *args = data; 146 } *args = data;
146 int ret; 147 int ret = -ENOSYS;
147 148
148 nvif_ioctl(object, "client devlist size %d\n", size); 149 nvif_ioctl(object, "client devlist size %d\n", size);
149 if (nvif_unpack(args->v0, 0, 0, true)) { 150 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
150 nvif_ioctl(object, "client devlist vers %d count %d\n", 151 nvif_ioctl(object, "client devlist vers %d count %d\n",
151 args->v0.version, args->v0.count); 152 args->v0.version, args->v0.count);
152 if (size == sizeof(args->v0.device[0]) * args->v0.count) { 153 if (size == sizeof(args->v0.device[0]) * args->v0.count) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index d87d6ab03cc7..b0db51847c36 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -34,10 +34,10 @@ nvkm_ioctl_nop(struct nvkm_object *object, void *data, u32 size)
34 union { 34 union {
35 struct nvif_ioctl_nop_v0 v0; 35 struct nvif_ioctl_nop_v0 v0;
36 } *args = data; 36 } *args = data;
37 int ret; 37 int ret = -ENOSYS;
38 38
39 nvif_ioctl(object, "nop size %d\n", size); 39 nvif_ioctl(object, "nop size %d\n", size);
40 if (nvif_unpack(args->v0, 0, 0, false)) { 40 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
41 nvif_ioctl(object, "nop vers %lld\n", args->v0.version); 41 nvif_ioctl(object, "nop vers %lld\n", args->v0.version);
42 args->v0.version = NVIF_VERSION_LATEST; 42 args->v0.version = NVIF_VERSION_LATEST;
43 } 43 }
@@ -52,10 +52,10 @@ nvkm_ioctl_sclass(struct nvkm_object *object, void *data, u32 size)
52 struct nvif_ioctl_sclass_v0 v0; 52 struct nvif_ioctl_sclass_v0 v0;
53 } *args = data; 53 } *args = data;
54 struct nvkm_oclass oclass; 54 struct nvkm_oclass oclass;
55 int ret, i = 0; 55 int ret = -ENOSYS, i = 0;
56 56
57 nvif_ioctl(object, "sclass size %d\n", size); 57 nvif_ioctl(object, "sclass size %d\n", size);
58 if (nvif_unpack(args->v0, 0, 0, true)) { 58 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
59 nvif_ioctl(object, "sclass vers %d count %d\n", 59 nvif_ioctl(object, "sclass vers %d count %d\n",
60 args->v0.version, args->v0.count); 60 args->v0.version, args->v0.count);
61 if (size != args->v0.count * sizeof(args->v0.oclass[0])) 61 if (size != args->v0.count * sizeof(args->v0.oclass[0]))
@@ -86,10 +86,10 @@ nvkm_ioctl_new(struct nvkm_object *parent, void *data, u32 size)
86 struct nvkm_client *client = parent->client; 86 struct nvkm_client *client = parent->client;
87 struct nvkm_object *object = NULL; 87 struct nvkm_object *object = NULL;
88 struct nvkm_oclass oclass; 88 struct nvkm_oclass oclass;
89 int ret, i = 0; 89 int ret = -ENOSYS, i = 0;
90 90
91 nvif_ioctl(parent, "new size %d\n", size); 91 nvif_ioctl(parent, "new size %d\n", size);
92 if (nvif_unpack(args->v0, 0, 0, true)) { 92 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
93 nvif_ioctl(parent, "new vers %d handle %08x class %08x " 93 nvif_ioctl(parent, "new vers %d handle %08x class %08x "
94 "route %02x token %llx object %016llx\n", 94 "route %02x token %llx object %016llx\n",
95 args->v0.version, args->v0.handle, args->v0.oclass, 95 args->v0.version, args->v0.handle, args->v0.oclass,
@@ -147,10 +147,10 @@ nvkm_ioctl_del(struct nvkm_object *object, void *data, u32 size)
147 union { 147 union {
148 struct nvif_ioctl_del none; 148 struct nvif_ioctl_del none;
149 } *args = data; 149 } *args = data;
150 int ret; 150 int ret = -ENOSYS;
151 151
152 nvif_ioctl(object, "delete size %d\n", size); 152 nvif_ioctl(object, "delete size %d\n", size);
153 if (nvif_unvers(args->none)) { 153 if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
154 nvif_ioctl(object, "delete\n"); 154 nvif_ioctl(object, "delete\n");
155 nvkm_object_fini(object, false); 155 nvkm_object_fini(object, false);
156 nvkm_object_del(&object); 156 nvkm_object_del(&object);
@@ -165,10 +165,10 @@ nvkm_ioctl_mthd(struct nvkm_object *object, void *data, u32 size)
165 union { 165 union {
166 struct nvif_ioctl_mthd_v0 v0; 166 struct nvif_ioctl_mthd_v0 v0;
167 } *args = data; 167 } *args = data;
168 int ret; 168 int ret = -ENOSYS;
169 169
170 nvif_ioctl(object, "mthd size %d\n", size); 170 nvif_ioctl(object, "mthd size %d\n", size);
171 if (nvif_unpack(args->v0, 0, 0, true)) { 171 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
172 nvif_ioctl(object, "mthd vers %d mthd %02x\n", 172 nvif_ioctl(object, "mthd vers %d mthd %02x\n",
173 args->v0.version, args->v0.method); 173 args->v0.version, args->v0.method);
174 ret = nvkm_object_mthd(object, args->v0.method, data, size); 174 ret = nvkm_object_mthd(object, args->v0.method, data, size);
@@ -189,10 +189,10 @@ nvkm_ioctl_rd(struct nvkm_object *object, void *data, u32 size)
189 u16 b16; 189 u16 b16;
190 u32 b32; 190 u32 b32;
191 } v; 191 } v;
192 int ret; 192 int ret = -ENOSYS;
193 193
194 nvif_ioctl(object, "rd size %d\n", size); 194 nvif_ioctl(object, "rd size %d\n", size);
195 if (nvif_unpack(args->v0, 0, 0, false)) { 195 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
196 nvif_ioctl(object, "rd vers %d size %d addr %016llx\n", 196 nvif_ioctl(object, "rd vers %d size %d addr %016llx\n",
197 args->v0.version, args->v0.size, args->v0.addr); 197 args->v0.version, args->v0.size, args->v0.addr);
198 switch (args->v0.size) { 198 switch (args->v0.size) {
@@ -223,10 +223,10 @@ nvkm_ioctl_wr(struct nvkm_object *object, void *data, u32 size)
223 union { 223 union {
224 struct nvif_ioctl_wr_v0 v0; 224 struct nvif_ioctl_wr_v0 v0;
225 } *args = data; 225 } *args = data;
226 int ret; 226 int ret = -ENOSYS;
227 227
228 nvif_ioctl(object, "wr size %d\n", size); 228 nvif_ioctl(object, "wr size %d\n", size);
229 if (nvif_unpack(args->v0, 0, 0, false)) { 229 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
230 nvif_ioctl(object, 230 nvif_ioctl(object,
231 "wr vers %d size %d addr %016llx data %08x\n", 231 "wr vers %d size %d addr %016llx data %08x\n",
232 args->v0.version, args->v0.size, args->v0.addr, 232 args->v0.version, args->v0.size, args->v0.addr,
@@ -251,10 +251,10 @@ nvkm_ioctl_map(struct nvkm_object *object, void *data, u32 size)
251 union { 251 union {
252 struct nvif_ioctl_map_v0 v0; 252 struct nvif_ioctl_map_v0 v0;
253 } *args = data; 253 } *args = data;
254 int ret; 254 int ret = -ENOSYS;
255 255
256 nvif_ioctl(object, "map size %d\n", size); 256 nvif_ioctl(object, "map size %d\n", size);
257 if (nvif_unpack(args->v0, 0, 0, false)) { 257 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
258 nvif_ioctl(object, "map vers %d\n", args->v0.version); 258 nvif_ioctl(object, "map vers %d\n", args->v0.version);
259 ret = nvkm_object_map(object, &args->v0.handle, 259 ret = nvkm_object_map(object, &args->v0.handle,
260 &args->v0.length); 260 &args->v0.length);
@@ -269,10 +269,10 @@ nvkm_ioctl_unmap(struct nvkm_object *object, void *data, u32 size)
269 union { 269 union {
270 struct nvif_ioctl_unmap none; 270 struct nvif_ioctl_unmap none;
271 } *args = data; 271 } *args = data;
272 int ret; 272 int ret = -ENOSYS;
273 273
274 nvif_ioctl(object, "unmap size %d\n", size); 274 nvif_ioctl(object, "unmap size %d\n", size);
275 if (nvif_unvers(args->none)) { 275 if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
276 nvif_ioctl(object, "unmap\n"); 276 nvif_ioctl(object, "unmap\n");
277 } 277 }
278 278
@@ -286,10 +286,10 @@ nvkm_ioctl_ntfy_new(struct nvkm_object *object, void *data, u32 size)
286 struct nvif_ioctl_ntfy_new_v0 v0; 286 struct nvif_ioctl_ntfy_new_v0 v0;
287 } *args = data; 287 } *args = data;
288 struct nvkm_event *event; 288 struct nvkm_event *event;
289 int ret; 289 int ret = -ENOSYS;
290 290
291 nvif_ioctl(object, "ntfy new size %d\n", size); 291 nvif_ioctl(object, "ntfy new size %d\n", size);
292 if (nvif_unpack(args->v0, 0, 0, true)) { 292 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
293 nvif_ioctl(object, "ntfy new vers %d event %02x\n", 293 nvif_ioctl(object, "ntfy new vers %d event %02x\n",
294 args->v0.version, args->v0.event); 294 args->v0.version, args->v0.event);
295 ret = nvkm_object_ntfy(object, args->v0.event, &event); 295 ret = nvkm_object_ntfy(object, args->v0.event, &event);
@@ -312,10 +312,10 @@ nvkm_ioctl_ntfy_del(struct nvkm_object *object, void *data, u32 size)
312 union { 312 union {
313 struct nvif_ioctl_ntfy_del_v0 v0; 313 struct nvif_ioctl_ntfy_del_v0 v0;
314 } *args = data; 314 } *args = data;
315 int ret; 315 int ret = -ENOSYS;
316 316
317 nvif_ioctl(object, "ntfy del size %d\n", size); 317 nvif_ioctl(object, "ntfy del size %d\n", size);
318 if (nvif_unpack(args->v0, 0, 0, false)) { 318 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
319 nvif_ioctl(object, "ntfy del vers %d index %d\n", 319 nvif_ioctl(object, "ntfy del vers %d index %d\n",
320 args->v0.version, args->v0.index); 320 args->v0.version, args->v0.index);
321 ret = nvkm_client_notify_del(client, args->v0.index); 321 ret = nvkm_client_notify_del(client, args->v0.index);
@@ -331,10 +331,10 @@ nvkm_ioctl_ntfy_get(struct nvkm_object *object, void *data, u32 size)
331 union { 331 union {
332 struct nvif_ioctl_ntfy_get_v0 v0; 332 struct nvif_ioctl_ntfy_get_v0 v0;
333 } *args = data; 333 } *args = data;
334 int ret; 334 int ret = -ENOSYS;
335 335
336 nvif_ioctl(object, "ntfy get size %d\n", size); 336 nvif_ioctl(object, "ntfy get size %d\n", size);
337 if (nvif_unpack(args->v0, 0, 0, false)) { 337 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
338 nvif_ioctl(object, "ntfy get vers %d index %d\n", 338 nvif_ioctl(object, "ntfy get vers %d index %d\n",
339 args->v0.version, args->v0.index); 339 args->v0.version, args->v0.index);
340 ret = nvkm_client_notify_get(client, args->v0.index); 340 ret = nvkm_client_notify_get(client, args->v0.index);
@@ -350,10 +350,10 @@ nvkm_ioctl_ntfy_put(struct nvkm_object *object, void *data, u32 size)
350 union { 350 union {
351 struct nvif_ioctl_ntfy_put_v0 v0; 351 struct nvif_ioctl_ntfy_put_v0 v0;
352 } *args = data; 352 } *args = data;
353 int ret; 353 int ret = -ENOSYS;
354 354
355 nvif_ioctl(object, "ntfy put size %d\n", size); 355 nvif_ioctl(object, "ntfy put size %d\n", size);
356 if (nvif_unpack(args->v0, 0, 0, false)) { 356 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
357 nvif_ioctl(object, "ntfy put vers %d index %d\n", 357 nvif_ioctl(object, "ntfy put vers %d index %d\n",
358 args->v0.version, args->v0.index); 358 args->v0.version, args->v0.index);
359 ret = nvkm_client_notify_put(client, args->v0.index); 359 ret = nvkm_client_notify_put(client, args->v0.index);
@@ -421,12 +421,12 @@ nvkm_ioctl(struct nvkm_client *client, bool supervisor,
421 union { 421 union {
422 struct nvif_ioctl_v0 v0; 422 struct nvif_ioctl_v0 v0;
423 } *args = data; 423 } *args = data;
424 int ret; 424 int ret = -ENOSYS;
425 425
426 client->super = supervisor; 426 client->super = supervisor;
427 nvif_ioctl(object, "size %d\n", size); 427 nvif_ioctl(object, "size %d\n", size);
428 428
429 if (nvif_unpack(args->v0, 0, 0, true)) { 429 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
430 nvif_ioctl(object, 430 nvif_ioctl(object,
431 "vers %d type %02x object %016llx owner %02x\n", 431 "vers %d type %02x object %016llx owner %02x\n",
432 args->v0.version, args->v0.type, args->v0.object, 432 args->v0.version, args->v0.type, args->v0.object,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/ce/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/ce/gk104.c
index c541a1c012dc..e2b944dce9b8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/ce/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/ce/gk104.c
@@ -22,19 +22,65 @@
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24#include "priv.h" 24#include "priv.h"
25#include <core/enum.h>
25 26
26#include <nvif/class.h> 27#include <nvif/class.h>
27 28
29static const struct nvkm_enum
30gk104_ce_launcherr_report[] = {
31 { 0x0, "NO_ERR" },
32 { 0x1, "2D_LAYER_EXCEEDS_DEPTH" },
33 { 0x2, "INVALID_ARGUMENT" },
34 { 0x3, "MEM2MEM_RECT_OUT_OF_BOUNDS" },
35 { 0x4, "SRC_LINE_EXCEEDS_PITCH" },
36 { 0x5, "SRC_LINE_EXCEEDS_NEG_PITCH" },
37 { 0x6, "DST_LINE_EXCEEDS_PITCH" },
38 { 0x7, "DST_LINE_EXCEEDS_NEG_PITCH" },
39 { 0x8, "BAD_SRC_PIXEL_COMP_REF" },
40 { 0x9, "INVALID_VALUE" },
41 { 0xa, "UNUSED_FIELD" },
42 { 0xb, "INVALID_OPERATION" },
43 {}
44};
45
46static void
47gk104_ce_intr_launcherr(struct nvkm_engine *ce, const u32 base)
48{
49 struct nvkm_subdev *subdev = &ce->subdev;
50 struct nvkm_device *device = subdev->device;
51 u32 stat = nvkm_rd32(device, 0x104f14 + base);
52 const struct nvkm_enum *en =
53 nvkm_enum_find(gk104_ce_launcherr_report, stat & 0x0000000f);
54 nvkm_warn(subdev, "LAUNCHERR %08x [%s]\n", stat, en ? en->name : "");
55 nvkm_wr32(device, 0x104f14 + base, 0x00000000);
56}
57
28void 58void
29gk104_ce_intr(struct nvkm_engine *ce) 59gk104_ce_intr(struct nvkm_engine *ce)
30{ 60{
31 const u32 base = (ce->subdev.index - NVKM_ENGINE_CE0) * 0x1000; 61 const u32 base = (ce->subdev.index - NVKM_ENGINE_CE0) * 0x1000;
32 struct nvkm_subdev *subdev = &ce->subdev; 62 struct nvkm_subdev *subdev = &ce->subdev;
33 struct nvkm_device *device = subdev->device; 63 struct nvkm_device *device = subdev->device;
34 u32 stat = nvkm_rd32(device, 0x104908 + base); 64 u32 mask = nvkm_rd32(device, 0x104904 + base);
35 if (stat) { 65 u32 intr = nvkm_rd32(device, 0x104908 + base) & mask;
36 nvkm_warn(subdev, "intr %08x\n", stat); 66 if (intr & 0x00000001) {
37 nvkm_wr32(device, 0x104908 + base, stat); 67 nvkm_warn(subdev, "BLOCKPIPE\n");
68 nvkm_wr32(device, 0x104908 + base, 0x00000001);
69 intr &= ~0x00000001;
70 }
71 if (intr & 0x00000002) {
72 nvkm_warn(subdev, "NONBLOCKPIPE\n");
73 nvkm_wr32(device, 0x104908 + base, 0x00000002);
74 intr &= ~0x00000002;
75 }
76 if (intr & 0x00000004) {
77 gk104_ce_intr_launcherr(ce, base);
78 nvkm_wr32(device, 0x104908 + base, 0x00000004);
79 intr &= ~0x00000004;
80 }
81 if (intr) {
82 nvkm_warn(subdev, "intr %08x\n", intr);
83 nvkm_wr32(device, 0x104908 + base, intr);
38 } 84 }
39} 85}
40 86
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
index bbc9824af6e0..b1ba1c782a2b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
@@ -1388,7 +1388,7 @@ nvc1_chipset = {
1388 .mc = gf100_mc_new, 1388 .mc = gf100_mc_new,
1389 .mmu = gf100_mmu_new, 1389 .mmu = gf100_mmu_new,
1390 .mxm = nv50_mxm_new, 1390 .mxm = nv50_mxm_new,
1391 .pci = g94_pci_new, 1391 .pci = gf106_pci_new,
1392 .pmu = gf100_pmu_new, 1392 .pmu = gf100_pmu_new,
1393 .therm = gt215_therm_new, 1393 .therm = gt215_therm_new,
1394 .timer = nv41_timer_new, 1394 .timer = nv41_timer_new,
@@ -1423,7 +1423,7 @@ nvc3_chipset = {
1423 .mc = gf100_mc_new, 1423 .mc = gf100_mc_new,
1424 .mmu = gf100_mmu_new, 1424 .mmu = gf100_mmu_new,
1425 .mxm = nv50_mxm_new, 1425 .mxm = nv50_mxm_new,
1426 .pci = g94_pci_new, 1426 .pci = gf106_pci_new,
1427 .pmu = gf100_pmu_new, 1427 .pmu = gf100_pmu_new,
1428 .therm = gt215_therm_new, 1428 .therm = gt215_therm_new,
1429 .timer = nv41_timer_new, 1429 .timer = nv41_timer_new,
@@ -1566,7 +1566,7 @@ nvcf_chipset = {
1566 .mc = gf100_mc_new, 1566 .mc = gf100_mc_new,
1567 .mmu = gf100_mmu_new, 1567 .mmu = gf100_mmu_new,
1568 .mxm = nv50_mxm_new, 1568 .mxm = nv50_mxm_new,
1569 .pci = g94_pci_new, 1569 .pci = gf106_pci_new,
1570 .pmu = gf100_pmu_new, 1570 .pmu = gf100_pmu_new,
1571 .therm = gt215_therm_new, 1571 .therm = gt215_therm_new,
1572 .timer = nv41_timer_new, 1572 .timer = nv41_timer_new,
@@ -1601,7 +1601,7 @@ nvd7_chipset = {
1601 .mc = gf100_mc_new, 1601 .mc = gf100_mc_new,
1602 .mmu = gf100_mmu_new, 1602 .mmu = gf100_mmu_new,
1603 .mxm = nv50_mxm_new, 1603 .mxm = nv50_mxm_new,
1604 .pci = g94_pci_new, 1604 .pci = gf106_pci_new,
1605 .therm = gf119_therm_new, 1605 .therm = gf119_therm_new,
1606 .timer = nv41_timer_new, 1606 .timer = nv41_timer_new,
1607 .ce[0] = gf100_ce_new, 1607 .ce[0] = gf100_ce_new,
@@ -1634,7 +1634,7 @@ nvd9_chipset = {
1634 .mc = gf100_mc_new, 1634 .mc = gf100_mc_new,
1635 .mmu = gf100_mmu_new, 1635 .mmu = gf100_mmu_new,
1636 .mxm = nv50_mxm_new, 1636 .mxm = nv50_mxm_new,
1637 .pci = g94_pci_new, 1637 .pci = gf106_pci_new,
1638 .pmu = gf119_pmu_new, 1638 .pmu = gf119_pmu_new,
1639 .therm = gf119_therm_new, 1639 .therm = gf119_therm_new,
1640 .timer = nv41_timer_new, 1640 .timer = nv41_timer_new,
@@ -1669,7 +1669,7 @@ nve4_chipset = {
1669 .mc = gf100_mc_new, 1669 .mc = gf100_mc_new,
1670 .mmu = gf100_mmu_new, 1670 .mmu = gf100_mmu_new,
1671 .mxm = nv50_mxm_new, 1671 .mxm = nv50_mxm_new,
1672 .pci = g94_pci_new, 1672 .pci = gk104_pci_new,
1673 .pmu = gk104_pmu_new, 1673 .pmu = gk104_pmu_new,
1674 .therm = gf119_therm_new, 1674 .therm = gf119_therm_new,
1675 .timer = nv41_timer_new, 1675 .timer = nv41_timer_new,
@@ -1706,7 +1706,7 @@ nve6_chipset = {
1706 .mc = gf100_mc_new, 1706 .mc = gf100_mc_new,
1707 .mmu = gf100_mmu_new, 1707 .mmu = gf100_mmu_new,
1708 .mxm = nv50_mxm_new, 1708 .mxm = nv50_mxm_new,
1709 .pci = g94_pci_new, 1709 .pci = gk104_pci_new,
1710 .pmu = gk104_pmu_new, 1710 .pmu = gk104_pmu_new,
1711 .therm = gf119_therm_new, 1711 .therm = gf119_therm_new,
1712 .timer = nv41_timer_new, 1712 .timer = nv41_timer_new,
@@ -1743,7 +1743,7 @@ nve7_chipset = {
1743 .mc = gf100_mc_new, 1743 .mc = gf100_mc_new,
1744 .mmu = gf100_mmu_new, 1744 .mmu = gf100_mmu_new,
1745 .mxm = nv50_mxm_new, 1745 .mxm = nv50_mxm_new,
1746 .pci = g94_pci_new, 1746 .pci = gk104_pci_new,
1747 .pmu = gk104_pmu_new, 1747 .pmu = gk104_pmu_new,
1748 .therm = gf119_therm_new, 1748 .therm = gf119_therm_new,
1749 .timer = nv41_timer_new, 1749 .timer = nv41_timer_new,
@@ -1804,7 +1804,7 @@ nvf0_chipset = {
1804 .mc = gf100_mc_new, 1804 .mc = gf100_mc_new,
1805 .mmu = gf100_mmu_new, 1805 .mmu = gf100_mmu_new,
1806 .mxm = nv50_mxm_new, 1806 .mxm = nv50_mxm_new,
1807 .pci = g94_pci_new, 1807 .pci = gk104_pci_new,
1808 .pmu = gk110_pmu_new, 1808 .pmu = gk110_pmu_new,
1809 .therm = gf119_therm_new, 1809 .therm = gf119_therm_new,
1810 .timer = nv41_timer_new, 1810 .timer = nv41_timer_new,
@@ -1840,7 +1840,7 @@ nvf1_chipset = {
1840 .mc = gf100_mc_new, 1840 .mc = gf100_mc_new,
1841 .mmu = gf100_mmu_new, 1841 .mmu = gf100_mmu_new,
1842 .mxm = nv50_mxm_new, 1842 .mxm = nv50_mxm_new,
1843 .pci = g94_pci_new, 1843 .pci = gk104_pci_new,
1844 .pmu = gk110_pmu_new, 1844 .pmu = gk110_pmu_new,
1845 .therm = gf119_therm_new, 1845 .therm = gf119_therm_new,
1846 .timer = nv41_timer_new, 1846 .timer = nv41_timer_new,
@@ -1876,7 +1876,7 @@ nv106_chipset = {
1876 .mc = gk20a_mc_new, 1876 .mc = gk20a_mc_new,
1877 .mmu = gf100_mmu_new, 1877 .mmu = gf100_mmu_new,
1878 .mxm = nv50_mxm_new, 1878 .mxm = nv50_mxm_new,
1879 .pci = g94_pci_new, 1879 .pci = gk104_pci_new,
1880 .pmu = gk208_pmu_new, 1880 .pmu = gk208_pmu_new,
1881 .therm = gf119_therm_new, 1881 .therm = gf119_therm_new,
1882 .timer = nv41_timer_new, 1882 .timer = nv41_timer_new,
@@ -1912,7 +1912,7 @@ nv108_chipset = {
1912 .mc = gk20a_mc_new, 1912 .mc = gk20a_mc_new,
1913 .mmu = gf100_mmu_new, 1913 .mmu = gf100_mmu_new,
1914 .mxm = nv50_mxm_new, 1914 .mxm = nv50_mxm_new,
1915 .pci = g94_pci_new, 1915 .pci = gk104_pci_new,
1916 .pmu = gk208_pmu_new, 1916 .pmu = gk208_pmu_new,
1917 .therm = gf119_therm_new, 1917 .therm = gf119_therm_new,
1918 .timer = nv41_timer_new, 1918 .timer = nv41_timer_new,
@@ -1948,7 +1948,7 @@ nv117_chipset = {
1948 .mc = gk20a_mc_new, 1948 .mc = gk20a_mc_new,
1949 .mmu = gf100_mmu_new, 1949 .mmu = gf100_mmu_new,
1950 .mxm = nv50_mxm_new, 1950 .mxm = nv50_mxm_new,
1951 .pci = g94_pci_new, 1951 .pci = gk104_pci_new,
1952 .pmu = gm107_pmu_new, 1952 .pmu = gm107_pmu_new,
1953 .therm = gm107_therm_new, 1953 .therm = gm107_therm_new,
1954 .timer = gk20a_timer_new, 1954 .timer = gk20a_timer_new,
@@ -1973,13 +1973,13 @@ nv124_chipset = {
1973 .fuse = gm107_fuse_new, 1973 .fuse = gm107_fuse_new,
1974 .gpio = gk104_gpio_new, 1974 .gpio = gk104_gpio_new,
1975 .i2c = gm204_i2c_new, 1975 .i2c = gm204_i2c_new,
1976 .ibus = gk104_ibus_new, 1976 .ibus = gm204_ibus_new,
1977 .imem = nv50_instmem_new, 1977 .imem = nv50_instmem_new,
1978 .ltc = gm107_ltc_new, 1978 .ltc = gm204_ltc_new,
1979 .mc = gk20a_mc_new, 1979 .mc = gk20a_mc_new,
1980 .mmu = gf100_mmu_new, 1980 .mmu = gf100_mmu_new,
1981 .mxm = nv50_mxm_new, 1981 .mxm = nv50_mxm_new,
1982 .pci = g94_pci_new, 1982 .pci = gk104_pci_new,
1983 .pmu = gm107_pmu_new, 1983 .pmu = gm107_pmu_new,
1984 .timer = gk20a_timer_new, 1984 .timer = gk20a_timer_new,
1985 .volt = gk104_volt_new, 1985 .volt = gk104_volt_new,
@@ -2004,13 +2004,13 @@ nv126_chipset = {
2004 .fuse = gm107_fuse_new, 2004 .fuse = gm107_fuse_new,
2005 .gpio = gk104_gpio_new, 2005 .gpio = gk104_gpio_new,
2006 .i2c = gm204_i2c_new, 2006 .i2c = gm204_i2c_new,
2007 .ibus = gk104_ibus_new, 2007 .ibus = gm204_ibus_new,
2008 .imem = nv50_instmem_new, 2008 .imem = nv50_instmem_new,
2009 .ltc = gm107_ltc_new, 2009 .ltc = gm204_ltc_new,
2010 .mc = gk20a_mc_new, 2010 .mc = gk20a_mc_new,
2011 .mmu = gf100_mmu_new, 2011 .mmu = gf100_mmu_new,
2012 .mxm = nv50_mxm_new, 2012 .mxm = nv50_mxm_new,
2013 .pci = g94_pci_new, 2013 .pci = gk104_pci_new,
2014 .pmu = gm107_pmu_new, 2014 .pmu = gm107_pmu_new,
2015 .timer = gk20a_timer_new, 2015 .timer = gk20a_timer_new,
2016 .volt = gk104_volt_new, 2016 .volt = gk104_volt_new,
@@ -2033,7 +2033,7 @@ nv12b_chipset = {
2033 .fuse = gm107_fuse_new, 2033 .fuse = gm107_fuse_new,
2034 .ibus = gk20a_ibus_new, 2034 .ibus = gk20a_ibus_new,
2035 .imem = gk20a_instmem_new, 2035 .imem = gk20a_instmem_new,
2036 .ltc = gm107_ltc_new, 2036 .ltc = gm204_ltc_new,
2037 .mc = gk20a_mc_new, 2037 .mc = gk20a_mc_new,
2038 .mmu = gf100_mmu_new, 2038 .mmu = gf100_mmu_new,
2039 .timer = gk20a_timer_new, 2039 .timer = gk20a_timer_new,
@@ -2494,7 +2494,8 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
2494 device->pri = ioremap(mmio_base, mmio_size); 2494 device->pri = ioremap(mmio_base, mmio_size);
2495 if (!device->pri) { 2495 if (!device->pri) {
2496 nvdev_error(device, "unable to map PRI\n"); 2496 nvdev_error(device, "unable to map PRI\n");
2497 return -ENOMEM; 2497 ret = -ENOMEM;
2498 goto done;
2498 } 2499 }
2499 } 2500 }
2500 2501
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
index cf8bc068e9b7..b0ece71aefde 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
@@ -27,6 +27,7 @@
27#include <subdev/clk.h> 27#include <subdev/clk.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/if0001.h>
30#include <nvif/ioctl.h> 31#include <nvif/ioctl.h>
31#include <nvif/unpack.h> 32#include <nvif/unpack.h>
32 33
@@ -37,10 +38,10 @@ nvkm_control_mthd_pstate_info(struct nvkm_control *ctrl, void *data, u32 size)
37 struct nvif_control_pstate_info_v0 v0; 38 struct nvif_control_pstate_info_v0 v0;
38 } *args = data; 39 } *args = data;
39 struct nvkm_clk *clk = ctrl->device->clk; 40 struct nvkm_clk *clk = ctrl->device->clk;
40 int ret; 41 int ret = -ENOSYS;
41 42
42 nvif_ioctl(&ctrl->object, "control pstate info size %d\n", size); 43 nvif_ioctl(&ctrl->object, "control pstate info size %d\n", size);
43 if (nvif_unpack(args->v0, 0, 0, false)) { 44 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
44 nvif_ioctl(&ctrl->object, "control pstate info vers %d\n", 45 nvif_ioctl(&ctrl->object, "control pstate info vers %d\n",
45 args->v0.version); 46 args->v0.version);
46 } else 47 } else
@@ -75,10 +76,10 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)
75 struct nvkm_cstate *cstate; 76 struct nvkm_cstate *cstate;
76 int i = 0, j = -1; 77 int i = 0, j = -1;
77 u32 lo, hi; 78 u32 lo, hi;
78 int ret; 79 int ret = -ENOSYS;
79 80
80 nvif_ioctl(&ctrl->object, "control pstate attr size %d\n", size); 81 nvif_ioctl(&ctrl->object, "control pstate attr size %d\n", size);
81 if (nvif_unpack(args->v0, 0, 0, false)) { 82 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
82 nvif_ioctl(&ctrl->object, 83 nvif_ioctl(&ctrl->object,
83 "control pstate attr vers %d state %d index %d\n", 84 "control pstate attr vers %d state %d index %d\n",
84 args->v0.version, args->v0.state, args->v0.index); 85 args->v0.version, args->v0.state, args->v0.index);
@@ -143,10 +144,10 @@ nvkm_control_mthd_pstate_user(struct nvkm_control *ctrl, void *data, u32 size)
143 struct nvif_control_pstate_user_v0 v0; 144 struct nvif_control_pstate_user_v0 v0;
144 } *args = data; 145 } *args = data;
145 struct nvkm_clk *clk = ctrl->device->clk; 146 struct nvkm_clk *clk = ctrl->device->clk;
146 int ret; 147 int ret = -ENOSYS;
147 148
148 nvif_ioctl(&ctrl->object, "control pstate user size %d\n", size); 149 nvif_ioctl(&ctrl->object, "control pstate user size %d\n", size);
149 if (nvif_unpack(args->v0, 0, 0, false)) { 150 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
150 nvif_ioctl(&ctrl->object, 151 nvif_ioctl(&ctrl->object,
151 "control pstate user vers %d ustate %d pwrsrc %d\n", 152 "control pstate user vers %d ustate %d pwrsrc %d\n",
152 args->v0.version, args->v0.ustate, args->v0.pwrsrc); 153 args->v0.version, args->v0.ustate, args->v0.pwrsrc);
@@ -204,7 +205,7 @@ nvkm_control_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
204 205
205const struct nvkm_device_oclass 206const struct nvkm_device_oclass
206nvkm_control_oclass = { 207nvkm_control_oclass = {
207 .base.oclass = NVIF_IOCTL_NEW_V0_CONTROL, 208 .base.oclass = NVIF_CLASS_CONTROL,
208 .base.minver = -1, 209 .base.minver = -1,
209 .base.maxver = -1, 210 .base.maxver = -1,
210 .ctor = nvkm_control_new, 211 .ctor = nvkm_control_new,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/user.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
index 1ae48f27029d..137066426ed7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
@@ -31,6 +31,7 @@
31#include <subdev/timer.h> 31#include <subdev/timer.h>
32 32
33#include <nvif/class.h> 33#include <nvif/class.h>
34#include <nvif/cl0080.h>
34#include <nvif/unpack.h> 35#include <nvif/unpack.h>
35 36
36struct nvkm_udevice { 37struct nvkm_udevice {
@@ -48,10 +49,10 @@ nvkm_udevice_info(struct nvkm_udevice *udev, void *data, u32 size)
48 union { 49 union {
49 struct nv_device_info_v0 v0; 50 struct nv_device_info_v0 v0;
50 } *args = data; 51 } *args = data;
51 int ret; 52 int ret = -ENOSYS;
52 53
53 nvif_ioctl(object, "device info size %d\n", size); 54 nvif_ioctl(object, "device info size %d\n", size);
54 if (nvif_unpack(args->v0, 0, 0, false)) { 55 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
55 nvif_ioctl(object, "device info vers %d\n", args->v0.version); 56 nvif_ioctl(object, "device info vers %d\n", args->v0.version);
56 } else 57 } else
57 return ret; 58 return ret;
@@ -123,13 +124,16 @@ nvkm_udevice_info(struct nvkm_udevice *udev, void *data, u32 size)
123static int 124static int
124nvkm_udevice_time(struct nvkm_udevice *udev, void *data, u32 size) 125nvkm_udevice_time(struct nvkm_udevice *udev, void *data, u32 size)
125{ 126{
127 struct nvkm_object *object = &udev->object;
126 struct nvkm_device *device = udev->device; 128 struct nvkm_device *device = udev->device;
127 union { 129 union {
128 struct nv_device_time_v0 v0; 130 struct nv_device_time_v0 v0;
129 } *args = data; 131 } *args = data;
130 int ret; 132 int ret = -ENOSYS;
131 133
132 if (nvif_unpack(args->v0, 0, 0, false)) { 134 nvif_ioctl(object, "device time size %d\n", size);
135 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
136 nvif_ioctl(object, "device time vers %d\n", args->v0.version);
133 args->v0.time = nvkm_timer_read(device->timer); 137 args->v0.time = nvkm_timer_read(device->timer);
134 } 138 }
135 139
@@ -140,6 +144,7 @@ static int
140nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) 144nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
141{ 145{
142 struct nvkm_udevice *udev = nvkm_udevice(object); 146 struct nvkm_udevice *udev = nvkm_udevice(object);
147 nvif_ioctl(object, "device mthd %08x\n", mthd);
143 switch (mthd) { 148 switch (mthd) {
144 case NV_DEVICE_V0_INFO: 149 case NV_DEVICE_V0_INFO:
145 return nvkm_udevice_info(udev, data, size); 150 return nvkm_udevice_info(udev, data, size);
@@ -331,10 +336,10 @@ nvkm_udevice_new(const struct nvkm_oclass *oclass, void *data, u32 size,
331 struct nvkm_object *parent = &client->object; 336 struct nvkm_object *parent = &client->object;
332 const struct nvkm_object_func *func; 337 const struct nvkm_object_func *func;
333 struct nvkm_udevice *udev; 338 struct nvkm_udevice *udev;
334 int ret; 339 int ret = -ENOSYS;
335 340
336 nvif_ioctl(parent, "create device size %d\n", size); 341 nvif_ioctl(parent, "create device size %d\n", size);
337 if (nvif_unpack(args->v0, 0, 0, false)) { 342 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
338 nvif_ioctl(parent, "create device v%d device %016llx\n", 343 nvif_ioctl(parent, "create device v%d device %016llx\n",
339 args->v0.version, args->v0.device); 344 args->v0.version, args->v0.device);
340 } else 345 } else
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
index 44b67719f64d..785fa76d0fbf 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
@@ -32,6 +32,7 @@
32#include <subdev/bios/dcb.h> 32#include <subdev/bios/dcb.h>
33 33
34#include <nvif/class.h> 34#include <nvif/class.h>
35#include <nvif/cl0046.h>
35#include <nvif/event.h> 36#include <nvif/event.h>
36#include <nvif/unpack.h> 37#include <nvif/unpack.h>
37 38
@@ -58,9 +59,9 @@ nvkm_disp_vblank_ctor(struct nvkm_object *object, void *data, u32 size,
58 union { 59 union {
59 struct nvif_notify_head_req_v0 v0; 60 struct nvif_notify_head_req_v0 v0;
60 } *req = data; 61 } *req = data;
61 int ret; 62 int ret = -ENOSYS;
62 63
63 if (nvif_unpack(req->v0, 0, 0, false)) { 64 if (!(ret = nvif_unpack(ret, &data, &size, req->v0, 0, 0, false))) {
64 notify->size = sizeof(struct nvif_notify_head_rep_v0); 65 notify->size = sizeof(struct nvif_notify_head_rep_v0);
65 if (ret = -ENXIO, req->v0.head <= disp->vblank.index_nr) { 66 if (ret = -ENXIO, req->v0.head <= disp->vblank.index_nr) {
66 notify->types = 1; 67 notify->types = 1;
@@ -96,9 +97,9 @@ nvkm_disp_hpd_ctor(struct nvkm_object *object, void *data, u32 size,
96 struct nvif_notify_conn_req_v0 v0; 97 struct nvif_notify_conn_req_v0 v0;
97 } *req = data; 98 } *req = data;
98 struct nvkm_output *outp; 99 struct nvkm_output *outp;
99 int ret; 100 int ret = -ENOSYS;
100 101
101 if (nvif_unpack(req->v0, 0, 0, false)) { 102 if (!(ret = nvif_unpack(ret, &data, &size, req->v0, 0, 0, false))) {
102 notify->size = sizeof(struct nvif_notify_conn_rep_v0); 103 notify->size = sizeof(struct nvif_notify_conn_rep_v0);
103 list_for_each_entry(outp, &disp->outp, head) { 104 list_for_each_entry(outp, &disp->outp, head) {
104 if (ret = -ENXIO, outp->conn->index == req->v0.conn) { 105 if (ret = -ENXIO, outp->conn->index == req->v0.conn) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/basenv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/basenv50.c
index 1fd89edefc26..83f152300ec0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/basenv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/basenv50.c
@@ -27,6 +27,7 @@
27#include <core/client.h> 27#include <core/client.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/cl507c.h>
30#include <nvif/unpack.h> 31#include <nvif/unpack.h>
31 32
32int 33int
@@ -41,11 +42,11 @@ nv50_disp_base_new(const struct nv50_disp_dmac_func *func,
41 } *args = data; 42 } *args = data;
42 struct nvkm_object *parent = oclass->parent; 43 struct nvkm_object *parent = oclass->parent;
43 struct nv50_disp *disp = root->disp; 44 struct nv50_disp *disp = root->disp;
44 int head, ret; 45 int head, ret = -ENOSYS;
45 u64 push; 46 u64 push;
46 47
47 nvif_ioctl(parent, "create disp base channel dma size %d\n", size); 48 nvif_ioctl(parent, "create disp base channel dma size %d\n", size);
48 if (nvif_unpack(args->v0, 0, 0, false)) { 49 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
49 nvif_ioctl(parent, "create disp base channel dma vers %d " 50 nvif_ioctl(parent, "create disp base channel dma vers %d "
50 "pushbuf %016llx head %d\n", 51 "pushbuf %016llx head %d\n",
51 args->v0.version, args->v0.pushbuf, args->v0.head); 52 args->v0.version, args->v0.pushbuf, args->v0.head);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
index 01803c0679b6..dd2953bc9264 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
@@ -28,7 +28,7 @@
28#include <core/ramht.h> 28#include <core/ramht.h>
29#include <engine/dma.h> 29#include <engine/dma.h>
30 30
31#include <nvif/class.h> 31#include <nvif/cl507d.h>
32#include <nvif/event.h> 32#include <nvif/event.h>
33#include <nvif/unpack.h> 33#include <nvif/unpack.h>
34 34
@@ -134,9 +134,9 @@ nv50_disp_chan_uevent_ctor(struct nvkm_object *object, void *data, u32 size,
134 union { 134 union {
135 struct nvif_notify_uevent_req none; 135 struct nvif_notify_uevent_req none;
136 } *args = data; 136 } *args = data;
137 int ret; 137 int ret = -ENOSYS;
138 138
139 if (nvif_unvers(args->none)) { 139 if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
140 notify->size = sizeof(struct nvif_notify_uevent_rep); 140 notify->size = sizeof(struct nvif_notify_uevent_rep);
141 notify->types = 1; 141 notify->types = 1;
142 notify->index = chan->chid; 142 notify->index = chan->chid;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c
index db4a9b3e0e09..b547c8b833ca 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c
@@ -28,6 +28,7 @@
28#include <subdev/timer.h> 28#include <subdev/timer.h>
29 29
30#include <nvif/class.h> 30#include <nvif/class.h>
31#include <nvif/cl507d.h>
31#include <nvif/unpack.h> 32#include <nvif/unpack.h>
32 33
33int 34int
@@ -42,10 +43,10 @@ nv50_disp_core_new(const struct nv50_disp_dmac_func *func,
42 } *args = data; 43 } *args = data;
43 struct nvkm_object *parent = oclass->parent; 44 struct nvkm_object *parent = oclass->parent;
44 u64 push; 45 u64 push;
45 int ret; 46 int ret = -ENOSYS;
46 47
47 nvif_ioctl(parent, "create disp core channel dma size %d\n", size); 48 nvif_ioctl(parent, "create disp core channel dma size %d\n", size);
48 if (nvif_unpack(args->v0, 0, 0, false)) { 49 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
49 nvif_ioctl(parent, "create disp core channel dma vers %d " 50 nvif_ioctl(parent, "create disp core channel dma vers %d "
50 "pushbuf %016llx\n", 51 "pushbuf %016llx\n",
51 args->v0.version, args->v0.pushbuf); 52 args->v0.version, args->v0.pushbuf);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/cursnv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/cursnv50.c
index 225858e62cf6..8b1320499a0f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/cursnv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/cursnv50.c
@@ -27,6 +27,7 @@
27#include <core/client.h> 27#include <core/client.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/cl507a.h>
30#include <nvif/unpack.h> 31#include <nvif/unpack.h>
31 32
32int 33int
@@ -41,10 +42,10 @@ nv50_disp_curs_new(const struct nv50_disp_chan_func *func,
41 } *args = data; 42 } *args = data;
42 struct nvkm_object *parent = oclass->parent; 43 struct nvkm_object *parent = oclass->parent;
43 struct nv50_disp *disp = root->disp; 44 struct nv50_disp *disp = root->disp;
44 int head, ret; 45 int head, ret = -ENOSYS;
45 46
46 nvif_ioctl(parent, "create disp cursor size %d\n", size); 47 nvif_ioctl(parent, "create disp cursor size %d\n", size);
47 if (nvif_unpack(args->v0, 0, 0, false)) { 48 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
48 nvif_ioctl(parent, "create disp cursor vers %d head %d\n", 49 nvif_ioctl(parent, "create disp cursor vers %d head %d\n",
49 args->v0.version, args->v0.head); 50 args->v0.version, args->v0.head);
50 if (args->v0.head > disp->base.head.nr) 51 if (args->v0.head > disp->base.head.nr)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c
index 9bfa9e7dc161..c9b78b8f9c87 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c
@@ -27,7 +27,7 @@
27#include <core/client.h> 27#include <core/client.h>
28#include <subdev/timer.h> 28#include <subdev/timer.h>
29 29
30#include <nvif/class.h> 30#include <nvif/cl5070.h>
31#include <nvif/unpack.h> 31#include <nvif/unpack.h>
32 32
33int 33int
@@ -39,10 +39,10 @@ nv50_dac_power(NV50_DISP_MTHD_V1)
39 struct nv50_disp_dac_pwr_v0 v0; 39 struct nv50_disp_dac_pwr_v0 v0;
40 } *args = data; 40 } *args = data;
41 u32 stat; 41 u32 stat;
42 int ret; 42 int ret = -ENOSYS;
43 43
44 nvif_ioctl(object, "disp dac pwr size %d\n", size); 44 nvif_ioctl(object, "disp dac pwr size %d\n", size);
45 if (nvif_unpack(args->v0, 0, 0, false)) { 45 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
46 nvif_ioctl(object, "disp dac pwr vers %d state %d data %d " 46 nvif_ioctl(object, "disp dac pwr vers %d state %d data %d "
47 "vsync %d hsync %d\n", 47 "vsync %d hsync %d\n",
48 args->v0.version, args->v0.state, args->v0.data, 48 args->v0.version, args->v0.state, args->v0.data,
@@ -76,10 +76,10 @@ nv50_dac_sense(NV50_DISP_MTHD_V1)
76 } *args = data; 76 } *args = data;
77 const u32 doff = outp->or * 0x800; 77 const u32 doff = outp->or * 0x800;
78 u32 loadval; 78 u32 loadval;
79 int ret; 79 int ret = -ENOSYS;
80 80
81 nvif_ioctl(object, "disp dac load size %d\n", size); 81 nvif_ioctl(object, "disp dac load size %d\n", size);
82 if (nvif_unpack(args->v0, 0, 0, false)) { 82 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
83 nvif_ioctl(object, "disp dac load vers %d data %08x\n", 83 nvif_ioctl(object, "disp dac load vers %d data %08x\n",
84 args->v0.version, args->v0.data); 84 args->v0.version, args->v0.data);
85 if (args->v0.data & 0xfff00000) 85 if (args->v0.data & 0xfff00000)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
index 186fd3ac78f6..f0314664349c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
@@ -158,7 +158,7 @@ exec_clkcmp(struct nv50_disp *disp, int head, int id, u32 pclk, u32 *conf)
158 switch (outp->info.type) { 158 switch (outp->info.type) {
159 case DCB_OUTPUT_TMDS: 159 case DCB_OUTPUT_TMDS:
160 *conf = (ctrl & 0x00000f00) >> 8; 160 *conf = (ctrl & 0x00000f00) >> 8;
161 if (pclk >= 165000) 161 if (*conf == 5)
162 *conf |= 0x0100; 162 *conf |= 0x0100;
163 break; 163 break;
164 case DCB_OUTPUT_LVDS: 164 case DCB_OUTPUT_LVDS:
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagf119.c
index af99efbd63f7..da6129b2b78f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagf119.c
@@ -29,7 +29,7 @@
29#include <subdev/bios/dcb.h> 29#include <subdev/bios/dcb.h>
30#include <subdev/timer.h> 30#include <subdev/timer.h>
31 31
32#include <nvif/class.h> 32#include <nvif/cl5070.h>
33#include <nvif/unpack.h> 33#include <nvif/unpack.h>
34 34
35int 35int
@@ -41,10 +41,10 @@ gf119_hda_eld(NV50_DISP_MTHD_V1)
41 } *args = data; 41 } *args = data;
42 const u32 soff = outp->or * 0x030; 42 const u32 soff = outp->or * 0x030;
43 const u32 hoff = head * 0x800; 43 const u32 hoff = head * 0x800;
44 int ret, i; 44 int ret = -ENOSYS, i;
45 45
46 nvif_ioctl(object, "disp sor hda eld size %d\n", size); 46 nvif_ioctl(object, "disp sor hda eld size %d\n", size);
47 if (nvif_unpack(args->v0, 0, 0, true)) { 47 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
48 nvif_ioctl(object, "disp sor hda eld vers %d\n", 48 nvif_ioctl(object, "disp sor hda eld vers %d\n",
49 args->v0.version); 49 args->v0.version);
50 if (size > 0x60) 50 if (size > 0x60)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagt215.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagt215.c
index c1590b746f13..6f0436df0219 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagt215.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagt215.c
@@ -27,7 +27,7 @@
27#include <core/client.h> 27#include <core/client.h>
28#include <subdev/timer.h> 28#include <subdev/timer.h>
29 29
30#include <nvif/class.h> 30#include <nvif/cl5070.h>
31#include <nvif/unpack.h> 31#include <nvif/unpack.h>
32 32
33int 33int
@@ -38,10 +38,10 @@ gt215_hda_eld(NV50_DISP_MTHD_V1)
38 struct nv50_disp_sor_hda_eld_v0 v0; 38 struct nv50_disp_sor_hda_eld_v0 v0;
39 } *args = data; 39 } *args = data;
40 const u32 soff = outp->or * 0x800; 40 const u32 soff = outp->or * 0x800;
41 int ret, i; 41 int ret = -ENOSYS, i;
42 42
43 nvif_ioctl(object, "disp sor hda eld size %d\n", size); 43 nvif_ioctl(object, "disp sor hda eld size %d\n", size);
44 if (nvif_unpack(args->v0, 0, 0, true)) { 44 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
45 nvif_ioctl(object, "disp sor hda eld vers %d\n", 45 nvif_ioctl(object, "disp sor hda eld vers %d\n",
46 args->v0.version); 46 args->v0.version);
47 if (size > 0x60) 47 if (size > 0x60)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c
index ee9e800a8f06..1c4256e8cbd6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c
@@ -25,7 +25,7 @@
25 25
26#include <core/client.h> 26#include <core/client.h>
27 27
28#include <nvif/class.h> 28#include <nvif/cl5070.h>
29#include <nvif/unpack.h> 29#include <nvif/unpack.h>
30 30
31int 31int
@@ -37,10 +37,10 @@ g84_hdmi_ctrl(NV50_DISP_MTHD_V1)
37 struct nv50_disp_sor_hdmi_pwr_v0 v0; 37 struct nv50_disp_sor_hdmi_pwr_v0 v0;
38 } *args = data; 38 } *args = data;
39 u32 ctrl; 39 u32 ctrl;
40 int ret; 40 int ret = -ENOSYS;
41 41
42 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size); 42 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
43 if (nvif_unpack(args->v0, 0, 0, false)) { 43 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
44 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d " 44 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
45 "max_ac_packet %d rekey %d\n", 45 "max_ac_packet %d rekey %d\n",
46 args->v0.version, args->v0.state, 46 args->v0.version, args->v0.state,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c
index b5af025d3b04..632f02da1382 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c
@@ -25,7 +25,7 @@
25 25
26#include <core/client.h> 26#include <core/client.h>
27 27
28#include <nvif/class.h> 28#include <nvif/cl5070.h>
29#include <nvif/unpack.h> 29#include <nvif/unpack.h>
30 30
31int 31int
@@ -37,10 +37,10 @@ gf119_hdmi_ctrl(NV50_DISP_MTHD_V1)
37 struct nv50_disp_sor_hdmi_pwr_v0 v0; 37 struct nv50_disp_sor_hdmi_pwr_v0 v0;
38 } *args = data; 38 } *args = data;
39 u32 ctrl; 39 u32 ctrl;
40 int ret; 40 int ret = -ENOSYS;
41 41
42 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size); 42 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
43 if (nvif_unpack(args->v0, 0, 0, false)) { 43 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
44 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d " 44 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
45 "max_ac_packet %d rekey %d\n", 45 "max_ac_packet %d rekey %d\n",
46 args->v0.version, args->v0.state, 46 args->v0.version, args->v0.state,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c
index 110dc19e4f67..4e8067d511d7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c
@@ -25,7 +25,7 @@
25 25
26#include <core/client.h> 26#include <core/client.h>
27 27
28#include <nvif/class.h> 28#include <nvif/cl5070.h>
29#include <nvif/unpack.h> 29#include <nvif/unpack.h>
30 30
31int 31int
@@ -38,10 +38,10 @@ gk104_hdmi_ctrl(NV50_DISP_MTHD_V1)
38 struct nv50_disp_sor_hdmi_pwr_v0 v0; 38 struct nv50_disp_sor_hdmi_pwr_v0 v0;
39 } *args = data; 39 } *args = data;
40 u32 ctrl; 40 u32 ctrl;
41 int ret; 41 int ret = -ENOSYS;
42 42
43 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size); 43 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
44 if (nvif_unpack(args->v0, 0, 0, false)) { 44 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
45 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d " 45 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
46 "max_ac_packet %d rekey %d\n", 46 "max_ac_packet %d rekey %d\n",
47 args->v0.version, args->v0.state, 47 args->v0.version, args->v0.state,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c
index 61237dbfa35a..f1afc16494b6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c
@@ -26,7 +26,7 @@
26 26
27#include <core/client.h> 27#include <core/client.h>
28 28
29#include <nvif/class.h> 29#include <nvif/cl5070.h>
30#include <nvif/unpack.h> 30#include <nvif/unpack.h>
31 31
32int 32int
@@ -38,10 +38,10 @@ gt215_hdmi_ctrl(NV50_DISP_MTHD_V1)
38 struct nv50_disp_sor_hdmi_pwr_v0 v0; 38 struct nv50_disp_sor_hdmi_pwr_v0 v0;
39 } *args = data; 39 } *args = data;
40 u32 ctrl; 40 u32 ctrl;
41 int ret; 41 int ret = -ENOSYS;
42 42
43 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size); 43 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
44 if (nvif_unpack(args->v0, 0, 0, false)) { 44 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
45 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d " 45 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
46 "max_ac_packet %d rekey %d\n", 46 "max_ac_packet %d rekey %d\n",
47 args->v0.version, args->v0.state, 47 args->v0.version, args->v0.state,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
index 32e73a975b58..4226d2153b9c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
@@ -391,7 +391,7 @@ exec_clkcmp(struct nv50_disp *disp, int head, int id, u32 pclk, u32 *conf)
391 switch (outp->info.type) { 391 switch (outp->info.type) {
392 case DCB_OUTPUT_TMDS: 392 case DCB_OUTPUT_TMDS:
393 *conf = (ctrl & 0x00000f00) >> 8; 393 *conf = (ctrl & 0x00000f00) >> 8;
394 if (pclk >= 165000) 394 if (*conf == 5)
395 *conf |= 0x0100; 395 *conf |= 0x0100;
396 break; 396 break;
397 case DCB_OUTPUT_LVDS: 397 case DCB_OUTPUT_LVDS:
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/oimmnv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/oimmnv50.c
index cd888a1e443c..3940b9c966ec 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/oimmnv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/oimmnv50.c
@@ -27,6 +27,7 @@
27#include <core/client.h> 27#include <core/client.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/cl507b.h>
30#include <nvif/unpack.h> 31#include <nvif/unpack.h>
31 32
32int 33int
@@ -41,10 +42,10 @@ nv50_disp_oimm_new(const struct nv50_disp_chan_func *func,
41 } *args = data; 42 } *args = data;
42 struct nvkm_object *parent = oclass->parent; 43 struct nvkm_object *parent = oclass->parent;
43 struct nv50_disp *disp = root->disp; 44 struct nv50_disp *disp = root->disp;
44 int head, ret; 45 int head, ret = -ENOSYS;
45 46
46 nvif_ioctl(parent, "create disp overlay size %d\n", size); 47 nvif_ioctl(parent, "create disp overlay size %d\n", size);
47 if (nvif_unpack(args->v0, 0, 0, false)) { 48 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
48 nvif_ioctl(parent, "create disp overlay vers %d head %d\n", 49 nvif_ioctl(parent, "create disp overlay vers %d head %d\n",
49 args->v0.version, args->v0.head); 50 args->v0.version, args->v0.head);
50 if (args->v0.head > disp->base.head.nr) 51 if (args->v0.head > disp->base.head.nr)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ovlynv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ovlynv50.c
index 6fa296c047b8..2a49c46425cd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ovlynv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ovlynv50.c
@@ -27,6 +27,7 @@
27#include <core/client.h> 27#include <core/client.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/cl507e.h>
30#include <nvif/unpack.h> 31#include <nvif/unpack.h>
31 32
32int 33int
@@ -41,11 +42,11 @@ nv50_disp_ovly_new(const struct nv50_disp_dmac_func *func,
41 } *args = data; 42 } *args = data;
42 struct nvkm_object *parent = oclass->parent; 43 struct nvkm_object *parent = oclass->parent;
43 struct nv50_disp *disp = root->disp; 44 struct nv50_disp *disp = root->disp;
44 int head, ret; 45 int head, ret = -ENOSYS;
45 u64 push; 46 u64 push;
46 47
47 nvif_ioctl(parent, "create disp overlay channel dma size %d\n", size); 48 nvif_ioctl(parent, "create disp overlay channel dma size %d\n", size);
48 if (nvif_unpack(args->v0, 0, 0, false)) { 49 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
49 nvif_ioctl(parent, "create disp overlay channel dma vers %d " 50 nvif_ioctl(parent, "create disp overlay channel dma vers %d "
50 "pushbuf %016llx head %d\n", 51 "pushbuf %016llx head %d\n",
51 args->v0.version, args->v0.pushbuf, args->v0.head); 52 args->v0.version, args->v0.pushbuf, args->v0.head);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c
index ab524bde7795..6c532eadba17 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c
@@ -28,7 +28,7 @@
28#include <subdev/i2c.h> 28#include <subdev/i2c.h>
29#include <subdev/timer.h> 29#include <subdev/timer.h>
30 30
31#include <nvif/class.h> 31#include <nvif/cl5070.h>
32#include <nvif/unpack.h> 32#include <nvif/unpack.h>
33 33
34int 34int
@@ -40,10 +40,10 @@ nv50_pior_power(NV50_DISP_MTHD_V1)
40 struct nv50_disp_pior_pwr_v0 v0; 40 struct nv50_disp_pior_pwr_v0 v0;
41 } *args = data; 41 } *args = data;
42 u32 ctrl, type; 42 u32 ctrl, type;
43 int ret; 43 int ret = -ENOSYS;
44 44
45 nvif_ioctl(object, "disp pior pwr size %d\n", size); 45 nvif_ioctl(object, "disp pior pwr size %d\n", size);
46 if (nvif_unpack(args->v0, 0, 0, false)) { 46 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
47 nvif_ioctl(object, "disp pior pwr vers %d state %d type %x\n", 47 nvif_ioctl(object, "disp pior pwr vers %d state %d type %x\n",
48 args->v0.version, args->v0.state, args->v0.type); 48 args->v0.version, args->v0.state, args->v0.type);
49 if (args->v0.type > 0x0f) 49 if (args->v0.type > 0x0f)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c
index 8591726871ac..335d88823c22 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c
@@ -29,6 +29,7 @@
29#include <subdev/timer.h> 29#include <subdev/timer.h>
30 30
31#include <nvif/class.h> 31#include <nvif/class.h>
32#include <nvif/cl5070.h>
32#include <nvif/unpack.h> 33#include <nvif/unpack.h>
33 34
34int 35int
@@ -39,12 +40,12 @@ gf119_disp_root_scanoutpos(NV50_DISP_MTHD_V0)
39 const u32 blanke = nvkm_rd32(device, 0x64041c + (head * 0x300)); 40 const u32 blanke = nvkm_rd32(device, 0x64041c + (head * 0x300));
40 const u32 blanks = nvkm_rd32(device, 0x640420 + (head * 0x300)); 41 const u32 blanks = nvkm_rd32(device, 0x640420 + (head * 0x300));
41 union { 42 union {
42 struct nv04_disp_scanoutpos_v0 v0; 43 struct nv50_disp_scanoutpos_v0 v0;
43 } *args = data; 44 } *args = data;
44 int ret; 45 int ret = -ENOSYS;
45 46
46 nvif_ioctl(object, "disp scanoutpos size %d\n", size); 47 nvif_ioctl(object, "disp scanoutpos size %d\n", size);
47 if (nvif_unpack(args->v0, 0, 0, false)) { 48 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
48 nvif_ioctl(object, "disp scanoutpos vers %d\n", 49 nvif_ioctl(object, "disp scanoutpos vers %d\n",
49 args->v0.version); 50 args->v0.version);
50 args->v0.vblanke = (blanke & 0xffff0000) >> 16; 51 args->v0.vblanke = (blanke & 0xffff0000) >> 16;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv04.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv04.c
index 2be846374d39..f535f43231e2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv04.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv04.c
@@ -27,6 +27,7 @@
27#include <core/client.h> 27#include <core/client.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/cl0046.h>
30#include <nvif/unpack.h> 31#include <nvif/unpack.h>
31 32
32struct nv04_disp_root { 33struct nv04_disp_root {
@@ -45,10 +46,10 @@ nv04_disp_scanoutpos(struct nv04_disp_root *root,
45 struct nv04_disp_scanoutpos_v0 v0; 46 struct nv04_disp_scanoutpos_v0 v0;
46 } *args = data; 47 } *args = data;
47 u32 line; 48 u32 line;
48 int ret; 49 int ret = -ENOSYS;
49 50
50 nvif_ioctl(object, "disp scanoutpos size %d\n", size); 51 nvif_ioctl(object, "disp scanoutpos size %d\n", size);
51 if (nvif_unpack(args->v0, 0, 0, false)) { 52 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
52 nvif_ioctl(object, "disp scanoutpos vers %d\n", 53 nvif_ioctl(object, "disp scanoutpos vers %d\n",
53 args->v0.version); 54 args->v0.version);
54 args->v0.vblanks = nvkm_rd32(device, 0x680800 + hoff) & 0xffff; 55 args->v0.vblanks = nvkm_rd32(device, 0x680800 + hoff) & 0xffff;
@@ -85,10 +86,10 @@ nv04_disp_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
85 union { 86 union {
86 struct nv04_disp_mthd_v0 v0; 87 struct nv04_disp_mthd_v0 v0;
87 } *args = data; 88 } *args = data;
88 int head, ret; 89 int head, ret = -ENOSYS;
89 90
90 nvif_ioctl(object, "disp mthd size %d\n", size); 91 nvif_ioctl(object, "disp mthd size %d\n", size);
91 if (nvif_unpack(args->v0, 0, 0, true)) { 92 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
92 nvif_ioctl(object, "disp mthd vers %d mthd %02x head %d\n", 93 nvif_ioctl(object, "disp mthd vers %d mthd %02x head %d\n",
93 args->v0.version, args->v0.method, args->v0.head); 94 args->v0.version, args->v0.method, args->v0.head);
94 mthd = args->v0.method; 95 mthd = args->v0.method;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c
index 06fb24d88702..2f9cecd81d04 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c
@@ -29,6 +29,7 @@
29#include <subdev/timer.h> 29#include <subdev/timer.h>
30 30
31#include <nvif/class.h> 31#include <nvif/class.h>
32#include <nvif/cl5070.h>
32#include <nvif/unpack.h> 33#include <nvif/unpack.h>
33 34
34int 35int
@@ -39,12 +40,12 @@ nv50_disp_root_scanoutpos(NV50_DISP_MTHD_V0)
39 const u32 blanks = nvkm_rd32(device, 0x610af4 + (head * 0x540)); 40 const u32 blanks = nvkm_rd32(device, 0x610af4 + (head * 0x540));
40 const u32 total = nvkm_rd32(device, 0x610afc + (head * 0x540)); 41 const u32 total = nvkm_rd32(device, 0x610afc + (head * 0x540));
41 union { 42 union {
42 struct nv04_disp_scanoutpos_v0 v0; 43 struct nv50_disp_scanoutpos_v0 v0;
43 } *args = data; 44 } *args = data;
44 int ret; 45 int ret = -ENOSYS;
45 46
46 nvif_ioctl(object, "disp scanoutpos size %d\n", size); 47 nvif_ioctl(object, "disp scanoutpos size %d\n", size);
47 if (nvif_unpack(args->v0, 0, 0, false)) { 48 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
48 nvif_ioctl(object, "disp scanoutpos vers %d\n", 49 nvif_ioctl(object, "disp scanoutpos vers %d\n",
49 args->v0.version); 50 args->v0.version);
50 args->v0.vblanke = (blanke & 0xffff0000) >> 16; 51 args->v0.vblanke = (blanke & 0xffff0000) >> 16;
@@ -78,19 +79,19 @@ nv50_disp_root_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
78 struct nvkm_output *outp = NULL; 79 struct nvkm_output *outp = NULL;
79 struct nvkm_output *temp; 80 struct nvkm_output *temp;
80 u16 type, mask = 0; 81 u16 type, mask = 0;
81 int head, ret; 82 int head, ret = -ENOSYS;
82 83
83 if (mthd != NV50_DISP_MTHD) 84 if (mthd != NV50_DISP_MTHD)
84 return -EINVAL; 85 return -EINVAL;
85 86
86 nvif_ioctl(object, "disp mthd size %d\n", size); 87 nvif_ioctl(object, "disp mthd size %d\n", size);
87 if (nvif_unpack(args->v0, 0, 0, true)) { 88 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
88 nvif_ioctl(object, "disp mthd vers %d mthd %02x head %d\n", 89 nvif_ioctl(object, "disp mthd vers %d mthd %02x head %d\n",
89 args->v0.version, args->v0.method, args->v0.head); 90 args->v0.version, args->v0.method, args->v0.head);
90 mthd = args->v0.method; 91 mthd = args->v0.method;
91 head = args->v0.head; 92 head = args->v0.head;
92 } else 93 } else
93 if (nvif_unpack(args->v1, 1, 1, true)) { 94 if (!(ret = nvif_unpack(ret, &data, &size, args->v1, 1, 1, true))) {
94 nvif_ioctl(object, "disp mthd vers %d mthd %02x " 95 nvif_ioctl(object, "disp mthd vers %d mthd %02x "
95 "type %04x mask %04x\n", 96 "type %04x mask %04x\n",
96 args->v1.version, args->v1.method, 97 args->v1.version, args->v1.method,
@@ -143,8 +144,9 @@ nv50_disp_root_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
143 union { 144 union {
144 struct nv50_disp_sor_lvds_script_v0 v0; 145 struct nv50_disp_sor_lvds_script_v0 v0;
145 } *args = data; 146 } *args = data;
147 int ret = -ENOSYS;
146 nvif_ioctl(object, "disp sor lvds script size %d\n", size); 148 nvif_ioctl(object, "disp sor lvds script size %d\n", size);
147 if (nvif_unpack(args->v0, 0, 0, false)) { 149 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
148 nvif_ioctl(object, "disp sor lvds script " 150 nvif_ioctl(object, "disp sor lvds script "
149 "vers %d name %04x\n", 151 "vers %d name %04x\n",
150 args->v0.version, args->v0.script); 152 args->v0.version, args->v0.script);
@@ -159,8 +161,9 @@ nv50_disp_root_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
159 union { 161 union {
160 struct nv50_disp_sor_dp_pwr_v0 v0; 162 struct nv50_disp_sor_dp_pwr_v0 v0;
161 } *args = data; 163 } *args = data;
164 int ret = -ENOSYS;
162 nvif_ioctl(object, "disp sor dp pwr size %d\n", size); 165 nvif_ioctl(object, "disp sor dp pwr size %d\n", size);
163 if (nvif_unpack(args->v0, 0, 0, false)) { 166 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
164 nvif_ioctl(object, "disp sor dp pwr vers %d state %d\n", 167 nvif_ioctl(object, "disp sor dp pwr vers %d state %d\n",
165 args->v0.version, args->v0.state); 168 args->v0.version, args->v0.state);
166 if (args->v0.state == 0) { 169 if (args->v0.state == 0) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c
index 29e0d2a9a839..53596bed3c36 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c
@@ -27,7 +27,7 @@
27#include <core/client.h> 27#include <core/client.h>
28#include <subdev/timer.h> 28#include <subdev/timer.h>
29 29
30#include <nvif/class.h> 30#include <nvif/cl5070.h>
31#include <nvif/unpack.h> 31#include <nvif/unpack.h>
32 32
33int 33int
@@ -39,10 +39,10 @@ nv50_sor_power(NV50_DISP_MTHD_V1)
39 } *args = data; 39 } *args = data;
40 const u32 soff = outp->or * 0x800; 40 const u32 soff = outp->or * 0x800;
41 u32 stat; 41 u32 stat;
42 int ret; 42 int ret = -ENOSYS;
43 43
44 nvif_ioctl(object, "disp sor pwr size %d\n", size); 44 nvif_ioctl(object, "disp sor pwr size %d\n", size);
45 if (nvif_unpack(args->v0, 0, 0, false)) { 45 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
46 nvif_ioctl(object, "disp sor pwr vers %d state %d\n", 46 nvif_ioctl(object, "disp sor pwr vers %d state %d\n",
47 args->v0.version, args->v0.state); 47 args->v0.version, args->v0.state);
48 stat = !!args->v0.state; 48 stat = !!args->v0.state;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
index 45ab062661a4..13c661b1ef14 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
@@ -28,7 +28,7 @@
28#include <subdev/fb.h> 28#include <subdev/fb.h>
29#include <subdev/instmem.h> 29#include <subdev/instmem.h>
30 30
31#include <nvif/class.h> 31#include <nvif/cl0002.h>
32#include <nvif/unpack.h> 32#include <nvif/unpack.h>
33 33
34static int 34static int
@@ -69,7 +69,7 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma,
69 struct nvkm_fb *fb = device->fb; 69 struct nvkm_fb *fb = device->fb;
70 void *data = *pdata; 70 void *data = *pdata;
71 u32 size = *psize; 71 u32 size = *psize;
72 int ret; 72 int ret = -ENOSYS;
73 73
74 nvkm_object_ctor(&nvkm_dmaobj_func, oclass, &dmaobj->object); 74 nvkm_object_ctor(&nvkm_dmaobj_func, oclass, &dmaobj->object);
75 dmaobj->func = func; 75 dmaobj->func = func;
@@ -77,7 +77,7 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma,
77 RB_CLEAR_NODE(&dmaobj->rb); 77 RB_CLEAR_NODE(&dmaobj->rb);
78 78
79 nvif_ioctl(parent, "create dma size %d\n", *psize); 79 nvif_ioctl(parent, "create dma size %d\n", *psize);
80 if (nvif_unpack(args->v0, 0, 0, true)) { 80 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
81 nvif_ioctl(parent, "create dma vers %d target %d access %d " 81 nvif_ioctl(parent, "create dma vers %d target %d access %d "
82 "start %016llx limit %016llx\n", 82 "start %016llx limit %016llx\n",
83 args->v0.version, args->v0.target, args->v0.access, 83 args->v0.version, args->v0.target, args->v0.access,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c
index 13e341cc4e32..ef7ac360101e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c
@@ -28,7 +28,7 @@
28#include <core/gpuobj.h> 28#include <core/gpuobj.h>
29#include <subdev/fb.h> 29#include <subdev/fb.h>
30 30
31#include <nvif/class.h> 31#include <nvif/cl0002.h>
32#include <nvif/unpack.h> 32#include <nvif/unpack.h>
33 33
34struct gf100_dmaobj { 34struct gf100_dmaobj {
@@ -87,10 +87,11 @@ gf100_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
87 if (ret) 87 if (ret)
88 return ret; 88 return ret;
89 89
90 ret = -ENOSYS;
90 args = data; 91 args = data;
91 92
92 nvif_ioctl(parent, "create gf100 dma size %d\n", size); 93 nvif_ioctl(parent, "create gf100 dma size %d\n", size);
93 if (nvif_unpack(args->v0, 0, 0, false)) { 94 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
94 nvif_ioctl(parent, 95 nvif_ioctl(parent,
95 "create gf100 dma vers %d priv %d kind %02x\n", 96 "create gf100 dma vers %d priv %d kind %02x\n",
96 args->v0.version, args->v0.priv, args->v0.kind); 97 args->v0.version, args->v0.priv, args->v0.kind);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c
index 0e1af8b4db84..c068cee34588 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c
@@ -28,7 +28,7 @@
28#include <core/gpuobj.h> 28#include <core/gpuobj.h>
29#include <subdev/fb.h> 29#include <subdev/fb.h>
30 30
31#include <nvif/class.h> 31#include <nvif/cl0002.h>
32#include <nvif/unpack.h> 32#include <nvif/unpack.h>
33 33
34struct gf119_dmaobj { 34struct gf119_dmaobj {
@@ -85,10 +85,11 @@ gf119_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
85 if (ret) 85 if (ret)
86 return ret; 86 return ret;
87 87
88 ret = -ENOSYS;
88 args = data; 89 args = data;
89 90
90 nvif_ioctl(parent, "create gf119 dma size %d\n", size); 91 nvif_ioctl(parent, "create gf119 dma size %d\n", size);
91 if (nvif_unpack(args->v0, 0, 0, false)) { 92 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
92 nvif_ioctl(parent, 93 nvif_ioctl(parent,
93 "create gf100 dma vers %d page %d kind %02x\n", 94 "create gf100 dma vers %d page %d kind %02x\n",
94 args->v0.version, args->v0.page, args->v0.kind); 95 args->v0.version, args->v0.page, args->v0.kind);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c
index 5b7ce313ea14..6a85b5dea643 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c
@@ -28,7 +28,7 @@
28#include <core/gpuobj.h> 28#include <core/gpuobj.h>
29#include <subdev/fb.h> 29#include <subdev/fb.h>
30 30
31#include <nvif/class.h> 31#include <nvif/cl0002.h>
32#include <nvif/unpack.h> 32#include <nvif/unpack.h>
33 33
34struct nv50_dmaobj { 34struct nv50_dmaobj {
@@ -87,10 +87,11 @@ nv50_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
87 if (ret) 87 if (ret)
88 return ret; 88 return ret;
89 89
90 ret = -ENOSYS;
90 args = data; 91 args = data;
91 92
92 nvif_ioctl(parent, "create nv50 dma size %d\n", size); 93 nvif_ioctl(parent, "create nv50 dma size %d\n", size);
93 if (nvif_unpack(args->v0, 0, 0, false)) { 94 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
94 nvif_ioctl(parent, "create nv50 dma vers %d priv %d part %d " 95 nvif_ioctl(parent, "create nv50 dma vers %d priv %d part %d "
95 "comp %d kind %02x\n", args->v0.version, 96 "comp %d kind %02x\n", args->v0.version,
96 args->v0.priv, args->v0.part, args->v0.comp, 97 args->v0.priv, args->v0.part, args->v0.comp,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
index 1fbbfbe6ca9c..cfc7d5725a61 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
@@ -129,9 +129,9 @@ nvkm_fifo_uevent_ctor(struct nvkm_object *object, void *data, u32 size,
129 union { 129 union {
130 struct nvif_notify_uevent_req none; 130 struct nvif_notify_uevent_req none;
131 } *req = data; 131 } *req = data;
132 int ret; 132 int ret = -ENOSYS;
133 133
134 if (nvif_unvers(req->none)) { 134 if (!(ret = nvif_unvers(ret, &data, &size, req->none))) {
135 notify->size = sizeof(struct nvif_notify_uevent_rep); 135 notify->size = sizeof(struct nvif_notify_uevent_rep);
136 notify->types = 1; 136 notify->types = 1;
137 notify->index = 0; 137 notify->index = 0;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chang84.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chang84.c
index 04305241ceed..aeb3387a3fb0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chang84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chang84.c
@@ -28,7 +28,7 @@
28#include <subdev/mmu.h> 28#include <subdev/mmu.h>
29#include <subdev/timer.h> 29#include <subdev/timer.h>
30 30
31#include <nvif/class.h> 31#include <nvif/cl826e.h>
32 32
33int 33int
34g84_fifo_chan_ntfy(struct nvkm_fifo_chan *chan, u32 type, 34g84_fifo_chan_ntfy(struct nvkm_fifo_chan *chan, u32 type,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c
index a5ca52c7b74f..caa914074752 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c
@@ -27,6 +27,7 @@
27#include <core/ramht.h> 27#include <core/ramht.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/cl826e.h>
30#include <nvif/unpack.h> 31#include <nvif/unpack.h>
31 32
32static int 33static int
@@ -35,14 +36,14 @@ g84_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
35{ 36{
36 struct nvkm_object *parent = oclass->parent; 37 struct nvkm_object *parent = oclass->parent;
37 union { 38 union {
38 struct nv50_channel_dma_v0 v0; 39 struct g82_channel_dma_v0 v0;
39 } *args = data; 40 } *args = data;
40 struct nv50_fifo *fifo = nv50_fifo(base); 41 struct nv50_fifo *fifo = nv50_fifo(base);
41 struct nv50_fifo_chan *chan; 42 struct nv50_fifo_chan *chan;
42 int ret; 43 int ret = -ENOSYS;
43 44
44 nvif_ioctl(parent, "create channel dma size %d\n", size); 45 nvif_ioctl(parent, "create channel dma size %d\n", size);
45 if (nvif_unpack(args->v0, 0, 0, false)) { 46 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
46 nvif_ioctl(parent, "create channel dma vers %d vm %llx " 47 nvif_ioctl(parent, "create channel dma vers %d vm %llx "
47 "pushbuf %llx offset %016llx\n", 48 "pushbuf %llx offset %016llx\n",
48 args->v0.version, args->v0.vm, args->v0.pushbuf, 49 args->v0.version, args->v0.vm, args->v0.pushbuf,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c
index bfcc6408a772..edec30fd3ecd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c
@@ -29,6 +29,7 @@
29#include <subdev/instmem.h> 29#include <subdev/instmem.h>
30 30
31#include <nvif/class.h> 31#include <nvif/class.h>
32#include <nvif/cl006b.h>
32#include <nvif/unpack.h> 33#include <nvif/unpack.h>
33 34
34void 35void
@@ -167,10 +168,10 @@ nv04_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
167 struct nv04_fifo_chan *chan = NULL; 168 struct nv04_fifo_chan *chan = NULL;
168 struct nvkm_device *device = fifo->base.engine.subdev.device; 169 struct nvkm_device *device = fifo->base.engine.subdev.device;
169 struct nvkm_instmem *imem = device->imem; 170 struct nvkm_instmem *imem = device->imem;
170 int ret; 171 int ret = -ENOSYS;
171 172
172 nvif_ioctl(parent, "create channel dma size %d\n", size); 173 nvif_ioctl(parent, "create channel dma size %d\n", size);
173 if (nvif_unpack(args->v0, 0, 0, false)) { 174 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
174 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx " 175 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx "
175 "offset %08x\n", args->v0.version, 176 "offset %08x\n", args->v0.version,
176 args->v0.pushbuf, args->v0.offset); 177 args->v0.pushbuf, args->v0.offset);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv10.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv10.c
index 34f68e5bd040..f5f355ff005d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv10.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv10.c
@@ -29,6 +29,7 @@
29#include <subdev/instmem.h> 29#include <subdev/instmem.h>
30 30
31#include <nvif/class.h> 31#include <nvif/class.h>
32#include <nvif/cl006b.h>
32#include <nvif/unpack.h> 33#include <nvif/unpack.h>
33 34
34static int 35static int
@@ -43,10 +44,10 @@ nv10_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
43 struct nv04_fifo_chan *chan = NULL; 44 struct nv04_fifo_chan *chan = NULL;
44 struct nvkm_device *device = fifo->base.engine.subdev.device; 45 struct nvkm_device *device = fifo->base.engine.subdev.device;
45 struct nvkm_instmem *imem = device->imem; 46 struct nvkm_instmem *imem = device->imem;
46 int ret; 47 int ret = -ENOSYS;
47 48
48 nvif_ioctl(parent, "create channel dma size %d\n", size); 49 nvif_ioctl(parent, "create channel dma size %d\n", size);
49 if (nvif_unpack(args->v0, 0, 0, false)) { 50 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
50 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx " 51 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx "
51 "offset %08x\n", args->v0.version, 52 "offset %08x\n", args->v0.version,
52 args->v0.pushbuf, args->v0.offset); 53 args->v0.pushbuf, args->v0.offset);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv17.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv17.c
index ed7cc9f2b540..7edc6a564b5d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv17.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv17.c
@@ -29,6 +29,7 @@
29#include <subdev/instmem.h> 29#include <subdev/instmem.h>
30 30
31#include <nvif/class.h> 31#include <nvif/class.h>
32#include <nvif/cl006b.h>
32#include <nvif/unpack.h> 33#include <nvif/unpack.h>
33 34
34static int 35static int
@@ -43,10 +44,10 @@ nv17_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
43 struct nv04_fifo_chan *chan = NULL; 44 struct nv04_fifo_chan *chan = NULL;
44 struct nvkm_device *device = fifo->base.engine.subdev.device; 45 struct nvkm_device *device = fifo->base.engine.subdev.device;
45 struct nvkm_instmem *imem = device->imem; 46 struct nvkm_instmem *imem = device->imem;
46 int ret; 47 int ret = -ENOSYS;
47 48
48 nvif_ioctl(parent, "create channel dma size %d\n", size); 49 nvif_ioctl(parent, "create channel dma size %d\n", size);
49 if (nvif_unpack(args->v0, 0, 0, false)) { 50 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
50 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx " 51 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx "
51 "offset %08x\n", args->v0.version, 52 "offset %08x\n", args->v0.version,
52 args->v0.pushbuf, args->v0.offset); 53 args->v0.pushbuf, args->v0.offset);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv40.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv40.c
index 043b6c325949..0ec179fc40a1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv40.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv40.c
@@ -29,6 +29,7 @@
29#include <subdev/instmem.h> 29#include <subdev/instmem.h>
30 30
31#include <nvif/class.h> 31#include <nvif/class.h>
32#include <nvif/cl006b.h>
32#include <nvif/unpack.h> 33#include <nvif/unpack.h>
33 34
34static bool 35static bool
@@ -188,10 +189,10 @@ nv40_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
188 struct nv04_fifo_chan *chan = NULL; 189 struct nv04_fifo_chan *chan = NULL;
189 struct nvkm_device *device = fifo->base.engine.subdev.device; 190 struct nvkm_device *device = fifo->base.engine.subdev.device;
190 struct nvkm_instmem *imem = device->imem; 191 struct nvkm_instmem *imem = device->imem;
191 int ret; 192 int ret = -ENOSYS;
192 193
193 nvif_ioctl(parent, "create channel dma size %d\n", size); 194 nvif_ioctl(parent, "create channel dma size %d\n", size);
194 if (nvif_unpack(args->v0, 0, 0, false)) { 195 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
195 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx " 196 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx "
196 "offset %08x\n", args->v0.version, 197 "offset %08x\n", args->v0.version,
197 args->v0.pushbuf, args->v0.offset); 198 args->v0.pushbuf, args->v0.offset);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c
index 6b3b15f12c39..480bc3777be5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c
@@ -27,6 +27,7 @@
27#include <core/ramht.h> 27#include <core/ramht.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/cl506e.h>
30#include <nvif/unpack.h> 31#include <nvif/unpack.h>
31 32
32static int 33static int
@@ -39,10 +40,10 @@ nv50_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
39 } *args = data; 40 } *args = data;
40 struct nv50_fifo *fifo = nv50_fifo(base); 41 struct nv50_fifo *fifo = nv50_fifo(base);
41 struct nv50_fifo_chan *chan; 42 struct nv50_fifo_chan *chan;
42 int ret; 43 int ret = -ENOSYS;
43 44
44 nvif_ioctl(parent, "create channel dma size %d\n", size); 45 nvif_ioctl(parent, "create channel dma size %d\n", size);
45 if (nvif_unpack(args->v0, 0, 0, false)) { 46 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
46 nvif_ioctl(parent, "create channel dma vers %d vm %llx " 47 nvif_ioctl(parent, "create channel dma vers %d vm %llx "
47 "pushbuf %llx offset %016llx\n", 48 "pushbuf %llx offset %016llx\n",
48 args->v0.version, args->v0.vm, args->v0.pushbuf, 49 args->v0.version, args->v0.vm, args->v0.pushbuf,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
index ff6fcbda615b..36a39c7fd8d2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
@@ -47,7 +47,7 @@ gf100_fifo_uevent_fini(struct nvkm_fifo *fifo)
47} 47}
48 48
49void 49void
50gf100_fifo_runlist_update(struct gf100_fifo *fifo) 50gf100_fifo_runlist_commit(struct gf100_fifo *fifo)
51{ 51{
52 struct gf100_fifo_chan *chan; 52 struct gf100_fifo_chan *chan;
53 struct nvkm_subdev *subdev = &fifo->base.engine.subdev; 53 struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
@@ -77,6 +77,22 @@ gf100_fifo_runlist_update(struct gf100_fifo *fifo)
77 mutex_unlock(&subdev->mutex); 77 mutex_unlock(&subdev->mutex);
78} 78}
79 79
80void
81gf100_fifo_runlist_remove(struct gf100_fifo *fifo, struct gf100_fifo_chan *chan)
82{
83 mutex_lock(&fifo->base.engine.subdev.mutex);
84 list_del_init(&chan->head);
85 mutex_unlock(&fifo->base.engine.subdev.mutex);
86}
87
88void
89gf100_fifo_runlist_insert(struct gf100_fifo *fifo, struct gf100_fifo_chan *chan)
90{
91 mutex_lock(&fifo->base.engine.subdev.mutex);
92 list_add_tail(&chan->head, &fifo->chan);
93 mutex_unlock(&fifo->base.engine.subdev.mutex);
94}
95
80static inline int 96static inline int
81gf100_fifo_engidx(struct gf100_fifo *fifo, u32 engn) 97gf100_fifo_engidx(struct gf100_fifo *fifo, u32 engn)
82{ 98{
@@ -139,7 +155,7 @@ gf100_fifo_recover_work(struct work_struct *work)
139 } 155 }
140 } 156 }
141 157
142 gf100_fifo_runlist_update(fifo); 158 gf100_fifo_runlist_commit(fifo);
143 nvkm_wr32(device, 0x00262c, engm); 159 nvkm_wr32(device, 0x00262c, engm);
144 nvkm_mask(device, 0x002630, engm, 0x00000000); 160 nvkm_mask(device, 0x002630, engm, 0x00000000);
145} 161}
@@ -239,7 +255,7 @@ gf100_fifo_fault_engine[] = {
239 { 0x14, "PMSPDEC", NULL, NVKM_ENGINE_MSPDEC }, 255 { 0x14, "PMSPDEC", NULL, NVKM_ENGINE_MSPDEC },
240 { 0x15, "PCE0", NULL, NVKM_ENGINE_CE0 }, 256 { 0x15, "PCE0", NULL, NVKM_ENGINE_CE0 },
241 { 0x16, "PCE1", NULL, NVKM_ENGINE_CE1 }, 257 { 0x16, "PCE1", NULL, NVKM_ENGINE_CE1 },
242 { 0x17, "PDAEMON" }, 258 { 0x17, "PMU" },
243 {} 259 {}
244}; 260};
245 261
@@ -270,7 +286,7 @@ gf100_fifo_fault_hubclient[] = {
270 { 0x0c, "PMSPPP" }, 286 { 0x0c, "PMSPPP" },
271 { 0x0d, "PMSVLD" }, 287 { 0x0d, "PMSVLD" },
272 { 0x11, "PCOUNTER" }, 288 { 0x11, "PCOUNTER" },
273 { 0x12, "PDAEMON" }, 289 { 0x12, "PMU" },
274 { 0x14, "CCACHE" }, 290 { 0x14, "CCACHE" },
275 { 0x15, "CCACHE_POST" }, 291 { 0x15, "CCACHE_POST" },
276 {} 292 {}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.h
index c649ca9b53e3..08c33c3ceaf7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.h
@@ -5,6 +5,7 @@
5 5
6#include <subdev/mmu.h> 6#include <subdev/mmu.h>
7 7
8struct gf100_fifo_chan;
8struct gf100_fifo { 9struct gf100_fifo {
9 struct nvkm_fifo base; 10 struct nvkm_fifo base;
10 11
@@ -27,5 +28,7 @@ struct gf100_fifo {
27}; 28};
28 29
29void gf100_fifo_intr_engine(struct gf100_fifo *); 30void gf100_fifo_intr_engine(struct gf100_fifo *);
30void gf100_fifo_runlist_update(struct gf100_fifo *); 31void gf100_fifo_runlist_insert(struct gf100_fifo *, struct gf100_fifo_chan *);
32void gf100_fifo_runlist_remove(struct gf100_fifo *, struct gf100_fifo_chan *);
33void gf100_fifo_runlist_commit(struct gf100_fifo *);
31#endif 34#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
index 98970a0b7a66..4fcd147d43c8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
@@ -47,7 +47,7 @@ gk104_fifo_uevent_init(struct nvkm_fifo *fifo)
47} 47}
48 48
49void 49void
50gk104_fifo_runlist_update(struct gk104_fifo *fifo, u32 engine) 50gk104_fifo_runlist_commit(struct gk104_fifo *fifo, u32 engine)
51{ 51{
52 struct gk104_fifo_engn *engn = &fifo->engine[engine]; 52 struct gk104_fifo_engn *engn = &fifo->engine[engine];
53 struct gk104_fifo_chan *chan; 53 struct gk104_fifo_chan *chan;
@@ -78,6 +78,22 @@ gk104_fifo_runlist_update(struct gk104_fifo *fifo, u32 engine)
78 mutex_unlock(&subdev->mutex); 78 mutex_unlock(&subdev->mutex);
79} 79}
80 80
81void
82gk104_fifo_runlist_remove(struct gk104_fifo *fifo, struct gk104_fifo_chan *chan)
83{
84 mutex_lock(&fifo->base.engine.subdev.mutex);
85 list_del_init(&chan->head);
86 mutex_unlock(&fifo->base.engine.subdev.mutex);
87}
88
89void
90gk104_fifo_runlist_insert(struct gk104_fifo *fifo, struct gk104_fifo_chan *chan)
91{
92 mutex_lock(&fifo->base.engine.subdev.mutex);
93 list_add_tail(&chan->head, &fifo->engine[chan->engine].chan);
94 mutex_unlock(&fifo->base.engine.subdev.mutex);
95}
96
81static inline struct nvkm_engine * 97static inline struct nvkm_engine *
82gk104_fifo_engine(struct gk104_fifo *fifo, u32 engn) 98gk104_fifo_engine(struct gk104_fifo *fifo, u32 engn)
83{ 99{
@@ -112,7 +128,7 @@ gk104_fifo_recover_work(struct work_struct *work)
112 nvkm_subdev_fini(&engine->subdev, false); 128 nvkm_subdev_fini(&engine->subdev, false);
113 WARN_ON(nvkm_subdev_init(&engine->subdev)); 129 WARN_ON(nvkm_subdev_init(&engine->subdev));
114 } 130 }
115 gk104_fifo_runlist_update(fifo, gk104_fifo_subdev_engine(engn)); 131 gk104_fifo_runlist_commit(fifo, gk104_fifo_subdev_engine(engn));
116 } 132 }
117 133
118 nvkm_wr32(device, 0x00262c, engm); 134 nvkm_wr32(device, 0x00262c, engm);
@@ -180,7 +196,7 @@ gk104_fifo_intr_sched_ctxsw(struct gk104_fifo *fifo)
180 196
181 spin_lock_irqsave(&fifo->base.lock, flags); 197 spin_lock_irqsave(&fifo->base.lock, flags);
182 for (engn = 0; engn < ARRAY_SIZE(fifo->engine); engn++) { 198 for (engn = 0; engn < ARRAY_SIZE(fifo->engine); engn++) {
183 u32 stat = nvkm_rd32(device, 0x002640 + (engn * 0x04)); 199 u32 stat = nvkm_rd32(device, 0x002640 + (engn * 0x08));
184 u32 busy = (stat & 0x80000000); 200 u32 busy = (stat & 0x80000000);
185 u32 next = (stat & 0x07ff0000) >> 16; 201 u32 next = (stat & 0x07ff0000) >> 16;
186 u32 chsw = (stat & 0x00008000); 202 u32 chsw = (stat & 0x00008000);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h
index 5afd9b5ec5d1..bec519d8f91e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h
@@ -5,6 +5,7 @@
5 5
6#include <subdev/mmu.h> 6#include <subdev/mmu.h>
7 7
8struct gk104_fifo_chan;
8struct gk104_fifo_engn { 9struct gk104_fifo_engn {
9 struct nvkm_memory *runlist[2]; 10 struct nvkm_memory *runlist[2];
10 int cur_runlist; 11 int cur_runlist;
@@ -35,7 +36,9 @@ void gk104_fifo_fini(struct nvkm_fifo *);
35void gk104_fifo_intr(struct nvkm_fifo *); 36void gk104_fifo_intr(struct nvkm_fifo *);
36void gk104_fifo_uevent_init(struct nvkm_fifo *); 37void gk104_fifo_uevent_init(struct nvkm_fifo *);
37void gk104_fifo_uevent_fini(struct nvkm_fifo *); 38void gk104_fifo_uevent_fini(struct nvkm_fifo *);
38void gk104_fifo_runlist_update(struct gk104_fifo *, u32 engine); 39void gk104_fifo_runlist_insert(struct gk104_fifo *, struct gk104_fifo_chan *);
40void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *);
41void gk104_fifo_runlist_commit(struct gk104_fifo *, u32 engine);
39 42
40static inline u64 43static inline u64
41gk104_fifo_engine_subdev(int engine) 44gk104_fifo_engine_subdev(int engine)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c
index 820132363f68..77c2f2a28bf3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c
@@ -27,6 +27,7 @@
27#include <core/ramht.h> 27#include <core/ramht.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/cl826f.h>
30#include <nvif/unpack.h> 31#include <nvif/unpack.h>
31 32
32static int 33static int
@@ -35,15 +36,15 @@ g84_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
35{ 36{
36 struct nvkm_object *parent = oclass->parent; 37 struct nvkm_object *parent = oclass->parent;
37 union { 38 union {
38 struct nv50_channel_gpfifo_v0 v0; 39 struct g82_channel_gpfifo_v0 v0;
39 } *args = data; 40 } *args = data;
40 struct nv50_fifo *fifo = nv50_fifo(base); 41 struct nv50_fifo *fifo = nv50_fifo(base);
41 struct nv50_fifo_chan *chan; 42 struct nv50_fifo_chan *chan;
42 u64 ioffset, ilength; 43 u64 ioffset, ilength;
43 int ret; 44 int ret = -ENOSYS;
44 45
45 nvif_ioctl(parent, "create channel gpfifo size %d\n", size); 46 nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
46 if (nvif_unpack(args->v0, 0, 0, false)) { 47 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
47 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx " 48 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
48 "pushbuf %llx ioffset %016llx " 49 "pushbuf %llx ioffset %016llx "
49 "ilength %08x\n", 50 "ilength %08x\n",
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c
index e7cbc139c1d4..cbc67f262322 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c
@@ -29,6 +29,7 @@
29#include <subdev/timer.h> 29#include <subdev/timer.h>
30 30
31#include <nvif/class.h> 31#include <nvif/class.h>
32#include <nvif/cl906f.h>
32#include <nvif/unpack.h> 33#include <nvif/unpack.h>
33 34
34static u32 35static u32
@@ -138,9 +139,9 @@ gf100_fifo_gpfifo_fini(struct nvkm_fifo_chan *base)
138 u32 coff = chan->base.chid * 8; 139 u32 coff = chan->base.chid * 8;
139 140
140 if (!list_empty(&chan->head) && !chan->killed) { 141 if (!list_empty(&chan->head) && !chan->killed) {
141 list_del_init(&chan->head); 142 gf100_fifo_runlist_remove(fifo, chan);
142 nvkm_mask(device, 0x003004 + coff, 0x00000001, 0x00000000); 143 nvkm_mask(device, 0x003004 + coff, 0x00000001, 0x00000000);
143 gf100_fifo_runlist_update(fifo); 144 gf100_fifo_runlist_commit(fifo);
144 } 145 }
145 146
146 gf100_fifo_intr_engine(fifo); 147 gf100_fifo_intr_engine(fifo);
@@ -160,9 +161,9 @@ gf100_fifo_gpfifo_init(struct nvkm_fifo_chan *base)
160 nvkm_wr32(device, 0x003000 + coff, 0xc0000000 | addr); 161 nvkm_wr32(device, 0x003000 + coff, 0xc0000000 | addr);
161 162
162 if (list_empty(&chan->head) && !chan->killed) { 163 if (list_empty(&chan->head) && !chan->killed) {
163 list_add_tail(&chan->head, &fifo->chan); 164 gf100_fifo_runlist_insert(fifo, chan);
164 nvkm_wr32(device, 0x003004 + coff, 0x001f0001); 165 nvkm_wr32(device, 0x003004 + coff, 0x001f0001);
165 gf100_fifo_runlist_update(fifo); 166 gf100_fifo_runlist_commit(fifo);
166 } 167 }
167} 168}
168 169
@@ -199,10 +200,10 @@ gf100_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
199 struct nvkm_object *parent = oclass->parent; 200 struct nvkm_object *parent = oclass->parent;
200 struct gf100_fifo_chan *chan; 201 struct gf100_fifo_chan *chan;
201 u64 usermem, ioffset, ilength; 202 u64 usermem, ioffset, ilength;
202 int ret, i; 203 int ret = -ENOSYS, i;
203 204
204 nvif_ioctl(parent, "create channel gpfifo size %d\n", size); 205 nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
205 if (nvif_unpack(args->v0, 0, 0, false)) { 206 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
206 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx " 207 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
207 "ioffset %016llx ilength %08x\n", 208 "ioffset %016llx ilength %08x\n",
208 args->v0.version, args->v0.vm, args->v0.ioffset, 209 args->v0.version, args->v0.vm, args->v0.ioffset,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c
index 0b817540a9e4..2e1df01bd928 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c
@@ -30,6 +30,7 @@
30#include <subdev/timer.h> 30#include <subdev/timer.h>
31 31
32#include <nvif/class.h> 32#include <nvif/class.h>
33#include <nvif/cla06f.h>
33#include <nvif/unpack.h> 34#include <nvif/unpack.h>
34 35
35static int 36static int
@@ -151,9 +152,9 @@ gk104_fifo_gpfifo_fini(struct nvkm_fifo_chan *base)
151 u32 coff = chan->base.chid * 8; 152 u32 coff = chan->base.chid * 8;
152 153
153 if (!list_empty(&chan->head)) { 154 if (!list_empty(&chan->head)) {
154 list_del_init(&chan->head); 155 gk104_fifo_runlist_remove(fifo, chan);
155 nvkm_mask(device, 0x800004 + coff, 0x00000800, 0x00000800); 156 nvkm_mask(device, 0x800004 + coff, 0x00000800, 0x00000800);
156 gk104_fifo_runlist_update(fifo, chan->engine); 157 gk104_fifo_runlist_commit(fifo, chan->engine);
157 } 158 }
158 159
159 nvkm_wr32(device, 0x800000 + coff, 0x00000000); 160 nvkm_wr32(device, 0x800000 + coff, 0x00000000);
@@ -172,9 +173,9 @@ gk104_fifo_gpfifo_init(struct nvkm_fifo_chan *base)
172 nvkm_wr32(device, 0x800000 + coff, 0x80000000 | addr); 173 nvkm_wr32(device, 0x800000 + coff, 0x80000000 | addr);
173 174
174 if (list_empty(&chan->head) && !chan->killed) { 175 if (list_empty(&chan->head) && !chan->killed) {
175 list_add_tail(&chan->head, &fifo->engine[chan->engine].chan); 176 gk104_fifo_runlist_insert(fifo, chan);
176 nvkm_mask(device, 0x800004 + coff, 0x00000400, 0x00000400); 177 nvkm_mask(device, 0x800004 + coff, 0x00000400, 0x00000400);
177 gk104_fifo_runlist_update(fifo, chan->engine); 178 gk104_fifo_runlist_commit(fifo, chan->engine);
178 nvkm_mask(device, 0x800004 + coff, 0x00000400, 0x00000400); 179 nvkm_mask(device, 0x800004 + coff, 0x00000400, 0x00000400);
179 } 180 }
180} 181}
@@ -213,10 +214,10 @@ gk104_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
213 struct gk104_fifo_chan *chan; 214 struct gk104_fifo_chan *chan;
214 u64 usermem, ioffset, ilength; 215 u64 usermem, ioffset, ilength;
215 u32 engines; 216 u32 engines;
216 int ret, i; 217 int ret = -ENOSYS, i;
217 218
218 nvif_ioctl(parent, "create channel gpfifo size %d\n", size); 219 nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
219 if (nvif_unpack(args->v0, 0, 0, false)) { 220 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
220 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx " 221 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
221 "ioffset %016llx ilength %08x engine %08x\n", 222 "ioffset %016llx ilength %08x engine %08x\n",
222 args->v0.version, args->v0.vm, args->v0.ioffset, 223 args->v0.version, args->v0.vm, args->v0.ioffset,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c
index a8c69f878221..c5a7de9db259 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c
@@ -27,6 +27,7 @@
27#include <core/ramht.h> 27#include <core/ramht.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/cl506f.h>
30#include <nvif/unpack.h> 31#include <nvif/unpack.h>
31 32
32static int 33static int
@@ -40,10 +41,10 @@ nv50_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
40 struct nv50_fifo *fifo = nv50_fifo(base); 41 struct nv50_fifo *fifo = nv50_fifo(base);
41 struct nv50_fifo_chan *chan; 42 struct nv50_fifo_chan *chan;
42 u64 ioffset, ilength; 43 u64 ioffset, ilength;
43 int ret; 44 int ret = -ENOSYS;
44 45
45 nvif_ioctl(parent, "create channel gpfifo size %d\n", size); 46 nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
46 if (nvif_unpack(args->v0, 0, 0, false)) { 47 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
47 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx " 48 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
48 "pushbuf %llx ioffset %016llx " 49 "pushbuf %llx ioffset %016llx "
49 "ilength %08x\n", 50 "ilength %08x\n",
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgk20a.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgk20a.c
index ddaa16a71c84..ad0a6cfe7580 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgk20a.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgk20a.c
@@ -55,7 +55,7 @@ gk20a_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info)
55 55
56 gk104_grctx_generate_rop_active_fbps(gr); 56 gk104_grctx_generate_rop_active_fbps(gr);
57 57
58 nvkm_mask(device, 0x5044b0, 0x8000000, 0x8000000); 58 nvkm_mask(device, 0x5044b0, 0x08000000, 0x08000000);
59 59
60 gf100_gr_wait_idle(gr); 60 gf100_gr_wait_idle(gr);
61 61
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc
index 7dacb3cc0668..e168b83a10c9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc
@@ -247,10 +247,7 @@ init:
247 tpc_strand_info(-1); 247 tpc_strand_info(-1);
248 248
249 ld b32 $r4 D[$r0 + #tpc_count] 249 ld b32 $r4 D[$r0 + #tpc_count]
250 mov $r5 NV_PGRAPH_GPC0_TPC0 250 gpc_addr($r5, NV_PGRAPH_GPC0_TPC0)
251 ld b32 $r6 D[$r0 + #gpc_id]
252 shl b32 $r6 15
253 add b32 $r5 $r6
254 tpc_strand_init_tpc_loop: 251 tpc_strand_init_tpc_loop:
255 add b32 $r14 $r5 NV_TPC_STRAND_CNT 252 add b32 $r14 $r5 NV_TPC_STRAND_CNT
256 call(nv_rd32) 253 call(nv_rd32)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h
index 11bf363a6ae9..5136f9161706 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h
@@ -289,7 +289,7 @@ uint32_t gm107_grgpc_code[] = {
289 0x020014fe, 289 0x020014fe,
290 0x12004002, 290 0x12004002,
291 0xbd0002f6, 291 0xbd0002f6,
292 0x05b34104, 292 0x05ad4104,
293 0x400010fe, 293 0x400010fe,
294 0x00f60700, 294 0x00f60700,
295 0x0204bd00, 295 0x0204bd00,
@@ -387,180 +387,180 @@ uint32_t gm107_grgpc_code[] = {
387 0x7e00008f, 387 0x7e00008f,
388 0x98000314, 388 0x98000314,
389 0x00850504, 389 0x00850504,
390 0x06985040, 390 0x55f05040,
391 0x0f64b604, 391/* 0x04dd: tpc_strand_init_tpc_loop */
392/* 0x04e3: tpc_strand_init_tpc_loop */ 392 0x705eb801,
393 0xb80056bb, 393 0x657e0005,
394 0x0005705e, 394 0xf6b20000,
395 0x0000657e, 395/* 0x04ea: tpc_strand_init_idx_loop */
396 0x74bdf6b2, 396 0x5eb874bd,
397/* 0x04f0: tpc_strand_init_idx_loop */ 397 0xb2000560,
398 0x05605eb8, 398 0x008f7e7f,
399 0x7e7fb200, 399 0x885eb800,
400 0xb800008f, 400 0x2f950005,
401 0x0005885e, 401 0x008f7e08,
402 0x7e082f95, 402 0x8c5eb800,
403 0xb800008f, 403 0x2f950005,
404 0x00058c5e, 404 0x008f7e08,
405 0x7e082f95, 405 0x905eb800,
406 0xb800008f, 406 0x657e0005,
407 0x0005905e, 407 0xf5b60000,
408 0x0000657e, 408 0x01f0b606,
409 0xb606f5b6, 409 0xbb08f4b6,
410 0xf4b601f0, 410 0x3fbb002f,
411 0x002fbb08, 411 0x0170b600,
412 0xb6003fbb, 412 0xf40162b6,
413 0x62b60170, 413 0x50b7bf1b,
414 0xbf1bf401, 414 0x42b60800,
415 0x080050b7, 415 0xa81bf401,
416 0xf40142b6,
417 0x3f0fa81b,
418 0x501d608e,
419 0xb201e5f0,
420 0x008f7eff,
421 0x8e0d0f00,
422 0xf0501da8,
423 0xffb201e5,
424 0x00008f7e,
425 0x0003147e,
426 0x02010080,
427 0xbd0003f6,
428 0xf024bd04,
429 0x00801f29,
430 0x02f60230,
431/* 0x0577: main */
432 0xf404bd00,
433 0x28f40031,
434 0x7e240d00,
435 0xf4000037,
436 0xe4b0f401,
437 0x1d18f404,
438 0x020181fe,
439 0xfd20bd06,
440 0xe4b60412,
441 0x051efd01,
442 0x7e0018fe,
443 0xf400064a,
444/* 0x05a6: main_not_ctx_xfer */
445 0xef94d40e,
446 0x01f5f010,
447 0x0002f87e,
448/* 0x05b3: ih */
449 0xf9c70ef4,
450 0x0188fe80,
451 0x90f980f9,
452 0xb0f9a0f9,
453 0xe0f9d0f9,
454 0x04bdf0f9,
455 0xcf02004a,
456 0xabc400aa,
457 0x1f0bf404,
458 0x004e240d,
459 0x00eecf1a,
460 0xcf19004f,
461 0x047e00ff,
462 0x010e0000,
463 0xf61d0040,
464 0x04bd000e,
465/* 0x05f0: ih_no_fifo */
466 0xf6010040,
467 0x04bd000a,
468 0xe0fcf0fc,
469 0xb0fcd0fc,
470 0x90fca0fc,
471 0x88fe80fc,
472 0xf480fc00,
473 0x01f80032,
474/* 0x0610: hub_barrier_done */
475 0x0e98010f,
476 0x04febb04,
477 0x188effb2,
478 0x8f7e4094,
479 0x00f80000,
480/* 0x0624: ctx_redswitch */
481 0x0080200f,
482 0x0ff60185,
483 0x0e04bd00,
484/* 0x0631: ctx_redswitch_delay */
485 0x01e2b608,
486 0xf1fd1bf4,
487 0xf10800f5,
488 0x800200f5,
489 0xf6018500,
490 0x04bd000f,
491/* 0x064a: ctx_xfer */
492 0x008000f8,
493 0x0ff60281,
494 0x8e04bd00,
495 0xf0501dc4,
496 0xffb201e5,
497 0x00008f7e,
498 0x7e0711f4,
499/* 0x0667: ctx_xfer_not_load */
500 0x7e000624,
501 0xbd000216,
502 0x47fc8024,
503 0x0002f602,
504 0x2cf004bd,
505 0x0320b601,
506 0x024afc80,
507 0xbd0002f6,
508 0x8e0c0f04,
509 0xf0501da8,
510 0xffb201e5,
511 0x00008f7e,
512 0x0003147e,
513 0x608e3f0f, 416 0x608e3f0f,
514 0xe5f0501d, 417 0xe5f0501d,
515 0x7effb201, 418 0x7effb201,
516 0x0f00008f, 419 0x0f00008f,
517 0x1d9c8e00, 420 0x1da88e0d,
518 0x01e5f050, 421 0x01e5f050,
519 0x8f7effb2, 422 0x8f7effb2,
520 0x010f0000, 423 0x147e0000,
521 0x0003147e, 424 0x00800003,
522 0xb601fcf0, 425 0x03f60201,
523 0xa88e03f0, 426 0xbd04bd00,
524 0xe5f0501d, 427 0x1f29f024,
525 0x7effb201, 428 0x02300080,
526 0xf000008f, 429 0xbd0002f6,
527 0xa5f001ac, 430/* 0x0571: main */
528 0x00008b02, 431 0x0031f404,
529 0x040c9850, 432 0x0d0028f4,
530 0xbb0fc4b6, 433 0x00377e24,
531 0x0c9800bc, 434 0xf401f400,
532 0x010d9800, 435 0xf404e4b0,
533 0x3d7e000e, 436 0x81fe1d18,
534 0xacf00001, 437 0xbd060201,
535 0x40008b01, 438 0x0412fd20,
536 0x040c9850, 439 0xfd01e4b6,
537 0xbb0fc4b6, 440 0x18fe051e,
538 0x0c9800bc, 441 0x06447e00,
539 0x020d9801, 442 0xd40ef400,
540 0x4e060f98, 443/* 0x05a0: main_not_ctx_xfer */
541 0x3d7e0800, 444 0xf010ef94,
542 0xacf00001, 445 0xf87e01f5,
543 0x04a5f001, 446 0x0ef40002,
544 0x5030008b, 447/* 0x05ad: ih */
545 0xb6040c98, 448 0xfe80f9c7,
546 0xbcbb0fc4, 449 0x80f90188,
547 0x020c9800, 450 0xa0f990f9,
548 0x98030d98, 451 0xd0f9b0f9,
549 0x004e080f, 452 0xf0f9e0f9,
550 0x013d7e02, 453 0x004a04bd,
551 0x020a7e00, 454 0x00aacf02,
552 0x03147e00, 455 0xf404abc4,
553 0x0601f400, 456 0x240d1f0b,
554/* 0x073f: ctx_xfer_post */ 457 0xcf1a004e,
555 0x7e1a12f4, 458 0x004f00ee,
556 0x0f000227, 459 0x00ffcf19,
557 0x1da88e0d, 460 0x0000047e,
461 0x0040010e,
462 0x000ef61d,
463/* 0x05ea: ih_no_fifo */
464 0x004004bd,
465 0x000af601,
466 0xf0fc04bd,
467 0xd0fce0fc,
468 0xa0fcb0fc,
469 0x80fc90fc,
470 0xfc0088fe,
471 0x0032f480,
472/* 0x060a: hub_barrier_done */
473 0x010f01f8,
474 0xbb040e98,
475 0xffb204fe,
476 0x4094188e,
477 0x00008f7e,
478/* 0x061e: ctx_redswitch */
479 0x200f00f8,
480 0x01850080,
481 0xbd000ff6,
482/* 0x062b: ctx_redswitch_delay */
483 0xb6080e04,
484 0x1bf401e2,
485 0x00f5f1fd,
486 0x00f5f108,
487 0x85008002,
488 0x000ff601,
489 0x00f804bd,
490/* 0x0644: ctx_xfer */
491 0x02810080,
492 0xbd000ff6,
493 0x1dc48e04,
494 0x01e5f050,
495 0x8f7effb2,
496 0x11f40000,
497 0x061e7e07,
498/* 0x0661: ctx_xfer_not_load */
499 0x02167e00,
500 0x8024bd00,
501 0xf60247fc,
502 0x04bd0002,
503 0xb6012cf0,
504 0xfc800320,
505 0x02f6024a,
506 0x0f04bd00,
507 0x1da88e0c,
558 0x01e5f050, 508 0x01e5f050,
559 0x8f7effb2, 509 0x8f7effb2,
560 0x147e0000, 510 0x147e0000,
561/* 0x0756: ctx_xfer_done */ 511 0x3f0f0003,
562 0x107e0003, 512 0x501d608e,
563 0x00f80006, 513 0xb201e5f0,
514 0x008f7eff,
515 0x8e000f00,
516 0xf0501d9c,
517 0xffb201e5,
518 0x00008f7e,
519 0x147e010f,
520 0xfcf00003,
521 0x03f0b601,
522 0x501da88e,
523 0xb201e5f0,
524 0x008f7eff,
525 0x01acf000,
526 0x8b02a5f0,
527 0x98500000,
528 0xc4b6040c,
529 0x00bcbb0f,
530 0x98000c98,
531 0x000e010d,
532 0x00013d7e,
533 0x8b01acf0,
534 0x98504000,
535 0xc4b6040c,
536 0x00bcbb0f,
537 0x98010c98,
538 0x0f98020d,
539 0x08004e06,
540 0x00013d7e,
541 0xf001acf0,
542 0x008b04a5,
543 0x0c985030,
544 0x0fc4b604,
545 0x9800bcbb,
546 0x0d98020c,
547 0x080f9803,
548 0x7e02004e,
549 0x7e00013d,
550 0x7e00020a,
551 0xf4000314,
552 0x12f40601,
553/* 0x0739: ctx_xfer_post */
554 0x02277e1a,
555 0x8e0d0f00,
556 0xf0501da8,
557 0xffb201e5,
558 0x00008f7e,
559 0x0003147e,
560/* 0x0750: ctx_xfer_done */
561 0x00060a7e,
562 0x000000f8,
563 0x00000000,
564 0x00000000, 564 0x00000000,
565 0x00000000, 565 0x00000000,
566 0x00000000, 566 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
index 9f5dfc85147a..1f81069edc58 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
@@ -34,6 +34,7 @@
34#include <engine/fifo.h> 34#include <engine/fifo.h>
35 35
36#include <nvif/class.h> 36#include <nvif/class.h>
37#include <nvif/cl9097.h>
37#include <nvif/unpack.h> 38#include <nvif/unpack.h>
38 39
39/******************************************************************************* 40/*******************************************************************************
@@ -139,6 +140,12 @@ gf100_gr_zbc_depth_get(struct gf100_gr *gr, int format,
139/******************************************************************************* 140/*******************************************************************************
140 * Graphics object classes 141 * Graphics object classes
141 ******************************************************************************/ 142 ******************************************************************************/
143#define gf100_gr_object(p) container_of((p), struct gf100_gr_object, object)
144
145struct gf100_gr_object {
146 struct nvkm_object object;
147 struct gf100_gr_chan *chan;
148};
142 149
143static int 150static int
144gf100_fermi_mthd_zbc_color(struct nvkm_object *object, void *data, u32 size) 151gf100_fermi_mthd_zbc_color(struct nvkm_object *object, void *data, u32 size)
@@ -147,9 +154,9 @@ gf100_fermi_mthd_zbc_color(struct nvkm_object *object, void *data, u32 size)
147 union { 154 union {
148 struct fermi_a_zbc_color_v0 v0; 155 struct fermi_a_zbc_color_v0 v0;
149 } *args = data; 156 } *args = data;
150 int ret; 157 int ret = -ENOSYS;
151 158
152 if (nvif_unpack(args->v0, 0, 0, false)) { 159 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
153 switch (args->v0.format) { 160 switch (args->v0.format) {
154 case FERMI_A_ZBC_COLOR_V0_FMT_ZERO: 161 case FERMI_A_ZBC_COLOR_V0_FMT_ZERO:
155 case FERMI_A_ZBC_COLOR_V0_FMT_UNORM_ONE: 162 case FERMI_A_ZBC_COLOR_V0_FMT_UNORM_ONE:
@@ -193,9 +200,9 @@ gf100_fermi_mthd_zbc_depth(struct nvkm_object *object, void *data, u32 size)
193 union { 200 union {
194 struct fermi_a_zbc_depth_v0 v0; 201 struct fermi_a_zbc_depth_v0 v0;
195 } *args = data; 202 } *args = data;
196 int ret; 203 int ret = -ENOSYS;
197 204
198 if (nvif_unpack(args->v0, 0, 0, false)) { 205 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
199 switch (args->v0.format) { 206 switch (args->v0.format) {
200 case FERMI_A_ZBC_DEPTH_V0_FMT_FP32: 207 case FERMI_A_ZBC_DEPTH_V0_FMT_FP32:
201 ret = gf100_gr_zbc_depth_get(gr, args->v0.format, 208 ret = gf100_gr_zbc_depth_get(gr, args->v0.format,
@@ -213,6 +220,7 @@ gf100_fermi_mthd_zbc_depth(struct nvkm_object *object, void *data, u32 size)
213static int 220static int
214gf100_fermi_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) 221gf100_fermi_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
215{ 222{
223 nvif_ioctl(object, "fermi mthd %08x\n", mthd);
216 switch (mthd) { 224 switch (mthd) {
217 case FERMI_A_ZBC_COLOR: 225 case FERMI_A_ZBC_COLOR:
218 return gf100_fermi_mthd_zbc_color(object, data, size); 226 return gf100_fermi_mthd_zbc_color(object, data, size);
@@ -256,6 +264,27 @@ gf100_gr_mthd_sw(struct nvkm_device *device, u16 class, u32 mthd, u32 data)
256 return false; 264 return false;
257} 265}
258 266
267static const struct nvkm_object_func
268gf100_gr_object_func = {
269};
270
271static int
272gf100_gr_object_new(const struct nvkm_oclass *oclass, void *data, u32 size,
273 struct nvkm_object **pobject)
274{
275 struct gf100_gr_chan *chan = gf100_gr_chan(oclass->parent);
276 struct gf100_gr_object *object;
277
278 if (!(object = kzalloc(sizeof(*object), GFP_KERNEL)))
279 return -ENOMEM;
280 *pobject = &object->object;
281
282 nvkm_object_ctor(oclass->base.func ? oclass->base.func :
283 &gf100_gr_object_func, oclass, &object->object);
284 object->chan = chan;
285 return 0;
286}
287
259static int 288static int
260gf100_gr_object_get(struct nvkm_gr *base, int index, struct nvkm_sclass *sclass) 289gf100_gr_object_get(struct nvkm_gr *base, int index, struct nvkm_sclass *sclass)
261{ 290{
@@ -265,6 +294,7 @@ gf100_gr_object_get(struct nvkm_gr *base, int index, struct nvkm_sclass *sclass)
265 while (gr->func->sclass[c].oclass) { 294 while (gr->func->sclass[c].oclass) {
266 if (c++ == index) { 295 if (c++ == index) {
267 *sclass = gr->func->sclass[index]; 296 *sclass = gr->func->sclass[index];
297 sclass->ctor = gf100_gr_object_new;
268 return index; 298 return index;
269 } 299 }
270 } 300 }
@@ -826,7 +856,41 @@ gf100_gr_units(struct nvkm_gr *base)
826 return cfg; 856 return cfg;
827} 857}
828 858
859static const struct nvkm_bitfield gf100_dispatch_error[] = {
860 { 0x00000001, "INJECTED_BUNDLE_ERROR" },
861 { 0x00000002, "CLASS_SUBCH_MISMATCH" },
862 { 0x00000004, "SUBCHSW_DURING_NOTIFY" },
863 {}
864};
865
866static const struct nvkm_bitfield gf100_m2mf_error[] = {
867 { 0x00000001, "PUSH_TOO_MUCH_DATA" },
868 { 0x00000002, "PUSH_NOT_ENOUGH_DATA" },
869 {}
870};
871
872static const struct nvkm_bitfield gf100_unk6_error[] = {
873 { 0x00000001, "TEMP_TOO_SMALL" },
874 {}
875};
876
877static const struct nvkm_bitfield gf100_ccache_error[] = {
878 { 0x00000001, "INTR" },
879 { 0x00000002, "LDCONST_OOB" },
880 {}
881};
882
883static const struct nvkm_bitfield gf100_macro_error[] = {
884 { 0x00000001, "TOO_FEW_PARAMS" },
885 { 0x00000002, "TOO_MANY_PARAMS" },
886 { 0x00000004, "ILLEGAL_OPCODE" },
887 { 0x00000008, "DOUBLE_BRANCH" },
888 { 0x00000010, "WATCHDOG" },
889 {}
890};
891
829static const struct nvkm_bitfield gk104_sked_error[] = { 892static const struct nvkm_bitfield gk104_sked_error[] = {
893 { 0x00000040, "CTA_RESUME" },
830 { 0x00000080, "CONSTANT_BUFFER_SIZE" }, 894 { 0x00000080, "CONSTANT_BUFFER_SIZE" },
831 { 0x00000200, "LOCAL_MEMORY_SIZE_POS" }, 895 { 0x00000200, "LOCAL_MEMORY_SIZE_POS" },
832 { 0x00000400, "LOCAL_MEMORY_SIZE_NEG" }, 896 { 0x00000400, "LOCAL_MEMORY_SIZE_NEG" },
@@ -836,6 +900,8 @@ static const struct nvkm_bitfield gk104_sked_error[] = {
836 { 0x00040000, "TOTAL_THREADS" }, 900 { 0x00040000, "TOTAL_THREADS" },
837 { 0x00100000, "PROGRAM_OFFSET" }, 901 { 0x00100000, "PROGRAM_OFFSET" },
838 { 0x00200000, "SHARED_MEMORY_SIZE" }, 902 { 0x00200000, "SHARED_MEMORY_SIZE" },
903 { 0x00800000, "CTA_THREAD_DIMENSION_ZERO" },
904 { 0x01000000, "MEMORY_WINDOW_OVERLAP" },
839 { 0x02000000, "SHARED_CONFIG_TOO_SMALL" }, 905 { 0x02000000, "SHARED_CONFIG_TOO_SMALL" },
840 { 0x04000000, "TOTAL_REGISTER_COUNT" }, 906 { 0x04000000, "TOTAL_REGISTER_COUNT" },
841 {} 907 {}
@@ -1005,12 +1071,16 @@ gf100_gr_trap_intr(struct gf100_gr *gr)
1005{ 1071{
1006 struct nvkm_subdev *subdev = &gr->base.engine.subdev; 1072 struct nvkm_subdev *subdev = &gr->base.engine.subdev;
1007 struct nvkm_device *device = subdev->device; 1073 struct nvkm_device *device = subdev->device;
1074 char error[128];
1008 u32 trap = nvkm_rd32(device, 0x400108); 1075 u32 trap = nvkm_rd32(device, 0x400108);
1009 int rop, gpc; 1076 int rop, gpc;
1010 1077
1011 if (trap & 0x00000001) { 1078 if (trap & 0x00000001) {
1012 u32 stat = nvkm_rd32(device, 0x404000); 1079 u32 stat = nvkm_rd32(device, 0x404000);
1013 nvkm_error(subdev, "DISPATCH %08x\n", stat); 1080
1081 nvkm_snprintbf(error, sizeof(error), gf100_dispatch_error,
1082 stat & 0x3fffffff);
1083 nvkm_error(subdev, "DISPATCH %08x [%s]\n", stat, error);
1014 nvkm_wr32(device, 0x404000, 0xc0000000); 1084 nvkm_wr32(device, 0x404000, 0xc0000000);
1015 nvkm_wr32(device, 0x400108, 0x00000001); 1085 nvkm_wr32(device, 0x400108, 0x00000001);
1016 trap &= ~0x00000001; 1086 trap &= ~0x00000001;
@@ -1018,7 +1088,11 @@ gf100_gr_trap_intr(struct gf100_gr *gr)
1018 1088
1019 if (trap & 0x00000002) { 1089 if (trap & 0x00000002) {
1020 u32 stat = nvkm_rd32(device, 0x404600); 1090 u32 stat = nvkm_rd32(device, 0x404600);
1021 nvkm_error(subdev, "M2MF %08x\n", stat); 1091
1092 nvkm_snprintbf(error, sizeof(error), gf100_m2mf_error,
1093 stat & 0x3fffffff);
1094 nvkm_error(subdev, "M2MF %08x [%s]\n", stat, error);
1095
1022 nvkm_wr32(device, 0x404600, 0xc0000000); 1096 nvkm_wr32(device, 0x404600, 0xc0000000);
1023 nvkm_wr32(device, 0x400108, 0x00000002); 1097 nvkm_wr32(device, 0x400108, 0x00000002);
1024 trap &= ~0x00000002; 1098 trap &= ~0x00000002;
@@ -1026,7 +1100,10 @@ gf100_gr_trap_intr(struct gf100_gr *gr)
1026 1100
1027 if (trap & 0x00000008) { 1101 if (trap & 0x00000008) {
1028 u32 stat = nvkm_rd32(device, 0x408030); 1102 u32 stat = nvkm_rd32(device, 0x408030);
1029 nvkm_error(subdev, "CCACHE %08x\n", stat); 1103
1104 nvkm_snprintbf(error, sizeof(error), gf100_m2mf_error,
1105 stat & 0x3fffffff);
1106 nvkm_error(subdev, "CCACHE %08x [%s]\n", stat, error);
1030 nvkm_wr32(device, 0x408030, 0xc0000000); 1107 nvkm_wr32(device, 0x408030, 0xc0000000);
1031 nvkm_wr32(device, 0x400108, 0x00000008); 1108 nvkm_wr32(device, 0x400108, 0x00000008);
1032 trap &= ~0x00000008; 1109 trap &= ~0x00000008;
@@ -1034,7 +1111,8 @@ gf100_gr_trap_intr(struct gf100_gr *gr)
1034 1111
1035 if (trap & 0x00000010) { 1112 if (trap & 0x00000010) {
1036 u32 stat = nvkm_rd32(device, 0x405840); 1113 u32 stat = nvkm_rd32(device, 0x405840);
1037 nvkm_error(subdev, "SHADER %08x\n", stat); 1114 nvkm_error(subdev, "SHADER %08x, sph: 0x%06x, stage: 0x%02x\n",
1115 stat, stat & 0xffffff, (stat >> 24) & 0x3f);
1038 nvkm_wr32(device, 0x405840, 0xc0000000); 1116 nvkm_wr32(device, 0x405840, 0xc0000000);
1039 nvkm_wr32(device, 0x400108, 0x00000010); 1117 nvkm_wr32(device, 0x400108, 0x00000010);
1040 trap &= ~0x00000010; 1118 trap &= ~0x00000010;
@@ -1042,7 +1120,11 @@ gf100_gr_trap_intr(struct gf100_gr *gr)
1042 1120
1043 if (trap & 0x00000040) { 1121 if (trap & 0x00000040) {
1044 u32 stat = nvkm_rd32(device, 0x40601c); 1122 u32 stat = nvkm_rd32(device, 0x40601c);
1045 nvkm_error(subdev, "UNK6 %08x\n", stat); 1123
1124 nvkm_snprintbf(error, sizeof(error), gf100_unk6_error,
1125 stat & 0x3fffffff);
1126 nvkm_error(subdev, "UNK6 %08x [%s]\n", stat, error);
1127
1046 nvkm_wr32(device, 0x40601c, 0xc0000000); 1128 nvkm_wr32(device, 0x40601c, 0xc0000000);
1047 nvkm_wr32(device, 0x400108, 0x00000040); 1129 nvkm_wr32(device, 0x400108, 0x00000040);
1048 trap &= ~0x00000040; 1130 trap &= ~0x00000040;
@@ -1050,7 +1132,16 @@ gf100_gr_trap_intr(struct gf100_gr *gr)
1050 1132
1051 if (trap & 0x00000080) { 1133 if (trap & 0x00000080) {
1052 u32 stat = nvkm_rd32(device, 0x404490); 1134 u32 stat = nvkm_rd32(device, 0x404490);
1053 nvkm_error(subdev, "MACRO %08x\n", stat); 1135 u32 pc = nvkm_rd32(device, 0x404494);
1136 u32 op = nvkm_rd32(device, 0x40449c);
1137
1138 nvkm_snprintbf(error, sizeof(error), gf100_macro_error,
1139 stat & 0x1fffffff);
1140 nvkm_error(subdev, "MACRO %08x [%s], pc: 0x%03x%s, op: 0x%08x\n",
1141 stat, error, pc & 0x7ff,
1142 (pc & 0x10000000) ? "" : " (invalid)",
1143 op);
1144
1054 nvkm_wr32(device, 0x404490, 0xc0000000); 1145 nvkm_wr32(device, 0x404490, 0xc0000000);
1055 nvkm_wr32(device, 0x400108, 0x00000080); 1146 nvkm_wr32(device, 0x400108, 0x00000080);
1056 trap &= ~0x00000080; 1147 trap &= ~0x00000080;
@@ -1058,10 +1149,9 @@ gf100_gr_trap_intr(struct gf100_gr *gr)
1058 1149
1059 if (trap & 0x00000100) { 1150 if (trap & 0x00000100) {
1060 u32 stat = nvkm_rd32(device, 0x407020) & 0x3fffffff; 1151 u32 stat = nvkm_rd32(device, 0x407020) & 0x3fffffff;
1061 char sked[128];
1062 1152
1063 nvkm_snprintbf(sked, sizeof(sked), gk104_sked_error, stat); 1153 nvkm_snprintbf(error, sizeof(error), gk104_sked_error, stat);
1064 nvkm_error(subdev, "SKED: %08x [%s]\n", stat, sked); 1154 nvkm_error(subdev, "SKED: %08x [%s]\n", stat, error);
1065 1155
1066 if (stat) 1156 if (stat)
1067 nvkm_wr32(device, 0x407020, 0x40000000); 1157 nvkm_wr32(device, 0x407020, 0x40000000);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
index 2721592d3031..f19fabef8d73 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
@@ -27,6 +27,8 @@
27#include <core/option.h> 27#include <core/option.h>
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/if0002.h>
31#include <nvif/if0003.h>
30#include <nvif/ioctl.h> 32#include <nvif/ioctl.h>
31#include <nvif/unpack.h> 33#include <nvif/unpack.h>
32 34
@@ -210,10 +212,10 @@ nvkm_perfdom_init(struct nvkm_perfdom *dom, void *data, u32 size)
210 } *args = data; 212 } *args = data;
211 struct nvkm_object *object = &dom->object; 213 struct nvkm_object *object = &dom->object;
212 struct nvkm_pm *pm = dom->perfmon->pm; 214 struct nvkm_pm *pm = dom->perfmon->pm;
213 int ret, i; 215 int ret = -ENOSYS, i;
214 216
215 nvif_ioctl(object, "perfdom init size %d\n", size); 217 nvif_ioctl(object, "perfdom init size %d\n", size);
216 if (nvif_unvers(args->none)) { 218 if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
217 nvif_ioctl(object, "perfdom init\n"); 219 nvif_ioctl(object, "perfdom init\n");
218 } else 220 } else
219 return ret; 221 return ret;
@@ -240,10 +242,10 @@ nvkm_perfdom_sample(struct nvkm_perfdom *dom, void *data, u32 size)
240 } *args = data; 242 } *args = data;
241 struct nvkm_object *object = &dom->object; 243 struct nvkm_object *object = &dom->object;
242 struct nvkm_pm *pm = dom->perfmon->pm; 244 struct nvkm_pm *pm = dom->perfmon->pm;
243 int ret; 245 int ret = -ENOSYS;
244 246
245 nvif_ioctl(object, "perfdom sample size %d\n", size); 247 nvif_ioctl(object, "perfdom sample size %d\n", size);
246 if (nvif_unvers(args->none)) { 248 if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
247 nvif_ioctl(object, "perfdom sample\n"); 249 nvif_ioctl(object, "perfdom sample\n");
248 } else 250 } else
249 return ret; 251 return ret;
@@ -264,10 +266,10 @@ nvkm_perfdom_read(struct nvkm_perfdom *dom, void *data, u32 size)
264 } *args = data; 266 } *args = data;
265 struct nvkm_object *object = &dom->object; 267 struct nvkm_object *object = &dom->object;
266 struct nvkm_pm *pm = dom->perfmon->pm; 268 struct nvkm_pm *pm = dom->perfmon->pm;
267 int ret, i; 269 int ret = -ENOSYS, i;
268 270
269 nvif_ioctl(object, "perfdom read size %d\n", size); 271 nvif_ioctl(object, "perfdom read size %d\n", size);
270 if (nvif_unpack(args->v0, 0, 0, false)) { 272 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
271 nvif_ioctl(object, "perfdom read vers %d\n", args->v0.version); 273 nvif_ioctl(object, "perfdom read vers %d\n", args->v0.version);
272 } else 274 } else
273 return ret; 275 return ret;
@@ -374,10 +376,10 @@ nvkm_perfdom_new_(struct nvkm_perfmon *perfmon,
374 struct nvkm_perfctr *ctr[4] = {}; 376 struct nvkm_perfctr *ctr[4] = {};
375 struct nvkm_perfdom *dom; 377 struct nvkm_perfdom *dom;
376 int c, s, m; 378 int c, s, m;
377 int ret; 379 int ret = -ENOSYS;
378 380
379 nvif_ioctl(parent, "create perfdom size %d\n", size); 381 nvif_ioctl(parent, "create perfdom size %d\n", size);
380 if (nvif_unpack(args->v0, 0, 0, false)) { 382 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
381 nvif_ioctl(parent, "create perfdom vers %d dom %d mode %02x\n", 383 nvif_ioctl(parent, "create perfdom vers %d dom %d mode %02x\n",
382 args->v0.version, args->v0.domain, args->v0.mode); 384 args->v0.version, args->v0.domain, args->v0.mode);
383 } else 385 } else
@@ -439,10 +441,10 @@ nvkm_perfmon_mthd_query_domain(struct nvkm_perfmon *perfmon,
439 struct nvkm_pm *pm = perfmon->pm; 441 struct nvkm_pm *pm = perfmon->pm;
440 struct nvkm_perfdom *dom; 442 struct nvkm_perfdom *dom;
441 u8 domain_nr; 443 u8 domain_nr;
442 int di, ret; 444 int di, ret = -ENOSYS;
443 445
444 nvif_ioctl(object, "perfmon query domain size %d\n", size); 446 nvif_ioctl(object, "perfmon query domain size %d\n", size);
445 if (nvif_unpack(args->v0, 0, 0, false)) { 447 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
446 nvif_ioctl(object, "perfmon domain vers %d iter %02x\n", 448 nvif_ioctl(object, "perfmon domain vers %d iter %02x\n",
447 args->v0.version, args->v0.iter); 449 args->v0.version, args->v0.iter);
448 di = (args->v0.iter & 0xff) - 1; 450 di = (args->v0.iter & 0xff) - 1;
@@ -490,10 +492,10 @@ nvkm_perfmon_mthd_query_signal(struct nvkm_perfmon *perfmon,
490 struct nvkm_perfsig *sig; 492 struct nvkm_perfsig *sig;
491 const bool all = nvkm_boolopt(device->cfgopt, "NvPmShowAll", false); 493 const bool all = nvkm_boolopt(device->cfgopt, "NvPmShowAll", false);
492 const bool raw = nvkm_boolopt(device->cfgopt, "NvPmUnnamed", all); 494 const bool raw = nvkm_boolopt(device->cfgopt, "NvPmUnnamed", all);
493 int ret, si; 495 int ret = -ENOSYS, si;
494 496
495 nvif_ioctl(object, "perfmon query signal size %d\n", size); 497 nvif_ioctl(object, "perfmon query signal size %d\n", size);
496 if (nvif_unpack(args->v0, 0, 0, false)) { 498 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
497 nvif_ioctl(object, 499 nvif_ioctl(object,
498 "perfmon query signal vers %d dom %d iter %04x\n", 500 "perfmon query signal vers %d dom %d iter %04x\n",
499 args->v0.version, args->v0.domain, args->v0.iter); 501 args->v0.version, args->v0.domain, args->v0.iter);
@@ -543,10 +545,10 @@ nvkm_perfmon_mthd_query_source(struct nvkm_perfmon *perfmon,
543 struct nvkm_perfsig *sig; 545 struct nvkm_perfsig *sig;
544 struct nvkm_perfsrc *src; 546 struct nvkm_perfsrc *src;
545 u8 source_nr = 0; 547 u8 source_nr = 0;
546 int si, ret; 548 int si, ret = -ENOSYS;
547 549
548 nvif_ioctl(object, "perfmon query source size %d\n", size); 550 nvif_ioctl(object, "perfmon query source size %d\n", size);
549 if (nvif_unpack(args->v0, 0, 0, false)) { 551 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
550 nvif_ioctl(object, 552 nvif_ioctl(object,
551 "perfmon source vers %d dom %d sig %02x iter %02x\n", 553 "perfmon source vers %d dom %d sig %02x iter %02x\n",
552 args->v0.version, args->v0.domain, args->v0.signal, 554 args->v0.version, args->v0.domain, args->v0.signal,
@@ -612,7 +614,7 @@ nvkm_perfmon_child_get(struct nvkm_object *object, int index,
612 struct nvkm_oclass *oclass) 614 struct nvkm_oclass *oclass)
613{ 615{
614 if (index == 0) { 616 if (index == 0) {
615 oclass->base.oclass = NVIF_IOCTL_NEW_V0_PERFDOM; 617 oclass->base.oclass = NVIF_CLASS_PERFDOM;
616 oclass->base.minver = 0; 618 oclass->base.minver = 0;
617 oclass->base.maxver = 0; 619 oclass->base.maxver = 0;
618 oclass->ctor = nvkm_perfmon_child_new; 620 oclass->ctor = nvkm_perfmon_child_new;
@@ -679,7 +681,7 @@ nvkm_pm_oclass_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
679 681
680static const struct nvkm_device_oclass 682static const struct nvkm_device_oclass
681nvkm_pm_oclass = { 683nvkm_pm_oclass = {
682 .base.oclass = NVIF_IOCTL_NEW_V0_PERFMON, 684 .base.oclass = NVIF_CLASS_PERFMON,
683 .base.minver = -1, 685 .base.minver = -1,
684 .base.maxver = -1, 686 .base.maxver = -1,
685 .ctor = nvkm_pm_oclass_new, 687 .ctor = nvkm_pm_oclass_new,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c b/drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c
index d082f4f73a80..f28967065639 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c
@@ -53,9 +53,9 @@ nvkm_sw_chan_event_ctor(struct nvkm_object *object, void *data, u32 size,
53 union { 53 union {
54 struct nvif_notify_uevent_req none; 54 struct nvif_notify_uevent_req none;
55 } *req = data; 55 } *req = data;
56 int ret; 56 int ret = -ENOSYS;
57 57
58 if (nvif_unvers(req->none)) { 58 if (!(ret = nvif_unvers(ret, &data, &size, req->none))) {
59 notify->size = sizeof(struct nvif_notify_uevent_rep); 59 notify->size = sizeof(struct nvif_notify_uevent_rep);
60 notify->types = 1; 60 notify->types = 1;
61 notify->index = 0; 61 notify->index = 0;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sw/gf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/sw/gf100.c
index b01ef7eca906..ea8f4247b628 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/sw/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sw/gf100.c
@@ -28,8 +28,8 @@
28#include <engine/disp.h> 28#include <engine/disp.h>
29#include <engine/fifo.h> 29#include <engine/fifo.h>
30 30
31#include <nvif/class.h>
31#include <nvif/event.h> 32#include <nvif/event.h>
32#include <nvif/ioctl.h>
33 33
34/******************************************************************************* 34/*******************************************************************************
35 * software context 35 * software context
@@ -143,7 +143,7 @@ static const struct nvkm_sw_func
143gf100_sw = { 143gf100_sw = {
144 .chan_new = gf100_sw_chan_new, 144 .chan_new = gf100_sw_chan_new,
145 .sclass = { 145 .sclass = {
146 { nvkm_nvsw_new, { -1, -1, NVIF_IOCTL_NEW_V0_SW_GF100 } }, 146 { nvkm_nvsw_new, { -1, -1, NVIF_CLASS_SW_GF100 } },
147 {} 147 {}
148 } 148 }
149}; 149};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv04.c b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv04.c
index 445217ffa791..b6675fe1b0ce 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv04.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv04.c
@@ -27,6 +27,7 @@
27#include "nvsw.h" 27#include "nvsw.h"
28 28
29#include <nvif/class.h> 29#include <nvif/class.h>
30#include <nvif/if0004.h>
30#include <nvif/ioctl.h> 31#include <nvif/ioctl.h>
31#include <nvif/unpack.h> 32#include <nvif/unpack.h>
32 33
@@ -46,9 +47,9 @@ nv04_nvsw_mthd_get_ref(struct nvkm_nvsw *nvsw, void *data, u32 size)
46 union { 47 union {
47 struct nv04_nvsw_get_ref_v0 v0; 48 struct nv04_nvsw_get_ref_v0 v0;
48 } *args = data; 49 } *args = data;
49 int ret; 50 int ret = -ENOSYS;
50 51
51 if (nvif_unpack(args->v0, 0, 0, false)) { 52 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
52 args->v0.ref = atomic_read(&chan->ref); 53 args->v0.ref = atomic_read(&chan->ref);
53 } 54 }
54 55
@@ -126,7 +127,7 @@ static const struct nvkm_sw_func
126nv04_sw = { 127nv04_sw = {
127 .chan_new = nv04_sw_chan_new, 128 .chan_new = nv04_sw_chan_new,
128 .sclass = { 129 .sclass = {
129 { nv04_nvsw_new, { -1, -1, NVIF_IOCTL_NEW_V0_SW_NV04 } }, 130 { nv04_nvsw_new, { -1, -1, NVIF_CLASS_SW_NV04 } },
130 {} 131 {}
131 } 132 }
132}; 133};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv10.c b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv10.c
index adf70d92b244..09d22fcd194c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv10.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv10.c
@@ -25,7 +25,7 @@
25#include "chan.h" 25#include "chan.h"
26#include "nvsw.h" 26#include "nvsw.h"
27 27
28#include <nvif/ioctl.h> 28#include <nvif/class.h>
29 29
30/******************************************************************************* 30/*******************************************************************************
31 * software context 31 * software context
@@ -56,7 +56,7 @@ static const struct nvkm_sw_func
56nv10_sw = { 56nv10_sw = {
57 .chan_new = nv10_sw_chan_new, 57 .chan_new = nv10_sw_chan_new,
58 .sclass = { 58 .sclass = {
59 { nvkm_nvsw_new, { -1, -1, NVIF_IOCTL_NEW_V0_SW_NV10 } }, 59 { nvkm_nvsw_new, { -1, -1, NVIF_CLASS_SW_NV10 } },
60 {} 60 {}
61 } 61 }
62}; 62};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv50.c
index a381196af69d..01573d187f2c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv50.c
@@ -28,8 +28,8 @@
28#include <engine/fifo/chan.h> 28#include <engine/fifo/chan.h>
29#include <subdev/bar.h> 29#include <subdev/bar.h>
30 30
31#include <nvif/class.h>
31#include <nvif/event.h> 32#include <nvif/event.h>
32#include <nvif/ioctl.h>
33 33
34/******************************************************************************* 34/*******************************************************************************
35 * software context 35 * software context
@@ -136,7 +136,7 @@ static const struct nvkm_sw_func
136nv50_sw = { 136nv50_sw = {
137 .chan_new = nv50_sw_chan_new, 137 .chan_new = nv50_sw_chan_new,
138 .sclass = { 138 .sclass = {
139 { nvkm_nvsw_new, { -1, -1, NVIF_IOCTL_NEW_V0_SW_NV50 } }, 139 { nvkm_nvsw_new, { -1, -1, NVIF_CLASS_SW_NV50 } },
140 {} 140 {}
141 } 141 }
142}; 142};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c
index 66cf986b9572..33dd03fff3c4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nvsw.c
@@ -24,7 +24,7 @@
24#include "nvsw.h" 24#include "nvsw.h"
25#include "chan.h" 25#include "chan.h"
26 26
27#include <nvif/class.h> 27#include <nvif/if0004.h>
28 28
29static int 29static int
30nvkm_nvsw_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size) 30nvkm_nvsw_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
@@ -41,7 +41,7 @@ nvkm_nvsw_ntfy_(struct nvkm_object *object, u32 mthd,
41{ 41{
42 struct nvkm_nvsw *nvsw = nvkm_nvsw(object); 42 struct nvkm_nvsw *nvsw = nvkm_nvsw(object);
43 switch (mthd) { 43 switch (mthd) {
44 case NVSW_NTFY_UEVENT: 44 case NV04_NVSW_NTFY_UEVENT:
45 *pevent = &nvsw->chan->event; 45 *pevent = &nvsw->chan->event;
46 return 0; 46 return 0;
47 default: 47 default:
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/dcb.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/dcb.c
index 8304b806f2a6..a8d5d67feeaf 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/dcb.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/dcb.c
@@ -143,16 +143,19 @@ dcb_outp_parse(struct nvkm_bios *bios, u8 idx, u8 *ver, u8 *len,
143 switch (outp->type) { 143 switch (outp->type) {
144 case DCB_OUTPUT_DP: 144 case DCB_OUTPUT_DP:
145 switch (conf & 0x00e00000) { 145 switch (conf & 0x00e00000) {
146 case 0x00000000: 146 case 0x00000000: /* 1.62 */
147 outp->dpconf.link_bw = 0x06; 147 outp->dpconf.link_bw = 0x06;
148 break; 148 break;
149 case 0x00200000: 149 case 0x00200000: /* 2.7 */
150 outp->dpconf.link_bw = 0x0a; 150 outp->dpconf.link_bw = 0x0a;
151 break; 151 break;
152 case 0x00400000: 152 case 0x00400000: /* 5.4 */
153 default:
154 outp->dpconf.link_bw = 0x14; 153 outp->dpconf.link_bw = 0x14;
155 break; 154 break;
155 case 0x00600000: /* 8.1 */
156 default:
157 outp->dpconf.link_bw = 0x1e;
158 break;
156 } 159 }
157 160
158 switch ((conf & 0x0f000000) >> 24) { 161 switch ((conf & 0x0f000000) >> 24) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/perf.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/perf.c
index aa7e33b42b30..636bfb665bb9 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/perf.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/perf.c
@@ -24,6 +24,7 @@
24#include <subdev/bios.h> 24#include <subdev/bios.h>
25#include <subdev/bios/bit.h> 25#include <subdev/bios/bit.h>
26#include <subdev/bios/perf.h> 26#include <subdev/bios/perf.h>
27#include <subdev/pci.h>
27 28
28u16 29u16
29nvbios_perf_table(struct nvkm_bios *bios, u8 *ver, u8 *hdr, 30nvbios_perf_table(struct nvkm_bios *bios, u8 *ver, u8 *hdr,
@@ -145,6 +146,21 @@ nvbios_perfEp(struct nvkm_bios *bios, int idx,
145 break; 146 break;
146 case 0x40: 147 case 0x40:
147 info->voltage = nvbios_rd08(bios, perf + 0x02); 148 info->voltage = nvbios_rd08(bios, perf + 0x02);
149 switch (nvbios_rd08(bios, perf + 0xb) & 0x3) {
150 case 0:
151 info->pcie_speed = NVKM_PCIE_SPEED_5_0;
152 break;
153 case 3:
154 case 1:
155 info->pcie_speed = NVKM_PCIE_SPEED_2_5;
156 break;
157 case 2:
158 info->pcie_speed = NVKM_PCIE_SPEED_8_0;
159 break;
160 default:
161 break;
162 }
163 info->pcie_width = 0xff;
148 break; 164 break;
149 default: 165 default:
150 return 0x0000; 166 return 0x0000;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
index dc8682c91cc7..889cce2eb727 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
@@ -176,6 +176,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
176{ 176{
177 struct nvkm_subdev *subdev = &clk->subdev; 177 struct nvkm_subdev *subdev = &clk->subdev;
178 struct nvkm_ram *ram = subdev->device->fb->ram; 178 struct nvkm_ram *ram = subdev->device->fb->ram;
179 struct nvkm_pci *pci = subdev->device->pci;
179 struct nvkm_pstate *pstate; 180 struct nvkm_pstate *pstate;
180 int ret, idx = 0; 181 int ret, idx = 0;
181 182
@@ -187,6 +188,8 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
187 nvkm_debug(subdev, "setting performance state %d\n", pstatei); 188 nvkm_debug(subdev, "setting performance state %d\n", pstatei);
188 clk->pstate = pstatei; 189 clk->pstate = pstatei;
189 190
191 nvkm_pcie_set_link(pci, pstate->pcie_speed, pstate->pcie_width);
192
190 if (ram && ram->func->calc) { 193 if (ram && ram->func->calc) {
191 int khz = pstate->base.domain[nv_clk_src_mem]; 194 int khz = pstate->base.domain[nv_clk_src_mem];
192 do { 195 do {
@@ -330,6 +333,8 @@ nvkm_pstate_new(struct nvkm_clk *clk, int idx)
330 333
331 pstate->pstate = perfE.pstate; 334 pstate->pstate = perfE.pstate;
332 pstate->fanspeed = perfE.fanspeed; 335 pstate->fanspeed = perfE.fanspeed;
336 pstate->pcie_speed = perfE.pcie_speed;
337 pstate->pcie_width = perfE.pcie_width;
333 cstate->voltage = perfE.voltage; 338 cstate->voltage = perfE.voltage;
334 cstate->domain[nv_clk_src_core] = perfE.core; 339 cstate->domain[nv_clk_src_core] = perfE.core;
335 cstate->domain[nv_clk_src_shader] = perfE.shader; 340 cstate->domain[nv_clk_src_shader] = perfE.shader;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gf100.c
index a52b7e7fce41..78c449b417b7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gf100.c
@@ -188,7 +188,7 @@ gf100_clk_read(struct nvkm_clk *base, enum nv_clk_src src)
188 return read_clk(clk, 0x08); 188 return read_clk(clk, 0x08);
189 case nv_clk_src_copy: 189 case nv_clk_src_copy:
190 return read_clk(clk, 0x09); 190 return read_clk(clk, 0x09);
191 case nv_clk_src_daemon: 191 case nv_clk_src_pmu:
192 return read_clk(clk, 0x0c); 192 return read_clk(clk, 0x0c);
193 case nv_clk_src_vdec: 193 case nv_clk_src_vdec:
194 return read_clk(clk, 0x0e); 194 return read_clk(clk, 0x0e);
@@ -325,7 +325,7 @@ gf100_clk_calc(struct nvkm_clk *base, struct nvkm_cstate *cstate)
325 (ret = calc_clk(clk, cstate, 0x07, nv_clk_src_hubk06)) || 325 (ret = calc_clk(clk, cstate, 0x07, nv_clk_src_hubk06)) ||
326 (ret = calc_clk(clk, cstate, 0x08, nv_clk_src_hubk01)) || 326 (ret = calc_clk(clk, cstate, 0x08, nv_clk_src_hubk01)) ||
327 (ret = calc_clk(clk, cstate, 0x09, nv_clk_src_copy)) || 327 (ret = calc_clk(clk, cstate, 0x09, nv_clk_src_copy)) ||
328 (ret = calc_clk(clk, cstate, 0x0c, nv_clk_src_daemon)) || 328 (ret = calc_clk(clk, cstate, 0x0c, nv_clk_src_pmu)) ||
329 (ret = calc_clk(clk, cstate, 0x0e, nv_clk_src_vdec))) 329 (ret = calc_clk(clk, cstate, 0x0e, nv_clk_src_vdec)))
330 return ret; 330 return ret;
331 331
@@ -447,7 +447,7 @@ gf100_clk = {
447 { nv_clk_src_rop , 0x04 }, 447 { nv_clk_src_rop , 0x04 },
448 { nv_clk_src_mem , 0x05, 0, "memory", 1000 }, 448 { nv_clk_src_mem , 0x05, 0, "memory", 1000 },
449 { nv_clk_src_vdec , 0x06 }, 449 { nv_clk_src_vdec , 0x06 },
450 { nv_clk_src_daemon , 0x0a }, 450 { nv_clk_src_pmu , 0x0a },
451 { nv_clk_src_hubk07 , 0x0b }, 451 { nv_clk_src_hubk07 , 0x0b },
452 { nv_clk_src_max } 452 { nv_clk_src_max }
453 } 453 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk104.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk104.c
index 396f7e4dad0a..975c401bccab 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk104.c
@@ -209,7 +209,7 @@ gk104_clk_read(struct nvkm_clk *base, enum nv_clk_src src)
209 return read_clk(clk, 0x07); 209 return read_clk(clk, 0x07);
210 case nv_clk_src_hubk01: 210 case nv_clk_src_hubk01:
211 return read_clk(clk, 0x08); 211 return read_clk(clk, 0x08);
212 case nv_clk_src_daemon: 212 case nv_clk_src_pmu:
213 return read_clk(clk, 0x0c); 213 return read_clk(clk, 0x0c);
214 case nv_clk_src_vdec: 214 case nv_clk_src_vdec:
215 return read_clk(clk, 0x0e); 215 return read_clk(clk, 0x0e);
@@ -346,7 +346,7 @@ gk104_clk_calc(struct nvkm_clk *base, struct nvkm_cstate *cstate)
346 (ret = calc_clk(clk, cstate, 0x02, nv_clk_src_hubk07)) || 346 (ret = calc_clk(clk, cstate, 0x02, nv_clk_src_hubk07)) ||
347 (ret = calc_clk(clk, cstate, 0x07, nv_clk_src_hubk06)) || 347 (ret = calc_clk(clk, cstate, 0x07, nv_clk_src_hubk06)) ||
348 (ret = calc_clk(clk, cstate, 0x08, nv_clk_src_hubk01)) || 348 (ret = calc_clk(clk, cstate, 0x08, nv_clk_src_hubk01)) ||
349 (ret = calc_clk(clk, cstate, 0x0c, nv_clk_src_daemon)) || 349 (ret = calc_clk(clk, cstate, 0x0c, nv_clk_src_pmu)) ||
350 (ret = calc_clk(clk, cstate, 0x0e, nv_clk_src_vdec))) 350 (ret = calc_clk(clk, cstate, 0x0e, nv_clk_src_vdec)))
351 return ret; 351 return ret;
352 352
@@ -492,7 +492,7 @@ gk104_clk = {
492 { nv_clk_src_hubk06 , 0x04, NVKM_CLK_DOM_FLAG_CORE }, 492 { nv_clk_src_hubk06 , 0x04, NVKM_CLK_DOM_FLAG_CORE },
493 { nv_clk_src_hubk01 , 0x05 }, 493 { nv_clk_src_hubk01 , 0x05 },
494 { nv_clk_src_vdec , 0x06 }, 494 { nv_clk_src_vdec , 0x06 },
495 { nv_clk_src_daemon , 0x07 }, 495 { nv_clk_src_pmu , 0x07 },
496 { nv_clk_src_max } 496 { nv_clk_src_max }
497 } 497 }
498}; 498};
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c
index c233e3f653ce..056702ef69aa 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c
@@ -158,7 +158,7 @@ gt215_clk_read(struct nvkm_clk *base, enum nv_clk_src src)
158 return read_clk(clk, 0x20, false); 158 return read_clk(clk, 0x20, false);
159 case nv_clk_src_vdec: 159 case nv_clk_src_vdec:
160 return read_clk(clk, 0x21, false); 160 return read_clk(clk, 0x21, false);
161 case nv_clk_src_daemon: 161 case nv_clk_src_pmu:
162 return read_clk(clk, 0x25, false); 162 return read_clk(clk, 0x25, false);
163 case nv_clk_src_host: 163 case nv_clk_src_host:
164 hsrc = (nvkm_rd32(device, 0xc040) & 0x30000000) >> 28; 164 hsrc = (nvkm_rd32(device, 0xc040) & 0x30000000) >> 28;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c
index f5edfadb5b46..1b5fb02eab2a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c
@@ -132,7 +132,7 @@ static const struct nvkm_enum vm_engine[] = {
132 { 0x0000000b, "PCOUNTER" }, 132 { 0x0000000b, "PCOUNTER" },
133 { 0x0000000c, "SEMAPHORE_BG" }, 133 { 0x0000000c, "SEMAPHORE_BG" },
134 { 0x0000000d, "PCE0" }, 134 { 0x0000000d, "PCE0" },
135 { 0x0000000e, "PDAEMON" }, 135 { 0x0000000e, "PMU" },
136 {} 136 {}
137}; 137};
138 138
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk104.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk104.c
index 9df45030ff9f..1fa3ade468ae 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk104.c
@@ -216,11 +216,11 @@ r1373f4_fini(struct gk104_ramfuc *fuc)
216 ram_wr32(fuc, 0x1373ec, tmp | (v1 << 16)); 216 ram_wr32(fuc, 0x1373ec, tmp | (v1 << 16));
217 ram_mask(fuc, 0x1373f0, (~ram->mode & 3), 0x00000000); 217 ram_mask(fuc, 0x1373f0, (~ram->mode & 3), 0x00000000);
218 if (ram->mode == 2) { 218 if (ram->mode == 2) {
219 ram_mask(fuc, 0x1373f4, 0x00000003, 0x000000002); 219 ram_mask(fuc, 0x1373f4, 0x00000003, 0x00000002);
220 ram_mask(fuc, 0x1373f4, 0x00001100, 0x000000000); 220 ram_mask(fuc, 0x1373f4, 0x00001100, 0x00000000);
221 } else { 221 } else {
222 ram_mask(fuc, 0x1373f4, 0x00000003, 0x000000001); 222 ram_mask(fuc, 0x1373f4, 0x00000003, 0x00000001);
223 ram_mask(fuc, 0x1373f4, 0x00010000, 0x000000000); 223 ram_mask(fuc, 0x1373f4, 0x00010000, 0x00000000);
224 } 224 }
225 ram_mask(fuc, 0x10f800, 0x00000030, (v0 ^ v1) << 4); 225 ram_mask(fuc, 0x10f800, 0x00000030, (v0 ^ v1) << 4);
226} 226}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/Kbuild
index de888fa62b3e..7e77a7466992 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/Kbuild
@@ -2,3 +2,4 @@ nvkm-y += nvkm/subdev/ibus/gf100.o
2nvkm-y += nvkm/subdev/ibus/gf117.o 2nvkm-y += nvkm/subdev/ibus/gf117.o
3nvkm-y += nvkm/subdev/ibus/gk104.o 3nvkm-y += nvkm/subdev/ibus/gk104.o
4nvkm-y += nvkm/subdev/ibus/gk20a.o 4nvkm-y += nvkm/subdev/ibus/gk20a.o
5nvkm-y += nvkm/subdev/ibus/gm204.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
index ba33609f643c..b5cee3f89aaa 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c
@@ -21,7 +21,7 @@
21 * 21 *
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24#include <subdev/ibus.h> 24#include "priv.h"
25 25
26static void 26static void
27gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i) 27gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -56,7 +56,7 @@ gk104_ibus_intr_gpc(struct nvkm_subdev *ibus, int i)
56 nvkm_mask(device, 0x128128 + (i * 0x0800), 0x00000200, 0x00000000); 56 nvkm_mask(device, 0x128128 + (i * 0x0800), 0x00000200, 0x00000000);
57} 57}
58 58
59static void 59void
60gk104_ibus_intr(struct nvkm_subdev *ibus) 60gk104_ibus_intr(struct nvkm_subdev *ibus)
61{ 61{
62 struct nvkm_device *device = ibus->device; 62 struct nvkm_device *device = ibus->device;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gm204.c b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gm204.c
new file mode 100644
index 000000000000..b3839dc254ee
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gm204.c
@@ -0,0 +1,40 @@
1/*
2 * Copyright 2015 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24#include "priv.h"
25
26static const struct nvkm_subdev_func
27gm204_ibus = {
28 .intr = gk104_ibus_intr,
29};
30
31int
32gm204_ibus_new(struct nvkm_device *device, int index,
33 struct nvkm_subdev **pibus)
34{
35 struct nvkm_subdev *ibus;
36 if (!(ibus = *pibus = kzalloc(sizeof(*ibus), GFP_KERNEL)))
37 return -ENOMEM;
38 nvkm_subdev_ctor(&gm204_ibus, device, index, 0, ibus);
39 return 0;
40}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/priv.h
index 48e1b6365ce6..01caf798cf31 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ibus/priv.h
@@ -4,4 +4,5 @@
4#include <subdev/ibus.h> 4#include <subdev/ibus.h>
5 5
6void gf100_ibus_intr(struct nvkm_subdev *); 6void gf100_ibus_intr(struct nvkm_subdev *);
7void gk104_ibus_intr(struct nvkm_subdev *);
7#endif 8#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
index 14107b5b7811..4c20fec64d96 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
@@ -56,7 +56,6 @@ struct gk20a_instobj {
56 56
57 /* CPU mapping */ 57 /* CPU mapping */
58 u32 *vaddr; 58 u32 *vaddr;
59 struct list_head vaddr_node;
60}; 59};
61#define gk20a_instobj(p) container_of((p), struct gk20a_instobj, memory) 60#define gk20a_instobj(p) container_of((p), struct gk20a_instobj, memory)
62 61
@@ -66,7 +65,6 @@ struct gk20a_instobj {
66struct gk20a_instobj_dma { 65struct gk20a_instobj_dma {
67 struct gk20a_instobj base; 66 struct gk20a_instobj base;
68 67
69 u32 *cpuaddr;
70 dma_addr_t handle; 68 dma_addr_t handle;
71 struct nvkm_mm_node r; 69 struct nvkm_mm_node r;
72}; 70};
@@ -79,6 +77,11 @@ struct gk20a_instobj_dma {
79struct gk20a_instobj_iommu { 77struct gk20a_instobj_iommu {
80 struct gk20a_instobj base; 78 struct gk20a_instobj base;
81 79
80 /* to link into gk20a_instmem::vaddr_lru */
81 struct list_head vaddr_node;
82 /* how many clients are using vaddr? */
83 u32 use_cpt;
84
82 /* will point to the higher half of pages */ 85 /* will point to the higher half of pages */
83 dma_addr_t *dma_addrs; 86 dma_addr_t *dma_addrs;
84 /* array of base.mem->size pages (+ dma_addr_ts) */ 87 /* array of base.mem->size pages (+ dma_addr_ts) */
@@ -107,8 +110,6 @@ struct gk20a_instmem {
107 110
108 /* Only used by DMA API */ 111 /* Only used by DMA API */
109 struct dma_attrs attrs; 112 struct dma_attrs attrs;
110
111 void __iomem * (*cpu_map)(struct nvkm_memory *);
112}; 113};
113#define gk20a_instmem(p) container_of((p), struct gk20a_instmem, base) 114#define gk20a_instmem(p) container_of((p), struct gk20a_instmem, base)
114 115
@@ -130,70 +131,58 @@ gk20a_instobj_size(struct nvkm_memory *memory)
130 return (u64)gk20a_instobj(memory)->mem.size << 12; 131 return (u64)gk20a_instobj(memory)->mem.size << 12;
131} 132}
132 133
133static void __iomem * 134/*
134gk20a_instobj_cpu_map_dma(struct nvkm_memory *memory) 135 * Recycle the vaddr of obj. Must be called with gk20a_instmem::lock held.
135{ 136 */
136#if defined(CONFIG_ARM) || defined(CONFIG_ARM64) 137static void
137 struct gk20a_instobj_dma *node = gk20a_instobj_dma(memory); 138gk20a_instobj_iommu_recycle_vaddr(struct gk20a_instobj_iommu *obj)
138 struct device *dev = node->base.imem->base.subdev.device->dev;
139 int npages = nvkm_memory_size(memory) >> 12;
140 struct page *pages[npages];
141 int i;
142
143 /* we shouldn't see a gk20a on anything but arm/arm64 anyways */
144 /* phys_to_page does not exist on all platforms... */
145 pages[0] = pfn_to_page(dma_to_phys(dev, node->handle) >> PAGE_SHIFT);
146 for (i = 1; i < npages; i++)
147 pages[i] = pages[0] + i;
148
149 return vmap(pages, npages, VM_MAP, pgprot_writecombine(PAGE_KERNEL));
150#else
151 BUG();
152 return NULL;
153#endif
154}
155
156static void __iomem *
157gk20a_instobj_cpu_map_iommu(struct nvkm_memory *memory)
158{ 139{
159 struct gk20a_instobj_iommu *node = gk20a_instobj_iommu(memory); 140 struct gk20a_instmem *imem = obj->base.imem;
160 int npages = nvkm_memory_size(memory) >> 12; 141 /* there should not be any user left... */
161 142 WARN_ON(obj->use_cpt);
162 return vmap(node->pages, npages, VM_MAP, 143 list_del(&obj->vaddr_node);
163 pgprot_writecombine(PAGE_KERNEL)); 144 vunmap(obj->base.vaddr);
145 obj->base.vaddr = NULL;
146 imem->vaddr_use -= nvkm_memory_size(&obj->base.memory);
147 nvkm_debug(&imem->base.subdev, "vaddr used: %x/%x\n", imem->vaddr_use,
148 imem->vaddr_max);
164} 149}
165 150
166/* 151/*
167 * Must be called while holding gk20a_instmem_lock 152 * Must be called while holding gk20a_instmem::lock
168 */ 153 */
169static void 154static void
170gk20a_instmem_vaddr_gc(struct gk20a_instmem *imem, const u64 size) 155gk20a_instmem_vaddr_gc(struct gk20a_instmem *imem, const u64 size)
171{ 156{
172 while (imem->vaddr_use + size > imem->vaddr_max) { 157 while (imem->vaddr_use + size > imem->vaddr_max) {
173 struct gk20a_instobj *obj;
174
175 /* no candidate that can be unmapped, abort... */ 158 /* no candidate that can be unmapped, abort... */
176 if (list_empty(&imem->vaddr_lru)) 159 if (list_empty(&imem->vaddr_lru))
177 break; 160 break;
178 161
179 obj = list_first_entry(&imem->vaddr_lru, struct gk20a_instobj, 162 gk20a_instobj_iommu_recycle_vaddr(
180 vaddr_node); 163 list_first_entry(&imem->vaddr_lru,
181 list_del(&obj->vaddr_node); 164 struct gk20a_instobj_iommu, vaddr_node));
182 vunmap(obj->vaddr);
183 obj->vaddr = NULL;
184 imem->vaddr_use -= nvkm_memory_size(&obj->memory);
185 nvkm_debug(&imem->base.subdev, "(GC) vaddr used: %x/%x\n",
186 imem->vaddr_use, imem->vaddr_max);
187
188 } 165 }
189} 166}
190 167
191static void __iomem * 168static void __iomem *
192gk20a_instobj_acquire(struct nvkm_memory *memory) 169gk20a_instobj_acquire_dma(struct nvkm_memory *memory)
193{ 170{
194 struct gk20a_instobj *node = gk20a_instobj(memory); 171 struct gk20a_instobj *node = gk20a_instobj(memory);
195 struct gk20a_instmem *imem = node->imem; 172 struct gk20a_instmem *imem = node->imem;
196 struct nvkm_ltc *ltc = imem->base.subdev.device->ltc; 173 struct nvkm_ltc *ltc = imem->base.subdev.device->ltc;
174
175 nvkm_ltc_flush(ltc);
176
177 return node->vaddr;
178}
179
180static void __iomem *
181gk20a_instobj_acquire_iommu(struct nvkm_memory *memory)
182{
183 struct gk20a_instobj_iommu *node = gk20a_instobj_iommu(memory);
184 struct gk20a_instmem *imem = node->base.imem;
185 struct nvkm_ltc *ltc = imem->base.subdev.device->ltc;
197 const u64 size = nvkm_memory_size(memory); 186 const u64 size = nvkm_memory_size(memory);
198 unsigned long flags; 187 unsigned long flags;
199 188
@@ -201,19 +190,21 @@ gk20a_instobj_acquire(struct nvkm_memory *memory)
201 190
202 spin_lock_irqsave(&imem->lock, flags); 191 spin_lock_irqsave(&imem->lock, flags);
203 192
204 if (node->vaddr) { 193 if (node->base.vaddr) {
205 /* remove us from the LRU list since we cannot be unmapped */ 194 if (!node->use_cpt) {
206 list_del(&node->vaddr_node); 195 /* remove from LRU list since mapping in use again */
207 196 list_del(&node->vaddr_node);
197 }
208 goto out; 198 goto out;
209 } 199 }
210 200
211 /* try to free some address space if we reached the limit */ 201 /* try to free some address space if we reached the limit */
212 gk20a_instmem_vaddr_gc(imem, size); 202 gk20a_instmem_vaddr_gc(imem, size);
213 203
214 node->vaddr = imem->cpu_map(memory); 204 /* map the pages */
215 205 node->base.vaddr = vmap(node->pages, size >> PAGE_SHIFT, VM_MAP,
216 if (!node->vaddr) { 206 pgprot_writecombine(PAGE_KERNEL));
207 if (!node->base.vaddr) {
217 nvkm_error(&imem->base.subdev, "cannot map instobj - " 208 nvkm_error(&imem->base.subdev, "cannot map instobj - "
218 "this is not going to end well...\n"); 209 "this is not going to end well...\n");
219 goto out; 210 goto out;
@@ -224,24 +215,41 @@ gk20a_instobj_acquire(struct nvkm_memory *memory)
224 imem->vaddr_use, imem->vaddr_max); 215 imem->vaddr_use, imem->vaddr_max);
225 216
226out: 217out:
218 node->use_cpt++;
227 spin_unlock_irqrestore(&imem->lock, flags); 219 spin_unlock_irqrestore(&imem->lock, flags);
228 220
229 return node->vaddr; 221 return node->base.vaddr;
230} 222}
231 223
232static void 224static void
233gk20a_instobj_release(struct nvkm_memory *memory) 225gk20a_instobj_release_dma(struct nvkm_memory *memory)
234{ 226{
235 struct gk20a_instobj *node = gk20a_instobj(memory); 227 struct gk20a_instobj *node = gk20a_instobj(memory);
236 struct gk20a_instmem *imem = node->imem; 228 struct gk20a_instmem *imem = node->imem;
237 struct nvkm_ltc *ltc = imem->base.subdev.device->ltc; 229 struct nvkm_ltc *ltc = imem->base.subdev.device->ltc;
230
231 nvkm_ltc_invalidate(ltc);
232}
233
234static void
235gk20a_instobj_release_iommu(struct nvkm_memory *memory)
236{
237 struct gk20a_instobj_iommu *node = gk20a_instobj_iommu(memory);
238 struct gk20a_instmem *imem = node->base.imem;
239 struct nvkm_ltc *ltc = imem->base.subdev.device->ltc;
238 unsigned long flags; 240 unsigned long flags;
239 241
240 spin_lock_irqsave(&imem->lock, flags); 242 spin_lock_irqsave(&imem->lock, flags);
241 243
242 /* add ourselves to the LRU list so our CPU mapping can be freed */ 244 /* we should at least have one user to release... */
243 list_add_tail(&node->vaddr_node, &imem->vaddr_lru); 245 if (WARN_ON(node->use_cpt == 0))
246 goto out;
247
248 /* add unused objs to the LRU list to recycle their mapping */
249 if (--node->use_cpt == 0)
250 list_add_tail(&node->vaddr_node, &imem->vaddr_lru);
244 251
252out:
245 spin_unlock_irqrestore(&imem->lock, flags); 253 spin_unlock_irqrestore(&imem->lock, flags);
246 254
247 wmb(); 255 wmb();
@@ -272,37 +280,6 @@ gk20a_instobj_map(struct nvkm_memory *memory, struct nvkm_vma *vma, u64 offset)
272 nvkm_vm_map_at(vma, offset, &node->mem); 280 nvkm_vm_map_at(vma, offset, &node->mem);
273} 281}
274 282
275/*
276 * Clear the CPU mapping of an instobj if it exists
277 */
278static void
279gk20a_instobj_dtor(struct gk20a_instobj *node)
280{
281 struct gk20a_instmem *imem = node->imem;
282 struct gk20a_instobj *obj;
283 unsigned long flags;
284
285 spin_lock_irqsave(&imem->lock, flags);
286
287 if (!node->vaddr)
288 goto out;
289
290 list_for_each_entry(obj, &imem->vaddr_lru, vaddr_node) {
291 if (obj == node) {
292 list_del(&obj->vaddr_node);
293 break;
294 }
295 }
296 vunmap(node->vaddr);
297 node->vaddr = NULL;
298 imem->vaddr_use -= nvkm_memory_size(&node->memory);
299 nvkm_debug(&imem->base.subdev, "vaddr used: %x/%x\n",
300 imem->vaddr_use, imem->vaddr_max);
301
302out:
303 spin_unlock_irqrestore(&imem->lock, flags);
304}
305
306static void * 283static void *
307gk20a_instobj_dtor_dma(struct nvkm_memory *memory) 284gk20a_instobj_dtor_dma(struct nvkm_memory *memory)
308{ 285{
@@ -310,12 +287,10 @@ gk20a_instobj_dtor_dma(struct nvkm_memory *memory)
310 struct gk20a_instmem *imem = node->base.imem; 287 struct gk20a_instmem *imem = node->base.imem;
311 struct device *dev = imem->base.subdev.device->dev; 288 struct device *dev = imem->base.subdev.device->dev;
312 289
313 gk20a_instobj_dtor(&node->base); 290 if (unlikely(!node->base.vaddr))
314
315 if (unlikely(!node->cpuaddr))
316 goto out; 291 goto out;
317 292
318 dma_free_attrs(dev, node->base.mem.size << PAGE_SHIFT, node->cpuaddr, 293 dma_free_attrs(dev, node->base.mem.size << PAGE_SHIFT, node->base.vaddr,
319 node->handle, &imem->attrs); 294 node->handle, &imem->attrs);
320 295
321out: 296out:
@@ -329,13 +304,20 @@ gk20a_instobj_dtor_iommu(struct nvkm_memory *memory)
329 struct gk20a_instmem *imem = node->base.imem; 304 struct gk20a_instmem *imem = node->base.imem;
330 struct device *dev = imem->base.subdev.device->dev; 305 struct device *dev = imem->base.subdev.device->dev;
331 struct nvkm_mm_node *r; 306 struct nvkm_mm_node *r;
307 unsigned long flags;
332 int i; 308 int i;
333 309
334 gk20a_instobj_dtor(&node->base);
335
336 if (unlikely(list_empty(&node->base.mem.regions))) 310 if (unlikely(list_empty(&node->base.mem.regions)))
337 goto out; 311 goto out;
338 312
313 spin_lock_irqsave(&imem->lock, flags);
314
315 /* vaddr has already been recycled */
316 if (node->base.vaddr)
317 gk20a_instobj_iommu_recycle_vaddr(node);
318
319 spin_unlock_irqrestore(&imem->lock, flags);
320
339 r = list_first_entry(&node->base.mem.regions, struct nvkm_mm_node, 321 r = list_first_entry(&node->base.mem.regions, struct nvkm_mm_node,
340 rl_entry); 322 rl_entry);
341 323
@@ -366,8 +348,8 @@ gk20a_instobj_func_dma = {
366 .target = gk20a_instobj_target, 348 .target = gk20a_instobj_target,
367 .addr = gk20a_instobj_addr, 349 .addr = gk20a_instobj_addr,
368 .size = gk20a_instobj_size, 350 .size = gk20a_instobj_size,
369 .acquire = gk20a_instobj_acquire, 351 .acquire = gk20a_instobj_acquire_dma,
370 .release = gk20a_instobj_release, 352 .release = gk20a_instobj_release_dma,
371 .rd32 = gk20a_instobj_rd32, 353 .rd32 = gk20a_instobj_rd32,
372 .wr32 = gk20a_instobj_wr32, 354 .wr32 = gk20a_instobj_wr32,
373 .map = gk20a_instobj_map, 355 .map = gk20a_instobj_map,
@@ -379,8 +361,8 @@ gk20a_instobj_func_iommu = {
379 .target = gk20a_instobj_target, 361 .target = gk20a_instobj_target,
380 .addr = gk20a_instobj_addr, 362 .addr = gk20a_instobj_addr,
381 .size = gk20a_instobj_size, 363 .size = gk20a_instobj_size,
382 .acquire = gk20a_instobj_acquire, 364 .acquire = gk20a_instobj_acquire_iommu,
383 .release = gk20a_instobj_release, 365 .release = gk20a_instobj_release_iommu,
384 .rd32 = gk20a_instobj_rd32, 366 .rd32 = gk20a_instobj_rd32,
385 .wr32 = gk20a_instobj_wr32, 367 .wr32 = gk20a_instobj_wr32,
386 .map = gk20a_instobj_map, 368 .map = gk20a_instobj_map,
@@ -400,10 +382,10 @@ gk20a_instobj_ctor_dma(struct gk20a_instmem *imem, u32 npages, u32 align,
400 382
401 nvkm_memory_ctor(&gk20a_instobj_func_dma, &node->base.memory); 383 nvkm_memory_ctor(&gk20a_instobj_func_dma, &node->base.memory);
402 384
403 node->cpuaddr = dma_alloc_attrs(dev, npages << PAGE_SHIFT, 385 node->base.vaddr = dma_alloc_attrs(dev, npages << PAGE_SHIFT,
404 &node->handle, GFP_KERNEL, 386 &node->handle, GFP_KERNEL,
405 &imem->attrs); 387 &imem->attrs);
406 if (!node->cpuaddr) { 388 if (!node->base.vaddr) {
407 nvkm_error(subdev, "cannot allocate DMA memory\n"); 389 nvkm_error(subdev, "cannot allocate DMA memory\n");
408 return -ENOMEM; 390 return -ENOMEM;
409 } 391 }
@@ -609,18 +591,14 @@ gk20a_instmem_new(struct nvkm_device *device, int index,
609 imem->mm = &tdev->iommu.mm; 591 imem->mm = &tdev->iommu.mm;
610 imem->domain = tdev->iommu.domain; 592 imem->domain = tdev->iommu.domain;
611 imem->iommu_pgshift = tdev->iommu.pgshift; 593 imem->iommu_pgshift = tdev->iommu.pgshift;
612 imem->cpu_map = gk20a_instobj_cpu_map_iommu;
613 imem->iommu_bit = tdev->func->iommu_bit; 594 imem->iommu_bit = tdev->func->iommu_bit;
614 595
615 nvkm_info(&imem->base.subdev, "using IOMMU\n"); 596 nvkm_info(&imem->base.subdev, "using IOMMU\n");
616 } else { 597 } else {
617 init_dma_attrs(&imem->attrs); 598 init_dma_attrs(&imem->attrs);
618 /* We will access the memory through our own mapping */
619 dma_set_attr(DMA_ATTR_NON_CONSISTENT, &imem->attrs); 599 dma_set_attr(DMA_ATTR_NON_CONSISTENT, &imem->attrs);
620 dma_set_attr(DMA_ATTR_WEAK_ORDERING, &imem->attrs); 600 dma_set_attr(DMA_ATTR_WEAK_ORDERING, &imem->attrs);
621 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &imem->attrs); 601 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &imem->attrs);
622 dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &imem->attrs);
623 imem->cpu_map = gk20a_instobj_cpu_map_dma;
624 602
625 nvkm_info(&imem->base.subdev, "using DMA API\n"); 603 nvkm_info(&imem->base.subdev, "using DMA API\n");
626 } 604 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/Kbuild
index e5df3d865f0c..f8108df3cb38 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/Kbuild
@@ -2,3 +2,4 @@ nvkm-y += nvkm/subdev/ltc/base.o
2nvkm-y += nvkm/subdev/ltc/gf100.o 2nvkm-y += nvkm/subdev/ltc/gf100.o
3nvkm-y += nvkm/subdev/ltc/gk104.o 3nvkm-y += nvkm/subdev/ltc/gk104.o
4nvkm-y += nvkm/subdev/ltc/gm107.o 4nvkm-y += nvkm/subdev/ltc/gm107.o
5nvkm-y += nvkm/subdev/ltc/gm204.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm107.c b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm107.c
index 3043bbfd7384..2af1f9e100fc 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm107.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm107.c
@@ -26,16 +26,16 @@
26#include <subdev/fb.h> 26#include <subdev/fb.h>
27#include <subdev/timer.h> 27#include <subdev/timer.h>
28 28
29static void 29void
30gm107_ltc_cbc_clear(struct nvkm_ltc *ltc, u32 start, u32 limit) 30gm107_ltc_cbc_clear(struct nvkm_ltc *ltc, u32 start, u32 limit)
31{ 31{
32 struct nvkm_device *device = ltc->subdev.device; 32 struct nvkm_device *device = ltc->subdev.device;
33 nvkm_wr32(device, 0x17e270, start); 33 nvkm_wr32(device, 0x17e270, start);
34 nvkm_wr32(device, 0x17e274, limit); 34 nvkm_wr32(device, 0x17e274, limit);
35 nvkm_wr32(device, 0x17e26c, 0x00000004); 35 nvkm_mask(device, 0x17e26c, 0x00000000, 0x00000004);
36} 36}
37 37
38static void 38void
39gm107_ltc_cbc_wait(struct nvkm_ltc *ltc) 39gm107_ltc_cbc_wait(struct nvkm_ltc *ltc)
40{ 40{
41 struct nvkm_device *device = ltc->subdev.device; 41 struct nvkm_device *device = ltc->subdev.device;
@@ -51,7 +51,7 @@ gm107_ltc_cbc_wait(struct nvkm_ltc *ltc)
51 } 51 }
52} 52}
53 53
54static void 54void
55gm107_ltc_zbc_clear_color(struct nvkm_ltc *ltc, int i, const u32 color[4]) 55gm107_ltc_zbc_clear_color(struct nvkm_ltc *ltc, int i, const u32 color[4])
56{ 56{
57 struct nvkm_device *device = ltc->subdev.device; 57 struct nvkm_device *device = ltc->subdev.device;
@@ -62,7 +62,7 @@ gm107_ltc_zbc_clear_color(struct nvkm_ltc *ltc, int i, const u32 color[4])
62 nvkm_wr32(device, 0x17e348, color[3]); 62 nvkm_wr32(device, 0x17e348, color[3]);
63} 63}
64 64
65static void 65void
66gm107_ltc_zbc_clear_depth(struct nvkm_ltc *ltc, int i, const u32 depth) 66gm107_ltc_zbc_clear_depth(struct nvkm_ltc *ltc, int i, const u32 depth)
67{ 67{
68 struct nvkm_device *device = ltc->subdev.device; 68 struct nvkm_device *device = ltc->subdev.device;
@@ -84,7 +84,7 @@ gm107_ltc_lts_isr(struct nvkm_ltc *ltc, int c, int s)
84 } 84 }
85} 85}
86 86
87static void 87void
88gm107_ltc_intr(struct nvkm_ltc *ltc) 88gm107_ltc_intr(struct nvkm_ltc *ltc)
89{ 89{
90 struct nvkm_device *device = ltc->subdev.device; 90 struct nvkm_device *device = ltc->subdev.device;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm204.c b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm204.c
new file mode 100644
index 000000000000..5ad6fb9d022d
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm204.c
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2015 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24#include "priv.h"
25
26#include <subdev/fb.h>
27#include <subdev/timer.h>
28
29static int
30gm204_ltc_oneinit(struct nvkm_ltc *ltc)
31{
32 struct nvkm_device *device = ltc->subdev.device;
33
34 ltc->ltc_nr = nvkm_rd32(device, 0x12006c);
35 ltc->lts_nr = nvkm_rd32(device, 0x17e280) >> 28;
36
37 return gf100_ltc_oneinit_tag_ram(ltc);
38}
39static void
40gm204_ltc_init(struct nvkm_ltc *ltc)
41{
42 nvkm_wr32(ltc->subdev.device, 0x17e278, ltc->tag_base);
43}
44
45static const struct nvkm_ltc_func
46gm204_ltc = {
47 .oneinit = gm204_ltc_oneinit,
48 .init = gm204_ltc_init,
49 .intr = gm107_ltc_intr, /*XXX: not validated */
50 .cbc_clear = gm107_ltc_cbc_clear,
51 .cbc_wait = gm107_ltc_cbc_wait,
52 .zbc = 16,
53 .zbc_clear_color = gm107_ltc_zbc_clear_color,
54 .zbc_clear_depth = gm107_ltc_zbc_clear_depth,
55 .invalidate = gf100_ltc_invalidate,
56 .flush = gf100_ltc_flush,
57};
58
59int
60gm204_ltc_new(struct nvkm_device *device, int index, struct nvkm_ltc **pltc)
61{
62 return nvkm_ltc_new_(&gm204_ltc, device, index, pltc);
63}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/priv.h
index 4e3755b82769..6d81c695ed0d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/priv.h
@@ -31,4 +31,10 @@ void gf100_ltc_zbc_clear_color(struct nvkm_ltc *, int, const u32[4]);
31void gf100_ltc_zbc_clear_depth(struct nvkm_ltc *, int, const u32); 31void gf100_ltc_zbc_clear_depth(struct nvkm_ltc *, int, const u32);
32void gf100_ltc_invalidate(struct nvkm_ltc *); 32void gf100_ltc_invalidate(struct nvkm_ltc *);
33void gf100_ltc_flush(struct nvkm_ltc *); 33void gf100_ltc_flush(struct nvkm_ltc *);
34
35void gm107_ltc_intr(struct nvkm_ltc *);
36void gm107_ltc_cbc_clear(struct nvkm_ltc *, u32, u32);
37void gm107_ltc_cbc_wait(struct nvkm_ltc *);
38void gm107_ltc_zbc_clear_color(struct nvkm_ltc *, int, const u32[4]);
39void gm107_ltc_zbc_clear_depth(struct nvkm_ltc *, int, const u32);
34#endif 40#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
index 4476ef75acd6..3c2519fdeb81 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
@@ -1,5 +1,6 @@
1nvkm-y += nvkm/subdev/pci/agp.o 1nvkm-y += nvkm/subdev/pci/agp.o
2nvkm-y += nvkm/subdev/pci/base.o 2nvkm-y += nvkm/subdev/pci/base.o
3nvkm-y += nvkm/subdev/pci/pcie.o
3nvkm-y += nvkm/subdev/pci/nv04.o 4nvkm-y += nvkm/subdev/pci/nv04.o
4nvkm-y += nvkm/subdev/pci/nv40.o 5nvkm-y += nvkm/subdev/pci/nv40.o
5nvkm-y += nvkm/subdev/pci/nv46.o 6nvkm-y += nvkm/subdev/pci/nv46.o
@@ -7,3 +8,5 @@ nvkm-y += nvkm/subdev/pci/nv4c.o
7nvkm-y += nvkm/subdev/pci/g84.o 8nvkm-y += nvkm/subdev/pci/g84.o
8nvkm-y += nvkm/subdev/pci/g94.o 9nvkm-y += nvkm/subdev/pci/g94.o
9nvkm-y += nvkm/subdev/pci/gf100.o 10nvkm-y += nvkm/subdev/pci/gf100.o
11nvkm-y += nvkm/subdev/pci/gf106.o
12nvkm-y += nvkm/subdev/pci/gk104.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c
index d671dcfaff3c..65057c8310a2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c
@@ -107,6 +107,15 @@ nvkm_pci_preinit(struct nvkm_subdev *subdev)
107} 107}
108 108
109static int 109static int
110nvkm_pci_oneinit(struct nvkm_subdev *subdev)
111{
112 struct nvkm_pci *pci = nvkm_pci(subdev);
113 if (pci_is_pcie(pci->pdev))
114 return nvkm_pcie_oneinit(pci);
115 return 0;
116}
117
118static int
110nvkm_pci_init(struct nvkm_subdev *subdev) 119nvkm_pci_init(struct nvkm_subdev *subdev)
111{ 120{
112 struct nvkm_pci *pci = nvkm_pci(subdev); 121 struct nvkm_pci *pci = nvkm_pci(subdev);
@@ -117,6 +126,8 @@ nvkm_pci_init(struct nvkm_subdev *subdev)
117 ret = nvkm_agp_init(pci); 126 ret = nvkm_agp_init(pci);
118 if (ret) 127 if (ret)
119 return ret; 128 return ret;
129 } else if (pci_is_pcie(pci->pdev)) {
130 nvkm_pcie_init(pci);
120 } 131 }
121 132
122 if (pci->func->init) 133 if (pci->func->init)
@@ -143,6 +154,7 @@ nvkm_pci_dtor(struct nvkm_subdev *subdev)
143static const struct nvkm_subdev_func 154static const struct nvkm_subdev_func
144nvkm_pci_func = { 155nvkm_pci_func = {
145 .dtor = nvkm_pci_dtor, 156 .dtor = nvkm_pci_dtor,
157 .oneinit = nvkm_pci_oneinit,
146 .preinit = nvkm_pci_preinit, 158 .preinit = nvkm_pci_preinit,
147 .init = nvkm_pci_init, 159 .init = nvkm_pci_init,
148 .fini = nvkm_pci_fini, 160 .fini = nvkm_pci_fini,
@@ -160,6 +172,8 @@ nvkm_pci_new_(const struct nvkm_pci_func *func, struct nvkm_device *device,
160 pci->func = func; 172 pci->func = func;
161 pci->pdev = device->func->pci(device)->pdev; 173 pci->pdev = device->func->pci(device)->pdev;
162 pci->irq = -1; 174 pci->irq = -1;
175 pci->pcie.speed = -1;
176 pci->pcie.width = -1;
163 177
164 if (device->type == NVKM_DEVICE_AGP) 178 if (device->type == NVKM_DEVICE_AGP)
165 nvkm_agp_ctor(pci); 179 nvkm_agp_ctor(pci);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/g84.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/g84.c
index 3faa6bfb895b..62438d892f42 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/g84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/g84.c
@@ -25,6 +25,80 @@
25 25
26#include <core/pci.h> 26#include <core/pci.h>
27 27
28static int
29g84_pcie_version_supported(struct nvkm_pci *pci)
30{
31 /* g84 and g86 report wrong information about what they support */
32 return 1;
33}
34
35int
36g84_pcie_version(struct nvkm_pci *pci)
37{
38 struct nvkm_device *device = pci->subdev.device;
39 return (nvkm_rd32(device, 0x00154c) & 0x1) + 1;
40}
41
42void
43g84_pcie_set_version(struct nvkm_pci *pci, u8 ver)
44{
45 struct nvkm_device *device = pci->subdev.device;
46 nvkm_mask(device, 0x00154c, 0x1, (ver >= 2 ? 0x1 : 0x0));
47}
48
49static void
50g84_pcie_set_cap_speed(struct nvkm_pci *pci, bool full_speed)
51{
52 struct nvkm_device *device = pci->subdev.device;
53 nvkm_mask(device, 0x00154c, 0x80, full_speed ? 0x80 : 0x0);
54}
55
56enum nvkm_pcie_speed
57g84_pcie_cur_speed(struct nvkm_pci *pci)
58{
59 u32 reg_v = nvkm_pci_rd32(pci, 0x88) & 0x30000;
60 switch (reg_v) {
61 case 0x30000:
62 return NVKM_PCIE_SPEED_8_0;
63 case 0x20000:
64 return NVKM_PCIE_SPEED_5_0;
65 case 0x10000:
66 default:
67 return NVKM_PCIE_SPEED_2_5;
68 }
69}
70
71enum nvkm_pcie_speed
72g84_pcie_max_speed(struct nvkm_pci *pci)
73{
74 u32 reg_v = nvkm_pci_rd32(pci, 0x460) & 0x3300;
75 if (reg_v == 0x2200)
76 return NVKM_PCIE_SPEED_5_0;
77 return NVKM_PCIE_SPEED_2_5;
78}
79
80void
81g84_pcie_set_link_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
82{
83 u32 mask_value;
84
85 if (speed == NVKM_PCIE_SPEED_5_0)
86 mask_value = 0x20;
87 else
88 mask_value = 0x10;
89
90 nvkm_pci_mask(pci, 0x460, 0x30, mask_value);
91 nvkm_pci_mask(pci, 0x460, 0x1, 0x1);
92}
93
94int
95g84_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width)
96{
97 g84_pcie_set_cap_speed(pci, speed == NVKM_PCIE_SPEED_5_0);
98 g84_pcie_set_link_speed(pci, speed);
99 return 0;
100}
101
28void 102void
29g84_pci_init(struct nvkm_pci *pci) 103g84_pci_init(struct nvkm_pci *pci)
30{ 104{
@@ -48,6 +122,14 @@ g84_pci_init(struct nvkm_pci *pci)
48 nvkm_pci_mask(pci, 0x041c, 0x00000060, 0x00000000); 122 nvkm_pci_mask(pci, 0x041c, 0x00000060, 0x00000000);
49} 123}
50 124
125int
126g84_pcie_init(struct nvkm_pci *pci)
127{
128 bool full_speed = g84_pcie_cur_speed(pci) == NVKM_PCIE_SPEED_5_0;
129 g84_pcie_set_cap_speed(pci, full_speed);
130 return 0;
131}
132
51static const struct nvkm_pci_func 133static const struct nvkm_pci_func
52g84_pci_func = { 134g84_pci_func = {
53 .init = g84_pci_init, 135 .init = g84_pci_init,
@@ -55,6 +137,16 @@ g84_pci_func = {
55 .wr08 = nv40_pci_wr08, 137 .wr08 = nv40_pci_wr08,
56 .wr32 = nv40_pci_wr32, 138 .wr32 = nv40_pci_wr32,
57 .msi_rearm = nv46_pci_msi_rearm, 139 .msi_rearm = nv46_pci_msi_rearm,
140
141 .pcie.init = g84_pcie_init,
142 .pcie.set_link = g84_pcie_set_link,
143
144 .pcie.max_speed = g84_pcie_max_speed,
145 .pcie.cur_speed = g84_pcie_cur_speed,
146
147 .pcie.set_version = g84_pcie_set_version,
148 .pcie.version = g84_pcie_version,
149 .pcie.version_supported = g84_pcie_version_supported,
58}; 150};
59 151
60int 152int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/g94.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/g94.c
index cd311ee311cc..43444123bc04 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/g94.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/g94.c
@@ -23,6 +23,14 @@
23 */ 23 */
24#include "priv.h" 24#include "priv.h"
25 25
26int
27g94_pcie_version_supported(struct nvkm_pci *pci)
28{
29 if ((nvkm_pci_rd32(pci, 0x460) & 0x200) == 0x200)
30 return 2;
31 return 1;
32}
33
26static const struct nvkm_pci_func 34static const struct nvkm_pci_func
27g94_pci_func = { 35g94_pci_func = {
28 .init = g84_pci_init, 36 .init = g84_pci_init,
@@ -30,6 +38,16 @@ g94_pci_func = {
30 .wr08 = nv40_pci_wr08, 38 .wr08 = nv40_pci_wr08,
31 .wr32 = nv40_pci_wr32, 39 .wr32 = nv40_pci_wr32,
32 .msi_rearm = nv40_pci_msi_rearm, 40 .msi_rearm = nv40_pci_msi_rearm,
41
42 .pcie.init = g84_pcie_init,
43 .pcie.set_link = g84_pcie_set_link,
44
45 .pcie.max_speed = g84_pcie_max_speed,
46 .pcie.cur_speed = g84_pcie_cur_speed,
47
48 .pcie.set_version = g84_pcie_set_version,
49 .pcie.version = g84_pcie_version,
50 .pcie.version_supported = g94_pcie_version_supported,
33}; 51};
34 52
35int 53int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/gf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/gf100.c
index 25e1ae70867f..e30ea676baf6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/gf100.c
@@ -29,6 +29,53 @@ gf100_pci_msi_rearm(struct nvkm_pci *pci)
29 nvkm_pci_wr08(pci, 0x0704, 0xff); 29 nvkm_pci_wr08(pci, 0x0704, 0xff);
30} 30}
31 31
32void
33gf100_pcie_set_version(struct nvkm_pci *pci, u8 ver)
34{
35 struct nvkm_device *device = pci->subdev.device;
36 nvkm_mask(device, 0x02241c, 0x1, ver > 1 ? 1 : 0);
37}
38
39int
40gf100_pcie_version(struct nvkm_pci *pci)
41{
42 struct nvkm_device *device = pci->subdev.device;
43 return (nvkm_rd32(device, 0x02241c) & 0x1) + 1;
44}
45
46void
47gf100_pcie_set_cap_speed(struct nvkm_pci *pci, bool full_speed)
48{
49 struct nvkm_device *device = pci->subdev.device;
50 nvkm_mask(device, 0x02241c, 0x80, full_speed ? 0x80 : 0x0);
51}
52
53int
54gf100_pcie_cap_speed(struct nvkm_pci *pci)
55{
56 struct nvkm_device *device = pci->subdev.device;
57 u8 punits_pci_cap_speed = nvkm_rd32(device, 0x02241c) & 0x80;
58 if (punits_pci_cap_speed == 0x80)
59 return 1;
60 return 0;
61}
62
63int
64gf100_pcie_init(struct nvkm_pci *pci)
65{
66 bool full_speed = g84_pcie_cur_speed(pci) == NVKM_PCIE_SPEED_5_0;
67 gf100_pcie_set_cap_speed(pci, full_speed);
68 return 0;
69}
70
71int
72gf100_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width)
73{
74 gf100_pcie_set_cap_speed(pci, speed == NVKM_PCIE_SPEED_5_0);
75 g84_pcie_set_link_speed(pci, speed);
76 return 0;
77}
78
32static const struct nvkm_pci_func 79static const struct nvkm_pci_func
33gf100_pci_func = { 80gf100_pci_func = {
34 .init = g84_pci_init, 81 .init = g84_pci_init,
@@ -36,6 +83,16 @@ gf100_pci_func = {
36 .wr08 = nv40_pci_wr08, 83 .wr08 = nv40_pci_wr08,
37 .wr32 = nv40_pci_wr32, 84 .wr32 = nv40_pci_wr32,
38 .msi_rearm = gf100_pci_msi_rearm, 85 .msi_rearm = gf100_pci_msi_rearm,
86
87 .pcie.init = gf100_pcie_init,
88 .pcie.set_link = gf100_pcie_set_link,
89
90 .pcie.max_speed = g84_pcie_max_speed,
91 .pcie.cur_speed = g84_pcie_cur_speed,
92
93 .pcie.set_version = gf100_pcie_set_version,
94 .pcie.version = gf100_pcie_version,
95 .pcie.version_supported = g94_pcie_version_supported,
39}; 96};
40 97
41int 98int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/gf106.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/gf106.c
new file mode 100644
index 000000000000..c3b798c5c6dd
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/gf106.c
@@ -0,0 +1,49 @@
1/*
2 * Copyright 2015 Karol Herbst <nouveau@karolherbst.de>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Karol Herbst <nouveau@karolherbst.de>
23 */
24#include "priv.h"
25
26static const struct nvkm_pci_func
27gf106_pci_func = {
28 .init = g84_pci_init,
29 .rd32 = nv40_pci_rd32,
30 .wr08 = nv40_pci_wr08,
31 .wr32 = nv40_pci_wr32,
32 .msi_rearm = nv40_pci_msi_rearm,
33
34 .pcie.init = gf100_pcie_init,
35 .pcie.set_link = gf100_pcie_set_link,
36
37 .pcie.max_speed = g84_pcie_max_speed,
38 .pcie.cur_speed = g84_pcie_cur_speed,
39
40 .pcie.set_version = gf100_pcie_set_version,
41 .pcie.version = gf100_pcie_version,
42 .pcie.version_supported = g94_pcie_version_supported,
43};
44
45int
46gf106_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
47{
48 return nvkm_pci_new_(&gf106_pci_func, device, index, ppci);
49}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/gk104.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/gk104.c
new file mode 100644
index 000000000000..e68030507d88
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/gk104.c
@@ -0,0 +1,228 @@
1/*
2 * Copyright 2015 Karol Herbst <nouveau@karolherbst.de>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Karol Herbst <nouveau@karolherbst.de>
23 */
24#include "priv.h"
25
26static int
27gk104_pcie_version_supported(struct nvkm_pci *pci)
28{
29 return (nvkm_rd32(pci->subdev.device, 0x8c1c0) & 0x4) == 0x4 ? 2 : 1;
30}
31
32static void
33gk104_pcie_set_cap_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
34{
35 struct nvkm_device *device = pci->subdev.device;
36
37 switch (speed) {
38 case NVKM_PCIE_SPEED_2_5:
39 gf100_pcie_set_cap_speed(pci, false);
40 nvkm_mask(device, 0x8c1c0, 0x30000, 0x10000);
41 break;
42 case NVKM_PCIE_SPEED_5_0:
43 gf100_pcie_set_cap_speed(pci, true);
44 nvkm_mask(device, 0x8c1c0, 0x30000, 0x20000);
45 break;
46 case NVKM_PCIE_SPEED_8_0:
47 gf100_pcie_set_cap_speed(pci, true);
48 nvkm_mask(device, 0x8c1c0, 0x30000, 0x30000);
49 break;
50 }
51}
52
53static enum nvkm_pcie_speed
54gk104_pcie_cap_speed(struct nvkm_pci *pci)
55{
56 int speed = gf100_pcie_cap_speed(pci);
57
58 if (speed == 0)
59 return NVKM_PCIE_SPEED_2_5;
60
61 if (speed >= 1) {
62 int speed2 = nvkm_rd32(pci->subdev.device, 0x8c1c0) & 0x30000;
63 switch (speed2) {
64 case 0x00000:
65 case 0x10000:
66 return NVKM_PCIE_SPEED_2_5;
67 case 0x20000:
68 return NVKM_PCIE_SPEED_5_0;
69 case 0x30000:
70 return NVKM_PCIE_SPEED_8_0;
71 }
72 }
73
74 return -EINVAL;
75}
76
77static void
78gk104_pcie_set_lnkctl_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
79{
80 u8 reg_v = 0;
81 switch (speed) {
82 case NVKM_PCIE_SPEED_2_5:
83 reg_v = 1;
84 break;
85 case NVKM_PCIE_SPEED_5_0:
86 reg_v = 2;
87 break;
88 case NVKM_PCIE_SPEED_8_0:
89 reg_v = 3;
90 break;
91 }
92 nvkm_pci_mask(pci, 0xa8, 0x3, reg_v);
93}
94
95static enum nvkm_pcie_speed
96gk104_pcie_lnkctl_speed(struct nvkm_pci *pci)
97{
98 u8 reg_v = nvkm_pci_rd32(pci, 0xa8) & 0x3;
99 switch (reg_v) {
100 case 0:
101 case 1:
102 return NVKM_PCIE_SPEED_2_5;
103 case 2:
104 return NVKM_PCIE_SPEED_5_0;
105 case 3:
106 return NVKM_PCIE_SPEED_8_0;
107 }
108 return -1;
109}
110
111static enum nvkm_pcie_speed
112gk104_pcie_max_speed(struct nvkm_pci *pci)
113{
114 u32 max_speed = nvkm_rd32(pci->subdev.device, 0x8c1c0) & 0x300000;
115 switch (max_speed) {
116 case 0x000000:
117 return NVKM_PCIE_SPEED_8_0;
118 case 0x100000:
119 return NVKM_PCIE_SPEED_5_0;
120 case 0x200000:
121 return NVKM_PCIE_SPEED_2_5;
122 }
123 return NVKM_PCIE_SPEED_2_5;
124}
125
126static void
127gk104_pcie_set_link_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
128{
129 struct nvkm_device *device = pci->subdev.device;
130 u32 mask_value;
131
132 switch (speed) {
133 case NVKM_PCIE_SPEED_8_0:
134 mask_value = 0x00000;
135 break;
136 case NVKM_PCIE_SPEED_5_0:
137 mask_value = 0x40000;
138 break;
139 case NVKM_PCIE_SPEED_2_5:
140 default:
141 mask_value = 0x80000;
142 break;
143 }
144
145 nvkm_mask(device, 0x8c040, 0xc0000, mask_value);
146 nvkm_mask(device, 0x8c040, 0x1, 0x1);
147}
148
149static int
150gk104_pcie_init(struct nvkm_pci * pci)
151{
152 enum nvkm_pcie_speed lnkctl_speed, max_speed, cap_speed;
153 struct nvkm_subdev *subdev = &pci->subdev;
154
155 if (gf100_pcie_version(pci) < 2)
156 return 0;
157
158 lnkctl_speed = gk104_pcie_lnkctl_speed(pci);
159 max_speed = gk104_pcie_max_speed(pci);
160 cap_speed = gk104_pcie_cap_speed(pci);
161
162 if (cap_speed != max_speed) {
163 nvkm_trace(subdev, "adjusting cap to max speed\n");
164 gk104_pcie_set_cap_speed(pci, max_speed);
165 cap_speed = gk104_pcie_cap_speed(pci);
166 if (cap_speed != max_speed)
167 nvkm_warn(subdev, "failed to adjust cap speed\n");
168 }
169
170 if (lnkctl_speed != max_speed) {
171 nvkm_debug(subdev, "adjusting lnkctl to max speed\n");
172 gk104_pcie_set_lnkctl_speed(pci, max_speed);
173 lnkctl_speed = gk104_pcie_lnkctl_speed(pci);
174 if (lnkctl_speed != max_speed)
175 nvkm_error(subdev, "failed to adjust lnkctl speed\n");
176 }
177
178 return 0;
179}
180
181static int
182gk104_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width)
183{
184 struct nvkm_subdev *subdev = &pci->subdev;
185 enum nvkm_pcie_speed lnk_ctl_speed = gk104_pcie_lnkctl_speed(pci);
186 enum nvkm_pcie_speed lnk_cap_speed = gk104_pcie_cap_speed(pci);
187
188 if (speed > lnk_cap_speed) {
189 speed = lnk_cap_speed;
190 nvkm_warn(subdev, "dropping requested speed due too low cap"
191 " speed\n");
192 }
193
194 if (speed > lnk_ctl_speed) {
195 speed = lnk_ctl_speed;
196 nvkm_warn(subdev, "dropping requested speed due too low"
197 " lnkctl speed\n");
198 }
199
200 gk104_pcie_set_link_speed(pci, speed);
201 return 0;
202}
203
204
205static const struct nvkm_pci_func
206gk104_pci_func = {
207 .init = g84_pci_init,
208 .rd32 = nv40_pci_rd32,
209 .wr08 = nv40_pci_wr08,
210 .wr32 = nv40_pci_wr32,
211 .msi_rearm = nv40_pci_msi_rearm,
212
213 .pcie.init = gk104_pcie_init,
214 .pcie.set_link = gk104_pcie_set_link,
215
216 .pcie.max_speed = gk104_pcie_max_speed,
217 .pcie.cur_speed = g84_pcie_cur_speed,
218
219 .pcie.set_version = gf100_pcie_set_version,
220 .pcie.version = gf100_pcie_version,
221 .pcie.version_supported = gk104_pcie_version_supported,
222};
223
224int
225gk104_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
226{
227 return nvkm_pci_new_(&gk104_pci_func, device, index, ppci);
228}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/pcie.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/pcie.c
new file mode 100644
index 000000000000..d71e5db5028a
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/pcie.c
@@ -0,0 +1,165 @@
1/*
2 * Copyright 2015 Karol Herbst <nouveau@karolherbst.de>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Karol Herbst <git@karolherbst.de>
23 */
24#include "priv.h"
25
26static char *nvkm_pcie_speeds[] = {
27 "2.5GT/s",
28 "5.0GT/s",
29 "8.0GT/s",
30};
31
32static enum nvkm_pcie_speed
33nvkm_pcie_speed(enum pci_bus_speed speed)
34{
35 switch (speed) {
36 case PCIE_SPEED_2_5GT:
37 return NVKM_PCIE_SPEED_2_5;
38 case PCIE_SPEED_5_0GT:
39 return NVKM_PCIE_SPEED_5_0;
40 case PCIE_SPEED_8_0GT:
41 return NVKM_PCIE_SPEED_8_0;
42 default:
43 /* XXX 0x16 is 8_0, assume 0x17 will be 16_0 for now */
44 if (speed == 0x17)
45 return NVKM_PCIE_SPEED_8_0;
46 return -1;
47 }
48}
49
50static int
51nvkm_pcie_get_version(struct nvkm_pci *pci)
52{
53 if (!pci->func->pcie.version)
54 return -ENOSYS;
55
56 return pci->func->pcie.version(pci);
57}
58
59static int
60nvkm_pcie_get_max_version(struct nvkm_pci *pci)
61{
62 if (!pci->func->pcie.version_supported)
63 return -ENOSYS;
64
65 return pci->func->pcie.version_supported(pci);
66}
67
68static int
69nvkm_pcie_set_version(struct nvkm_pci *pci, int version)
70{
71 if (!pci->func->pcie.set_version)
72 return -ENOSYS;
73
74 nvkm_trace(&pci->subdev, "set to version %i\n", version);
75 pci->func->pcie.set_version(pci, version);
76 return nvkm_pcie_get_version(pci);
77}
78
79int
80nvkm_pcie_oneinit(struct nvkm_pci *pci)
81{
82 if (pci->func->pcie.max_speed)
83 nvkm_debug(&pci->subdev, "pcie max speed: %s\n",
84 nvkm_pcie_speeds[pci->func->pcie.max_speed(pci)]);
85 return 0;
86}
87
88int
89nvkm_pcie_init(struct nvkm_pci *pci)
90{
91 struct nvkm_subdev *subdev = &pci->subdev;
92 int ret;
93
94 /* raise pcie version first */
95 ret = nvkm_pcie_get_version(pci);
96 if (ret > 0) {
97 int max_version = nvkm_pcie_get_max_version(pci);
98 if (max_version > 0 && max_version > ret)
99 ret = nvkm_pcie_set_version(pci, max_version);
100
101 if (ret < max_version)
102 nvkm_error(subdev, "couldn't raise version: %i\n", ret);
103 }
104
105 if (pci->func->pcie.init)
106 pci->func->pcie.init(pci);
107
108 if (pci->pcie.speed != -1)
109 nvkm_pcie_set_link(pci, pci->pcie.speed, pci->pcie.width);
110
111 return 0;
112}
113
114int
115nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width)
116{
117 struct nvkm_subdev *subdev = &pci->subdev;
118 enum nvkm_pcie_speed cur_speed, max_speed;
119 struct pci_bus *pbus;
120 int ret;
121
122 if (!pci || !pci_is_pcie(pci->pdev))
123 return 0;
124 pbus = pci->pdev->bus;
125
126 if (!pci->func->pcie.set_link)
127 return -ENOSYS;
128
129 nvkm_trace(subdev, "requested %s\n", nvkm_pcie_speeds[speed]);
130
131 if (pci->func->pcie.version(pci) < 2) {
132 nvkm_error(subdev, "setting link failed due to low version\n");
133 return -ENODEV;
134 }
135
136 cur_speed = pci->func->pcie.cur_speed(pci);
137 max_speed = min(nvkm_pcie_speed(pbus->max_bus_speed),
138 pci->func->pcie.max_speed(pci));
139
140 nvkm_trace(subdev, "current speed: %s\n", nvkm_pcie_speeds[cur_speed]);
141
142 if (speed > max_speed) {
143 nvkm_debug(subdev, "%s not supported by bus or card, dropping"
144 "requested speed to %s", nvkm_pcie_speeds[speed],
145 nvkm_pcie_speeds[max_speed]);
146 speed = max_speed;
147 }
148
149 pci->pcie.speed = speed;
150 pci->pcie.width = width;
151
152 if (speed == cur_speed) {
153 nvkm_debug(subdev, "requested matches current speed\n");
154 return speed;
155 }
156
157 nvkm_debug(subdev, "set link to %s x%i\n",
158 nvkm_pcie_speeds[speed], width);
159
160 ret = pci->func->pcie.set_link(pci, speed, width);
161 if (ret < 0)
162 nvkm_error(subdev, "setting link failed: %i\n", ret);
163
164 return ret;
165}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/priv.h
index cf46d38d0b0a..23de3180aae5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/priv.h
@@ -12,6 +12,18 @@ struct nvkm_pci_func {
12 void (*wr08)(struct nvkm_pci *, u16 addr, u8 data); 12 void (*wr08)(struct nvkm_pci *, u16 addr, u8 data);
13 void (*wr32)(struct nvkm_pci *, u16 addr, u32 data); 13 void (*wr32)(struct nvkm_pci *, u16 addr, u32 data);
14 void (*msi_rearm)(struct nvkm_pci *); 14 void (*msi_rearm)(struct nvkm_pci *);
15
16 struct {
17 int (*init)(struct nvkm_pci *);
18 int (*set_link)(struct nvkm_pci *, enum nvkm_pcie_speed, u8);
19
20 enum nvkm_pcie_speed (*max_speed)(struct nvkm_pci *);
21 enum nvkm_pcie_speed (*cur_speed)(struct nvkm_pci *);
22
23 void (*set_version)(struct nvkm_pci *, u8);
24 int (*version)(struct nvkm_pci *);
25 int (*version_supported)(struct nvkm_pci *);
26 } pcie;
15}; 27};
16 28
17u32 nv40_pci_rd32(struct nvkm_pci *, u16); 29u32 nv40_pci_rd32(struct nvkm_pci *, u16);
@@ -22,4 +34,25 @@ void nv40_pci_msi_rearm(struct nvkm_pci *);
22void nv46_pci_msi_rearm(struct nvkm_pci *); 34void nv46_pci_msi_rearm(struct nvkm_pci *);
23 35
24void g84_pci_init(struct nvkm_pci *pci); 36void g84_pci_init(struct nvkm_pci *pci);
37
38/* pcie functions */
39void g84_pcie_set_version(struct nvkm_pci *, u8);
40int g84_pcie_version(struct nvkm_pci *);
41void g84_pcie_set_link_speed(struct nvkm_pci *, enum nvkm_pcie_speed);
42enum nvkm_pcie_speed g84_pcie_cur_speed(struct nvkm_pci *);
43enum nvkm_pcie_speed g84_pcie_max_speed(struct nvkm_pci *);
44int g84_pcie_init(struct nvkm_pci *);
45int g84_pcie_set_link(struct nvkm_pci *, enum nvkm_pcie_speed, u8);
46
47int g94_pcie_version_supported(struct nvkm_pci *);
48
49void gf100_pcie_set_version(struct nvkm_pci *, u8);
50int gf100_pcie_version(struct nvkm_pci *);
51void gf100_pcie_set_cap_speed(struct nvkm_pci *, bool);
52int gf100_pcie_cap_speed(struct nvkm_pci *);
53int gf100_pcie_init(struct nvkm_pci *);
54int gf100_pcie_set_link(struct nvkm_pci *, enum nvkm_pcie_speed, u8);
55
56int nvkm_pcie_oneinit(struct nvkm_pci *);
57int nvkm_pcie_init(struct nvkm_pci *);
25#endif 58#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf100.fuc3.h b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf100.fuc3.h
index 302557c52d03..770294457274 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf100.fuc3.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf100.fuc3.h
@@ -24,8 +24,8 @@ uint32_t gf100_pmu_data[] = {
24 0x00000000, 24 0x00000000,
25/* 0x0058: proc_list_head */ 25/* 0x0058: proc_list_head */
26 0x54534f48, 26 0x54534f48,
27 0x00000512, 27 0x00000507,
28 0x000004af, 28 0x000004a4,
29 0x00000000, 29 0x00000000,
30 0x00000000, 30 0x00000000,
31 0x00000000, 31 0x00000000,
@@ -46,8 +46,8 @@ uint32_t gf100_pmu_data[] = {
46 0x00000000, 46 0x00000000,
47 0x00000000, 47 0x00000000,
48 0x584d454d, 48 0x584d454d,
49 0x0000075e, 49 0x00000753,
50 0x00000750, 50 0x00000745,
51 0x00000000, 51 0x00000000,
52 0x00000000, 52 0x00000000,
53 0x00000000, 53 0x00000000,
@@ -68,8 +68,8 @@ uint32_t gf100_pmu_data[] = {
68 0x00000000, 68 0x00000000,
69 0x00000000, 69 0x00000000,
70 0x46524550, 70 0x46524550,
71 0x00000762, 71 0x00000757,
72 0x00000760, 72 0x00000755,
73 0x00000000, 73 0x00000000,
74 0x00000000, 74 0x00000000,
75 0x00000000, 75 0x00000000,
@@ -90,8 +90,8 @@ uint32_t gf100_pmu_data[] = {
90 0x00000000, 90 0x00000000,
91 0x00000000, 91 0x00000000,
92 0x5f433249, 92 0x5f433249,
93 0x00000b92, 93 0x00000b87,
94 0x00000a35, 94 0x00000a2a,
95 0x00000000, 95 0x00000000,
96 0x00000000, 96 0x00000000,
97 0x00000000, 97 0x00000000,
@@ -112,8 +112,8 @@ uint32_t gf100_pmu_data[] = {
112 0x00000000, 112 0x00000000,
113 0x00000000, 113 0x00000000,
114 0x54534554, 114 0x54534554,
115 0x00000bbb, 115 0x00000bb0,
116 0x00000b94, 116 0x00000b89,
117 0x00000000, 117 0x00000000,
118 0x00000000, 118 0x00000000,
119 0x00000000, 119 0x00000000,
@@ -134,8 +134,8 @@ uint32_t gf100_pmu_data[] = {
134 0x00000000, 134 0x00000000,
135 0x00000000, 135 0x00000000,
136 0x454c4449, 136 0x454c4449,
137 0x00000bc7, 137 0x00000bbc,
138 0x00000bc5, 138 0x00000bba,
139 0x00000000, 139 0x00000000,
140 0x00000000, 140 0x00000000,
141 0x00000000, 141 0x00000000,
@@ -229,26 +229,26 @@ uint32_t gf100_pmu_data[] = {
229/* 0x0370: memx_func_head */ 229/* 0x0370: memx_func_head */
230 0x00000001, 230 0x00000001,
231 0x00000000, 231 0x00000000,
232 0x00000551, 232 0x00000546,
233/* 0x037c: memx_func_next */ 233/* 0x037c: memx_func_next */
234 0x00000002, 234 0x00000002,
235 0x00000000, 235 0x00000000,
236 0x000005db, 236 0x000005d0,
237 0x00000003, 237 0x00000003,
238 0x00000002, 238 0x00000002,
239 0x000006a5, 239 0x0000069a,
240 0x00040004, 240 0x00040004,
241 0x00000000, 241 0x00000000,
242 0x000006c1, 242 0x000006b6,
243 0x00010005, 243 0x00010005,
244 0x00000000, 244 0x00000000,
245 0x000006de, 245 0x000006d3,
246 0x00010006, 246 0x00010006,
247 0x00000000, 247 0x00000000,
248 0x00000663, 248 0x00000658,
249 0x00000007, 249 0x00000007,
250 0x00000000, 250 0x00000000,
251 0x000006e9, 251 0x000006de,
252/* 0x03c4: memx_func_tail */ 252/* 0x03c4: memx_func_tail */
253/* 0x03c4: memx_ts_start */ 253/* 0x03c4: memx_ts_start */
254 0x00000000, 254 0x00000000,
@@ -917,7 +917,7 @@ uint32_t gf100_pmu_data[] = {
917}; 917};
918 918
919uint32_t gf100_pmu_code[] = { 919uint32_t gf100_pmu_code[] = {
920 0x039e0ef5, 920 0x03930ef5,
921/* 0x0004: rd32 */ 921/* 0x0004: rd32 */
922 0x07a007f1, 922 0x07a007f1,
923 0xd00604b6, 923 0xd00604b6,
@@ -987,7 +987,7 @@ uint32_t gf100_pmu_code[] = {
987 0xbb9a0a98, 987 0xbb9a0a98,
988 0x1cf4029a, 988 0x1cf4029a,
989 0x01d7f00f, 989 0x01d7f00f,
990 0x02dd21f5, 990 0x02d221f5,
991 0x0ef494bd, 991 0x0ef494bd,
992/* 0x00f9: intr_watchdog_next_time */ 992/* 0x00f9: intr_watchdog_next_time */
993 0x9b0a9815, 993 0x9b0a9815,
@@ -1039,7 +1039,7 @@ uint32_t gf100_pmu_code[] = {
1039 0x48e7f1c0, 1039 0x48e7f1c0,
1040 0x53e3f14f, 1040 0x53e3f14f,
1041 0x00d7f054, 1041 0x00d7f054,
1042 0x034221f5, 1042 0x033721f5,
1043 0x07f1c0fc, 1043 0x07f1c0fc,
1044 0x04b604c0, 1044 0x04b604c0,
1045 0x000cd006, 1045 0x000cd006,
@@ -1048,760 +1048,758 @@ uint32_t gf100_pmu_code[] = {
1048 0x04b60688, 1048 0x04b60688,
1049 0x0009d006, 1049 0x0009d006,
1050/* 0x01ca: intr_skip_subintr */ 1050/* 0x01ca: intr_skip_subintr */
1051 0x89c404bd, 1051 0x97f104bd,
1052 0x070bf420, 1052 0x90bd00e0,
1053 0xffbfa4f1, 1053 0xf00489fd,
1054/* 0x01d4: intr_skip_pause */ 1054 0x04b60407,
1055 0xf44089c4, 1055 0x0008d006,
1056 0xa4f1070b, 1056 0x80fc04bd,
1057/* 0x01de: intr_skip_user0 */ 1057 0xfc0088fe,
1058 0x07f0ffbf, 1058 0xfce0fcf0,
1059 0x0604b604, 1059 0xfcc0fcd0,
1060 0xbd0008d0, 1060 0xfca0fcb0,
1061 0xfe80fc04, 1061 0xfc80fc90,
1062 0xf0fc0088, 1062 0x0032f400,
1063 0xd0fce0fc, 1063/* 0x01fa: ticks_from_ns */
1064 0xb0fcc0fc, 1064 0xc0f901f8,
1065 0x90fca0fc,
1066 0x00fc80fc,
1067 0xf80032f4,
1068/* 0x0205: ticks_from_ns */
1069 0xf9c0f901,
1070 0xcbd7f1b0,
1071 0x00d3f000,
1072 0x041321f5,
1073 0x03e8ccec,
1074 0xf400b4b0,
1075 0xeeec120b,
1076 0xd7f103e8,
1077 0xd3f000cb,
1078 0x1321f500,
1079/* 0x022d: ticks_from_ns_quit */
1080 0x02ceb904,
1081 0xc0fcb0fc,
1082/* 0x0236: ticks_from_us */
1083 0xc0f900f8,
1084 0xd7f1b0f9, 1065 0xd7f1b0f9,
1085 0xd3f000cb, 1066 0xd3f000cb,
1086 0x1321f500, 1067 0x0821f500,
1087 0x02ceb904, 1068 0xe8ccec04,
1088 0xf400b4b0, 1069 0x00b4b003,
1089 0xe4bd050b, 1070 0xec120bf4,
1090/* 0x0250: ticks_from_us_quit */ 1071 0xf103e8ee,
1091 0xc0fcb0fc, 1072 0xf000cbd7,
1092/* 0x0256: ticks_to_us */ 1073 0x21f500d3,
1093 0xd7f100f8, 1074/* 0x0222: ticks_from_ns_quit */
1094 0xd3f000cb, 1075 0xceb90408,
1095 0xecedff00, 1076 0xfcb0fc02,
1096/* 0x0262: timer */ 1077/* 0x022b: ticks_from_us */
1097 0x90f900f8, 1078 0xf900f8c0,
1098 0x32f480f9, 1079 0xf1b0f9c0,
1099 0x03f89810, 1080 0xf000cbd7,
1100 0xf40086b0, 1081 0x21f500d3,
1101 0x84bd651c, 1082 0xceb90408,
1102 0xb63807f0, 1083 0x00b4b002,
1103 0x08d00604, 1084 0xbd050bf4,
1104 0xf004bd00, 1085/* 0x0245: ticks_from_us_quit */
1105 0x84b63487, 1086 0xfcb0fce4,
1106 0x0088cf06, 1087/* 0x024b: ticks_to_us */
1107 0xbb9a0998, 1088 0xf100f8c0,
1108 0xe9bb0298, 1089 0xf000cbd7,
1109 0x03fe8000, 1090 0xedff00d3,
1110 0xb60887f0, 1091/* 0x0257: timer */
1111 0x88cf0684, 1092 0xf900f8ec,
1112 0x0284f000, 1093 0xf480f990,
1113 0xf0261bf4, 1094 0xf8981032,
1114 0x84b63487, 1095 0x0086b003,
1115 0x0088cf06, 1096 0xbd651cf4,
1116 0xf406e0b8, 1097 0x3807f084,
1117 0xe8b8090b,
1118 0x111cf406,
1119/* 0x02b8: timer_reset */
1120 0xb63407f0,
1121 0x0ed00604,
1122 0x8004bd00,
1123/* 0x02c6: timer_enable */
1124 0x87f09a0e,
1125 0x3807f001,
1126 0xd00604b6, 1098 0xd00604b6,
1127 0x04bd0008, 1099 0x04bd0008,
1128/* 0x02d4: timer_done */ 1100 0xb63487f0,
1129 0xfc1031f4, 1101 0x88cf0684,
1130 0xf890fc80, 1102 0x9a099800,
1131/* 0x02dd: send_proc */ 1103 0xbb0298bb,
1132 0xf980f900, 1104 0xfe8000e9,
1133 0x05e89890, 1105 0x0887f003,
1134 0xf004e998, 1106 0xcf0684b6,
1135 0x89b80486, 1107 0x84f00088,
1136 0x2a0bf406, 1108 0x261bf402,
1137 0x940398c4, 1109 0xb63487f0,
1138 0x80b60488, 1110 0x88cf0684,
1139 0x008ebb18, 1111 0x06e0b800,
1140 0x8000fa98, 1112 0xb8090bf4,
1141 0x8d80008a, 1113 0x1cf406e8,
1142 0x028c8001, 1114/* 0x02ad: timer_reset */
1143 0xb6038b80, 1115 0x3407f011,
1144 0x94f00190,
1145 0x04e98007,
1146/* 0x0317: send_done */
1147 0xfc0231f4,
1148 0xf880fc90,
1149/* 0x031d: find */
1150 0xf080f900,
1151 0x31f45887,
1152/* 0x0325: find_loop */
1153 0x008a9801,
1154 0xf406aeb8,
1155 0x80b6100b,
1156 0x6886b158,
1157 0xf01bf402,
1158/* 0x033b: find_done */
1159 0xb90132f4,
1160 0x80fc028e,
1161/* 0x0342: send */
1162 0x21f500f8,
1163 0x01f4031d,
1164/* 0x034b: recv */
1165 0xf900f897,
1166 0x9880f990,
1167 0xe99805e8,
1168 0x0132f404,
1169 0xf40689b8,
1170 0x89c43d0b,
1171 0x0180b603,
1172 0x800784f0,
1173 0xea9805e8,
1174 0xfef0f902,
1175 0xf0f9018f,
1176 0x9402efb9,
1177 0xe9bb0499,
1178 0x18e0b600,
1179 0x9803eb98,
1180 0xed9802ec,
1181 0x00ee9801,
1182 0xf0fca5f9,
1183 0xf400f8fe,
1184 0xf0fc0131,
1185/* 0x0398: recv_done */
1186 0x90fc80fc,
1187/* 0x039e: init */
1188 0x17f100f8,
1189 0x14b60108,
1190 0x0011cf06,
1191 0x010911e7,
1192 0xfe0814b6,
1193 0x17f10014,
1194 0x13f000e0,
1195 0x1c07f000,
1196 0xd00604b6,
1197 0x04bd0001,
1198 0xf0ff17f0,
1199 0x04b61407,
1200 0x0001d006,
1201 0x17f004bd,
1202 0x0015f102,
1203 0x1007f008,
1204 0xd00604b6, 1116 0xd00604b6,
1205 0x04bd0001, 1117 0x04bd000e,
1206 0x011a17f1, 1118/* 0x02bb: timer_enable */
1207 0xfe0013f0, 1119 0xf09a0e80,
1208 0x31f40010, 1120 0x07f00187,
1209 0x0117f010, 1121 0x0604b638,
1210 0xb63807f0, 1122 0xbd0008d0,
1123/* 0x02c9: timer_done */
1124 0x1031f404,
1125 0x90fc80fc,
1126/* 0x02d2: send_proc */
1127 0x80f900f8,
1128 0xe89890f9,
1129 0x04e99805,
1130 0xb80486f0,
1131 0x0bf40689,
1132 0x0398c42a,
1133 0xb6048894,
1134 0x8ebb1880,
1135 0x00fa9800,
1136 0x80008a80,
1137 0x8c80018d,
1138 0x038b8002,
1139 0xf00190b6,
1140 0xe9800794,
1141 0x0231f404,
1142/* 0x030c: send_done */
1143 0x80fc90fc,
1144/* 0x0312: find */
1145 0x80f900f8,
1146 0xf45887f0,
1147/* 0x031a: find_loop */
1148 0x8a980131,
1149 0x06aeb800,
1150 0xb6100bf4,
1151 0x86b15880,
1152 0x1bf40268,
1153 0x0132f4f0,
1154/* 0x0330: find_done */
1155 0xfc028eb9,
1156/* 0x0337: send */
1157 0xf500f880,
1158 0xf4031221,
1159 0x00f89701,
1160/* 0x0340: recv */
1161 0x80f990f9,
1162 0x9805e898,
1163 0x32f404e9,
1164 0x0689b801,
1165 0xc43d0bf4,
1166 0x80b60389,
1167 0x0784f001,
1168 0x9805e880,
1169 0xf0f902ea,
1170 0xf9018ffe,
1171 0x02efb9f0,
1172 0xbb049994,
1173 0xe0b600e9,
1174 0x03eb9818,
1175 0x9802ec98,
1176 0xee9801ed,
1177 0xfca5f900,
1178 0x00f8fef0,
1179 0xfc0131f4,
1180/* 0x038d: recv_done */
1181 0xfc80fcf0,
1182/* 0x0393: init */
1183 0xf100f890,
1184 0xb6010817,
1185 0x11cf0614,
1186 0x0911e700,
1187 0x0814b601,
1188 0xf10014fe,
1189 0xf000e017,
1190 0x07f00013,
1191 0x0604b61c,
1192 0xbd0001d0,
1193 0xff17f004,
1194 0xb61407f0,
1211 0x01d00604, 1195 0x01d00604,
1212 0xf004bd00, 1196 0xf004bd00,
1213/* 0x0402: init_proc */ 1197 0x15f10217,
1214 0xf19858f7, 1198 0x07f00800,
1215 0x0016b001, 1199 0x0604b610,
1216 0xf9fa0bf4, 1200 0xbd0001d0,
1217 0x58f0b615, 1201 0x1a17f104,
1218/* 0x0413: mulu32_32_64 */ 1202 0x0013f001,
1219 0xf9f20ef4, 1203 0xf40010fe,
1220 0xf920f910, 1204 0x17f01031,
1221 0x9540f930, 1205 0x3807f001,
1222 0xd29510e1, 1206 0xd00604b6,
1223 0xbdc4bd10, 1207 0x04bd0001,
1224 0xc0edffb4, 1208/* 0x03f7: init_proc */
1225 0xb9301dff, 1209 0x9858f7f0,
1226 0x34f10234, 1210 0x16b001f1,
1227 0x34b6ffff, 1211 0xfa0bf400,
1228 0x1045b610, 1212 0xf0b615f9,
1229 0xbb00c3bb, 1213 0xf20ef458,
1230 0xe2ff01b4, 1214/* 0x0408: mulu32_32_64 */
1231 0x0234b930, 1215 0x20f910f9,
1232 0xffff34f1, 1216 0x40f930f9,
1233 0xb61034b6, 1217 0x9510e195,
1234 0xc3bb1045, 1218 0xc4bd10d2,
1235 0x01b4bb00, 1219 0xedffb4bd,
1236 0xbb3012ff, 1220 0x301dffc0,
1237 0x40fc00b3, 1221 0xf10234b9,
1238 0x20fc30fc, 1222 0xb6ffff34,
1239 0x00f810fc, 1223 0x45b61034,
1240/* 0x0464: host_send */ 1224 0x00c3bb10,
1241 0x04b017f1, 1225 0xff01b4bb,
1242 0xcf0614b6, 1226 0x34b930e2,
1243 0x27f10011, 1227 0xff34f102,
1244 0x24b604a0, 1228 0x1034b6ff,
1245 0x0022cf06, 1229 0xbb1045b6,
1246 0xf40612b8, 1230 0xb4bb00c3,
1247 0x1ec4320b, 1231 0x3012ff01,
1248 0x04ee9407, 1232 0xfc00b3bb,
1249 0x0270e0b7, 1233 0xfc30fc40,
1250 0x9803eb98, 1234 0xf810fc20,
1251 0xed9802ec, 1235/* 0x0459: host_send */
1252 0x00ee9801, 1236 0xb017f100,
1253 0x034221f5,
1254 0xc40110b6,
1255 0x07f10f1e,
1256 0x04b604b0,
1257 0x000ed006,
1258 0x0ef404bd,
1259/* 0x04ad: host_send_done */
1260/* 0x04af: host_recv */
1261 0xf100f8ba,
1262 0xf14e4917,
1263 0xb8525413,
1264 0x0bf406e1,
1265/* 0x04bd: host_recv_wait */
1266 0xcc17f1aa,
1267 0x0614b604, 1237 0x0614b604,
1268 0xf10011cf, 1238 0xf10011cf,
1269 0xb604c827, 1239 0xb604a027,
1270 0x22cf0624, 1240 0x22cf0624,
1271 0x0816f000, 1241 0x0612b800,
1272 0xf40612b8, 1242 0xc4320bf4,
1273 0x23c4e60b, 1243 0xee94071e,
1274 0x0434b607, 1244 0x70e0b704,
1275 0x02f030b7, 1245 0x03eb9802,
1276 0x80033b80, 1246 0x9802ec98,
1277 0x3d80023c, 1247 0xee9801ed,
1278 0x003e8001, 1248 0x3721f500,
1279 0xf00120b6, 1249 0x0110b603,
1280 0x07f10f24, 1250 0xf10f1ec4,
1281 0x04b604c8, 1251 0xb604b007,
1282 0x0002d006, 1252 0x0ed00604,
1283 0x27f004bd, 1253 0xf404bd00,
1284 0x0007f040, 1254/* 0x04a2: host_send_done */
1285 0xd00604b6, 1255 0x00f8ba0e,
1286 0x04bd0002, 1256/* 0x04a4: host_recv */
1287/* 0x0512: host_init */ 1257 0x4e4917f1,
1288 0x17f100f8, 1258 0x525413f1,
1259 0xf406e1b8,
1260/* 0x04b2: host_recv_wait */
1261 0x17f1aa0b,
1262 0x14b604cc,
1263 0x0011cf06,
1264 0x04c827f1,
1265 0xcf0624b6,
1266 0x16f00022,
1267 0x0612b808,
1268 0xc4e60bf4,
1269 0x34b60723,
1270 0xf030b704,
1271 0x033b8002,
1272 0x80023c80,
1273 0x3e80013d,
1274 0x0120b600,
1275 0xf10f24f0,
1276 0xb604c807,
1277 0x02d00604,
1278 0xf004bd00,
1279 0x07f04027,
1280 0x0604b600,
1281 0xbd0002d0,
1282/* 0x0507: host_init */
1283 0xf100f804,
1284 0xb6008017,
1285 0x15f11014,
1286 0x07f10270,
1287 0x04b604d0,
1288 0x0001d006,
1289 0x17f104bd,
1289 0x14b60080, 1290 0x14b60080,
1290 0x7015f110, 1291 0xf015f110,
1291 0xd007f102, 1292 0xdc07f102,
1292 0x0604b604, 1293 0x0604b604,
1293 0xbd0001d0, 1294 0xbd0001d0,
1294 0x8017f104, 1295 0x0117f004,
1295 0x1014b600, 1296 0x04c407f1,
1296 0x02f015f1,
1297 0x04dc07f1,
1298 0xd00604b6, 1297 0xd00604b6,
1299 0x04bd0001, 1298 0x04bd0001,
1300 0xf10117f0, 1299/* 0x0546: memx_func_enter */
1301 0xb604c407, 1300 0x67f100f8,
1302 0x01d00604, 1301 0x77f11620,
1303 0xf804bd00, 1302 0x73f1f55d,
1304/* 0x0551: memx_func_enter */ 1303 0x6eb9ffff,
1305 0x2067f100, 1304 0x0421f402,
1306 0x5d77f116, 1305 0xfd02d8b9,
1307 0xff73f1f5, 1306 0x60f90487,
1307 0xd0fc80f9,
1308 0x21f4e0fc,
1309 0xfe77f13f,
1310 0xff73f1ff,
1308 0x026eb9ff, 1311 0x026eb9ff,
1309 0xb90421f4, 1312 0xb90421f4,
1310 0x87fd02d8, 1313 0x87fd02d8,
1311 0xf960f904, 1314 0xf960f904,
1312 0xfcd0fc80, 1315 0xfcd0fc80,
1313 0x3f21f4e0, 1316 0x3f21f4e0,
1314 0xfffe77f1, 1317 0x26f067f1,
1315 0xffff73f1,
1316 0xf4026eb9, 1318 0xf4026eb9,
1317 0xd8b90421, 1319 0xd8b90421,
1318 0x0487fd02, 1320 0x0487fd02,
1319 0x80f960f9, 1321 0x80f960f9,
1320 0xe0fcd0fc, 1322 0xe0fcd0fc,
1321 0xf13f21f4, 1323 0xf03f21f4,
1322 0xb926f067,
1323 0x21f4026e,
1324 0x02d8b904,
1325 0xf90487fd,
1326 0xfc80f960,
1327 0xf4e0fcd0,
1328 0x67f03f21,
1329 0xe007f104,
1330 0x0604b607,
1331 0xbd0006d0,
1332/* 0x05bd: memx_func_enter_wait */
1333 0xc067f104,
1334 0x0664b607,
1335 0xf00066cf,
1336 0x0bf40464,
1337 0x2c67f0f3,
1338 0xcf0664b6,
1339 0x06800066,
1340/* 0x05db: memx_func_leave */
1341 0xf000f8f1,
1342 0x64b62c67,
1343 0x0066cf06,
1344 0xf0f20680,
1345 0x07f10467, 1324 0x07f10467,
1346 0x04b607e4, 1325 0x04b607e0,
1347 0x0006d006, 1326 0x0006d006,
1348/* 0x05f6: memx_func_leave_wait */ 1327/* 0x05b2: memx_func_enter_wait */
1349 0x67f104bd, 1328 0x67f104bd,
1350 0x64b607c0, 1329 0x64b607c0,
1351 0x0066cf06, 1330 0x0066cf06,
1352 0xf40464f0, 1331 0xf40464f0,
1353 0x67f1f31b, 1332 0x67f0f30b,
1354 0x77f126f0, 1333 0x0664b62c,
1355 0x73f00001, 1334 0x800066cf,
1356 0x026eb900, 1335 0x00f8f106,
1357 0xb90421f4, 1336/* 0x05d0: memx_func_leave */
1358 0x87fd02d8, 1337 0xb62c67f0,
1359 0xf960f905, 1338 0x66cf0664,
1360 0xfcd0fc80, 1339 0xf2068000,
1361 0x3f21f4e0, 1340 0xf10467f0,
1362 0x162067f1, 1341 0xb607e407,
1363 0xf4026eb9, 1342 0x06d00604,
1364 0xd8b90421, 1343/* 0x05eb: memx_func_leave_wait */
1365 0x0587fd02, 1344 0xf104bd00,
1366 0x80f960f9, 1345 0xb607c067,
1367 0xe0fcd0fc, 1346 0x66cf0664,
1368 0xf13f21f4, 1347 0x0464f000,
1369 0xf00aa277, 1348 0xf1f31bf4,
1349 0xf126f067,
1350 0xf0000177,
1370 0x6eb90073, 1351 0x6eb90073,
1371 0x0421f402, 1352 0x0421f402,
1372 0xfd02d8b9, 1353 0xfd02d8b9,
1373 0x60f90587, 1354 0x60f90587,
1374 0xd0fc80f9, 1355 0xd0fc80f9,
1375 0x21f4e0fc, 1356 0x21f4e0fc,
1376/* 0x0663: memx_func_wait_vblank */ 1357 0x2067f13f,
1377 0x9800f83f, 1358 0x026eb916,
1378 0x66b00016, 1359 0xb90421f4,
1379 0x130bf400, 1360 0x87fd02d8,
1380 0xf40166b0, 1361 0xf960f905,
1381 0x0ef4060b, 1362 0xfcd0fc80,
1382/* 0x0675: memx_func_wait_vblank_head1 */ 1363 0x3f21f4e0,
1383 0x2077f12e, 1364 0x0aa277f1,
1384 0x070ef400, 1365 0xb90073f0,
1385/* 0x067c: memx_func_wait_vblank_head0 */ 1366 0x21f4026e,
1386 0x000877f1, 1367 0x02d8b904,
1387/* 0x0680: memx_func_wait_vblank_0 */ 1368 0xf90587fd,
1388 0x07c467f1, 1369 0xfc80f960,
1389 0xcf0664b6, 1370 0xf4e0fcd0,
1390 0x67fd0066, 1371 0x00f83f21,
1391 0xf31bf404, 1372/* 0x0658: memx_func_wait_vblank */
1392/* 0x0690: memx_func_wait_vblank_1 */ 1373 0xb0001698,
1393 0x07c467f1, 1374 0x0bf40066,
1394 0xcf0664b6, 1375 0x0166b013,
1395 0x67fd0066, 1376 0xf4060bf4,
1396 0xf30bf404, 1377/* 0x066a: memx_func_wait_vblank_head1 */
1397/* 0x06a0: memx_func_wait_vblank_fini */ 1378 0x77f12e0e,
1398 0xf80410b6, 1379 0x0ef40020,
1399/* 0x06a5: memx_func_wr32 */ 1380/* 0x0671: memx_func_wait_vblank_head0 */
1400 0x00169800, 1381 0x0877f107,
1401 0xb6011598, 1382/* 0x0675: memx_func_wait_vblank_0 */
1402 0x60f90810, 1383 0xc467f100,
1403 0xd0fc50f9, 1384 0x0664b607,
1404 0x21f4e0fc, 1385 0xfd0066cf,
1405 0x0242b63f, 1386 0x1bf40467,
1406 0xf8e91bf4, 1387/* 0x0685: memx_func_wait_vblank_1 */
1407/* 0x06c1: memx_func_wait */ 1388 0xc467f1f3,
1408 0x2c87f000, 1389 0x0664b607,
1409 0xcf0684b6, 1390 0xfd0066cf,
1410 0x1e980088, 1391 0x0bf40467,
1411 0x011d9800, 1392/* 0x0695: memx_func_wait_vblank_fini */
1412 0x98021c98, 1393 0x0410b6f3,
1413 0x10b6031b, 1394/* 0x069a: memx_func_wr32 */
1414 0xa421f410, 1395 0x169800f8,
1415/* 0x06de: memx_func_delay */ 1396 0x01159800,
1416 0x1e9800f8, 1397 0xf90810b6,
1398 0xfc50f960,
1399 0xf4e0fcd0,
1400 0x42b63f21,
1401 0xe91bf402,
1402/* 0x06b6: memx_func_wait */
1403 0x87f000f8,
1404 0x0684b62c,
1405 0x980088cf,
1406 0x1d98001e,
1407 0x021c9801,
1408 0xb6031b98,
1409 0x21f41010,
1410/* 0x06d3: memx_func_delay */
1411 0x9800f8a4,
1412 0x10b6001e,
1413 0x7f21f404,
1414/* 0x06de: memx_func_train */
1415 0x00f800f8,
1416/* 0x06e0: memx_exec */
1417 0xd0f9e0f9,
1418 0xb902c1b9,
1419/* 0x06ea: memx_exec_next */
1420 0x139802b2,
1417 0x0410b600, 1421 0x0410b600,
1422 0x01f034e7,
1423 0x01e033e7,
1424 0xf00132b6,
1425 0x35980c30,
1426 0xb855f9de,
1427 0x1ef40612,
1428 0xf10b98e4,
1429 0xbbf20c98,
1430 0xb7f102cb,
1431 0xb4b607c4,
1432 0x00bbcf06,
1433 0xe0fcd0fc,
1434 0x033721f5,
1435/* 0x0726: memx_info */
1436 0xc67000f8,
1437 0x0e0bf401,
1438/* 0x072c: memx_info_data */
1439 0x03ccc7f1,
1440 0x0800b7f1,
1441/* 0x0737: memx_info_train */
1442 0xf10b0ef4,
1443 0xf10bccc7,
1444/* 0x073f: memx_info_send */
1445 0xf50100b7,
1446 0xf8033721,
1447/* 0x0745: memx_recv */
1448 0x01d6b000,
1449 0xb0980bf4,
1450 0x0bf400d6,
1451/* 0x0753: memx_init */
1452 0xf800f8d8,
1453/* 0x0755: perf_recv */
1454/* 0x0757: perf_init */
1455 0xf800f800,
1456/* 0x0759: i2c_drive_scl */
1457 0x0036b000,
1458 0xf1110bf4,
1459 0xb607e007,
1460 0x01d00604,
1461 0xf804bd00,
1462/* 0x076d: i2c_drive_scl_lo */
1463 0xe407f100,
1464 0x0604b607,
1465 0xbd0001d0,
1466/* 0x077b: i2c_drive_sda */
1467 0xb000f804,
1468 0x0bf40036,
1469 0xe007f111,
1470 0x0604b607,
1471 0xbd0002d0,
1472/* 0x078f: i2c_drive_sda_lo */
1473 0xf100f804,
1474 0xb607e407,
1475 0x02d00604,
1476 0xf804bd00,
1477/* 0x079d: i2c_sense_scl */
1478 0x0132f400,
1479 0x07c437f1,
1480 0xcf0634b6,
1481 0x31fd0033,
1482 0x060bf404,
1483/* 0x07b3: i2c_sense_scl_done */
1484 0xf80131f4,
1485/* 0x07b5: i2c_sense_sda */
1486 0x0132f400,
1487 0x07c437f1,
1488 0xcf0634b6,
1489 0x32fd0033,
1490 0x060bf404,
1491/* 0x07cb: i2c_sense_sda_done */
1492 0xf80131f4,
1493/* 0x07cd: i2c_raise_scl */
1494 0xf140f900,
1495 0xf0089847,
1496 0x21f50137,
1497/* 0x07da: i2c_raise_scl_wait */
1498 0xe7f10759,
1499 0x21f403e8,
1500 0x9d21f57f,
1501 0x0901f407,
1502 0xf40142b6,
1503/* 0x07ee: i2c_raise_scl_done */
1504 0x40fcef1b,
1505/* 0x07f2: i2c_start */
1506 0x21f500f8,
1507 0x11f4079d,
1508 0xb521f50d,
1509 0x0611f407,
1510/* 0x0803: i2c_start_rep */
1511 0xf0300ef4,
1512 0x21f50037,
1513 0x37f00759,
1514 0x7b21f501,
1515 0x0076bb07,
1516 0xf90465b6,
1517 0x04659450,
1518 0xbd0256bb,
1519 0x0475fd50,
1520 0x21f550fc,
1521 0x64b607cd,
1522 0x1f11f404,
1523/* 0x0830: i2c_start_send */
1524 0xf50037f0,
1525 0xf1077b21,
1526 0xf41388e7,
1527 0x37f07f21,
1528 0x5921f500,
1529 0x88e7f107,
1530 0x7f21f413,
1531/* 0x084c: i2c_start_out */
1532/* 0x084e: i2c_stop */
1533 0x37f000f8,
1534 0x5921f500,
1535 0x0037f007,
1536 0x077b21f5,
1537 0x03e8e7f1,
1538 0xf07f21f4,
1539 0x21f50137,
1540 0xe7f10759,
1541 0x21f41388,
1542 0x0137f07f,
1543 0x077b21f5,
1544 0x1388e7f1,
1418 0xf87f21f4, 1545 0xf87f21f4,
1419/* 0x06e9: memx_func_train */ 1546/* 0x0881: i2c_bitw */
1420/* 0x06eb: memx_exec */ 1547 0x7b21f500,
1421 0xf900f800,
1422 0xb9d0f9e0,
1423 0xb2b902c1,
1424/* 0x06f5: memx_exec_next */
1425 0x00139802,
1426 0xe70410b6,
1427 0xe701f034,
1428 0xb601e033,
1429 0x30f00132,
1430 0xde35980c,
1431 0x12b855f9,
1432 0xe41ef406,
1433 0x98f10b98,
1434 0xcbbbf20c,
1435 0xc4b7f102,
1436 0x06b4b607,
1437 0xfc00bbcf,
1438 0xf5e0fcd0,
1439 0xf8034221,
1440/* 0x0731: memx_info */
1441 0x01c67000,
1442/* 0x0737: memx_info_data */
1443 0xf10e0bf4,
1444 0xf103ccc7,
1445 0xf40800b7,
1446/* 0x0742: memx_info_train */
1447 0xc7f10b0e,
1448 0xb7f10bcc,
1449/* 0x074a: memx_info_send */
1450 0x21f50100,
1451 0x00f80342,
1452/* 0x0750: memx_recv */
1453 0xf401d6b0,
1454 0xd6b0980b,
1455 0xd80bf400,
1456/* 0x075e: memx_init */
1457 0x00f800f8,
1458/* 0x0760: perf_recv */
1459/* 0x0762: perf_init */
1460 0x00f800f8,
1461/* 0x0764: i2c_drive_scl */
1462 0xf40036b0,
1463 0x07f1110b,
1464 0x04b607e0,
1465 0x0001d006,
1466 0x00f804bd,
1467/* 0x0778: i2c_drive_scl_lo */
1468 0x07e407f1,
1469 0xd00604b6,
1470 0x04bd0001,
1471/* 0x0786: i2c_drive_sda */
1472 0x36b000f8,
1473 0x110bf400,
1474 0x07e007f1,
1475 0xd00604b6,
1476 0x04bd0002,
1477/* 0x079a: i2c_drive_sda_lo */
1478 0x07f100f8,
1479 0x04b607e4,
1480 0x0002d006,
1481 0x00f804bd,
1482/* 0x07a8: i2c_sense_scl */
1483 0xf10132f4,
1484 0xb607c437,
1485 0x33cf0634,
1486 0x0431fd00,
1487 0xf4060bf4,
1488/* 0x07be: i2c_sense_scl_done */
1489 0x00f80131,
1490/* 0x07c0: i2c_sense_sda */
1491 0xf10132f4,
1492 0xb607c437,
1493 0x33cf0634,
1494 0x0432fd00,
1495 0xf4060bf4,
1496/* 0x07d6: i2c_sense_sda_done */
1497 0x00f80131,
1498/* 0x07d8: i2c_raise_scl */
1499 0x47f140f9,
1500 0x37f00898,
1501 0x6421f501,
1502/* 0x07e5: i2c_raise_scl_wait */
1503 0xe8e7f107, 1548 0xe8e7f107,
1504 0x7f21f403, 1549 0x7f21f403,
1505 0x07a821f5,
1506 0xb60901f4,
1507 0x1bf40142,
1508/* 0x07f9: i2c_raise_scl_done */
1509 0xf840fcef,
1510/* 0x07fd: i2c_start */
1511 0xa821f500,
1512 0x0d11f407,
1513 0x07c021f5,
1514 0xf40611f4,
1515/* 0x080e: i2c_start_rep */
1516 0x37f0300e,
1517 0x6421f500,
1518 0x0137f007,
1519 0x078621f5,
1520 0xb60076bb, 1550 0xb60076bb,
1521 0x50f90465, 1551 0x50f90465,
1522 0xbb046594, 1552 0xbb046594,
1523 0x50bd0256, 1553 0x50bd0256,
1524 0xfc0475fd, 1554 0xfc0475fd,
1525 0xd821f550, 1555 0xcd21f550,
1526 0x0464b607, 1556 0x0464b607,
1527/* 0x083b: i2c_start_send */ 1557 0xf11811f4,
1528 0xf01f11f4, 1558 0xf41388e7,
1529 0x21f50037,
1530 0xe7f10786,
1531 0x21f41388,
1532 0x0037f07f,
1533 0x076421f5,
1534 0x1388e7f1,
1535/* 0x0857: i2c_start_out */
1536 0xf87f21f4,
1537/* 0x0859: i2c_stop */
1538 0x0037f000,
1539 0x076421f5,
1540 0xf50037f0,
1541 0xf1078621,
1542 0xf403e8e7,
1543 0x37f07f21, 1559 0x37f07f21,
1544 0x6421f501, 1560 0x5921f500,
1545 0x88e7f107, 1561 0x88e7f107,
1546 0x7f21f413, 1562 0x7f21f413,
1547 0xf50137f0, 1563/* 0x08c0: i2c_bitw_out */
1548 0xf1078621, 1564/* 0x08c2: i2c_bitr */
1549 0xf41388e7, 1565 0x37f000f8,
1550 0x00f87f21, 1566 0x7b21f501,
1551/* 0x088c: i2c_bitw */ 1567 0xe8e7f107,
1552 0x078621f5, 1568 0x7f21f403,
1553 0x03e8e7f1, 1569 0xb60076bb,
1554 0xbb7f21f4, 1570 0x50f90465,
1555 0x65b60076, 1571 0xbb046594,
1556 0x9450f904, 1572 0x50bd0256,
1557 0x56bb0465, 1573 0xfc0475fd,
1558 0xfd50bd02, 1574 0xcd21f550,
1559 0x50fc0475, 1575 0x0464b607,
1560 0x07d821f5, 1576 0xf51b11f4,
1561 0xf40464b6, 1577 0xf007b521,
1562 0xe7f11811, 1578 0x21f50037,
1579 0xe7f10759,
1563 0x21f41388, 1580 0x21f41388,
1564 0x0037f07f, 1581 0x013cf07f,
1565 0x076421f5, 1582/* 0x0907: i2c_bitr_done */
1566 0x1388e7f1, 1583 0xf80131f4,
1567/* 0x08cb: i2c_bitw_out */ 1584/* 0x0909: i2c_get_byte */
1568 0xf87f21f4, 1585 0x0057f000,
1569/* 0x08cd: i2c_bitr */ 1586/* 0x090f: i2c_get_byte_next */
1570 0x0137f000, 1587 0xb60847f0,
1571 0x078621f5, 1588 0x76bb0154,
1572 0x03e8e7f1, 1589 0x0465b600,
1573 0xbb7f21f4, 1590 0x659450f9,
1574 0x65b60076, 1591 0x0256bb04,
1575 0x9450f904, 1592 0x75fd50bd,
1576 0x56bb0465, 1593 0xf550fc04,
1577 0xfd50bd02, 1594 0xb608c221,
1578 0x50fc0475, 1595 0x11f40464,
1579 0x07d821f5, 1596 0x0553fd2b,
1580 0xf40464b6, 1597 0xf40142b6,
1581 0x21f51b11, 1598 0x37f0d81b,
1582 0x37f007c0,
1583 0x6421f500,
1584 0x88e7f107,
1585 0x7f21f413,
1586 0xf4013cf0,
1587/* 0x0912: i2c_bitr_done */
1588 0x00f80131,
1589/* 0x0914: i2c_get_byte */
1590 0xf00057f0,
1591/* 0x091a: i2c_get_byte_next */
1592 0x54b60847,
1593 0x0076bb01, 1599 0x0076bb01,
1594 0xf90465b6, 1600 0xf90465b6,
1595 0x04659450, 1601 0x04659450,
1596 0xbd0256bb, 1602 0xbd0256bb,
1597 0x0475fd50, 1603 0x0475fd50,
1598 0x21f550fc, 1604 0x21f550fc,
1599 0x64b608cd, 1605 0x64b60881,
1600 0x2b11f404, 1606/* 0x0959: i2c_get_byte_done */
1601 0xb60553fd, 1607/* 0x095b: i2c_put_byte */
1602 0x1bf40142, 1608 0xf000f804,
1603 0x0137f0d8, 1609/* 0x095e: i2c_put_byte_next */
1610 0x42b60847,
1611 0x3854ff01,
1604 0xb60076bb, 1612 0xb60076bb,
1605 0x50f90465, 1613 0x50f90465,
1606 0xbb046594, 1614 0xbb046594,
1607 0x50bd0256, 1615 0x50bd0256,
1608 0xfc0475fd, 1616 0xfc0475fd,
1609 0x8c21f550, 1617 0x8121f550,
1610 0x0464b608, 1618 0x0464b608,
1611/* 0x0964: i2c_get_byte_done */ 1619 0xb03411f4,
1612/* 0x0966: i2c_put_byte */ 1620 0x1bf40046,
1613 0x47f000f8, 1621 0x0076bbd8,
1614/* 0x0969: i2c_put_byte_next */
1615 0x0142b608,
1616 0xbb3854ff,
1617 0x65b60076,
1618 0x9450f904,
1619 0x56bb0465,
1620 0xfd50bd02,
1621 0x50fc0475,
1622 0x088c21f5,
1623 0xf40464b6,
1624 0x46b03411,
1625 0xd81bf400,
1626 0xb60076bb,
1627 0x50f90465,
1628 0xbb046594,
1629 0x50bd0256,
1630 0xfc0475fd,
1631 0xcd21f550,
1632 0x0464b608,
1633 0xbb0f11f4,
1634 0x36b00076,
1635 0x061bf401,
1636/* 0x09bf: i2c_put_byte_done */
1637 0xf80132f4,
1638/* 0x09c1: i2c_addr */
1639 0x0076bb00,
1640 0xf90465b6, 1622 0xf90465b6,
1641 0x04659450, 1623 0x04659450,
1642 0xbd0256bb, 1624 0xbd0256bb,
1643 0x0475fd50, 1625 0x0475fd50,
1644 0x21f550fc, 1626 0x21f550fc,
1645 0x64b607fd, 1627 0x64b608c2,
1646 0x2911f404, 1628 0x0f11f404,
1647 0x012ec3e7, 1629 0xb00076bb,
1648 0xfd0134b6, 1630 0x1bf40136,
1649 0x76bb0553, 1631 0x0132f406,
1632/* 0x09b4: i2c_put_byte_done */
1633/* 0x09b6: i2c_addr */
1634 0x76bb00f8,
1650 0x0465b600, 1635 0x0465b600,
1651 0x659450f9, 1636 0x659450f9,
1652 0x0256bb04, 1637 0x0256bb04,
1653 0x75fd50bd, 1638 0x75fd50bd,
1654 0xf550fc04, 1639 0xf550fc04,
1655 0xb6096621, 1640 0xb607f221,
1656/* 0x0a06: i2c_addr_done */ 1641 0x11f40464,
1657 0x00f80464, 1642 0x2ec3e729,
1658/* 0x0a08: i2c_acquire_addr */ 1643 0x0134b601,
1659 0xb6f8cec7, 1644 0xbb0553fd,
1660 0xe0b702e4,
1661 0xee980d1c,
1662/* 0x0a17: i2c_acquire */
1663 0xf500f800,
1664 0xf40a0821,
1665 0xd9f00421,
1666 0x3f21f403,
1667/* 0x0a26: i2c_release */
1668 0x21f500f8,
1669 0x21f40a08,
1670 0x03daf004,
1671 0xf83f21f4,
1672/* 0x0a35: i2c_recv */
1673 0x0132f400,
1674 0xb6f8c1c7,
1675 0x16b00214,
1676 0x3a1ff528,
1677 0xf413a001,
1678 0x0032980c,
1679 0x0ccc13a0,
1680 0xf4003198,
1681 0xd0f90231,
1682 0xd0f9e0f9,
1683 0x000067f1,
1684 0x100063f1,
1685 0xbb016792,
1686 0x65b60076, 1645 0x65b60076,
1687 0x9450f904, 1646 0x9450f904,
1688 0x56bb0465, 1647 0x56bb0465,
1689 0xfd50bd02, 1648 0xfd50bd02,
1690 0x50fc0475, 1649 0x50fc0475,
1691 0x0a1721f5, 1650 0x095b21f5,
1692 0xfc0464b6, 1651/* 0x09fb: i2c_addr_done */
1693 0x00d6b0d0, 1652 0xf80464b6,
1694 0x00b31bf5, 1653/* 0x09fd: i2c_acquire_addr */
1695 0xbb0057f0, 1654 0xf8cec700,
1655 0xb702e4b6,
1656 0x980d1ce0,
1657 0x00f800ee,
1658/* 0x0a0c: i2c_acquire */
1659 0x09fd21f5,
1660 0xf00421f4,
1661 0x21f403d9,
1662/* 0x0a1b: i2c_release */
1663 0xf500f83f,
1664 0xf409fd21,
1665 0xdaf00421,
1666 0x3f21f403,
1667/* 0x0a2a: i2c_recv */
1668 0x32f400f8,
1669 0xf8c1c701,
1670 0xb00214b6,
1671 0x1ff52816,
1672 0x13a0013a,
1673 0x32980cf4,
1674 0xcc13a000,
1675 0x0031980c,
1676 0xf90231f4,
1677 0xf9e0f9d0,
1678 0x0067f1d0,
1679 0x0063f100,
1680 0x01679210,
1681 0xb60076bb,
1682 0x50f90465,
1683 0xbb046594,
1684 0x50bd0256,
1685 0xfc0475fd,
1686 0x0c21f550,
1687 0x0464b60a,
1688 0xd6b0d0fc,
1689 0xb31bf500,
1690 0x0057f000,
1691 0xb60076bb,
1692 0x50f90465,
1693 0xbb046594,
1694 0x50bd0256,
1695 0xfc0475fd,
1696 0xb621f550,
1697 0x0464b609,
1698 0x00d011f5,
1699 0xbbe0c5c7,
1696 0x65b60076, 1700 0x65b60076,
1697 0x9450f904, 1701 0x9450f904,
1698 0x56bb0465, 1702 0x56bb0465,
1699 0xfd50bd02, 1703 0xfd50bd02,
1700 0x50fc0475, 1704 0x50fc0475,
1701 0x09c121f5, 1705 0x095b21f5,
1702 0xf50464b6, 1706 0xf50464b6,
1703 0xc700d011, 1707 0xf000ad11,
1704 0x76bbe0c5, 1708 0x76bb0157,
1705 0x0465b600, 1709 0x0465b600,
1706 0x659450f9, 1710 0x659450f9,
1707 0x0256bb04, 1711 0x0256bb04,
1708 0x75fd50bd, 1712 0x75fd50bd,
1709 0xf550fc04, 1713 0xf550fc04,
1710 0xb6096621, 1714 0xb609b621,
1711 0x11f50464, 1715 0x11f50464,
1712 0x57f000ad, 1716 0x76bb008a,
1713 0x0076bb01, 1717 0x0465b600,
1714 0xf90465b6, 1718 0x659450f9,
1715 0x04659450, 1719 0x0256bb04,
1716 0xbd0256bb, 1720 0x75fd50bd,
1717 0x0475fd50, 1721 0xf550fc04,
1718 0x21f550fc, 1722 0xb6090921,
1719 0x64b609c1, 1723 0x11f40464,
1720 0x8a11f504, 1724 0xe05bcb6a,
1721 0x0076bb00, 1725 0xb60076bb,
1722 0xf90465b6, 1726 0x50f90465,
1723 0x04659450, 1727 0xbb046594,
1724 0xbd0256bb, 1728 0x50bd0256,
1725 0x0475fd50, 1729 0xfc0475fd,
1726 0x21f550fc, 1730 0x4e21f550,
1727 0x64b60914, 1731 0x0464b608,
1728 0x6a11f404, 1732 0xbd025bb9,
1729 0xbbe05bcb, 1733 0x430ef474,
1730 0x65b60076, 1734/* 0x0b30: i2c_recv_not_rd08 */
1731 0x9450f904, 1735 0xf401d6b0,
1732 0x56bb0465, 1736 0x57f03d1b,
1733 0xfd50bd02, 1737 0xb621f500,
1734 0x50fc0475, 1738 0x3311f409,
1735 0x085921f5, 1739 0xf5e0c5c7,
1736 0xb90464b6, 1740 0xf4095b21,
1737 0x74bd025b, 1741 0x57f02911,
1738/* 0x0b3b: i2c_recv_not_rd08 */ 1742 0xb621f500,
1739 0xb0430ef4, 1743 0x1f11f409,
1740 0x1bf401d6, 1744 0xf5e0b5c7,
1741 0x0057f03d, 1745 0xf4095b21,
1742 0x09c121f5, 1746 0x21f51511,
1743 0xc73311f4, 1747 0x74bd084e,
1744 0x21f5e0c5, 1748 0xf408c5c7,
1745 0x11f40966, 1749 0x32f4091b,
1746 0x0057f029, 1750 0x030ef402,
1747 0x09c121f5, 1751/* 0x0b70: i2c_recv_not_wr08 */
1748 0xc71f11f4, 1752/* 0x0b70: i2c_recv_done */
1749 0x21f5e0b5, 1753 0xf5f8cec7,
1750 0x11f40966, 1754 0xfc0a1b21,
1751 0x5921f515, 1755 0xf4d0fce0,
1752 0xc774bd08, 1756 0x7cb90a12,
1753 0x1bf408c5, 1757 0x3721f502,
1754 0x0232f409, 1758/* 0x0b85: i2c_recv_exit */
1755/* 0x0b7b: i2c_recv_not_wr08 */ 1759/* 0x0b87: i2c_init */
1756/* 0x0b7b: i2c_recv_done */ 1760 0xf800f803,
1757 0xc7030ef4, 1761/* 0x0b89: test_recv */
1758 0x21f5f8ce, 1762 0xd817f100,
1759 0xe0fc0a26, 1763 0x0614b605,
1760 0x12f4d0fc, 1764 0xb60011cf,
1761 0x027cb90a, 1765 0x07f10110,
1762 0x034221f5, 1766 0x04b605d8,
1763/* 0x0b90: i2c_recv_exit */ 1767 0x0001d006,
1764/* 0x0b92: i2c_init */ 1768 0xe7f104bd,
1769 0xe3f1d900,
1770 0x21f5134f,
1771 0x00f80257,
1772/* 0x0bb0: test_init */
1773 0x0800e7f1,
1774 0x025721f5,
1775/* 0x0bba: idle_recv */
1765 0x00f800f8, 1776 0x00f800f8,
1766/* 0x0b94: test_recv */ 1777/* 0x0bbc: idle */
1767 0x05d817f1, 1778 0xf10031f4,
1768 0xcf0614b6, 1779 0xb605d417,
1769 0x10b60011, 1780 0x11cf0614,
1770 0xd807f101, 1781 0x0110b600,
1771 0x0604b605, 1782 0x05d407f1,
1772 0xbd0001d0, 1783 0xd00604b6,
1773 0x00e7f104, 1784 0x04bd0001,
1774 0x4fe3f1d9, 1785/* 0x0bd8: idle_loop */
1775 0x6221f513, 1786 0xf45817f0,
1776/* 0x0bbb: test_init */ 1787/* 0x0bde: idle_proc */
1777 0xf100f802, 1788/* 0x0bde: idle_proc_exec */
1778 0xf50800e7, 1789 0x10f90232,
1779 0xf8026221, 1790 0xf5021eb9,
1780/* 0x0bc5: idle_recv */ 1791 0xfc034021,
1781/* 0x0bc7: idle */ 1792 0x0911f410,
1782 0xf400f800, 1793 0xf40231f4,
1783 0x17f10031, 1794/* 0x0bf2: idle_proc_next */
1784 0x14b605d4, 1795 0x10b6ef0e,
1785 0x0011cf06, 1796 0x061fb858,
1786 0xf10110b6, 1797 0xf4e61bf4,
1787 0xb605d407, 1798 0x28f4dd02,
1788 0x01d00604, 1799 0xbb0ef400,
1789/* 0x0be3: idle_loop */ 1800 0x00000000,
1790 0xf004bd00, 1801 0x00000000,
1791 0x32f45817, 1802 0x00000000,
1792/* 0x0be9: idle_proc */
1793/* 0x0be9: idle_proc_exec */
1794 0xb910f902,
1795 0x21f5021e,
1796 0x10fc034b,
1797 0xf40911f4,
1798 0x0ef40231,
1799/* 0x0bfd: idle_proc_next */
1800 0x5810b6ef,
1801 0xf4061fb8,
1802 0x02f4e61b,
1803 0x0028f4dd,
1804 0x00bb0ef4,
1805 0x00000000, 1803 0x00000000,
1806 0x00000000, 1804 0x00000000,
1807 0x00000000, 1805 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf119.fuc4.h b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf119.fuc4.h
index 31552af9b06e..7bf6b39ed205 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf119.fuc4.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf119.fuc4.h
@@ -24,8 +24,8 @@ uint32_t gf119_pmu_data[] = {
24 0x00000000, 24 0x00000000,
25/* 0x0058: proc_list_head */ 25/* 0x0058: proc_list_head */
26 0x54534f48, 26 0x54534f48,
27 0x0000049d, 27 0x00000492,
28 0x00000446, 28 0x0000043b,
29 0x00000000, 29 0x00000000,
30 0x00000000, 30 0x00000000,
31 0x00000000, 31 0x00000000,
@@ -46,8 +46,8 @@ uint32_t gf119_pmu_data[] = {
46 0x00000000, 46 0x00000000,
47 0x00000000, 47 0x00000000,
48 0x584d454d, 48 0x584d454d,
49 0x0000068b, 49 0x00000680,
50 0x0000067d, 50 0x00000672,
51 0x00000000, 51 0x00000000,
52 0x00000000, 52 0x00000000,
53 0x00000000, 53 0x00000000,
@@ -68,8 +68,8 @@ uint32_t gf119_pmu_data[] = {
68 0x00000000, 68 0x00000000,
69 0x00000000, 69 0x00000000,
70 0x46524550, 70 0x46524550,
71 0x0000068f, 71 0x00000684,
72 0x0000068d, 72 0x00000682,
73 0x00000000, 73 0x00000000,
74 0x00000000, 74 0x00000000,
75 0x00000000, 75 0x00000000,
@@ -90,8 +90,8 @@ uint32_t gf119_pmu_data[] = {
90 0x00000000, 90 0x00000000,
91 0x00000000, 91 0x00000000,
92 0x5f433249, 92 0x5f433249,
93 0x00000aaa, 93 0x00000a9f,
94 0x0000094d, 94 0x00000942,
95 0x00000000, 95 0x00000000,
96 0x00000000, 96 0x00000000,
97 0x00000000, 97 0x00000000,
@@ -112,8 +112,8 @@ uint32_t gf119_pmu_data[] = {
112 0x00000000, 112 0x00000000,
113 0x00000000, 113 0x00000000,
114 0x54534554, 114 0x54534554,
115 0x00000acd, 115 0x00000ac2,
116 0x00000aac, 116 0x00000aa1,
117 0x00000000, 117 0x00000000,
118 0x00000000, 118 0x00000000,
119 0x00000000, 119 0x00000000,
@@ -134,8 +134,8 @@ uint32_t gf119_pmu_data[] = {
134 0x00000000, 134 0x00000000,
135 0x00000000, 135 0x00000000,
136 0x454c4449, 136 0x454c4449,
137 0x00000ad9, 137 0x00000ace,
138 0x00000ad7, 138 0x00000acc,
139 0x00000000, 139 0x00000000,
140 0x00000000, 140 0x00000000,
141 0x00000000, 141 0x00000000,
@@ -229,26 +229,26 @@ uint32_t gf119_pmu_data[] = {
229/* 0x0370: memx_func_head */ 229/* 0x0370: memx_func_head */
230 0x00000001, 230 0x00000001,
231 0x00000000, 231 0x00000000,
232 0x000004d3, 232 0x000004c8,
233/* 0x037c: memx_func_next */ 233/* 0x037c: memx_func_next */
234 0x00000002, 234 0x00000002,
235 0x00000000, 235 0x00000000,
236 0x00000554, 236 0x00000549,
237 0x00000003, 237 0x00000003,
238 0x00000002, 238 0x00000002,
239 0x000005d8, 239 0x000005cd,
240 0x00040004, 240 0x00040004,
241 0x00000000, 241 0x00000000,
242 0x000005f4, 242 0x000005e9,
243 0x00010005, 243 0x00010005,
244 0x00000000, 244 0x00000000,
245 0x0000060e, 245 0x00000603,
246 0x00010006, 246 0x00010006,
247 0x00000000, 247 0x00000000,
248 0x000005d3, 248 0x000005c8,
249 0x00000007, 249 0x00000007,
250 0x00000000, 250 0x00000000,
251 0x00000619, 251 0x0000060e,
252/* 0x03c4: memx_func_tail */ 252/* 0x03c4: memx_func_tail */
253/* 0x03c4: memx_ts_start */ 253/* 0x03c4: memx_ts_start */
254 0x00000000, 254 0x00000000,
@@ -916,7 +916,7 @@ uint32_t gf119_pmu_data[] = {
916}; 916};
917 917
918uint32_t gf119_pmu_code[] = { 918uint32_t gf119_pmu_code[] = {
919 0x034d0ef5, 919 0x03420ef5,
920/* 0x0004: rd32 */ 920/* 0x0004: rd32 */
921 0x07a007f1, 921 0x07a007f1,
922 0xbd000ed0, 922 0xbd000ed0,
@@ -977,7 +977,7 @@ uint32_t gf119_pmu_code[] = {
977 0xbb9a0a98, 977 0xbb9a0a98,
978 0x1cf4029a, 978 0x1cf4029a,
979 0x01d7f00f, 979 0x01d7f00f,
980 0x028c21f5, 980 0x028121f5,
981 0x0ef494bd, 981 0x0ef494bd,
982/* 0x00d5: intr_watchdog_next_time */ 982/* 0x00d5: intr_watchdog_next_time */
983 0x9b0a9815, 983 0x9b0a9815,
@@ -1025,716 +1025,714 @@ uint32_t gf119_pmu_code[] = {
1025 0xf14f48e7, 1025 0xf14f48e7,
1026 0xf05453e3, 1026 0xf05453e3,
1027 0x21f500d7, 1027 0x21f500d7,
1028 0xc0fc02f1, 1028 0xc0fc02e6,
1029 0x04c007f1, 1029 0x04c007f1,
1030 0xbd000cd0, 1030 0xbd000cd0,
1031/* 0x0185: intr_subintr_skip_fifo */ 1031/* 0x0185: intr_subintr_skip_fifo */
1032 0x8807f104, 1032 0x8807f104,
1033 0x0009d006, 1033 0x0009d006,
1034/* 0x018e: intr_skip_subintr */ 1034/* 0x018e: intr_skip_subintr */
1035 0x89c404bd, 1035 0x97f104bd,
1036 0x070bf420, 1036 0x90bd00e0,
1037 0xffbfa4f1, 1037 0xf00489fd,
1038/* 0x0198: intr_skip_pause */ 1038 0x08d00407,
1039 0xf44089c4, 1039 0xfc04bd00,
1040 0xa4f1070b, 1040 0x0088fe80,
1041/* 0x01a2: intr_skip_user0 */ 1041 0xe0fcf0fc,
1042 0x07f0ffbf, 1042 0xc0fcd0fc,
1043 0x0008d004, 1043 0xa0fcb0fc,
1044 0x80fc04bd, 1044 0x80fc90fc,
1045 0xfc0088fe, 1045 0x32f400fc,
1046 0xfce0fcf0, 1046/* 0x01bb: ticks_from_ns */
1047 0xfcc0fcd0, 1047 0xf901f800,
1048 0xfca0fcb0,
1049 0xfc80fc90,
1050 0x0032f400,
1051/* 0x01c6: ticks_from_ns */
1052 0xc0f901f8,
1053 0xd7f1b0f9,
1054 0xd3f00144,
1055 0xb321f500,
1056 0xe8ccec03,
1057 0x00b4b003,
1058 0xec120bf4,
1059 0xf103e8ee,
1060 0xf00144d7,
1061 0x21f500d3,
1062/* 0x01ee: ticks_from_ns_quit */
1063 0xceb903b3,
1064 0xfcb0fc02,
1065/* 0x01f7: ticks_from_us */
1066 0xf900f8c0,
1067 0xf1b0f9c0, 1048 0xf1b0f9c0,
1068 0xf00144d7, 1049 0xf00144d7,
1069 0x21f500d3, 1050 0x21f500d3,
1070 0xceb903b3, 1051 0xccec03a8,
1071 0x00b4b002, 1052 0xb4b003e8,
1072 0xbd050bf4, 1053 0x120bf400,
1073/* 0x0211: ticks_from_us_quit */ 1054 0x03e8eeec,
1074 0xfcb0fce4, 1055 0x0144d7f1,
1075/* 0x0217: ticks_to_us */ 1056 0xf500d3f0,
1076 0xf100f8c0, 1057/* 0x01e3: ticks_from_ns_quit */
1077 0xf00144d7, 1058 0xb903a821,
1078 0xedff00d3, 1059 0xb0fc02ce,
1079/* 0x0223: timer */ 1060 0x00f8c0fc,
1080 0xf900f8ec, 1061/* 0x01ec: ticks_from_us */
1081 0xf480f990, 1062 0xb0f9c0f9,
1082 0xf8981032, 1063 0x0144d7f1,
1083 0x0086b003, 1064 0xf500d3f0,
1084 0xbd531cf4, 1065 0xb903a821,
1085 0x3807f084, 1066 0xb4b002ce,
1086 0xbd0008d0, 1067 0x050bf400,
1087 0x3487f004, 1068/* 0x0206: ticks_from_us_quit */
1088 0x980088cf, 1069 0xb0fce4bd,
1089 0x98bb9a09, 1070 0x00f8c0fc,
1090 0x00e9bb02, 1071/* 0x020c: ticks_to_us */
1091 0xf003fe80, 1072 0x0144d7f1,
1092 0x88cf0887, 1073 0xff00d3f0,
1093 0x0284f000, 1074 0x00f8eced,
1094 0xf0201bf4, 1075/* 0x0218: timer */
1095 0x88cf3487, 1076 0x80f990f9,
1096 0x06e0b800, 1077 0x981032f4,
1097 0xb8090bf4, 1078 0x86b003f8,
1098 0x1cf406e8, 1079 0x531cf400,
1099/* 0x026d: timer_reset */ 1080 0x07f084bd,
1100 0x3407f00e, 1081 0x0008d038,
1101 0xbd000ed0, 1082 0x87f004bd,
1102 0x9a0e8004, 1083 0x0088cf34,
1103/* 0x0278: timer_enable */ 1084 0xbb9a0998,
1104 0xf00187f0, 1085 0xe9bb0298,
1105 0x08d03807, 1086 0x03fe8000,
1106/* 0x0283: timer_done */ 1087 0xcf0887f0,
1107 0xf404bd00, 1088 0x84f00088,
1108 0x80fc1031, 1089 0x201bf402,
1109 0x00f890fc, 1090 0xcf3487f0,
1110/* 0x028c: send_proc */ 1091 0xe0b80088,
1111 0x90f980f9, 1092 0x090bf406,
1112 0x9805e898, 1093 0xf406e8b8,
1113 0x86f004e9, 1094/* 0x0262: timer_reset */
1114 0x0689b804, 1095 0x07f00e1c,
1115 0xc42a0bf4, 1096 0x000ed034,
1116 0x88940398, 1097 0x0e8004bd,
1117 0x1880b604, 1098/* 0x026d: timer_enable */
1118 0x98008ebb, 1099 0x0187f09a,
1119 0x8a8000fa, 1100 0xd03807f0,
1120 0x018d8000, 1101 0x04bd0008,
1121 0x80028c80, 1102/* 0x0278: timer_done */
1122 0x90b6038b, 1103 0xfc1031f4,
1123 0x0794f001,
1124 0xf404e980,
1125/* 0x02c6: send_done */
1126 0x90fc0231,
1127 0x00f880fc,
1128/* 0x02cc: find */
1129 0x87f080f9,
1130 0x0131f458,
1131/* 0x02d4: find_loop */
1132 0xb8008a98,
1133 0x0bf406ae,
1134 0x5880b610,
1135 0x026886b1,
1136 0xf4f01bf4,
1137/* 0x02ea: find_done */
1138 0x8eb90132,
1139 0xf880fc02,
1140/* 0x02f1: send */
1141 0xcc21f500,
1142 0x9701f402,
1143/* 0x02fa: recv */
1144 0x90f900f8,
1145 0xe89880f9,
1146 0x04e99805,
1147 0xb80132f4,
1148 0x0bf40689,
1149 0x0389c43d,
1150 0xf00180b6,
1151 0xe8800784,
1152 0x02ea9805,
1153 0x8ffef0f9,
1154 0xb9f0f901,
1155 0x999402ef,
1156 0x00e9bb04,
1157 0x9818e0b6,
1158 0xec9803eb,
1159 0x01ed9802,
1160 0xf900ee98,
1161 0xfef0fca5,
1162 0x31f400f8,
1163/* 0x0347: recv_done */
1164 0xfcf0fc01,
1165 0xf890fc80, 1104 0xf890fc80,
1166/* 0x034d: init */ 1105/* 0x0281: send_proc */
1167 0x0817f100, 1106 0xf980f900,
1168 0x0011cf01, 1107 0x05e89890,
1169 0x010911e7, 1108 0xf004e998,
1170 0xfe0814b6, 1109 0x89b80486,
1171 0x17f10014, 1110 0x2a0bf406,
1172 0x13f000e0, 1111 0x940398c4,
1173 0x1c07f000, 1112 0x80b60488,
1113 0x008ebb18,
1114 0x8000fa98,
1115 0x8d80008a,
1116 0x028c8001,
1117 0xb6038b80,
1118 0x94f00190,
1119 0x04e98007,
1120/* 0x02bb: send_done */
1121 0xfc0231f4,
1122 0xf880fc90,
1123/* 0x02c1: find */
1124 0xf080f900,
1125 0x31f45887,
1126/* 0x02c9: find_loop */
1127 0x008a9801,
1128 0xf406aeb8,
1129 0x80b6100b,
1130 0x6886b158,
1131 0xf01bf402,
1132/* 0x02df: find_done */
1133 0xb90132f4,
1134 0x80fc028e,
1135/* 0x02e6: send */
1136 0x21f500f8,
1137 0x01f402c1,
1138/* 0x02ef: recv */
1139 0xf900f897,
1140 0x9880f990,
1141 0xe99805e8,
1142 0x0132f404,
1143 0xf40689b8,
1144 0x89c43d0b,
1145 0x0180b603,
1146 0x800784f0,
1147 0xea9805e8,
1148 0xfef0f902,
1149 0xf0f9018f,
1150 0x9402efb9,
1151 0xe9bb0499,
1152 0x18e0b600,
1153 0x9803eb98,
1154 0xed9802ec,
1155 0x00ee9801,
1156 0xf0fca5f9,
1157 0xf400f8fe,
1158 0xf0fc0131,
1159/* 0x033c: recv_done */
1160 0x90fc80fc,
1161/* 0x0342: init */
1162 0x17f100f8,
1163 0x11cf0108,
1164 0x0911e700,
1165 0x0814b601,
1166 0xf10014fe,
1167 0xf000e017,
1168 0x07f00013,
1169 0x0001d01c,
1170 0x17f004bd,
1171 0x1407f0ff,
1174 0xbd0001d0, 1172 0xbd0001d0,
1175 0xff17f004, 1173 0x0217f004,
1176 0xd01407f0, 1174 0x080015f1,
1175 0xd01007f0,
1177 0x04bd0001, 1176 0x04bd0001,
1178 0xf10217f0, 1177 0x00f617f1,
1179 0xf0080015, 1178 0xfe0013f0,
1180 0x01d01007, 1179 0x31f40010,
1181 0xf104bd00, 1180 0x0117f010,
1182 0xf000f617, 1181 0xd03807f0,
1183 0x10fe0013, 1182 0x04bd0001,
1184 0x1031f400, 1183/* 0x0397: init_proc */
1185 0xf00117f0, 1184 0x9858f7f0,
1186 0x01d03807, 1185 0x16b001f1,
1187 0xf004bd00, 1186 0xfa0bf400,
1188/* 0x03a2: init_proc */ 1187 0xf0b615f9,
1189 0xf19858f7, 1188 0xf20ef458,
1190 0x0016b001, 1189/* 0x03a8: mulu32_32_64 */
1191 0xf9fa0bf4, 1190 0x20f910f9,
1192 0x58f0b615, 1191 0x40f930f9,
1193/* 0x03b3: mulu32_32_64 */ 1192 0x9510e195,
1194 0xf9f20ef4, 1193 0xc4bd10d2,
1195 0xf920f910, 1194 0xedffb4bd,
1196 0x9540f930, 1195 0x301dffc0,
1197 0xd29510e1, 1196 0xf10234b9,
1198 0xbdc4bd10, 1197 0xb6ffff34,
1199 0xc0edffb4, 1198 0x45b61034,
1200 0xb9301dff, 1199 0x00c3bb10,
1201 0x34f10234, 1200 0xff01b4bb,
1202 0x34b6ffff, 1201 0x34b930e2,
1203 0x1045b610, 1202 0xff34f102,
1204 0xbb00c3bb, 1203 0x1034b6ff,
1205 0xe2ff01b4, 1204 0xbb1045b6,
1206 0x0234b930, 1205 0xb4bb00c3,
1207 0xffff34f1, 1206 0x3012ff01,
1208 0xb61034b6, 1207 0xfc00b3bb,
1209 0xc3bb1045, 1208 0xfc30fc40,
1210 0x01b4bb00, 1209 0xf810fc20,
1211 0xbb3012ff, 1210/* 0x03f9: host_send */
1212 0x40fc00b3, 1211 0xb017f100,
1213 0x20fc30fc, 1212 0x0011cf04,
1214 0x00f810fc, 1213 0x04a027f1,
1215/* 0x0404: host_send */ 1214 0xb80022cf,
1216 0x04b017f1, 1215 0x0bf40612,
1217 0xf10011cf, 1216 0x071ec42f,
1218 0xcf04a027, 1217 0xb704ee94,
1219 0x12b80022, 1218 0x980270e0,
1220 0x2f0bf406, 1219 0xec9803eb,
1221 0x94071ec4, 1220 0x01ed9802,
1222 0xe0b704ee, 1221 0xf500ee98,
1223 0xeb980270, 1222 0xb602e621,
1224 0x02ec9803, 1223 0x1ec40110,
1225 0x9801ed98, 1224 0xb007f10f,
1226 0x21f500ee, 1225 0x000ed004,
1227 0x10b602f1, 1226 0x0ef404bd,
1228 0x0f1ec401, 1227/* 0x0439: host_send_done */
1229 0x04b007f1, 1228/* 0x043b: host_recv */
1230 0xbd000ed0, 1229 0xf100f8c3,
1231 0xc30ef404, 1230 0xf14e4917,
1232/* 0x0444: host_send_done */ 1231 0xb8525413,
1233/* 0x0446: host_recv */ 1232 0x0bf406e1,
1234 0x17f100f8, 1233/* 0x0449: host_recv_wait */
1235 0x13f14e49, 1234 0xcc17f1b3,
1236 0xe1b85254, 1235 0x0011cf04,
1237 0xb30bf406, 1236 0x04c827f1,
1238/* 0x0454: host_recv_wait */ 1237 0xf00022cf,
1239 0x04cc17f1, 1238 0x12b80816,
1240 0xf10011cf, 1239 0xec0bf406,
1241 0xcf04c827, 1240 0xb60723c4,
1242 0x16f00022, 1241 0x30b70434,
1243 0x0612b808, 1242 0x3b8002f0,
1244 0xc4ec0bf4, 1243 0x023c8003,
1245 0x34b60723, 1244 0x80013d80,
1246 0xf030b704, 1245 0x20b6003e,
1247 0x033b8002, 1246 0x0f24f001,
1248 0x80023c80, 1247 0x04c807f1,
1249 0x3e80013d, 1248 0xbd0002d0,
1250 0x0120b600, 1249 0x4027f004,
1251 0xf10f24f0, 1250 0xd00007f0,
1252 0xd004c807,
1253 0x04bd0002, 1251 0x04bd0002,
1254 0xf04027f0, 1252/* 0x0492: host_init */
1255 0x02d00007, 1253 0x17f100f8,
1256 0xf804bd00, 1254 0x14b60080,
1257/* 0x049d: host_init */ 1255 0x7015f110,
1258 0x8017f100, 1256 0xd007f102,
1259 0x1014b600, 1257 0x0001d004,
1260 0x027015f1, 1258 0x17f104bd,
1261 0x04d007f1, 1259 0x14b60080,
1262 0xbd0001d0, 1260 0xf015f110,
1263 0x8017f104, 1261 0xdc07f102,
1264 0x1014b600, 1262 0x0001d004,
1265 0x02f015f1, 1263 0x17f004bd,
1266 0x04dc07f1, 1264 0xc407f101,
1267 0xbd0001d0, 1265 0x0001d004,
1268 0x0117f004, 1266 0x00f804bd,
1269 0x04c407f1, 1267/* 0x04c8: memx_func_enter */
1270 0xbd0001d0, 1268 0x162067f1,
1271/* 0x04d3: memx_func_enter */ 1269 0xf55d77f1,
1272 0xf100f804, 1270 0xffff73f1,
1273 0xf1162067, 1271 0xf4026eb9,
1274 0xf1f55d77, 1272 0xd8b90421,
1273 0x0487fd02,
1274 0x80f960f9,
1275 0xe0fcd0fc,
1276 0xf13321f4,
1277 0xf1fffe77,
1275 0xb9ffff73, 1278 0xb9ffff73,
1276 0x21f4026e, 1279 0x21f4026e,
1277 0x02d8b904, 1280 0x02d8b904,
1278 0xf90487fd, 1281 0xf90487fd,
1279 0xfc80f960, 1282 0xfc80f960,
1280 0xf4e0fcd0, 1283 0xf4e0fcd0,
1281 0x77f13321, 1284 0x67f13321,
1282 0x73f1fffe, 1285 0x6eb926f0,
1283 0x6eb9ffff,
1284 0x0421f402, 1286 0x0421f402,
1285 0xfd02d8b9, 1287 0xfd02d8b9,
1286 0x60f90487, 1288 0x60f90487,
1287 0xd0fc80f9, 1289 0xd0fc80f9,
1288 0x21f4e0fc, 1290 0x21f4e0fc,
1289 0xf067f133, 1291 0x0467f033,
1290 0x026eb926, 1292 0x07e007f1,
1291 0xb90421f4,
1292 0x87fd02d8,
1293 0xf960f904,
1294 0xfcd0fc80,
1295 0x3321f4e0,
1296 0xf10467f0,
1297 0xd007e007,
1298 0x04bd0006,
1299/* 0x053c: memx_func_enter_wait */
1300 0x07c067f1,
1301 0xf00066cf,
1302 0x0bf40464,
1303 0x2c67f0f6,
1304 0x800066cf,
1305 0x00f8f106,
1306/* 0x0554: memx_func_leave */
1307 0xcf2c67f0,
1308 0x06800066,
1309 0x0467f0f2,
1310 0x07e407f1,
1311 0xbd0006d0, 1293 0xbd0006d0,
1312/* 0x0569: memx_func_leave_wait */ 1294/* 0x0531: memx_func_enter_wait */
1313 0xc067f104, 1295 0xc067f104,
1314 0x0066cf07, 1296 0x0066cf07,
1315 0xf40464f0, 1297 0xf40464f0,
1316 0x67f1f61b, 1298 0x67f0f60b,
1317 0x77f126f0, 1299 0x0066cf2c,
1318 0x73f00001, 1300 0xf8f10680,
1319 0x026eb900, 1301/* 0x0549: memx_func_leave */
1320 0xb90421f4, 1302 0x2c67f000,
1321 0x87fd02d8, 1303 0x800066cf,
1322 0xf960f905, 1304 0x67f0f206,
1323 0xfcd0fc80, 1305 0xe407f104,
1324 0x3321f4e0, 1306 0x0006d007,
1325 0x162067f1, 1307/* 0x055e: memx_func_leave_wait */
1326 0xf4026eb9, 1308 0x67f104bd,
1327 0xd8b90421, 1309 0x66cf07c0,
1328 0x0587fd02, 1310 0x0464f000,
1329 0x80f960f9, 1311 0xf1f61bf4,
1330 0xe0fcd0fc, 1312 0xf126f067,
1331 0xf13321f4, 1313 0xf0000177,
1332 0xf00aa277,
1333 0x6eb90073, 1314 0x6eb90073,
1334 0x0421f402, 1315 0x0421f402,
1335 0xfd02d8b9, 1316 0xfd02d8b9,
1336 0x60f90587, 1317 0x60f90587,
1337 0xd0fc80f9, 1318 0xd0fc80f9,
1338 0x21f4e0fc, 1319 0x21f4e0fc,
1339/* 0x05d3: memx_func_wait_vblank */ 1320 0x2067f133,
1340 0xb600f833, 1321 0x026eb916,
1341 0x00f80410, 1322 0xb90421f4,
1342/* 0x05d8: memx_func_wr32 */ 1323 0x87fd02d8,
1343 0x98001698, 1324 0xf960f905,
1344 0x10b60115, 1325 0xfcd0fc80,
1345 0xf960f908,
1346 0xfcd0fc50,
1347 0x3321f4e0, 1326 0x3321f4e0,
1348 0xf40242b6, 1327 0x0aa277f1,
1349 0x00f8e91b, 1328 0xb90073f0,
1350/* 0x05f4: memx_func_wait */ 1329 0x21f4026e,
1351 0xcf2c87f0, 1330 0x02d8b904,
1352 0x1e980088, 1331 0xf90587fd,
1353 0x011d9800, 1332 0xfc80f960,
1354 0x98021c98, 1333 0xf4e0fcd0,
1355 0x10b6031b, 1334 0x00f83321,
1356 0x8621f410, 1335/* 0x05c8: memx_func_wait_vblank */
1357/* 0x060e: memx_func_delay */ 1336 0xf80410b6,
1358 0x1e9800f8, 1337/* 0x05cd: memx_func_wr32 */
1338 0x00169800,
1339 0xb6011598,
1340 0x60f90810,
1341 0xd0fc50f9,
1342 0x21f4e0fc,
1343 0x0242b633,
1344 0xf8e91bf4,
1345/* 0x05e9: memx_func_wait */
1346 0x2c87f000,
1347 0x980088cf,
1348 0x1d98001e,
1349 0x021c9801,
1350 0xb6031b98,
1351 0x21f41010,
1352/* 0x0603: memx_func_delay */
1353 0x9800f886,
1354 0x10b6001e,
1355 0x6721f404,
1356/* 0x060e: memx_func_train */
1357 0x00f800f8,
1358/* 0x0610: memx_exec */
1359 0xd0f9e0f9,
1360 0xb902c1b9,
1361/* 0x061a: memx_exec_next */
1362 0x139802b2,
1359 0x0410b600, 1363 0x0410b600,
1360 0xf86721f4, 1364 0x01f034e7,
1361/* 0x0619: memx_func_train */ 1365 0x01e033e7,
1362/* 0x061b: memx_exec */ 1366 0xf00132b6,
1363 0xf900f800, 1367 0x35980c30,
1364 0xb9d0f9e0, 1368 0xb855f9de,
1365 0xb2b902c1, 1369 0x1ef40612,
1366/* 0x0625: memx_exec_next */ 1370 0xf10b98e4,
1367 0x00139802, 1371 0xbbf20c98,
1368 0xe70410b6, 1372 0xb7f102cb,
1369 0xe701f034, 1373 0xbbcf07c4,
1370 0xb601e033, 1374 0xfcd0fc00,
1371 0x30f00132, 1375 0xe621f5e0,
1372 0xde35980c, 1376/* 0x0653: memx_info */
1373 0x12b855f9, 1377 0x7000f802,
1374 0xe41ef406, 1378 0x0bf401c6,
1375 0x98f10b98, 1379/* 0x0659: memx_info_data */
1376 0xcbbbf20c, 1380 0xccc7f10e,
1377 0xc4b7f102, 1381 0x00b7f103,
1378 0x00bbcf07, 1382 0x0b0ef408,
1379 0xe0fcd0fc, 1383/* 0x0664: memx_info_train */
1380 0x02f121f5, 1384 0x0bccc7f1,
1381/* 0x065e: memx_info */ 1385 0x0100b7f1,
1382 0xc67000f8, 1386/* 0x066c: memx_info_send */
1383 0x0e0bf401, 1387 0x02e621f5,
1384/* 0x0664: memx_info_data */ 1388/* 0x0672: memx_recv */
1385 0x03ccc7f1, 1389 0xd6b000f8,
1386 0x0800b7f1, 1390 0x9b0bf401,
1387/* 0x066f: memx_info_train */ 1391 0xf400d6b0,
1388 0xf10b0ef4, 1392 0x00f8d80b,
1389 0xf10bccc7, 1393/* 0x0680: memx_init */
1390/* 0x0677: memx_info_send */ 1394/* 0x0682: perf_recv */
1391 0xf50100b7, 1395 0x00f800f8,
1392 0xf802f121, 1396/* 0x0684: perf_init */
1393/* 0x067d: memx_recv */ 1397/* 0x0686: i2c_drive_scl */
1394 0x01d6b000, 1398 0x36b000f8,
1395 0xb09b0bf4, 1399 0x0e0bf400,
1396 0x0bf400d6, 1400 0x07e007f1,
1397/* 0x068b: memx_init */ 1401 0xbd0001d0,
1398 0xf800f8d8, 1402/* 0x0697: i2c_drive_scl_lo */
1399/* 0x068d: perf_recv */ 1403 0xf100f804,
1400/* 0x068f: perf_init */ 1404 0xd007e407,
1401 0xf800f800,
1402/* 0x0691: i2c_drive_scl */
1403 0x0036b000,
1404 0xf10e0bf4,
1405 0xd007e007,
1406 0x04bd0001, 1405 0x04bd0001,
1407/* 0x06a2: i2c_drive_scl_lo */ 1406/* 0x06a2: i2c_drive_sda */
1408 0x07f100f8, 1407 0x36b000f8,
1409 0x01d007e4, 1408 0x0e0bf400,
1410 0xf804bd00, 1409 0x07e007f1,
1411/* 0x06ad: i2c_drive_sda */ 1410 0xbd0002d0,
1412 0x0036b000, 1411/* 0x06b3: i2c_drive_sda_lo */
1413 0xf10e0bf4, 1412 0xf100f804,
1414 0xd007e007, 1413 0xd007e407,
1415 0x04bd0002, 1414 0x04bd0002,
1416/* 0x06be: i2c_drive_sda_lo */ 1415/* 0x06be: i2c_sense_scl */
1417 0x07f100f8,
1418 0x02d007e4,
1419 0xf804bd00,
1420/* 0x06c9: i2c_sense_scl */
1421 0x0132f400,
1422 0x07c437f1,
1423 0xfd0033cf,
1424 0x0bf40431,
1425 0x0131f406,
1426/* 0x06dc: i2c_sense_scl_done */
1427/* 0x06de: i2c_sense_sda */
1428 0x32f400f8, 1416 0x32f400f8,
1429 0xc437f101, 1417 0xc437f101,
1430 0x0033cf07, 1418 0x0033cf07,
1431 0xf40432fd, 1419 0xf40431fd,
1432 0x31f4060b, 1420 0x31f4060b,
1433/* 0x06f1: i2c_sense_sda_done */ 1421/* 0x06d1: i2c_sense_scl_done */
1434/* 0x06f3: i2c_raise_scl */ 1422/* 0x06d3: i2c_sense_sda */
1435 0xf900f801, 1423 0xf400f801,
1436 0x9847f140, 1424 0x37f10132,
1437 0x0137f008, 1425 0x33cf07c4,
1438 0x069121f5, 1426 0x0432fd00,
1439/* 0x0700: i2c_raise_scl_wait */ 1427 0xf4060bf4,
1440 0x03e8e7f1, 1428/* 0x06e6: i2c_sense_sda_done */
1441 0xf56721f4, 1429 0x00f80131,
1442 0xf406c921, 1430/* 0x06e8: i2c_raise_scl */
1443 0x42b60901, 1431 0x47f140f9,
1444 0xef1bf401, 1432 0x37f00898,
1445/* 0x0714: i2c_raise_scl_done */ 1433 0x8621f501,
1446 0x00f840fc, 1434/* 0x06f5: i2c_raise_scl_wait */
1447/* 0x0718: i2c_start */ 1435 0xe8e7f106,
1448 0x06c921f5, 1436 0x6721f403,
1449 0xf50d11f4, 1437 0x06be21f5,
1450 0xf406de21, 1438 0xb60901f4,
1451 0x0ef40611, 1439 0x1bf40142,
1452/* 0x0729: i2c_start_rep */ 1440/* 0x0709: i2c_raise_scl_done */
1453 0x0037f030, 1441 0xf840fcef,
1454 0x069121f5, 1442/* 0x070d: i2c_start */
1443 0xbe21f500,
1444 0x0d11f406,
1445 0x06d321f5,
1446 0xf40611f4,
1447/* 0x071e: i2c_start_rep */
1448 0x37f0300e,
1449 0x8621f500,
1450 0x0137f006,
1451 0x06a221f5,
1452 0xb60076bb,
1453 0x50f90465,
1454 0xbb046594,
1455 0x50bd0256,
1456 0xfc0475fd,
1457 0xe821f550,
1458 0x0464b606,
1459/* 0x074b: i2c_start_send */
1460 0xf01f11f4,
1461 0x21f50037,
1462 0xe7f106a2,
1463 0x21f41388,
1464 0x0037f067,
1465 0x068621f5,
1466 0x1388e7f1,
1467/* 0x0767: i2c_start_out */
1468 0xf86721f4,
1469/* 0x0769: i2c_stop */
1470 0x0037f000,
1471 0x068621f5,
1472 0xf50037f0,
1473 0xf106a221,
1474 0xf403e8e7,
1475 0x37f06721,
1476 0x8621f501,
1477 0x88e7f106,
1478 0x6721f413,
1455 0xf50137f0, 1479 0xf50137f0,
1456 0xbb06ad21, 1480 0xf106a221,
1481 0xf41388e7,
1482 0x00f86721,
1483/* 0x079c: i2c_bitw */
1484 0x06a221f5,
1485 0x03e8e7f1,
1486 0xbb6721f4,
1457 0x65b60076, 1487 0x65b60076,
1458 0x9450f904, 1488 0x9450f904,
1459 0x56bb0465, 1489 0x56bb0465,
1460 0xfd50bd02, 1490 0xfd50bd02,
1461 0x50fc0475, 1491 0x50fc0475,
1462 0x06f321f5, 1492 0x06e821f5,
1463 0xf40464b6, 1493 0xf40464b6,
1464/* 0x0756: i2c_start_send */ 1494 0xe7f11811,
1465 0x37f01f11,
1466 0xad21f500,
1467 0x88e7f106,
1468 0x6721f413,
1469 0xf50037f0,
1470 0xf1069121,
1471 0xf41388e7,
1472/* 0x0772: i2c_start_out */
1473 0x00f86721,
1474/* 0x0774: i2c_stop */
1475 0xf50037f0,
1476 0xf0069121,
1477 0x21f50037,
1478 0xe7f106ad,
1479 0x21f403e8,
1480 0x0137f067,
1481 0x069121f5,
1482 0x1388e7f1,
1483 0xf06721f4,
1484 0x21f50137,
1485 0xe7f106ad,
1486 0x21f41388, 1495 0x21f41388,
1487/* 0x07a7: i2c_bitw */ 1496 0x0037f067,
1488 0xf500f867, 1497 0x068621f5,
1489 0xf106ad21,
1490 0xf403e8e7,
1491 0x76bb6721,
1492 0x0465b600,
1493 0x659450f9,
1494 0x0256bb04,
1495 0x75fd50bd,
1496 0xf550fc04,
1497 0xb606f321,
1498 0x11f40464,
1499 0x88e7f118,
1500 0x6721f413,
1501 0xf50037f0,
1502 0xf1069121,
1503 0xf41388e7,
1504/* 0x07e6: i2c_bitw_out */
1505 0x00f86721,
1506/* 0x07e8: i2c_bitr */
1507 0xf50137f0,
1508 0xf106ad21,
1509 0xf403e8e7,
1510 0x76bb6721,
1511 0x0465b600,
1512 0x659450f9,
1513 0x0256bb04,
1514 0x75fd50bd,
1515 0xf550fc04,
1516 0xb606f321,
1517 0x11f40464,
1518 0xde21f51b,
1519 0x0037f006,
1520 0x069121f5,
1521 0x1388e7f1, 1498 0x1388e7f1,
1522 0xf06721f4, 1499/* 0x07db: i2c_bitw_out */
1523 0x31f4013c, 1500 0xf86721f4,
1524/* 0x082d: i2c_bitr_done */ 1501/* 0x07dd: i2c_bitr */
1525/* 0x082f: i2c_get_byte */ 1502 0x0137f000,
1526 0xf000f801, 1503 0x06a221f5,
1527 0x47f00057, 1504 0x03e8e7f1,
1528/* 0x0835: i2c_get_byte_next */ 1505 0xbb6721f4,
1529 0x0154b608, 1506 0x65b60076,
1507 0x9450f904,
1508 0x56bb0465,
1509 0xfd50bd02,
1510 0x50fc0475,
1511 0x06e821f5,
1512 0xf40464b6,
1513 0x21f51b11,
1514 0x37f006d3,
1515 0x8621f500,
1516 0x88e7f106,
1517 0x6721f413,
1518 0xf4013cf0,
1519/* 0x0822: i2c_bitr_done */
1520 0x00f80131,
1521/* 0x0824: i2c_get_byte */
1522 0xf00057f0,
1523/* 0x082a: i2c_get_byte_next */
1524 0x54b60847,
1525 0x0076bb01,
1526 0xf90465b6,
1527 0x04659450,
1528 0xbd0256bb,
1529 0x0475fd50,
1530 0x21f550fc,
1531 0x64b607dd,
1532 0x2b11f404,
1533 0xb60553fd,
1534 0x1bf40142,
1535 0x0137f0d8,
1530 0xb60076bb, 1536 0xb60076bb,
1531 0x50f90465, 1537 0x50f90465,
1532 0xbb046594, 1538 0xbb046594,
1533 0x50bd0256, 1539 0x50bd0256,
1534 0xfc0475fd, 1540 0xfc0475fd,
1535 0xe821f550, 1541 0x9c21f550,
1536 0x0464b607, 1542 0x0464b607,
1537 0xfd2b11f4, 1543/* 0x0874: i2c_get_byte_done */
1538 0x42b60553, 1544/* 0x0876: i2c_put_byte */
1539 0xd81bf401, 1545 0x47f000f8,
1540 0xbb0137f0, 1546/* 0x0879: i2c_put_byte_next */
1547 0x0142b608,
1548 0xbb3854ff,
1541 0x65b60076, 1549 0x65b60076,
1542 0x9450f904, 1550 0x9450f904,
1543 0x56bb0465, 1551 0x56bb0465,
1544 0xfd50bd02, 1552 0xfd50bd02,
1545 0x50fc0475, 1553 0x50fc0475,
1546 0x07a721f5, 1554 0x079c21f5,
1547/* 0x087f: i2c_get_byte_done */
1548 0xf80464b6,
1549/* 0x0881: i2c_put_byte */
1550 0x0847f000,
1551/* 0x0884: i2c_put_byte_next */
1552 0xff0142b6,
1553 0x76bb3854,
1554 0x0465b600,
1555 0x659450f9,
1556 0x0256bb04,
1557 0x75fd50bd,
1558 0xf550fc04,
1559 0xb607a721,
1560 0x11f40464,
1561 0x0046b034,
1562 0xbbd81bf4,
1563 0x65b60076,
1564 0x9450f904,
1565 0x56bb0465,
1566 0xfd50bd02,
1567 0x50fc0475,
1568 0x07e821f5,
1569 0xf40464b6, 1555 0xf40464b6,
1570 0x76bb0f11, 1556 0x46b03411,
1571 0x0136b000, 1557 0xd81bf400,
1572 0xf4061bf4,
1573/* 0x08da: i2c_put_byte_done */
1574 0x00f80132,
1575/* 0x08dc: i2c_addr */
1576 0xb60076bb, 1558 0xb60076bb,
1577 0x50f90465, 1559 0x50f90465,
1578 0xbb046594, 1560 0xbb046594,
1579 0x50bd0256, 1561 0x50bd0256,
1580 0xfc0475fd, 1562 0xfc0475fd,
1581 0x1821f550, 1563 0xdd21f550,
1582 0x0464b607, 1564 0x0464b607,
1583 0xe72911f4, 1565 0xbb0f11f4,
1584 0xb6012ec3, 1566 0x36b00076,
1585 0x53fd0134, 1567 0x061bf401,
1586 0x0076bb05, 1568/* 0x08cf: i2c_put_byte_done */
1569 0xf80132f4,
1570/* 0x08d1: i2c_addr */
1571 0x0076bb00,
1587 0xf90465b6, 1572 0xf90465b6,
1588 0x04659450, 1573 0x04659450,
1589 0xbd0256bb, 1574 0xbd0256bb,
1590 0x0475fd50, 1575 0x0475fd50,
1591 0x21f550fc, 1576 0x21f550fc,
1592 0x64b60881, 1577 0x64b6070d,
1593/* 0x0921: i2c_addr_done */ 1578 0x2911f404,
1594/* 0x0923: i2c_acquire_addr */ 1579 0x012ec3e7,
1595 0xc700f804, 1580 0xfd0134b6,
1596 0xe4b6f8ce, 1581 0x76bb0553,
1597 0x14e0b705, 1582 0x0465b600,
1598/* 0x092f: i2c_acquire */ 1583 0x659450f9,
1599 0xf500f8d0, 1584 0x0256bb04,
1600 0xf4092321, 1585 0x75fd50bd,
1601 0xd9f00421, 1586 0xf550fc04,
1587 0xb6087621,
1588/* 0x0916: i2c_addr_done */
1589 0x00f80464,
1590/* 0x0918: i2c_acquire_addr */
1591 0xb6f8cec7,
1592 0xe0b705e4,
1593 0x00f8d014,
1594/* 0x0924: i2c_acquire */
1595 0x091821f5,
1596 0xf00421f4,
1597 0x21f403d9,
1598/* 0x0933: i2c_release */
1599 0xf500f833,
1600 0xf4091821,
1601 0xdaf00421,
1602 0x3321f403, 1602 0x3321f403,
1603/* 0x093e: i2c_release */ 1603/* 0x0942: i2c_recv */
1604 0x21f500f8, 1604 0x32f400f8,
1605 0x21f40923, 1605 0xf8c1c701,
1606 0x03daf004, 1606 0xb00214b6,
1607 0xf83321f4, 1607 0x1ff52816,
1608/* 0x094d: i2c_recv */ 1608 0x13a0013a,
1609 0x0132f400, 1609 0x32980cf4,
1610 0xb6f8c1c7, 1610 0xcc13a000,
1611 0x16b00214, 1611 0x0031980c,
1612 0x3a1ff528, 1612 0xf90231f4,
1613 0xf413a001, 1613 0xf9e0f9d0,
1614 0x0032980c, 1614 0x0067f1d0,
1615 0x0ccc13a0, 1615 0x0063f100,
1616 0xf4003198, 1616 0x01679210,
1617 0xd0f90231, 1617 0xb60076bb,
1618 0xd0f9e0f9, 1618 0x50f90465,
1619 0x000067f1, 1619 0xbb046594,
1620 0x100063f1, 1620 0x50bd0256,
1621 0xbb016792, 1621 0xfc0475fd,
1622 0x65b60076, 1622 0x2421f550,
1623 0x9450f904, 1623 0x0464b609,
1624 0x56bb0465, 1624 0xd6b0d0fc,
1625 0xfd50bd02, 1625 0xb31bf500,
1626 0x50fc0475, 1626 0x0057f000,
1627 0x092f21f5, 1627 0xb60076bb,
1628 0xfc0464b6, 1628 0x50f90465,
1629 0x00d6b0d0, 1629 0xbb046594,
1630 0x00b31bf5, 1630 0x50bd0256,
1631 0xbb0057f0, 1631 0xfc0475fd,
1632 0xd121f550,
1633 0x0464b608,
1634 0x00d011f5,
1635 0xbbe0c5c7,
1632 0x65b60076, 1636 0x65b60076,
1633 0x9450f904, 1637 0x9450f904,
1634 0x56bb0465, 1638 0x56bb0465,
1635 0xfd50bd02, 1639 0xfd50bd02,
1636 0x50fc0475, 1640 0x50fc0475,
1637 0x08dc21f5, 1641 0x087621f5,
1638 0xf50464b6, 1642 0xf50464b6,
1639 0xc700d011, 1643 0xf000ad11,
1640 0x76bbe0c5, 1644 0x76bb0157,
1641 0x0465b600, 1645 0x0465b600,
1642 0x659450f9, 1646 0x659450f9,
1643 0x0256bb04, 1647 0x0256bb04,
1644 0x75fd50bd, 1648 0x75fd50bd,
1645 0xf550fc04, 1649 0xf550fc04,
1646 0xb6088121, 1650 0xb608d121,
1647 0x11f50464, 1651 0x11f50464,
1648 0x57f000ad, 1652 0x76bb008a,
1649 0x0076bb01, 1653 0x0465b600,
1650 0xf90465b6, 1654 0x659450f9,
1651 0x04659450, 1655 0x0256bb04,
1652 0xbd0256bb, 1656 0x75fd50bd,
1653 0x0475fd50, 1657 0xf550fc04,
1654 0x21f550fc, 1658 0xb6082421,
1655 0x64b608dc, 1659 0x11f40464,
1656 0x8a11f504, 1660 0xe05bcb6a,
1657 0x0076bb00, 1661 0xb60076bb,
1658 0xf90465b6, 1662 0x50f90465,
1659 0x04659450, 1663 0xbb046594,
1660 0xbd0256bb, 1664 0x50bd0256,
1661 0x0475fd50, 1665 0xfc0475fd,
1662 0x21f550fc, 1666 0x6921f550,
1663 0x64b6082f, 1667 0x0464b607,
1664 0x6a11f404, 1668 0xbd025bb9,
1665 0xbbe05bcb, 1669 0x430ef474,
1666 0x65b60076, 1670/* 0x0a48: i2c_recv_not_rd08 */
1667 0x9450f904, 1671 0xf401d6b0,
1668 0x56bb0465, 1672 0x57f03d1b,
1669 0xfd50bd02, 1673 0xd121f500,
1670 0x50fc0475, 1674 0x3311f408,
1671 0x077421f5, 1675 0xf5e0c5c7,
1672 0xb90464b6, 1676 0xf4087621,
1673 0x74bd025b, 1677 0x57f02911,
1674/* 0x0a53: i2c_recv_not_rd08 */ 1678 0xd121f500,
1675 0xb0430ef4, 1679 0x1f11f408,
1676 0x1bf401d6, 1680 0xf5e0b5c7,
1677 0x0057f03d, 1681 0xf4087621,
1678 0x08dc21f5, 1682 0x21f51511,
1679 0xc73311f4, 1683 0x74bd0769,
1680 0x21f5e0c5, 1684 0xf408c5c7,
1681 0x11f40881, 1685 0x32f4091b,
1682 0x0057f029, 1686 0x030ef402,
1683 0x08dc21f5, 1687/* 0x0a88: i2c_recv_not_wr08 */
1684 0xc71f11f4, 1688/* 0x0a88: i2c_recv_done */
1685 0x21f5e0b5, 1689 0xf5f8cec7,
1686 0x11f40881, 1690 0xfc093321,
1687 0x7421f515, 1691 0xf4d0fce0,
1688 0xc774bd07, 1692 0x7cb90a12,
1689 0x1bf408c5, 1693 0xe621f502,
1690 0x0232f409, 1694/* 0x0a9d: i2c_recv_exit */
1691/* 0x0a93: i2c_recv_not_wr08 */ 1695/* 0x0a9f: i2c_init */
1692/* 0x0a93: i2c_recv_done */
1693 0xc7030ef4,
1694 0x21f5f8ce,
1695 0xe0fc093e,
1696 0x12f4d0fc,
1697 0x027cb90a,
1698 0x02f121f5,
1699/* 0x0aa8: i2c_recv_exit */
1700/* 0x0aaa: i2c_init */
1701 0x00f800f8,
1702/* 0x0aac: test_recv */
1703 0x05d817f1,
1704 0xb60011cf,
1705 0x07f10110,
1706 0x01d005d8,
1707 0xf104bd00,
1708 0xf1d900e7,
1709 0xf5134fe3,
1710 0xf8022321,
1711/* 0x0acd: test_init */
1712 0x00e7f100,
1713 0x2321f508,
1714/* 0x0ad7: idle_recv */
1715 0xf800f802, 1696 0xf800f802,
1716/* 0x0ad9: idle */ 1697/* 0x0aa1: test_recv */
1717 0x0031f400, 1698 0xd817f100,
1718 0x05d417f1, 1699 0x0011cf05,
1719 0xb60011cf, 1700 0xf10110b6,
1720 0x07f10110, 1701 0xd005d807,
1721 0x01d005d4, 1702 0x04bd0001,
1722/* 0x0aef: idle_loop */ 1703 0xd900e7f1,
1723 0xf004bd00, 1704 0x134fe3f1,
1724 0x32f45817, 1705 0x021821f5,
1725/* 0x0af5: idle_proc */ 1706/* 0x0ac2: test_init */
1726/* 0x0af5: idle_proc_exec */ 1707 0xe7f100f8,
1727 0xb910f902, 1708 0x21f50800,
1728 0x21f5021e, 1709 0x00f80218,
1729 0x10fc02fa, 1710/* 0x0acc: idle_recv */
1730 0xf40911f4, 1711/* 0x0ace: idle */
1731 0x0ef40231, 1712 0x31f400f8,
1732/* 0x0b09: idle_proc_next */ 1713 0xd417f100,
1733 0x5810b6ef, 1714 0x0011cf05,
1734 0xf4061fb8, 1715 0xf10110b6,
1735 0x02f4e61b, 1716 0xd005d407,
1736 0x0028f4dd, 1717 0x04bd0001,
1737 0x00c10ef4, 1718/* 0x0ae4: idle_loop */
1719 0xf45817f0,
1720/* 0x0aea: idle_proc */
1721/* 0x0aea: idle_proc_exec */
1722 0x10f90232,
1723 0xf5021eb9,
1724 0xfc02ef21,
1725 0x0911f410,
1726 0xf40231f4,
1727/* 0x0afe: idle_proc_next */
1728 0x10b6ef0e,
1729 0x061fb858,
1730 0xf4e61bf4,
1731 0x28f4dd02,
1732 0xc10ef400,
1733 0x00000000,
1734 0x00000000,
1735 0x00000000,
1738 0x00000000, 1736 0x00000000,
1739 0x00000000, 1737 0x00000000,
1740 0x00000000, 1738 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gk208.fuc5.h b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gk208.fuc5.h
index fe4f63deeaab..8a2b628642ac 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gk208.fuc5.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gk208.fuc5.h
@@ -24,8 +24,8 @@ uint32_t gk208_pmu_data[] = {
24 0x00000000, 24 0x00000000,
25/* 0x0058: proc_list_head */ 25/* 0x0058: proc_list_head */
26 0x54534f48, 26 0x54534f48,
27 0x00000453, 27 0x00000447,
28 0x00000404, 28 0x000003f8,
29 0x00000000, 29 0x00000000,
30 0x00000000, 30 0x00000000,
31 0x00000000, 31 0x00000000,
@@ -46,8 +46,8 @@ uint32_t gk208_pmu_data[] = {
46 0x00000000, 46 0x00000000,
47 0x00000000, 47 0x00000000,
48 0x584d454d, 48 0x584d454d,
49 0x0000062d, 49 0x00000621,
50 0x0000061f, 50 0x00000613,
51 0x00000000, 51 0x00000000,
52 0x00000000, 52 0x00000000,
53 0x00000000, 53 0x00000000,
@@ -68,8 +68,8 @@ uint32_t gk208_pmu_data[] = {
68 0x00000000, 68 0x00000000,
69 0x00000000, 69 0x00000000,
70 0x46524550, 70 0x46524550,
71 0x00000631, 71 0x00000625,
72 0x0000062f, 72 0x00000623,
73 0x00000000, 73 0x00000000,
74 0x00000000, 74 0x00000000,
75 0x00000000, 75 0x00000000,
@@ -90,8 +90,8 @@ uint32_t gk208_pmu_data[] = {
90 0x00000000, 90 0x00000000,
91 0x00000000, 91 0x00000000,
92 0x5f433249, 92 0x5f433249,
93 0x00000a35, 93 0x00000a29,
94 0x000008dc, 94 0x000008d0,
95 0x00000000, 95 0x00000000,
96 0x00000000, 96 0x00000000,
97 0x00000000, 97 0x00000000,
@@ -112,8 +112,8 @@ uint32_t gk208_pmu_data[] = {
112 0x00000000, 112 0x00000000,
113 0x00000000, 113 0x00000000,
114 0x54534554, 114 0x54534554,
115 0x00000a56, 115 0x00000a4a,
116 0x00000a37, 116 0x00000a2b,
117 0x00000000, 117 0x00000000,
118 0x00000000, 118 0x00000000,
119 0x00000000, 119 0x00000000,
@@ -134,8 +134,8 @@ uint32_t gk208_pmu_data[] = {
134 0x00000000, 134 0x00000000,
135 0x00000000, 135 0x00000000,
136 0x454c4449, 136 0x454c4449,
137 0x00000a61, 137 0x00000a55,
138 0x00000a5f, 138 0x00000a53,
139 0x00000000, 139 0x00000000,
140 0x00000000, 140 0x00000000,
141 0x00000000, 141 0x00000000,
@@ -229,26 +229,26 @@ uint32_t gk208_pmu_data[] = {
229/* 0x0370: memx_func_head */ 229/* 0x0370: memx_func_head */
230 0x00000001, 230 0x00000001,
231 0x00000000, 231 0x00000000,
232 0x00000483, 232 0x00000477,
233/* 0x037c: memx_func_next */ 233/* 0x037c: memx_func_next */
234 0x00000002, 234 0x00000002,
235 0x00000000, 235 0x00000000,
236 0x00000500, 236 0x000004f4,
237 0x00000003, 237 0x00000003,
238 0x00000002, 238 0x00000002,
239 0x00000580, 239 0x00000574,
240 0x00040004, 240 0x00040004,
241 0x00000000, 241 0x00000000,
242 0x0000059d, 242 0x00000591,
243 0x00010005, 243 0x00010005,
244 0x00000000, 244 0x00000000,
245 0x000005b7, 245 0x000005ab,
246 0x00010006, 246 0x00010006,
247 0x00000000, 247 0x00000000,
248 0x0000057b, 248 0x0000056f,
249 0x00000007, 249 0x00000007,
250 0x00000000, 250 0x00000000,
251 0x000005c3, 251 0x000005b7,
252/* 0x03c4: memx_func_tail */ 252/* 0x03c4: memx_func_tail */
253/* 0x03c4: memx_ts_start */ 253/* 0x03c4: memx_ts_start */
254 0x00000000, 254 0x00000000,
@@ -916,7 +916,7 @@ uint32_t gk208_pmu_data[] = {
916}; 916};
917 917
918uint32_t gk208_pmu_code[] = { 918uint32_t gk208_pmu_code[] = {
919 0x031c0ef5, 919 0x03100ef5,
920/* 0x0004: rd32 */ 920/* 0x0004: rd32 */
921 0xf607a040, 921 0xf607a040,
922 0x04bd000e, 922 0x04bd000e,
@@ -972,7 +972,7 @@ uint32_t gk208_pmu_code[] = {
972 0x0a98280b, 972 0x0a98280b,
973 0x029abb9a, 973 0x029abb9a,
974 0x0d0e1cf4, 974 0x0d0e1cf4,
975 0x02617e01, 975 0x02557e01,
976 0xf494bd00, 976 0xf494bd00,
977/* 0x00c2: intr_watchdog_next_time */ 977/* 0x00c2: intr_watchdog_next_time */
978 0x0a98140e, 978 0x0a98140e,
@@ -1017,21 +1017,16 @@ uint32_t gk208_pmu_code[] = {
1017 0xc0f900cc, 1017 0xc0f900cc,
1018 0xf14f484e, 1018 0xf14f484e,
1019 0x0d5453e3, 1019 0x0d5453e3,
1020 0x02c27e00, 1020 0x02b67e00,
1021 0x40c0fc00, 1021 0x40c0fc00,
1022 0x0cf604c0, 1022 0x0cf604c0,
1023/* 0x0167: intr_subintr_skip_fifo */ 1023/* 0x0167: intr_subintr_skip_fifo */
1024 0x4004bd00, 1024 0x4004bd00,
1025 0x09f60688, 1025 0x09f60688,
1026/* 0x016f: intr_skip_subintr */ 1026/* 0x016f: intr_skip_subintr */
1027 0xc404bd00, 1027 0x4904bd00,
1028 0x0bf42089, 1028 0x90bd00e0,
1029 0xbfa4f107, 1029 0x000489fd,
1030/* 0x0179: intr_skip_pause */
1031 0x4089c4ff,
1032 0xf1070bf4,
1033/* 0x0183: intr_skip_user0 */
1034 0x00ffbfa4,
1035 0x0008f604, 1030 0x0008f604,
1036 0x80fc04bd, 1031 0x80fc04bd,
1037 0xfc0088fe, 1032 0xfc0088fe,
@@ -1040,35 +1035,35 @@ uint32_t gk208_pmu_code[] = {
1040 0xfca0fcb0, 1035 0xfca0fcb0,
1041 0xfc80fc90, 1036 0xfc80fc90,
1042 0x0032f400, 1037 0x0032f400,
1043/* 0x01a6: ticks_from_ns */ 1038/* 0x019a: ticks_from_ns */
1044 0xc0f901f8, 1039 0xc0f901f8,
1045 0xd7f1b0f9, 1040 0xd7f1b0f9,
1046 0xd3f00144, 1041 0xd3f00144,
1047 0x7721f500, 1042 0x6b21f500,
1048 0xe8ccec03, 1043 0xe8ccec03,
1049 0x00b4b003, 1044 0x00b4b003,
1050 0xec120bf4, 1045 0xec120bf4,
1051 0xf103e8ee, 1046 0xf103e8ee,
1052 0xf00144d7, 1047 0xf00144d7,
1053 0x21f500d3, 1048 0x21f500d3,
1054/* 0x01ce: ticks_from_ns_quit */ 1049/* 0x01c2: ticks_from_ns_quit */
1055 0xceb20377, 1050 0xceb2036b,
1056 0xc0fcb0fc, 1051 0xc0fcb0fc,
1057/* 0x01d6: ticks_from_us */ 1052/* 0x01ca: ticks_from_us */
1058 0xc0f900f8, 1053 0xc0f900f8,
1059 0xd7f1b0f9, 1054 0xd7f1b0f9,
1060 0xd3f00144, 1055 0xd3f00144,
1061 0x7721f500, 1056 0x6b21f500,
1062 0xb0ceb203, 1057 0xb0ceb203,
1063 0x0bf400b4, 1058 0x0bf400b4,
1064/* 0x01ef: ticks_from_us_quit */ 1059/* 0x01e3: ticks_from_us_quit */
1065 0xfce4bd05, 1060 0xfce4bd05,
1066 0xf8c0fcb0, 1061 0xf8c0fcb0,
1067/* 0x01f5: ticks_to_us */ 1062/* 0x01e9: ticks_to_us */
1068 0x44d7f100, 1063 0x44d7f100,
1069 0x00d3f001, 1064 0x00d3f001,
1070 0xf8ecedff, 1065 0xf8ecedff,
1071/* 0x0201: timer */ 1066/* 0x01f5: timer */
1072 0xf990f900, 1067 0xf990f900,
1073 0x1032f480, 1068 0x1032f480,
1074 0xb003f898, 1069 0xb003f898,
@@ -1086,17 +1081,17 @@ uint32_t gk208_pmu_code[] = {
1086 0xa60088cf, 1081 0xa60088cf,
1087 0x080bf4e0, 1082 0x080bf4e0,
1088 0x1cf4e8a6, 1083 0x1cf4e8a6,
1089/* 0x0245: timer_reset */ 1084/* 0x0239: timer_reset */
1090 0xf634000d, 1085 0xf634000d,
1091 0x04bd000e, 1086 0x04bd000e,
1092/* 0x024f: timer_enable */ 1087/* 0x0243: timer_enable */
1093 0x089a0eb5, 1088 0x089a0eb5,
1094 0xf6380001, 1089 0xf6380001,
1095 0x04bd0008, 1090 0x04bd0008,
1096/* 0x0258: timer_done */ 1091/* 0x024c: timer_done */
1097 0xfc1031f4, 1092 0xfc1031f4,
1098 0xf890fc80, 1093 0xf890fc80,
1099/* 0x0261: send_proc */ 1094/* 0x0255: send_proc */
1100 0xf980f900, 1095 0xf980f900,
1101 0x05e89890, 1096 0x05e89890,
1102 0xf004e998, 1097 0xf004e998,
@@ -1111,24 +1106,24 @@ uint32_t gk208_pmu_code[] = {
1111 0x90b6038b, 1106 0x90b6038b,
1112 0x0794f001, 1107 0x0794f001,
1113 0xf404e9b5, 1108 0xf404e9b5,
1114/* 0x029a: send_done */ 1109/* 0x028e: send_done */
1115 0x90fc0231, 1110 0x90fc0231,
1116 0x00f880fc, 1111 0x00f880fc,
1117/* 0x02a0: find */ 1112/* 0x0294: find */
1118 0x580880f9, 1113 0x580880f9,
1119/* 0x02a7: find_loop */ 1114/* 0x029b: find_loop */
1120 0x980131f4, 1115 0x980131f4,
1121 0xaea6008a, 1116 0xaea6008a,
1122 0xb6100bf4, 1117 0xb6100bf4,
1123 0x86b15880, 1118 0x86b15880,
1124 0x1bf40268, 1119 0x1bf40268,
1125 0x0132f4f1, 1120 0x0132f4f1,
1126/* 0x02bc: find_done */ 1121/* 0x02b0: find_done */
1127 0x80fc8eb2, 1122 0x80fc8eb2,
1128/* 0x02c2: send */ 1123/* 0x02b6: send */
1129 0xa07e00f8, 1124 0x947e00f8,
1130 0x01f40002, 1125 0x01f40002,
1131/* 0x02cb: recv */ 1126/* 0x02bf: recv */
1132 0xf900f89b, 1127 0xf900f89b,
1133 0x9880f990, 1128 0x9880f990,
1134 0xe99805e8, 1129 0xe99805e8,
@@ -1148,10 +1143,10 @@ uint32_t gk208_pmu_code[] = {
1148 0xa5f900ee, 1143 0xa5f900ee,
1149 0xf8fef0fc, 1144 0xf8fef0fc,
1150 0x0131f400, 1145 0x0131f400,
1151/* 0x0316: recv_done */ 1146/* 0x030a: recv_done */
1152 0x80fcf0fc, 1147 0x80fcf0fc,
1153 0x00f890fc, 1148 0x00f890fc,
1154/* 0x031c: init */ 1149/* 0x0310: init */
1155 0xcf010841, 1150 0xcf010841,
1156 0x11e70011, 1151 0x11e70011,
1157 0x14b60109, 1152 0x14b60109,
@@ -1170,12 +1165,12 @@ uint32_t gk208_pmu_code[] = {
1170 0x011031f4, 1165 0x011031f4,
1171 0xf6380001, 1166 0xf6380001,
1172 0x04bd0001, 1167 0x04bd0001,
1173/* 0x0366: init_proc */ 1168/* 0x035a: init_proc */
1174 0xf198580f, 1169 0xf198580f,
1175 0x0016b001, 1170 0x0016b001,
1176 0xf9fa0bf4, 1171 0xf9fa0bf4,
1177 0x58f0b615, 1172 0x58f0b615,
1178/* 0x0377: mulu32_32_64 */ 1173/* 0x036b: mulu32_32_64 */
1179 0xf9f20ef4, 1174 0xf9f20ef4,
1180 0xf920f910, 1175 0xf920f910,
1181 0x9540f930, 1176 0x9540f930,
@@ -1196,7 +1191,7 @@ uint32_t gk208_pmu_code[] = {
1196 0x00b3bb30, 1191 0x00b3bb30,
1197 0x30fc40fc, 1192 0x30fc40fc,
1198 0x10fc20fc, 1193 0x10fc20fc,
1199/* 0x03c6: host_send */ 1194/* 0x03ba: host_send */
1200 0xb04100f8, 1195 0xb04100f8,
1201 0x0011cf04, 1196 0x0011cf04,
1202 0xcf04a042, 1197 0xcf04a042,
@@ -1207,18 +1202,18 @@ uint32_t gk208_pmu_code[] = {
1207 0x03eb9802, 1202 0x03eb9802,
1208 0x9802ec98, 1203 0x9802ec98,
1209 0xee9801ed, 1204 0xee9801ed,
1210 0x02c27e00, 1205 0x02b67e00,
1211 0x0110b600, 1206 0x0110b600,
1212 0x400f1ec4, 1207 0x400f1ec4,
1213 0x0ef604b0, 1208 0x0ef604b0,
1214 0xf404bd00, 1209 0xf404bd00,
1215/* 0x0402: host_send_done */ 1210/* 0x03f6: host_send_done */
1216 0x00f8c70e, 1211 0x00f8c70e,
1217/* 0x0404: host_recv */ 1212/* 0x03f8: host_recv */
1218 0xf14e4941, 1213 0xf14e4941,
1219 0xa6525413, 1214 0xa6525413,
1220 0xb90bf4e1, 1215 0xb90bf4e1,
1221/* 0x0410: host_recv_wait */ 1216/* 0x0404: host_recv_wait */
1222 0xcf04cc41, 1217 0xcf04cc41,
1223 0xc8420011, 1218 0xc8420011,
1224 0x0022cf04, 1219 0x0022cf04,
@@ -1235,7 +1230,7 @@ uint32_t gk208_pmu_code[] = {
1235 0x04bd0002, 1230 0x04bd0002,
1236 0x00004002, 1231 0x00004002,
1237 0xbd0002f6, 1232 0xbd0002f6,
1238/* 0x0453: host_init */ 1233/* 0x0447: host_init */
1239 0x4100f804, 1234 0x4100f804,
1240 0x14b60080, 1235 0x14b60080,
1241 0x7015f110, 1236 0x7015f110,
@@ -1248,7 +1243,7 @@ uint32_t gk208_pmu_code[] = {
1248 0x0104bd00, 1243 0x0104bd00,
1249 0x04c44001, 1244 0x04c44001,
1250 0xbd0001f6, 1245 0xbd0001f6,
1251/* 0x0483: memx_func_enter */ 1246/* 0x0477: memx_func_enter */
1252 0xf100f804, 1247 0xf100f804,
1253 0xf1162067, 1248 0xf1162067,
1254 0xf1f55d77, 1249 0xf1f55d77,
@@ -1275,19 +1270,19 @@ uint32_t gk208_pmu_code[] = {
1275 0x00002e7e, 1270 0x00002e7e,
1276 0xe0400406, 1271 0xe0400406,
1277 0x0006f607, 1272 0x0006f607,
1278/* 0x04ea: memx_func_enter_wait */ 1273/* 0x04de: memx_func_enter_wait */
1279 0xc04604bd, 1274 0xc04604bd,
1280 0x0066cf07, 1275 0x0066cf07,
1281 0xf40464f0, 1276 0xf40464f0,
1282 0x2c06f70b, 1277 0x2c06f70b,
1283 0xb50066cf, 1278 0xb50066cf,
1284 0x00f8f106, 1279 0x00f8f106,
1285/* 0x0500: memx_func_leave */ 1280/* 0x04f4: memx_func_leave */
1286 0x66cf2c06, 1281 0x66cf2c06,
1287 0xf206b500, 1282 0xf206b500,
1288 0xe4400406, 1283 0xe4400406,
1289 0x0006f607, 1284 0x0006f607,
1290/* 0x0512: memx_func_leave_wait */ 1285/* 0x0506: memx_func_leave_wait */
1291 0xc04604bd, 1286 0xc04604bd,
1292 0x0066cf07, 1287 0x0066cf07,
1293 0xf40464f0, 1288 0xf40464f0,
@@ -1314,10 +1309,10 @@ uint32_t gk208_pmu_code[] = {
1314 0xf960f905, 1309 0xf960f905,
1315 0xfcd0fc80, 1310 0xfcd0fc80,
1316 0x002e7ee0, 1311 0x002e7ee0,
1317/* 0x057b: memx_func_wait_vblank */ 1312/* 0x056f: memx_func_wait_vblank */
1318 0xb600f800, 1313 0xb600f800,
1319 0x00f80410, 1314 0x00f80410,
1320/* 0x0580: memx_func_wr32 */ 1315/* 0x0574: memx_func_wr32 */
1321 0x98001698, 1316 0x98001698,
1322 0x10b60115, 1317 0x10b60115,
1323 0xf960f908, 1318 0xf960f908,
@@ -1325,23 +1320,23 @@ uint32_t gk208_pmu_code[] = {
1325 0x002e7ee0, 1320 0x002e7ee0,
1326 0x0242b600, 1321 0x0242b600,
1327 0xf8e81bf4, 1322 0xf8e81bf4,
1328/* 0x059d: memx_func_wait */ 1323/* 0x0591: memx_func_wait */
1329 0xcf2c0800, 1324 0xcf2c0800,
1330 0x1e980088, 1325 0x1e980088,
1331 0x011d9800, 1326 0x011d9800,
1332 0x98021c98, 1327 0x98021c98,
1333 0x10b6031b, 1328 0x10b6031b,
1334 0x00797e10, 1329 0x00797e10,
1335/* 0x05b7: memx_func_delay */ 1330/* 0x05ab: memx_func_delay */
1336 0x9800f800, 1331 0x9800f800,
1337 0x10b6001e, 1332 0x10b6001e,
1338 0x005d7e04, 1333 0x005d7e04,
1339/* 0x05c3: memx_func_train */ 1334/* 0x05b7: memx_func_train */
1340 0xf800f800, 1335 0xf800f800,
1341/* 0x05c5: memx_exec */ 1336/* 0x05b9: memx_exec */
1342 0xf9e0f900, 1337 0xf9e0f900,
1343 0xb2c1b2d0, 1338 0xb2c1b2d0,
1344/* 0x05cd: memx_exec_next */ 1339/* 0x05c1: memx_exec_next */
1345 0x001398b2, 1340 0x001398b2,
1346 0xe70410b6, 1341 0xe70410b6,
1347 0xe701f034, 1342 0xe701f034,
@@ -1354,111 +1349,111 @@ uint32_t gk208_pmu_code[] = {
1354 0x02cbbbf2, 1349 0x02cbbbf2,
1355 0xcf07c44b, 1350 0xcf07c44b,
1356 0xd0fc00bb, 1351 0xd0fc00bb,
1357 0xc27ee0fc, 1352 0xb67ee0fc,
1358 0x00f80002, 1353 0x00f80002,
1359/* 0x0604: memx_info */ 1354/* 0x05f8: memx_info */
1360 0xf401c670, 1355 0xf401c670,
1361/* 0x060a: memx_info_data */ 1356/* 0x05fe: memx_info_data */
1362 0xcc4c0c0b, 1357 0xcc4c0c0b,
1363 0x08004b03, 1358 0x08004b03,
1364/* 0x0613: memx_info_train */ 1359/* 0x0607: memx_info_train */
1365 0x4c090ef4, 1360 0x4c090ef4,
1366 0x004b0bcc, 1361 0x004b0bcc,
1367/* 0x0619: memx_info_send */ 1362/* 0x060d: memx_info_send */
1368 0x02c27e01, 1363 0x02b67e01,
1369/* 0x061f: memx_recv */ 1364/* 0x0613: memx_recv */
1370 0xb000f800, 1365 0xb000f800,
1371 0x0bf401d6, 1366 0x0bf401d6,
1372 0x00d6b0a3, 1367 0x00d6b0a3,
1373 0xf8dc0bf4, 1368 0xf8dc0bf4,
1374/* 0x062d: memx_init */ 1369/* 0x0621: memx_init */
1375/* 0x062f: perf_recv */ 1370/* 0x0623: perf_recv */
1376 0xf800f800, 1371 0xf800f800,
1377/* 0x0631: perf_init */ 1372/* 0x0625: perf_init */
1378/* 0x0633: i2c_drive_scl */ 1373/* 0x0627: i2c_drive_scl */
1379 0xb000f800, 1374 0xb000f800,
1380 0x0bf40036, 1375 0x0bf40036,
1381 0x07e0400d, 1376 0x07e0400d,
1382 0xbd0001f6, 1377 0xbd0001f6,
1383/* 0x0643: i2c_drive_scl_lo */ 1378/* 0x0637: i2c_drive_scl_lo */
1384 0x4000f804, 1379 0x4000f804,
1385 0x01f607e4, 1380 0x01f607e4,
1386 0xf804bd00, 1381 0xf804bd00,
1387/* 0x064d: i2c_drive_sda */ 1382/* 0x0641: i2c_drive_sda */
1388 0x0036b000, 1383 0x0036b000,
1389 0x400d0bf4, 1384 0x400d0bf4,
1390 0x02f607e0, 1385 0x02f607e0,
1391 0xf804bd00, 1386 0xf804bd00,
1392/* 0x065d: i2c_drive_sda_lo */ 1387/* 0x0651: i2c_drive_sda_lo */
1393 0x07e44000, 1388 0x07e44000,
1394 0xbd0002f6, 1389 0xbd0002f6,
1395/* 0x0667: i2c_sense_scl */ 1390/* 0x065b: i2c_sense_scl */
1396 0xf400f804, 1391 0xf400f804,
1397 0xc4430132, 1392 0xc4430132,
1398 0x0033cf07, 1393 0x0033cf07,
1399 0xf40431fd, 1394 0xf40431fd,
1400 0x31f4060b, 1395 0x31f4060b,
1401/* 0x0679: i2c_sense_scl_done */ 1396/* 0x066d: i2c_sense_scl_done */
1402/* 0x067b: i2c_sense_sda */ 1397/* 0x066f: i2c_sense_sda */
1403 0xf400f801, 1398 0xf400f801,
1404 0xc4430132, 1399 0xc4430132,
1405 0x0033cf07, 1400 0x0033cf07,
1406 0xf40432fd, 1401 0xf40432fd,
1407 0x31f4060b, 1402 0x31f4060b,
1408/* 0x068d: i2c_sense_sda_done */ 1403/* 0x0681: i2c_sense_sda_done */
1409/* 0x068f: i2c_raise_scl */ 1404/* 0x0683: i2c_raise_scl */
1410 0xf900f801, 1405 0xf900f801,
1411 0x08984440, 1406 0x08984440,
1412 0x337e0103, 1407 0x277e0103,
1413/* 0x069a: i2c_raise_scl_wait */ 1408/* 0x068e: i2c_raise_scl_wait */
1414 0xe84e0006, 1409 0xe84e0006,
1415 0x005d7e03, 1410 0x005d7e03,
1416 0x06677e00, 1411 0x065b7e00,
1417 0x0901f400, 1412 0x0901f400,
1418 0xf40142b6, 1413 0xf40142b6,
1419/* 0x06ae: i2c_raise_scl_done */ 1414/* 0x06a2: i2c_raise_scl_done */
1420 0x40fcef1b, 1415 0x40fcef1b,
1421/* 0x06b2: i2c_start */ 1416/* 0x06a6: i2c_start */
1422 0x677e00f8, 1417 0x5b7e00f8,
1423 0x11f40006, 1418 0x11f40006,
1424 0x067b7e0d, 1419 0x066f7e0d,
1425 0x0611f400, 1420 0x0611f400,
1426/* 0x06c3: i2c_start_rep */ 1421/* 0x06b7: i2c_start_rep */
1427 0x032e0ef4, 1422 0x032e0ef4,
1428 0x06337e00, 1423 0x06277e00,
1429 0x7e010300, 1424 0x7e010300,
1430 0xbb00064d, 1425 0xbb000641,
1431 0x65b60076, 1426 0x65b60076,
1432 0x9450f904, 1427 0x9450f904,
1433 0x56bb0465, 1428 0x56bb0465,
1434 0xfd50bd02, 1429 0xfd50bd02,
1435 0x50fc0475, 1430 0x50fc0475,
1436 0x00068f7e, 1431 0x0006837e,
1437 0xf40464b6, 1432 0xf40464b6,
1438/* 0x06ee: i2c_start_send */ 1433/* 0x06e2: i2c_start_send */
1439 0x00031d11, 1434 0x00031d11,
1440 0x00064d7e, 1435 0x0006417e,
1441 0x7e13884e, 1436 0x7e13884e,
1442 0x0300005d, 1437 0x0300005d,
1443 0x06337e00, 1438 0x06277e00,
1444 0x13884e00, 1439 0x13884e00,
1445 0x00005d7e, 1440 0x00005d7e,
1446/* 0x0708: i2c_start_out */ 1441/* 0x06fc: i2c_start_out */
1447/* 0x070a: i2c_stop */ 1442/* 0x06fe: i2c_stop */
1448 0x000300f8, 1443 0x000300f8,
1449 0x0006337e, 1444 0x0006277e,
1450 0x4d7e0003, 1445 0x417e0003,
1451 0xe84e0006, 1446 0xe84e0006,
1452 0x005d7e03, 1447 0x005d7e03,
1453 0x7e010300, 1448 0x7e010300,
1454 0x4e000633, 1449 0x4e000627,
1455 0x5d7e1388, 1450 0x5d7e1388,
1456 0x01030000, 1451 0x01030000,
1457 0x00064d7e, 1452 0x0006417e,
1458 0x7e13884e, 1453 0x7e13884e,
1459 0xf800005d, 1454 0xf800005d,
1460/* 0x0739: i2c_bitw */ 1455/* 0x072d: i2c_bitw */
1461 0x064d7e00, 1456 0x06417e00,
1462 0x03e84e00, 1457 0x03e84e00,
1463 0x00005d7e, 1458 0x00005d7e,
1464 0xb60076bb, 1459 0xb60076bb,
@@ -1466,18 +1461,18 @@ uint32_t gk208_pmu_code[] = {
1466 0xbb046594, 1461 0xbb046594,
1467 0x50bd0256, 1462 0x50bd0256,
1468 0xfc0475fd, 1463 0xfc0475fd,
1469 0x068f7e50, 1464 0x06837e50,
1470 0x0464b600, 1465 0x0464b600,
1471 0x4e1711f4, 1466 0x4e1711f4,
1472 0x5d7e1388, 1467 0x5d7e1388,
1473 0x00030000, 1468 0x00030000,
1474 0x0006337e, 1469 0x0006277e,
1475 0x7e13884e, 1470 0x7e13884e,
1476/* 0x0777: i2c_bitw_out */ 1471/* 0x076b: i2c_bitw_out */
1477 0xf800005d, 1472 0xf800005d,
1478/* 0x0779: i2c_bitr */ 1473/* 0x076d: i2c_bitr */
1479 0x7e010300, 1474 0x7e010300,
1480 0x4e00064d, 1475 0x4e000641,
1481 0x5d7e03e8, 1476 0x5d7e03e8,
1482 0x76bb0000, 1477 0x76bb0000,
1483 0x0465b600, 1478 0x0465b600,
@@ -1485,25 +1480,25 @@ uint32_t gk208_pmu_code[] = {
1485 0x0256bb04, 1480 0x0256bb04,
1486 0x75fd50bd, 1481 0x75fd50bd,
1487 0x7e50fc04, 1482 0x7e50fc04,
1488 0xb600068f, 1483 0xb6000683,
1489 0x11f40464, 1484 0x11f40464,
1490 0x067b7e1a, 1485 0x066f7e1a,
1491 0x7e000300, 1486 0x7e000300,
1492 0x4e000633, 1487 0x4e000627,
1493 0x5d7e1388, 1488 0x5d7e1388,
1494 0x3cf00000, 1489 0x3cf00000,
1495 0x0131f401, 1490 0x0131f401,
1496/* 0x07bc: i2c_bitr_done */ 1491/* 0x07b0: i2c_bitr_done */
1497/* 0x07be: i2c_get_byte */ 1492/* 0x07b2: i2c_get_byte */
1498 0x000500f8, 1493 0x000500f8,
1499/* 0x07c2: i2c_get_byte_next */ 1494/* 0x07b6: i2c_get_byte_next */
1500 0x54b60804, 1495 0x54b60804,
1501 0x0076bb01, 1496 0x0076bb01,
1502 0xf90465b6, 1497 0xf90465b6,
1503 0x04659450, 1498 0x04659450,
1504 0xbd0256bb, 1499 0xbd0256bb,
1505 0x0475fd50, 1500 0x0475fd50,
1506 0x797e50fc, 1501 0x6d7e50fc,
1507 0x64b60007, 1502 0x64b60007,
1508 0x2a11f404, 1503 0x2a11f404,
1509 0xb60553fd, 1504 0xb60553fd,
@@ -1514,11 +1509,11 @@ uint32_t gk208_pmu_code[] = {
1514 0x56bb0465, 1509 0x56bb0465,
1515 0xfd50bd02, 1510 0xfd50bd02,
1516 0x50fc0475, 1511 0x50fc0475,
1517 0x0007397e, 1512 0x00072d7e,
1518/* 0x080b: i2c_get_byte_done */ 1513/* 0x07ff: i2c_get_byte_done */
1519 0xf80464b6, 1514 0xf80464b6,
1520/* 0x080d: i2c_put_byte */ 1515/* 0x0801: i2c_put_byte */
1521/* 0x080f: i2c_put_byte_next */ 1516/* 0x0803: i2c_put_byte_next */
1522 0xb6080400, 1517 0xb6080400,
1523 0x54ff0142, 1518 0x54ff0142,
1524 0x0076bb38, 1519 0x0076bb38,
@@ -1526,7 +1521,7 @@ uint32_t gk208_pmu_code[] = {
1526 0x04659450, 1521 0x04659450,
1527 0xbd0256bb, 1522 0xbd0256bb,
1528 0x0475fd50, 1523 0x0475fd50,
1529 0x397e50fc, 1524 0x2d7e50fc,
1530 0x64b60007, 1525 0x64b60007,
1531 0x3411f404, 1526 0x3411f404,
1532 0xf40046b0, 1527 0xf40046b0,
@@ -1536,20 +1531,20 @@ uint32_t gk208_pmu_code[] = {
1536 0x0256bb04, 1531 0x0256bb04,
1537 0x75fd50bd, 1532 0x75fd50bd,
1538 0x7e50fc04, 1533 0x7e50fc04,
1539 0xb6000779, 1534 0xb600076d,
1540 0x11f40464, 1535 0x11f40464,
1541 0x0076bb0f, 1536 0x0076bb0f,
1542 0xf40136b0, 1537 0xf40136b0,
1543 0x32f4061b, 1538 0x32f4061b,
1544/* 0x0865: i2c_put_byte_done */ 1539/* 0x0859: i2c_put_byte_done */
1545/* 0x0867: i2c_addr */ 1540/* 0x085b: i2c_addr */
1546 0xbb00f801, 1541 0xbb00f801,
1547 0x65b60076, 1542 0x65b60076,
1548 0x9450f904, 1543 0x9450f904,
1549 0x56bb0465, 1544 0x56bb0465,
1550 0xfd50bd02, 1545 0xfd50bd02,
1551 0x50fc0475, 1546 0x50fc0475,
1552 0x0006b27e, 1547 0x0006a67e,
1553 0xf40464b6, 1548 0xf40464b6,
1554 0xc3e72911, 1549 0xc3e72911,
1555 0x34b6012e, 1550 0x34b6012e,
@@ -1559,25 +1554,25 @@ uint32_t gk208_pmu_code[] = {
1559 0xbb046594, 1554 0xbb046594,
1560 0x50bd0256, 1555 0x50bd0256,
1561 0xfc0475fd, 1556 0xfc0475fd,
1562 0x080d7e50, 1557 0x08017e50,
1563 0x0464b600, 1558 0x0464b600,
1564/* 0x08ac: i2c_addr_done */ 1559/* 0x08a0: i2c_addr_done */
1565/* 0x08ae: i2c_acquire_addr */ 1560/* 0x08a2: i2c_acquire_addr */
1566 0xcec700f8, 1561 0xcec700f8,
1567 0x05e4b6f8, 1562 0x05e4b6f8,
1568 0xd014e0b7, 1563 0xd014e0b7,
1569/* 0x08ba: i2c_acquire */ 1564/* 0x08ae: i2c_acquire */
1570 0xae7e00f8, 1565 0xa27e00f8,
1571 0x047e0008, 1566 0x047e0008,
1572 0xd9f00000, 1567 0xd9f00000,
1573 0x002e7e03, 1568 0x002e7e03,
1574/* 0x08cb: i2c_release */ 1569/* 0x08bf: i2c_release */
1575 0x7e00f800, 1570 0x7e00f800,
1576 0x7e0008ae, 1571 0x7e0008a2,
1577 0xf0000004, 1572 0xf0000004,
1578 0x2e7e03da, 1573 0x2e7e03da,
1579 0x00f80000, 1574 0x00f80000,
1580/* 0x08dc: i2c_recv */ 1575/* 0x08d0: i2c_recv */
1581 0xc70132f4, 1576 0xc70132f4,
1582 0x14b6f8c1, 1577 0x14b6f8c1,
1583 0x2816b002, 1578 0x2816b002,
@@ -1596,7 +1591,7 @@ uint32_t gk208_pmu_code[] = {
1596 0xbb046594, 1591 0xbb046594,
1597 0x50bd0256, 1592 0x50bd0256,
1598 0xfc0475fd, 1593 0xfc0475fd,
1599 0x08ba7e50, 1594 0x08ae7e50,
1600 0x0464b600, 1595 0x0464b600,
1601 0xd6b0d0fc, 1596 0xd6b0d0fc,
1602 0xb01bf500, 1597 0xb01bf500,
@@ -1606,7 +1601,7 @@ uint32_t gk208_pmu_code[] = {
1606 0x56bb0465, 1601 0x56bb0465,
1607 0xfd50bd02, 1602 0xfd50bd02,
1608 0x50fc0475, 1603 0x50fc0475,
1609 0x0008677e, 1604 0x00085b7e,
1610 0xf50464b6, 1605 0xf50464b6,
1611 0xc700cc11, 1606 0xc700cc11,
1612 0x76bbe0c5, 1607 0x76bbe0c5,
@@ -1615,7 +1610,7 @@ uint32_t gk208_pmu_code[] = {
1615 0x0256bb04, 1610 0x0256bb04,
1616 0x75fd50bd, 1611 0x75fd50bd,
1617 0x7e50fc04, 1612 0x7e50fc04,
1618 0xb600080d, 1613 0xb6000801,
1619 0x11f50464, 1614 0x11f50464,
1620 0x010500a9, 1615 0x010500a9,
1621 0xb60076bb, 1616 0xb60076bb,
@@ -1623,7 +1618,7 @@ uint32_t gk208_pmu_code[] = {
1623 0xbb046594, 1618 0xbb046594,
1624 0x50bd0256, 1619 0x50bd0256,
1625 0xfc0475fd, 1620 0xfc0475fd,
1626 0x08677e50, 1621 0x085b7e50,
1627 0x0464b600, 1622 0x0464b600,
1628 0x008711f5, 1623 0x008711f5,
1629 0xb60076bb, 1624 0xb60076bb,
@@ -1631,7 +1626,7 @@ uint32_t gk208_pmu_code[] = {
1631 0xbb046594, 1626 0xbb046594,
1632 0x50bd0256, 1627 0x50bd0256,
1633 0xfc0475fd, 1628 0xfc0475fd,
1634 0x07be7e50, 1629 0x07b27e50,
1635 0x0464b600, 1630 0x0464b600,
1636 0xcb6711f4, 1631 0xcb6711f4,
1637 0x76bbe05b, 1632 0x76bbe05b,
@@ -1640,36 +1635,36 @@ uint32_t gk208_pmu_code[] = {
1640 0x0256bb04, 1635 0x0256bb04,
1641 0x75fd50bd, 1636 0x75fd50bd,
1642 0x7e50fc04, 1637 0x7e50fc04,
1643 0xb600070a, 1638 0xb60006fe,
1644 0x5bb20464, 1639 0x5bb20464,
1645 0x0ef474bd, 1640 0x0ef474bd,
1646/* 0x09e1: i2c_recv_not_rd08 */ 1641/* 0x09d5: i2c_recv_not_rd08 */
1647 0x01d6b041, 1642 0x01d6b041,
1648 0x053b1bf4, 1643 0x053b1bf4,
1649 0x08677e00, 1644 0x085b7e00,
1650 0x3211f400, 1645 0x3211f400,
1651 0x7ee0c5c7, 1646 0x7ee0c5c7,
1652 0xf400080d, 1647 0xf4000801,
1653 0x00052811, 1648 0x00052811,
1654 0x0008677e, 1649 0x00085b7e,
1655 0xc71f11f4, 1650 0xc71f11f4,
1656 0x0d7ee0b5, 1651 0x017ee0b5,
1657 0x11f40008, 1652 0x11f40008,
1658 0x070a7e15, 1653 0x06fe7e15,
1659 0xc774bd00, 1654 0xc774bd00,
1660 0x1bf408c5, 1655 0x1bf408c5,
1661 0x0232f409, 1656 0x0232f409,
1662/* 0x0a1f: i2c_recv_not_wr08 */ 1657/* 0x0a13: i2c_recv_not_wr08 */
1663/* 0x0a1f: i2c_recv_done */ 1658/* 0x0a13: i2c_recv_done */
1664 0xc7030ef4, 1659 0xc7030ef4,
1665 0xcb7ef8ce, 1660 0xbf7ef8ce,
1666 0xe0fc0008, 1661 0xe0fc0008,
1667 0x12f4d0fc, 1662 0x12f4d0fc,
1668 0x7e7cb209, 1663 0x7e7cb209,
1669/* 0x0a33: i2c_recv_exit */ 1664/* 0x0a27: i2c_recv_exit */
1670 0xf80002c2, 1665 0xf80002b6,
1671/* 0x0a35: i2c_init */ 1666/* 0x0a29: i2c_init */
1672/* 0x0a37: test_recv */ 1667/* 0x0a2b: test_recv */
1673 0x4100f800, 1668 0x4100f800,
1674 0x11cf0458, 1669 0x11cf0458,
1675 0x0110b600, 1670 0x0110b600,
@@ -1677,28 +1672,28 @@ uint32_t gk208_pmu_code[] = {
1677 0x04bd0001, 1672 0x04bd0001,
1678 0xd900e7f1, 1673 0xd900e7f1,
1679 0x134fe3f1, 1674 0x134fe3f1,
1680 0x0002017e, 1675 0x0001f57e,
1681/* 0x0a56: test_init */ 1676/* 0x0a4a: test_init */
1682 0x004e00f8, 1677 0x004e00f8,
1683 0x02017e08, 1678 0x01f57e08,
1684/* 0x0a5f: idle_recv */ 1679/* 0x0a53: idle_recv */
1685 0xf800f800, 1680 0xf800f800,
1686/* 0x0a61: idle */ 1681/* 0x0a55: idle */
1687 0x0031f400, 1682 0x0031f400,
1688 0xcf045441, 1683 0xcf045441,
1689 0x10b60011, 1684 0x10b60011,
1690 0x04544001, 1685 0x04544001,
1691 0xbd0001f6, 1686 0xbd0001f6,
1692/* 0x0a75: idle_loop */ 1687/* 0x0a69: idle_loop */
1693 0xf4580104, 1688 0xf4580104,
1694/* 0x0a7a: idle_proc */ 1689/* 0x0a6e: idle_proc */
1695/* 0x0a7a: idle_proc_exec */ 1690/* 0x0a6e: idle_proc_exec */
1696 0x10f90232, 1691 0x10f90232,
1697 0xcb7e1eb2, 1692 0xbf7e1eb2,
1698 0x10fc0002, 1693 0x10fc0002,
1699 0xf40911f4, 1694 0xf40911f4,
1700 0x0ef40231, 1695 0x0ef40231,
1701/* 0x0a8d: idle_proc_next */ 1696/* 0x0a81: idle_proc_next */
1702 0x5810b6f0, 1697 0x5810b6f0,
1703 0x1bf41fa6, 1698 0x1bf41fa6,
1704 0xe002f4e8, 1699 0xe002f4e8,
@@ -1728,4 +1723,7 @@ uint32_t gk208_pmu_code[] = {
1728 0x00000000, 1723 0x00000000,
1729 0x00000000, 1724 0x00000000,
1730 0x00000000, 1725 0x00000000,
1726 0x00000000,
1727 0x00000000,
1728 0x00000000,
1731}; 1729};
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gt215.fuc3.h b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gt215.fuc3.h
index 2686f8fad0f5..516569270bac 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gt215.fuc3.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gt215.fuc3.h
@@ -24,8 +24,8 @@ uint32_t gt215_pmu_data[] = {
24 0x00000000, 24 0x00000000,
25/* 0x0058: proc_list_head */ 25/* 0x0058: proc_list_head */
26 0x54534f48, 26 0x54534f48,
27 0x00000512, 27 0x00000507,
28 0x000004af, 28 0x000004a4,
29 0x00000000, 29 0x00000000,
30 0x00000000, 30 0x00000000,
31 0x00000000, 31 0x00000000,
@@ -46,8 +46,8 @@ uint32_t gt215_pmu_data[] = {
46 0x00000000, 46 0x00000000,
47 0x00000000, 47 0x00000000,
48 0x584d454d, 48 0x584d454d,
49 0x00000842, 49 0x00000837,
50 0x00000834, 50 0x00000829,
51 0x00000000, 51 0x00000000,
52 0x00000000, 52 0x00000000,
53 0x00000000, 53 0x00000000,
@@ -68,8 +68,8 @@ uint32_t gt215_pmu_data[] = {
68 0x00000000, 68 0x00000000,
69 0x00000000, 69 0x00000000,
70 0x46524550, 70 0x46524550,
71 0x00000846, 71 0x0000083b,
72 0x00000844, 72 0x00000839,
73 0x00000000, 73 0x00000000,
74 0x00000000, 74 0x00000000,
75 0x00000000, 75 0x00000000,
@@ -90,8 +90,8 @@ uint32_t gt215_pmu_data[] = {
90 0x00000000, 90 0x00000000,
91 0x00000000, 91 0x00000000,
92 0x5f433249, 92 0x5f433249,
93 0x00000c76, 93 0x00000c6b,
94 0x00000b19, 94 0x00000b0e,
95 0x00000000, 95 0x00000000,
96 0x00000000, 96 0x00000000,
97 0x00000000, 97 0x00000000,
@@ -112,8 +112,8 @@ uint32_t gt215_pmu_data[] = {
112 0x00000000, 112 0x00000000,
113 0x00000000, 113 0x00000000,
114 0x54534554, 114 0x54534554,
115 0x00000c9f, 115 0x00000c94,
116 0x00000c78, 116 0x00000c6d,
117 0x00000000, 117 0x00000000,
118 0x00000000, 118 0x00000000,
119 0x00000000, 119 0x00000000,
@@ -134,8 +134,8 @@ uint32_t gt215_pmu_data[] = {
134 0x00000000, 134 0x00000000,
135 0x00000000, 135 0x00000000,
136 0x454c4449, 136 0x454c4449,
137 0x00000cab, 137 0x00000ca0,
138 0x00000ca9, 138 0x00000c9e,
139 0x00000000, 139 0x00000000,
140 0x00000000, 140 0x00000000,
141 0x00000000, 141 0x00000000,
@@ -229,26 +229,26 @@ uint32_t gt215_pmu_data[] = {
229/* 0x0370: memx_func_head */ 229/* 0x0370: memx_func_head */
230 0x00000001, 230 0x00000001,
231 0x00000000, 231 0x00000000,
232 0x00000551, 232 0x00000546,
233/* 0x037c: memx_func_next */ 233/* 0x037c: memx_func_next */
234 0x00000002, 234 0x00000002,
235 0x00000000, 235 0x00000000,
236 0x000005a8, 236 0x0000059d,
237 0x00000003, 237 0x00000003,
238 0x00000002, 238 0x00000002,
239 0x0000063a, 239 0x0000062f,
240 0x00040004, 240 0x00040004,
241 0x00000000, 241 0x00000000,
242 0x00000656, 242 0x0000064b,
243 0x00010005, 243 0x00010005,
244 0x00000000, 244 0x00000000,
245 0x00000673, 245 0x00000668,
246 0x00010006, 246 0x00010006,
247 0x00000000, 247 0x00000000,
248 0x000005f8, 248 0x000005ed,
249 0x00000007, 249 0x00000007,
250 0x00000000, 250 0x00000000,
251 0x0000067e, 251 0x00000673,
252/* 0x03c4: memx_func_tail */ 252/* 0x03c4: memx_func_tail */
253/* 0x03c4: memx_ts_start */ 253/* 0x03c4: memx_ts_start */
254 0x00000000, 254 0x00000000,
@@ -917,7 +917,7 @@ uint32_t gt215_pmu_data[] = {
917}; 917};
918 918
919uint32_t gt215_pmu_code[] = { 919uint32_t gt215_pmu_code[] = {
920 0x039e0ef5, 920 0x03930ef5,
921/* 0x0004: rd32 */ 921/* 0x0004: rd32 */
922 0x07a007f1, 922 0x07a007f1,
923 0xd00604b6, 923 0xd00604b6,
@@ -987,7 +987,7 @@ uint32_t gt215_pmu_code[] = {
987 0xbb9a0a98, 987 0xbb9a0a98,
988 0x1cf4029a, 988 0x1cf4029a,
989 0x01d7f00f, 989 0x01d7f00f,
990 0x02dd21f5, 990 0x02d221f5,
991 0x0ef494bd, 991 0x0ef494bd,
992/* 0x00f9: intr_watchdog_next_time */ 992/* 0x00f9: intr_watchdog_next_time */
993 0x9b0a9815, 993 0x9b0a9815,
@@ -1039,7 +1039,7 @@ uint32_t gt215_pmu_code[] = {
1039 0x48e7f1c0, 1039 0x48e7f1c0,
1040 0x53e3f14f, 1040 0x53e3f14f,
1041 0x00d7f054, 1041 0x00d7f054,
1042 0x034221f5, 1042 0x033721f5,
1043 0x07f1c0fc, 1043 0x07f1c0fc,
1044 0x04b604c0, 1044 0x04b604c0,
1045 0x000cd006, 1045 0x000cd006,
@@ -1048,820 +1048,818 @@ uint32_t gt215_pmu_code[] = {
1048 0x04b60688, 1048 0x04b60688,
1049 0x0009d006, 1049 0x0009d006,
1050/* 0x01ca: intr_skip_subintr */ 1050/* 0x01ca: intr_skip_subintr */
1051 0x89c404bd, 1051 0x97f104bd,
1052 0x070bf420, 1052 0x90bd00e0,
1053 0xffbfa4f1, 1053 0xf00489fd,
1054/* 0x01d4: intr_skip_pause */ 1054 0x04b60407,
1055 0xf44089c4, 1055 0x0008d006,
1056 0xa4f1070b, 1056 0x80fc04bd,
1057/* 0x01de: intr_skip_user0 */ 1057 0xfc0088fe,
1058 0x07f0ffbf, 1058 0xfce0fcf0,
1059 0x0604b604, 1059 0xfcc0fcd0,
1060 0xbd0008d0, 1060 0xfca0fcb0,
1061 0xfe80fc04, 1061 0xfc80fc90,
1062 0xf0fc0088, 1062 0x0032f400,
1063 0xd0fce0fc, 1063/* 0x01fa: ticks_from_ns */
1064 0xb0fcc0fc, 1064 0xc0f901f8,
1065 0x90fca0fc,
1066 0x00fc80fc,
1067 0xf80032f4,
1068/* 0x0205: ticks_from_ns */
1069 0xf9c0f901,
1070 0xcbd7f1b0,
1071 0x00d3f000,
1072 0x041321f5,
1073 0x03e8ccec,
1074 0xf400b4b0,
1075 0xeeec120b,
1076 0xd7f103e8,
1077 0xd3f000cb,
1078 0x1321f500,
1079/* 0x022d: ticks_from_ns_quit */
1080 0x02ceb904,
1081 0xc0fcb0fc,
1082/* 0x0236: ticks_from_us */
1083 0xc0f900f8,
1084 0xd7f1b0f9, 1065 0xd7f1b0f9,
1085 0xd3f000cb, 1066 0xd3f000cb,
1086 0x1321f500, 1067 0x0821f500,
1087 0x02ceb904, 1068 0xe8ccec04,
1088 0xf400b4b0, 1069 0x00b4b003,
1089 0xe4bd050b, 1070 0xec120bf4,
1090/* 0x0250: ticks_from_us_quit */ 1071 0xf103e8ee,
1091 0xc0fcb0fc, 1072 0xf000cbd7,
1092/* 0x0256: ticks_to_us */ 1073 0x21f500d3,
1093 0xd7f100f8, 1074/* 0x0222: ticks_from_ns_quit */
1094 0xd3f000cb, 1075 0xceb90408,
1095 0xecedff00, 1076 0xfcb0fc02,
1096/* 0x0262: timer */ 1077/* 0x022b: ticks_from_us */
1097 0x90f900f8, 1078 0xf900f8c0,
1098 0x32f480f9, 1079 0xf1b0f9c0,
1099 0x03f89810, 1080 0xf000cbd7,
1100 0xf40086b0, 1081 0x21f500d3,
1101 0x84bd651c, 1082 0xceb90408,
1102 0xb63807f0, 1083 0x00b4b002,
1103 0x08d00604, 1084 0xbd050bf4,
1104 0xf004bd00, 1085/* 0x0245: ticks_from_us_quit */
1105 0x84b63487, 1086 0xfcb0fce4,
1106 0x0088cf06, 1087/* 0x024b: ticks_to_us */
1107 0xbb9a0998, 1088 0xf100f8c0,
1108 0xe9bb0298, 1089 0xf000cbd7,
1109 0x03fe8000, 1090 0xedff00d3,
1110 0xb60887f0, 1091/* 0x0257: timer */
1111 0x88cf0684, 1092 0xf900f8ec,
1112 0x0284f000, 1093 0xf480f990,
1113 0xf0261bf4, 1094 0xf8981032,
1114 0x84b63487, 1095 0x0086b003,
1115 0x0088cf06, 1096 0xbd651cf4,
1116 0xf406e0b8, 1097 0x3807f084,
1117 0xe8b8090b,
1118 0x111cf406,
1119/* 0x02b8: timer_reset */
1120 0xb63407f0,
1121 0x0ed00604,
1122 0x8004bd00,
1123/* 0x02c6: timer_enable */
1124 0x87f09a0e,
1125 0x3807f001,
1126 0xd00604b6, 1098 0xd00604b6,
1127 0x04bd0008, 1099 0x04bd0008,
1128/* 0x02d4: timer_done */ 1100 0xb63487f0,
1129 0xfc1031f4, 1101 0x88cf0684,
1130 0xf890fc80, 1102 0x9a099800,
1131/* 0x02dd: send_proc */ 1103 0xbb0298bb,
1132 0xf980f900, 1104 0xfe8000e9,
1133 0x05e89890, 1105 0x0887f003,
1134 0xf004e998, 1106 0xcf0684b6,
1135 0x89b80486, 1107 0x84f00088,
1136 0x2a0bf406, 1108 0x261bf402,
1137 0x940398c4, 1109 0xb63487f0,
1138 0x80b60488, 1110 0x88cf0684,
1139 0x008ebb18, 1111 0x06e0b800,
1140 0x8000fa98, 1112 0xb8090bf4,
1141 0x8d80008a, 1113 0x1cf406e8,
1142 0x028c8001, 1114/* 0x02ad: timer_reset */
1143 0xb6038b80, 1115 0x3407f011,
1144 0x94f00190,
1145 0x04e98007,
1146/* 0x0317: send_done */
1147 0xfc0231f4,
1148 0xf880fc90,
1149/* 0x031d: find */
1150 0xf080f900,
1151 0x31f45887,
1152/* 0x0325: find_loop */
1153 0x008a9801,
1154 0xf406aeb8,
1155 0x80b6100b,
1156 0x6886b158,
1157 0xf01bf402,
1158/* 0x033b: find_done */
1159 0xb90132f4,
1160 0x80fc028e,
1161/* 0x0342: send */
1162 0x21f500f8,
1163 0x01f4031d,
1164/* 0x034b: recv */
1165 0xf900f897,
1166 0x9880f990,
1167 0xe99805e8,
1168 0x0132f404,
1169 0xf40689b8,
1170 0x89c43d0b,
1171 0x0180b603,
1172 0x800784f0,
1173 0xea9805e8,
1174 0xfef0f902,
1175 0xf0f9018f,
1176 0x9402efb9,
1177 0xe9bb0499,
1178 0x18e0b600,
1179 0x9803eb98,
1180 0xed9802ec,
1181 0x00ee9801,
1182 0xf0fca5f9,
1183 0xf400f8fe,
1184 0xf0fc0131,
1185/* 0x0398: recv_done */
1186 0x90fc80fc,
1187/* 0x039e: init */
1188 0x17f100f8,
1189 0x14b60108,
1190 0x0011cf06,
1191 0x010911e7,
1192 0xfe0814b6,
1193 0x17f10014,
1194 0x13f000e0,
1195 0x1c07f000,
1196 0xd00604b6,
1197 0x04bd0001,
1198 0xf0ff17f0,
1199 0x04b61407,
1200 0x0001d006,
1201 0x17f004bd,
1202 0x0015f102,
1203 0x1007f008,
1204 0xd00604b6, 1116 0xd00604b6,
1205 0x04bd0001, 1117 0x04bd000e,
1206 0x011a17f1, 1118/* 0x02bb: timer_enable */
1207 0xfe0013f0, 1119 0xf09a0e80,
1208 0x31f40010, 1120 0x07f00187,
1209 0x0117f010, 1121 0x0604b638,
1210 0xb63807f0, 1122 0xbd0008d0,
1123/* 0x02c9: timer_done */
1124 0x1031f404,
1125 0x90fc80fc,
1126/* 0x02d2: send_proc */
1127 0x80f900f8,
1128 0xe89890f9,
1129 0x04e99805,
1130 0xb80486f0,
1131 0x0bf40689,
1132 0x0398c42a,
1133 0xb6048894,
1134 0x8ebb1880,
1135 0x00fa9800,
1136 0x80008a80,
1137 0x8c80018d,
1138 0x038b8002,
1139 0xf00190b6,
1140 0xe9800794,
1141 0x0231f404,
1142/* 0x030c: send_done */
1143 0x80fc90fc,
1144/* 0x0312: find */
1145 0x80f900f8,
1146 0xf45887f0,
1147/* 0x031a: find_loop */
1148 0x8a980131,
1149 0x06aeb800,
1150 0xb6100bf4,
1151 0x86b15880,
1152 0x1bf40268,
1153 0x0132f4f0,
1154/* 0x0330: find_done */
1155 0xfc028eb9,
1156/* 0x0337: send */
1157 0xf500f880,
1158 0xf4031221,
1159 0x00f89701,
1160/* 0x0340: recv */
1161 0x80f990f9,
1162 0x9805e898,
1163 0x32f404e9,
1164 0x0689b801,
1165 0xc43d0bf4,
1166 0x80b60389,
1167 0x0784f001,
1168 0x9805e880,
1169 0xf0f902ea,
1170 0xf9018ffe,
1171 0x02efb9f0,
1172 0xbb049994,
1173 0xe0b600e9,
1174 0x03eb9818,
1175 0x9802ec98,
1176 0xee9801ed,
1177 0xfca5f900,
1178 0x00f8fef0,
1179 0xfc0131f4,
1180/* 0x038d: recv_done */
1181 0xfc80fcf0,
1182/* 0x0393: init */
1183 0xf100f890,
1184 0xb6010817,
1185 0x11cf0614,
1186 0x0911e700,
1187 0x0814b601,
1188 0xf10014fe,
1189 0xf000e017,
1190 0x07f00013,
1191 0x0604b61c,
1192 0xbd0001d0,
1193 0xff17f004,
1194 0xb61407f0,
1211 0x01d00604, 1195 0x01d00604,
1212 0xf004bd00, 1196 0xf004bd00,
1213/* 0x0402: init_proc */ 1197 0x15f10217,
1214 0xf19858f7, 1198 0x07f00800,
1215 0x0016b001, 1199 0x0604b610,
1216 0xf9fa0bf4, 1200 0xbd0001d0,
1217 0x58f0b615, 1201 0x1a17f104,
1218/* 0x0413: mulu32_32_64 */ 1202 0x0013f001,
1219 0xf9f20ef4, 1203 0xf40010fe,
1220 0xf920f910, 1204 0x17f01031,
1221 0x9540f930, 1205 0x3807f001,
1222 0xd29510e1, 1206 0xd00604b6,
1223 0xbdc4bd10, 1207 0x04bd0001,
1224 0xc0edffb4, 1208/* 0x03f7: init_proc */
1225 0xb9301dff, 1209 0x9858f7f0,
1226 0x34f10234, 1210 0x16b001f1,
1227 0x34b6ffff, 1211 0xfa0bf400,
1228 0x1045b610, 1212 0xf0b615f9,
1229 0xbb00c3bb, 1213 0xf20ef458,
1230 0xe2ff01b4, 1214/* 0x0408: mulu32_32_64 */
1231 0x0234b930, 1215 0x20f910f9,
1232 0xffff34f1, 1216 0x40f930f9,
1233 0xb61034b6, 1217 0x9510e195,
1234 0xc3bb1045, 1218 0xc4bd10d2,
1235 0x01b4bb00, 1219 0xedffb4bd,
1236 0xbb3012ff, 1220 0x301dffc0,
1237 0x40fc00b3, 1221 0xf10234b9,
1238 0x20fc30fc, 1222 0xb6ffff34,
1239 0x00f810fc, 1223 0x45b61034,
1240/* 0x0464: host_send */ 1224 0x00c3bb10,
1241 0x04b017f1, 1225 0xff01b4bb,
1242 0xcf0614b6, 1226 0x34b930e2,
1243 0x27f10011, 1227 0xff34f102,
1244 0x24b604a0, 1228 0x1034b6ff,
1245 0x0022cf06, 1229 0xbb1045b6,
1246 0xf40612b8, 1230 0xb4bb00c3,
1247 0x1ec4320b, 1231 0x3012ff01,
1248 0x04ee9407, 1232 0xfc00b3bb,
1249 0x0270e0b7, 1233 0xfc30fc40,
1250 0x9803eb98, 1234 0xf810fc20,
1251 0xed9802ec, 1235/* 0x0459: host_send */
1252 0x00ee9801, 1236 0xb017f100,
1253 0x034221f5,
1254 0xc40110b6,
1255 0x07f10f1e,
1256 0x04b604b0,
1257 0x000ed006,
1258 0x0ef404bd,
1259/* 0x04ad: host_send_done */
1260/* 0x04af: host_recv */
1261 0xf100f8ba,
1262 0xf14e4917,
1263 0xb8525413,
1264 0x0bf406e1,
1265/* 0x04bd: host_recv_wait */
1266 0xcc17f1aa,
1267 0x0614b604, 1237 0x0614b604,
1268 0xf10011cf, 1238 0xf10011cf,
1269 0xb604c827, 1239 0xb604a027,
1270 0x22cf0624, 1240 0x22cf0624,
1271 0x0816f000, 1241 0x0612b800,
1272 0xf40612b8, 1242 0xc4320bf4,
1273 0x23c4e60b, 1243 0xee94071e,
1274 0x0434b607, 1244 0x70e0b704,
1275 0x02f030b7, 1245 0x03eb9802,
1276 0x80033b80, 1246 0x9802ec98,
1277 0x3d80023c, 1247 0xee9801ed,
1278 0x003e8001, 1248 0x3721f500,
1279 0xf00120b6, 1249 0x0110b603,
1280 0x07f10f24, 1250 0xf10f1ec4,
1281 0x04b604c8, 1251 0xb604b007,
1282 0x0002d006, 1252 0x0ed00604,
1283 0x27f004bd, 1253 0xf404bd00,
1284 0x0007f040, 1254/* 0x04a2: host_send_done */
1285 0xd00604b6, 1255 0x00f8ba0e,
1286 0x04bd0002, 1256/* 0x04a4: host_recv */
1287/* 0x0512: host_init */ 1257 0x4e4917f1,
1288 0x17f100f8, 1258 0x525413f1,
1259 0xf406e1b8,
1260/* 0x04b2: host_recv_wait */
1261 0x17f1aa0b,
1262 0x14b604cc,
1263 0x0011cf06,
1264 0x04c827f1,
1265 0xcf0624b6,
1266 0x16f00022,
1267 0x0612b808,
1268 0xc4e60bf4,
1269 0x34b60723,
1270 0xf030b704,
1271 0x033b8002,
1272 0x80023c80,
1273 0x3e80013d,
1274 0x0120b600,
1275 0xf10f24f0,
1276 0xb604c807,
1277 0x02d00604,
1278 0xf004bd00,
1279 0x07f04027,
1280 0x0604b600,
1281 0xbd0002d0,
1282/* 0x0507: host_init */
1283 0xf100f804,
1284 0xb6008017,
1285 0x15f11014,
1286 0x07f10270,
1287 0x04b604d0,
1288 0x0001d006,
1289 0x17f104bd,
1289 0x14b60080, 1290 0x14b60080,
1290 0x7015f110, 1291 0xf015f110,
1291 0xd007f102, 1292 0xdc07f102,
1292 0x0604b604, 1293 0x0604b604,
1293 0xbd0001d0, 1294 0xbd0001d0,
1294 0x8017f104, 1295 0x0117f004,
1295 0x1014b600, 1296 0x04c407f1,
1296 0x02f015f1,
1297 0x04dc07f1,
1298 0xd00604b6, 1297 0xd00604b6,
1299 0x04bd0001, 1298 0x04bd0001,
1300 0xf10117f0, 1299/* 0x0546: memx_func_enter */
1301 0xb604c407, 1300 0x87f100f8,
1302 0x01d00604, 1301 0x8eb91610,
1303 0xf804bd00, 1302 0x0421f402,
1304/* 0x0551: memx_func_enter */ 1303 0xf102d7b9,
1305 0x1087f100, 1304 0xf1fffc67,
1306 0x028eb916, 1305 0xfdffff63,
1307 0xb90421f4, 1306 0x67f10476,
1308 0x67f102d7, 1307 0x76fd0002,
1309 0x63f1fffc, 1308 0xf980f905,
1310 0x76fdffff, 1309 0xfcd0fc70,
1311 0x0267f104, 1310 0x3f21f4e0,
1312 0x0576fd00,
1313 0x70f980f9,
1314 0xe0fcd0fc,
1315 0xf03f21f4,
1316 0x07f10467,
1317 0x04b607e0,
1318 0x0006d006,
1319/* 0x058a: memx_func_enter_wait */
1320 0x67f104bd,
1321 0x64b607c0,
1322 0x0066cf06,
1323 0xf40464f0,
1324 0x67f0f30b,
1325 0x0664b62c,
1326 0x800066cf,
1327 0x00f8f106,
1328/* 0x05a8: memx_func_leave */
1329 0xb62c67f0,
1330 0x66cf0664,
1331 0xf2068000,
1332 0xf10467f0, 1311 0xf10467f0,
1333 0xb607e407, 1312 0xb607e007,
1334 0x06d00604, 1313 0x06d00604,
1335/* 0x05c3: memx_func_leave_wait */ 1314/* 0x057f: memx_func_enter_wait */
1336 0xf104bd00, 1315 0xf104bd00,
1337 0xb607c067, 1316 0xb607c067,
1338 0x66cf0664, 1317 0x66cf0664,
1339 0x0464f000, 1318 0x0464f000,
1340 0xf1f31bf4, 1319 0xf0f30bf4,
1341 0xb9161087, 1320 0x64b62c67,
1342 0x21f4028e, 1321 0x0066cf06,
1343 0x02d7b904, 1322 0xf8f10680,
1344 0xffcc67f1, 1323/* 0x059d: memx_func_leave */
1345 0xffff63f1, 1324 0x2c67f000,
1346 0xf90476fd, 1325 0xcf0664b6,
1347 0xfc70f980, 1326 0x06800066,
1348 0xf4e0fcd0, 1327 0x0467f0f2,
1349 0x00f83f21, 1328 0x07e407f1,
1350/* 0x05f8: memx_func_wait_vblank */ 1329 0xd00604b6,
1351 0xb0001698, 1330 0x04bd0006,
1352 0x0bf40066, 1331/* 0x05b8: memx_func_leave_wait */
1353 0x0166b013, 1332 0x07c067f1,
1354 0xf4060bf4, 1333 0xcf0664b6,
1355/* 0x060a: memx_func_wait_vblank_head1 */ 1334 0x64f00066,
1356 0x77f12e0e, 1335 0xf31bf404,
1357 0x0ef40020, 1336 0x161087f1,
1358/* 0x0611: memx_func_wait_vblank_head0 */ 1337 0xf4028eb9,
1359 0x0877f107, 1338 0xd7b90421,
1360/* 0x0615: memx_func_wait_vblank_0 */ 1339 0xcc67f102,
1361 0xc467f100, 1340 0xff63f1ff,
1362 0x0664b607, 1341 0x0476fdff,
1363 0xfd0066cf, 1342 0x70f980f9,
1364 0x1bf40467,
1365/* 0x0625: memx_func_wait_vblank_1 */
1366 0xc467f1f3,
1367 0x0664b607,
1368 0xfd0066cf,
1369 0x0bf40467,
1370/* 0x0635: memx_func_wait_vblank_fini */
1371 0x0410b6f3,
1372/* 0x063a: memx_func_wr32 */
1373 0x169800f8,
1374 0x01159800,
1375 0xf90810b6,
1376 0xfc50f960,
1377 0xf4e0fcd0,
1378 0x42b63f21,
1379 0xe91bf402,
1380/* 0x0656: memx_func_wait */
1381 0x87f000f8,
1382 0x0684b62c,
1383 0x980088cf,
1384 0x1d98001e,
1385 0x021c9801,
1386 0xb6031b98,
1387 0x21f41010,
1388/* 0x0673: memx_func_delay */
1389 0x9800f8a4,
1390 0x10b6001e,
1391 0x7f21f404,
1392/* 0x067e: memx_func_train */
1393 0x57f100f8,
1394 0x77f10003,
1395 0x97f10000,
1396 0x93f00000,
1397 0x029eb970,
1398 0xb90421f4,
1399 0xe7f102d8,
1400 0x21f42710,
1401/* 0x069d: memx_func_train_loop_outer */
1402 0x0158e07f,
1403 0x0083f101,
1404 0xe097f102,
1405 0x1193f011,
1406 0x80f990f9,
1407 0xe0fcd0fc, 1343 0xe0fcd0fc,
1408 0xf93f21f4, 1344 0xf83f21f4,
1409 0x0067f150, 1345/* 0x05ed: memx_func_wait_vblank */
1410/* 0x06bd: memx_func_train_loop_inner */ 1346 0x00169800,
1411 0x1187f100, 1347 0xf40066b0,
1412 0x9068ff11, 1348 0x66b0130b,
1413 0xfd109894, 1349 0x060bf401,
1414 0x97f10589, 1350/* 0x05ff: memx_func_wait_vblank_head1 */
1415 0x93f00720, 1351 0xf12e0ef4,
1416 0xf990f910, 1352 0xf4002077,
1417 0xfcd0fc80, 1353/* 0x0606: memx_func_wait_vblank_head0 */
1418 0x3f21f4e0, 1354 0x77f1070e,
1419 0x008097f1, 1355/* 0x060a: memx_func_wait_vblank_0 */
1420 0xb91093f0, 1356 0x67f10008,
1421 0x21f4029e, 1357 0x64b607c4,
1422 0x02d8b904, 1358 0x0066cf06,
1423 0xf92088c5, 1359 0xf40467fd,
1424 0xfc80f990, 1360/* 0x061a: memx_func_wait_vblank_1 */
1425 0xf4e0fcd0, 1361 0x67f1f31b,
1426 0x97f13f21, 1362 0x64b607c4,
1427 0x93f0053c, 1363 0x0066cf06,
1428 0x0287f110, 1364 0xf40467fd,
1429 0x0083f130, 1365/* 0x062a: memx_func_wait_vblank_fini */
1430 0xf990f980, 1366 0x10b6f30b,
1431 0xfcd0fc80, 1367/* 0x062f: memx_func_wr32 */
1432 0x3f21f4e0, 1368 0x9800f804,
1433 0x0560e7f1, 1369 0x15980016,
1434 0xf110e3f0, 1370 0x0810b601,
1435 0xf10000d7, 1371 0x50f960f9,
1436 0x908000d3, 1372 0xe0fcd0fc,
1437 0xb7f100dc, 1373 0xb63f21f4,
1438 0xb3f08480, 1374 0x1bf40242,
1439 0xa421f41e, 1375/* 0x064b: memx_func_wait */
1440 0x000057f1, 1376 0xf000f8e9,
1441 0xffff97f1, 1377 0x84b62c87,
1442 0x830093f1, 1378 0x0088cf06,
1443/* 0x073c: memx_func_train_loop_4x */ 1379 0x98001e98,
1444 0x0080a7f1, 1380 0x1c98011d,
1445 0xb910a3f0, 1381 0x031b9802,
1446 0x21f402ae, 1382 0xf41010b6,
1447 0x02d8b904, 1383 0x00f8a421,
1448 0xffdfb7f1, 1384/* 0x0668: memx_func_delay */
1449 0xffffb3f1, 1385 0xb6001e98,
1450 0xf9048bfd, 1386 0x21f40410,
1451 0xfc80f9a0, 1387/* 0x0673: memx_func_train */
1452 0xf4e0fcd0, 1388 0xf100f87f,
1453 0xa7f13f21, 1389 0xf1000357,
1454 0xa3f0053c, 1390 0xf1000077,
1455 0x0287f110, 1391 0xf0000097,
1456 0x0083f130, 1392 0x9eb97093,
1457 0xf9a0f980, 1393 0x0421f402,
1394 0xf102d8b9,
1395 0xf42710e7,
1396/* 0x0692: memx_func_train_loop_outer */
1397 0x58e07f21,
1398 0x83f10101,
1399 0x97f10200,
1400 0x93f011e0,
1401 0xf990f911,
1458 0xfcd0fc80, 1402 0xfcd0fc80,
1459 0x3f21f4e0, 1403 0x3f21f4e0,
1460 0x0560e7f1, 1404 0x67f150f9,
1461 0xf110e3f0, 1405/* 0x06b2: memx_func_train_loop_inner */
1462 0xf10000d7, 1406 0x87f10000,
1463 0xb98000d3, 1407 0x68ff1111,
1464 0xb7f102dc, 1408 0x10989490,
1465 0xb3f02710, 1409 0xf10589fd,
1466 0xa421f400, 1410 0xf0072097,
1467 0xf402eeb9, 1411 0x90f91093,
1468 0xddb90421, 1412 0xd0fc80f9,
1469 0x949dff02, 1413 0x21f4e0fc,
1414 0x8097f13f,
1415 0x1093f000,
1416 0xf4029eb9,
1417 0xd8b90421,
1418 0x2088c502,
1419 0x80f990f9,
1420 0xe0fcd0fc,
1421 0xf13f21f4,
1422 0xf0053c97,
1423 0x87f11093,
1424 0x83f13002,
1425 0x90f98000,
1426 0xd0fc80f9,
1427 0x21f4e0fc,
1428 0x60e7f13f,
1429 0x10e3f005,
1430 0x0000d7f1,
1431 0x8000d3f1,
1432 0xf100dc90,
1433 0xf08480b7,
1434 0x21f41eb3,
1435 0x0057f1a4,
1436 0xff97f100,
1437 0x0093f1ff,
1438/* 0x0731: memx_func_train_loop_4x */
1439 0x80a7f183,
1440 0x10a3f000,
1441 0xf402aeb9,
1442 0xd8b90421,
1443 0xdfb7f102,
1444 0xffb3f1ff,
1445 0x048bfdff,
1446 0x80f9a0f9,
1447 0xe0fcd0fc,
1448 0xf13f21f4,
1449 0xf0053ca7,
1450 0x87f110a3,
1451 0x83f13002,
1452 0xa0f98000,
1453 0xd0fc80f9,
1454 0x21f4e0fc,
1455 0x60e7f13f,
1456 0x10e3f005,
1457 0x0000d7f1,
1458 0x8000d3f1,
1459 0xf102dcb9,
1460 0xf02710b7,
1461 0x21f400b3,
1462 0x02eeb9a4,
1463 0xb90421f4,
1464 0x9dff02dd,
1465 0x0150b694,
1466 0xf4045670,
1467 0x7aa0921e,
1468 0xa9800bcc,
1469 0x0160b600,
1470 0x700470b6,
1471 0x1ef51066,
1472 0x50fcff00,
1470 0x700150b6, 1473 0x700150b6,
1471 0x1ef40456, 1474 0x1ef50756,
1472 0xcc7aa092, 1475 0x00f8fed4,
1473 0x00a9800b, 1476/* 0x07c4: memx_exec */
1474 0xb60160b6, 1477 0xd0f9e0f9,
1475 0x66700470, 1478 0xb902c1b9,
1476 0x001ef510, 1479/* 0x07ce: memx_exec_next */
1477 0xb650fcff, 1480 0x139802b2,
1478 0x56700150, 1481 0x0410b600,
1479 0xd41ef507, 1482 0x01f034e7,
1480/* 0x07cf: memx_exec */ 1483 0x01e033e7,
1481 0xf900f8fe, 1484 0xf00132b6,
1482 0xb9d0f9e0, 1485 0x35980c30,
1483 0xb2b902c1, 1486 0xb855f9de,
1484/* 0x07d9: memx_exec_next */ 1487 0x1ef40612,
1485 0x00139802, 1488 0xf10b98e4,
1486 0xe70410b6, 1489 0xbbf20c98,
1487 0xe701f034, 1490 0xb7f102cb,
1488 0xb601e033, 1491 0xb4b607c4,
1489 0x30f00132, 1492 0x00bbcf06,
1490 0xde35980c, 1493 0xe0fcd0fc,
1491 0x12b855f9, 1494 0x033721f5,
1492 0xe41ef406, 1495/* 0x080a: memx_info */
1493 0x98f10b98, 1496 0xc67000f8,
1494 0xcbbbf20c, 1497 0x0e0bf401,
1495 0xc4b7f102, 1498/* 0x0810: memx_info_data */
1496 0x06b4b607, 1499 0x03ccc7f1,
1497 0xfc00bbcf, 1500 0x0800b7f1,
1498 0xf5e0fcd0, 1501/* 0x081b: memx_info_train */
1499 0xf8034221, 1502 0xf10b0ef4,
1500/* 0x0815: memx_info */ 1503 0xf10bccc7,
1501 0x01c67000, 1504/* 0x0823: memx_info_send */
1502/* 0x081b: memx_info_data */ 1505 0xf50100b7,
1503 0xf10e0bf4, 1506 0xf8033721,
1504 0xf103ccc7, 1507/* 0x0829: memx_recv */
1505 0xf40800b7, 1508 0x01d6b000,
1506/* 0x0826: memx_info_train */ 1509 0xb0980bf4,
1507 0xc7f10b0e, 1510 0x0bf400d6,
1508 0xb7f10bcc, 1511/* 0x0837: memx_init */
1509/* 0x082e: memx_info_send */ 1512 0xf800f8d8,
1510 0x21f50100, 1513/* 0x0839: perf_recv */
1511 0x00f80342, 1514/* 0x083b: perf_init */
1512/* 0x0834: memx_recv */ 1515 0xf800f800,
1513 0xf401d6b0, 1516/* 0x083d: i2c_drive_scl */
1514 0xd6b0980b, 1517 0x0036b000,
1515 0xd80bf400, 1518 0xf1110bf4,
1516/* 0x0842: memx_init */ 1519 0xb607e007,
1517 0x00f800f8, 1520 0x01d00604,
1518/* 0x0844: perf_recv */ 1521 0xf804bd00,
1519/* 0x0846: perf_init */ 1522/* 0x0851: i2c_drive_scl_lo */
1520 0x00f800f8, 1523 0xe407f100,
1521/* 0x0848: i2c_drive_scl */ 1524 0x0604b607,
1522 0xf40036b0, 1525 0xbd0001d0,
1523 0x07f1110b, 1526/* 0x085f: i2c_drive_sda */
1524 0x04b607e0, 1527 0xb000f804,
1525 0x0001d006, 1528 0x0bf40036,
1526 0x00f804bd, 1529 0xe007f111,
1527/* 0x085c: i2c_drive_scl_lo */ 1530 0x0604b607,
1528 0x07e407f1, 1531 0xbd0002d0,
1529 0xd00604b6, 1532/* 0x0873: i2c_drive_sda_lo */
1530 0x04bd0001, 1533 0xf100f804,
1531/* 0x086a: i2c_drive_sda */ 1534 0xb607e407,
1532 0x36b000f8, 1535 0x02d00604,
1533 0x110bf400, 1536 0xf804bd00,
1534 0x07e007f1, 1537/* 0x0881: i2c_sense_scl */
1535 0xd00604b6, 1538 0x0132f400,
1536 0x04bd0002, 1539 0x07c437f1,
1537/* 0x087e: i2c_drive_sda_lo */ 1540 0xcf0634b6,
1538 0x07f100f8, 1541 0x31fd0033,
1539 0x04b607e4, 1542 0x060bf404,
1540 0x0002d006, 1543/* 0x0897: i2c_sense_scl_done */
1541 0x00f804bd, 1544 0xf80131f4,
1542/* 0x088c: i2c_sense_scl */ 1545/* 0x0899: i2c_sense_sda */
1543 0xf10132f4, 1546 0x0132f400,
1544 0xb607c437, 1547 0x07c437f1,
1545 0x33cf0634, 1548 0xcf0634b6,
1546 0x0431fd00, 1549 0x32fd0033,
1547 0xf4060bf4, 1550 0x060bf404,
1548/* 0x08a2: i2c_sense_scl_done */ 1551/* 0x08af: i2c_sense_sda_done */
1549 0x00f80131, 1552 0xf80131f4,
1550/* 0x08a4: i2c_sense_sda */ 1553/* 0x08b1: i2c_raise_scl */
1551 0xf10132f4, 1554 0xf140f900,
1552 0xb607c437, 1555 0xf0089847,
1553 0x33cf0634, 1556 0x21f50137,
1554 0x0432fd00, 1557/* 0x08be: i2c_raise_scl_wait */
1555 0xf4060bf4, 1558 0xe7f1083d,
1556/* 0x08ba: i2c_sense_sda_done */ 1559 0x21f403e8,
1557 0x00f80131, 1560 0x8121f57f,
1558/* 0x08bc: i2c_raise_scl */ 1561 0x0901f408,
1559 0x47f140f9, 1562 0xf40142b6,
1560 0x37f00898, 1563/* 0x08d2: i2c_raise_scl_done */
1561 0x4821f501, 1564 0x40fcef1b,
1562/* 0x08c9: i2c_raise_scl_wait */ 1565/* 0x08d6: i2c_start */
1566 0x21f500f8,
1567 0x11f40881,
1568 0x9921f50d,
1569 0x0611f408,
1570/* 0x08e7: i2c_start_rep */
1571 0xf0300ef4,
1572 0x21f50037,
1573 0x37f0083d,
1574 0x5f21f501,
1575 0x0076bb08,
1576 0xf90465b6,
1577 0x04659450,
1578 0xbd0256bb,
1579 0x0475fd50,
1580 0x21f550fc,
1581 0x64b608b1,
1582 0x1f11f404,
1583/* 0x0914: i2c_start_send */
1584 0xf50037f0,
1585 0xf1085f21,
1586 0xf41388e7,
1587 0x37f07f21,
1588 0x3d21f500,
1589 0x88e7f108,
1590 0x7f21f413,
1591/* 0x0930: i2c_start_out */
1592/* 0x0932: i2c_stop */
1593 0x37f000f8,
1594 0x3d21f500,
1595 0x0037f008,
1596 0x085f21f5,
1597 0x03e8e7f1,
1598 0xf07f21f4,
1599 0x21f50137,
1600 0xe7f1083d,
1601 0x21f41388,
1602 0x0137f07f,
1603 0x085f21f5,
1604 0x1388e7f1,
1605 0xf87f21f4,
1606/* 0x0965: i2c_bitw */
1607 0x5f21f500,
1563 0xe8e7f108, 1608 0xe8e7f108,
1564 0x7f21f403, 1609 0x7f21f403,
1565 0x088c21f5,
1566 0xb60901f4,
1567 0x1bf40142,
1568/* 0x08dd: i2c_raise_scl_done */
1569 0xf840fcef,
1570/* 0x08e1: i2c_start */
1571 0x8c21f500,
1572 0x0d11f408,
1573 0x08a421f5,
1574 0xf40611f4,
1575/* 0x08f2: i2c_start_rep */
1576 0x37f0300e,
1577 0x4821f500,
1578 0x0137f008,
1579 0x086a21f5,
1580 0xb60076bb, 1610 0xb60076bb,
1581 0x50f90465, 1611 0x50f90465,
1582 0xbb046594, 1612 0xbb046594,
1583 0x50bd0256, 1613 0x50bd0256,
1584 0xfc0475fd, 1614 0xfc0475fd,
1585 0xbc21f550, 1615 0xb121f550,
1586 0x0464b608, 1616 0x0464b608,
1587/* 0x091f: i2c_start_send */ 1617 0xf11811f4,
1588 0xf01f11f4, 1618 0xf41388e7,
1589 0x21f50037,
1590 0xe7f1086a,
1591 0x21f41388,
1592 0x0037f07f,
1593 0x084821f5,
1594 0x1388e7f1,
1595/* 0x093b: i2c_start_out */
1596 0xf87f21f4,
1597/* 0x093d: i2c_stop */
1598 0x0037f000,
1599 0x084821f5,
1600 0xf50037f0,
1601 0xf1086a21,
1602 0xf403e8e7,
1603 0x37f07f21, 1619 0x37f07f21,
1604 0x4821f501, 1620 0x3d21f500,
1605 0x88e7f108, 1621 0x88e7f108,
1606 0x7f21f413, 1622 0x7f21f413,
1607 0xf50137f0, 1623/* 0x09a4: i2c_bitw_out */
1608 0xf1086a21, 1624/* 0x09a6: i2c_bitr */
1609 0xf41388e7, 1625 0x37f000f8,
1610 0x00f87f21, 1626 0x5f21f501,
1611/* 0x0970: i2c_bitw */ 1627 0xe8e7f108,
1612 0x086a21f5, 1628 0x7f21f403,
1613 0x03e8e7f1, 1629 0xb60076bb,
1614 0xbb7f21f4, 1630 0x50f90465,
1615 0x65b60076, 1631 0xbb046594,
1616 0x9450f904, 1632 0x50bd0256,
1617 0x56bb0465, 1633 0xfc0475fd,
1618 0xfd50bd02, 1634 0xb121f550,
1619 0x50fc0475, 1635 0x0464b608,
1620 0x08bc21f5, 1636 0xf51b11f4,
1621 0xf40464b6, 1637 0xf0089921,
1622 0xe7f11811, 1638 0x21f50037,
1639 0xe7f1083d,
1623 0x21f41388, 1640 0x21f41388,
1624 0x0037f07f, 1641 0x013cf07f,
1625 0x084821f5, 1642/* 0x09eb: i2c_bitr_done */
1626 0x1388e7f1, 1643 0xf80131f4,
1627/* 0x09af: i2c_bitw_out */ 1644/* 0x09ed: i2c_get_byte */
1628 0xf87f21f4, 1645 0x0057f000,
1629/* 0x09b1: i2c_bitr */ 1646/* 0x09f3: i2c_get_byte_next */
1630 0x0137f000, 1647 0xb60847f0,
1631 0x086a21f5, 1648 0x76bb0154,
1632 0x03e8e7f1, 1649 0x0465b600,
1633 0xbb7f21f4, 1650 0x659450f9,
1634 0x65b60076, 1651 0x0256bb04,
1635 0x9450f904, 1652 0x75fd50bd,
1636 0x56bb0465, 1653 0xf550fc04,
1637 0xfd50bd02, 1654 0xb609a621,
1638 0x50fc0475, 1655 0x11f40464,
1639 0x08bc21f5, 1656 0x0553fd2b,
1640 0xf40464b6, 1657 0xf40142b6,
1641 0x21f51b11, 1658 0x37f0d81b,
1642 0x37f008a4,
1643 0x4821f500,
1644 0x88e7f108,
1645 0x7f21f413,
1646 0xf4013cf0,
1647/* 0x09f6: i2c_bitr_done */
1648 0x00f80131,
1649/* 0x09f8: i2c_get_byte */
1650 0xf00057f0,
1651/* 0x09fe: i2c_get_byte_next */
1652 0x54b60847,
1653 0x0076bb01, 1659 0x0076bb01,
1654 0xf90465b6, 1660 0xf90465b6,
1655 0x04659450, 1661 0x04659450,
1656 0xbd0256bb, 1662 0xbd0256bb,
1657 0x0475fd50, 1663 0x0475fd50,
1658 0x21f550fc, 1664 0x21f550fc,
1659 0x64b609b1, 1665 0x64b60965,
1660 0x2b11f404, 1666/* 0x0a3d: i2c_get_byte_done */
1661 0xb60553fd, 1667/* 0x0a3f: i2c_put_byte */
1662 0x1bf40142, 1668 0xf000f804,
1663 0x0137f0d8, 1669/* 0x0a42: i2c_put_byte_next */
1664 0xb60076bb, 1670 0x42b60847,
1665 0x50f90465, 1671 0x3854ff01,
1666 0xbb046594,
1667 0x50bd0256,
1668 0xfc0475fd,
1669 0x7021f550,
1670 0x0464b609,
1671/* 0x0a48: i2c_get_byte_done */
1672/* 0x0a4a: i2c_put_byte */
1673 0x47f000f8,
1674/* 0x0a4d: i2c_put_byte_next */
1675 0x0142b608,
1676 0xbb3854ff,
1677 0x65b60076,
1678 0x9450f904,
1679 0x56bb0465,
1680 0xfd50bd02,
1681 0x50fc0475,
1682 0x097021f5,
1683 0xf40464b6,
1684 0x46b03411,
1685 0xd81bf400,
1686 0xb60076bb, 1672 0xb60076bb,
1687 0x50f90465, 1673 0x50f90465,
1688 0xbb046594, 1674 0xbb046594,
1689 0x50bd0256, 1675 0x50bd0256,
1690 0xfc0475fd, 1676 0xfc0475fd,
1691 0xb121f550, 1677 0x6521f550,
1692 0x0464b609, 1678 0x0464b609,
1693 0xbb0f11f4, 1679 0xb03411f4,
1694 0x36b00076, 1680 0x1bf40046,
1695 0x061bf401, 1681 0x0076bbd8,
1696/* 0x0aa3: i2c_put_byte_done */
1697 0xf80132f4,
1698/* 0x0aa5: i2c_addr */
1699 0x0076bb00,
1700 0xf90465b6, 1682 0xf90465b6,
1701 0x04659450, 1683 0x04659450,
1702 0xbd0256bb, 1684 0xbd0256bb,
1703 0x0475fd50, 1685 0x0475fd50,
1704 0x21f550fc, 1686 0x21f550fc,
1705 0x64b608e1, 1687 0x64b609a6,
1706 0x2911f404, 1688 0x0f11f404,
1707 0x012ec3e7, 1689 0xb00076bb,
1708 0xfd0134b6, 1690 0x1bf40136,
1709 0x76bb0553, 1691 0x0132f406,
1692/* 0x0a98: i2c_put_byte_done */
1693/* 0x0a9a: i2c_addr */
1694 0x76bb00f8,
1710 0x0465b600, 1695 0x0465b600,
1711 0x659450f9, 1696 0x659450f9,
1712 0x0256bb04, 1697 0x0256bb04,
1713 0x75fd50bd, 1698 0x75fd50bd,
1714 0xf550fc04, 1699 0xf550fc04,
1715 0xb60a4a21, 1700 0xb608d621,
1716/* 0x0aea: i2c_addr_done */ 1701 0x11f40464,
1717 0x00f80464, 1702 0x2ec3e729,
1718/* 0x0aec: i2c_acquire_addr */ 1703 0x0134b601,
1719 0xb6f8cec7, 1704 0xbb0553fd,
1720 0xe0b702e4,
1721 0xee980d1c,
1722/* 0x0afb: i2c_acquire */
1723 0xf500f800,
1724 0xf40aec21,
1725 0xd9f00421,
1726 0x3f21f403,
1727/* 0x0b0a: i2c_release */
1728 0x21f500f8,
1729 0x21f40aec,
1730 0x03daf004,
1731 0xf83f21f4,
1732/* 0x0b19: i2c_recv */
1733 0x0132f400,
1734 0xb6f8c1c7,
1735 0x16b00214,
1736 0x3a1ff528,
1737 0xf413a001,
1738 0x0032980c,
1739 0x0ccc13a0,
1740 0xf4003198,
1741 0xd0f90231,
1742 0xd0f9e0f9,
1743 0x000067f1,
1744 0x100063f1,
1745 0xbb016792,
1746 0x65b60076, 1705 0x65b60076,
1747 0x9450f904, 1706 0x9450f904,
1748 0x56bb0465, 1707 0x56bb0465,
1749 0xfd50bd02, 1708 0xfd50bd02,
1750 0x50fc0475, 1709 0x50fc0475,
1751 0x0afb21f5, 1710 0x0a3f21f5,
1752 0xfc0464b6, 1711/* 0x0adf: i2c_addr_done */
1753 0x00d6b0d0, 1712 0xf80464b6,
1754 0x00b31bf5, 1713/* 0x0ae1: i2c_acquire_addr */
1755 0xbb0057f0, 1714 0xf8cec700,
1715 0xb702e4b6,
1716 0x980d1ce0,
1717 0x00f800ee,
1718/* 0x0af0: i2c_acquire */
1719 0x0ae121f5,
1720 0xf00421f4,
1721 0x21f403d9,
1722/* 0x0aff: i2c_release */
1723 0xf500f83f,
1724 0xf40ae121,
1725 0xdaf00421,
1726 0x3f21f403,
1727/* 0x0b0e: i2c_recv */
1728 0x32f400f8,
1729 0xf8c1c701,
1730 0xb00214b6,
1731 0x1ff52816,
1732 0x13a0013a,
1733 0x32980cf4,
1734 0xcc13a000,
1735 0x0031980c,
1736 0xf90231f4,
1737 0xf9e0f9d0,
1738 0x0067f1d0,
1739 0x0063f100,
1740 0x01679210,
1741 0xb60076bb,
1742 0x50f90465,
1743 0xbb046594,
1744 0x50bd0256,
1745 0xfc0475fd,
1746 0xf021f550,
1747 0x0464b60a,
1748 0xd6b0d0fc,
1749 0xb31bf500,
1750 0x0057f000,
1751 0xb60076bb,
1752 0x50f90465,
1753 0xbb046594,
1754 0x50bd0256,
1755 0xfc0475fd,
1756 0x9a21f550,
1757 0x0464b60a,
1758 0x00d011f5,
1759 0xbbe0c5c7,
1756 0x65b60076, 1760 0x65b60076,
1757 0x9450f904, 1761 0x9450f904,
1758 0x56bb0465, 1762 0x56bb0465,
1759 0xfd50bd02, 1763 0xfd50bd02,
1760 0x50fc0475, 1764 0x50fc0475,
1761 0x0aa521f5, 1765 0x0a3f21f5,
1762 0xf50464b6, 1766 0xf50464b6,
1763 0xc700d011, 1767 0xf000ad11,
1764 0x76bbe0c5, 1768 0x76bb0157,
1765 0x0465b600, 1769 0x0465b600,
1766 0x659450f9, 1770 0x659450f9,
1767 0x0256bb04, 1771 0x0256bb04,
1768 0x75fd50bd, 1772 0x75fd50bd,
1769 0xf550fc04, 1773 0xf550fc04,
1770 0xb60a4a21, 1774 0xb60a9a21,
1771 0x11f50464, 1775 0x11f50464,
1772 0x57f000ad, 1776 0x76bb008a,
1773 0x0076bb01, 1777 0x0465b600,
1774 0xf90465b6, 1778 0x659450f9,
1775 0x04659450, 1779 0x0256bb04,
1776 0xbd0256bb, 1780 0x75fd50bd,
1777 0x0475fd50, 1781 0xf550fc04,
1778 0x21f550fc, 1782 0xb609ed21,
1779 0x64b60aa5, 1783 0x11f40464,
1780 0x8a11f504, 1784 0xe05bcb6a,
1781 0x0076bb00, 1785 0xb60076bb,
1782 0xf90465b6, 1786 0x50f90465,
1783 0x04659450, 1787 0xbb046594,
1784 0xbd0256bb, 1788 0x50bd0256,
1785 0x0475fd50, 1789 0xfc0475fd,
1786 0x21f550fc, 1790 0x3221f550,
1787 0x64b609f8, 1791 0x0464b609,
1788 0x6a11f404, 1792 0xbd025bb9,
1789 0xbbe05bcb, 1793 0x430ef474,
1790 0x65b60076, 1794/* 0x0c14: i2c_recv_not_rd08 */
1791 0x9450f904, 1795 0xf401d6b0,
1792 0x56bb0465, 1796 0x57f03d1b,
1793 0xfd50bd02, 1797 0x9a21f500,
1794 0x50fc0475, 1798 0x3311f40a,
1795 0x093d21f5, 1799 0xf5e0c5c7,
1796 0xb90464b6, 1800 0xf40a3f21,
1797 0x74bd025b, 1801 0x57f02911,
1798/* 0x0c1f: i2c_recv_not_rd08 */ 1802 0x9a21f500,
1799 0xb0430ef4, 1803 0x1f11f40a,
1800 0x1bf401d6, 1804 0xf5e0b5c7,
1801 0x0057f03d, 1805 0xf40a3f21,
1802 0x0aa521f5, 1806 0x21f51511,
1803 0xc73311f4, 1807 0x74bd0932,
1804 0x21f5e0c5, 1808 0xf408c5c7,
1805 0x11f40a4a, 1809 0x32f4091b,
1806 0x0057f029, 1810 0x030ef402,
1807 0x0aa521f5, 1811/* 0x0c54: i2c_recv_not_wr08 */
1808 0xc71f11f4, 1812/* 0x0c54: i2c_recv_done */
1809 0x21f5e0b5, 1813 0xf5f8cec7,
1810 0x11f40a4a, 1814 0xfc0aff21,
1811 0x3d21f515, 1815 0xf4d0fce0,
1812 0xc774bd09, 1816 0x7cb90a12,
1813 0x1bf408c5, 1817 0x3721f502,
1814 0x0232f409, 1818/* 0x0c69: i2c_recv_exit */
1815/* 0x0c5f: i2c_recv_not_wr08 */ 1819/* 0x0c6b: i2c_init */
1816/* 0x0c5f: i2c_recv_done */ 1820 0xf800f803,
1817 0xc7030ef4, 1821/* 0x0c6d: test_recv */
1818 0x21f5f8ce, 1822 0xd817f100,
1819 0xe0fc0b0a, 1823 0x0614b605,
1820 0x12f4d0fc, 1824 0xb60011cf,
1821 0x027cb90a, 1825 0x07f10110,
1822 0x034221f5, 1826 0x04b605d8,
1823/* 0x0c74: i2c_recv_exit */ 1827 0x0001d006,
1824/* 0x0c76: i2c_init */ 1828 0xe7f104bd,
1829 0xe3f1d900,
1830 0x21f5134f,
1831 0x00f80257,
1832/* 0x0c94: test_init */
1833 0x0800e7f1,
1834 0x025721f5,
1835/* 0x0c9e: idle_recv */
1825 0x00f800f8, 1836 0x00f800f8,
1826/* 0x0c78: test_recv */ 1837/* 0x0ca0: idle */
1827 0x05d817f1, 1838 0xf10031f4,
1828 0xcf0614b6, 1839 0xb605d417,
1829 0x10b60011, 1840 0x11cf0614,
1830 0xd807f101, 1841 0x0110b600,
1831 0x0604b605, 1842 0x05d407f1,
1832 0xbd0001d0, 1843 0xd00604b6,
1833 0x00e7f104, 1844 0x04bd0001,
1834 0x4fe3f1d9, 1845/* 0x0cbc: idle_loop */
1835 0x6221f513, 1846 0xf45817f0,
1836/* 0x0c9f: test_init */ 1847/* 0x0cc2: idle_proc */
1837 0xf100f802, 1848/* 0x0cc2: idle_proc_exec */
1838 0xf50800e7, 1849 0x10f90232,
1839 0xf8026221, 1850 0xf5021eb9,
1840/* 0x0ca9: idle_recv */ 1851 0xfc034021,
1841/* 0x0cab: idle */ 1852 0x0911f410,
1842 0xf400f800, 1853 0xf40231f4,
1843 0x17f10031, 1854/* 0x0cd6: idle_proc_next */
1844 0x14b605d4, 1855 0x10b6ef0e,
1845 0x0011cf06, 1856 0x061fb858,
1846 0xf10110b6, 1857 0xf4e61bf4,
1847 0xb605d407, 1858 0x28f4dd02,
1848 0x01d00604, 1859 0xbb0ef400,
1849/* 0x0cc7: idle_loop */ 1860 0x00000000,
1850 0xf004bd00, 1861 0x00000000,
1851 0x32f45817, 1862 0x00000000,
1852/* 0x0ccd: idle_proc */
1853/* 0x0ccd: idle_proc_exec */
1854 0xb910f902,
1855 0x21f5021e,
1856 0x10fc034b,
1857 0xf40911f4,
1858 0x0ef40231,
1859/* 0x0ce1: idle_proc_next */
1860 0x5810b6ef,
1861 0xf4061fb8,
1862 0x02f4e61b,
1863 0x0028f4dd,
1864 0x00bb0ef4,
1865 0x00000000, 1863 0x00000000,
1866 0x00000000, 1864 0x00000000,
1867 0x00000000, 1865 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/kernel.fuc b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/kernel.fuc
index 5cf5be63cbef..ad35fa57be94 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/kernel.fuc
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/kernel.fuc
@@ -225,17 +225,11 @@ intr:
225 nv_iowr(NV_PPWR_SUBINTR, $r9) 225 nv_iowr(NV_PPWR_SUBINTR, $r9)
226 226
227 intr_skip_subintr: 227 intr_skip_subintr:
228 and $r9 $r8 NV_PPWR_INTR_PAUSE 228 mov $r9 (NV_PPWR_INTR_USER0 | NV_PPWR_INTR_USER1 | NV_PPWR_INTR_PAUSE)
229 bra z #intr_skip_pause 229 not b32 $r9
230 and $r10 0xffbf 230 and $r8 $r9
231
232 intr_skip_pause:
233 and $r9 $r8 NV_PPWR_INTR_USER0
234 bra z #intr_skip_user0
235 and $r10 0xffbf
236
237 intr_skip_user0:
238 nv_iowr(NV_PPWR_INTR_ACK, $r8) 231 nv_iowr(NV_PPWR_INTR_ACK, $r8)
232
239 pop $r8 233 pop $r8
240 mov $flags $r8 234 mov $flags $r8
241 pop $r15 235 pop $r15
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c
index 6326fdc5a48d..2c92ffb5f9d0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c
@@ -107,7 +107,7 @@ nv40_fan_pwm_ctrl(struct nvkm_therm *therm, int line, bool enable)
107{ 107{
108 struct nvkm_subdev *subdev = &therm->subdev; 108 struct nvkm_subdev *subdev = &therm->subdev;
109 struct nvkm_device *device = subdev->device; 109 struct nvkm_device *device = subdev->device;
110 u32 mask = enable ? 0x80000000 : 0x0000000; 110 u32 mask = enable ? 0x80000000 : 0x00000000;
111 if (line == 2) nvkm_mask(device, 0x0010f0, 0x80000000, mask); 111 if (line == 2) nvkm_mask(device, 0x0010f0, 0x80000000, mask);
112 else if (line == 9) nvkm_mask(device, 0x0015f4, 0x80000000, mask); 112 else if (line == 9) nvkm_mask(device, 0x0015f4, 0x80000000, mask);
113 else { 113 else {
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 9e7e2bf03b81..5eae0a88dd3e 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -3150,7 +3150,8 @@ void r100_bandwidth_update(struct radeon_device *rdev)
3150{ 3150{
3151 fixed20_12 trcd_ff, trp_ff, tras_ff, trbs_ff, tcas_ff; 3151 fixed20_12 trcd_ff, trp_ff, tras_ff, trbs_ff, tcas_ff;
3152 fixed20_12 sclk_ff, mclk_ff, sclk_eff_ff, sclk_delay_ff; 3152 fixed20_12 sclk_ff, mclk_ff, sclk_eff_ff, sclk_delay_ff;
3153 fixed20_12 peak_disp_bw, mem_bw, pix_clk, pix_clk2, temp_ff, crit_point_ff; 3153 fixed20_12 peak_disp_bw, mem_bw, pix_clk, pix_clk2, temp_ff;
3154 fixed20_12 crit_point_ff = {0};
3154 uint32_t temp, data, mem_trcd, mem_trp, mem_tras; 3155 uint32_t temp, data, mem_trcd, mem_trp, mem_tras;
3155 fixed20_12 memtcas_ff[8] = { 3156 fixed20_12 memtcas_ff[8] = {
3156 dfixed_init(1), 3157 dfixed_init(1),
@@ -3204,7 +3205,7 @@ void r100_bandwidth_update(struct radeon_device *rdev)
3204 fixed20_12 min_mem_eff; 3205 fixed20_12 min_mem_eff;
3205 fixed20_12 mc_latency_sclk, mc_latency_mclk, k1; 3206 fixed20_12 mc_latency_sclk, mc_latency_mclk, k1;
3206 fixed20_12 cur_latency_mclk, cur_latency_sclk; 3207 fixed20_12 cur_latency_mclk, cur_latency_sclk;
3207 fixed20_12 disp_latency, disp_latency_overhead, disp_drain_rate, 3208 fixed20_12 disp_latency, disp_latency_overhead, disp_drain_rate = {0},
3208 disp_drain_rate2, read_return_rate; 3209 disp_drain_rate2, read_return_rate;
3209 fixed20_12 time_disp1_drop_priority; 3210 fixed20_12 time_disp1_drop_priority;
3210 int c; 3211 int c;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index d690df545b4d..902b59cebac5 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1150,7 +1150,7 @@ static void radeon_check_arguments(struct radeon_device *rdev)
1150 } 1150 }
1151 1151
1152 if (radeon_vm_size < 1) { 1152 if (radeon_vm_size < 1) {
1153 dev_warn(rdev->dev, "VM size (%d) to small, min is 1GB\n", 1153 dev_warn(rdev->dev, "VM size (%d) too small, min is 1GB\n",
1154 radeon_vm_size); 1154 radeon_vm_size);
1155 radeon_vm_size = 4; 1155 radeon_vm_size = 4;
1156 } 1156 }
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 4fab44e0f36b..414953c46a38 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -759,7 +759,7 @@ u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe)
759 u32 count; 759 u32 count;
760 struct radeon_device *rdev = dev->dev_private; 760 struct radeon_device *rdev = dev->dev_private;
761 761
762 if (pipe < 0 || pipe >= rdev->num_crtc) { 762 if (pipe >= rdev->num_crtc) {
763 DRM_ERROR("Invalid crtc %u\n", pipe); 763 DRM_ERROR("Invalid crtc %u\n", pipe);
764 return -EINVAL; 764 return -EINVAL;
765 } 765 }
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 59abebd6b5dc..460c8f2989da 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -713,7 +713,7 @@ static struct attribute *hwmon_attributes[] = {
713static umode_t hwmon_attributes_visible(struct kobject *kobj, 713static umode_t hwmon_attributes_visible(struct kobject *kobj,
714 struct attribute *attr, int index) 714 struct attribute *attr, int index)
715{ 715{
716 struct device *dev = container_of(kobj, struct device, kobj); 716 struct device *dev = kobj_to_dev(kobj);
717 struct radeon_device *rdev = dev_get_drvdata(dev); 717 struct radeon_device *rdev = dev_get_drvdata(dev);
718 umode_t effective_mode = attr->mode; 718 umode_t effective_mode = attr->mode;
719 719
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 745e996d2dbc..4cbf26555093 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -176,7 +176,7 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
176 list_add_tail(&bo->lru, &man->lru); 176 list_add_tail(&bo->lru, &man->lru);
177 kref_get(&bo->list_kref); 177 kref_get(&bo->list_kref);
178 178
179 if (bo->ttm != NULL) { 179 if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) {
180 list_add_tail(&bo->swap, &bo->glob->swap_lru); 180 list_add_tail(&bo->swap, &bo->glob->swap_lru);
181 kref_get(&bo->list_kref); 181 kref_get(&bo->list_kref);
182 } 182 }
@@ -228,6 +228,27 @@ void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo)
228} 228}
229EXPORT_SYMBOL(ttm_bo_del_sub_from_lru); 229EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);
230 230
231void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
232{
233 struct ttm_bo_device *bdev = bo->bdev;
234 struct ttm_mem_type_manager *man;
235
236 lockdep_assert_held(&bo->resv->lock.base);
237
238 if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
239 list_del_init(&bo->swap);
240 list_del_init(&bo->lru);
241
242 } else {
243 if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG))
244 list_move_tail(&bo->swap, &bo->glob->swap_lru);
245
246 man = &bdev->man[bo->mem.mem_type];
247 list_move_tail(&bo->lru, &man->lru);
248 }
249}
250EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
251
231/* 252/*
232 * Call bo->mutex locked. 253 * Call bo->mutex locked.
233 */ 254 */
@@ -1170,9 +1191,15 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
1170 if (likely(!ret)) 1191 if (likely(!ret))
1171 ret = ttm_bo_validate(bo, placement, interruptible, false); 1192 ret = ttm_bo_validate(bo, placement, interruptible, false);
1172 1193
1173 if (!resv) 1194 if (!resv) {
1174 ttm_bo_unreserve(bo); 1195 ttm_bo_unreserve(bo);
1175 1196
1197 } else if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
1198 spin_lock(&bo->glob->lru_lock);
1199 ttm_bo_add_to_lru(bo);
1200 spin_unlock(&bo->glob->lru_lock);
1201 }
1202
1176 if (unlikely(ret)) 1203 if (unlikely(ret))
1177 ttm_bo_unref(&bo); 1204 ttm_bo_unref(&bo);
1178 1205
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
index 6377e8151000..67cebb23c940 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
@@ -247,7 +247,7 @@ static void __vmw_cmdbuf_header_free(struct vmw_cmdbuf_header *header)
247{ 247{
248 struct vmw_cmdbuf_man *man = header->man; 248 struct vmw_cmdbuf_man *man = header->man;
249 249
250 BUG_ON(!spin_is_locked(&man->lock)); 250 lockdep_assert_held_once(&man->lock);
251 251
252 if (header->inline_space) { 252 if (header->inline_space) {
253 vmw_cmdbuf_header_inline_free(header); 253 vmw_cmdbuf_header_inline_free(header);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 274c90da44a7..b221a8c40282 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -763,21 +763,25 @@ static int vmw_create_dmabuf_proxy(struct drm_device *dev,
763 uint32_t format; 763 uint32_t format;
764 struct drm_vmw_size content_base_size; 764 struct drm_vmw_size content_base_size;
765 struct vmw_resource *res; 765 struct vmw_resource *res;
766 unsigned int bytes_pp;
766 int ret; 767 int ret;
767 768
768 switch (mode_cmd->depth) { 769 switch (mode_cmd->depth) {
769 case 32: 770 case 32:
770 case 24: 771 case 24:
771 format = SVGA3D_X8R8G8B8; 772 format = SVGA3D_X8R8G8B8;
773 bytes_pp = 4;
772 break; 774 break;
773 775
774 case 16: 776 case 16:
775 case 15: 777 case 15:
776 format = SVGA3D_R5G6B5; 778 format = SVGA3D_R5G6B5;
779 bytes_pp = 2;
777 break; 780 break;
778 781
779 case 8: 782 case 8:
780 format = SVGA3D_P8; 783 format = SVGA3D_P8;
784 bytes_pp = 1;
781 break; 785 break;
782 786
783 default: 787 default:
@@ -785,7 +789,7 @@ static int vmw_create_dmabuf_proxy(struct drm_device *dev,
785 return -EINVAL; 789 return -EINVAL;
786 } 790 }
787 791
788 content_base_size.width = mode_cmd->width; 792 content_base_size.width = mode_cmd->pitch / bytes_pp;
789 content_base_size.height = mode_cmd->height; 793 content_base_size.height = mode_cmd->height;
790 content_base_size.depth = 1; 794 content_base_size.depth = 1;
791 795
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index 74b5888bbc73..4fc55a87dfee 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -451,9 +451,7 @@ struct drm_dp_mst_topology_mgr {
451 the mstb tx_slots and txmsg->state once they are queued */ 451 the mstb tx_slots and txmsg->state once they are queued */
452 struct mutex qlock; 452 struct mutex qlock;
453 struct list_head tx_msg_downq; 453 struct list_head tx_msg_downq;
454 struct list_head tx_msg_upq;
455 bool tx_down_in_progress; 454 bool tx_down_in_progress;
456 bool tx_up_in_progress;
457 455
458 /* payload info + lock for it */ 456 /* payload info + lock for it */
459 struct mutex payload_lock; 457 struct mutex payload_lock;
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index c768ddfbe53c..afae2316bd43 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -383,6 +383,16 @@ extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);
383 */ 383 */
384extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo); 384extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo);
385 385
386/**
387 * ttm_bo_move_to_lru_tail
388 *
389 * @bo: The buffer object.
390 *
391 * Move this BO to the tail of all lru lists used to lookup and reserve an
392 * object. This function must be called with struct ttm_bo_global::lru_lock
393 * held, and is used to make a BO less likely to be considered for eviction.
394 */
395extern void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo);
386 396
387/** 397/**
388 * ttm_bo_lock_delayed_workqueue 398 * ttm_bo_lock_delayed_workqueue