xref: /dflybsd-src/sys/dev/drm/amd/amdgpu/amdgpu_drv.c (revision b843c749addef9340ee7d4e250b09fdd492602a1)
1*b843c749SSergey Zigachev /*
2*b843c749SSergey Zigachev  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
3*b843c749SSergey Zigachev  * All Rights Reserved.
4*b843c749SSergey Zigachev  *
5*b843c749SSergey Zigachev  * Permission is hereby granted, free of charge, to any person obtaining a
6*b843c749SSergey Zigachev  * copy of this software and associated documentation files (the "Software"),
7*b843c749SSergey Zigachev  * to deal in the Software without restriction, including without limitation
8*b843c749SSergey Zigachev  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9*b843c749SSergey Zigachev  * and/or sell copies of the Software, and to permit persons to whom the
10*b843c749SSergey Zigachev  * Software is furnished to do so, subject to the following conditions:
11*b843c749SSergey Zigachev  *
12*b843c749SSergey Zigachev  * The above copyright notice and this permission notice (including the next
13*b843c749SSergey Zigachev  * paragraph) shall be included in all copies or substantial portions of the
14*b843c749SSergey Zigachev  * Software.
15*b843c749SSergey Zigachev  *
16*b843c749SSergey Zigachev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*b843c749SSergey Zigachev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*b843c749SSergey Zigachev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19*b843c749SSergey Zigachev  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20*b843c749SSergey Zigachev  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21*b843c749SSergey Zigachev  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22*b843c749SSergey Zigachev  * OTHER DEALINGS IN THE SOFTWARE.
23*b843c749SSergey Zigachev  */
24*b843c749SSergey Zigachev 
25*b843c749SSergey Zigachev #include <drm/drmP.h>
26*b843c749SSergey Zigachev #include <drm/amdgpu_drm.h>
27*b843c749SSergey Zigachev #include <drm/drm_gem.h>
28*b843c749SSergey Zigachev #include "amdgpu_drv.h"
29*b843c749SSergey Zigachev 
30*b843c749SSergey Zigachev #include <drm/drm_pciids.h>
31*b843c749SSergey Zigachev #include <linux/console.h>
32*b843c749SSergey Zigachev #include <linux/module.h>
33*b843c749SSergey Zigachev #include <linux/pm_runtime.h>
34*b843c749SSergey Zigachev #include <linux/vga_switcheroo.h>
35*b843c749SSergey Zigachev #include <drm/drm_crtc_helper.h>
36*b843c749SSergey Zigachev 
37*b843c749SSergey Zigachev #include "amdgpu.h"
38*b843c749SSergey Zigachev #include "amdgpu_irq.h"
39*b843c749SSergey Zigachev 
40*b843c749SSergey Zigachev #include "amdgpu_amdkfd.h"
41*b843c749SSergey Zigachev 
42*b843c749SSergey Zigachev /*
43*b843c749SSergey Zigachev  * KMS wrapper.
44*b843c749SSergey Zigachev  * - 3.0.0 - initial driver
45*b843c749SSergey Zigachev  * - 3.1.0 - allow reading more status registers (GRBM, SRBM, SDMA, CP)
46*b843c749SSergey Zigachev  * - 3.2.0 - GFX8: Uses EOP_TC_WB_ACTION_EN, so UMDs don't have to do the same
47*b843c749SSergey Zigachev  *           at the end of IBs.
48*b843c749SSergey Zigachev  * - 3.3.0 - Add VM support for UVD on supported hardware.
49*b843c749SSergey Zigachev  * - 3.4.0 - Add AMDGPU_INFO_NUM_EVICTIONS.
50*b843c749SSergey Zigachev  * - 3.5.0 - Add support for new UVD_NO_OP register.
51*b843c749SSergey Zigachev  * - 3.6.0 - kmd involves use CONTEXT_CONTROL in ring buffer.
52*b843c749SSergey Zigachev  * - 3.7.0 - Add support for VCE clock list packet
53*b843c749SSergey Zigachev  * - 3.8.0 - Add support raster config init in the kernel
54*b843c749SSergey Zigachev  * - 3.9.0 - Add support for memory query info about VRAM and GTT.
55*b843c749SSergey Zigachev  * - 3.10.0 - Add support for new fences ioctl, new gem ioctl flags
56*b843c749SSergey Zigachev  * - 3.11.0 - Add support for sensor query info (clocks, temp, etc).
57*b843c749SSergey Zigachev  * - 3.12.0 - Add query for double offchip LDS buffers
58*b843c749SSergey Zigachev  * - 3.13.0 - Add PRT support
59*b843c749SSergey Zigachev  * - 3.14.0 - Fix race in amdgpu_ctx_get_fence() and note new functionality
60*b843c749SSergey Zigachev  * - 3.15.0 - Export more gpu info for gfx9
61*b843c749SSergey Zigachev  * - 3.16.0 - Add reserved vmid support
62*b843c749SSergey Zigachev  * - 3.17.0 - Add AMDGPU_NUM_VRAM_CPU_PAGE_FAULTS.
63*b843c749SSergey Zigachev  * - 3.18.0 - Export gpu always on cu bitmap
64*b843c749SSergey Zigachev  * - 3.19.0 - Add support for UVD MJPEG decode
65*b843c749SSergey Zigachev  * - 3.20.0 - Add support for local BOs
66*b843c749SSergey Zigachev  * - 3.21.0 - Add DRM_AMDGPU_FENCE_TO_HANDLE ioctl
67*b843c749SSergey Zigachev  * - 3.22.0 - Add DRM_AMDGPU_SCHED ioctl
68*b843c749SSergey Zigachev  * - 3.23.0 - Add query for VRAM lost counter
69*b843c749SSergey Zigachev  * - 3.24.0 - Add high priority compute support for gfx9
70*b843c749SSergey Zigachev  * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk).
71*b843c749SSergey Zigachev  * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE.
72*b843c749SSergey Zigachev  * - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LIST creation.
73*b843c749SSergey Zigachev  */
74*b843c749SSergey Zigachev #define KMS_DRIVER_MAJOR	3
75*b843c749SSergey Zigachev #define KMS_DRIVER_MINOR	27
76*b843c749SSergey Zigachev #define KMS_DRIVER_PATCHLEVEL	0
77*b843c749SSergey Zigachev 
78*b843c749SSergey Zigachev int amdgpu_vram_limit = 0;
79*b843c749SSergey Zigachev int amdgpu_vis_vram_limit = 0;
80*b843c749SSergey Zigachev int amdgpu_gart_size = -1; /* auto */
81*b843c749SSergey Zigachev int amdgpu_gtt_size = -1; /* auto */
82*b843c749SSergey Zigachev int amdgpu_moverate = -1; /* auto */
83*b843c749SSergey Zigachev int amdgpu_benchmarking = 0;
84*b843c749SSergey Zigachev int amdgpu_testing = 0;
85*b843c749SSergey Zigachev int amdgpu_audio = -1;
86*b843c749SSergey Zigachev int amdgpu_disp_priority = 0;
87*b843c749SSergey Zigachev int amdgpu_hw_i2c = 0;
88*b843c749SSergey Zigachev int amdgpu_pcie_gen2 = -1;
89*b843c749SSergey Zigachev int amdgpu_msi = -1;
90*b843c749SSergey Zigachev int amdgpu_lockup_timeout = 10000;
91*b843c749SSergey Zigachev int amdgpu_dpm = -1;
92*b843c749SSergey Zigachev int amdgpu_fw_load_type = -1;
93*b843c749SSergey Zigachev int amdgpu_aspm = -1;
94*b843c749SSergey Zigachev int amdgpu_runtime_pm = -1;
95*b843c749SSergey Zigachev uint amdgpu_ip_block_mask = 0xffffffff;
96*b843c749SSergey Zigachev int amdgpu_bapm = -1;
97*b843c749SSergey Zigachev int amdgpu_deep_color = 0;
98*b843c749SSergey Zigachev int amdgpu_vm_size = -1;
99*b843c749SSergey Zigachev int amdgpu_vm_fragment_size = -1;
100*b843c749SSergey Zigachev int amdgpu_vm_block_size = -1;
101*b843c749SSergey Zigachev int amdgpu_vm_fault_stop = 0;
102*b843c749SSergey Zigachev int amdgpu_vm_debug = 0;
103*b843c749SSergey Zigachev int amdgpu_vram_page_split = 512;
104*b843c749SSergey Zigachev int amdgpu_vm_update_mode = -1;
105*b843c749SSergey Zigachev int amdgpu_exp_hw_support = 0;
106*b843c749SSergey Zigachev int amdgpu_dc = -1;
107*b843c749SSergey Zigachev int amdgpu_sched_jobs = 32;
108*b843c749SSergey Zigachev int amdgpu_sched_hw_submission = 2;
109*b843c749SSergey Zigachev uint amdgpu_pcie_gen_cap = 0;
110*b843c749SSergey Zigachev uint amdgpu_pcie_lane_cap = 0;
111*b843c749SSergey Zigachev uint amdgpu_cg_mask = 0xffffffff;
112*b843c749SSergey Zigachev uint amdgpu_pg_mask = 0xffffffff;
113*b843c749SSergey Zigachev uint amdgpu_sdma_phase_quantum = 32;
114*b843c749SSergey Zigachev char *amdgpu_disable_cu = NULL;
115*b843c749SSergey Zigachev char *amdgpu_virtual_display = NULL;
116*b843c749SSergey Zigachev /* OverDrive(bit 14),gfxoff(bit 15),stutter mode(bit 17) disabled by default*/
117*b843c749SSergey Zigachev uint amdgpu_pp_feature_mask = 0xfffd3fff;
118*b843c749SSergey Zigachev int amdgpu_ngg = 0;
119*b843c749SSergey Zigachev int amdgpu_prim_buf_per_se = 0;
120*b843c749SSergey Zigachev int amdgpu_pos_buf_per_se = 0;
121*b843c749SSergey Zigachev int amdgpu_cntl_sb_buf_per_se = 0;
122*b843c749SSergey Zigachev int amdgpu_param_buf_per_se = 0;
123*b843c749SSergey Zigachev int amdgpu_job_hang_limit = 0;
124*b843c749SSergey Zigachev int amdgpu_lbpw = -1;
125*b843c749SSergey Zigachev int amdgpu_compute_multipipe = -1;
126*b843c749SSergey Zigachev int amdgpu_gpu_recovery = -1; /* auto */
127*b843c749SSergey Zigachev int amdgpu_emu_mode = 0;
128*b843c749SSergey Zigachev uint amdgpu_smu_memory_pool_size = 0;
129*b843c749SSergey Zigachev 
130*b843c749SSergey Zigachev /**
131*b843c749SSergey Zigachev  * DOC: vramlimit (int)
132*b843c749SSergey Zigachev  * Restrict the total amount of VRAM in MiB for testing.  The default is 0 (Use full VRAM).
133*b843c749SSergey Zigachev  */
134*b843c749SSergey Zigachev MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
135*b843c749SSergey Zigachev module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
136*b843c749SSergey Zigachev 
137*b843c749SSergey Zigachev /**
138*b843c749SSergey Zigachev  * DOC: vis_vramlimit (int)
139*b843c749SSergey Zigachev  * Restrict the amount of CPU visible VRAM in MiB for testing.  The default is 0 (Use full CPU visible VRAM).
140*b843c749SSergey Zigachev  */
141*b843c749SSergey Zigachev MODULE_PARM_DESC(vis_vramlimit, "Restrict visible VRAM for testing, in megabytes");
142*b843c749SSergey Zigachev module_param_named(vis_vramlimit, amdgpu_vis_vram_limit, int, 0444);
143*b843c749SSergey Zigachev 
144*b843c749SSergey Zigachev /**
145*b843c749SSergey Zigachev  * DOC: gartsize (uint)
146*b843c749SSergey Zigachev  * Restrict the size of GART in Mib (32, 64, etc.) for testing. The default is -1 (The size depends on asic).
147*b843c749SSergey Zigachev  */
148*b843c749SSergey Zigachev MODULE_PARM_DESC(gartsize, "Size of GART to setup in megabytes (32, 64, etc., -1=auto)");
149*b843c749SSergey Zigachev module_param_named(gartsize, amdgpu_gart_size, uint, 0600);
150*b843c749SSergey Zigachev 
151*b843c749SSergey Zigachev /**
152*b843c749SSergey Zigachev  * DOC: gttsize (int)
153*b843c749SSergey Zigachev  * Restrict the size of GTT domain in MiB for testing. The default is -1 (It's VRAM size if 3GB < VRAM < 3/4 RAM,
154*b843c749SSergey Zigachev  * otherwise 3/4 RAM size).
155*b843c749SSergey Zigachev  */
156*b843c749SSergey Zigachev MODULE_PARM_DESC(gttsize, "Size of the GTT domain in megabytes (-1 = auto)");
157*b843c749SSergey Zigachev module_param_named(gttsize, amdgpu_gtt_size, int, 0600);
158*b843c749SSergey Zigachev 
159*b843c749SSergey Zigachev /**
160*b843c749SSergey Zigachev  * DOC: moverate (int)
161*b843c749SSergey Zigachev  * Set maximum buffer migration rate in MB/s. The default is -1 (8 MB/s).
162*b843c749SSergey Zigachev  */
163*b843c749SSergey Zigachev MODULE_PARM_DESC(moverate, "Maximum buffer migration rate in MB/s. (32, 64, etc., -1=auto, 0=1=disabled)");
164*b843c749SSergey Zigachev module_param_named(moverate, amdgpu_moverate, int, 0600);
165*b843c749SSergey Zigachev 
166*b843c749SSergey Zigachev /**
167*b843c749SSergey Zigachev  * DOC: benchmark (int)
168*b843c749SSergey Zigachev  * Run benchmarks. The default is 0 (Skip benchmarks).
169*b843c749SSergey Zigachev  */
170*b843c749SSergey Zigachev MODULE_PARM_DESC(benchmark, "Run benchmark");
171*b843c749SSergey Zigachev module_param_named(benchmark, amdgpu_benchmarking, int, 0444);
172*b843c749SSergey Zigachev 
173*b843c749SSergey Zigachev /**
174*b843c749SSergey Zigachev  * DOC: test (int)
175*b843c749SSergey Zigachev  * Test BO GTT->VRAM and VRAM->GTT GPU copies. The default is 0 (Skip test, only set 1 to run test).
176*b843c749SSergey Zigachev  */
177*b843c749SSergey Zigachev MODULE_PARM_DESC(test, "Run tests");
178*b843c749SSergey Zigachev module_param_named(test, amdgpu_testing, int, 0444);
179*b843c749SSergey Zigachev 
180*b843c749SSergey Zigachev /**
181*b843c749SSergey Zigachev  * DOC: audio (int)
182*b843c749SSergey Zigachev  * Set HDMI/DPAudio. Only affects non-DC display handling. The default is -1 (Enabled), set 0 to disabled it.
183*b843c749SSergey Zigachev  */
184*b843c749SSergey Zigachev MODULE_PARM_DESC(audio, "Audio enable (-1 = auto, 0 = disable, 1 = enable)");
185*b843c749SSergey Zigachev module_param_named(audio, amdgpu_audio, int, 0444);
186*b843c749SSergey Zigachev 
187*b843c749SSergey Zigachev /**
188*b843c749SSergey Zigachev  * DOC: disp_priority (int)
189*b843c749SSergey Zigachev  * Set display Priority (1 = normal, 2 = high). Only affects non-DC display handling. The default is 0 (auto).
190*b843c749SSergey Zigachev  */
191*b843c749SSergey Zigachev MODULE_PARM_DESC(disp_priority, "Display Priority (0 = auto, 1 = normal, 2 = high)");
192*b843c749SSergey Zigachev module_param_named(disp_priority, amdgpu_disp_priority, int, 0444);
193*b843c749SSergey Zigachev 
194*b843c749SSergey Zigachev /**
195*b843c749SSergey Zigachev  * DOC: hw_i2c (int)
196*b843c749SSergey Zigachev  * To enable hw i2c engine. Only affects non-DC display handling. The default is 0 (Disabled).
197*b843c749SSergey Zigachev  */
198*b843c749SSergey Zigachev MODULE_PARM_DESC(hw_i2c, "hw i2c engine enable (0 = disable)");
199*b843c749SSergey Zigachev module_param_named(hw_i2c, amdgpu_hw_i2c, int, 0444);
200*b843c749SSergey Zigachev 
201*b843c749SSergey Zigachev /**
202*b843c749SSergey Zigachev  * DOC: pcie_gen2 (int)
203*b843c749SSergey Zigachev  * To disable PCIE Gen2/3 mode (0 = disable, 1 = enable). The default is -1 (auto, enabled).
204*b843c749SSergey Zigachev  */
205*b843c749SSergey Zigachev MODULE_PARM_DESC(pcie_gen2, "PCIE Gen2 mode (-1 = auto, 0 = disable, 1 = enable)");
206*b843c749SSergey Zigachev module_param_named(pcie_gen2, amdgpu_pcie_gen2, int, 0444);
207*b843c749SSergey Zigachev 
208*b843c749SSergey Zigachev /**
209*b843c749SSergey Zigachev  * DOC: msi (int)
210*b843c749SSergey Zigachev  * To disable Message Signaled Interrupts (MSI) functionality (1 = enable, 0 = disable). The default is -1 (auto, enabled).
211*b843c749SSergey Zigachev  */
212*b843c749SSergey Zigachev MODULE_PARM_DESC(msi, "MSI support (1 = enable, 0 = disable, -1 = auto)");
213*b843c749SSergey Zigachev module_param_named(msi, amdgpu_msi, int, 0444);
214*b843c749SSergey Zigachev 
215*b843c749SSergey Zigachev /**
216*b843c749SSergey Zigachev  * DOC: lockup_timeout (int)
217*b843c749SSergey Zigachev  * Set GPU scheduler timeout value in ms. Value 0 is invalidated, will be adjusted to 10000.
218*b843c749SSergey Zigachev  * Negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET). The default is 10000.
219*b843c749SSergey Zigachev  */
220*b843c749SSergey Zigachev MODULE_PARM_DESC(lockup_timeout, "GPU lockup timeout in ms > 0 (default 10000)");
221*b843c749SSergey Zigachev module_param_named(lockup_timeout, amdgpu_lockup_timeout, int, 0444);
222*b843c749SSergey Zigachev 
223*b843c749SSergey Zigachev /**
224*b843c749SSergey Zigachev  * DOC: dpm (int)
225*b843c749SSergey Zigachev  * Override for dynamic power management setting (1 = enable, 0 = disable). The default is -1 (auto).
226*b843c749SSergey Zigachev  */
227*b843c749SSergey Zigachev MODULE_PARM_DESC(dpm, "DPM support (1 = enable, 0 = disable, -1 = auto)");
228*b843c749SSergey Zigachev module_param_named(dpm, amdgpu_dpm, int, 0444);
229*b843c749SSergey Zigachev 
230*b843c749SSergey Zigachev /**
231*b843c749SSergey Zigachev  * DOC: fw_load_type (int)
232*b843c749SSergey Zigachev  * Set different firmware loading type for debugging (0 = direct, 1 = SMU, 2 = PSP). The default is -1 (auto).
233*b843c749SSergey Zigachev  */
234*b843c749SSergey Zigachev MODULE_PARM_DESC(fw_load_type, "firmware loading type (0 = direct, 1 = SMU, 2 = PSP, -1 = auto)");
235*b843c749SSergey Zigachev module_param_named(fw_load_type, amdgpu_fw_load_type, int, 0444);
236*b843c749SSergey Zigachev 
237*b843c749SSergey Zigachev /**
238*b843c749SSergey Zigachev  * DOC: aspm (int)
239*b843c749SSergey Zigachev  * To disable ASPM (1 = enable, 0 = disable). The default is -1 (auto, enabled).
240*b843c749SSergey Zigachev  */
241*b843c749SSergey Zigachev MODULE_PARM_DESC(aspm, "ASPM support (1 = enable, 0 = disable, -1 = auto)");
242*b843c749SSergey Zigachev module_param_named(aspm, amdgpu_aspm, int, 0444);
243*b843c749SSergey Zigachev 
244*b843c749SSergey Zigachev /**
245*b843c749SSergey Zigachev  * DOC: runpm (int)
246*b843c749SSergey Zigachev  * Override for runtime power management control for dGPUs in PX/HG laptops. The amdgpu driver can dynamically power down
247*b843c749SSergey Zigachev  * the dGPU on PX/HG laptops when it is idle. The default is -1 (auto enable). Setting the value to 0 disables this functionality.
248*b843c749SSergey Zigachev  */
249*b843c749SSergey Zigachev MODULE_PARM_DESC(runpm, "PX runtime pm (1 = force enable, 0 = disable, -1 = PX only default)");
250*b843c749SSergey Zigachev module_param_named(runpm, amdgpu_runtime_pm, int, 0444);
251*b843c749SSergey Zigachev 
252*b843c749SSergey Zigachev /**
253*b843c749SSergey Zigachev  * DOC: ip_block_mask (uint)
254*b843c749SSergey Zigachev  * Override what IP blocks are enabled on the GPU. Each GPU is a collection of IP blocks (gfx, display, video, etc.).
255*b843c749SSergey Zigachev  * Use this parameter to disable specific blocks. Note that the IP blocks do not have a fixed index. Some asics may not have
256*b843c749SSergey Zigachev  * some IPs or may include multiple instances of an IP so the ordering various from asic to asic. See the driver output in
257*b843c749SSergey Zigachev  * the kernel log for the list of IPs on the asic. The default is 0xffffffff (enable all blocks on a device).
258*b843c749SSergey Zigachev  */
259*b843c749SSergey Zigachev MODULE_PARM_DESC(ip_block_mask, "IP Block Mask (all blocks enabled (default))");
260*b843c749SSergey Zigachev module_param_named(ip_block_mask, amdgpu_ip_block_mask, uint, 0444);
261*b843c749SSergey Zigachev 
262*b843c749SSergey Zigachev /**
263*b843c749SSergey Zigachev  * DOC: bapm (int)
264*b843c749SSergey Zigachev  * Bidirectional Application Power Management (BAPM) used to dynamically share TDP between CPU and GPU. Set value 0 to disable it.
265*b843c749SSergey Zigachev  * The default -1 (auto, enabled)
266*b843c749SSergey Zigachev  */
267*b843c749SSergey Zigachev MODULE_PARM_DESC(bapm, "BAPM support (1 = enable, 0 = disable, -1 = auto)");
268*b843c749SSergey Zigachev module_param_named(bapm, amdgpu_bapm, int, 0444);
269*b843c749SSergey Zigachev 
270*b843c749SSergey Zigachev /**
271*b843c749SSergey Zigachev  * DOC: deep_color (int)
272*b843c749SSergey Zigachev  * Set 1 to enable Deep Color support. Only affects non-DC display handling. The default is 0 (disabled).
273*b843c749SSergey Zigachev  */
274*b843c749SSergey Zigachev MODULE_PARM_DESC(deep_color, "Deep Color support (1 = enable, 0 = disable (default))");
275*b843c749SSergey Zigachev module_param_named(deep_color, amdgpu_deep_color, int, 0444);
276*b843c749SSergey Zigachev 
277*b843c749SSergey Zigachev /**
278*b843c749SSergey Zigachev  * DOC: vm_size (int)
279*b843c749SSergey Zigachev  * Override the size of the GPU's per client virtual address space in GiB.  The default is -1 (automatic for each asic).
280*b843c749SSergey Zigachev  */
281*b843c749SSergey Zigachev MODULE_PARM_DESC(vm_size, "VM address space size in gigabytes (default 64GB)");
282*b843c749SSergey Zigachev module_param_named(vm_size, amdgpu_vm_size, int, 0444);
283*b843c749SSergey Zigachev 
284*b843c749SSergey Zigachev /**
285*b843c749SSergey Zigachev  * DOC: vm_fragment_size (int)
286*b843c749SSergey Zigachev  * Override VM fragment size in bits (4, 5, etc. 4 = 64K, 9 = 2M). The default is -1 (automatic for each asic).
287*b843c749SSergey Zigachev  */
288*b843c749SSergey Zigachev MODULE_PARM_DESC(vm_fragment_size, "VM fragment size in bits (4, 5, etc. 4 = 64K (default), Max 9 = 2M)");
289*b843c749SSergey Zigachev module_param_named(vm_fragment_size, amdgpu_vm_fragment_size, int, 0444);
290*b843c749SSergey Zigachev 
291*b843c749SSergey Zigachev /**
292*b843c749SSergey Zigachev  * DOC: vm_block_size (int)
293*b843c749SSergey Zigachev  * Override VM page table size in bits (default depending on vm_size and hw setup). The default is -1 (automatic for each asic).
294*b843c749SSergey Zigachev  */
295*b843c749SSergey Zigachev MODULE_PARM_DESC(vm_block_size, "VM page table size in bits (default depending on vm_size)");
296*b843c749SSergey Zigachev module_param_named(vm_block_size, amdgpu_vm_block_size, int, 0444);
297*b843c749SSergey Zigachev 
298*b843c749SSergey Zigachev /**
299*b843c749SSergey Zigachev  * DOC: vm_fault_stop (int)
300*b843c749SSergey Zigachev  * Stop on VM fault for debugging (0 = never, 1 = print first, 2 = always). The default is 0 (No stop).
301*b843c749SSergey Zigachev  */
302*b843c749SSergey Zigachev MODULE_PARM_DESC(vm_fault_stop, "Stop on VM fault (0 = never (default), 1 = print first, 2 = always)");
303*b843c749SSergey Zigachev module_param_named(vm_fault_stop, amdgpu_vm_fault_stop, int, 0444);
304*b843c749SSergey Zigachev 
305*b843c749SSergey Zigachev /**
306*b843c749SSergey Zigachev  * DOC: vm_debug (int)
307*b843c749SSergey Zigachev  * Debug VM handling (0 = disabled, 1 = enabled). The default is 0 (Disabled).
308*b843c749SSergey Zigachev  */
309*b843c749SSergey Zigachev MODULE_PARM_DESC(vm_debug, "Debug VM handling (0 = disabled (default), 1 = enabled)");
310*b843c749SSergey Zigachev module_param_named(vm_debug, amdgpu_vm_debug, int, 0644);
311*b843c749SSergey Zigachev 
312*b843c749SSergey Zigachev /**
313*b843c749SSergey Zigachev  * DOC: vm_update_mode (int)
314*b843c749SSergey Zigachev  * Override VM update mode. VM updated by using CPU (0 = never, 1 = Graphics only, 2 = Compute only, 3 = Both). The default
315*b843c749SSergey Zigachev  * is -1 (Only in large BAR(LB) systems Compute VM tables will be updated by CPU, otherwise 0, never).
316*b843c749SSergey Zigachev  */
317*b843c749SSergey Zigachev MODULE_PARM_DESC(vm_update_mode, "VM update using CPU (0 = never (default except for large BAR(LB)), 1 = Graphics only, 2 = Compute only (default for LB), 3 = Both");
318*b843c749SSergey Zigachev module_param_named(vm_update_mode, amdgpu_vm_update_mode, int, 0444);
319*b843c749SSergey Zigachev 
320*b843c749SSergey Zigachev /**
321*b843c749SSergey Zigachev  * DOC: vram_page_split (int)
322*b843c749SSergey Zigachev  * Override the number of pages after we split VRAM allocations (default 512, -1 = disable). The default is 512.
323*b843c749SSergey Zigachev  */
324*b843c749SSergey Zigachev MODULE_PARM_DESC(vram_page_split, "Number of pages after we split VRAM allocations (default 512, -1 = disable)");
325*b843c749SSergey Zigachev module_param_named(vram_page_split, amdgpu_vram_page_split, int, 0444);
326*b843c749SSergey Zigachev 
327*b843c749SSergey Zigachev /**
328*b843c749SSergey Zigachev  * DOC: exp_hw_support (int)
329*b843c749SSergey Zigachev  * Enable experimental hw support (1 = enable). The default is 0 (disabled).
330*b843c749SSergey Zigachev  */
331*b843c749SSergey Zigachev MODULE_PARM_DESC(exp_hw_support, "experimental hw support (1 = enable, 0 = disable (default))");
332*b843c749SSergey Zigachev module_param_named(exp_hw_support, amdgpu_exp_hw_support, int, 0444);
333*b843c749SSergey Zigachev 
334*b843c749SSergey Zigachev /**
335*b843c749SSergey Zigachev  * DOC: dc (int)
336*b843c749SSergey Zigachev  * Disable/Enable Display Core driver for debugging (1 = enable, 0 = disable). The default is -1 (automatic for each asic).
337*b843c749SSergey Zigachev  */
338*b843c749SSergey Zigachev MODULE_PARM_DESC(dc, "Display Core driver (1 = enable, 0 = disable, -1 = auto (default))");
339*b843c749SSergey Zigachev module_param_named(dc, amdgpu_dc, int, 0444);
340*b843c749SSergey Zigachev 
341*b843c749SSergey Zigachev /**
342*b843c749SSergey Zigachev  * DOC: sched_jobs (int)
343*b843c749SSergey Zigachev  * Override the max number of jobs supported in the sw queue. The default is 32.
344*b843c749SSergey Zigachev  */
345*b843c749SSergey Zigachev MODULE_PARM_DESC(sched_jobs, "the max number of jobs supported in the sw queue (default 32)");
346*b843c749SSergey Zigachev module_param_named(sched_jobs, amdgpu_sched_jobs, int, 0444);
347*b843c749SSergey Zigachev 
348*b843c749SSergey Zigachev /**
349*b843c749SSergey Zigachev  * DOC: sched_hw_submission (int)
350*b843c749SSergey Zigachev  * Override the max number of HW submissions. The default is 2.
351*b843c749SSergey Zigachev  */
352*b843c749SSergey Zigachev MODULE_PARM_DESC(sched_hw_submission, "the max number of HW submissions (default 2)");
353*b843c749SSergey Zigachev module_param_named(sched_hw_submission, amdgpu_sched_hw_submission, int, 0444);
354*b843c749SSergey Zigachev 
355*b843c749SSergey Zigachev /**
356*b843c749SSergey Zigachev  * DOC: ppfeaturemask (uint)
357*b843c749SSergey Zigachev  * Override power features enabled. See enum PP_FEATURE_MASK in drivers/gpu/drm/amd/include/amd_shared.h.
358*b843c749SSergey Zigachev  * The default is the current set of stable power features.
359*b843c749SSergey Zigachev  */
360*b843c749SSergey Zigachev MODULE_PARM_DESC(ppfeaturemask, "all power features enabled (default))");
361*b843c749SSergey Zigachev module_param_named(ppfeaturemask, amdgpu_pp_feature_mask, uint, 0444);
362*b843c749SSergey Zigachev 
363*b843c749SSergey Zigachev /**
364*b843c749SSergey Zigachev  * DOC: pcie_gen_cap (uint)
365*b843c749SSergey Zigachev  * Override PCIE gen speed capabilities. See the CAIL flags in drivers/gpu/drm/amd/include/amd_pcie.h.
366*b843c749SSergey Zigachev  * The default is 0 (automatic for each asic).
367*b843c749SSergey Zigachev  */
368*b843c749SSergey Zigachev MODULE_PARM_DESC(pcie_gen_cap, "PCIE Gen Caps (0: autodetect (default))");
369*b843c749SSergey Zigachev module_param_named(pcie_gen_cap, amdgpu_pcie_gen_cap, uint, 0444);
370*b843c749SSergey Zigachev 
371*b843c749SSergey Zigachev /**
372*b843c749SSergey Zigachev  * DOC: pcie_lane_cap (uint)
373*b843c749SSergey Zigachev  * Override PCIE lanes capabilities. See the CAIL flags in drivers/gpu/drm/amd/include/amd_pcie.h.
374*b843c749SSergey Zigachev  * The default is 0 (automatic for each asic).
375*b843c749SSergey Zigachev  */
376*b843c749SSergey Zigachev MODULE_PARM_DESC(pcie_lane_cap, "PCIE Lane Caps (0: autodetect (default))");
377*b843c749SSergey Zigachev module_param_named(pcie_lane_cap, amdgpu_pcie_lane_cap, uint, 0444);
378*b843c749SSergey Zigachev 
379*b843c749SSergey Zigachev /**
380*b843c749SSergey Zigachev  * DOC: cg_mask (uint)
381*b843c749SSergey Zigachev  * Override Clockgating features enabled on GPU (0 = disable clock gating). See the AMD_CG_SUPPORT flags in
382*b843c749SSergey Zigachev  * drivers/gpu/drm/amd/include/amd_shared.h. The default is 0xffffffff (all enabled).
383*b843c749SSergey Zigachev  */
384*b843c749SSergey Zigachev MODULE_PARM_DESC(cg_mask, "Clockgating flags mask (0 = disable clock gating)");
385*b843c749SSergey Zigachev module_param_named(cg_mask, amdgpu_cg_mask, uint, 0444);
386*b843c749SSergey Zigachev 
387*b843c749SSergey Zigachev /**
388*b843c749SSergey Zigachev  * DOC: pg_mask (uint)
389*b843c749SSergey Zigachev  * Override Powergating features enabled on GPU (0 = disable power gating). See the AMD_PG_SUPPORT flags in
390*b843c749SSergey Zigachev  * drivers/gpu/drm/amd/include/amd_shared.h. The default is 0xffffffff (all enabled).
391*b843c749SSergey Zigachev  */
392*b843c749SSergey Zigachev MODULE_PARM_DESC(pg_mask, "Powergating flags mask (0 = disable power gating)");
393*b843c749SSergey Zigachev module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444);
394*b843c749SSergey Zigachev 
395*b843c749SSergey Zigachev /**
396*b843c749SSergey Zigachev  * DOC: sdma_phase_quantum (uint)
397*b843c749SSergey Zigachev  * Override SDMA context switch phase quantum (x 1K GPU clock cycles, 0 = no change). The default is 32.
398*b843c749SSergey Zigachev  */
399*b843c749SSergey Zigachev MODULE_PARM_DESC(sdma_phase_quantum, "SDMA context switch phase quantum (x 1K GPU clock cycles, 0 = no change (default 32))");
400*b843c749SSergey Zigachev module_param_named(sdma_phase_quantum, amdgpu_sdma_phase_quantum, uint, 0444);
401*b843c749SSergey Zigachev 
402*b843c749SSergey Zigachev /**
403*b843c749SSergey Zigachev  * DOC: disable_cu (charp)
404*b843c749SSergey Zigachev  * Set to disable CUs (It's set like se.sh.cu,...). The default is NULL.
405*b843c749SSergey Zigachev  */
406*b843c749SSergey Zigachev MODULE_PARM_DESC(disable_cu, "Disable CUs (se.sh.cu,...)");
407*b843c749SSergey Zigachev module_param_named(disable_cu, amdgpu_disable_cu, charp, 0444);
408*b843c749SSergey Zigachev 
409*b843c749SSergey Zigachev /**
410*b843c749SSergey Zigachev  * DOC: virtual_display (charp)
411*b843c749SSergey Zigachev  * Set to enable virtual display feature. This feature provides a virtual display hardware on headless boards
412*b843c749SSergey Zigachev  * or in virtualized environments. It will be set like xxxx:xx:xx.x,x;xxxx:xx:xx.x,x. It's the pci address of
413*b843c749SSergey Zigachev  * the device, plus the number of crtcs to expose. E.g., 0000:26:00.0,4 would enable 4 virtual crtcs on the pci
414*b843c749SSergey Zigachev  * device at 26:00.0. The default is NULL.
415*b843c749SSergey Zigachev  */
416*b843c749SSergey Zigachev MODULE_PARM_DESC(virtual_display,
417*b843c749SSergey Zigachev 		 "Enable virtual display feature (the virtual_display will be set like xxxx:xx:xx.x,x;xxxx:xx:xx.x,x)");
418*b843c749SSergey Zigachev module_param_named(virtual_display, amdgpu_virtual_display, charp, 0444);
419*b843c749SSergey Zigachev 
420*b843c749SSergey Zigachev /**
421*b843c749SSergey Zigachev  * DOC: ngg (int)
422*b843c749SSergey Zigachev  * Set to enable Next Generation Graphics (1 = enable). The default is 0 (disabled).
423*b843c749SSergey Zigachev  */
424*b843c749SSergey Zigachev MODULE_PARM_DESC(ngg, "Next Generation Graphics (1 = enable, 0 = disable(default depending on gfx))");
425*b843c749SSergey Zigachev module_param_named(ngg, amdgpu_ngg, int, 0444);
426*b843c749SSergey Zigachev 
427*b843c749SSergey Zigachev /**
428*b843c749SSergey Zigachev  * DOC: prim_buf_per_se (int)
429*b843c749SSergey Zigachev  * Override the size of Primitive Buffer per Shader Engine in Byte. The default is 0 (depending on gfx).
430*b843c749SSergey Zigachev  */
431*b843c749SSergey Zigachev MODULE_PARM_DESC(prim_buf_per_se, "the size of Primitive Buffer per Shader Engine (default depending on gfx)");
432*b843c749SSergey Zigachev module_param_named(prim_buf_per_se, amdgpu_prim_buf_per_se, int, 0444);
433*b843c749SSergey Zigachev 
434*b843c749SSergey Zigachev /**
435*b843c749SSergey Zigachev  * DOC: pos_buf_per_se (int)
436*b843c749SSergey Zigachev  * Override the size of Position Buffer per Shader Engine in Byte. The default is 0 (depending on gfx).
437*b843c749SSergey Zigachev  */
438*b843c749SSergey Zigachev MODULE_PARM_DESC(pos_buf_per_se, "the size of Position Buffer per Shader Engine (default depending on gfx)");
439*b843c749SSergey Zigachev module_param_named(pos_buf_per_se, amdgpu_pos_buf_per_se, int, 0444);
440*b843c749SSergey Zigachev 
441*b843c749SSergey Zigachev /**
442*b843c749SSergey Zigachev  * DOC: cntl_sb_buf_per_se (int)
443*b843c749SSergey Zigachev  * Override the size of Control Sideband per Shader Engine in Byte. The default is 0 (depending on gfx).
444*b843c749SSergey Zigachev  */
445*b843c749SSergey Zigachev MODULE_PARM_DESC(cntl_sb_buf_per_se, "the size of Control Sideband per Shader Engine (default depending on gfx)");
446*b843c749SSergey Zigachev module_param_named(cntl_sb_buf_per_se, amdgpu_cntl_sb_buf_per_se, int, 0444);
447*b843c749SSergey Zigachev 
448*b843c749SSergey Zigachev /**
449*b843c749SSergey Zigachev  * DOC: param_buf_per_se (int)
450*b843c749SSergey Zigachev  * Override the size of Off-Chip Pramater Cache per Shader Engine in Byte. The default is 0 (depending on gfx).
451*b843c749SSergey Zigachev  */
452*b843c749SSergey Zigachev MODULE_PARM_DESC(param_buf_per_se, "the size of Off-Chip Pramater Cache per Shader Engine (default depending on gfx)");
453*b843c749SSergey Zigachev module_param_named(param_buf_per_se, amdgpu_param_buf_per_se, int, 0444);
454*b843c749SSergey Zigachev 
455*b843c749SSergey Zigachev /**
456*b843c749SSergey Zigachev  * DOC: job_hang_limit (int)
457*b843c749SSergey Zigachev  * Set how much time allow a job hang and not drop it. The default is 0.
458*b843c749SSergey Zigachev  */
459*b843c749SSergey Zigachev MODULE_PARM_DESC(job_hang_limit, "how much time allow a job hang and not drop it (default 0)");
460*b843c749SSergey Zigachev module_param_named(job_hang_limit, amdgpu_job_hang_limit, int ,0444);
461*b843c749SSergey Zigachev 
462*b843c749SSergey Zigachev /**
463*b843c749SSergey Zigachev  * DOC: lbpw (int)
464*b843c749SSergey Zigachev  * Override Load Balancing Per Watt (LBPW) support (1 = enable, 0 = disable). The default is -1 (auto, enabled).
465*b843c749SSergey Zigachev  */
466*b843c749SSergey Zigachev MODULE_PARM_DESC(lbpw, "Load Balancing Per Watt (LBPW) support (1 = enable, 0 = disable, -1 = auto)");
467*b843c749SSergey Zigachev module_param_named(lbpw, amdgpu_lbpw, int, 0444);
468*b843c749SSergey Zigachev 
469*b843c749SSergey Zigachev MODULE_PARM_DESC(compute_multipipe, "Force compute queues to be spread across pipes (1 = enable, 0 = disable, -1 = auto)");
470*b843c749SSergey Zigachev module_param_named(compute_multipipe, amdgpu_compute_multipipe, int, 0444);
471*b843c749SSergey Zigachev 
472*b843c749SSergey Zigachev /**
473*b843c749SSergey Zigachev  * DOC: gpu_recovery (int)
474*b843c749SSergey Zigachev  * Set to enable GPU recovery mechanism (1 = enable, 0 = disable). The default is -1 (auto, disabled except SRIOV).
475*b843c749SSergey Zigachev  */
476*b843c749SSergey Zigachev MODULE_PARM_DESC(gpu_recovery, "Enable GPU recovery mechanism, (1 = enable, 0 = disable, -1 = auto)");
477*b843c749SSergey Zigachev module_param_named(gpu_recovery, amdgpu_gpu_recovery, int, 0444);
478*b843c749SSergey Zigachev 
479*b843c749SSergey Zigachev /**
480*b843c749SSergey Zigachev  * DOC: emu_mode (int)
481*b843c749SSergey Zigachev  * Set value 1 to enable emulation mode. This is only needed when running on an emulator. The default is 0 (disabled).
482*b843c749SSergey Zigachev  */
483*b843c749SSergey Zigachev MODULE_PARM_DESC(emu_mode, "Emulation mode, (1 = enable, 0 = disable)");
484*b843c749SSergey Zigachev module_param_named(emu_mode, amdgpu_emu_mode, int, 0444);
485*b843c749SSergey Zigachev 
486*b843c749SSergey Zigachev /**
487*b843c749SSergey Zigachev  * DOC: si_support (int)
488*b843c749SSergey Zigachev  * Set SI support driver. This parameter works after set config CONFIG_DRM_AMDGPU_SI. For SI asic, when radeon driver is enabled,
489*b843c749SSergey Zigachev  * set value 0 to use radeon driver, while set value 1 to use amdgpu driver. The default is using radeon driver when it available,
490*b843c749SSergey Zigachev  * otherwise using amdgpu driver.
491*b843c749SSergey Zigachev  */
492*b843c749SSergey Zigachev #ifdef CONFIG_DRM_AMDGPU_SI
493*b843c749SSergey Zigachev 
494*b843c749SSergey Zigachev #if defined(CONFIG_DRM_RADEON) || defined(CONFIG_DRM_RADEON_MODULE)
495*b843c749SSergey Zigachev int amdgpu_si_support = 0;
496*b843c749SSergey Zigachev MODULE_PARM_DESC(si_support, "SI support (1 = enabled, 0 = disabled (default))");
497*b843c749SSergey Zigachev #else
498*b843c749SSergey Zigachev int amdgpu_si_support = 1;
499*b843c749SSergey Zigachev MODULE_PARM_DESC(si_support, "SI support (1 = enabled (default), 0 = disabled)");
500*b843c749SSergey Zigachev #endif
501*b843c749SSergey Zigachev 
502*b843c749SSergey Zigachev module_param_named(si_support, amdgpu_si_support, int, 0444);
503*b843c749SSergey Zigachev #endif
504*b843c749SSergey Zigachev 
505*b843c749SSergey Zigachev /**
506*b843c749SSergey Zigachev  * DOC: cik_support (int)
507*b843c749SSergey Zigachev  * Set CIK support driver. This parameter works after set config CONFIG_DRM_AMDGPU_CIK. For CIK asic, when radeon driver is enabled,
508*b843c749SSergey Zigachev  * set value 0 to use radeon driver, while set value 1 to use amdgpu driver. The default is using radeon driver when it available,
509*b843c749SSergey Zigachev  * otherwise using amdgpu driver.
510*b843c749SSergey Zigachev  */
511*b843c749SSergey Zigachev #ifdef CONFIG_DRM_AMDGPU_CIK
512*b843c749SSergey Zigachev 
513*b843c749SSergey Zigachev #if defined(CONFIG_DRM_RADEON) || defined(CONFIG_DRM_RADEON_MODULE)
514*b843c749SSergey Zigachev int amdgpu_cik_support = 0;
515*b843c749SSergey Zigachev MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled, 0 = disabled (default))");
516*b843c749SSergey Zigachev #else
517*b843c749SSergey Zigachev int amdgpu_cik_support = 1;
518*b843c749SSergey Zigachev MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled (default), 0 = disabled)");
519*b843c749SSergey Zigachev #endif
520*b843c749SSergey Zigachev 
521*b843c749SSergey Zigachev module_param_named(cik_support, amdgpu_cik_support, int, 0444);
522*b843c749SSergey Zigachev #endif
523*b843c749SSergey Zigachev 
524*b843c749SSergey Zigachev /**
525*b843c749SSergey Zigachev  * DOC: smu_memory_pool_size (uint)
526*b843c749SSergey Zigachev  * It is used to reserve gtt for smu debug usage, setting value 0 to disable it. The actual size is value * 256MiB.
527*b843c749SSergey Zigachev  * E.g. 0x1 = 256Mbyte, 0x2 = 512Mbyte, 0x4 = 1 Gbyte, 0x8 = 2GByte. The default is 0 (disabled).
528*b843c749SSergey Zigachev  */
529*b843c749SSergey Zigachev MODULE_PARM_DESC(smu_memory_pool_size,
530*b843c749SSergey Zigachev 	"reserve gtt for smu debug usage, 0 = disable,"
531*b843c749SSergey Zigachev 		"0x1 = 256Mbyte, 0x2 = 512Mbyte, 0x4 = 1 Gbyte, 0x8 = 2GByte");
532*b843c749SSergey Zigachev module_param_named(smu_memory_pool_size, amdgpu_smu_memory_pool_size, uint, 0444);
533*b843c749SSergey Zigachev 
534*b843c749SSergey Zigachev static const struct pci_device_id pciidlist[] = {
535*b843c749SSergey Zigachev #ifdef  CONFIG_DRM_AMDGPU_SI
536*b843c749SSergey Zigachev 	{0x1002, 0x6780, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
537*b843c749SSergey Zigachev 	{0x1002, 0x6784, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
538*b843c749SSergey Zigachev 	{0x1002, 0x6788, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
539*b843c749SSergey Zigachev 	{0x1002, 0x678A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
540*b843c749SSergey Zigachev 	{0x1002, 0x6790, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
541*b843c749SSergey Zigachev 	{0x1002, 0x6791, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
542*b843c749SSergey Zigachev 	{0x1002, 0x6792, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
543*b843c749SSergey Zigachev 	{0x1002, 0x6798, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
544*b843c749SSergey Zigachev 	{0x1002, 0x6799, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
545*b843c749SSergey Zigachev 	{0x1002, 0x679A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
546*b843c749SSergey Zigachev 	{0x1002, 0x679B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
547*b843c749SSergey Zigachev 	{0x1002, 0x679E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
548*b843c749SSergey Zigachev 	{0x1002, 0x679F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
549*b843c749SSergey Zigachev 	{0x1002, 0x6800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|AMD_IS_MOBILITY},
550*b843c749SSergey Zigachev 	{0x1002, 0x6801, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|AMD_IS_MOBILITY},
551*b843c749SSergey Zigachev 	{0x1002, 0x6802, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|AMD_IS_MOBILITY},
552*b843c749SSergey Zigachev 	{0x1002, 0x6806, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
553*b843c749SSergey Zigachev 	{0x1002, 0x6808, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
554*b843c749SSergey Zigachev 	{0x1002, 0x6809, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
555*b843c749SSergey Zigachev 	{0x1002, 0x6810, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
556*b843c749SSergey Zigachev 	{0x1002, 0x6811, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
557*b843c749SSergey Zigachev 	{0x1002, 0x6816, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
558*b843c749SSergey Zigachev 	{0x1002, 0x6817, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
559*b843c749SSergey Zigachev 	{0x1002, 0x6818, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
560*b843c749SSergey Zigachev 	{0x1002, 0x6819, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
561*b843c749SSergey Zigachev 	{0x1002, 0x6600, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
562*b843c749SSergey Zigachev 	{0x1002, 0x6601, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
563*b843c749SSergey Zigachev 	{0x1002, 0x6602, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
564*b843c749SSergey Zigachev 	{0x1002, 0x6603, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
565*b843c749SSergey Zigachev 	{0x1002, 0x6604, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
566*b843c749SSergey Zigachev 	{0x1002, 0x6605, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
567*b843c749SSergey Zigachev 	{0x1002, 0x6606, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
568*b843c749SSergey Zigachev 	{0x1002, 0x6607, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
569*b843c749SSergey Zigachev 	{0x1002, 0x6608, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND},
570*b843c749SSergey Zigachev 	{0x1002, 0x6610, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND},
571*b843c749SSergey Zigachev 	{0x1002, 0x6611, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND},
572*b843c749SSergey Zigachev 	{0x1002, 0x6613, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND},
573*b843c749SSergey Zigachev 	{0x1002, 0x6617, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
574*b843c749SSergey Zigachev 	{0x1002, 0x6620, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
575*b843c749SSergey Zigachev 	{0x1002, 0x6621, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
576*b843c749SSergey Zigachev 	{0x1002, 0x6623, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
577*b843c749SSergey Zigachev 	{0x1002, 0x6631, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND},
578*b843c749SSergey Zigachev 	{0x1002, 0x6820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
579*b843c749SSergey Zigachev 	{0x1002, 0x6821, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
580*b843c749SSergey Zigachev 	{0x1002, 0x6822, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
581*b843c749SSergey Zigachev 	{0x1002, 0x6823, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
582*b843c749SSergey Zigachev 	{0x1002, 0x6824, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
583*b843c749SSergey Zigachev 	{0x1002, 0x6825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
584*b843c749SSergey Zigachev 	{0x1002, 0x6826, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
585*b843c749SSergey Zigachev 	{0x1002, 0x6827, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
586*b843c749SSergey Zigachev 	{0x1002, 0x6828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
587*b843c749SSergey Zigachev 	{0x1002, 0x6829, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
588*b843c749SSergey Zigachev 	{0x1002, 0x682A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
589*b843c749SSergey Zigachev 	{0x1002, 0x682B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
590*b843c749SSergey Zigachev 	{0x1002, 0x682C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
591*b843c749SSergey Zigachev 	{0x1002, 0x682D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
592*b843c749SSergey Zigachev 	{0x1002, 0x682F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
593*b843c749SSergey Zigachev 	{0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
594*b843c749SSergey Zigachev 	{0x1002, 0x6831, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
595*b843c749SSergey Zigachev 	{0x1002, 0x6835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
596*b843c749SSergey Zigachev 	{0x1002, 0x6837, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
597*b843c749SSergey Zigachev 	{0x1002, 0x6838, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
598*b843c749SSergey Zigachev 	{0x1002, 0x6839, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
599*b843c749SSergey Zigachev 	{0x1002, 0x683B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
600*b843c749SSergey Zigachev 	{0x1002, 0x683D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
601*b843c749SSergey Zigachev 	{0x1002, 0x683F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
602*b843c749SSergey Zigachev 	{0x1002, 0x6660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
603*b843c749SSergey Zigachev 	{0x1002, 0x6663, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
604*b843c749SSergey Zigachev 	{0x1002, 0x6664, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
605*b843c749SSergey Zigachev 	{0x1002, 0x6665, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
606*b843c749SSergey Zigachev 	{0x1002, 0x6667, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
607*b843c749SSergey Zigachev 	{0x1002, 0x666F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
608*b843c749SSergey Zigachev #endif
609*b843c749SSergey Zigachev #ifdef CONFIG_DRM_AMDGPU_CIK
610*b843c749SSergey Zigachev 	/* Kaveri */
611*b843c749SSergey Zigachev 	{0x1002, 0x1304, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
612*b843c749SSergey Zigachev 	{0x1002, 0x1305, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
613*b843c749SSergey Zigachev 	{0x1002, 0x1306, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
614*b843c749SSergey Zigachev 	{0x1002, 0x1307, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
615*b843c749SSergey Zigachev 	{0x1002, 0x1309, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
616*b843c749SSergey Zigachev 	{0x1002, 0x130A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
617*b843c749SSergey Zigachev 	{0x1002, 0x130B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
618*b843c749SSergey Zigachev 	{0x1002, 0x130C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
619*b843c749SSergey Zigachev 	{0x1002, 0x130D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
620*b843c749SSergey Zigachev 	{0x1002, 0x130E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
621*b843c749SSergey Zigachev 	{0x1002, 0x130F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
622*b843c749SSergey Zigachev 	{0x1002, 0x1310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
623*b843c749SSergey Zigachev 	{0x1002, 0x1311, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
624*b843c749SSergey Zigachev 	{0x1002, 0x1312, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
625*b843c749SSergey Zigachev 	{0x1002, 0x1313, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
626*b843c749SSergey Zigachev 	{0x1002, 0x1315, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
627*b843c749SSergey Zigachev 	{0x1002, 0x1316, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
628*b843c749SSergey Zigachev 	{0x1002, 0x1317, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
629*b843c749SSergey Zigachev 	{0x1002, 0x1318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
630*b843c749SSergey Zigachev 	{0x1002, 0x131B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
631*b843c749SSergey Zigachev 	{0x1002, 0x131C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
632*b843c749SSergey Zigachev 	{0x1002, 0x131D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
633*b843c749SSergey Zigachev 	/* Bonaire */
634*b843c749SSergey Zigachev 	{0x1002, 0x6640, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|AMD_IS_MOBILITY},
635*b843c749SSergey Zigachev 	{0x1002, 0x6641, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|AMD_IS_MOBILITY},
636*b843c749SSergey Zigachev 	{0x1002, 0x6646, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|AMD_IS_MOBILITY},
637*b843c749SSergey Zigachev 	{0x1002, 0x6647, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|AMD_IS_MOBILITY},
638*b843c749SSergey Zigachev 	{0x1002, 0x6649, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
639*b843c749SSergey Zigachev 	{0x1002, 0x6650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
640*b843c749SSergey Zigachev 	{0x1002, 0x6651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
641*b843c749SSergey Zigachev 	{0x1002, 0x6658, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
642*b843c749SSergey Zigachev 	{0x1002, 0x665c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
643*b843c749SSergey Zigachev 	{0x1002, 0x665d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
644*b843c749SSergey Zigachev 	{0x1002, 0x665f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
645*b843c749SSergey Zigachev 	/* Hawaii */
646*b843c749SSergey Zigachev 	{0x1002, 0x67A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
647*b843c749SSergey Zigachev 	{0x1002, 0x67A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
648*b843c749SSergey Zigachev 	{0x1002, 0x67A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
649*b843c749SSergey Zigachev 	{0x1002, 0x67A8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
650*b843c749SSergey Zigachev 	{0x1002, 0x67A9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
651*b843c749SSergey Zigachev 	{0x1002, 0x67AA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
652*b843c749SSergey Zigachev 	{0x1002, 0x67B0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
653*b843c749SSergey Zigachev 	{0x1002, 0x67B1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
654*b843c749SSergey Zigachev 	{0x1002, 0x67B8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
655*b843c749SSergey Zigachev 	{0x1002, 0x67B9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
656*b843c749SSergey Zigachev 	{0x1002, 0x67BA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
657*b843c749SSergey Zigachev 	{0x1002, 0x67BE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
658*b843c749SSergey Zigachev 	/* Kabini */
659*b843c749SSergey Zigachev 	{0x1002, 0x9830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
660*b843c749SSergey Zigachev 	{0x1002, 0x9831, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
661*b843c749SSergey Zigachev 	{0x1002, 0x9832, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
662*b843c749SSergey Zigachev 	{0x1002, 0x9833, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
663*b843c749SSergey Zigachev 	{0x1002, 0x9834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
664*b843c749SSergey Zigachev 	{0x1002, 0x9835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
665*b843c749SSergey Zigachev 	{0x1002, 0x9836, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
666*b843c749SSergey Zigachev 	{0x1002, 0x9837, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
667*b843c749SSergey Zigachev 	{0x1002, 0x9838, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
668*b843c749SSergey Zigachev 	{0x1002, 0x9839, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
669*b843c749SSergey Zigachev 	{0x1002, 0x983a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
670*b843c749SSergey Zigachev 	{0x1002, 0x983b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
671*b843c749SSergey Zigachev 	{0x1002, 0x983c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
672*b843c749SSergey Zigachev 	{0x1002, 0x983d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
673*b843c749SSergey Zigachev 	{0x1002, 0x983e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
674*b843c749SSergey Zigachev 	{0x1002, 0x983f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
675*b843c749SSergey Zigachev 	/* mullins */
676*b843c749SSergey Zigachev 	{0x1002, 0x9850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
677*b843c749SSergey Zigachev 	{0x1002, 0x9851, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
678*b843c749SSergey Zigachev 	{0x1002, 0x9852, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
679*b843c749SSergey Zigachev 	{0x1002, 0x9853, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
680*b843c749SSergey Zigachev 	{0x1002, 0x9854, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
681*b843c749SSergey Zigachev 	{0x1002, 0x9855, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
682*b843c749SSergey Zigachev 	{0x1002, 0x9856, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
683*b843c749SSergey Zigachev 	{0x1002, 0x9857, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
684*b843c749SSergey Zigachev 	{0x1002, 0x9858, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
685*b843c749SSergey Zigachev 	{0x1002, 0x9859, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
686*b843c749SSergey Zigachev 	{0x1002, 0x985A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
687*b843c749SSergey Zigachev 	{0x1002, 0x985B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
688*b843c749SSergey Zigachev 	{0x1002, 0x985C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
689*b843c749SSergey Zigachev 	{0x1002, 0x985D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
690*b843c749SSergey Zigachev 	{0x1002, 0x985E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
691*b843c749SSergey Zigachev 	{0x1002, 0x985F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
692*b843c749SSergey Zigachev #endif
693*b843c749SSergey Zigachev 	/* topaz */
694*b843c749SSergey Zigachev 	{0x1002, 0x6900, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
695*b843c749SSergey Zigachev 	{0x1002, 0x6901, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
696*b843c749SSergey Zigachev 	{0x1002, 0x6902, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
697*b843c749SSergey Zigachev 	{0x1002, 0x6903, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
698*b843c749SSergey Zigachev 	{0x1002, 0x6907, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
699*b843c749SSergey Zigachev 	/* tonga */
700*b843c749SSergey Zigachev 	{0x1002, 0x6920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
701*b843c749SSergey Zigachev 	{0x1002, 0x6921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
702*b843c749SSergey Zigachev 	{0x1002, 0x6928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
703*b843c749SSergey Zigachev 	{0x1002, 0x6929, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
704*b843c749SSergey Zigachev 	{0x1002, 0x692B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
705*b843c749SSergey Zigachev 	{0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
706*b843c749SSergey Zigachev 	{0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
707*b843c749SSergey Zigachev 	{0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
708*b843c749SSergey Zigachev 	{0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
709*b843c749SSergey Zigachev 	/* fiji */
710*b843c749SSergey Zigachev 	{0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI},
711*b843c749SSergey Zigachev 	{0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI},
712*b843c749SSergey Zigachev 	/* carrizo */
713*b843c749SSergey Zigachev 	{0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
714*b843c749SSergey Zigachev 	{0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
715*b843c749SSergey Zigachev 	{0x1002, 0x9875, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
716*b843c749SSergey Zigachev 	{0x1002, 0x9876, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
717*b843c749SSergey Zigachev 	{0x1002, 0x9877, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
718*b843c749SSergey Zigachev 	/* stoney */
719*b843c749SSergey Zigachev 	{0x1002, 0x98E4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_STONEY|AMD_IS_APU},
720*b843c749SSergey Zigachev 	/* Polaris11 */
721*b843c749SSergey Zigachev 	{0x1002, 0x67E0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
722*b843c749SSergey Zigachev 	{0x1002, 0x67E3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
723*b843c749SSergey Zigachev 	{0x1002, 0x67E8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
724*b843c749SSergey Zigachev 	{0x1002, 0x67EB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
725*b843c749SSergey Zigachev 	{0x1002, 0x67EF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
726*b843c749SSergey Zigachev 	{0x1002, 0x67FF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
727*b843c749SSergey Zigachev 	{0x1002, 0x67E1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
728*b843c749SSergey Zigachev 	{0x1002, 0x67E7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
729*b843c749SSergey Zigachev 	{0x1002, 0x67E9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
730*b843c749SSergey Zigachev 	/* Polaris10 */
731*b843c749SSergey Zigachev 	{0x1002, 0x67C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
732*b843c749SSergey Zigachev 	{0x1002, 0x67C1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
733*b843c749SSergey Zigachev 	{0x1002, 0x67C2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
734*b843c749SSergey Zigachev 	{0x1002, 0x67C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
735*b843c749SSergey Zigachev 	{0x1002, 0x67C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
736*b843c749SSergey Zigachev 	{0x1002, 0x67D0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
737*b843c749SSergey Zigachev 	{0x1002, 0x67DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
738*b843c749SSergey Zigachev 	{0x1002, 0x67C8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
739*b843c749SSergey Zigachev 	{0x1002, 0x67C9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
740*b843c749SSergey Zigachev 	{0x1002, 0x67CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
741*b843c749SSergey Zigachev 	{0x1002, 0x67CC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
742*b843c749SSergey Zigachev 	{0x1002, 0x67CF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
743*b843c749SSergey Zigachev 	{0x1002, 0x6FDF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
744*b843c749SSergey Zigachev 	/* Polaris12 */
745*b843c749SSergey Zigachev 	{0x1002, 0x6980, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
746*b843c749SSergey Zigachev 	{0x1002, 0x6981, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
747*b843c749SSergey Zigachev 	{0x1002, 0x6985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
748*b843c749SSergey Zigachev 	{0x1002, 0x6986, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
749*b843c749SSergey Zigachev 	{0x1002, 0x6987, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
750*b843c749SSergey Zigachev 	{0x1002, 0x6995, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
751*b843c749SSergey Zigachev 	{0x1002, 0x6997, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
752*b843c749SSergey Zigachev 	{0x1002, 0x699F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
753*b843c749SSergey Zigachev 	/* VEGAM */
754*b843c749SSergey Zigachev 	{0x1002, 0x694C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGAM},
755*b843c749SSergey Zigachev 	{0x1002, 0x694E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGAM},
756*b843c749SSergey Zigachev 	{0x1002, 0x694F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGAM},
757*b843c749SSergey Zigachev 	/* Vega 10 */
758*b843c749SSergey Zigachev 	{0x1002, 0x6860, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
759*b843c749SSergey Zigachev 	{0x1002, 0x6861, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
760*b843c749SSergey Zigachev 	{0x1002, 0x6862, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
761*b843c749SSergey Zigachev 	{0x1002, 0x6863, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
762*b843c749SSergey Zigachev 	{0x1002, 0x6864, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
763*b843c749SSergey Zigachev 	{0x1002, 0x6867, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
764*b843c749SSergey Zigachev 	{0x1002, 0x6868, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
765*b843c749SSergey Zigachev 	{0x1002, 0x6869, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
766*b843c749SSergey Zigachev 	{0x1002, 0x686a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
767*b843c749SSergey Zigachev 	{0x1002, 0x686b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
768*b843c749SSergey Zigachev 	{0x1002, 0x686c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
769*b843c749SSergey Zigachev 	{0x1002, 0x686d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
770*b843c749SSergey Zigachev 	{0x1002, 0x686e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
771*b843c749SSergey Zigachev 	{0x1002, 0x686f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
772*b843c749SSergey Zigachev 	{0x1002, 0x687f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
773*b843c749SSergey Zigachev 	/* Vega 12 */
774*b843c749SSergey Zigachev 	{0x1002, 0x69A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12},
775*b843c749SSergey Zigachev 	{0x1002, 0x69A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12},
776*b843c749SSergey Zigachev 	{0x1002, 0x69A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12},
777*b843c749SSergey Zigachev 	{0x1002, 0x69A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12},
778*b843c749SSergey Zigachev 	{0x1002, 0x69AF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12},
779*b843c749SSergey Zigachev 	/* Vega 20 */
780*b843c749SSergey Zigachev 	{0x1002, 0x66A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT},
781*b843c749SSergey Zigachev 	{0x1002, 0x66A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT},
782*b843c749SSergey Zigachev 	{0x1002, 0x66A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT},
783*b843c749SSergey Zigachev 	{0x1002, 0x66A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT},
784*b843c749SSergey Zigachev 	{0x1002, 0x66A7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT},
785*b843c749SSergey Zigachev 	{0x1002, 0x66AF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20|AMD_EXP_HW_SUPPORT},
786*b843c749SSergey Zigachev 	/* Raven */
787*b843c749SSergey Zigachev 	{0x1002, 0x15dd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RAVEN|AMD_IS_APU},
788*b843c749SSergey Zigachev 
789*b843c749SSergey Zigachev 	{0, 0, 0}
790*b843c749SSergey Zigachev };
791*b843c749SSergey Zigachev 
792*b843c749SSergey Zigachev MODULE_DEVICE_TABLE(pci, pciidlist);
793*b843c749SSergey Zigachev 
794*b843c749SSergey Zigachev static struct drm_driver kms_driver;
795*b843c749SSergey Zigachev 
796*b843c749SSergey Zigachev static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev)
797*b843c749SSergey Zigachev {
798*b843c749SSergey Zigachev 	struct apertures_struct *ap;
799*b843c749SSergey Zigachev 	bool primary = false;
800*b843c749SSergey Zigachev 
801*b843c749SSergey Zigachev 	ap = alloc_apertures(1);
802*b843c749SSergey Zigachev 	if (!ap)
803*b843c749SSergey Zigachev 		return -ENOMEM;
804*b843c749SSergey Zigachev 
805*b843c749SSergey Zigachev 	ap->ranges[0].base = pci_resource_start(pdev, 0);
806*b843c749SSergey Zigachev 	ap->ranges[0].size = pci_resource_len(pdev, 0);
807*b843c749SSergey Zigachev 
808*b843c749SSergey Zigachev #ifdef CONFIG_X86
809*b843c749SSergey Zigachev 	primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
810*b843c749SSergey Zigachev #endif
811*b843c749SSergey Zigachev 	drm_fb_helper_remove_conflicting_framebuffers(ap, "amdgpudrmfb", primary);
812*b843c749SSergey Zigachev 	kfree(ap);
813*b843c749SSergey Zigachev 
814*b843c749SSergey Zigachev 	return 0;
815*b843c749SSergey Zigachev }
816*b843c749SSergey Zigachev 
817*b843c749SSergey Zigachev 
818*b843c749SSergey Zigachev static int amdgpu_pci_probe(struct pci_dev *pdev,
819*b843c749SSergey Zigachev 			    const struct pci_device_id *ent)
820*b843c749SSergey Zigachev {
821*b843c749SSergey Zigachev 	struct drm_device *dev;
822*b843c749SSergey Zigachev 	unsigned long flags = ent->driver_data;
823*b843c749SSergey Zigachev 	int ret, retry = 0;
824*b843c749SSergey Zigachev 	bool supports_atomic = false;
825*b843c749SSergey Zigachev 
826*b843c749SSergey Zigachev 	if (!amdgpu_virtual_display &&
827*b843c749SSergey Zigachev 	    amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK))
828*b843c749SSergey Zigachev 		supports_atomic = true;
829*b843c749SSergey Zigachev 
830*b843c749SSergey Zigachev 	if ((flags & AMD_EXP_HW_SUPPORT) && !amdgpu_exp_hw_support) {
831*b843c749SSergey Zigachev 		DRM_INFO("This hardware requires experimental hardware support.\n"
832*b843c749SSergey Zigachev 			 "See modparam exp_hw_support\n");
833*b843c749SSergey Zigachev 		return -ENODEV;
834*b843c749SSergey Zigachev 	}
835*b843c749SSergey Zigachev 
836*b843c749SSergey Zigachev 	/*
837*b843c749SSergey Zigachev 	 * Initialize amdkfd before starting radeon. If it was not loaded yet,
838*b843c749SSergey Zigachev 	 * defer radeon probing
839*b843c749SSergey Zigachev 	 */
840*b843c749SSergey Zigachev 	ret = amdgpu_amdkfd_init();
841*b843c749SSergey Zigachev 	if (ret == -EPROBE_DEFER)
842*b843c749SSergey Zigachev 		return ret;
843*b843c749SSergey Zigachev 
844*b843c749SSergey Zigachev #ifdef CONFIG_DRM_AMDGPU_SI
845*b843c749SSergey Zigachev 	if (!amdgpu_si_support) {
846*b843c749SSergey Zigachev 		switch (flags & AMD_ASIC_MASK) {
847*b843c749SSergey Zigachev 		case CHIP_TAHITI:
848*b843c749SSergey Zigachev 		case CHIP_PITCAIRN:
849*b843c749SSergey Zigachev 		case CHIP_VERDE:
850*b843c749SSergey Zigachev 		case CHIP_OLAND:
851*b843c749SSergey Zigachev 		case CHIP_HAINAN:
852*b843c749SSergey Zigachev 			dev_info(&pdev->dev,
853*b843c749SSergey Zigachev 				 "SI support provided by radeon.\n");
854*b843c749SSergey Zigachev 			dev_info(&pdev->dev,
855*b843c749SSergey Zigachev 				 "Use radeon.si_support=0 amdgpu.si_support=1 to override.\n"
856*b843c749SSergey Zigachev 				);
857*b843c749SSergey Zigachev 			return -ENODEV;
858*b843c749SSergey Zigachev 		}
859*b843c749SSergey Zigachev 	}
860*b843c749SSergey Zigachev #endif
861*b843c749SSergey Zigachev #ifdef CONFIG_DRM_AMDGPU_CIK
862*b843c749SSergey Zigachev 	if (!amdgpu_cik_support) {
863*b843c749SSergey Zigachev 		switch (flags & AMD_ASIC_MASK) {
864*b843c749SSergey Zigachev 		case CHIP_KAVERI:
865*b843c749SSergey Zigachev 		case CHIP_BONAIRE:
866*b843c749SSergey Zigachev 		case CHIP_HAWAII:
867*b843c749SSergey Zigachev 		case CHIP_KABINI:
868*b843c749SSergey Zigachev 		case CHIP_MULLINS:
869*b843c749SSergey Zigachev 			dev_info(&pdev->dev,
870*b843c749SSergey Zigachev 				 "CIK support provided by radeon.\n");
871*b843c749SSergey Zigachev 			dev_info(&pdev->dev,
872*b843c749SSergey Zigachev 				 "Use radeon.cik_support=0 amdgpu.cik_support=1 to override.\n"
873*b843c749SSergey Zigachev 				);
874*b843c749SSergey Zigachev 			return -ENODEV;
875*b843c749SSergey Zigachev 		}
876*b843c749SSergey Zigachev 	}
877*b843c749SSergey Zigachev #endif
878*b843c749SSergey Zigachev 
879*b843c749SSergey Zigachev 	/* Get rid of things like offb */
880*b843c749SSergey Zigachev 	ret = amdgpu_kick_out_firmware_fb(pdev);
881*b843c749SSergey Zigachev 	if (ret)
882*b843c749SSergey Zigachev 		return ret;
883*b843c749SSergey Zigachev 
884*b843c749SSergey Zigachev 	/* warn the user if they mix atomic and non-atomic capable GPUs */
885*b843c749SSergey Zigachev 	if ((kms_driver.driver_features & DRIVER_ATOMIC) && !supports_atomic)
886*b843c749SSergey Zigachev 		DRM_ERROR("Mixing atomic and non-atomic capable GPUs!\n");
887*b843c749SSergey Zigachev 	/* support atomic early so the atomic debugfs stuff gets created */
888*b843c749SSergey Zigachev 	if (supports_atomic)
889*b843c749SSergey Zigachev 		kms_driver.driver_features |= DRIVER_ATOMIC;
890*b843c749SSergey Zigachev 
891*b843c749SSergey Zigachev 	dev = drm_dev_alloc(&kms_driver, &pdev->dev);
892*b843c749SSergey Zigachev 	if (IS_ERR(dev))
893*b843c749SSergey Zigachev 		return PTR_ERR(dev);
894*b843c749SSergey Zigachev 
895*b843c749SSergey Zigachev 	ret = pci_enable_device(pdev);
896*b843c749SSergey Zigachev 	if (ret)
897*b843c749SSergey Zigachev 		goto err_free;
898*b843c749SSergey Zigachev 
899*b843c749SSergey Zigachev 	dev->pdev = pdev;
900*b843c749SSergey Zigachev 
901*b843c749SSergey Zigachev 	pci_set_drvdata(pdev, dev);
902*b843c749SSergey Zigachev 
903*b843c749SSergey Zigachev retry_init:
904*b843c749SSergey Zigachev 	ret = drm_dev_register(dev, ent->driver_data);
905*b843c749SSergey Zigachev 	if (ret == -EAGAIN && ++retry <= 3) {
906*b843c749SSergey Zigachev 		DRM_INFO("retry init %d\n", retry);
907*b843c749SSergey Zigachev 		/* Don't request EX mode too frequently which is attacking */
908*b843c749SSergey Zigachev 		msleep(5000);
909*b843c749SSergey Zigachev 		goto retry_init;
910*b843c749SSergey Zigachev 	} else if (ret)
911*b843c749SSergey Zigachev 		goto err_pci;
912*b843c749SSergey Zigachev 
913*b843c749SSergey Zigachev 	return 0;
914*b843c749SSergey Zigachev 
915*b843c749SSergey Zigachev err_pci:
916*b843c749SSergey Zigachev 	pci_disable_device(pdev);
917*b843c749SSergey Zigachev err_free:
918*b843c749SSergey Zigachev 	drm_dev_put(dev);
919*b843c749SSergey Zigachev 	return ret;
920*b843c749SSergey Zigachev }
921*b843c749SSergey Zigachev 
922*b843c749SSergey Zigachev static void
923*b843c749SSergey Zigachev amdgpu_pci_remove(struct pci_dev *pdev)
924*b843c749SSergey Zigachev {
925*b843c749SSergey Zigachev 	struct drm_device *dev = pci_get_drvdata(pdev);
926*b843c749SSergey Zigachev 
927*b843c749SSergey Zigachev 	drm_dev_unregister(dev);
928*b843c749SSergey Zigachev 	drm_dev_put(dev);
929*b843c749SSergey Zigachev 	pci_disable_device(pdev);
930*b843c749SSergey Zigachev 	pci_set_drvdata(pdev, NULL);
931*b843c749SSergey Zigachev }
932*b843c749SSergey Zigachev 
933*b843c749SSergey Zigachev static void
934*b843c749SSergey Zigachev amdgpu_pci_shutdown(struct pci_dev *pdev)
935*b843c749SSergey Zigachev {
936*b843c749SSergey Zigachev 	struct drm_device *dev = pci_get_drvdata(pdev);
937*b843c749SSergey Zigachev 	struct amdgpu_device *adev = dev->dev_private;
938*b843c749SSergey Zigachev 
939*b843c749SSergey Zigachev 	/* if we are running in a VM, make sure the device
940*b843c749SSergey Zigachev 	 * torn down properly on reboot/shutdown.
941*b843c749SSergey Zigachev 	 * unfortunately we can't detect certain
942*b843c749SSergey Zigachev 	 * hypervisors so just do this all the time.
943*b843c749SSergey Zigachev 	 */
944*b843c749SSergey Zigachev 	amdgpu_device_ip_suspend(adev);
945*b843c749SSergey Zigachev }
946*b843c749SSergey Zigachev 
947*b843c749SSergey Zigachev static int amdgpu_pmops_suspend(struct device *dev)
948*b843c749SSergey Zigachev {
949*b843c749SSergey Zigachev 	struct pci_dev *pdev = to_pci_dev(dev);
950*b843c749SSergey Zigachev 
951*b843c749SSergey Zigachev 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
952*b843c749SSergey Zigachev 	return amdgpu_device_suspend(drm_dev, true, true);
953*b843c749SSergey Zigachev }
954*b843c749SSergey Zigachev 
955*b843c749SSergey Zigachev static int amdgpu_pmops_resume(struct device *dev)
956*b843c749SSergey Zigachev {
957*b843c749SSergey Zigachev 	struct pci_dev *pdev = to_pci_dev(dev);
958*b843c749SSergey Zigachev 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
959*b843c749SSergey Zigachev 
960*b843c749SSergey Zigachev 	/* GPU comes up enabled by the bios on resume */
961*b843c749SSergey Zigachev 	if (amdgpu_device_is_px(drm_dev)) {
962*b843c749SSergey Zigachev 		pm_runtime_disable(dev);
963*b843c749SSergey Zigachev 		pm_runtime_set_active(dev);
964*b843c749SSergey Zigachev 		pm_runtime_enable(dev);
965*b843c749SSergey Zigachev 	}
966*b843c749SSergey Zigachev 
967*b843c749SSergey Zigachev 	return amdgpu_device_resume(drm_dev, true, true);
968*b843c749SSergey Zigachev }
969*b843c749SSergey Zigachev 
970*b843c749SSergey Zigachev static int amdgpu_pmops_freeze(struct device *dev)
971*b843c749SSergey Zigachev {
972*b843c749SSergey Zigachev 	struct pci_dev *pdev = to_pci_dev(dev);
973*b843c749SSergey Zigachev 
974*b843c749SSergey Zigachev 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
975*b843c749SSergey Zigachev 	return amdgpu_device_suspend(drm_dev, false, true);
976*b843c749SSergey Zigachev }
977*b843c749SSergey Zigachev 
978*b843c749SSergey Zigachev static int amdgpu_pmops_thaw(struct device *dev)
979*b843c749SSergey Zigachev {
980*b843c749SSergey Zigachev 	struct pci_dev *pdev = to_pci_dev(dev);
981*b843c749SSergey Zigachev 
982*b843c749SSergey Zigachev 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
983*b843c749SSergey Zigachev 	return amdgpu_device_resume(drm_dev, false, true);
984*b843c749SSergey Zigachev }
985*b843c749SSergey Zigachev 
986*b843c749SSergey Zigachev static int amdgpu_pmops_poweroff(struct device *dev)
987*b843c749SSergey Zigachev {
988*b843c749SSergey Zigachev 	struct pci_dev *pdev = to_pci_dev(dev);
989*b843c749SSergey Zigachev 
990*b843c749SSergey Zigachev 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
991*b843c749SSergey Zigachev 	return amdgpu_device_suspend(drm_dev, true, true);
992*b843c749SSergey Zigachev }
993*b843c749SSergey Zigachev 
994*b843c749SSergey Zigachev static int amdgpu_pmops_restore(struct device *dev)
995*b843c749SSergey Zigachev {
996*b843c749SSergey Zigachev 	struct pci_dev *pdev = to_pci_dev(dev);
997*b843c749SSergey Zigachev 
998*b843c749SSergey Zigachev 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
999*b843c749SSergey Zigachev 	return amdgpu_device_resume(drm_dev, false, true);
1000*b843c749SSergey Zigachev }
1001*b843c749SSergey Zigachev 
1002*b843c749SSergey Zigachev static int amdgpu_pmops_runtime_suspend(struct device *dev)
1003*b843c749SSergey Zigachev {
1004*b843c749SSergey Zigachev 	struct pci_dev *pdev = to_pci_dev(dev);
1005*b843c749SSergey Zigachev 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
1006*b843c749SSergey Zigachev 	int ret;
1007*b843c749SSergey Zigachev 
1008*b843c749SSergey Zigachev 	if (!amdgpu_device_is_px(drm_dev)) {
1009*b843c749SSergey Zigachev 		pm_runtime_forbid(dev);
1010*b843c749SSergey Zigachev 		return -EBUSY;
1011*b843c749SSergey Zigachev 	}
1012*b843c749SSergey Zigachev 
1013*b843c749SSergey Zigachev 	drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
1014*b843c749SSergey Zigachev 	drm_kms_helper_poll_disable(drm_dev);
1015*b843c749SSergey Zigachev 
1016*b843c749SSergey Zigachev 	ret = amdgpu_device_suspend(drm_dev, false, false);
1017*b843c749SSergey Zigachev 	pci_save_state(pdev);
1018*b843c749SSergey Zigachev 	pci_disable_device(pdev);
1019*b843c749SSergey Zigachev 	pci_ignore_hotplug(pdev);
1020*b843c749SSergey Zigachev 	if (amdgpu_is_atpx_hybrid())
1021*b843c749SSergey Zigachev 		pci_set_power_state(pdev, PCI_D3cold);
1022*b843c749SSergey Zigachev 	else if (!amdgpu_has_atpx_dgpu_power_cntl())
1023*b843c749SSergey Zigachev 		pci_set_power_state(pdev, PCI_D3hot);
1024*b843c749SSergey Zigachev 	drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
1025*b843c749SSergey Zigachev 
1026*b843c749SSergey Zigachev 	return 0;
1027*b843c749SSergey Zigachev }
1028*b843c749SSergey Zigachev 
1029*b843c749SSergey Zigachev static int amdgpu_pmops_runtime_resume(struct device *dev)
1030*b843c749SSergey Zigachev {
1031*b843c749SSergey Zigachev 	struct pci_dev *pdev = to_pci_dev(dev);
1032*b843c749SSergey Zigachev 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
1033*b843c749SSergey Zigachev 	int ret;
1034*b843c749SSergey Zigachev 
1035*b843c749SSergey Zigachev 	if (!amdgpu_device_is_px(drm_dev))
1036*b843c749SSergey Zigachev 		return -EINVAL;
1037*b843c749SSergey Zigachev 
1038*b843c749SSergey Zigachev 	drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
1039*b843c749SSergey Zigachev 
1040*b843c749SSergey Zigachev 	if (amdgpu_is_atpx_hybrid() ||
1041*b843c749SSergey Zigachev 	    !amdgpu_has_atpx_dgpu_power_cntl())
1042*b843c749SSergey Zigachev 		pci_set_power_state(pdev, PCI_D0);
1043*b843c749SSergey Zigachev 	pci_restore_state(pdev);
1044*b843c749SSergey Zigachev 	ret = pci_enable_device(pdev);
1045*b843c749SSergey Zigachev 	if (ret)
1046*b843c749SSergey Zigachev 		return ret;
1047*b843c749SSergey Zigachev 	pci_set_master(pdev);
1048*b843c749SSergey Zigachev 
1049*b843c749SSergey Zigachev 	ret = amdgpu_device_resume(drm_dev, false, false);
1050*b843c749SSergey Zigachev 	drm_kms_helper_poll_enable(drm_dev);
1051*b843c749SSergey Zigachev 	drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
1052*b843c749SSergey Zigachev 	return 0;
1053*b843c749SSergey Zigachev }
1054*b843c749SSergey Zigachev 
1055*b843c749SSergey Zigachev static int amdgpu_pmops_runtime_idle(struct device *dev)
1056*b843c749SSergey Zigachev {
1057*b843c749SSergey Zigachev 	struct pci_dev *pdev = to_pci_dev(dev);
1058*b843c749SSergey Zigachev 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
1059*b843c749SSergey Zigachev 	struct drm_crtc *crtc;
1060*b843c749SSergey Zigachev 
1061*b843c749SSergey Zigachev 	if (!amdgpu_device_is_px(drm_dev)) {
1062*b843c749SSergey Zigachev 		pm_runtime_forbid(dev);
1063*b843c749SSergey Zigachev 		return -EBUSY;
1064*b843c749SSergey Zigachev 	}
1065*b843c749SSergey Zigachev 
1066*b843c749SSergey Zigachev 	list_for_each_entry(crtc, &drm_dev->mode_config.crtc_list, head) {
1067*b843c749SSergey Zigachev 		if (crtc->enabled) {
1068*b843c749SSergey Zigachev 			DRM_DEBUG_DRIVER("failing to power off - crtc active\n");
1069*b843c749SSergey Zigachev 			return -EBUSY;
1070*b843c749SSergey Zigachev 		}
1071*b843c749SSergey Zigachev 	}
1072*b843c749SSergey Zigachev 
1073*b843c749SSergey Zigachev 	pm_runtime_mark_last_busy(dev);
1074*b843c749SSergey Zigachev 	pm_runtime_autosuspend(dev);
1075*b843c749SSergey Zigachev 	/* we don't want the main rpm_idle to call suspend - we want to autosuspend */
1076*b843c749SSergey Zigachev 	return 1;
1077*b843c749SSergey Zigachev }
1078*b843c749SSergey Zigachev 
1079*b843c749SSergey Zigachev long amdgpu_drm_ioctl(struct file *filp,
1080*b843c749SSergey Zigachev 		      unsigned int cmd, unsigned long arg)
1081*b843c749SSergey Zigachev {
1082*b843c749SSergey Zigachev 	struct drm_file *file_priv = filp->private_data;
1083*b843c749SSergey Zigachev 	struct drm_device *dev;
1084*b843c749SSergey Zigachev 	long ret;
1085*b843c749SSergey Zigachev 	dev = file_priv->minor->dev;
1086*b843c749SSergey Zigachev 	ret = pm_runtime_get_sync(dev->dev);
1087*b843c749SSergey Zigachev 	if (ret < 0)
1088*b843c749SSergey Zigachev 		goto out;
1089*b843c749SSergey Zigachev 
1090*b843c749SSergey Zigachev 	ret = drm_ioctl(filp, cmd, arg);
1091*b843c749SSergey Zigachev 
1092*b843c749SSergey Zigachev 	pm_runtime_mark_last_busy(dev->dev);
1093*b843c749SSergey Zigachev out:
1094*b843c749SSergey Zigachev 	pm_runtime_put_autosuspend(dev->dev);
1095*b843c749SSergey Zigachev 	return ret;
1096*b843c749SSergey Zigachev }
1097*b843c749SSergey Zigachev 
1098*b843c749SSergey Zigachev static const struct dev_pm_ops amdgpu_pm_ops = {
1099*b843c749SSergey Zigachev 	.suspend = amdgpu_pmops_suspend,
1100*b843c749SSergey Zigachev 	.resume = amdgpu_pmops_resume,
1101*b843c749SSergey Zigachev 	.freeze = amdgpu_pmops_freeze,
1102*b843c749SSergey Zigachev 	.thaw = amdgpu_pmops_thaw,
1103*b843c749SSergey Zigachev 	.poweroff = amdgpu_pmops_poweroff,
1104*b843c749SSergey Zigachev 	.restore = amdgpu_pmops_restore,
1105*b843c749SSergey Zigachev 	.runtime_suspend = amdgpu_pmops_runtime_suspend,
1106*b843c749SSergey Zigachev 	.runtime_resume = amdgpu_pmops_runtime_resume,
1107*b843c749SSergey Zigachev 	.runtime_idle = amdgpu_pmops_runtime_idle,
1108*b843c749SSergey Zigachev };
1109*b843c749SSergey Zigachev 
1110*b843c749SSergey Zigachev static int amdgpu_flush(struct file *f, fl_owner_t id)
1111*b843c749SSergey Zigachev {
1112*b843c749SSergey Zigachev 	struct drm_file *file_priv = f->private_data;
1113*b843c749SSergey Zigachev 	struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
1114*b843c749SSergey Zigachev 
1115*b843c749SSergey Zigachev 	amdgpu_ctx_mgr_entity_flush(&fpriv->ctx_mgr);
1116*b843c749SSergey Zigachev 
1117*b843c749SSergey Zigachev 	return 0;
1118*b843c749SSergey Zigachev }
1119*b843c749SSergey Zigachev 
1120*b843c749SSergey Zigachev 
1121*b843c749SSergey Zigachev static const struct file_operations amdgpu_driver_kms_fops = {
1122*b843c749SSergey Zigachev 	.owner = THIS_MODULE,
1123*b843c749SSergey Zigachev 	.open = drm_open,
1124*b843c749SSergey Zigachev 	.flush = amdgpu_flush,
1125*b843c749SSergey Zigachev 	.release = drm_release,
1126*b843c749SSergey Zigachev 	.unlocked_ioctl = amdgpu_drm_ioctl,
1127*b843c749SSergey Zigachev 	.mmap = amdgpu_mmap,
1128*b843c749SSergey Zigachev 	.poll = drm_poll,
1129*b843c749SSergey Zigachev 	.read = drm_read,
1130*b843c749SSergey Zigachev #ifdef CONFIG_COMPAT
1131*b843c749SSergey Zigachev 	.compat_ioctl = amdgpu_kms_compat_ioctl,
1132*b843c749SSergey Zigachev #endif
1133*b843c749SSergey Zigachev };
1134*b843c749SSergey Zigachev 
1135*b843c749SSergey Zigachev static bool
1136*b843c749SSergey Zigachev amdgpu_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
1137*b843c749SSergey Zigachev 				 bool in_vblank_irq, int *vpos, int *hpos,
1138*b843c749SSergey Zigachev 				 ktime_t *stime, ktime_t *etime,
1139*b843c749SSergey Zigachev 				 const struct drm_display_mode *mode)
1140*b843c749SSergey Zigachev {
1141*b843c749SSergey Zigachev 	return amdgpu_display_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
1142*b843c749SSergey Zigachev 						  stime, etime, mode);
1143*b843c749SSergey Zigachev }
1144*b843c749SSergey Zigachev 
1145*b843c749SSergey Zigachev static struct drm_driver kms_driver = {
1146*b843c749SSergey Zigachev 	.driver_features =
1147*b843c749SSergey Zigachev 	    DRIVER_USE_AGP |
1148*b843c749SSergey Zigachev 	    DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM |
1149*b843c749SSergey Zigachev 	    DRIVER_PRIME | DRIVER_RENDER | DRIVER_MODESET | DRIVER_SYNCOBJ,
1150*b843c749SSergey Zigachev 	.load = amdgpu_driver_load_kms,
1151*b843c749SSergey Zigachev 	.open = amdgpu_driver_open_kms,
1152*b843c749SSergey Zigachev 	.postclose = amdgpu_driver_postclose_kms,
1153*b843c749SSergey Zigachev 	.lastclose = amdgpu_driver_lastclose_kms,
1154*b843c749SSergey Zigachev 	.unload = amdgpu_driver_unload_kms,
1155*b843c749SSergey Zigachev 	.get_vblank_counter = amdgpu_get_vblank_counter_kms,
1156*b843c749SSergey Zigachev 	.enable_vblank = amdgpu_enable_vblank_kms,
1157*b843c749SSergey Zigachev 	.disable_vblank = amdgpu_disable_vblank_kms,
1158*b843c749SSergey Zigachev 	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
1159*b843c749SSergey Zigachev 	.get_scanout_position = amdgpu_get_crtc_scanout_position,
1160*b843c749SSergey Zigachev 	.irq_handler = amdgpu_irq_handler,
1161*b843c749SSergey Zigachev 	.ioctls = amdgpu_ioctls_kms,
1162*b843c749SSergey Zigachev 	.gem_free_object_unlocked = amdgpu_gem_object_free,
1163*b843c749SSergey Zigachev 	.gem_open_object = amdgpu_gem_object_open,
1164*b843c749SSergey Zigachev 	.gem_close_object = amdgpu_gem_object_close,
1165*b843c749SSergey Zigachev 	.dumb_create = amdgpu_mode_dumb_create,
1166*b843c749SSergey Zigachev 	.dumb_map_offset = amdgpu_mode_dumb_mmap,
1167*b843c749SSergey Zigachev 	.fops = &amdgpu_driver_kms_fops,
1168*b843c749SSergey Zigachev 
1169*b843c749SSergey Zigachev 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
1170*b843c749SSergey Zigachev 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
1171*b843c749SSergey Zigachev 	.gem_prime_export = amdgpu_gem_prime_export,
1172*b843c749SSergey Zigachev 	.gem_prime_import = amdgpu_gem_prime_import,
1173*b843c749SSergey Zigachev 	.gem_prime_res_obj = amdgpu_gem_prime_res_obj,
1174*b843c749SSergey Zigachev 	.gem_prime_get_sg_table = amdgpu_gem_prime_get_sg_table,
1175*b843c749SSergey Zigachev 	.gem_prime_import_sg_table = amdgpu_gem_prime_import_sg_table,
1176*b843c749SSergey Zigachev 	.gem_prime_vmap = amdgpu_gem_prime_vmap,
1177*b843c749SSergey Zigachev 	.gem_prime_vunmap = amdgpu_gem_prime_vunmap,
1178*b843c749SSergey Zigachev 	.gem_prime_mmap = amdgpu_gem_prime_mmap,
1179*b843c749SSergey Zigachev 
1180*b843c749SSergey Zigachev 	.name = DRIVER_NAME,
1181*b843c749SSergey Zigachev 	.desc = DRIVER_DESC,
1182*b843c749SSergey Zigachev 	.date = DRIVER_DATE,
1183*b843c749SSergey Zigachev 	.major = KMS_DRIVER_MAJOR,
1184*b843c749SSergey Zigachev 	.minor = KMS_DRIVER_MINOR,
1185*b843c749SSergey Zigachev 	.patchlevel = KMS_DRIVER_PATCHLEVEL,
1186*b843c749SSergey Zigachev };
1187*b843c749SSergey Zigachev 
1188*b843c749SSergey Zigachev static struct drm_driver *driver;
1189*b843c749SSergey Zigachev static struct pci_driver *pdriver;
1190*b843c749SSergey Zigachev 
1191*b843c749SSergey Zigachev static struct pci_driver amdgpu_kms_pci_driver = {
1192*b843c749SSergey Zigachev 	.name = DRIVER_NAME,
1193*b843c749SSergey Zigachev 	.id_table = pciidlist,
1194*b843c749SSergey Zigachev 	.probe = amdgpu_pci_probe,
1195*b843c749SSergey Zigachev 	.remove = amdgpu_pci_remove,
1196*b843c749SSergey Zigachev 	.shutdown = amdgpu_pci_shutdown,
1197*b843c749SSergey Zigachev 	.driver.pm = &amdgpu_pm_ops,
1198*b843c749SSergey Zigachev };
1199*b843c749SSergey Zigachev 
1200*b843c749SSergey Zigachev 
1201*b843c749SSergey Zigachev 
1202*b843c749SSergey Zigachev static int __init amdgpu_init(void)
1203*b843c749SSergey Zigachev {
1204*b843c749SSergey Zigachev 	int r;
1205*b843c749SSergey Zigachev 
1206*b843c749SSergey Zigachev 	if (vgacon_text_force()) {
1207*b843c749SSergey Zigachev 		DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n");
1208*b843c749SSergey Zigachev 		return -EINVAL;
1209*b843c749SSergey Zigachev 	}
1210*b843c749SSergey Zigachev 
1211*b843c749SSergey Zigachev 	r = amdgpu_sync_init();
1212*b843c749SSergey Zigachev 	if (r)
1213*b843c749SSergey Zigachev 		goto error_sync;
1214*b843c749SSergey Zigachev 
1215*b843c749SSergey Zigachev 	r = amdgpu_fence_slab_init();
1216*b843c749SSergey Zigachev 	if (r)
1217*b843c749SSergey Zigachev 		goto error_fence;
1218*b843c749SSergey Zigachev 
1219*b843c749SSergey Zigachev 	DRM_INFO("amdgpu kernel modesetting enabled.\n");
1220*b843c749SSergey Zigachev 	driver = &kms_driver;
1221*b843c749SSergey Zigachev 	pdriver = &amdgpu_kms_pci_driver;
1222*b843c749SSergey Zigachev 	driver->num_ioctls = amdgpu_max_kms_ioctl;
1223*b843c749SSergey Zigachev 	amdgpu_register_atpx_handler();
1224*b843c749SSergey Zigachev 	/* let modprobe override vga console setting */
1225*b843c749SSergey Zigachev 	return pci_register_driver(pdriver);
1226*b843c749SSergey Zigachev 
1227*b843c749SSergey Zigachev error_fence:
1228*b843c749SSergey Zigachev 	amdgpu_sync_fini();
1229*b843c749SSergey Zigachev 
1230*b843c749SSergey Zigachev error_sync:
1231*b843c749SSergey Zigachev 	return r;
1232*b843c749SSergey Zigachev }
1233*b843c749SSergey Zigachev 
1234*b843c749SSergey Zigachev static void __exit amdgpu_exit(void)
1235*b843c749SSergey Zigachev {
1236*b843c749SSergey Zigachev 	amdgpu_amdkfd_fini();
1237*b843c749SSergey Zigachev 	pci_unregister_driver(pdriver);
1238*b843c749SSergey Zigachev 	amdgpu_unregister_atpx_handler();
1239*b843c749SSergey Zigachev 	amdgpu_sync_fini();
1240*b843c749SSergey Zigachev 	amdgpu_fence_slab_fini();
1241*b843c749SSergey Zigachev }
1242*b843c749SSergey Zigachev 
1243*b843c749SSergey Zigachev module_init(amdgpu_init);
1244*b843c749SSergey Zigachev module_exit(amdgpu_exit);
1245*b843c749SSergey Zigachev 
1246*b843c749SSergey Zigachev MODULE_AUTHOR(DRIVER_AUTHOR);
1247*b843c749SSergey Zigachev MODULE_DESCRIPTION(DRIVER_DESC);
1248*b843c749SSergey Zigachev MODULE_LICENSE("GPL and additional rights");
1249