&adev->dm.dmub_bo_gpu_addr,
&adev->dm.dmub_bo_cpu_addr);
+ if (adev->dm.boot_time_crc_info.bo_ptr)
+ amdgpu_bo_free_kernel(&adev->dm.boot_time_crc_info.bo_ptr,
+ &adev->dm.boot_time_crc_info.gpu_addr,
+ &adev->dm.boot_time_crc_info.cpu_addr);
+
if (adev->dm.hpd_rx_offload_wq && adev->dm.dc) {
for (i = 0; i < adev->dm.dc->caps.max_links; i++) {
if (adev->dm.hpd_rx_offload_wq[i].wq) {
return ret;
}
+static void amdgpu_dm_boot_time_crc_init(struct amdgpu_device *adev)
+{
+ struct dm_boot_time_crc_info *bootcrc_info = NULL;
+ struct dmub_srv *dmub = NULL;
+ union dmub_fw_boot_options option = {0};
+ int ret = 0;
+ const uint32_t fb_size = 3 * 1024 * 1024; /* 3MB for DCC pattern */
+
+ if (!adev || !adev->dm.dc || !adev->dm.dc->ctx ||
+ !adev->dm.dc->ctx->dmub_srv) {
+ return;
+ }
+
+ dmub = adev->dm.dc->ctx->dmub_srv->dmub;
+ bootcrc_info = &adev->dm.boot_time_crc_info;
+
+ if (!dmub || !dmub->hw_funcs.get_fw_boot_option) {
+ drm_dbg(adev_to_drm(adev), "failed to init boot time crc buffer\n");
+ return;
+ }
+
+ option = dmub->hw_funcs.get_fw_boot_option(dmub);
+
+ /* Return if boot time CRC is not enabled */
+ if (option.bits.bootcrc_en_at_S0i3 == 0)
+ return;
+
+ /* Create a buffer for boot time CRC */
+ ret = amdgpu_bo_create_kernel(adev, fb_size, PAGE_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT,
+ &bootcrc_info->bo_ptr,
+ &bootcrc_info->gpu_addr,
+ &bootcrc_info->cpu_addr);
+
+ if (ret) {
+ drm_dbg(adev_to_drm(adev), "failed to create boot time crc buffer\n");
+ } else {
+ bootcrc_info->size = fb_size;
+
+ drm_dbg(adev_to_drm(adev), "boot time crc buffer created addr 0x%llx, size %u\n",
+ bootcrc_info->gpu_addr, bootcrc_info->size);
+
+ /* Send the buffer info to DMUB */
+ dc_dmub_srv_boot_time_crc_init(adev->dm.dc,
+ bootcrc_info->gpu_addr, bootcrc_info->size);
+ }
+}
+
static int dm_late_init(struct amdgpu_ip_block *ip_block)
{
struct amdgpu_device *adev = ip_block->adev;
dmcu = adev->dm.dc->res_pool->dmcu;
+ /* Init the boot time CRC (skip in resume) */
+ if ((adev->in_suspend == 0) &&
+ (amdgpu_ip_version(adev, DCE_HWIP, 0) == IP_VERSION(3, 6, 0)))
+ amdgpu_dm_boot_time_crc_init(adev);
+
for (i = 0; i < 16; i++)
linear_lut[i] = 0xFFFF * i / 15;
uint64_t gpu_addr;
};
+/**
+ * struct dm_boot_time_crc_info - Buffer info used by boot time CRC
+ * @cpu_addr: MMIO cpu addr
+ * @bo_ptr: Pointer to the buffer object
+ * @gpu_addr: MMIO gpu addr
+ * @size: Size of the buffer
+ */
+struct dm_boot_time_crc_info {
+ void *cpu_addr;
+ struct amdgpu_bo *bo_ptr;
+ uint64_t gpu_addr;
+ uint32_t size;
+};
+
typedef void (*dmub_notify_interrupt_callback_t)(struct amdgpu_device *adev, struct dmub_notification *notify);
/**
struct completion replied;
char reply_data[0x40]; // Cannot include dmub_cmd here
} fused_io[8];
+
+ /**
+ * @dm_boot_time_crc_info:
+ *
+ * Buffer info for the boot time crc.
+ */
+ struct dm_boot_time_crc_info boot_time_crc_info;
};
enum dsc_clock_force_state {
return dc->ctx->dmub_srv && dc->ctx->dmub_srv->cursor_offload_enabled;
}
+void dc_dmub_srv_boot_time_crc_init(const struct dc *dc, uint64_t gpu_addr, uint32_t size)
+{
+ struct dc_dmub_srv *dc_dmub_srv;
+ struct dc_context *dc_ctx;
+ union dmub_rb_cmd cmd = {0};
+ bool result = false;
+
+ if (!dc || !dc->ctx || !dc->ctx->dmub_srv || size == 0)
+ return;
+
+ dc_dmub_srv = dc->ctx->dmub_srv;
+ dc_ctx = dc_dmub_srv->ctx;
+
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.boot_time_crc_init.header.type = DMUB_CMD__BOOT_TIME_CRC;
+ cmd.boot_time_crc_init.header.sub_type = DMUB_CMD__BOOT_TIME_CRC_INIT_MEM;
+ cmd.boot_time_crc_init.header.payload_bytes =
+ sizeof(struct dmub_rb_cmd_boot_time_crc_init);
+ cmd.boot_time_crc_init.data.buffer_addr.quad_part = gpu_addr;
+ cmd.boot_time_crc_init.data.buffer_size = size;
+
+ result = dc_wake_and_execute_dmub_cmd(dc->ctx, &cmd, DM_DMUB_WAIT_TYPE_NO_WAIT);
+
+ if (!result)
+ DC_ERROR("Boot time crc init failed in DMUB");
+}
+
void dc_dmub_srv_release_hw(const struct dc *dc)
{
struct dc_dmub_srv *dc_dmub_srv = dc->ctx->dmub_srv;