diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2016-09-23 13:10:49 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-03-29 23:54:17 -0400 |
commit | 43bf11bd9231ad06bd1d91c847beda52b88bc6e0 (patch) | |
tree | c9a150fb340728c58a5d0324bda1b8d305124f71 /drivers | |
parent | 0cdd500560e233aef4e0749c9f014e9ee8f4d752 (diff) |
drm/amdgpu: move atom scratch setup into amdgpu_atombios.c
There will be a slightly different version for atomfirmware.
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ken Wang <Qingqing.Wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 28 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/atom.c | 26 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/atom.h | 1 |
5 files changed, 32 insertions, 28 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c index 56a86dd5789e..f52b1bf3d3d9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | |||
@@ -1748,3 +1748,31 @@ void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le) | |||
1748 | memcpy(dst, src, num_bytes); | 1748 | memcpy(dst, src, num_bytes); |
1749 | #endif | 1749 | #endif |
1750 | } | 1750 | } |
1751 | |||
1752 | int amdgpu_atombios_allocate_fb_scratch(struct amdgpu_device *adev) | ||
1753 | { | ||
1754 | struct atom_context *ctx = adev->mode_info.atom_context; | ||
1755 | int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware); | ||
1756 | uint16_t data_offset; | ||
1757 | int usage_bytes = 0; | ||
1758 | struct _ATOM_VRAM_USAGE_BY_FIRMWARE *firmware_usage; | ||
1759 | |||
1760 | if (amdgpu_atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset)) { | ||
1761 | firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE *)(ctx->bios + data_offset); | ||
1762 | |||
1763 | DRM_DEBUG("atom firmware requested %08x %dkb\n", | ||
1764 | le32_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware), | ||
1765 | le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb)); | ||
1766 | |||
1767 | usage_bytes = le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb) * 1024; | ||
1768 | } | ||
1769 | ctx->scratch_size_bytes = 0; | ||
1770 | if (usage_bytes == 0) | ||
1771 | usage_bytes = 20 * 1024; | ||
1772 | /* allocate some scratch memory */ | ||
1773 | ctx->scratch = kzalloc(usage_bytes, GFP_KERNEL); | ||
1774 | if (!ctx->scratch) | ||
1775 | return -ENOMEM; | ||
1776 | ctx->scratch_size_bytes = usage_bytes; | ||
1777 | return 0; | ||
1778 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h index 70e9acef5d9c..4e0f488487f3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h | |||
@@ -215,4 +215,7 @@ int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev, | |||
215 | int amdgpu_atombios_get_svi2_info(struct amdgpu_device *adev, | 215 | int amdgpu_atombios_get_svi2_info(struct amdgpu_device *adev, |
216 | u8 voltage_type, | 216 | u8 voltage_type, |
217 | u8 *svd_gpio_id, u8 *svc_gpio_id); | 217 | u8 *svd_gpio_id, u8 *svc_gpio_id); |
218 | |||
219 | int amdgpu_atombios_allocate_fb_scratch(struct amdgpu_device *adev); | ||
220 | |||
218 | #endif | 221 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 7f996ac089b4..dfbfd56bcc25 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -994,7 +994,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev) | |||
994 | 994 | ||
995 | mutex_init(&adev->mode_info.atom_context->mutex); | 995 | mutex_init(&adev->mode_info.atom_context->mutex); |
996 | amdgpu_atombios_scratch_regs_init(adev); | 996 | amdgpu_atombios_scratch_regs_init(adev); |
997 | amdgpu_atom_allocate_fb_scratch(adev->mode_info.atom_context); | 997 | amdgpu_atombios_allocate_fb_scratch(adev); |
998 | return 0; | 998 | return 0; |
999 | } | 999 | } |
1000 | 1000 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c b/drivers/gpu/drm/amd/amdgpu/atom.c index 81c60a277eeb..d69aa2e179bb 100644 --- a/drivers/gpu/drm/amd/amdgpu/atom.c +++ b/drivers/gpu/drm/amd/amdgpu/atom.c | |||
@@ -1417,29 +1417,3 @@ bool amdgpu_atom_parse_cmd_header(struct atom_context *ctx, int index, uint8_t * | |||
1417 | return true; | 1417 | return true; |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | int amdgpu_atom_allocate_fb_scratch(struct atom_context *ctx) | ||
1421 | { | ||
1422 | int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware); | ||
1423 | uint16_t data_offset; | ||
1424 | int usage_bytes = 0; | ||
1425 | struct _ATOM_VRAM_USAGE_BY_FIRMWARE *firmware_usage; | ||
1426 | |||
1427 | if (amdgpu_atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset)) { | ||
1428 | firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE *)(ctx->bios + data_offset); | ||
1429 | |||
1430 | DRM_DEBUG("atom firmware requested %08x %dkb\n", | ||
1431 | le32_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware), | ||
1432 | le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb)); | ||
1433 | |||
1434 | usage_bytes = le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb) * 1024; | ||
1435 | } | ||
1436 | ctx->scratch_size_bytes = 0; | ||
1437 | if (usage_bytes == 0) | ||
1438 | usage_bytes = 20 * 1024; | ||
1439 | /* allocate some scratch memory */ | ||
1440 | ctx->scratch = kzalloc(usage_bytes, GFP_KERNEL); | ||
1441 | if (!ctx->scratch) | ||
1442 | return -ENOMEM; | ||
1443 | ctx->scratch_size_bytes = usage_bytes; | ||
1444 | return 0; | ||
1445 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.h b/drivers/gpu/drm/amd/amdgpu/atom.h index baa2438d7883..ddd8045accf3 100644 --- a/drivers/gpu/drm/amd/amdgpu/atom.h +++ b/drivers/gpu/drm/amd/amdgpu/atom.h | |||
@@ -152,7 +152,6 @@ bool amdgpu_atom_parse_data_header(struct atom_context *ctx, int index, uint16_t | |||
152 | uint8_t *frev, uint8_t *crev, uint16_t *data_start); | 152 | uint8_t *frev, uint8_t *crev, uint16_t *data_start); |
153 | bool amdgpu_atom_parse_cmd_header(struct atom_context *ctx, int index, | 153 | bool amdgpu_atom_parse_cmd_header(struct atom_context *ctx, int index, |
154 | uint8_t *frev, uint8_t *crev); | 154 | uint8_t *frev, uint8_t *crev); |
155 | int amdgpu_atom_allocate_fb_scratch(struct atom_context *ctx); | ||
156 | #include "atom-types.h" | 155 | #include "atom-types.h" |
157 | #include "atombios.h" | 156 | #include "atombios.h" |
158 | #include "ObjectID.h" | 157 | #include "ObjectID.h" |