diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2017-04-27 16:58:01 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-05-24 17:39:36 -0400 |
commit | e2a75f88c3ad4b895b58d4abd877de827a12072f (patch) | |
tree | 6c8ebcd099a7ce53e00df520f34d3b95df247e22 /drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |
parent | 8ae1a33648969531d93008dda508f1715f1fdbf0 (diff) |
drm/amdgpu: parse the gpu_info firmware (v4)
And populate the gfx structures from it.
v2: update the structures updated by the table
v3: rework based on new table structure
v4: simplify things
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Tested-by: Junwei Zhang <Jerry.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_device.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 43ca16b6eee2..c20ef335a6ab 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -54,6 +54,8 @@ | |||
54 | #include <linux/pci.h> | 54 | #include <linux/pci.h> |
55 | #include <linux/firmware.h> | 55 | #include <linux/firmware.h> |
56 | 56 | ||
57 | MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin"); | ||
58 | |||
57 | static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); | 59 | static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); |
58 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); | 60 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); |
59 | 61 | ||
@@ -1392,6 +1394,98 @@ static void amdgpu_device_enable_virtual_display(struct amdgpu_device *adev) | |||
1392 | } | 1394 | } |
1393 | } | 1395 | } |
1394 | 1396 | ||
1397 | static int amdgpu_device_parse_gpu_info_fw(struct amdgpu_device *adev) | ||
1398 | { | ||
1399 | const struct firmware *fw; | ||
1400 | const char *chip_name; | ||
1401 | char fw_name[30]; | ||
1402 | int err; | ||
1403 | const struct gpu_info_firmware_header_v1_0 *hdr; | ||
1404 | |||
1405 | switch (adev->asic_type) { | ||
1406 | case CHIP_TOPAZ: | ||
1407 | case CHIP_TONGA: | ||
1408 | case CHIP_FIJI: | ||
1409 | case CHIP_POLARIS11: | ||
1410 | case CHIP_POLARIS10: | ||
1411 | case CHIP_POLARIS12: | ||
1412 | case CHIP_CARRIZO: | ||
1413 | case CHIP_STONEY: | ||
1414 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
1415 | case CHIP_VERDE: | ||
1416 | case CHIP_TAHITI: | ||
1417 | case CHIP_PITCAIRN: | ||
1418 | case CHIP_OLAND: | ||
1419 | case CHIP_HAINAN: | ||
1420 | #endif | ||
1421 | #ifdef CONFIG_DRM_AMDGPU_CIK | ||
1422 | case CHIP_BONAIRE: | ||
1423 | case CHIP_HAWAII: | ||
1424 | case CHIP_KAVERI: | ||
1425 | case CHIP_KABINI: | ||
1426 | case CHIP_MULLINS: | ||
1427 | #endif | ||
1428 | default: | ||
1429 | return 0; | ||
1430 | case CHIP_VEGA10: | ||
1431 | chip_name = "vega10"; | ||
1432 | break; | ||
1433 | } | ||
1434 | |||
1435 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_gpu_info.bin", chip_name); | ||
1436 | err = request_firmware(&fw, fw_name, adev->dev); | ||
1437 | if (err) { | ||
1438 | dev_err(adev->dev, | ||
1439 | "Failed to load gpu_info firmware \"%s\"\n", | ||
1440 | fw_name); | ||
1441 | goto out; | ||
1442 | } | ||
1443 | err = amdgpu_ucode_validate(fw); | ||
1444 | if (err) { | ||
1445 | dev_err(adev->dev, | ||
1446 | "Failed to validate gpu_info firmware \"%s\"\n", | ||
1447 | fw_name); | ||
1448 | goto out; | ||
1449 | } | ||
1450 | |||
1451 | hdr = (const struct gpu_info_firmware_header_v1_0 *)fw->data; | ||
1452 | amdgpu_ucode_print_gpu_info_hdr(&hdr->header); | ||
1453 | |||
1454 | switch (hdr->version_major) { | ||
1455 | case 1: | ||
1456 | { | ||
1457 | const struct gpu_info_firmware_v1_0 *gpu_info_fw = | ||
1458 | (const struct gpu_info_firmware_v1_0 *)(fw->data + | ||
1459 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
1460 | |||
1461 | adev->gfx.config.max_shader_engines = gpu_info_fw->gc_num_se; | ||
1462 | adev->gfx.config.max_cu_per_sh = gpu_info_fw->gc_num_cu_per_sh; | ||
1463 | adev->gfx.config.max_sh_per_se = gpu_info_fw->gc_num_sh_per_se; | ||
1464 | adev->gfx.config.max_backends_per_se = gpu_info_fw->gc_num_rb_per_se; | ||
1465 | adev->gfx.config.max_texture_channel_caches = | ||
1466 | gpu_info_fw->gc_num_tccs; | ||
1467 | adev->gfx.config.max_gprs = gpu_info_fw->gc_num_gprs; | ||
1468 | adev->gfx.config.max_gs_threads = gpu_info_fw->gc_num_max_gs_thds; | ||
1469 | adev->gfx.config.gs_vgt_table_depth = gpu_info_fw->gc_gs_table_depth; | ||
1470 | adev->gfx.config.gs_prim_buffer_depth = gpu_info_fw->gc_gsprim_buff_depth; | ||
1471 | adev->gfx.config.double_offchip_lds_buf = | ||
1472 | gpu_info_fw->gc_double_offchip_lds_buffer; | ||
1473 | adev->gfx.cu_info.wave_front_size = gpu_info_fw->gc_wave_size; | ||
1474 | break; | ||
1475 | } | ||
1476 | default: | ||
1477 | dev_err(adev->dev, | ||
1478 | "Unsupported gpu_info table %d\n", hdr->header.ucode_version); | ||
1479 | err = -EINVAL; | ||
1480 | goto out; | ||
1481 | } | ||
1482 | out: | ||
1483 | release_firmware(fw); | ||
1484 | fw = NULL; | ||
1485 | |||
1486 | return err; | ||
1487 | } | ||
1488 | |||
1395 | static int amdgpu_early_init(struct amdgpu_device *adev) | 1489 | static int amdgpu_early_init(struct amdgpu_device *adev) |
1396 | { | 1490 | { |
1397 | int i, r; | 1491 | int i, r; |
@@ -1456,6 +1550,10 @@ static int amdgpu_early_init(struct amdgpu_device *adev) | |||
1456 | return -EINVAL; | 1550 | return -EINVAL; |
1457 | } | 1551 | } |
1458 | 1552 | ||
1553 | r = amdgpu_device_parse_gpu_info_fw(adev); | ||
1554 | if (r) | ||
1555 | return r; | ||
1556 | |||
1459 | if (amdgpu_sriov_vf(adev)) { | 1557 | if (amdgpu_sriov_vf(adev)) { |
1460 | r = amdgpu_virt_request_full_gpu(adev, true); | 1558 | r = amdgpu_virt_request_full_gpu(adev, true); |
1461 | if (r) | 1559 | if (r) |