amdgpu_kms.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  1. /*
  2. * Copyright 2008 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Jerome Glisse.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Dave Airlie
  25. * Alex Deucher
  26. * Jerome Glisse
  27. */
  28. #include <drm/drmP.h>
  29. #include "amdgpu.h"
  30. #include <drm/amdgpu_drm.h>
  31. #include "amdgpu_uvd.h"
  32. #include "amdgpu_vce.h"
  33. #include <linux/vga_switcheroo.h>
  34. #include <linux/slab.h>
  35. #include <linux/pm_runtime.h>
  36. #include "amdgpu_amdkfd.h"
  37. #if defined(CONFIG_VGA_SWITCHEROO)
  38. bool amdgpu_has_atpx(void);
  39. #else
  40. static inline bool amdgpu_has_atpx(void) { return false; }
  41. #endif
  42. /**
  43. * amdgpu_driver_unload_kms - Main unload function for KMS.
  44. *
  45. * @dev: drm dev pointer
  46. *
  47. * This is the main unload function for KMS (all asics).
  48. * Returns 0 on success.
  49. */
  50. void amdgpu_driver_unload_kms(struct drm_device *dev)
  51. {
  52. struct amdgpu_device *adev = dev->dev_private;
  53. if (adev == NULL)
  54. return;
  55. if (adev->rmmio == NULL)
  56. goto done_free;
  57. if (amdgpu_sriov_vf(adev))
  58. amdgpu_virt_request_full_gpu(adev, false);
  59. if (amdgpu_device_is_px(dev)) {
  60. pm_runtime_get_sync(dev->dev);
  61. pm_runtime_forbid(dev->dev);
  62. }
  63. amdgpu_amdkfd_device_fini(adev);
  64. amdgpu_acpi_fini(adev);
  65. amdgpu_device_fini(adev);
  66. done_free:
  67. kfree(adev);
  68. dev->dev_private = NULL;
  69. }
  70. /**
  71. * amdgpu_driver_load_kms - Main load function for KMS.
  72. *
  73. * @dev: drm dev pointer
  74. * @flags: device flags
  75. *
  76. * This is the main load function for KMS (all asics).
  77. * Returns 0 on success, error on failure.
  78. */
  79. int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
  80. {
  81. struct amdgpu_device *adev;
  82. int r, acpi_status;
  83. adev = kzalloc(sizeof(struct amdgpu_device), GFP_KERNEL);
  84. if (adev == NULL) {
  85. return -ENOMEM;
  86. }
  87. dev->dev_private = (void *)adev;
  88. if ((amdgpu_runtime_pm != 0) &&
  89. amdgpu_has_atpx() &&
  90. (amdgpu_is_atpx_hybrid() ||
  91. amdgpu_has_atpx_dgpu_power_cntl()) &&
  92. ((flags & AMD_IS_APU) == 0))
  93. flags |= AMD_IS_PX;
  94. /* amdgpu_device_init should report only fatal error
  95. * like memory allocation failure or iomapping failure,
  96. * or memory manager initialization failure, it must
  97. * properly initialize the GPU MC controller and permit
  98. * VRAM allocation
  99. */
  100. r = amdgpu_device_init(adev, dev, dev->pdev, flags);
  101. if (r) {
  102. dev_err(&dev->pdev->dev, "Fatal error during GPU init\n");
  103. goto out;
  104. }
  105. /* Call ACPI methods: require modeset init
  106. * but failure is not fatal
  107. */
  108. if (!r) {
  109. acpi_status = amdgpu_acpi_init(adev);
  110. if (acpi_status)
  111. dev_dbg(&dev->pdev->dev,
  112. "Error during ACPI methods call\n");
  113. }
  114. amdgpu_amdkfd_load_interface(adev);
  115. amdgpu_amdkfd_device_probe(adev);
  116. amdgpu_amdkfd_device_init(adev);
  117. if (amdgpu_device_is_px(dev)) {
  118. pm_runtime_use_autosuspend(dev->dev);
  119. pm_runtime_set_autosuspend_delay(dev->dev, 5000);
  120. pm_runtime_set_active(dev->dev);
  121. pm_runtime_allow(dev->dev);
  122. pm_runtime_mark_last_busy(dev->dev);
  123. pm_runtime_put_autosuspend(dev->dev);
  124. }
  125. if (amdgpu_sriov_vf(adev))
  126. amdgpu_virt_release_full_gpu(adev, true);
  127. out:
  128. if (r) {
  129. /* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */
  130. if (adev->rmmio && amdgpu_device_is_px(dev))
  131. pm_runtime_put_noidle(dev->dev);
  132. amdgpu_driver_unload_kms(dev);
  133. }
  134. return r;
  135. }
  136. static int amdgpu_firmware_info(struct drm_amdgpu_info_firmware *fw_info,
  137. struct drm_amdgpu_query_fw *query_fw,
  138. struct amdgpu_device *adev)
  139. {
  140. switch (query_fw->fw_type) {
  141. case AMDGPU_INFO_FW_VCE:
  142. fw_info->ver = adev->vce.fw_version;
  143. fw_info->feature = adev->vce.fb_version;
  144. break;
  145. case AMDGPU_INFO_FW_UVD:
  146. fw_info->ver = adev->uvd.fw_version;
  147. fw_info->feature = 0;
  148. break;
  149. case AMDGPU_INFO_FW_GMC:
  150. fw_info->ver = adev->mc.fw_version;
  151. fw_info->feature = 0;
  152. break;
  153. case AMDGPU_INFO_FW_GFX_ME:
  154. fw_info->ver = adev->gfx.me_fw_version;
  155. fw_info->feature = adev->gfx.me_feature_version;
  156. break;
  157. case AMDGPU_INFO_FW_GFX_PFP:
  158. fw_info->ver = adev->gfx.pfp_fw_version;
  159. fw_info->feature = adev->gfx.pfp_feature_version;
  160. break;
  161. case AMDGPU_INFO_FW_GFX_CE:
  162. fw_info->ver = adev->gfx.ce_fw_version;
  163. fw_info->feature = adev->gfx.ce_feature_version;
  164. break;
  165. case AMDGPU_INFO_FW_GFX_RLC:
  166. fw_info->ver = adev->gfx.rlc_fw_version;
  167. fw_info->feature = adev->gfx.rlc_feature_version;
  168. break;
  169. case AMDGPU_INFO_FW_GFX_MEC:
  170. if (query_fw->index == 0) {
  171. fw_info->ver = adev->gfx.mec_fw_version;
  172. fw_info->feature = adev->gfx.mec_feature_version;
  173. } else if (query_fw->index == 1) {
  174. fw_info->ver = adev->gfx.mec2_fw_version;
  175. fw_info->feature = adev->gfx.mec2_feature_version;
  176. } else
  177. return -EINVAL;
  178. break;
  179. case AMDGPU_INFO_FW_SMC:
  180. fw_info->ver = adev->pm.fw_version;
  181. fw_info->feature = 0;
  182. break;
  183. case AMDGPU_INFO_FW_SDMA:
  184. if (query_fw->index >= adev->sdma.num_instances)
  185. return -EINVAL;
  186. fw_info->ver = adev->sdma.instance[query_fw->index].fw_version;
  187. fw_info->feature = adev->sdma.instance[query_fw->index].feature_version;
  188. break;
  189. default:
  190. return -EINVAL;
  191. }
  192. return 0;
  193. }
  194. /*
  195. * Userspace get information ioctl
  196. */
  197. /**
  198. * amdgpu_info_ioctl - answer a device specific request.
  199. *
  200. * @adev: amdgpu device pointer
  201. * @data: request object
  202. * @filp: drm filp
  203. *
  204. * This function is used to pass device specific parameters to the userspace
  205. * drivers. Examples include: pci device id, pipeline parms, tiling params,
  206. * etc. (all asics).
  207. * Returns 0 on success, -EINVAL on failure.
  208. */
  209. static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
  210. {
  211. struct amdgpu_device *adev = dev->dev_private;
  212. struct drm_amdgpu_info *info = data;
  213. struct amdgpu_mode_info *minfo = &adev->mode_info;
  214. void __user *out = (void __user *)(long)info->return_pointer;
  215. uint32_t size = info->return_size;
  216. struct drm_crtc *crtc;
  217. uint32_t ui32 = 0;
  218. uint64_t ui64 = 0;
  219. int i, found;
  220. if (!info->return_size || !info->return_pointer)
  221. return -EINVAL;
  222. switch (info->query) {
  223. case AMDGPU_INFO_ACCEL_WORKING:
  224. ui32 = adev->accel_working;
  225. return copy_to_user(out, &ui32, min(size, 4u)) ? -EFAULT : 0;
  226. case AMDGPU_INFO_CRTC_FROM_ID:
  227. for (i = 0, found = 0; i < adev->mode_info.num_crtc; i++) {
  228. crtc = (struct drm_crtc *)minfo->crtcs[i];
  229. if (crtc && crtc->base.id == info->mode_crtc.id) {
  230. struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
  231. ui32 = amdgpu_crtc->crtc_id;
  232. found = 1;
  233. break;
  234. }
  235. }
  236. if (!found) {
  237. DRM_DEBUG_KMS("unknown crtc id %d\n", info->mode_crtc.id);
  238. return -EINVAL;
  239. }
  240. return copy_to_user(out, &ui32, min(size, 4u)) ? -EFAULT : 0;
  241. case AMDGPU_INFO_HW_IP_INFO: {
  242. struct drm_amdgpu_info_hw_ip ip = {};
  243. enum amd_ip_block_type type;
  244. uint32_t ring_mask = 0;
  245. uint32_t ib_start_alignment = 0;
  246. uint32_t ib_size_alignment = 0;
  247. if (info->query_hw_ip.ip_instance >= AMDGPU_HW_IP_INSTANCE_MAX_COUNT)
  248. return -EINVAL;
  249. switch (info->query_hw_ip.type) {
  250. case AMDGPU_HW_IP_GFX:
  251. type = AMD_IP_BLOCK_TYPE_GFX;
  252. for (i = 0; i < adev->gfx.num_gfx_rings; i++)
  253. ring_mask |= ((adev->gfx.gfx_ring[i].ready ? 1 : 0) << i);
  254. ib_start_alignment = AMDGPU_GPU_PAGE_SIZE;
  255. ib_size_alignment = 8;
  256. break;
  257. case AMDGPU_HW_IP_COMPUTE:
  258. type = AMD_IP_BLOCK_TYPE_GFX;
  259. for (i = 0; i < adev->gfx.num_compute_rings; i++)
  260. ring_mask |= ((adev->gfx.compute_ring[i].ready ? 1 : 0) << i);
  261. ib_start_alignment = AMDGPU_GPU_PAGE_SIZE;
  262. ib_size_alignment = 8;
  263. break;
  264. case AMDGPU_HW_IP_DMA:
  265. type = AMD_IP_BLOCK_TYPE_SDMA;
  266. for (i = 0; i < adev->sdma.num_instances; i++)
  267. ring_mask |= ((adev->sdma.instance[i].ring.ready ? 1 : 0) << i);
  268. ib_start_alignment = AMDGPU_GPU_PAGE_SIZE;
  269. ib_size_alignment = 1;
  270. break;
  271. case AMDGPU_HW_IP_UVD:
  272. type = AMD_IP_BLOCK_TYPE_UVD;
  273. ring_mask = adev->uvd.ring.ready ? 1 : 0;
  274. ib_start_alignment = AMDGPU_GPU_PAGE_SIZE;
  275. ib_size_alignment = 16;
  276. break;
  277. case AMDGPU_HW_IP_VCE:
  278. type = AMD_IP_BLOCK_TYPE_VCE;
  279. for (i = 0; i < adev->vce.num_rings; i++)
  280. ring_mask |= ((adev->vce.ring[i].ready ? 1 : 0) << i);
  281. ib_start_alignment = AMDGPU_GPU_PAGE_SIZE;
  282. ib_size_alignment = 1;
  283. break;
  284. default:
  285. return -EINVAL;
  286. }
  287. for (i = 0; i < adev->num_ip_blocks; i++) {
  288. if (adev->ip_blocks[i].version->type == type &&
  289. adev->ip_blocks[i].status.valid) {
  290. ip.hw_ip_version_major = adev->ip_blocks[i].version->major;
  291. ip.hw_ip_version_minor = adev->ip_blocks[i].version->minor;
  292. ip.capabilities_flags = 0;
  293. ip.available_rings = ring_mask;
  294. ip.ib_start_alignment = ib_start_alignment;
  295. ip.ib_size_alignment = ib_size_alignment;
  296. break;
  297. }
  298. }
  299. return copy_to_user(out, &ip,
  300. min((size_t)size, sizeof(ip))) ? -EFAULT : 0;
  301. }
  302. case AMDGPU_INFO_HW_IP_COUNT: {
  303. enum amd_ip_block_type type;
  304. uint32_t count = 0;
  305. switch (info->query_hw_ip.type) {
  306. case AMDGPU_HW_IP_GFX:
  307. type = AMD_IP_BLOCK_TYPE_GFX;
  308. break;
  309. case AMDGPU_HW_IP_COMPUTE:
  310. type = AMD_IP_BLOCK_TYPE_GFX;
  311. break;
  312. case AMDGPU_HW_IP_DMA:
  313. type = AMD_IP_BLOCK_TYPE_SDMA;
  314. break;
  315. case AMDGPU_HW_IP_UVD:
  316. type = AMD_IP_BLOCK_TYPE_UVD;
  317. break;
  318. case AMDGPU_HW_IP_VCE:
  319. type = AMD_IP_BLOCK_TYPE_VCE;
  320. break;
  321. default:
  322. return -EINVAL;
  323. }
  324. for (i = 0; i < adev->num_ip_blocks; i++)
  325. if (adev->ip_blocks[i].version->type == type &&
  326. adev->ip_blocks[i].status.valid &&
  327. count < AMDGPU_HW_IP_INSTANCE_MAX_COUNT)
  328. count++;
  329. return copy_to_user(out, &count, min(size, 4u)) ? -EFAULT : 0;
  330. }
  331. case AMDGPU_INFO_TIMESTAMP:
  332. ui64 = amdgpu_gfx_get_gpu_clock_counter(adev);
  333. return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
  334. case AMDGPU_INFO_FW_VERSION: {
  335. struct drm_amdgpu_info_firmware fw_info;
  336. int ret;
  337. /* We only support one instance of each IP block right now. */
  338. if (info->query_fw.ip_instance != 0)
  339. return -EINVAL;
  340. ret = amdgpu_firmware_info(&fw_info, &info->query_fw, adev);
  341. if (ret)
  342. return ret;
  343. return copy_to_user(out, &fw_info,
  344. min((size_t)size, sizeof(fw_info))) ? -EFAULT : 0;
  345. }
  346. case AMDGPU_INFO_NUM_BYTES_MOVED:
  347. ui64 = atomic64_read(&adev->num_bytes_moved);
  348. return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
  349. case AMDGPU_INFO_NUM_EVICTIONS:
  350. ui64 = atomic64_read(&adev->num_evictions);
  351. return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
  352. case AMDGPU_INFO_VRAM_USAGE:
  353. ui64 = atomic64_read(&adev->vram_usage);
  354. return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
  355. case AMDGPU_INFO_VIS_VRAM_USAGE:
  356. ui64 = atomic64_read(&adev->vram_vis_usage);
  357. return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
  358. case AMDGPU_INFO_GTT_USAGE:
  359. ui64 = atomic64_read(&adev->gtt_usage);
  360. return copy_to_user(out, &ui64, min(size, 8u)) ? -EFAULT : 0;
  361. case AMDGPU_INFO_GDS_CONFIG: {
  362. struct drm_amdgpu_info_gds gds_info;
  363. memset(&gds_info, 0, sizeof(gds_info));
  364. gds_info.gds_gfx_partition_size = adev->gds.mem.gfx_partition_size >> AMDGPU_GDS_SHIFT;
  365. gds_info.compute_partition_size = adev->gds.mem.cs_partition_size >> AMDGPU_GDS_SHIFT;
  366. gds_info.gds_total_size = adev->gds.mem.total_size >> AMDGPU_GDS_SHIFT;
  367. gds_info.gws_per_gfx_partition = adev->gds.gws.gfx_partition_size >> AMDGPU_GWS_SHIFT;
  368. gds_info.gws_per_compute_partition = adev->gds.gws.cs_partition_size >> AMDGPU_GWS_SHIFT;
  369. gds_info.oa_per_gfx_partition = adev->gds.oa.gfx_partition_size >> AMDGPU_OA_SHIFT;
  370. gds_info.oa_per_compute_partition = adev->gds.oa.cs_partition_size >> AMDGPU_OA_SHIFT;
  371. return copy_to_user(out, &gds_info,
  372. min((size_t)size, sizeof(gds_info))) ? -EFAULT : 0;
  373. }
  374. case AMDGPU_INFO_VRAM_GTT: {
  375. struct drm_amdgpu_info_vram_gtt vram_gtt;
  376. vram_gtt.vram_size = adev->mc.real_vram_size;
  377. vram_gtt.vram_size -= adev->vram_pin_size;
  378. vram_gtt.vram_cpu_accessible_size = adev->mc.visible_vram_size;
  379. vram_gtt.vram_cpu_accessible_size -= (adev->vram_pin_size - adev->invisible_pin_size);
  380. vram_gtt.gtt_size = adev->mc.gtt_size;
  381. vram_gtt.gtt_size -= adev->gart_pin_size;
  382. return copy_to_user(out, &vram_gtt,
  383. min((size_t)size, sizeof(vram_gtt))) ? -EFAULT : 0;
  384. }
  385. case AMDGPU_INFO_MEMORY: {
  386. struct drm_amdgpu_memory_info mem;
  387. memset(&mem, 0, sizeof(mem));
  388. mem.vram.total_heap_size = adev->mc.real_vram_size;
  389. mem.vram.usable_heap_size =
  390. adev->mc.real_vram_size - adev->vram_pin_size;
  391. mem.vram.heap_usage = atomic64_read(&adev->vram_usage);
  392. mem.vram.max_allocation = mem.vram.usable_heap_size * 3 / 4;
  393. mem.cpu_accessible_vram.total_heap_size =
  394. adev->mc.visible_vram_size;
  395. mem.cpu_accessible_vram.usable_heap_size =
  396. adev->mc.visible_vram_size -
  397. (adev->vram_pin_size - adev->invisible_pin_size);
  398. mem.cpu_accessible_vram.heap_usage =
  399. atomic64_read(&adev->vram_vis_usage);
  400. mem.cpu_accessible_vram.max_allocation =
  401. mem.cpu_accessible_vram.usable_heap_size * 3 / 4;
  402. mem.gtt.total_heap_size = adev->mc.gtt_size;
  403. mem.gtt.usable_heap_size =
  404. adev->mc.gtt_size - adev->gart_pin_size;
  405. mem.gtt.heap_usage = atomic64_read(&adev->gtt_usage);
  406. mem.gtt.max_allocation = mem.gtt.usable_heap_size * 3 / 4;
  407. return copy_to_user(out, &mem,
  408. min((size_t)size, sizeof(mem)))
  409. ? -EFAULT : 0;
  410. }
  411. case AMDGPU_INFO_READ_MMR_REG: {
  412. unsigned n, alloc_size;
  413. uint32_t *regs;
  414. unsigned se_num = (info->read_mmr_reg.instance >>
  415. AMDGPU_INFO_MMR_SE_INDEX_SHIFT) &
  416. AMDGPU_INFO_MMR_SE_INDEX_MASK;
  417. unsigned sh_num = (info->read_mmr_reg.instance >>
  418. AMDGPU_INFO_MMR_SH_INDEX_SHIFT) &
  419. AMDGPU_INFO_MMR_SH_INDEX_MASK;
  420. /* set full masks if the userspace set all bits
  421. * in the bitfields */
  422. if (se_num == AMDGPU_INFO_MMR_SE_INDEX_MASK)
  423. se_num = 0xffffffff;
  424. if (sh_num == AMDGPU_INFO_MMR_SH_INDEX_MASK)
  425. sh_num = 0xffffffff;
  426. regs = kmalloc_array(info->read_mmr_reg.count, sizeof(*regs), GFP_KERNEL);
  427. if (!regs)
  428. return -ENOMEM;
  429. alloc_size = info->read_mmr_reg.count * sizeof(*regs);
  430. for (i = 0; i < info->read_mmr_reg.count; i++)
  431. if (amdgpu_asic_read_register(adev, se_num, sh_num,
  432. info->read_mmr_reg.dword_offset + i,
  433. &regs[i])) {
  434. DRM_DEBUG_KMS("unallowed offset %#x\n",
  435. info->read_mmr_reg.dword_offset + i);
  436. kfree(regs);
  437. return -EFAULT;
  438. }
  439. n = copy_to_user(out, regs, min(size, alloc_size));
  440. kfree(regs);
  441. return n ? -EFAULT : 0;
  442. }
  443. case AMDGPU_INFO_DEV_INFO: {
  444. struct drm_amdgpu_info_device dev_info = {};
  445. dev_info.device_id = dev->pdev->device;
  446. dev_info.chip_rev = adev->rev_id;
  447. dev_info.external_rev = adev->external_rev_id;
  448. dev_info.pci_rev = dev->pdev->revision;
  449. dev_info.family = adev->family;
  450. dev_info.num_shader_engines = adev->gfx.config.max_shader_engines;
  451. dev_info.num_shader_arrays_per_engine = adev->gfx.config.max_sh_per_se;
  452. /* return all clocks in KHz */
  453. dev_info.gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
  454. if (adev->pm.dpm_enabled) {
  455. dev_info.max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 10;
  456. dev_info.max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 10;
  457. } else {
  458. dev_info.max_engine_clock = adev->pm.default_sclk * 10;
  459. dev_info.max_memory_clock = adev->pm.default_mclk * 10;
  460. }
  461. dev_info.enabled_rb_pipes_mask = adev->gfx.config.backend_enable_mask;
  462. dev_info.num_rb_pipes = adev->gfx.config.max_backends_per_se *
  463. adev->gfx.config.max_shader_engines;
  464. dev_info.num_hw_gfx_contexts = adev->gfx.config.max_hw_contexts;
  465. dev_info._pad = 0;
  466. dev_info.ids_flags = 0;
  467. if (adev->flags & AMD_IS_APU)
  468. dev_info.ids_flags |= AMDGPU_IDS_FLAGS_FUSION;
  469. if (amdgpu_sriov_vf(adev))
  470. dev_info.ids_flags |= AMDGPU_IDS_FLAGS_PREEMPTION;
  471. dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE;
  472. dev_info.virtual_address_max = (uint64_t)adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE;
  473. dev_info.virtual_address_alignment = max((int)PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE);
  474. dev_info.pte_fragment_size = (1 << AMDGPU_LOG2_PAGES_PER_FRAG) *
  475. AMDGPU_GPU_PAGE_SIZE;
  476. dev_info.gart_page_size = AMDGPU_GPU_PAGE_SIZE;
  477. dev_info.cu_active_number = adev->gfx.cu_info.number;
  478. dev_info.cu_ao_mask = adev->gfx.cu_info.ao_cu_mask;
  479. dev_info.ce_ram_size = adev->gfx.ce_ram_size;
  480. memcpy(&dev_info.cu_bitmap[0], &adev->gfx.cu_info.bitmap[0],
  481. sizeof(adev->gfx.cu_info.bitmap));
  482. dev_info.vram_type = adev->mc.vram_type;
  483. dev_info.vram_bit_width = adev->mc.vram_width;
  484. dev_info.vce_harvest_config = adev->vce.harvest_config;
  485. return copy_to_user(out, &dev_info,
  486. min((size_t)size, sizeof(dev_info))) ? -EFAULT : 0;
  487. }
  488. case AMDGPU_INFO_VCE_CLOCK_TABLE: {
  489. unsigned i;
  490. struct drm_amdgpu_info_vce_clock_table vce_clk_table = {};
  491. struct amd_vce_state *vce_state;
  492. for (i = 0; i < AMDGPU_VCE_CLOCK_TABLE_ENTRIES; i++) {
  493. vce_state = amdgpu_dpm_get_vce_clock_state(adev, i);
  494. if (vce_state) {
  495. vce_clk_table.entries[i].sclk = vce_state->sclk;
  496. vce_clk_table.entries[i].mclk = vce_state->mclk;
  497. vce_clk_table.entries[i].eclk = vce_state->evclk;
  498. vce_clk_table.num_valid_entries++;
  499. }
  500. }
  501. return copy_to_user(out, &vce_clk_table,
  502. min((size_t)size, sizeof(vce_clk_table))) ? -EFAULT : 0;
  503. }
  504. case AMDGPU_INFO_VBIOS: {
  505. uint32_t bios_size = adev->bios_size;
  506. switch (info->vbios_info.type) {
  507. case AMDGPU_INFO_VBIOS_SIZE:
  508. return copy_to_user(out, &bios_size,
  509. min((size_t)size, sizeof(bios_size)))
  510. ? -EFAULT : 0;
  511. case AMDGPU_INFO_VBIOS_IMAGE: {
  512. uint8_t *bios;
  513. uint32_t bios_offset = info->vbios_info.offset;
  514. if (bios_offset >= bios_size)
  515. return -EINVAL;
  516. bios = adev->bios + bios_offset;
  517. return copy_to_user(out, bios,
  518. min((size_t)size, (size_t)(bios_size - bios_offset)))
  519. ? -EFAULT : 0;
  520. }
  521. default:
  522. DRM_DEBUG_KMS("Invalid request %d\n",
  523. info->vbios_info.type);
  524. return -EINVAL;
  525. }
  526. }
  527. case AMDGPU_INFO_NUM_HANDLES: {
  528. struct drm_amdgpu_info_num_handles handle;
  529. switch (info->query_hw_ip.type) {
  530. case AMDGPU_HW_IP_UVD:
  531. /* Starting Polaris, we support unlimited UVD handles */
  532. if (adev->asic_type < CHIP_POLARIS10) {
  533. handle.uvd_max_handles = adev->uvd.max_handles;
  534. handle.uvd_used_handles = amdgpu_uvd_used_handles(adev);
  535. return copy_to_user(out, &handle,
  536. min((size_t)size, sizeof(handle))) ? -EFAULT : 0;
  537. } else {
  538. return -ENODATA;
  539. }
  540. break;
  541. default:
  542. return -EINVAL;
  543. }
  544. }
  545. default:
  546. DRM_DEBUG_KMS("Invalid request %d\n", info->query);
  547. return -EINVAL;
  548. }
  549. return 0;
  550. }
  551. /*
  552. * Outdated mess for old drm with Xorg being in charge (void function now).
  553. */
  554. /**
  555. * amdgpu_driver_lastclose_kms - drm callback for last close
  556. *
  557. * @dev: drm dev pointer
  558. *
  559. * Switch vga_switcheroo state after last close (all asics).
  560. */
  561. void amdgpu_driver_lastclose_kms(struct drm_device *dev)
  562. {
  563. struct amdgpu_device *adev = dev->dev_private;
  564. amdgpu_fbdev_restore_mode(adev);
  565. vga_switcheroo_process_delayed_switch();
  566. }
  567. /**
  568. * amdgpu_driver_open_kms - drm callback for open
  569. *
  570. * @dev: drm dev pointer
  571. * @file_priv: drm file
  572. *
  573. * On device open, init vm on cayman+ (all asics).
  574. * Returns 0 on success, error on failure.
  575. */
  576. int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
  577. {
  578. struct amdgpu_device *adev = dev->dev_private;
  579. struct amdgpu_fpriv *fpriv;
  580. int r;
  581. file_priv->driver_priv = NULL;
  582. r = pm_runtime_get_sync(dev->dev);
  583. if (r < 0)
  584. return r;
  585. fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
  586. if (unlikely(!fpriv)) {
  587. r = -ENOMEM;
  588. goto out_suspend;
  589. }
  590. r = amdgpu_vm_init(adev, &fpriv->vm);
  591. if (r) {
  592. kfree(fpriv);
  593. goto out_suspend;
  594. }
  595. if (amdgpu_sriov_vf(adev)) {
  596. r = amdgpu_map_static_csa(adev, &fpriv->vm);
  597. if (r)
  598. goto out_suspend;
  599. }
  600. mutex_init(&fpriv->bo_list_lock);
  601. idr_init(&fpriv->bo_list_handles);
  602. amdgpu_ctx_mgr_init(&fpriv->ctx_mgr);
  603. file_priv->driver_priv = fpriv;
  604. out_suspend:
  605. pm_runtime_mark_last_busy(dev->dev);
  606. pm_runtime_put_autosuspend(dev->dev);
  607. return r;
  608. }
  609. /**
  610. * amdgpu_driver_postclose_kms - drm callback for post close
  611. *
  612. * @dev: drm dev pointer
  613. * @file_priv: drm file
  614. *
  615. * On device post close, tear down vm on cayman+ (all asics).
  616. */
  617. void amdgpu_driver_postclose_kms(struct drm_device *dev,
  618. struct drm_file *file_priv)
  619. {
  620. struct amdgpu_device *adev = dev->dev_private;
  621. struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
  622. struct amdgpu_bo_list *list;
  623. int handle;
  624. if (!fpriv)
  625. return;
  626. amdgpu_ctx_mgr_fini(&fpriv->ctx_mgr);
  627. amdgpu_uvd_free_handles(adev, file_priv);
  628. amdgpu_vce_free_handles(adev, file_priv);
  629. if (amdgpu_sriov_vf(adev)) {
  630. /* TODO: how to handle reserve failure */
  631. BUG_ON(amdgpu_bo_reserve(adev->virt.csa_obj, false));
  632. amdgpu_vm_bo_rmv(adev, fpriv->vm.csa_bo_va);
  633. fpriv->vm.csa_bo_va = NULL;
  634. amdgpu_bo_unreserve(adev->virt.csa_obj);
  635. }
  636. amdgpu_vm_fini(adev, &fpriv->vm);
  637. idr_for_each_entry(&fpriv->bo_list_handles, list, handle)
  638. amdgpu_bo_list_free(list);
  639. idr_destroy(&fpriv->bo_list_handles);
  640. mutex_destroy(&fpriv->bo_list_lock);
  641. kfree(fpriv);
  642. file_priv->driver_priv = NULL;
  643. pm_runtime_mark_last_busy(dev->dev);
  644. pm_runtime_put_autosuspend(dev->dev);
  645. }
  646. /**
  647. * amdgpu_driver_preclose_kms - drm callback for pre close
  648. *
  649. * @dev: drm dev pointer
  650. * @file_priv: drm file
  651. *
  652. * On device pre close, tear down hyperz and cmask filps on r1xx-r5xx
  653. * (all asics).
  654. */
  655. void amdgpu_driver_preclose_kms(struct drm_device *dev,
  656. struct drm_file *file_priv)
  657. {
  658. pm_runtime_get_sync(dev->dev);
  659. }
  660. /*
  661. * VBlank related functions.
  662. */
  663. /**
  664. * amdgpu_get_vblank_counter_kms - get frame count
  665. *
  666. * @dev: drm dev pointer
  667. * @pipe: crtc to get the frame count from
  668. *
  669. * Gets the frame count on the requested crtc (all asics).
  670. * Returns frame count on success, -EINVAL on failure.
  671. */
  672. u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe)
  673. {
  674. struct amdgpu_device *adev = dev->dev_private;
  675. int vpos, hpos, stat;
  676. u32 count;
  677. if (pipe >= adev->mode_info.num_crtc) {
  678. DRM_ERROR("Invalid crtc %u\n", pipe);
  679. return -EINVAL;
  680. }
  681. /* The hw increments its frame counter at start of vsync, not at start
  682. * of vblank, as is required by DRM core vblank counter handling.
  683. * Cook the hw count here to make it appear to the caller as if it
  684. * incremented at start of vblank. We measure distance to start of
  685. * vblank in vpos. vpos therefore will be >= 0 between start of vblank
  686. * and start of vsync, so vpos >= 0 means to bump the hw frame counter
  687. * result by 1 to give the proper appearance to caller.
  688. */
  689. if (adev->mode_info.crtcs[pipe]) {
  690. /* Repeat readout if needed to provide stable result if
  691. * we cross start of vsync during the queries.
  692. */
  693. do {
  694. count = amdgpu_display_vblank_get_counter(adev, pipe);
  695. /* Ask amdgpu_get_crtc_scanoutpos to return vpos as
  696. * distance to start of vblank, instead of regular
  697. * vertical scanout pos.
  698. */
  699. stat = amdgpu_get_crtc_scanoutpos(
  700. dev, pipe, GET_DISTANCE_TO_VBLANKSTART,
  701. &vpos, &hpos, NULL, NULL,
  702. &adev->mode_info.crtcs[pipe]->base.hwmode);
  703. } while (count != amdgpu_display_vblank_get_counter(adev, pipe));
  704. if (((stat & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE)) !=
  705. (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE))) {
  706. DRM_DEBUG_VBL("Query failed! stat %d\n", stat);
  707. } else {
  708. DRM_DEBUG_VBL("crtc %d: dist from vblank start %d\n",
  709. pipe, vpos);
  710. /* Bump counter if we are at >= leading edge of vblank,
  711. * but before vsync where vpos would turn negative and
  712. * the hw counter really increments.
  713. */
  714. if (vpos >= 0)
  715. count++;
  716. }
  717. } else {
  718. /* Fallback to use value as is. */
  719. count = amdgpu_display_vblank_get_counter(adev, pipe);
  720. DRM_DEBUG_VBL("NULL mode info! Returned count may be wrong.\n");
  721. }
  722. return count;
  723. }
  724. /**
  725. * amdgpu_enable_vblank_kms - enable vblank interrupt
  726. *
  727. * @dev: drm dev pointer
  728. * @pipe: crtc to enable vblank interrupt for
  729. *
  730. * Enable the interrupt on the requested crtc (all asics).
  731. * Returns 0 on success, -EINVAL on failure.
  732. */
  733. int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe)
  734. {
  735. struct amdgpu_device *adev = dev->dev_private;
  736. int idx = amdgpu_crtc_idx_to_irq_type(adev, pipe);
  737. return amdgpu_irq_get(adev, &adev->crtc_irq, idx);
  738. }
  739. /**
  740. * amdgpu_disable_vblank_kms - disable vblank interrupt
  741. *
  742. * @dev: drm dev pointer
  743. * @pipe: crtc to disable vblank interrupt for
  744. *
  745. * Disable the interrupt on the requested crtc (all asics).
  746. */
  747. void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe)
  748. {
  749. struct amdgpu_device *adev = dev->dev_private;
  750. int idx = amdgpu_crtc_idx_to_irq_type(adev, pipe);
  751. amdgpu_irq_put(adev, &adev->crtc_irq, idx);
  752. }
  753. /**
  754. * amdgpu_get_vblank_timestamp_kms - get vblank timestamp
  755. *
  756. * @dev: drm dev pointer
  757. * @crtc: crtc to get the timestamp for
  758. * @max_error: max error
  759. * @vblank_time: time value
  760. * @flags: flags passed to the driver
  761. *
  762. * Gets the timestamp on the requested crtc based on the
  763. * scanout position. (all asics).
  764. * Returns postive status flags on success, negative error on failure.
  765. */
  766. int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
  767. int *max_error,
  768. struct timeval *vblank_time,
  769. unsigned flags)
  770. {
  771. struct drm_crtc *crtc;
  772. struct amdgpu_device *adev = dev->dev_private;
  773. if (pipe >= dev->num_crtcs) {
  774. DRM_ERROR("Invalid crtc %u\n", pipe);
  775. return -EINVAL;
  776. }
  777. /* Get associated drm_crtc: */
  778. crtc = &adev->mode_info.crtcs[pipe]->base;
  779. if (!crtc) {
  780. /* This can occur on driver load if some component fails to
  781. * initialize completely and driver is unloaded */
  782. DRM_ERROR("Uninitialized crtc %d\n", pipe);
  783. return -EINVAL;
  784. }
  785. /* Helper routine in DRM core does all the work: */
  786. return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
  787. vblank_time, flags,
  788. &crtc->hwmode);
  789. }
  790. const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
  791. DRM_IOCTL_DEF_DRV(AMDGPU_GEM_CREATE, amdgpu_gem_create_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  792. DRM_IOCTL_DEF_DRV(AMDGPU_CTX, amdgpu_ctx_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  793. DRM_IOCTL_DEF_DRV(AMDGPU_BO_LIST, amdgpu_bo_list_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  794. /* KMS */
  795. DRM_IOCTL_DEF_DRV(AMDGPU_GEM_MMAP, amdgpu_gem_mmap_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  796. DRM_IOCTL_DEF_DRV(AMDGPU_GEM_WAIT_IDLE, amdgpu_gem_wait_idle_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  797. DRM_IOCTL_DEF_DRV(AMDGPU_CS, amdgpu_cs_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  798. DRM_IOCTL_DEF_DRV(AMDGPU_INFO, amdgpu_info_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  799. DRM_IOCTL_DEF_DRV(AMDGPU_WAIT_CS, amdgpu_cs_wait_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  800. DRM_IOCTL_DEF_DRV(AMDGPU_WAIT_FENCES, amdgpu_cs_wait_fences_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  801. DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA, amdgpu_gem_metadata_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  802. DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  803. DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  804. DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  805. };
  806. const int amdgpu_max_kms_ioctl = ARRAY_SIZE(amdgpu_ioctls_kms);
  807. /*
  808. * Debugfs info
  809. */
  810. #if defined(CONFIG_DEBUG_FS)
  811. static int amdgpu_debugfs_firmware_info(struct seq_file *m, void *data)
  812. {
  813. struct drm_info_node *node = (struct drm_info_node *) m->private;
  814. struct drm_device *dev = node->minor->dev;
  815. struct amdgpu_device *adev = dev->dev_private;
  816. struct drm_amdgpu_info_firmware fw_info;
  817. struct drm_amdgpu_query_fw query_fw;
  818. int ret, i;
  819. /* VCE */
  820. query_fw.fw_type = AMDGPU_INFO_FW_VCE;
  821. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  822. if (ret)
  823. return ret;
  824. seq_printf(m, "VCE feature version: %u, firmware version: 0x%08x\n",
  825. fw_info.feature, fw_info.ver);
  826. /* UVD */
  827. query_fw.fw_type = AMDGPU_INFO_FW_UVD;
  828. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  829. if (ret)
  830. return ret;
  831. seq_printf(m, "UVD feature version: %u, firmware version: 0x%08x\n",
  832. fw_info.feature, fw_info.ver);
  833. /* GMC */
  834. query_fw.fw_type = AMDGPU_INFO_FW_GMC;
  835. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  836. if (ret)
  837. return ret;
  838. seq_printf(m, "MC feature version: %u, firmware version: 0x%08x\n",
  839. fw_info.feature, fw_info.ver);
  840. /* ME */
  841. query_fw.fw_type = AMDGPU_INFO_FW_GFX_ME;
  842. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  843. if (ret)
  844. return ret;
  845. seq_printf(m, "ME feature version: %u, firmware version: 0x%08x\n",
  846. fw_info.feature, fw_info.ver);
  847. /* PFP */
  848. query_fw.fw_type = AMDGPU_INFO_FW_GFX_PFP;
  849. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  850. if (ret)
  851. return ret;
  852. seq_printf(m, "PFP feature version: %u, firmware version: 0x%08x\n",
  853. fw_info.feature, fw_info.ver);
  854. /* CE */
  855. query_fw.fw_type = AMDGPU_INFO_FW_GFX_CE;
  856. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  857. if (ret)
  858. return ret;
  859. seq_printf(m, "CE feature version: %u, firmware version: 0x%08x\n",
  860. fw_info.feature, fw_info.ver);
  861. /* RLC */
  862. query_fw.fw_type = AMDGPU_INFO_FW_GFX_RLC;
  863. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  864. if (ret)
  865. return ret;
  866. seq_printf(m, "RLC feature version: %u, firmware version: 0x%08x\n",
  867. fw_info.feature, fw_info.ver);
  868. /* MEC */
  869. query_fw.fw_type = AMDGPU_INFO_FW_GFX_MEC;
  870. query_fw.index = 0;
  871. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  872. if (ret)
  873. return ret;
  874. seq_printf(m, "MEC feature version: %u, firmware version: 0x%08x\n",
  875. fw_info.feature, fw_info.ver);
  876. /* MEC2 */
  877. if (adev->asic_type == CHIP_KAVERI ||
  878. (adev->asic_type > CHIP_TOPAZ && adev->asic_type != CHIP_STONEY)) {
  879. query_fw.index = 1;
  880. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  881. if (ret)
  882. return ret;
  883. seq_printf(m, "MEC2 feature version: %u, firmware version: 0x%08x\n",
  884. fw_info.feature, fw_info.ver);
  885. }
  886. /* SMC */
  887. query_fw.fw_type = AMDGPU_INFO_FW_SMC;
  888. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  889. if (ret)
  890. return ret;
  891. seq_printf(m, "SMC feature version: %u, firmware version: 0x%08x\n",
  892. fw_info.feature, fw_info.ver);
  893. /* SDMA */
  894. query_fw.fw_type = AMDGPU_INFO_FW_SDMA;
  895. for (i = 0; i < adev->sdma.num_instances; i++) {
  896. query_fw.index = i;
  897. ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
  898. if (ret)
  899. return ret;
  900. seq_printf(m, "SDMA%d feature version: %u, firmware version: 0x%08x\n",
  901. i, fw_info.feature, fw_info.ver);
  902. }
  903. return 0;
  904. }
  905. static const struct drm_info_list amdgpu_firmware_info_list[] = {
  906. {"amdgpu_firmware_info", amdgpu_debugfs_firmware_info, 0, NULL},
  907. };
  908. #endif
  909. int amdgpu_debugfs_firmware_init(struct amdgpu_device *adev)
  910. {
  911. #if defined(CONFIG_DEBUG_FS)
  912. return amdgpu_debugfs_add_files(adev, amdgpu_firmware_info_list,
  913. ARRAY_SIZE(amdgpu_firmware_info_list));
  914. #else
  915. return 0;
  916. #endif
  917. }