linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] venus: core: add support to dump FW region
@ 2020-12-07  6:13 dikshita
  2020-12-07 18:13 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: dikshita @ 2020-12-07  6:13 UTC (permalink / raw)
  To: linux-media, stanimir.varbanov
  Cc: linux-kernel, linux-arm-msm, vgarodia, Dikshita Agarwal

From: Dikshita Agarwal <dikshita@codeaurora.org>

Add support to dump video FW region during FW crash
using devcoredump helpers.

Signed-off-by: Dikshita Agarwal <dikshita@codeaurora.org>
---
 drivers/media/platform/qcom/venus/core.c     | 31 ++++++++++++++++++++++++++++
 drivers/media/platform/qcom/venus/core.h     |  2 ++
 drivers/media/platform/qcom/venus/firmware.c |  3 +++
 3 files changed, 36 insertions(+)

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 5102403..f23923d 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -7,8 +7,10 @@
 #include <linux/interconnect.h>
 #include <linux/ioctl.h>
 #include <linux/delay.h>
+#include <linux/devcoredump.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
@@ -22,6 +24,33 @@
 #include "firmware.h"
 #include "pm_helpers.h"
 
+static void venus_coredump(struct venus_core *core)
+{
+	struct device *dev;
+	phys_addr_t mem_phys;
+	size_t mem_size;
+	void *mem_va;
+	void *data;
+
+	dev = core->dev;
+	mem_phys = core->fw.mem_phys;
+	mem_size = core->fw.mem_size;
+
+	mem_va = memremap(mem_phys, mem_size, MEMREMAP_WC);
+	if (!mem_va)
+		return;
+
+	data = vmalloc(mem_size);
+	if (!data) {
+		memunmap(mem_va);
+		return;
+	}
+
+	memcpy(data, mem_va, mem_size);
+	dev_coredumpv(dev, data, mem_size, GFP_KERNEL);
+	memunmap(mem_va);
+}
+
 static void venus_event_notify(struct venus_core *core, u32 event)
 {
 	struct venus_inst *inst;
@@ -67,6 +96,8 @@ static void venus_sys_error_handler(struct work_struct *work)
 
 	venus_shutdown(core);
 
+	venus_coredump(core);
+
 	pm_runtime_put_sync(core->dev);
 
 	while (core->pmdomains[0] && pm_runtime_active(core->pmdomains[0]))
diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index 842a294..8122f23 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -171,6 +171,8 @@ struct venus_core {
 		struct device *dev;
 		struct iommu_domain *iommu_domain;
 		size_t mapped_mem_size;
+		phys_addr_t mem_phys;
+		size_t mem_size;
 	} fw;
 	struct mutex lock;
 	struct list_head instances;
diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c
index 9a9c097..f3d91d23 100644
--- a/drivers/media/platform/qcom/venus/firmware.c
+++ b/drivers/media/platform/qcom/venus/firmware.c
@@ -201,6 +201,9 @@ int venus_boot(struct venus_core *core)
 		return -EINVAL;
 	}
 
+	core->fw.mem_size = mem_size;
+	core->fw.mem_phys = mem_phys;
+
 	if (core->use_tz)
 		ret = qcom_scm_pas_auth_and_reset(VENUS_PAS_ID);
 	else
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] venus: core: add support to dump FW region
  2020-12-07  6:13 [PATCH v3] venus: core: add support to dump FW region dikshita
@ 2020-12-07 18:13 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2020-12-07 18:13 UTC (permalink / raw)
  To: dikshita, linux-media, stanimir.varbanov
  Cc: linux-kernel, linux-arm-msm, vgarodia, Dikshita Agarwal

Quoting dikshita@codeaurora.org (2020-12-06 22:13:30)
> From: Dikshita Agarwal <dikshita@codeaurora.org>
> 
> Add support to dump video FW region during FW crash
> using devcoredump helpers.
> 
> Signed-off-by: Dikshita Agarwal <dikshita@codeaurora.org>
> ---

One nit below.

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

Usually this contains a "Changes from v1" section. What changed?

>  drivers/media/platform/qcom/venus/core.c     | 31 ++++++++++++++++++++++++++++
>  drivers/media/platform/qcom/venus/core.h     |  2 ++
>  drivers/media/platform/qcom/venus/firmware.c |  3 +++
>  3 files changed, 36 insertions(+)
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index 5102403..f23923d 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -22,6 +24,33 @@
>  #include "firmware.h"
>  #include "pm_helpers.h"
>  
> +static void venus_coredump(struct venus_core *core)
> +{
> +       struct device *dev;
> +       phys_addr_t mem_phys;
> +       size_t mem_size;
> +       void *mem_va;
> +       void *data;
> +
> +       dev = core->dev;
> +       mem_phys = core->fw.mem_phys;
> +       mem_size = core->fw.mem_size;
> +
> +       mem_va = memremap(mem_phys, mem_size, MEMREMAP_WC);
> +       if (!mem_va)
> +               return;
> +
> +       data = vmalloc(mem_size);
> +       if (!data) {
> +               memunmap(mem_va);
> +               return;
> +       }
> +
> +       memcpy(data, mem_va, mem_size);
> +       dev_coredumpv(dev, data, mem_size, GFP_KERNEL);
> +       memunmap(mem_va);

Technically we could unmap right after memcpy() so that the mapping only
exists for the memcpy() and then mem_va isn't "alive" for the
dev_coredumpv() call.

> +}
> +
>  static void venus_event_notify(struct venus_core *core, u32 event)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-07 18:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07  6:13 [PATCH v3] venus: core: add support to dump FW region dikshita
2020-12-07 18:13 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).