xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_drv.c (revision 8f48ab4ea6eb8c8b41119c36af30f7ae6912122f)
1*8f48ab4eSriastradh /*	$NetBSD: amdgpu_drv.c,v 1.8 2021/12/19 12:23:42 riastradh Exp $	*/
2efa246c0Sriastradh 
3efa246c0Sriastradh /*
4efa246c0Sriastradh  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
5efa246c0Sriastradh  * All Rights Reserved.
6efa246c0Sriastradh  *
7efa246c0Sriastradh  * Permission is hereby granted, free of charge, to any person obtaining a
8efa246c0Sriastradh  * copy of this software and associated documentation files (the "Software"),
9efa246c0Sriastradh  * to deal in the Software without restriction, including without limitation
10efa246c0Sriastradh  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11efa246c0Sriastradh  * and/or sell copies of the Software, and to permit persons to whom the
12efa246c0Sriastradh  * Software is furnished to do so, subject to the following conditions:
13efa246c0Sriastradh  *
14efa246c0Sriastradh  * The above copyright notice and this permission notice (including the next
15efa246c0Sriastradh  * paragraph) shall be included in all copies or substantial portions of the
16efa246c0Sriastradh  * Software.
17efa246c0Sriastradh  *
18efa246c0Sriastradh  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19efa246c0Sriastradh  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20efa246c0Sriastradh  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21efa246c0Sriastradh  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22efa246c0Sriastradh  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23efa246c0Sriastradh  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24efa246c0Sriastradh  * OTHER DEALINGS IN THE SOFTWARE.
25efa246c0Sriastradh  */
26efa246c0Sriastradh 
27efa246c0Sriastradh #include <sys/cdefs.h>
28*8f48ab4eSriastradh __KERNEL_RCSID(0, "$NetBSD: amdgpu_drv.c,v 1.8 2021/12/19 12:23:42 riastradh Exp $");
29efa246c0Sriastradh 
30efa246c0Sriastradh #include <drm/amdgpu_drm.h>
3141ec0267Sriastradh #include <drm/drm_drv.h>
32efa246c0Sriastradh #include <drm/drm_gem.h>
3341ec0267Sriastradh #include <drm/drm_vblank.h>
34efa246c0Sriastradh #include "amdgpu_drv.h"
35efa246c0Sriastradh 
3613222386Sriastradh #include <drm/drm_pci.h>
37efa246c0Sriastradh #include <drm/drm_pciids.h>
38efa246c0Sriastradh #include <linux/console.h>
39efa246c0Sriastradh #include <linux/module.h>
4041ec0267Sriastradh #include <linux/pci.h>
41efa246c0Sriastradh #include <linux/pm_runtime.h>
42efa246c0Sriastradh #include <linux/vga_switcheroo.h>
4341ec0267Sriastradh #include <drm/drm_probe_helper.h>
4441ec0267Sriastradh #include <linux/mmu_notifier.h>
45efa246c0Sriastradh 
46efa246c0Sriastradh #include "amdgpu.h"
47efa246c0Sriastradh #include "amdgpu_irq.h"
4841ec0267Sriastradh #include "amdgpu_dma_buf.h"
49efa246c0Sriastradh 
50efa246c0Sriastradh #include "amdgpu_amdkfd.h"
51efa246c0Sriastradh 
5241ec0267Sriastradh #include "amdgpu_ras.h"
5341ec0267Sriastradh 
54efa246c0Sriastradh /*
55efa246c0Sriastradh  * KMS wrapper.
56efa246c0Sriastradh  * - 3.0.0 - initial driver
57efa246c0Sriastradh  * - 3.1.0 - allow reading more status registers (GRBM, SRBM, SDMA, CP)
5841ec0267Sriastradh  * - 3.2.0 - GFX8: Uses EOP_TC_WB_ACTION_EN, so UMDs don't have to do the same
5941ec0267Sriastradh  *           at the end of IBs.
6041ec0267Sriastradh  * - 3.3.0 - Add VM support for UVD on supported hardware.
6141ec0267Sriastradh  * - 3.4.0 - Add AMDGPU_INFO_NUM_EVICTIONS.
6241ec0267Sriastradh  * - 3.5.0 - Add support for new UVD_NO_OP register.
6341ec0267Sriastradh  * - 3.6.0 - kmd involves use CONTEXT_CONTROL in ring buffer.
6441ec0267Sriastradh  * - 3.7.0 - Add support for VCE clock list packet
6541ec0267Sriastradh  * - 3.8.0 - Add support raster config init in the kernel
6641ec0267Sriastradh  * - 3.9.0 - Add support for memory query info about VRAM and GTT.
6741ec0267Sriastradh  * - 3.10.0 - Add support for new fences ioctl, new gem ioctl flags
6841ec0267Sriastradh  * - 3.11.0 - Add support for sensor query info (clocks, temp, etc).
6941ec0267Sriastradh  * - 3.12.0 - Add query for double offchip LDS buffers
7041ec0267Sriastradh  * - 3.13.0 - Add PRT support
7141ec0267Sriastradh  * - 3.14.0 - Fix race in amdgpu_ctx_get_fence() and note new functionality
7241ec0267Sriastradh  * - 3.15.0 - Export more gpu info for gfx9
7341ec0267Sriastradh  * - 3.16.0 - Add reserved vmid support
7441ec0267Sriastradh  * - 3.17.0 - Add AMDGPU_NUM_VRAM_CPU_PAGE_FAULTS.
7541ec0267Sriastradh  * - 3.18.0 - Export gpu always on cu bitmap
7641ec0267Sriastradh  * - 3.19.0 - Add support for UVD MJPEG decode
7741ec0267Sriastradh  * - 3.20.0 - Add support for local BOs
7841ec0267Sriastradh  * - 3.21.0 - Add DRM_AMDGPU_FENCE_TO_HANDLE ioctl
7941ec0267Sriastradh  * - 3.22.0 - Add DRM_AMDGPU_SCHED ioctl
8041ec0267Sriastradh  * - 3.23.0 - Add query for VRAM lost counter
8141ec0267Sriastradh  * - 3.24.0 - Add high priority compute support for gfx9
8241ec0267Sriastradh  * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk).
8341ec0267Sriastradh  * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE.
8441ec0267Sriastradh  * - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LIST creation.
8541ec0267Sriastradh  * - 3.28.0 - Add AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES
8641ec0267Sriastradh  * - 3.29.0 - Add AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID
8741ec0267Sriastradh  * - 3.30.0 - Add AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE.
8841ec0267Sriastradh  * - 3.31.0 - Add support for per-flip tiling attribute changes with DC
8941ec0267Sriastradh  * - 3.32.0 - Add syncobj timeline support to AMDGPU_CS.
9041ec0267Sriastradh  * - 3.33.0 - Fixes for GDS ENOMEM failures in AMDGPU_CS.
9141ec0267Sriastradh  * - 3.34.0 - Non-DC can flip correctly between buffers with different pitches
9241ec0267Sriastradh  * - 3.35.0 - Add drm_amdgpu_info_device::tcc_disabled_mask
9341ec0267Sriastradh  * - 3.36.0 - Allow reading more status registers on si/cik
94efa246c0Sriastradh  */
95efa246c0Sriastradh #define KMS_DRIVER_MAJOR	3
9641ec0267Sriastradh #define KMS_DRIVER_MINOR	36
97efa246c0Sriastradh #define KMS_DRIVER_PATCHLEVEL	0
98efa246c0Sriastradh 
99efa246c0Sriastradh int amdgpu_vram_limit = 0;
10041ec0267Sriastradh int amdgpu_vis_vram_limit = 0;
101efa246c0Sriastradh int amdgpu_gart_size = -1; /* auto */
10241ec0267Sriastradh int amdgpu_gtt_size = -1; /* auto */
10341ec0267Sriastradh int amdgpu_moverate = -1; /* auto */
104efa246c0Sriastradh int amdgpu_benchmarking = 0;
105efa246c0Sriastradh int amdgpu_testing = 0;
106efa246c0Sriastradh int amdgpu_audio = -1;
107efa246c0Sriastradh int amdgpu_disp_priority = 0;
108efa246c0Sriastradh int amdgpu_hw_i2c = 0;
109efa246c0Sriastradh int amdgpu_pcie_gen2 = -1;
110efa246c0Sriastradh int amdgpu_msi = -1;
11141ec0267Sriastradh char amdgpu_lockup_timeout[AMDGPU_MAX_TIMEOUT_PARAM_LENGTH];
112efa246c0Sriastradh int amdgpu_dpm = -1;
11341ec0267Sriastradh int amdgpu_fw_load_type = -1;
114efa246c0Sriastradh int amdgpu_aspm = -1;
115efa246c0Sriastradh int amdgpu_runtime_pm = -1;
11641ec0267Sriastradh uint amdgpu_ip_block_mask = 0xffffffff;
117efa246c0Sriastradh int amdgpu_bapm = -1;
118efa246c0Sriastradh int amdgpu_deep_color = 0;
11941ec0267Sriastradh int amdgpu_vm_size = -1;
12041ec0267Sriastradh int amdgpu_vm_fragment_size = -1;
121efa246c0Sriastradh int amdgpu_vm_block_size = -1;
122efa246c0Sriastradh int amdgpu_vm_fault_stop = 0;
123efa246c0Sriastradh int amdgpu_vm_debug = 0;
12441ec0267Sriastradh int amdgpu_vm_update_mode = -1;
125efa246c0Sriastradh int amdgpu_exp_hw_support = 0;
12641ec0267Sriastradh int amdgpu_dc = -1;
12741ec0267Sriastradh int amdgpu_sched_jobs = 32;
128efa246c0Sriastradh int amdgpu_sched_hw_submission = 2;
12941ec0267Sriastradh uint amdgpu_pcie_gen_cap = 0;
13041ec0267Sriastradh uint amdgpu_pcie_lane_cap = 0;
13141ec0267Sriastradh uint amdgpu_cg_mask = 0xffffffff;
13241ec0267Sriastradh uint amdgpu_pg_mask = 0xffffffff;
13341ec0267Sriastradh uint amdgpu_sdma_phase_quantum = 32;
13441ec0267Sriastradh char *amdgpu_disable_cu = NULL;
13541ec0267Sriastradh char *amdgpu_virtual_display = NULL;
13641ec0267Sriastradh /* OverDrive(bit 14) disabled by default*/
13741ec0267Sriastradh uint amdgpu_pp_feature_mask = 0xffffbfff;
13841ec0267Sriastradh uint amdgpu_force_long_training = 0;
13941ec0267Sriastradh int amdgpu_job_hang_limit = 0;
14041ec0267Sriastradh int amdgpu_lbpw = -1;
14141ec0267Sriastradh int amdgpu_compute_multipipe = -1;
14241ec0267Sriastradh int amdgpu_gpu_recovery = -1; /* auto */
14341ec0267Sriastradh int amdgpu_emu_mode = 0;
14441ec0267Sriastradh uint amdgpu_smu_memory_pool_size = 0;
14541ec0267Sriastradh /* FBC (bit 0) disabled by default*/
14641ec0267Sriastradh uint amdgpu_dc_feature_mask = 0;
14741ec0267Sriastradh int amdgpu_async_gfx_ring = 1;
14841ec0267Sriastradh int amdgpu_mcbp = 0;
14941ec0267Sriastradh int amdgpu_discovery = -1;
15041ec0267Sriastradh int amdgpu_mes = 0;
15141ec0267Sriastradh int amdgpu_noretry;
15241ec0267Sriastradh int amdgpu_force_asic_type = -1;
153efa246c0Sriastradh 
15441ec0267Sriastradh struct amdgpu_mgpu_info mgpu_info = {
15513222386Sriastradh #ifndef __NetBSD__
15641ec0267Sriastradh 	.mutex = __MUTEX_INITIALIZER(mgpu_info.mutex),
15713222386Sriastradh #endif
15841ec0267Sriastradh };
15941ec0267Sriastradh int amdgpu_ras_enable = -1;
16041ec0267Sriastradh uint amdgpu_ras_mask = 0xffffffff;
16141ec0267Sriastradh 
16241ec0267Sriastradh /**
16341ec0267Sriastradh  * DOC: vramlimit (int)
16441ec0267Sriastradh  * Restrict the total amount of VRAM in MiB for testing.  The default is 0 (Use full VRAM).
16541ec0267Sriastradh  */
166efa246c0Sriastradh MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
167efa246c0Sriastradh module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
168efa246c0Sriastradh 
16941ec0267Sriastradh /**
17041ec0267Sriastradh  * DOC: vis_vramlimit (int)
17141ec0267Sriastradh  * Restrict the amount of CPU visible VRAM in MiB for testing.  The default is 0 (Use full CPU visible VRAM).
17241ec0267Sriastradh  */
17341ec0267Sriastradh MODULE_PARM_DESC(vis_vramlimit, "Restrict visible VRAM for testing, in megabytes");
17441ec0267Sriastradh module_param_named(vis_vramlimit, amdgpu_vis_vram_limit, int, 0444);
175efa246c0Sriastradh 
17641ec0267Sriastradh /**
17741ec0267Sriastradh  * DOC: gartsize (uint)
17841ec0267Sriastradh  * Restrict the size of GART in Mib (32, 64, etc.) for testing. The default is -1 (The size depends on asic).
17941ec0267Sriastradh  */
18041ec0267Sriastradh MODULE_PARM_DESC(gartsize, "Size of GART to setup in megabytes (32, 64, etc., -1=auto)");
18141ec0267Sriastradh module_param_named(gartsize, amdgpu_gart_size, uint, 0600);
18241ec0267Sriastradh 
18341ec0267Sriastradh /**
18441ec0267Sriastradh  * DOC: gttsize (int)
18541ec0267Sriastradh  * Restrict the size of GTT domain in MiB for testing. The default is -1 (It's VRAM size if 3GB < VRAM < 3/4 RAM,
18641ec0267Sriastradh  * otherwise 3/4 RAM size).
18741ec0267Sriastradh  */
18841ec0267Sriastradh MODULE_PARM_DESC(gttsize, "Size of the GTT domain in megabytes (-1 = auto)");
18941ec0267Sriastradh module_param_named(gttsize, amdgpu_gtt_size, int, 0600);
19041ec0267Sriastradh 
19141ec0267Sriastradh /**
19241ec0267Sriastradh  * DOC: moverate (int)
19341ec0267Sriastradh  * Set maximum buffer migration rate in MB/s. The default is -1 (8 MB/s).
19441ec0267Sriastradh  */
19541ec0267Sriastradh MODULE_PARM_DESC(moverate, "Maximum buffer migration rate in MB/s. (32, 64, etc., -1=auto, 0=1=disabled)");
19641ec0267Sriastradh module_param_named(moverate, amdgpu_moverate, int, 0600);
19741ec0267Sriastradh 
19841ec0267Sriastradh /**
19941ec0267Sriastradh  * DOC: benchmark (int)
20041ec0267Sriastradh  * Run benchmarks. The default is 0 (Skip benchmarks).
20141ec0267Sriastradh  */
202efa246c0Sriastradh MODULE_PARM_DESC(benchmark, "Run benchmark");
203efa246c0Sriastradh module_param_named(benchmark, amdgpu_benchmarking, int, 0444);
204efa246c0Sriastradh 
20541ec0267Sriastradh /**
20641ec0267Sriastradh  * DOC: test (int)
20741ec0267Sriastradh  * Test BO GTT->VRAM and VRAM->GTT GPU copies. The default is 0 (Skip test, only set 1 to run test).
20841ec0267Sriastradh  */
209efa246c0Sriastradh MODULE_PARM_DESC(test, "Run tests");
210efa246c0Sriastradh module_param_named(test, amdgpu_testing, int, 0444);
211efa246c0Sriastradh 
21241ec0267Sriastradh /**
21341ec0267Sriastradh  * DOC: audio (int)
21441ec0267Sriastradh  * Set HDMI/DPAudio. Only affects non-DC display handling. The default is -1 (Enabled), set 0 to disabled it.
21541ec0267Sriastradh  */
216efa246c0Sriastradh MODULE_PARM_DESC(audio, "Audio enable (-1 = auto, 0 = disable, 1 = enable)");
217efa246c0Sriastradh module_param_named(audio, amdgpu_audio, int, 0444);
218efa246c0Sriastradh 
21941ec0267Sriastradh /**
22041ec0267Sriastradh  * DOC: disp_priority (int)
22141ec0267Sriastradh  * Set display Priority (1 = normal, 2 = high). Only affects non-DC display handling. The default is 0 (auto).
22241ec0267Sriastradh  */
223efa246c0Sriastradh MODULE_PARM_DESC(disp_priority, "Display Priority (0 = auto, 1 = normal, 2 = high)");
224efa246c0Sriastradh module_param_named(disp_priority, amdgpu_disp_priority, int, 0444);
225efa246c0Sriastradh 
22641ec0267Sriastradh /**
22741ec0267Sriastradh  * DOC: hw_i2c (int)
22841ec0267Sriastradh  * To enable hw i2c engine. Only affects non-DC display handling. The default is 0 (Disabled).
22941ec0267Sriastradh  */
230efa246c0Sriastradh MODULE_PARM_DESC(hw_i2c, "hw i2c engine enable (0 = disable)");
231efa246c0Sriastradh module_param_named(hw_i2c, amdgpu_hw_i2c, int, 0444);
232efa246c0Sriastradh 
23341ec0267Sriastradh /**
23441ec0267Sriastradh  * DOC: pcie_gen2 (int)
23541ec0267Sriastradh  * To disable PCIE Gen2/3 mode (0 = disable, 1 = enable). The default is -1 (auto, enabled).
23641ec0267Sriastradh  */
237efa246c0Sriastradh MODULE_PARM_DESC(pcie_gen2, "PCIE Gen2 mode (-1 = auto, 0 = disable, 1 = enable)");
238efa246c0Sriastradh module_param_named(pcie_gen2, amdgpu_pcie_gen2, int, 0444);
239efa246c0Sriastradh 
24041ec0267Sriastradh /**
24141ec0267Sriastradh  * DOC: msi (int)
24241ec0267Sriastradh  * To disable Message Signaled Interrupts (MSI) functionality (1 = enable, 0 = disable). The default is -1 (auto, enabled).
24341ec0267Sriastradh  */
244efa246c0Sriastradh MODULE_PARM_DESC(msi, "MSI support (1 = enable, 0 = disable, -1 = auto)");
245efa246c0Sriastradh module_param_named(msi, amdgpu_msi, int, 0444);
246efa246c0Sriastradh 
24741ec0267Sriastradh /**
24841ec0267Sriastradh  * DOC: lockup_timeout (string)
24941ec0267Sriastradh  * Set GPU scheduler timeout value in ms.
25041ec0267Sriastradh  *
25141ec0267Sriastradh  * The format can be [Non-Compute] or [GFX,Compute,SDMA,Video]. That is there can be one or
25241ec0267Sriastradh  * multiple values specified. 0 and negative values are invalidated. They will be adjusted
25341ec0267Sriastradh  * to the default timeout.
25441ec0267Sriastradh  *
25541ec0267Sriastradh  * - With one value specified, the setting will apply to all non-compute jobs.
25641ec0267Sriastradh  * - With multiple values specified, the first one will be for GFX.
25741ec0267Sriastradh  *   The second one is for Compute. The third and fourth ones are
25841ec0267Sriastradh  *   for SDMA and Video.
25941ec0267Sriastradh  *
26041ec0267Sriastradh  * By default(with no lockup_timeout settings), the timeout for all non-compute(GFX, SDMA and Video)
26141ec0267Sriastradh  * jobs is 10000. And there is no timeout enforced on compute jobs.
26241ec0267Sriastradh  */
26341ec0267Sriastradh MODULE_PARM_DESC(lockup_timeout, "GPU lockup timeout in ms (default: for bare metal 10000 for non-compute jobs and infinity timeout for compute jobs; "
26441ec0267Sriastradh 		"for passthrough or sriov, 10000 for all jobs."
26541ec0267Sriastradh 		" 0: keep default value. negative: infinity timeout), "
26641ec0267Sriastradh 		"format: for bare metal [Non-Compute] or [GFX,Compute,SDMA,Video]; "
26741ec0267Sriastradh 		"for passthrough or sriov [all jobs] or [GFX,Compute,SDMA,Video].");
26841ec0267Sriastradh module_param_string(lockup_timeout, amdgpu_lockup_timeout, sizeof(amdgpu_lockup_timeout), 0444);
269efa246c0Sriastradh 
27041ec0267Sriastradh /**
27141ec0267Sriastradh  * DOC: dpm (int)
27241ec0267Sriastradh  * Override for dynamic power management setting
27341ec0267Sriastradh  * (0 = disable, 1 = enable, 2 = enable sw smu driver for vega20)
27441ec0267Sriastradh  * The default is -1 (auto).
27541ec0267Sriastradh  */
276efa246c0Sriastradh MODULE_PARM_DESC(dpm, "DPM support (1 = enable, 0 = disable, -1 = auto)");
277efa246c0Sriastradh module_param_named(dpm, amdgpu_dpm, int, 0444);
278efa246c0Sriastradh 
27941ec0267Sriastradh /**
28041ec0267Sriastradh  * DOC: fw_load_type (int)
28141ec0267Sriastradh  * Set different firmware loading type for debugging (0 = direct, 1 = SMU, 2 = PSP). The default is -1 (auto).
28241ec0267Sriastradh  */
28341ec0267Sriastradh MODULE_PARM_DESC(fw_load_type, "firmware loading type (0 = direct, 1 = SMU, 2 = PSP, -1 = auto)");
28441ec0267Sriastradh module_param_named(fw_load_type, amdgpu_fw_load_type, int, 0444);
285efa246c0Sriastradh 
28641ec0267Sriastradh /**
28741ec0267Sriastradh  * DOC: aspm (int)
28841ec0267Sriastradh  * To disable ASPM (1 = enable, 0 = disable). The default is -1 (auto, enabled).
28941ec0267Sriastradh  */
290efa246c0Sriastradh MODULE_PARM_DESC(aspm, "ASPM support (1 = enable, 0 = disable, -1 = auto)");
291efa246c0Sriastradh module_param_named(aspm, amdgpu_aspm, int, 0444);
292efa246c0Sriastradh 
29341ec0267Sriastradh /**
29441ec0267Sriastradh  * DOC: runpm (int)
29541ec0267Sriastradh  * Override for runtime power management control for dGPUs in PX/HG laptops. The amdgpu driver can dynamically power down
29641ec0267Sriastradh  * the dGPU on PX/HG laptops when it is idle. The default is -1 (auto enable). Setting the value to 0 disables this functionality.
29741ec0267Sriastradh  */
298efa246c0Sriastradh MODULE_PARM_DESC(runpm, "PX runtime pm (1 = force enable, 0 = disable, -1 = PX only default)");
299efa246c0Sriastradh module_param_named(runpm, amdgpu_runtime_pm, int, 0444);
300efa246c0Sriastradh 
30141ec0267Sriastradh /**
30241ec0267Sriastradh  * DOC: ip_block_mask (uint)
30341ec0267Sriastradh  * Override what IP blocks are enabled on the GPU. Each GPU is a collection of IP blocks (gfx, display, video, etc.).
30441ec0267Sriastradh  * Use this parameter to disable specific blocks. Note that the IP blocks do not have a fixed index. Some asics may not have
30541ec0267Sriastradh  * some IPs or may include multiple instances of an IP so the ordering various from asic to asic. See the driver output in
30641ec0267Sriastradh  * the kernel log for the list of IPs on the asic. The default is 0xffffffff (enable all blocks on a device).
30741ec0267Sriastradh  */
308efa246c0Sriastradh MODULE_PARM_DESC(ip_block_mask, "IP Block Mask (all blocks enabled (default))");
309efa246c0Sriastradh module_param_named(ip_block_mask, amdgpu_ip_block_mask, uint, 0444);
310efa246c0Sriastradh 
31141ec0267Sriastradh /**
31241ec0267Sriastradh  * DOC: bapm (int)
31341ec0267Sriastradh  * Bidirectional Application Power Management (BAPM) used to dynamically share TDP between CPU and GPU. Set value 0 to disable it.
31441ec0267Sriastradh  * The default -1 (auto, enabled)
31541ec0267Sriastradh  */
316efa246c0Sriastradh MODULE_PARM_DESC(bapm, "BAPM support (1 = enable, 0 = disable, -1 = auto)");
317efa246c0Sriastradh module_param_named(bapm, amdgpu_bapm, int, 0444);
318efa246c0Sriastradh 
31941ec0267Sriastradh /**
32041ec0267Sriastradh  * DOC: deep_color (int)
32141ec0267Sriastradh  * Set 1 to enable Deep Color support. Only affects non-DC display handling. The default is 0 (disabled).
32241ec0267Sriastradh  */
323efa246c0Sriastradh MODULE_PARM_DESC(deep_color, "Deep Color support (1 = enable, 0 = disable (default))");
324efa246c0Sriastradh module_param_named(deep_color, amdgpu_deep_color, int, 0444);
325efa246c0Sriastradh 
32641ec0267Sriastradh /**
32741ec0267Sriastradh  * DOC: vm_size (int)
32841ec0267Sriastradh  * Override the size of the GPU's per client virtual address space in GiB.  The default is -1 (automatic for each asic).
32941ec0267Sriastradh  */
330efa246c0Sriastradh MODULE_PARM_DESC(vm_size, "VM address space size in gigabytes (default 64GB)");
331efa246c0Sriastradh module_param_named(vm_size, amdgpu_vm_size, int, 0444);
332efa246c0Sriastradh 
33341ec0267Sriastradh /**
33441ec0267Sriastradh  * DOC: vm_fragment_size (int)
33541ec0267Sriastradh  * Override VM fragment size in bits (4, 5, etc. 4 = 64K, 9 = 2M). The default is -1 (automatic for each asic).
33641ec0267Sriastradh  */
33741ec0267Sriastradh MODULE_PARM_DESC(vm_fragment_size, "VM fragment size in bits (4, 5, etc. 4 = 64K (default), Max 9 = 2M)");
33841ec0267Sriastradh module_param_named(vm_fragment_size, amdgpu_vm_fragment_size, int, 0444);
33941ec0267Sriastradh 
34041ec0267Sriastradh /**
34141ec0267Sriastradh  * DOC: vm_block_size (int)
34241ec0267Sriastradh  * Override VM page table size in bits (default depending on vm_size and hw setup). The default is -1 (automatic for each asic).
34341ec0267Sriastradh  */
344efa246c0Sriastradh MODULE_PARM_DESC(vm_block_size, "VM page table size in bits (default depending on vm_size)");
345efa246c0Sriastradh module_param_named(vm_block_size, amdgpu_vm_block_size, int, 0444);
346efa246c0Sriastradh 
34741ec0267Sriastradh /**
34841ec0267Sriastradh  * DOC: vm_fault_stop (int)
34941ec0267Sriastradh  * Stop on VM fault for debugging (0 = never, 1 = print first, 2 = always). The default is 0 (No stop).
35041ec0267Sriastradh  */
351efa246c0Sriastradh MODULE_PARM_DESC(vm_fault_stop, "Stop on VM fault (0 = never (default), 1 = print first, 2 = always)");
352efa246c0Sriastradh module_param_named(vm_fault_stop, amdgpu_vm_fault_stop, int, 0444);
353efa246c0Sriastradh 
35441ec0267Sriastradh /**
35541ec0267Sriastradh  * DOC: vm_debug (int)
35641ec0267Sriastradh  * Debug VM handling (0 = disabled, 1 = enabled). The default is 0 (Disabled).
35741ec0267Sriastradh  */
358efa246c0Sriastradh MODULE_PARM_DESC(vm_debug, "Debug VM handling (0 = disabled (default), 1 = enabled)");
359efa246c0Sriastradh module_param_named(vm_debug, amdgpu_vm_debug, int, 0644);
360efa246c0Sriastradh 
36141ec0267Sriastradh /**
36241ec0267Sriastradh  * DOC: vm_update_mode (int)
36341ec0267Sriastradh  * Override VM update mode. VM updated by using CPU (0 = never, 1 = Graphics only, 2 = Compute only, 3 = Both). The default
36441ec0267Sriastradh  * is -1 (Only in large BAR(LB) systems Compute VM tables will be updated by CPU, otherwise 0, never).
36541ec0267Sriastradh  */
36641ec0267Sriastradh 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");
36741ec0267Sriastradh module_param_named(vm_update_mode, amdgpu_vm_update_mode, int, 0444);
36841ec0267Sriastradh 
36941ec0267Sriastradh /**
37041ec0267Sriastradh  * DOC: exp_hw_support (int)
37141ec0267Sriastradh  * Enable experimental hw support (1 = enable). The default is 0 (disabled).
37241ec0267Sriastradh  */
373efa246c0Sriastradh MODULE_PARM_DESC(exp_hw_support, "experimental hw support (1 = enable, 0 = disable (default))");
374efa246c0Sriastradh module_param_named(exp_hw_support, amdgpu_exp_hw_support, int, 0444);
375efa246c0Sriastradh 
37641ec0267Sriastradh /**
37741ec0267Sriastradh  * DOC: dc (int)
37841ec0267Sriastradh  * Disable/Enable Display Core driver for debugging (1 = enable, 0 = disable). The default is -1 (automatic for each asic).
37941ec0267Sriastradh  */
38041ec0267Sriastradh MODULE_PARM_DESC(dc, "Display Core driver (1 = enable, 0 = disable, -1 = auto (default))");
38141ec0267Sriastradh module_param_named(dc, amdgpu_dc, int, 0444);
382efa246c0Sriastradh 
38341ec0267Sriastradh /**
38441ec0267Sriastradh  * DOC: sched_jobs (int)
38541ec0267Sriastradh  * Override the max number of jobs supported in the sw queue. The default is 32.
38641ec0267Sriastradh  */
38741ec0267Sriastradh MODULE_PARM_DESC(sched_jobs, "the max number of jobs supported in the sw queue (default 32)");
388efa246c0Sriastradh module_param_named(sched_jobs, amdgpu_sched_jobs, int, 0444);
389efa246c0Sriastradh 
39041ec0267Sriastradh /**
39141ec0267Sriastradh  * DOC: sched_hw_submission (int)
39241ec0267Sriastradh  * Override the max number of HW submissions. The default is 2.
39341ec0267Sriastradh  */
394efa246c0Sriastradh MODULE_PARM_DESC(sched_hw_submission, "the max number of HW submissions (default 2)");
395efa246c0Sriastradh module_param_named(sched_hw_submission, amdgpu_sched_hw_submission, int, 0444);
396efa246c0Sriastradh 
39741ec0267Sriastradh /**
39841ec0267Sriastradh  * DOC: ppfeaturemask (uint)
39941ec0267Sriastradh  * Override power features enabled. See enum PP_FEATURE_MASK in drivers/gpu/drm/amd/include/amd_shared.h.
40041ec0267Sriastradh  * The default is the current set of stable power features.
40141ec0267Sriastradh  */
40241ec0267Sriastradh MODULE_PARM_DESC(ppfeaturemask, "all power features enabled (default))");
40341ec0267Sriastradh module_param_named(ppfeaturemask, amdgpu_pp_feature_mask, uint, 0444);
404efa246c0Sriastradh 
40541ec0267Sriastradh /**
40641ec0267Sriastradh  * DOC: forcelongtraining (uint)
40741ec0267Sriastradh  * Force long memory training in resume.
40841ec0267Sriastradh  * The default is zero, indicates short training in resume.
40941ec0267Sriastradh  */
41041ec0267Sriastradh MODULE_PARM_DESC(forcelongtraining, "force memory long training");
41141ec0267Sriastradh module_param_named(forcelongtraining, amdgpu_force_long_training, uint, 0444);
41241ec0267Sriastradh 
41341ec0267Sriastradh /**
41441ec0267Sriastradh  * DOC: pcie_gen_cap (uint)
41541ec0267Sriastradh  * Override PCIE gen speed capabilities. See the CAIL flags in drivers/gpu/drm/amd/include/amd_pcie.h.
41641ec0267Sriastradh  * The default is 0 (automatic for each asic).
41741ec0267Sriastradh  */
41841ec0267Sriastradh MODULE_PARM_DESC(pcie_gen_cap, "PCIE Gen Caps (0: autodetect (default))");
41941ec0267Sriastradh module_param_named(pcie_gen_cap, amdgpu_pcie_gen_cap, uint, 0444);
42041ec0267Sriastradh 
42141ec0267Sriastradh /**
42241ec0267Sriastradh  * DOC: pcie_lane_cap (uint)
42341ec0267Sriastradh  * Override PCIE lanes capabilities. See the CAIL flags in drivers/gpu/drm/amd/include/amd_pcie.h.
42441ec0267Sriastradh  * The default is 0 (automatic for each asic).
42541ec0267Sriastradh  */
42641ec0267Sriastradh MODULE_PARM_DESC(pcie_lane_cap, "PCIE Lane Caps (0: autodetect (default))");
42741ec0267Sriastradh module_param_named(pcie_lane_cap, amdgpu_pcie_lane_cap, uint, 0444);
42841ec0267Sriastradh 
42941ec0267Sriastradh /**
43041ec0267Sriastradh  * DOC: cg_mask (uint)
43141ec0267Sriastradh  * Override Clockgating features enabled on GPU (0 = disable clock gating). See the AMD_CG_SUPPORT flags in
43241ec0267Sriastradh  * drivers/gpu/drm/amd/include/amd_shared.h. The default is 0xffffffff (all enabled).
43341ec0267Sriastradh  */
43441ec0267Sriastradh MODULE_PARM_DESC(cg_mask, "Clockgating flags mask (0 = disable clock gating)");
43541ec0267Sriastradh module_param_named(cg_mask, amdgpu_cg_mask, uint, 0444);
43641ec0267Sriastradh 
43741ec0267Sriastradh /**
43841ec0267Sriastradh  * DOC: pg_mask (uint)
43941ec0267Sriastradh  * Override Powergating features enabled on GPU (0 = disable power gating). See the AMD_PG_SUPPORT flags in
44041ec0267Sriastradh  * drivers/gpu/drm/amd/include/amd_shared.h. The default is 0xffffffff (all enabled).
44141ec0267Sriastradh  */
44241ec0267Sriastradh MODULE_PARM_DESC(pg_mask, "Powergating flags mask (0 = disable power gating)");
44341ec0267Sriastradh module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444);
44441ec0267Sriastradh 
44541ec0267Sriastradh /**
44641ec0267Sriastradh  * DOC: sdma_phase_quantum (uint)
44741ec0267Sriastradh  * Override SDMA context switch phase quantum (x 1K GPU clock cycles, 0 = no change). The default is 32.
44841ec0267Sriastradh  */
44941ec0267Sriastradh MODULE_PARM_DESC(sdma_phase_quantum, "SDMA context switch phase quantum (x 1K GPU clock cycles, 0 = no change (default 32))");
45041ec0267Sriastradh module_param_named(sdma_phase_quantum, amdgpu_sdma_phase_quantum, uint, 0444);
45141ec0267Sriastradh 
45241ec0267Sriastradh /**
45341ec0267Sriastradh  * DOC: disable_cu (charp)
45441ec0267Sriastradh  * Set to disable CUs (It's set like se.sh.cu,...). The default is NULL.
45541ec0267Sriastradh  */
45641ec0267Sriastradh MODULE_PARM_DESC(disable_cu, "Disable CUs (se.sh.cu,...)");
45741ec0267Sriastradh module_param_named(disable_cu, amdgpu_disable_cu, charp, 0444);
45841ec0267Sriastradh 
45941ec0267Sriastradh /**
46041ec0267Sriastradh  * DOC: virtual_display (charp)
46141ec0267Sriastradh  * Set to enable virtual display feature. This feature provides a virtual display hardware on headless boards
46241ec0267Sriastradh  * 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
46341ec0267Sriastradh  * the device, plus the number of crtcs to expose. E.g., 0000:26:00.0,4 would enable 4 virtual crtcs on the pci
46441ec0267Sriastradh  * device at 26:00.0. The default is NULL.
46541ec0267Sriastradh  */
46641ec0267Sriastradh MODULE_PARM_DESC(virtual_display,
46741ec0267Sriastradh 		 "Enable virtual display feature (the virtual_display will be set like xxxx:xx:xx.x,x;xxxx:xx:xx.x,x)");
46841ec0267Sriastradh module_param_named(virtual_display, amdgpu_virtual_display, charp, 0444);
46941ec0267Sriastradh 
47041ec0267Sriastradh /**
47141ec0267Sriastradh  * DOC: job_hang_limit (int)
47241ec0267Sriastradh  * Set how much time allow a job hang and not drop it. The default is 0.
47341ec0267Sriastradh  */
47441ec0267Sriastradh MODULE_PARM_DESC(job_hang_limit, "how much time allow a job hang and not drop it (default 0)");
47541ec0267Sriastradh module_param_named(job_hang_limit, amdgpu_job_hang_limit, int ,0444);
47641ec0267Sriastradh 
47741ec0267Sriastradh /**
47841ec0267Sriastradh  * DOC: lbpw (int)
47941ec0267Sriastradh  * Override Load Balancing Per Watt (LBPW) support (1 = enable, 0 = disable). The default is -1 (auto, enabled).
48041ec0267Sriastradh  */
48141ec0267Sriastradh MODULE_PARM_DESC(lbpw, "Load Balancing Per Watt (LBPW) support (1 = enable, 0 = disable, -1 = auto)");
48241ec0267Sriastradh module_param_named(lbpw, amdgpu_lbpw, int, 0444);
48341ec0267Sriastradh 
48441ec0267Sriastradh MODULE_PARM_DESC(compute_multipipe, "Force compute queues to be spread across pipes (1 = enable, 0 = disable, -1 = auto)");
48541ec0267Sriastradh module_param_named(compute_multipipe, amdgpu_compute_multipipe, int, 0444);
48641ec0267Sriastradh 
48741ec0267Sriastradh /**
48841ec0267Sriastradh  * DOC: gpu_recovery (int)
48941ec0267Sriastradh  * Set to enable GPU recovery mechanism (1 = enable, 0 = disable). The default is -1 (auto, disabled except SRIOV).
49041ec0267Sriastradh  */
49141ec0267Sriastradh MODULE_PARM_DESC(gpu_recovery, "Enable GPU recovery mechanism, (1 = enable, 0 = disable, -1 = auto)");
49241ec0267Sriastradh module_param_named(gpu_recovery, amdgpu_gpu_recovery, int, 0444);
49341ec0267Sriastradh 
49441ec0267Sriastradh /**
49541ec0267Sriastradh  * DOC: emu_mode (int)
49641ec0267Sriastradh  * Set value 1 to enable emulation mode. This is only needed when running on an emulator. The default is 0 (disabled).
49741ec0267Sriastradh  */
49841ec0267Sriastradh MODULE_PARM_DESC(emu_mode, "Emulation mode, (1 = enable, 0 = disable)");
49941ec0267Sriastradh module_param_named(emu_mode, amdgpu_emu_mode, int, 0444);
50041ec0267Sriastradh 
50141ec0267Sriastradh /**
50241ec0267Sriastradh  * DOC: ras_enable (int)
50341ec0267Sriastradh  * Enable RAS features on the GPU (0 = disable, 1 = enable, -1 = auto (default))
50441ec0267Sriastradh  */
50541ec0267Sriastradh MODULE_PARM_DESC(ras_enable, "Enable RAS features on the GPU (0 = disable, 1 = enable, -1 = auto (default))");
50641ec0267Sriastradh module_param_named(ras_enable, amdgpu_ras_enable, int, 0444);
50741ec0267Sriastradh 
50841ec0267Sriastradh /**
50941ec0267Sriastradh  * DOC: ras_mask (uint)
51041ec0267Sriastradh  * Mask of RAS features to enable (default 0xffffffff), only valid when ras_enable == 1
51141ec0267Sriastradh  * See the flags in drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
51241ec0267Sriastradh  */
51341ec0267Sriastradh MODULE_PARM_DESC(ras_mask, "Mask of RAS features to enable (default 0xffffffff), only valid when ras_enable == 1");
51441ec0267Sriastradh module_param_named(ras_mask, amdgpu_ras_mask, uint, 0444);
51541ec0267Sriastradh 
51641ec0267Sriastradh /**
51741ec0267Sriastradh  * DOC: si_support (int)
51841ec0267Sriastradh  * Set SI support driver. This parameter works after set config CONFIG_DRM_AMDGPU_SI. For SI asic, when radeon driver is enabled,
51941ec0267Sriastradh  * set value 0 to use radeon driver, while set value 1 to use amdgpu driver. The default is using radeon driver when it available,
52041ec0267Sriastradh  * otherwise using amdgpu driver.
52141ec0267Sriastradh  */
52241ec0267Sriastradh #ifdef CONFIG_DRM_AMDGPU_SI
52341ec0267Sriastradh 
52441ec0267Sriastradh #if defined(CONFIG_DRM_RADEON) || defined(CONFIG_DRM_RADEON_MODULE)
52541ec0267Sriastradh int amdgpu_si_support = 0;
52641ec0267Sriastradh MODULE_PARM_DESC(si_support, "SI support (1 = enabled, 0 = disabled (default))");
52741ec0267Sriastradh #else
52841ec0267Sriastradh int amdgpu_si_support = 1;
52941ec0267Sriastradh MODULE_PARM_DESC(si_support, "SI support (1 = enabled (default), 0 = disabled)");
53041ec0267Sriastradh #endif
53141ec0267Sriastradh 
53241ec0267Sriastradh module_param_named(si_support, amdgpu_si_support, int, 0444);
53341ec0267Sriastradh #endif
53441ec0267Sriastradh 
53541ec0267Sriastradh /**
53641ec0267Sriastradh  * DOC: cik_support (int)
53741ec0267Sriastradh  * Set CIK support driver. This parameter works after set config CONFIG_DRM_AMDGPU_CIK. For CIK asic, when radeon driver is enabled,
53841ec0267Sriastradh  * set value 0 to use radeon driver, while set value 1 to use amdgpu driver. The default is using radeon driver when it available,
53941ec0267Sriastradh  * otherwise using amdgpu driver.
54041ec0267Sriastradh  */
54141ec0267Sriastradh #ifdef CONFIG_DRM_AMDGPU_CIK
54241ec0267Sriastradh 
54341ec0267Sriastradh #if defined(CONFIG_DRM_RADEON) || defined(CONFIG_DRM_RADEON_MODULE)
54441ec0267Sriastradh int amdgpu_cik_support = 0;
54541ec0267Sriastradh MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled, 0 = disabled (default))");
54641ec0267Sriastradh #else
54741ec0267Sriastradh int amdgpu_cik_support = 1;
54841ec0267Sriastradh MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled (default), 0 = disabled)");
54941ec0267Sriastradh #endif
55041ec0267Sriastradh 
55141ec0267Sriastradh module_param_named(cik_support, amdgpu_cik_support, int, 0444);
55241ec0267Sriastradh #endif
55341ec0267Sriastradh 
55441ec0267Sriastradh /**
55541ec0267Sriastradh  * DOC: smu_memory_pool_size (uint)
55641ec0267Sriastradh  * It is used to reserve gtt for smu debug usage, setting value 0 to disable it. The actual size is value * 256MiB.
55741ec0267Sriastradh  * E.g. 0x1 = 256Mbyte, 0x2 = 512Mbyte, 0x4 = 1 Gbyte, 0x8 = 2GByte. The default is 0 (disabled).
55841ec0267Sriastradh  */
55941ec0267Sriastradh MODULE_PARM_DESC(smu_memory_pool_size,
56041ec0267Sriastradh 	"reserve gtt for smu debug usage, 0 = disable,"
56141ec0267Sriastradh 		"0x1 = 256Mbyte, 0x2 = 512Mbyte, 0x4 = 1 Gbyte, 0x8 = 2GByte");
56241ec0267Sriastradh module_param_named(smu_memory_pool_size, amdgpu_smu_memory_pool_size, uint, 0444);
56341ec0267Sriastradh 
56441ec0267Sriastradh /**
56541ec0267Sriastradh  * DOC: async_gfx_ring (int)
56641ec0267Sriastradh  * It is used to enable gfx rings that could be configured with different prioritites or equal priorities
56741ec0267Sriastradh  */
56841ec0267Sriastradh MODULE_PARM_DESC(async_gfx_ring,
56941ec0267Sriastradh 	"Asynchronous GFX rings that could be configured with either different priorities (HP3D ring and LP3D ring), or equal priorities (0 = disabled, 1 = enabled (default))");
57041ec0267Sriastradh module_param_named(async_gfx_ring, amdgpu_async_gfx_ring, int, 0444);
57141ec0267Sriastradh 
57241ec0267Sriastradh /**
57341ec0267Sriastradh  * DOC: mcbp (int)
57441ec0267Sriastradh  * It is used to enable mid command buffer preemption. (0 = disabled (default), 1 = enabled)
57541ec0267Sriastradh  */
57641ec0267Sriastradh MODULE_PARM_DESC(mcbp,
57741ec0267Sriastradh 	"Enable Mid-command buffer preemption (0 = disabled (default), 1 = enabled)");
57841ec0267Sriastradh module_param_named(mcbp, amdgpu_mcbp, int, 0444);
57941ec0267Sriastradh 
58041ec0267Sriastradh /**
58141ec0267Sriastradh  * DOC: discovery (int)
58241ec0267Sriastradh  * Allow driver to discover hardware IP information from IP Discovery table at the top of VRAM.
58341ec0267Sriastradh  * (-1 = auto (default), 0 = disabled, 1 = enabled)
58441ec0267Sriastradh  */
58541ec0267Sriastradh MODULE_PARM_DESC(discovery,
58641ec0267Sriastradh 	"Allow driver to discover hardware IPs from IP Discovery table at the top of VRAM");
58741ec0267Sriastradh module_param_named(discovery, amdgpu_discovery, int, 0444);
58841ec0267Sriastradh 
58941ec0267Sriastradh /**
59041ec0267Sriastradh  * DOC: mes (int)
59141ec0267Sriastradh  * Enable Micro Engine Scheduler. This is a new hw scheduling engine for gfx, sdma, and compute.
59241ec0267Sriastradh  * (0 = disabled (default), 1 = enabled)
59341ec0267Sriastradh  */
59441ec0267Sriastradh MODULE_PARM_DESC(mes,
59541ec0267Sriastradh 	"Enable Micro Engine Scheduler (0 = disabled (default), 1 = enabled)");
59641ec0267Sriastradh module_param_named(mes, amdgpu_mes, int, 0444);
59741ec0267Sriastradh 
59841ec0267Sriastradh MODULE_PARM_DESC(noretry,
59941ec0267Sriastradh 	"Disable retry faults (0 = retry enabled (default), 1 = retry disabled)");
60041ec0267Sriastradh module_param_named(noretry, amdgpu_noretry, int, 0644);
60141ec0267Sriastradh 
60241ec0267Sriastradh /**
60341ec0267Sriastradh  * DOC: force_asic_type (int)
60441ec0267Sriastradh  * A non negative value used to specify the asic type for all supported GPUs.
60541ec0267Sriastradh  */
60641ec0267Sriastradh MODULE_PARM_DESC(force_asic_type,
60741ec0267Sriastradh 	"A non negative value used to specify the asic type for all supported GPUs");
60841ec0267Sriastradh module_param_named(force_asic_type, amdgpu_force_asic_type, int, 0444);
60941ec0267Sriastradh 
61041ec0267Sriastradh 
61141ec0267Sriastradh 
61241ec0267Sriastradh #ifdef CONFIG_HSA_AMD
61341ec0267Sriastradh /**
61441ec0267Sriastradh  * DOC: sched_policy (int)
61541ec0267Sriastradh  * Set scheduling policy. Default is HWS(hardware scheduling) with over-subscription.
61641ec0267Sriastradh  * Setting 1 disables over-subscription. Setting 2 disables HWS and statically
61741ec0267Sriastradh  * assigns queues to HQDs.
61841ec0267Sriastradh  */
61941ec0267Sriastradh int sched_policy = KFD_SCHED_POLICY_HWS;
62041ec0267Sriastradh module_param(sched_policy, int, 0444);
62141ec0267Sriastradh MODULE_PARM_DESC(sched_policy,
62241ec0267Sriastradh 	"Scheduling policy (0 = HWS (Default), 1 = HWS without over-subscription, 2 = Non-HWS (Used for debugging only)");
62341ec0267Sriastradh 
62441ec0267Sriastradh /**
62541ec0267Sriastradh  * DOC: hws_max_conc_proc (int)
62641ec0267Sriastradh  * Maximum number of processes that HWS can schedule concurrently. The maximum is the
62741ec0267Sriastradh  * number of VMIDs assigned to the HWS, which is also the default.
62841ec0267Sriastradh  */
62941ec0267Sriastradh int hws_max_conc_proc = 8;
63041ec0267Sriastradh module_param(hws_max_conc_proc, int, 0444);
63141ec0267Sriastradh MODULE_PARM_DESC(hws_max_conc_proc,
63241ec0267Sriastradh 	"Max # processes HWS can execute concurrently when sched_policy=0 (0 = no concurrency, #VMIDs for KFD = Maximum(default))");
63341ec0267Sriastradh 
63441ec0267Sriastradh /**
63541ec0267Sriastradh  * DOC: cwsr_enable (int)
63641ec0267Sriastradh  * CWSR(compute wave store and resume) allows the GPU to preempt shader execution in
63741ec0267Sriastradh  * the middle of a compute wave. Default is 1 to enable this feature. Setting 0
63841ec0267Sriastradh  * disables it.
63941ec0267Sriastradh  */
64041ec0267Sriastradh int cwsr_enable = 1;
64141ec0267Sriastradh module_param(cwsr_enable, int, 0444);
64241ec0267Sriastradh MODULE_PARM_DESC(cwsr_enable, "CWSR enable (0 = Off, 1 = On (Default))");
64341ec0267Sriastradh 
64441ec0267Sriastradh /**
64541ec0267Sriastradh  * DOC: max_num_of_queues_per_device (int)
64641ec0267Sriastradh  * Maximum number of queues per device. Valid setting is between 1 and 4096. Default
64741ec0267Sriastradh  * is 4096.
64841ec0267Sriastradh  */
64941ec0267Sriastradh int max_num_of_queues_per_device = KFD_MAX_NUM_OF_QUEUES_PER_DEVICE_DEFAULT;
65041ec0267Sriastradh module_param(max_num_of_queues_per_device, int, 0444);
65141ec0267Sriastradh MODULE_PARM_DESC(max_num_of_queues_per_device,
65241ec0267Sriastradh 	"Maximum number of supported queues per device (1 = Minimum, 4096 = default)");
65341ec0267Sriastradh 
65441ec0267Sriastradh /**
65541ec0267Sriastradh  * DOC: send_sigterm (int)
65641ec0267Sriastradh  * Send sigterm to HSA process on unhandled exceptions. Default is not to send sigterm
65741ec0267Sriastradh  * but just print errors on dmesg. Setting 1 enables sending sigterm.
65841ec0267Sriastradh  */
65941ec0267Sriastradh int send_sigterm;
66041ec0267Sriastradh module_param(send_sigterm, int, 0444);
66141ec0267Sriastradh MODULE_PARM_DESC(send_sigterm,
66241ec0267Sriastradh 	"Send sigterm to HSA process on unhandled exception (0 = disable, 1 = enable)");
66341ec0267Sriastradh 
66441ec0267Sriastradh /**
66541ec0267Sriastradh  * DOC: debug_largebar (int)
66641ec0267Sriastradh  * Set debug_largebar as 1 to enable simulating large-bar capability on non-large bar
66741ec0267Sriastradh  * system. This limits the VRAM size reported to ROCm applications to the visible
66841ec0267Sriastradh  * size, usually 256MB.
66941ec0267Sriastradh  * Default value is 0, diabled.
67041ec0267Sriastradh  */
67141ec0267Sriastradh int debug_largebar;
67241ec0267Sriastradh module_param(debug_largebar, int, 0444);
67341ec0267Sriastradh MODULE_PARM_DESC(debug_largebar,
67441ec0267Sriastradh 	"Debug large-bar flag used to simulate large-bar capability on non-large bar machine (0 = disable, 1 = enable)");
67541ec0267Sriastradh 
67641ec0267Sriastradh /**
67741ec0267Sriastradh  * DOC: ignore_crat (int)
67841ec0267Sriastradh  * Ignore CRAT table during KFD initialization. By default, KFD uses the ACPI CRAT
67941ec0267Sriastradh  * table to get information about AMD APUs. This option can serve as a workaround on
68041ec0267Sriastradh  * systems with a broken CRAT table.
68141ec0267Sriastradh  */
68241ec0267Sriastradh int ignore_crat;
68341ec0267Sriastradh module_param(ignore_crat, int, 0444);
68441ec0267Sriastradh MODULE_PARM_DESC(ignore_crat,
68541ec0267Sriastradh 	"Ignore CRAT table during KFD initialization (0 = use CRAT (default), 1 = ignore CRAT)");
68641ec0267Sriastradh 
68741ec0267Sriastradh /**
68841ec0267Sriastradh  * DOC: halt_if_hws_hang (int)
68941ec0267Sriastradh  * Halt if HWS hang is detected. Default value, 0, disables the halt on hang.
69041ec0267Sriastradh  * Setting 1 enables halt on hang.
69141ec0267Sriastradh  */
69241ec0267Sriastradh int halt_if_hws_hang;
69341ec0267Sriastradh module_param(halt_if_hws_hang, int, 0644);
69441ec0267Sriastradh MODULE_PARM_DESC(halt_if_hws_hang, "Halt if HWS hang is detected (0 = off (default), 1 = on)");
69541ec0267Sriastradh 
69641ec0267Sriastradh /**
69741ec0267Sriastradh  * DOC: hws_gws_support(bool)
69841ec0267Sriastradh  * Whether HWS support gws barriers. Default value: false (not supported)
69941ec0267Sriastradh  * This will be replaced with a MEC firmware version check once firmware
70041ec0267Sriastradh  * is ready
70141ec0267Sriastradh  */
70241ec0267Sriastradh bool hws_gws_support;
70341ec0267Sriastradh module_param(hws_gws_support, bool, 0444);
70441ec0267Sriastradh MODULE_PARM_DESC(hws_gws_support, "MEC FW support gws barriers (false = not supported (Default), true = supported)");
70541ec0267Sriastradh 
70641ec0267Sriastradh /**
70741ec0267Sriastradh   * DOC: queue_preemption_timeout_ms (int)
70841ec0267Sriastradh   * queue preemption timeout in ms (1 = Minimum, 9000 = default)
70941ec0267Sriastradh   */
71041ec0267Sriastradh int queue_preemption_timeout_ms = 9000;
71141ec0267Sriastradh module_param(queue_preemption_timeout_ms, int, 0644);
71241ec0267Sriastradh MODULE_PARM_DESC(queue_preemption_timeout_ms, "queue preemption timeout in ms (1 = Minimum, 9000 = default)");
71341ec0267Sriastradh #endif
71441ec0267Sriastradh 
71541ec0267Sriastradh /**
71641ec0267Sriastradh  * DOC: dcfeaturemask (uint)
71741ec0267Sriastradh  * Override display features enabled. See enum DC_FEATURE_MASK in drivers/gpu/drm/amd/include/amd_shared.h.
71841ec0267Sriastradh  * The default is the current set of stable display features.
71941ec0267Sriastradh  */
72041ec0267Sriastradh MODULE_PARM_DESC(dcfeaturemask, "all stable DC features enabled (default))");
72141ec0267Sriastradh module_param_named(dcfeaturemask, amdgpu_dc_feature_mask, uint, 0444);
72241ec0267Sriastradh 
72341ec0267Sriastradh /**
72441ec0267Sriastradh  * DOC: abmlevel (uint)
72541ec0267Sriastradh  * Override the default ABM (Adaptive Backlight Management) level used for DC
72641ec0267Sriastradh  * enabled hardware. Requires DMCU to be supported and loaded.
72741ec0267Sriastradh  * Valid levels are 0-4. A value of 0 indicates that ABM should be disabled by
72841ec0267Sriastradh  * default. Values 1-4 control the maximum allowable brightness reduction via
72941ec0267Sriastradh  * the ABM algorithm, with 1 being the least reduction and 4 being the most
73041ec0267Sriastradh  * reduction.
73141ec0267Sriastradh  *
73241ec0267Sriastradh  * Defaults to 0, or disabled. Userspace can still override this level later
73341ec0267Sriastradh  * after boot.
73441ec0267Sriastradh  */
73541ec0267Sriastradh uint amdgpu_dm_abm_level = 0;
73641ec0267Sriastradh MODULE_PARM_DESC(abmlevel, "ABM level (0 = off (default), 1-4 = backlight reduction level) ");
73741ec0267Sriastradh module_param_named(abmlevel, amdgpu_dm_abm_level, uint, 0444);
73841ec0267Sriastradh 
73941ec0267Sriastradh static const struct pci_device_id pciidlist[] = {
74041ec0267Sriastradh #ifdef  CONFIG_DRM_AMDGPU_SI
74141ec0267Sriastradh 	{0x1002, 0x6780, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
74241ec0267Sriastradh 	{0x1002, 0x6784, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
74341ec0267Sriastradh 	{0x1002, 0x6788, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
74441ec0267Sriastradh 	{0x1002, 0x678A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
74541ec0267Sriastradh 	{0x1002, 0x6790, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
74641ec0267Sriastradh 	{0x1002, 0x6791, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
74741ec0267Sriastradh 	{0x1002, 0x6792, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
74841ec0267Sriastradh 	{0x1002, 0x6798, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
74941ec0267Sriastradh 	{0x1002, 0x6799, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
75041ec0267Sriastradh 	{0x1002, 0x679A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
75141ec0267Sriastradh 	{0x1002, 0x679B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
75241ec0267Sriastradh 	{0x1002, 0x679E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
75341ec0267Sriastradh 	{0x1002, 0x679F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI},
75441ec0267Sriastradh 	{0x1002, 0x6800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|AMD_IS_MOBILITY},
75541ec0267Sriastradh 	{0x1002, 0x6801, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|AMD_IS_MOBILITY},
75641ec0267Sriastradh 	{0x1002, 0x6802, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|AMD_IS_MOBILITY},
75741ec0267Sriastradh 	{0x1002, 0x6806, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
75841ec0267Sriastradh 	{0x1002, 0x6808, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
75941ec0267Sriastradh 	{0x1002, 0x6809, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
76041ec0267Sriastradh 	{0x1002, 0x6810, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
76141ec0267Sriastradh 	{0x1002, 0x6811, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
76241ec0267Sriastradh 	{0x1002, 0x6816, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
76341ec0267Sriastradh 	{0x1002, 0x6817, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
76441ec0267Sriastradh 	{0x1002, 0x6818, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
76541ec0267Sriastradh 	{0x1002, 0x6819, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN},
76641ec0267Sriastradh 	{0x1002, 0x6600, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
76741ec0267Sriastradh 	{0x1002, 0x6601, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
76841ec0267Sriastradh 	{0x1002, 0x6602, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
76941ec0267Sriastradh 	{0x1002, 0x6603, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
77041ec0267Sriastradh 	{0x1002, 0x6604, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
77141ec0267Sriastradh 	{0x1002, 0x6605, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
77241ec0267Sriastradh 	{0x1002, 0x6606, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
77341ec0267Sriastradh 	{0x1002, 0x6607, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
77441ec0267Sriastradh 	{0x1002, 0x6608, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND},
77541ec0267Sriastradh 	{0x1002, 0x6610, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND},
77641ec0267Sriastradh 	{0x1002, 0x6611, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND},
77741ec0267Sriastradh 	{0x1002, 0x6613, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND},
77841ec0267Sriastradh 	{0x1002, 0x6617, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
77941ec0267Sriastradh 	{0x1002, 0x6620, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
78041ec0267Sriastradh 	{0x1002, 0x6621, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
78141ec0267Sriastradh 	{0x1002, 0x6623, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|AMD_IS_MOBILITY},
78241ec0267Sriastradh 	{0x1002, 0x6631, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND},
78341ec0267Sriastradh 	{0x1002, 0x6820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
78441ec0267Sriastradh 	{0x1002, 0x6821, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
78541ec0267Sriastradh 	{0x1002, 0x6822, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
78641ec0267Sriastradh 	{0x1002, 0x6823, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
78741ec0267Sriastradh 	{0x1002, 0x6824, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
78841ec0267Sriastradh 	{0x1002, 0x6825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
78941ec0267Sriastradh 	{0x1002, 0x6826, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
79041ec0267Sriastradh 	{0x1002, 0x6827, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
79141ec0267Sriastradh 	{0x1002, 0x6828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
79241ec0267Sriastradh 	{0x1002, 0x6829, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
79341ec0267Sriastradh 	{0x1002, 0x682A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
79441ec0267Sriastradh 	{0x1002, 0x682B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
79541ec0267Sriastradh 	{0x1002, 0x682C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
79641ec0267Sriastradh 	{0x1002, 0x682D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
79741ec0267Sriastradh 	{0x1002, 0x682F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
79841ec0267Sriastradh 	{0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
79941ec0267Sriastradh 	{0x1002, 0x6831, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|AMD_IS_MOBILITY},
80041ec0267Sriastradh 	{0x1002, 0x6835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
80141ec0267Sriastradh 	{0x1002, 0x6837, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
80241ec0267Sriastradh 	{0x1002, 0x6838, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
80341ec0267Sriastradh 	{0x1002, 0x6839, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
80441ec0267Sriastradh 	{0x1002, 0x683B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
80541ec0267Sriastradh 	{0x1002, 0x683D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
80641ec0267Sriastradh 	{0x1002, 0x683F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE},
80741ec0267Sriastradh 	{0x1002, 0x6660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
80841ec0267Sriastradh 	{0x1002, 0x6663, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
80941ec0267Sriastradh 	{0x1002, 0x6664, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
81041ec0267Sriastradh 	{0x1002, 0x6665, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
81141ec0267Sriastradh 	{0x1002, 0x6667, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
81241ec0267Sriastradh 	{0x1002, 0x666F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|AMD_IS_MOBILITY},
81341ec0267Sriastradh #endif
814efa246c0Sriastradh #ifdef CONFIG_DRM_AMDGPU_CIK
815efa246c0Sriastradh 	/* Kaveri */
816efa246c0Sriastradh 	{0x1002, 0x1304, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
817efa246c0Sriastradh 	{0x1002, 0x1305, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
818efa246c0Sriastradh 	{0x1002, 0x1306, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
819efa246c0Sriastradh 	{0x1002, 0x1307, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
820efa246c0Sriastradh 	{0x1002, 0x1309, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
821efa246c0Sriastradh 	{0x1002, 0x130A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
822efa246c0Sriastradh 	{0x1002, 0x130B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
823efa246c0Sriastradh 	{0x1002, 0x130C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
824efa246c0Sriastradh 	{0x1002, 0x130D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
825efa246c0Sriastradh 	{0x1002, 0x130E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
826efa246c0Sriastradh 	{0x1002, 0x130F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
827efa246c0Sriastradh 	{0x1002, 0x1310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
828efa246c0Sriastradh 	{0x1002, 0x1311, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
829efa246c0Sriastradh 	{0x1002, 0x1312, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
830efa246c0Sriastradh 	{0x1002, 0x1313, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
831efa246c0Sriastradh 	{0x1002, 0x1315, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
832efa246c0Sriastradh 	{0x1002, 0x1316, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
833efa246c0Sriastradh 	{0x1002, 0x1317, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
834efa246c0Sriastradh 	{0x1002, 0x1318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_MOBILITY|AMD_IS_APU},
835efa246c0Sriastradh 	{0x1002, 0x131B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
836efa246c0Sriastradh 	{0x1002, 0x131C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
837efa246c0Sriastradh 	{0x1002, 0x131D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|AMD_IS_APU},
838efa246c0Sriastradh 	/* Bonaire */
839efa246c0Sriastradh 	{0x1002, 0x6640, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|AMD_IS_MOBILITY},
840efa246c0Sriastradh 	{0x1002, 0x6641, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|AMD_IS_MOBILITY},
841efa246c0Sriastradh 	{0x1002, 0x6646, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|AMD_IS_MOBILITY},
842efa246c0Sriastradh 	{0x1002, 0x6647, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|AMD_IS_MOBILITY},
843efa246c0Sriastradh 	{0x1002, 0x6649, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
844efa246c0Sriastradh 	{0x1002, 0x6650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
845efa246c0Sriastradh 	{0x1002, 0x6651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
846efa246c0Sriastradh 	{0x1002, 0x6658, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
847efa246c0Sriastradh 	{0x1002, 0x665c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
848efa246c0Sriastradh 	{0x1002, 0x665d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
849efa246c0Sriastradh 	{0x1002, 0x665f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE},
850efa246c0Sriastradh 	/* Hawaii */
851efa246c0Sriastradh 	{0x1002, 0x67A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
852efa246c0Sriastradh 	{0x1002, 0x67A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
853efa246c0Sriastradh 	{0x1002, 0x67A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
854efa246c0Sriastradh 	{0x1002, 0x67A8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
855efa246c0Sriastradh 	{0x1002, 0x67A9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
856efa246c0Sriastradh 	{0x1002, 0x67AA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
857efa246c0Sriastradh 	{0x1002, 0x67B0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
858efa246c0Sriastradh 	{0x1002, 0x67B1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
859efa246c0Sriastradh 	{0x1002, 0x67B8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
860efa246c0Sriastradh 	{0x1002, 0x67B9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
861efa246c0Sriastradh 	{0x1002, 0x67BA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
862efa246c0Sriastradh 	{0x1002, 0x67BE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAWAII},
863efa246c0Sriastradh 	/* Kabini */
864efa246c0Sriastradh 	{0x1002, 0x9830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
865efa246c0Sriastradh 	{0x1002, 0x9831, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
866efa246c0Sriastradh 	{0x1002, 0x9832, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
867efa246c0Sriastradh 	{0x1002, 0x9833, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
868efa246c0Sriastradh 	{0x1002, 0x9834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
869efa246c0Sriastradh 	{0x1002, 0x9835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
870efa246c0Sriastradh 	{0x1002, 0x9836, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
871efa246c0Sriastradh 	{0x1002, 0x9837, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
872efa246c0Sriastradh 	{0x1002, 0x9838, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
873efa246c0Sriastradh 	{0x1002, 0x9839, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
874efa246c0Sriastradh 	{0x1002, 0x983a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
875efa246c0Sriastradh 	{0x1002, 0x983b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_MOBILITY|AMD_IS_APU},
876efa246c0Sriastradh 	{0x1002, 0x983c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
877efa246c0Sriastradh 	{0x1002, 0x983d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
878efa246c0Sriastradh 	{0x1002, 0x983e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
879efa246c0Sriastradh 	{0x1002, 0x983f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KABINI|AMD_IS_APU},
880efa246c0Sriastradh 	/* mullins */
881efa246c0Sriastradh 	{0x1002, 0x9850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
882efa246c0Sriastradh 	{0x1002, 0x9851, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
883efa246c0Sriastradh 	{0x1002, 0x9852, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
884efa246c0Sriastradh 	{0x1002, 0x9853, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
885efa246c0Sriastradh 	{0x1002, 0x9854, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
886efa246c0Sriastradh 	{0x1002, 0x9855, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
887efa246c0Sriastradh 	{0x1002, 0x9856, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
888efa246c0Sriastradh 	{0x1002, 0x9857, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
889efa246c0Sriastradh 	{0x1002, 0x9858, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
890efa246c0Sriastradh 	{0x1002, 0x9859, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
891efa246c0Sriastradh 	{0x1002, 0x985A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
892efa246c0Sriastradh 	{0x1002, 0x985B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
893efa246c0Sriastradh 	{0x1002, 0x985C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
894efa246c0Sriastradh 	{0x1002, 0x985D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
895efa246c0Sriastradh 	{0x1002, 0x985E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
896efa246c0Sriastradh 	{0x1002, 0x985F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MULLINS|AMD_IS_MOBILITY|AMD_IS_APU},
897efa246c0Sriastradh #endif
898efa246c0Sriastradh 	/* topaz */
899efa246c0Sriastradh 	{0x1002, 0x6900, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
900efa246c0Sriastradh 	{0x1002, 0x6901, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
901efa246c0Sriastradh 	{0x1002, 0x6902, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
902efa246c0Sriastradh 	{0x1002, 0x6903, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
903efa246c0Sriastradh 	{0x1002, 0x6907, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TOPAZ},
904efa246c0Sriastradh 	/* tonga */
905efa246c0Sriastradh 	{0x1002, 0x6920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
906efa246c0Sriastradh 	{0x1002, 0x6921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
907efa246c0Sriastradh 	{0x1002, 0x6928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
908efa246c0Sriastradh 	{0x1002, 0x6929, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
909efa246c0Sriastradh 	{0x1002, 0x692B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
910efa246c0Sriastradh 	{0x1002, 0x692F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
911efa246c0Sriastradh 	{0x1002, 0x6930, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
912efa246c0Sriastradh 	{0x1002, 0x6938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
913efa246c0Sriastradh 	{0x1002, 0x6939, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TONGA},
914efa246c0Sriastradh 	/* fiji */
915efa246c0Sriastradh 	{0x1002, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI},
91641ec0267Sriastradh 	{0x1002, 0x730F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_FIJI},
917efa246c0Sriastradh 	/* carrizo */
918efa246c0Sriastradh 	{0x1002, 0x9870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
919efa246c0Sriastradh 	{0x1002, 0x9874, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
920efa246c0Sriastradh 	{0x1002, 0x9875, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
921efa246c0Sriastradh 	{0x1002, 0x9876, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
922efa246c0Sriastradh 	{0x1002, 0x9877, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CARRIZO|AMD_IS_APU},
923efa246c0Sriastradh 	/* stoney */
924efa246c0Sriastradh 	{0x1002, 0x98E4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_STONEY|AMD_IS_APU},
92541ec0267Sriastradh 	/* Polaris11 */
92641ec0267Sriastradh 	{0x1002, 0x67E0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
92741ec0267Sriastradh 	{0x1002, 0x67E3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
92841ec0267Sriastradh 	{0x1002, 0x67E8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
92941ec0267Sriastradh 	{0x1002, 0x67EB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
93041ec0267Sriastradh 	{0x1002, 0x67EF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
93141ec0267Sriastradh 	{0x1002, 0x67FF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
93241ec0267Sriastradh 	{0x1002, 0x67E1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
93341ec0267Sriastradh 	{0x1002, 0x67E7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
93441ec0267Sriastradh 	{0x1002, 0x67E9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
93541ec0267Sriastradh 	/* Polaris10 */
93641ec0267Sriastradh 	{0x1002, 0x67C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
93741ec0267Sriastradh 	{0x1002, 0x67C1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
93841ec0267Sriastradh 	{0x1002, 0x67C2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
93941ec0267Sriastradh 	{0x1002, 0x67C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
94041ec0267Sriastradh 	{0x1002, 0x67C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
94141ec0267Sriastradh 	{0x1002, 0x67D0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
94241ec0267Sriastradh 	{0x1002, 0x67DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
94341ec0267Sriastradh 	{0x1002, 0x67C8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
94441ec0267Sriastradh 	{0x1002, 0x67C9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
94541ec0267Sriastradh 	{0x1002, 0x67CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
94641ec0267Sriastradh 	{0x1002, 0x67CC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
94741ec0267Sriastradh 	{0x1002, 0x67CF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
94841ec0267Sriastradh 	{0x1002, 0x6FDF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
94941ec0267Sriastradh 	/* Polaris12 */
95041ec0267Sriastradh 	{0x1002, 0x6980, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
95141ec0267Sriastradh 	{0x1002, 0x6981, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
95241ec0267Sriastradh 	{0x1002, 0x6985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
95341ec0267Sriastradh 	{0x1002, 0x6986, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
95441ec0267Sriastradh 	{0x1002, 0x6987, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
95541ec0267Sriastradh 	{0x1002, 0x6995, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
95641ec0267Sriastradh 	{0x1002, 0x6997, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
95741ec0267Sriastradh 	{0x1002, 0x699F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},
95841ec0267Sriastradh 	/* VEGAM */
95941ec0267Sriastradh 	{0x1002, 0x694C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGAM},
96041ec0267Sriastradh 	{0x1002, 0x694E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGAM},
96141ec0267Sriastradh 	{0x1002, 0x694F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGAM},
96241ec0267Sriastradh 	/* Vega 10 */
96341ec0267Sriastradh 	{0x1002, 0x6860, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
96441ec0267Sriastradh 	{0x1002, 0x6861, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
96541ec0267Sriastradh 	{0x1002, 0x6862, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
96641ec0267Sriastradh 	{0x1002, 0x6863, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
96741ec0267Sriastradh 	{0x1002, 0x6864, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
96841ec0267Sriastradh 	{0x1002, 0x6867, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
96941ec0267Sriastradh 	{0x1002, 0x6868, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
97041ec0267Sriastradh 	{0x1002, 0x6869, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
97141ec0267Sriastradh 	{0x1002, 0x686a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
97241ec0267Sriastradh 	{0x1002, 0x686b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
97341ec0267Sriastradh 	{0x1002, 0x686c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
97441ec0267Sriastradh 	{0x1002, 0x686d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
97541ec0267Sriastradh 	{0x1002, 0x686e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
97641ec0267Sriastradh 	{0x1002, 0x686f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
97741ec0267Sriastradh 	{0x1002, 0x687f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10},
97841ec0267Sriastradh 	/* Vega 12 */
97941ec0267Sriastradh 	{0x1002, 0x69A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12},
98041ec0267Sriastradh 	{0x1002, 0x69A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12},
98141ec0267Sriastradh 	{0x1002, 0x69A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12},
98241ec0267Sriastradh 	{0x1002, 0x69A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12},
98341ec0267Sriastradh 	{0x1002, 0x69AF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA12},
98441ec0267Sriastradh 	/* Vega 20 */
98541ec0267Sriastradh 	{0x1002, 0x66A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20},
98641ec0267Sriastradh 	{0x1002, 0x66A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20},
98741ec0267Sriastradh 	{0x1002, 0x66A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20},
98841ec0267Sriastradh 	{0x1002, 0x66A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20},
98941ec0267Sriastradh 	{0x1002, 0x66A4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20},
99041ec0267Sriastradh 	{0x1002, 0x66A7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20},
99141ec0267Sriastradh 	{0x1002, 0x66AF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA20},
99241ec0267Sriastradh 	/* Raven */
99341ec0267Sriastradh 	{0x1002, 0x15dd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RAVEN|AMD_IS_APU},
99441ec0267Sriastradh 	{0x1002, 0x15d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RAVEN|AMD_IS_APU},
99541ec0267Sriastradh 	/* Arcturus */
99641ec0267Sriastradh 	{0x1002, 0x738C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARCTURUS|AMD_EXP_HW_SUPPORT},
99741ec0267Sriastradh 	{0x1002, 0x7388, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARCTURUS|AMD_EXP_HW_SUPPORT},
99841ec0267Sriastradh 	{0x1002, 0x738E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARCTURUS|AMD_EXP_HW_SUPPORT},
99941ec0267Sriastradh 	{0x1002, 0x7390, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARCTURUS|AMD_EXP_HW_SUPPORT},
100041ec0267Sriastradh 	/* Navi10 */
100141ec0267Sriastradh 	{0x1002, 0x7310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
100241ec0267Sriastradh 	{0x1002, 0x7312, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
100341ec0267Sriastradh 	{0x1002, 0x7318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
100441ec0267Sriastradh 	{0x1002, 0x7319, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
100541ec0267Sriastradh 	{0x1002, 0x731A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
100641ec0267Sriastradh 	{0x1002, 0x731B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
100741ec0267Sriastradh 	{0x1002, 0x731F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
100841ec0267Sriastradh 	/* Navi14 */
100941ec0267Sriastradh 	{0x1002, 0x7340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14},
101041ec0267Sriastradh 	{0x1002, 0x7341, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14},
101141ec0267Sriastradh 	{0x1002, 0x7347, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14},
101241ec0267Sriastradh 	{0x1002, 0x734F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14},
101341ec0267Sriastradh 
101441ec0267Sriastradh 	/* Renoir */
101541ec0267Sriastradh 	{0x1002, 0x1636, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RENOIR|AMD_IS_APU},
101641ec0267Sriastradh 
101741ec0267Sriastradh 	/* Navi12 */
101841ec0267Sriastradh 	{0x1002, 0x7360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI12|AMD_EXP_HW_SUPPORT},
101941ec0267Sriastradh 	{0x1002, 0x7362, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI12|AMD_EXP_HW_SUPPORT},
1020efa246c0Sriastradh 
1021efa246c0Sriastradh 	{0, 0, 0}
1022efa246c0Sriastradh };
1023efa246c0Sriastradh 
1024efa246c0Sriastradh MODULE_DEVICE_TABLE(pci, pciidlist);
1025efa246c0Sriastradh 
1026efa246c0Sriastradh static struct drm_driver kms_driver;
1027efa246c0Sriastradh 
10280d50c49dSriastradh #ifndef __NetBSD__
amdgpu_pci_probe(struct pci_dev * pdev,const struct pci_device_id * ent)1029efa246c0Sriastradh static int amdgpu_pci_probe(struct pci_dev *pdev,
1030efa246c0Sriastradh 			    const struct pci_device_id *ent)
1031efa246c0Sriastradh {
103241ec0267Sriastradh 	struct drm_device *dev;
1033efa246c0Sriastradh 	unsigned long flags = ent->driver_data;
103441ec0267Sriastradh 	int ret, retry = 0;
103541ec0267Sriastradh 	bool supports_atomic = false;
103641ec0267Sriastradh 
103741ec0267Sriastradh 	if (!amdgpu_virtual_display &&
103841ec0267Sriastradh 	    amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK))
103941ec0267Sriastradh 		supports_atomic = true;
1040efa246c0Sriastradh 
1041efa246c0Sriastradh 	if ((flags & AMD_EXP_HW_SUPPORT) && !amdgpu_exp_hw_support) {
1042efa246c0Sriastradh 		DRM_INFO("This hardware requires experimental hardware support.\n"
1043efa246c0Sriastradh 			 "See modparam exp_hw_support\n");
1044efa246c0Sriastradh 		return -ENODEV;
1045efa246c0Sriastradh 	}
1046efa246c0Sriastradh 
104741ec0267Sriastradh #ifdef CONFIG_DRM_AMDGPU_SI
104841ec0267Sriastradh 	if (!amdgpu_si_support) {
104941ec0267Sriastradh 		switch (flags & AMD_ASIC_MASK) {
105041ec0267Sriastradh 		case CHIP_TAHITI:
105141ec0267Sriastradh 		case CHIP_PITCAIRN:
105241ec0267Sriastradh 		case CHIP_VERDE:
105341ec0267Sriastradh 		case CHIP_OLAND:
105441ec0267Sriastradh 		case CHIP_HAINAN:
105541ec0267Sriastradh 			dev_info(&pdev->dev,
105641ec0267Sriastradh 				 "SI support provided by radeon.\n");
105741ec0267Sriastradh 			dev_info(&pdev->dev,
105841ec0267Sriastradh 				 "Use radeon.si_support=0 amdgpu.si_support=1 to override.\n"
105941ec0267Sriastradh 				);
106041ec0267Sriastradh 			return -ENODEV;
106141ec0267Sriastradh 		}
106241ec0267Sriastradh 	}
106341ec0267Sriastradh #endif
106441ec0267Sriastradh #ifdef CONFIG_DRM_AMDGPU_CIK
106541ec0267Sriastradh 	if (!amdgpu_cik_support) {
106641ec0267Sriastradh 		switch (flags & AMD_ASIC_MASK) {
106741ec0267Sriastradh 		case CHIP_KAVERI:
106841ec0267Sriastradh 		case CHIP_BONAIRE:
106941ec0267Sriastradh 		case CHIP_HAWAII:
107041ec0267Sriastradh 		case CHIP_KABINI:
107141ec0267Sriastradh 		case CHIP_MULLINS:
107241ec0267Sriastradh 			dev_info(&pdev->dev,
107341ec0267Sriastradh 				 "CIK support provided by radeon.\n");
107441ec0267Sriastradh 			dev_info(&pdev->dev,
107541ec0267Sriastradh 				 "Use radeon.cik_support=0 amdgpu.cik_support=1 to override.\n"
107641ec0267Sriastradh 				);
107741ec0267Sriastradh 			return -ENODEV;
107841ec0267Sriastradh 		}
107941ec0267Sriastradh 	}
108041ec0267Sriastradh #endif
108141ec0267Sriastradh 
1082efa246c0Sriastradh 	/* Get rid of things like offb */
108341ec0267Sriastradh 	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "amdgpudrmfb");
1084efa246c0Sriastradh 	if (ret)
1085efa246c0Sriastradh 		return ret;
1086efa246c0Sriastradh 
108741ec0267Sriastradh 	dev = drm_dev_alloc(&kms_driver, &pdev->dev);
108841ec0267Sriastradh 	if (IS_ERR(dev))
108941ec0267Sriastradh 		return PTR_ERR(dev);
109041ec0267Sriastradh 
109141ec0267Sriastradh 	if (!supports_atomic)
109241ec0267Sriastradh 		dev->driver_features &= ~DRIVER_ATOMIC;
109341ec0267Sriastradh 
109441ec0267Sriastradh 	ret = pci_enable_device(pdev);
109541ec0267Sriastradh 	if (ret)
109641ec0267Sriastradh 		goto err_free;
109741ec0267Sriastradh 
109841ec0267Sriastradh 	dev->pdev = pdev;
109941ec0267Sriastradh 
110041ec0267Sriastradh 	pci_set_drvdata(pdev, dev);
110141ec0267Sriastradh 
110241ec0267Sriastradh retry_init:
110341ec0267Sriastradh 	ret = drm_dev_register(dev, ent->driver_data);
110441ec0267Sriastradh 	if (ret == -EAGAIN && ++retry <= 3) {
110541ec0267Sriastradh 		DRM_INFO("retry init %d\n", retry);
110641ec0267Sriastradh 		/* Don't request EX mode too frequently which is attacking */
110741ec0267Sriastradh 		msleep(5000);
110841ec0267Sriastradh 		goto retry_init;
110941ec0267Sriastradh 	} else if (ret)
111041ec0267Sriastradh 		goto err_pci;
111141ec0267Sriastradh 
111241ec0267Sriastradh 	return 0;
111341ec0267Sriastradh 
111441ec0267Sriastradh err_pci:
111541ec0267Sriastradh 	pci_disable_device(pdev);
111641ec0267Sriastradh err_free:
111741ec0267Sriastradh 	drm_dev_put(dev);
111841ec0267Sriastradh 	return ret;
1119efa246c0Sriastradh }
1120efa246c0Sriastradh 
1121efa246c0Sriastradh static void
amdgpu_pci_remove(struct pci_dev * pdev)1122efa246c0Sriastradh amdgpu_pci_remove(struct pci_dev *pdev)
1123efa246c0Sriastradh {
1124efa246c0Sriastradh 	struct drm_device *dev = pci_get_drvdata(pdev);
1125efa246c0Sriastradh 
112641ec0267Sriastradh #ifdef MODULE
112741ec0267Sriastradh 	if (THIS_MODULE->state != MODULE_STATE_GOING)
112841ec0267Sriastradh #endif
112941ec0267Sriastradh 		DRM_ERROR("Hotplug removal is not supported\n");
113041ec0267Sriastradh 	drm_dev_unplug(dev);
113141ec0267Sriastradh 	drm_dev_put(dev);
113241ec0267Sriastradh 	pci_disable_device(pdev);
113341ec0267Sriastradh 	pci_set_drvdata(pdev, NULL);
113441ec0267Sriastradh }
113541ec0267Sriastradh 
113641ec0267Sriastradh static void
amdgpu_pci_shutdown(struct pci_dev * pdev)113741ec0267Sriastradh amdgpu_pci_shutdown(struct pci_dev *pdev)
113841ec0267Sriastradh {
113941ec0267Sriastradh 	struct drm_device *dev = pci_get_drvdata(pdev);
114041ec0267Sriastradh 	struct amdgpu_device *adev = dev->dev_private;
114141ec0267Sriastradh 
114241ec0267Sriastradh 	if (amdgpu_ras_intr_triggered())
114341ec0267Sriastradh 		return;
114441ec0267Sriastradh 
114541ec0267Sriastradh 	/* if we are running in a VM, make sure the device
114641ec0267Sriastradh 	 * torn down properly on reboot/shutdown.
114741ec0267Sriastradh 	 * unfortunately we can't detect certain
114841ec0267Sriastradh 	 * hypervisors so just do this all the time.
114941ec0267Sriastradh 	 */
115041ec0267Sriastradh 	adev->mp1_state = PP_MP1_STATE_UNLOAD;
115141ec0267Sriastradh 	amdgpu_device_ip_suspend(adev);
115241ec0267Sriastradh 	adev->mp1_state = PP_MP1_STATE_NONE;
1153efa246c0Sriastradh }
1154efa246c0Sriastradh 
amdgpu_pmops_suspend(struct device * dev)1155efa246c0Sriastradh static int amdgpu_pmops_suspend(struct device *dev)
1156efa246c0Sriastradh {
115741ec0267Sriastradh 	struct drm_device *drm_dev = dev_get_drvdata(dev);
115841ec0267Sriastradh 
115941ec0267Sriastradh 	return amdgpu_device_suspend(drm_dev, true);
1160efa246c0Sriastradh }
1161efa246c0Sriastradh 
amdgpu_pmops_resume(struct device * dev)1162efa246c0Sriastradh static int amdgpu_pmops_resume(struct device *dev)
1163efa246c0Sriastradh {
116441ec0267Sriastradh 	struct drm_device *drm_dev = dev_get_drvdata(dev);
116541ec0267Sriastradh 
116641ec0267Sriastradh 	/* GPU comes up enabled by the bios on resume */
116741ec0267Sriastradh 	if (amdgpu_device_supports_boco(drm_dev) ||
116841ec0267Sriastradh 	    amdgpu_device_supports_baco(drm_dev)) {
116941ec0267Sriastradh 		pm_runtime_disable(dev);
117041ec0267Sriastradh 		pm_runtime_set_active(dev);
117141ec0267Sriastradh 		pm_runtime_enable(dev);
117241ec0267Sriastradh 	}
117341ec0267Sriastradh 
117441ec0267Sriastradh 	return amdgpu_device_resume(drm_dev, true);
1175efa246c0Sriastradh }
1176efa246c0Sriastradh 
amdgpu_pmops_freeze(struct device * dev)1177efa246c0Sriastradh static int amdgpu_pmops_freeze(struct device *dev)
1178efa246c0Sriastradh {
117941ec0267Sriastradh 	struct drm_device *drm_dev = dev_get_drvdata(dev);
118041ec0267Sriastradh 	struct amdgpu_device *adev = drm_dev->dev_private;
118141ec0267Sriastradh 	int r;
118241ec0267Sriastradh 
118341ec0267Sriastradh 	r = amdgpu_device_suspend(drm_dev, true);
118441ec0267Sriastradh 	if (r)
118541ec0267Sriastradh 		return r;
118641ec0267Sriastradh 	return amdgpu_asic_reset(adev);
1187efa246c0Sriastradh }
1188efa246c0Sriastradh 
amdgpu_pmops_thaw(struct device * dev)1189efa246c0Sriastradh static int amdgpu_pmops_thaw(struct device *dev)
1190efa246c0Sriastradh {
119141ec0267Sriastradh 	struct drm_device *drm_dev = dev_get_drvdata(dev);
119241ec0267Sriastradh 
119341ec0267Sriastradh 	return amdgpu_device_resume(drm_dev, true);
119441ec0267Sriastradh }
119541ec0267Sriastradh 
amdgpu_pmops_poweroff(struct device * dev)119641ec0267Sriastradh static int amdgpu_pmops_poweroff(struct device *dev)
119741ec0267Sriastradh {
119841ec0267Sriastradh 	struct drm_device *drm_dev = dev_get_drvdata(dev);
119941ec0267Sriastradh 
120041ec0267Sriastradh 	return amdgpu_device_suspend(drm_dev, true);
120141ec0267Sriastradh }
120241ec0267Sriastradh 
amdgpu_pmops_restore(struct device * dev)120341ec0267Sriastradh static int amdgpu_pmops_restore(struct device *dev)
120441ec0267Sriastradh {
120541ec0267Sriastradh 	struct drm_device *drm_dev = dev_get_drvdata(dev);
120641ec0267Sriastradh 
120741ec0267Sriastradh 	return amdgpu_device_resume(drm_dev, true);
1208efa246c0Sriastradh }
1209efa246c0Sriastradh 
amdgpu_pmops_runtime_suspend(struct device * dev)1210efa246c0Sriastradh static int amdgpu_pmops_runtime_suspend(struct device *dev)
1211efa246c0Sriastradh {
1212efa246c0Sriastradh 	struct pci_dev *pdev = to_pci_dev(dev);
1213efa246c0Sriastradh 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
121441ec0267Sriastradh 	struct amdgpu_device *adev = drm_dev->dev_private;
121541ec0267Sriastradh 	int ret, i;
1216efa246c0Sriastradh 
121741ec0267Sriastradh 	if (!adev->runpm) {
1218efa246c0Sriastradh 		pm_runtime_forbid(dev);
1219efa246c0Sriastradh 		return -EBUSY;
1220efa246c0Sriastradh 	}
1221efa246c0Sriastradh 
122241ec0267Sriastradh 	/* wait for all rings to drain before suspending */
122341ec0267Sriastradh 	for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
122441ec0267Sriastradh 		struct amdgpu_ring *ring = adev->rings[i];
122541ec0267Sriastradh 		if (ring && ring->sched.ready) {
122641ec0267Sriastradh 			ret = amdgpu_fence_wait_empty(ring);
122741ec0267Sriastradh 			if (ret)
122841ec0267Sriastradh 				return -EBUSY;
122941ec0267Sriastradh 		}
123041ec0267Sriastradh 	}
123141ec0267Sriastradh 
123241ec0267Sriastradh 	if (amdgpu_device_supports_boco(drm_dev))
1233efa246c0Sriastradh 		drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
1234efa246c0Sriastradh 	drm_kms_helper_poll_disable(drm_dev);
1235efa246c0Sriastradh 
123641ec0267Sriastradh 	ret = amdgpu_device_suspend(drm_dev, false);
123741ec0267Sriastradh 	if (amdgpu_device_supports_boco(drm_dev)) {
123841ec0267Sriastradh 		/* Only need to handle PCI state in the driver for ATPX
123941ec0267Sriastradh 		 * PCI core handles it for _PR3.
124041ec0267Sriastradh 		 */
124141ec0267Sriastradh 		if (amdgpu_is_atpx_hybrid()) {
124241ec0267Sriastradh 			pci_ignore_hotplug(pdev);
124341ec0267Sriastradh 		} else {
1244efa246c0Sriastradh 			pci_save_state(pdev);
1245efa246c0Sriastradh 			pci_disable_device(pdev);
1246efa246c0Sriastradh 			pci_ignore_hotplug(pdev);
1247efa246c0Sriastradh 			pci_set_power_state(pdev, PCI_D3cold);
124841ec0267Sriastradh 		}
1249efa246c0Sriastradh 		drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
125041ec0267Sriastradh 	} else if (amdgpu_device_supports_baco(drm_dev)) {
125141ec0267Sriastradh 		amdgpu_device_baco_enter(drm_dev);
125241ec0267Sriastradh 	}
1253efa246c0Sriastradh 
1254efa246c0Sriastradh 	return 0;
1255efa246c0Sriastradh }
1256efa246c0Sriastradh 
amdgpu_pmops_runtime_resume(struct device * dev)1257efa246c0Sriastradh static int amdgpu_pmops_runtime_resume(struct device *dev)
1258efa246c0Sriastradh {
1259efa246c0Sriastradh 	struct pci_dev *pdev = to_pci_dev(dev);
1260efa246c0Sriastradh 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
126141ec0267Sriastradh 	struct amdgpu_device *adev = drm_dev->dev_private;
1262efa246c0Sriastradh 	int ret;
1263efa246c0Sriastradh 
126441ec0267Sriastradh 	if (!adev->runpm)
1265efa246c0Sriastradh 		return -EINVAL;
1266efa246c0Sriastradh 
126741ec0267Sriastradh 	if (amdgpu_device_supports_boco(drm_dev)) {
1268efa246c0Sriastradh 		drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
1269efa246c0Sriastradh 
127041ec0267Sriastradh 		/* Only need to handle PCI state in the driver for ATPX
127141ec0267Sriastradh 		 * PCI core handles it for _PR3.
127241ec0267Sriastradh 		 */
127341ec0267Sriastradh 		if (amdgpu_is_atpx_hybrid()) {
127441ec0267Sriastradh 			pci_set_master(pdev);
127541ec0267Sriastradh 		} else {
1276efa246c0Sriastradh 			pci_set_power_state(pdev, PCI_D0);
1277efa246c0Sriastradh 			pci_restore_state(pdev);
1278efa246c0Sriastradh 			ret = pci_enable_device(pdev);
1279efa246c0Sriastradh 			if (ret)
1280efa246c0Sriastradh 				return ret;
1281efa246c0Sriastradh 			pci_set_master(pdev);
128241ec0267Sriastradh 		}
128341ec0267Sriastradh 	} else if (amdgpu_device_supports_baco(drm_dev)) {
128441ec0267Sriastradh 		amdgpu_device_baco_exit(drm_dev);
128541ec0267Sriastradh 	}
128641ec0267Sriastradh 	ret = amdgpu_device_resume(drm_dev, false);
1287efa246c0Sriastradh 	drm_kms_helper_poll_enable(drm_dev);
128841ec0267Sriastradh 	if (amdgpu_device_supports_boco(drm_dev))
1289efa246c0Sriastradh 		drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
1290efa246c0Sriastradh 	return 0;
1291efa246c0Sriastradh }
1292efa246c0Sriastradh 
amdgpu_pmops_runtime_idle(struct device * dev)1293efa246c0Sriastradh static int amdgpu_pmops_runtime_idle(struct device *dev)
1294efa246c0Sriastradh {
129541ec0267Sriastradh 	struct drm_device *drm_dev = dev_get_drvdata(dev);
129641ec0267Sriastradh 	struct amdgpu_device *adev = drm_dev->dev_private;
1297efa246c0Sriastradh 	struct drm_crtc *crtc;
1298efa246c0Sriastradh 
129941ec0267Sriastradh 	if (!adev->runpm) {
1300efa246c0Sriastradh 		pm_runtime_forbid(dev);
1301efa246c0Sriastradh 		return -EBUSY;
1302efa246c0Sriastradh 	}
1303efa246c0Sriastradh 
1304efa246c0Sriastradh 	list_for_each_entry(crtc, &drm_dev->mode_config.crtc_list, head) {
1305efa246c0Sriastradh 		if (crtc->enabled) {
1306efa246c0Sriastradh 			DRM_DEBUG_DRIVER("failing to power off - crtc active\n");
1307efa246c0Sriastradh 			return -EBUSY;
1308efa246c0Sriastradh 		}
1309efa246c0Sriastradh 	}
1310efa246c0Sriastradh 
1311efa246c0Sriastradh 	pm_runtime_mark_last_busy(dev);
1312efa246c0Sriastradh 	pm_runtime_autosuspend(dev);
1313efa246c0Sriastradh 	/* we don't want the main rpm_idle to call suspend - we want to autosuspend */
1314efa246c0Sriastradh 	return 1;
1315efa246c0Sriastradh }
1316efa246c0Sriastradh 
amdgpu_drm_ioctl(struct file * filp,unsigned int cmd,unsigned long arg)1317efa246c0Sriastradh long amdgpu_drm_ioctl(struct file *filp,
1318efa246c0Sriastradh 		      unsigned int cmd, unsigned long arg)
1319efa246c0Sriastradh {
1320efa246c0Sriastradh 	struct drm_file *file_priv = filp->private_data;
1321efa246c0Sriastradh 	struct drm_device *dev;
1322efa246c0Sriastradh 	long ret;
1323efa246c0Sriastradh 	dev = file_priv->minor->dev;
1324efa246c0Sriastradh 	ret = pm_runtime_get_sync(dev->dev);
1325efa246c0Sriastradh 	if (ret < 0)
1326efa246c0Sriastradh 		return ret;
1327efa246c0Sriastradh 
1328efa246c0Sriastradh 	ret = drm_ioctl(filp, cmd, arg);
1329efa246c0Sriastradh 
1330efa246c0Sriastradh 	pm_runtime_mark_last_busy(dev->dev);
1331efa246c0Sriastradh 	pm_runtime_put_autosuspend(dev->dev);
1332efa246c0Sriastradh 	return ret;
1333efa246c0Sriastradh }
1334efa246c0Sriastradh 
1335efa246c0Sriastradh static const struct dev_pm_ops amdgpu_pm_ops = {
1336efa246c0Sriastradh 	.suspend = amdgpu_pmops_suspend,
1337efa246c0Sriastradh 	.resume = amdgpu_pmops_resume,
1338efa246c0Sriastradh 	.freeze = amdgpu_pmops_freeze,
1339efa246c0Sriastradh 	.thaw = amdgpu_pmops_thaw,
134041ec0267Sriastradh 	.poweroff = amdgpu_pmops_poweroff,
134141ec0267Sriastradh 	.restore = amdgpu_pmops_restore,
1342efa246c0Sriastradh 	.runtime_suspend = amdgpu_pmops_runtime_suspend,
1343efa246c0Sriastradh 	.runtime_resume = amdgpu_pmops_runtime_resume,
1344efa246c0Sriastradh 	.runtime_idle = amdgpu_pmops_runtime_idle,
1345efa246c0Sriastradh };
1346efa246c0Sriastradh 
amdgpu_flush(struct file * f,fl_owner_t id)134741ec0267Sriastradh static int amdgpu_flush(struct file *f, fl_owner_t id)
134841ec0267Sriastradh {
134941ec0267Sriastradh 	struct drm_file *file_priv = f->private_data;
135041ec0267Sriastradh 	struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
135141ec0267Sriastradh 	long timeout = MAX_WAIT_SCHED_ENTITY_Q_EMPTY;
135241ec0267Sriastradh 
135341ec0267Sriastradh 	timeout = amdgpu_ctx_mgr_entity_flush(&fpriv->ctx_mgr, timeout);
135441ec0267Sriastradh 	timeout = amdgpu_vm_wait_idle(&fpriv->vm, timeout);
135541ec0267Sriastradh 
135641ec0267Sriastradh 	return timeout >= 0 ? 0 : timeout;
135741ec0267Sriastradh }
135841ec0267Sriastradh 
1359efa246c0Sriastradh static const struct file_operations amdgpu_driver_kms_fops = {
1360efa246c0Sriastradh 	.owner = THIS_MODULE,
1361efa246c0Sriastradh 	.open = drm_open,
136241ec0267Sriastradh 	.flush = amdgpu_flush,
1363efa246c0Sriastradh 	.release = drm_release,
1364efa246c0Sriastradh 	.unlocked_ioctl = amdgpu_drm_ioctl,
1365efa246c0Sriastradh 	.mmap = amdgpu_mmap,
1366efa246c0Sriastradh 	.poll = drm_poll,
1367efa246c0Sriastradh 	.read = drm_read,
1368efa246c0Sriastradh #ifdef CONFIG_COMPAT
1369efa246c0Sriastradh 	.compat_ioctl = amdgpu_kms_compat_ioctl,
1370efa246c0Sriastradh #endif
1371efa246c0Sriastradh };
13720d50c49dSriastradh #endif	/* __NetBSD__ */
13730d50c49dSriastradh 
13740d50c49dSriastradh #ifdef __NetBSD__
13750d50c49dSriastradh /* XXX Kludge for the non-GEM GEM that amdgpu uses.  */
13760d50c49dSriastradh static const struct uvm_pagerops amdgpu_gem_uvm_ops;
13770d50c49dSriastradh #endif
13780d50c49dSriastradh 
amdgpu_file_to_fpriv(struct file * filp,struct amdgpu_fpriv ** fpriv)137941ec0267Sriastradh int amdgpu_file_to_fpriv(struct file *filp, struct amdgpu_fpriv **fpriv)
138041ec0267Sriastradh {
138141ec0267Sriastradh         struct drm_file *file;
138241ec0267Sriastradh 
138341ec0267Sriastradh 	if (!filp)
138441ec0267Sriastradh 		return -EINVAL;
138541ec0267Sriastradh 
1386*8f48ab4eSriastradh #ifdef __NetBSD__
1387*8f48ab4eSriastradh 	if (filp->f_ops != &drm_fileops)
1388*8f48ab4eSriastradh 		return -EINVAL;
1389*8f48ab4eSriastradh 	file = filp->f_data;
1390*8f48ab4eSriastradh 	if (file->minor->dev->driver != &kms_driver)
1391*8f48ab4eSriastradh 		return -EINVAL;
1392*8f48ab4eSriastradh #else
139341ec0267Sriastradh 	if (filp->f_op != &amdgpu_driver_kms_fops) {
139441ec0267Sriastradh 		return -EINVAL;
139541ec0267Sriastradh 	}
139641ec0267Sriastradh 
139741ec0267Sriastradh 	file = filp->private_data;
1398*8f48ab4eSriastradh #endif
139941ec0267Sriastradh 	*fpriv = file->driver_priv;
140041ec0267Sriastradh 	return 0;
140141ec0267Sriastradh }
140241ec0267Sriastradh 
140341ec0267Sriastradh static bool
amdgpu_get_crtc_scanout_position(struct drm_device * dev,unsigned int pipe,bool in_vblank_irq,int * vpos,int * hpos,ktime_t * stime,ktime_t * etime,const struct drm_display_mode * mode)140441ec0267Sriastradh amdgpu_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
140541ec0267Sriastradh 				 bool in_vblank_irq, int *vpos, int *hpos,
140641ec0267Sriastradh 				 ktime_t *stime, ktime_t *etime,
140741ec0267Sriastradh 				 const struct drm_display_mode *mode)
140841ec0267Sriastradh {
140941ec0267Sriastradh 	return amdgpu_display_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
141041ec0267Sriastradh 						  stime, etime, mode);
141141ec0267Sriastradh }
141241ec0267Sriastradh 
1413efa246c0Sriastradh static struct drm_driver kms_driver = {
1414efa246c0Sriastradh 	.driver_features =
141541ec0267Sriastradh 	    DRIVER_USE_AGP | DRIVER_ATOMIC |
141641ec0267Sriastradh 	    DRIVER_GEM |
141741ec0267Sriastradh 	    DRIVER_RENDER | DRIVER_MODESET | DRIVER_SYNCOBJ |
141841ec0267Sriastradh 	    DRIVER_SYNCOBJ_TIMELINE,
1419efa246c0Sriastradh 	.load = amdgpu_driver_load_kms,
1420efa246c0Sriastradh 	.open = amdgpu_driver_open_kms,
1421efa246c0Sriastradh 	.postclose = amdgpu_driver_postclose_kms,
1422efa246c0Sriastradh 	.lastclose = amdgpu_driver_lastclose_kms,
1423efa246c0Sriastradh 	.unload = amdgpu_driver_unload_kms,
1424efa246c0Sriastradh 	.get_vblank_counter = amdgpu_get_vblank_counter_kms,
1425efa246c0Sriastradh 	.enable_vblank = amdgpu_enable_vblank_kms,
1426efa246c0Sriastradh 	.disable_vblank = amdgpu_disable_vblank_kms,
142741ec0267Sriastradh 	.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
142841ec0267Sriastradh 	.get_scanout_position = amdgpu_get_crtc_scanout_position,
1429efa246c0Sriastradh 	.irq_handler = amdgpu_irq_handler,
143037ac6a77Sriastradh #ifdef __NetBSD__
143137ac6a77Sriastradh 	.request_irq = drm_pci_request_irq,
143237ac6a77Sriastradh 	.free_irq = drm_pci_free_irq,
143337ac6a77Sriastradh #endif
1434efa246c0Sriastradh 	.ioctls = amdgpu_ioctls_kms,
143541ec0267Sriastradh 	.gem_free_object_unlocked = amdgpu_gem_object_free,
1436efa246c0Sriastradh 	.gem_open_object = amdgpu_gem_object_open,
1437efa246c0Sriastradh 	.gem_close_object = amdgpu_gem_object_close,
1438efa246c0Sriastradh 	.dumb_create = amdgpu_mode_dumb_create,
1439efa246c0Sriastradh 	.dumb_map_offset = amdgpu_mode_dumb_mmap,
14400d50c49dSriastradh #ifdef __NetBSD__
14410d50c49dSriastradh 	.fops = NULL,
14420d50c49dSriastradh 	.mmap_object = &amdgpu_mmap_object,
14430d50c49dSriastradh 	.gem_uvm_ops = &amdgpu_gem_uvm_ops,
14440d50c49dSriastradh #else
1445efa246c0Sriastradh 	.fops = &amdgpu_driver_kms_fops,
14460d50c49dSriastradh #endif
1447efa246c0Sriastradh 
1448efa246c0Sriastradh 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
1449efa246c0Sriastradh 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
1450efa246c0Sriastradh 	.gem_prime_export = amdgpu_gem_prime_export,
145141ec0267Sriastradh 	.gem_prime_import = amdgpu_gem_prime_import,
1452efa246c0Sriastradh 	.gem_prime_vmap = amdgpu_gem_prime_vmap,
1453efa246c0Sriastradh 	.gem_prime_vunmap = amdgpu_gem_prime_vunmap,
145441ec0267Sriastradh 	.gem_prime_mmap = amdgpu_gem_prime_mmap,
1455efa246c0Sriastradh 
1456efa246c0Sriastradh 	.name = DRIVER_NAME,
1457efa246c0Sriastradh 	.desc = DRIVER_DESC,
1458efa246c0Sriastradh 	.date = DRIVER_DATE,
1459efa246c0Sriastradh 	.major = KMS_DRIVER_MAJOR,
1460efa246c0Sriastradh 	.minor = KMS_DRIVER_MINOR,
1461efa246c0Sriastradh 	.patchlevel = KMS_DRIVER_PATCHLEVEL,
1462efa246c0Sriastradh };
1463efa246c0Sriastradh 
14640d50c49dSriastradh #ifdef __NetBSD__
14650d50c49dSriastradh 
14660d50c49dSriastradh struct drm_driver *const amdgpu_drm_driver = &kms_driver;
14670d50c49dSriastradh const struct pci_device_id *const amdgpu_device_ids = pciidlist;
14680d50c49dSriastradh const size_t amdgpu_n_device_ids = __arraycount(pciidlist);
14690d50c49dSriastradh 
14700d50c49dSriastradh #else  /* __NetBSD__ */
14710d50c49dSriastradh 
1472efa246c0Sriastradh static struct pci_driver amdgpu_kms_pci_driver = {
1473efa246c0Sriastradh 	.name = DRIVER_NAME,
1474efa246c0Sriastradh 	.id_table = pciidlist,
1475efa246c0Sriastradh 	.probe = amdgpu_pci_probe,
1476efa246c0Sriastradh 	.remove = amdgpu_pci_remove,
147741ec0267Sriastradh 	.shutdown = amdgpu_pci_shutdown,
1478efa246c0Sriastradh 	.driver.pm = &amdgpu_pm_ops,
1479efa246c0Sriastradh };
1480efa246c0Sriastradh 
148141ec0267Sriastradh 
148241ec0267Sriastradh 
amdgpu_init(void)1483efa246c0Sriastradh static int __init amdgpu_init(void)
1484efa246c0Sriastradh {
148541ec0267Sriastradh 	int r;
148641ec0267Sriastradh 
1487efa246c0Sriastradh 	if (vgacon_text_force()) {
1488efa246c0Sriastradh 		DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n");
1489efa246c0Sriastradh 		return -EINVAL;
1490efa246c0Sriastradh 	}
149141ec0267Sriastradh 
149241ec0267Sriastradh 	r = amdgpu_sync_init();
149341ec0267Sriastradh 	if (r)
149441ec0267Sriastradh 		goto error_sync;
149541ec0267Sriastradh 
149641ec0267Sriastradh 	r = amdgpu_fence_slab_init();
149741ec0267Sriastradh 	if (r)
149841ec0267Sriastradh 		goto error_fence;
149941ec0267Sriastradh 
1500efa246c0Sriastradh 	DRM_INFO("amdgpu kernel modesetting enabled.\n");
150141ec0267Sriastradh 	kms_driver.num_ioctls = amdgpu_max_kms_ioctl;
1502efa246c0Sriastradh 	amdgpu_register_atpx_handler();
1503efa246c0Sriastradh 
150441ec0267Sriastradh 	/* Ignore KFD init failures. Normal when CONFIG_HSA_AMD is not set. */
1505efa246c0Sriastradh 	amdgpu_amdkfd_init();
1506efa246c0Sriastradh 
1507efa246c0Sriastradh 	/* let modprobe override vga console setting */
150841ec0267Sriastradh 	return pci_register_driver(&amdgpu_kms_pci_driver);
150941ec0267Sriastradh 
151041ec0267Sriastradh error_fence:
151141ec0267Sriastradh 	amdgpu_sync_fini();
151241ec0267Sriastradh 
151341ec0267Sriastradh error_sync:
151441ec0267Sriastradh 	return r;
1515efa246c0Sriastradh }
1516efa246c0Sriastradh 
amdgpu_exit(void)1517efa246c0Sriastradh static void __exit amdgpu_exit(void)
1518efa246c0Sriastradh {
1519efa246c0Sriastradh 	amdgpu_amdkfd_fini();
152041ec0267Sriastradh 	pci_unregister_driver(&amdgpu_kms_pci_driver);
1521efa246c0Sriastradh 	amdgpu_unregister_atpx_handler();
152241ec0267Sriastradh 	amdgpu_sync_fini();
152341ec0267Sriastradh 	amdgpu_fence_slab_fini();
152441ec0267Sriastradh 	mmu_notifier_synchronize();
1525efa246c0Sriastradh }
1526efa246c0Sriastradh 
1527efa246c0Sriastradh module_init(amdgpu_init);
1528efa246c0Sriastradh module_exit(amdgpu_exit);
1529efa246c0Sriastradh 
1530efa246c0Sriastradh MODULE_AUTHOR(DRIVER_AUTHOR);
1531efa246c0Sriastradh MODULE_DESCRIPTION(DRIVER_DESC);
1532efa246c0Sriastradh MODULE_LICENSE("GPL and additional rights");
15330d50c49dSriastradh 
15340d50c49dSriastradh #endif	/* __NetBSD__ */
1535