diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2016-09-23 16:23:41 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-03-29 23:54:17 -0400 |
commit | a5bde2f964fa0657b8750156d9bc0ca156e18d2b (patch) | |
tree | 912a0f76a27a36d7b3bdd95d5db13a4f20738f5c /drivers/gpu/drm/amd/amdgpu | |
parent | 43bf11bd9231ad06bd1d91c847beda52b88bc6e0 (diff) |
drm/amdgpu: add basic support for atomfirmware.h (v3)
This adds basic support for asics that use atomfirmware.h
to define their vbios tables.
v2: rebase
v3: squash in num scratch reg fix
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ken Wang <Qingqing.Wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/Makefile | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 112 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h | 33 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 35 |
5 files changed, 172 insertions, 13 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 2814aad81752..9a4e9ec10646 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile | |||
@@ -24,7 +24,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ | |||
24 | atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ | 24 | atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ |
25 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ | 25 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ |
26 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ | 26 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ |
27 | amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o | 27 | amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o |
28 | 28 | ||
29 | # add asic specific block | 29 | # add asic specific block |
30 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ | 30 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 2790129c0b76..a7108ba94794 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -111,7 +111,7 @@ extern int amdgpu_vram_page_split; | |||
111 | #define AMDGPU_IB_POOL_SIZE 16 | 111 | #define AMDGPU_IB_POOL_SIZE 16 |
112 | #define AMDGPU_DEBUGFS_MAX_COMPONENTS 32 | 112 | #define AMDGPU_DEBUGFS_MAX_COMPONENTS 32 |
113 | #define AMDGPUFB_CONN_LIMIT 4 | 113 | #define AMDGPUFB_CONN_LIMIT 4 |
114 | #define AMDGPU_BIOS_NUM_SCRATCH 8 | 114 | #define AMDGPU_BIOS_NUM_SCRATCH 16 |
115 | 115 | ||
116 | /* max number of IP instances */ | 116 | /* max number of IP instances */ |
117 | #define AMDGPU_MAX_SDMA_INSTANCES 2 | 117 | #define AMDGPU_MAX_SDMA_INSTANCES 2 |
@@ -1312,6 +1312,7 @@ struct amdgpu_device { | |||
1312 | uint8_t *bios; | 1312 | uint8_t *bios; |
1313 | uint32_t bios_size; | 1313 | uint32_t bios_size; |
1314 | struct amdgpu_bo *stollen_vga_memory; | 1314 | struct amdgpu_bo *stollen_vga_memory; |
1315 | uint32_t bios_scratch_reg_offset; | ||
1315 | uint32_t bios_scratch[AMDGPU_BIOS_NUM_SCRATCH]; | 1316 | uint32_t bios_scratch[AMDGPU_BIOS_NUM_SCRATCH]; |
1316 | 1317 | ||
1317 | /* Register/doorbell mmio */ | 1318 | /* Register/doorbell mmio */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c new file mode 100644 index 000000000000..4b9abd68e04f --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | * Copyright 2016 Advanced Micro Devices, 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 | */ | ||
23 | #include <drm/drmP.h> | ||
24 | #include <drm/amdgpu_drm.h> | ||
25 | #include "amdgpu.h" | ||
26 | #include "atomfirmware.h" | ||
27 | #include "amdgpu_atomfirmware.h" | ||
28 | #include "atom.h" | ||
29 | |||
30 | #define get_index_into_master_table(master_table, table_name) (offsetof(struct master_table, table_name) / sizeof(uint16_t)) | ||
31 | |||
32 | bool amdgpu_atomfirmware_gpu_supports_virtualization(struct amdgpu_device *adev) | ||
33 | { | ||
34 | int index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
35 | firmwareinfo); | ||
36 | uint16_t data_offset; | ||
37 | |||
38 | if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context, index, NULL, | ||
39 | NULL, NULL, &data_offset)) { | ||
40 | struct atom_firmware_info_v3_1 *firmware_info = | ||
41 | (struct atom_firmware_info_v3_1 *)(adev->mode_info.atom_context->bios + | ||
42 | data_offset); | ||
43 | |||
44 | if (le32_to_cpu(firmware_info->firmware_capability) & | ||
45 | ATOM_FIRMWARE_CAP_GPU_VIRTUALIZATION) | ||
46 | return true; | ||
47 | } | ||
48 | return false; | ||
49 | } | ||
50 | |||
51 | void amdgpu_atomfirmware_scratch_regs_init(struct amdgpu_device *adev) | ||
52 | { | ||
53 | int index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
54 | firmwareinfo); | ||
55 | uint16_t data_offset; | ||
56 | |||
57 | if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context, index, NULL, | ||
58 | NULL, NULL, &data_offset)) { | ||
59 | struct atom_firmware_info_v3_1 *firmware_info = | ||
60 | (struct atom_firmware_info_v3_1 *)(adev->mode_info.atom_context->bios + | ||
61 | data_offset); | ||
62 | |||
63 | adev->bios_scratch_reg_offset = | ||
64 | le32_to_cpu(firmware_info->bios_scratch_reg_startaddr); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | void amdgpu_atomfirmware_scratch_regs_save(struct amdgpu_device *adev) | ||
69 | { | ||
70 | int i; | ||
71 | |||
72 | for (i = 0; i < AMDGPU_BIOS_NUM_SCRATCH; i++) | ||
73 | adev->bios_scratch[i] = RREG32(adev->bios_scratch_reg_offset + i); | ||
74 | } | ||
75 | |||
76 | void amdgpu_atomfirmware_scratch_regs_restore(struct amdgpu_device *adev) | ||
77 | { | ||
78 | int i; | ||
79 | |||
80 | for (i = 0; i < AMDGPU_BIOS_NUM_SCRATCH; i++) | ||
81 | WREG32(adev->bios_scratch_reg_offset + i, adev->bios_scratch[i]); | ||
82 | } | ||
83 | |||
84 | int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev) | ||
85 | { | ||
86 | struct atom_context *ctx = adev->mode_info.atom_context; | ||
87 | int index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
88 | vram_usagebyfirmware); | ||
89 | uint16_t data_offset; | ||
90 | int usage_bytes = 0; | ||
91 | |||
92 | if (amdgpu_atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset)) { | ||
93 | struct vram_usagebyfirmware_v2_1 *firmware_usage = | ||
94 | (struct vram_usagebyfirmware_v2_1 *)(ctx->bios + data_offset); | ||
95 | |||
96 | DRM_DEBUG("atom firmware requested %08x %dkb fw %dkb drv\n", | ||
97 | le32_to_cpu(firmware_usage->start_address_in_kb), | ||
98 | le16_to_cpu(firmware_usage->used_by_firmware_in_kb), | ||
99 | le16_to_cpu(firmware_usage->used_by_driver_in_kb)); | ||
100 | |||
101 | usage_bytes = le16_to_cpu(firmware_usage->used_by_driver_in_kb) * 1024; | ||
102 | } | ||
103 | ctx->scratch_size_bytes = 0; | ||
104 | if (usage_bytes == 0) | ||
105 | usage_bytes = 20 * 1024; | ||
106 | /* allocate some scratch memory */ | ||
107 | ctx->scratch = kzalloc(usage_bytes, GFP_KERNEL); | ||
108 | if (!ctx->scratch) | ||
109 | return -ENOMEM; | ||
110 | ctx->scratch_size_bytes = usage_bytes; | ||
111 | return 0; | ||
112 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h new file mode 100644 index 000000000000..d0c4dcd7fa96 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | * Copyright 2014 Advanced Micro Devices, 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 | */ | ||
23 | |||
24 | #ifndef __AMDGPU_ATOMFIRMWARE_H__ | ||
25 | #define __AMDGPU_ATOMFIRMWARE_H__ | ||
26 | |||
27 | bool amdgpu_atomfirmware_gpu_supports_virtualization(struct amdgpu_device *adev); | ||
28 | void amdgpu_atomfirmware_scratch_regs_init(struct amdgpu_device *adev); | ||
29 | void amdgpu_atomfirmware_scratch_regs_save(struct amdgpu_device *adev); | ||
30 | void amdgpu_atomfirmware_scratch_regs_restore(struct amdgpu_device *adev); | ||
31 | int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev); | ||
32 | |||
33 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index dfbfd56bcc25..fbacc13534d2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include "amdgpu_i2c.h" | 40 | #include "amdgpu_i2c.h" |
41 | #include "atom.h" | 41 | #include "atom.h" |
42 | #include "amdgpu_atombios.h" | 42 | #include "amdgpu_atombios.h" |
43 | #include "amdgpu_atomfirmware.h" | ||
43 | #include "amd_pcie.h" | 44 | #include "amd_pcie.h" |
44 | #ifdef CONFIG_DRM_AMDGPU_SI | 45 | #ifdef CONFIG_DRM_AMDGPU_SI |
45 | #include "si.h" | 46 | #include "si.h" |
@@ -993,8 +994,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev) | |||
993 | } | 994 | } |
994 | 995 | ||
995 | mutex_init(&adev->mode_info.atom_context->mutex); | 996 | mutex_init(&adev->mode_info.atom_context->mutex); |
996 | amdgpu_atombios_scratch_regs_init(adev); | 997 | if (adev->is_atom_fw) { |
997 | amdgpu_atombios_allocate_fb_scratch(adev); | 998 | amdgpu_atomfirmware_scratch_regs_init(adev); |
999 | amdgpu_atomfirmware_allocate_fb_scratch(adev); | ||
1000 | } else { | ||
1001 | amdgpu_atombios_scratch_regs_init(adev); | ||
1002 | amdgpu_atombios_allocate_fb_scratch(adev); | ||
1003 | } | ||
998 | return 0; | 1004 | return 0; |
999 | } | 1005 | } |
1000 | 1006 | ||
@@ -1759,8 +1765,13 @@ static int amdgpu_resume(struct amdgpu_device *adev) | |||
1759 | 1765 | ||
1760 | static void amdgpu_device_detect_sriov_bios(struct amdgpu_device *adev) | 1766 | static void amdgpu_device_detect_sriov_bios(struct amdgpu_device *adev) |
1761 | { | 1767 | { |
1762 | if (amdgpu_atombios_has_gpu_virtualization_table(adev)) | 1768 | if (adev->is_atom_fw) { |
1763 | adev->virt.caps |= AMDGPU_SRIOV_CAPS_SRIOV_VBIOS; | 1769 | if (amdgpu_atomfirmware_gpu_supports_virtualization(adev)) |
1770 | adev->virt.caps |= AMDGPU_SRIOV_CAPS_SRIOV_VBIOS; | ||
1771 | } else { | ||
1772 | if (amdgpu_atombios_has_gpu_virtualization_table(adev)) | ||
1773 | adev->virt.caps |= AMDGPU_SRIOV_CAPS_SRIOV_VBIOS; | ||
1774 | } | ||
1764 | } | 1775 | } |
1765 | 1776 | ||
1766 | /** | 1777 | /** |
@@ -1931,14 +1942,16 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1931 | DRM_INFO("GPU post is not needed\n"); | 1942 | DRM_INFO("GPU post is not needed\n"); |
1932 | } | 1943 | } |
1933 | 1944 | ||
1934 | /* Initialize clocks */ | 1945 | if (!adev->is_atom_fw) { |
1935 | r = amdgpu_atombios_get_clock_info(adev); | 1946 | /* Initialize clocks */ |
1936 | if (r) { | 1947 | r = amdgpu_atombios_get_clock_info(adev); |
1937 | dev_err(adev->dev, "amdgpu_atombios_get_clock_info failed\n"); | 1948 | if (r) { |
1938 | goto failed; | 1949 | dev_err(adev->dev, "amdgpu_atombios_get_clock_info failed\n"); |
1950 | return r; | ||
1951 | } | ||
1952 | /* init i2c buses */ | ||
1953 | amdgpu_atombios_i2c_init(adev); | ||
1939 | } | 1954 | } |
1940 | /* init i2c buses */ | ||
1941 | amdgpu_atombios_i2c_init(adev); | ||
1942 | 1955 | ||
1943 | /* Fence driver */ | 1956 | /* Fence driver */ |
1944 | r = amdgpu_fence_driver_init(adev); | 1957 | r = amdgpu_fence_driver_init(adev); |