There will be a slightly different version for atomfirmware.

Reviewed-by: Ken Wang <qingqing.w...@amd.com>
Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 28 ++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h |  3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/atom.c            | 26 --------------------------
 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 56a86dd..f52b1bf 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)
        memcpy(dst, src, num_bytes);
 #endif
 }
+
+int amdgpu_atombios_allocate_fb_scratch(struct amdgpu_device *adev)
+{
+       struct atom_context *ctx = adev->mode_info.atom_context;
+       int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware);
+       uint16_t data_offset;
+       int usage_bytes = 0;
+       struct _ATOM_VRAM_USAGE_BY_FIRMWARE *firmware_usage;
+
+       if (amdgpu_atom_parse_data_header(ctx, index, NULL, NULL, NULL, 
&data_offset)) {
+               firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE 
*)(ctx->bios + data_offset);
+
+               DRM_DEBUG("atom firmware requested %08x %dkb\n",
+                         
le32_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware),
+                         
le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb));
+
+               usage_bytes = 
le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb) * 
1024;
+       }
+       ctx->scratch_size_bytes = 0;
+       if (usage_bytes == 0)
+               usage_bytes = 20 * 1024;
+       /* allocate some scratch memory */
+       ctx->scratch = kzalloc(usage_bytes, GFP_KERNEL);
+       if (!ctx->scratch)
+               return -ENOMEM;
+       ctx->scratch_size_bytes = usage_bytes;
+       return 0;
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
index 70e9ace..4e0f488 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,
 int amdgpu_atombios_get_svi2_info(struct amdgpu_device *adev,
                              u8 voltage_type,
                              u8 *svd_gpio_id, u8 *svc_gpio_id);
+
+int amdgpu_atombios_allocate_fb_scratch(struct amdgpu_device *adev);
+
 #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 118f4e6..f87c1cb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -993,7 +993,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)
 
        mutex_init(&adev->mode_info.atom_context->mutex);
        amdgpu_atombios_scratch_regs_init(adev);
-       amdgpu_atom_allocate_fb_scratch(adev->mode_info.atom_context);
+       amdgpu_atombios_allocate_fb_scratch(adev);
        return 0;
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c 
b/drivers/gpu/drm/amd/amdgpu/atom.c
index 81c60a2..d69aa2e 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 *
        return true;
 }
 
-int amdgpu_atom_allocate_fb_scratch(struct atom_context *ctx)
-{
-       int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware);
-       uint16_t data_offset;
-       int usage_bytes = 0;
-       struct _ATOM_VRAM_USAGE_BY_FIRMWARE *firmware_usage;
-
-       if (amdgpu_atom_parse_data_header(ctx, index, NULL, NULL, NULL, 
&data_offset)) {
-               firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE 
*)(ctx->bios + data_offset);
-
-               DRM_DEBUG("atom firmware requested %08x %dkb\n",
-                         
le32_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware),
-                         
le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb));
-
-               usage_bytes = 
le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb) * 
1024;
-       }
-       ctx->scratch_size_bytes = 0;
-       if (usage_bytes == 0)
-               usage_bytes = 20 * 1024;
-       /* allocate some scratch memory */
-       ctx->scratch = kzalloc(usage_bytes, GFP_KERNEL);
-       if (!ctx->scratch)
-               return -ENOMEM;
-       ctx->scratch_size_bytes = usage_bytes;
-       return 0;
-}
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.h 
b/drivers/gpu/drm/amd/amdgpu/atom.h
index baa2438..ddd8045 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
                            uint8_t *frev, uint8_t *crev, uint16_t *data_start);
 bool amdgpu_atom_parse_cmd_header(struct atom_context *ctx, int index,
                           uint8_t *frev, uint8_t *crev);
-int amdgpu_atom_allocate_fb_scratch(struct atom_context *ctx);
 #include "atom-types.h"
 #include "atombios.h"
 #include "ObjectID.h"
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to