| .. | .. |
|---|
| 22 | 22 | */ |
|---|
| 23 | 23 | |
|---|
| 24 | 24 | #include <linux/firmware.h> |
|---|
| 25 | | -#include <drm/drmP.h> |
|---|
| 25 | +#include <linux/pci.h> |
|---|
| 26 | +#include <linux/seq_file.h> |
|---|
| 27 | + |
|---|
| 28 | +#include "atom.h" |
|---|
| 29 | +#include "ci_dpm.h" |
|---|
| 30 | +#include "cikd.h" |
|---|
| 31 | +#include "r600_dpm.h" |
|---|
| 26 | 32 | #include "radeon.h" |
|---|
| 27 | 33 | #include "radeon_asic.h" |
|---|
| 28 | 34 | #include "radeon_ucode.h" |
|---|
| 29 | | -#include "cikd.h" |
|---|
| 30 | | -#include "r600_dpm.h" |
|---|
| 31 | | -#include "ci_dpm.h" |
|---|
| 32 | | -#include "atom.h" |
|---|
| 33 | | -#include <linux/seq_file.h> |
|---|
| 34 | 35 | |
|---|
| 35 | 36 | #define MC_CG_ARB_FREQ_F0 0x0a |
|---|
| 36 | 37 | #define MC_CG_ARB_FREQ_F1 0x0b |
|---|
| .. | .. |
|---|
| 64 | 65 | { 0x17C, 0x172, 0x180, 0x1BC, 0x1B3, 0x1BD, 0x206, 0x200, 0x203, 0x25D, 0x25A, 0x255, 0x2C3, 0x2C5, 0x2B4 } |
|---|
| 65 | 66 | }; |
|---|
| 66 | 67 | |
|---|
| 67 | | -static const struct ci_pt_defaults defaults_bonaire_pro = |
|---|
| 68 | | -{ |
|---|
| 69 | | - 1, 0xF, 0xFD, 0x19, 5, 45, 0, 0x65062, |
|---|
| 70 | | - { 0x8C, 0x23F, 0x244, 0xA6, 0x83, 0x85, 0x86, 0x86, 0x83, 0xDB, 0xDB, 0xDA, 0x67, 0x60, 0x5F }, |
|---|
| 71 | | - { 0x187, 0x193, 0x193, 0x1C7, 0x1D1, 0x1D1, 0x210, 0x219, 0x219, 0x266, 0x26C, 0x26C, 0x2C9, 0x2CB, 0x2CB } |
|---|
| 72 | | -}; |
|---|
| 73 | | - |
|---|
| 74 | 68 | static const struct ci_pt_defaults defaults_saturn_xt = |
|---|
| 75 | 69 | { |
|---|
| 76 | 70 | 1, 0xF, 0xFD, 0x19, 5, 55, 0, 0x70000, |
|---|
| 77 | 71 | { 0x8C, 0x247, 0x249, 0xA6, 0x80, 0x81, 0x8B, 0x89, 0x86, 0xC9, 0xCA, 0xC9, 0x4D, 0x4D, 0x4D }, |
|---|
| 78 | 72 | { 0x187, 0x187, 0x187, 0x1C7, 0x1C7, 0x1C7, 0x210, 0x210, 0x210, 0x266, 0x266, 0x266, 0x2C9, 0x2C9, 0x2C9 } |
|---|
| 79 | | -}; |
|---|
| 80 | | - |
|---|
| 81 | | -static const struct ci_pt_defaults defaults_saturn_pro = |
|---|
| 82 | | -{ |
|---|
| 83 | | - 1, 0xF, 0xFD, 0x19, 5, 55, 0, 0x30000, |
|---|
| 84 | | - { 0x96, 0x21D, 0x23B, 0xA1, 0x85, 0x87, 0x83, 0x84, 0x81, 0xE6, 0xE6, 0xE6, 0x71, 0x6A, 0x6A }, |
|---|
| 85 | | - { 0x193, 0x19E, 0x19E, 0x1D2, 0x1DC, 0x1DC, 0x21A, 0x223, 0x223, 0x26E, 0x27E, 0x274, 0x2CF, 0x2D2, 0x2D2 } |
|---|
| 86 | 73 | }; |
|---|
| 87 | 74 | |
|---|
| 88 | 75 | static const struct ci_pt_config_reg didt_config_ci[] = |
|---|
| .. | .. |
|---|
| 4869 | 4856 | pi->force_pcie_gen = RADEON_PCIE_GEN2; |
|---|
| 4870 | 4857 | if (current_link_speed == RADEON_PCIE_GEN2) |
|---|
| 4871 | 4858 | break; |
|---|
| 4859 | + fallthrough; |
|---|
| 4872 | 4860 | case RADEON_PCIE_GEN2: |
|---|
| 4873 | 4861 | if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN2, false) == 0) |
|---|
| 4874 | 4862 | break; |
|---|
| 4875 | 4863 | #endif |
|---|
| 4864 | + /* fall through */ |
|---|
| 4876 | 4865 | default: |
|---|
| 4877 | 4866 | pi->force_pcie_gen = ci_get_current_pcie_speed(rdev); |
|---|
| 4878 | 4867 | break; |
|---|
| .. | .. |
|---|
| 5552 | 5541 | u8 frev, crev; |
|---|
| 5553 | 5542 | u8 *power_state_offset; |
|---|
| 5554 | 5543 | struct ci_ps *ps; |
|---|
| 5544 | + int ret; |
|---|
| 5555 | 5545 | |
|---|
| 5556 | 5546 | if (!atom_parse_data_header(mode_info->atom_context, index, NULL, |
|---|
| 5557 | 5547 | &frev, &crev, &data_offset)) |
|---|
| .. | .. |
|---|
| 5581 | 5571 | non_clock_array_index = power_state->v2.nonClockInfoIndex; |
|---|
| 5582 | 5572 | non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) |
|---|
| 5583 | 5573 | &non_clock_info_array->nonClockInfo[non_clock_array_index]; |
|---|
| 5584 | | - if (!rdev->pm.power_state[i].clock_info) |
|---|
| 5585 | | - return -EINVAL; |
|---|
| 5574 | + if (!rdev->pm.power_state[i].clock_info) { |
|---|
| 5575 | + ret = -EINVAL; |
|---|
| 5576 | + goto err_free_ps; |
|---|
| 5577 | + } |
|---|
| 5586 | 5578 | ps = kzalloc(sizeof(struct ci_ps), GFP_KERNEL); |
|---|
| 5587 | | - if (ps == NULL) |
|---|
| 5588 | | - return -ENOMEM; |
|---|
| 5579 | + if (ps == NULL) { |
|---|
| 5580 | + ret = -ENOMEM; |
|---|
| 5581 | + goto err_free_ps; |
|---|
| 5582 | + } |
|---|
| 5589 | 5583 | rdev->pm.dpm.ps[i].ps_priv = ps; |
|---|
| 5590 | 5584 | ci_parse_pplib_non_clock_info(rdev, &rdev->pm.dpm.ps[i], |
|---|
| 5591 | 5585 | non_clock_info, |
|---|
| .. | .. |
|---|
| 5625 | 5619 | } |
|---|
| 5626 | 5620 | |
|---|
| 5627 | 5621 | return 0; |
|---|
| 5622 | + |
|---|
| 5623 | +err_free_ps: |
|---|
| 5624 | + for (i = 0; i < rdev->pm.dpm.num_ps; i++) |
|---|
| 5625 | + kfree(rdev->pm.dpm.ps[i].ps_priv); |
|---|
| 5626 | + kfree(rdev->pm.dpm.ps); |
|---|
| 5627 | + return ret; |
|---|
| 5628 | 5628 | } |
|---|
| 5629 | 5629 | |
|---|
| 5630 | 5630 | static int ci_get_vbios_boot_values(struct radeon_device *rdev, |
|---|
| .. | .. |
|---|
| 5713 | 5713 | |
|---|
| 5714 | 5714 | ret = ci_get_vbios_boot_values(rdev, &pi->vbios_boot_state); |
|---|
| 5715 | 5715 | if (ret) { |
|---|
| 5716 | | - ci_dpm_fini(rdev); |
|---|
| 5716 | + kfree(rdev->pm.dpm.priv); |
|---|
| 5717 | 5717 | return ret; |
|---|
| 5718 | 5718 | } |
|---|
| 5719 | 5719 | |
|---|
| 5720 | 5720 | ret = r600_get_platform_caps(rdev); |
|---|
| 5721 | 5721 | if (ret) { |
|---|
| 5722 | | - ci_dpm_fini(rdev); |
|---|
| 5722 | + kfree(rdev->pm.dpm.priv); |
|---|
| 5723 | 5723 | return ret; |
|---|
| 5724 | 5724 | } |
|---|
| 5725 | 5725 | |
|---|
| 5726 | 5726 | ret = r600_parse_extended_power_table(rdev); |
|---|
| 5727 | 5727 | if (ret) { |
|---|
| 5728 | | - ci_dpm_fini(rdev); |
|---|
| 5728 | + kfree(rdev->pm.dpm.priv); |
|---|
| 5729 | 5729 | return ret; |
|---|
| 5730 | 5730 | } |
|---|
| 5731 | 5731 | |
|---|
| 5732 | 5732 | ret = ci_parse_power_table(rdev); |
|---|
| 5733 | 5733 | if (ret) { |
|---|
| 5734 | | - ci_dpm_fini(rdev); |
|---|
| 5734 | + kfree(rdev->pm.dpm.priv); |
|---|
| 5735 | + r600_free_extended_power_table(rdev); |
|---|
| 5735 | 5736 | return ret; |
|---|
| 5736 | 5737 | } |
|---|
| 5737 | 5738 | |
|---|