]> Git Repo - J-linux.git/blobdiff - drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
Merge tag 'riscv-for-linus-4.20-mw2' of git://git.kernel.org/pub/scm/linux/kernel...
[J-linux.git] / drivers / gpu / drm / amd / display / amdgpu_dm / amdgpu_dm_helpers.c
index 8403b6a9a77bd0008ab30b67153db5392206a5b6..39997d977efb949e06aecb180212b9b15f553c60 100644 (file)
@@ -335,15 +335,92 @@ bool dm_helpers_dp_mst_send_payload_allocation(
        return true;
 }
 
-void dm_dtn_log_begin(struct dc_context *ctx)
-{}
+void dm_dtn_log_begin(struct dc_context *ctx,
+       struct dc_log_buffer_ctx *log_ctx)
+{
+       static const char msg[] = "[dtn begin]\n";
+
+       if (!log_ctx) {
+               pr_info("%s", msg);
+               return;
+       }
+
+       dm_dtn_log_append_v(ctx, log_ctx, "%s", msg);
+}
 
 void dm_dtn_log_append_v(struct dc_context *ctx,
-               const char *pMsg, ...)
-{}
+       struct dc_log_buffer_ctx *log_ctx,
+       const char *msg, ...)
+{
+       va_list args;
+       size_t total;
+       int n;
 
-void dm_dtn_log_end(struct dc_context *ctx)
-{}
+       if (!log_ctx) {
+               /* No context, redirect to dmesg. */
+               struct va_format vaf;
+
+               vaf.fmt = msg;
+               vaf.va = &args;
+
+               va_start(args, msg);
+               pr_info("%pV", &vaf);
+               va_end(args);
+
+               return;
+       }
+
+       /* Measure the output. */
+       va_start(args, msg);
+       n = vsnprintf(NULL, 0, msg, args);
+       va_end(args);
+
+       if (n <= 0)
+               return;
+
+       /* Reallocate the string buffer as needed. */
+       total = log_ctx->pos + n + 1;
+
+       if (total > log_ctx->size) {
+               char *buf = (char *)kvcalloc(total, sizeof(char), GFP_KERNEL);
+
+               if (buf) {
+                       memcpy(buf, log_ctx->buf, log_ctx->pos);
+                       kfree(log_ctx->buf);
+
+                       log_ctx->buf = buf;
+                       log_ctx->size = total;
+               }
+       }
+
+       if (!log_ctx->buf)
+               return;
+
+       /* Write the formatted string to the log buffer. */
+       va_start(args, msg);
+       n = vscnprintf(
+               log_ctx->buf + log_ctx->pos,
+               log_ctx->size - log_ctx->pos,
+               msg,
+               args);
+       va_end(args);
+
+       if (n > 0)
+               log_ctx->pos += n;
+}
+
+void dm_dtn_log_end(struct dc_context *ctx,
+       struct dc_log_buffer_ctx *log_ctx)
+{
+       static const char msg[] = "[dtn end]\n";
+
+       if (!log_ctx) {
+               pr_info("%s", msg);
+               return;
+       }
+
+       dm_dtn_log_append_v(ctx, log_ctx, "%s", msg);
+}
 
 bool dm_helpers_dp_mst_start_top_mgr(
                struct dc_context *ctx,
This page took 0.032062 seconds and 4 git commands to generate.