linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] venus: core: add support to dump FW region
@ 2020-11-30  5:36 Dikshita Agarwal
  2020-11-30 10:27 ` Stanimir Varbanov
  2020-12-03  7:18 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Dikshita Agarwal @ 2020-11-30  5:36 UTC (permalink / raw)
  To: linux-media, stanimir.varbanov
  Cc: linux-kernel, linux-arm-msm, vgarodia, Dikshita Agarwal

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 | 47 ++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 6103aaf..01a0cfe 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,48 @@
 #include "firmware.h"
 #include "pm_helpers.h"
 
+static int subsystem_dump(struct venus_core *core)
+{
+	struct device_node *node;
+	struct device *dev;
+	struct resource r;
+	void *mem_va;
+	size_t mem_size;
+	void *data;
+	int ret;
+
+	dev = core->dev;
+	node = of_parse_phandle(dev->of_node, "memory-region", 0);
+	if (!node)
+		return -EINVAL;
+
+	ret = of_address_to_resource(node, 0, &r);
+	if (ret)
+		goto err_put_node;
+
+	mem_size = resource_size(&r);
+
+	mem_va = memremap(r.start, mem_size, MEMREMAP_WC);
+	if (!mem_va) {
+		ret = -ENOMEM;
+		goto err_put_node;
+	}
+
+	data = vmalloc(mem_size);
+	if (!data) {
+		ret = -EINVAL;
+		goto err_unmap;
+	}
+
+	memcpy(data, mem_va, mem_size);
+
+	dev_coredumpv(dev, data, mem_size, GFP_KERNEL);
+err_unmap:
+	memunmap(mem_va);
+err_put_node:
+	of_node_put(node);
+	return ret;
+}
 static void venus_event_notify(struct venus_core *core, u32 event)
 {
 	struct venus_inst *inst;
@@ -67,6 +111,9 @@ static void venus_sys_error_handler(struct work_struct *work)
 
 	venus_shutdown(core);
 
+	dev_warn(core->dev, "dumping FW region!\n");
+	subsystem_dump(core);
+
 	pm_runtime_put_sync(core->dev);
 
 	while (core->pmdomains[0] && pm_runtime_active(core->pmdomains[0]))
-- 
2.7.4


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

* Re: [PATCH] venus: core: add support to dump FW region
  2020-11-30  5:36 [PATCH] venus: core: add support to dump FW region Dikshita Agarwal
@ 2020-11-30 10:27 ` Stanimir Varbanov
  2020-12-03  7:18 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stanimir Varbanov @ 2020-11-30 10:27 UTC (permalink / raw)
  To: Dikshita Agarwal, linux-media; +Cc: linux-kernel, linux-arm-msm, vgarodia



On 11/30/20 7:36 AM, Dikshita Agarwal wrote:
> 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 | 47 ++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index 6103aaf..01a0cfe 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,48 @@
>  #include "firmware.h"
>  #include "pm_helpers.h"
>  
> +static int subsystem_dump(struct venus_core *core)

this function could return void because we don't handle the error in
venus_sys_error_handler().

> +{
> +	struct device_node *node;
> +	struct device *dev;
> +	struct resource r;
> +	void *mem_va;
> +	size_t mem_size;
> +	void *data;
> +	int ret;
> +
> +	dev = core->dev;
> +	node = of_parse_phandle(dev->of_node, "memory-region", 0);
> +	if (!node)
> +		return -EINVAL;
> +
> +	ret = of_address_to_resource(node, 0, &r);
> +	if (ret)
> +		goto err_put_node;
> +
> +	mem_size = resource_size(&r);

could you reuse the resource from venus_load_fw by adding r.sart and
resource size in venus_core->fw{} structure.

> +
> +	mem_va = memremap(r.start, mem_size, MEMREMAP_WC);
> +	if (!mem_va) {
> +		ret = -ENOMEM;
> +		goto err_put_node;
> +	}
> +
> +	data = vmalloc(mem_size);
> +	if (!data) {
> +		ret = -EINVAL;
> +		goto err_unmap;
> +	}
> +
> +	memcpy(data, mem_va, mem_size);
> +
> +	dev_coredumpv(dev, data, mem_size, GFP_KERNEL);
> +err_unmap:
> +	memunmap(mem_va);
> +err_put_node:
> +	of_node_put(node);
> +	return ret;
> +}
>  static void venus_event_notify(struct venus_core *core, u32 event)
>  {
>  	struct venus_inst *inst;
> @@ -67,6 +111,9 @@ static void venus_sys_error_handler(struct work_struct *work)
>  
>  	venus_shutdown(core);
>  
> +	dev_warn(core->dev, "dumping FW region!\n");

this warn is not needed, please drop it.

> +	subsystem_dump(core);

Are we sure that the dump is always required?

> +
>  	pm_runtime_put_sync(core->dev);
>  
>  	while (core->pmdomains[0] && pm_runtime_active(core->pmdomains[0]))
> 

-- 
regards,
Stan

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

* Re: [PATCH] venus: core: add support to dump FW region
  2020-11-30  5:36 [PATCH] venus: core: add support to dump FW region Dikshita Agarwal
  2020-11-30 10:27 ` Stanimir Varbanov
@ 2020-12-03  7:18 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2020-12-03  7:18 UTC (permalink / raw)
  To: Dikshita Agarwal, linux-media, stanimir.varbanov
  Cc: linux-kernel, linux-arm-msm, vgarodia, Dikshita Agarwal

Quoting Dikshita Agarwal (2020-11-29 21:36:12)
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index 6103aaf..01a0cfe 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -22,6 +24,48 @@
>  #include "firmware.h"
>  #include "pm_helpers.h"
>  
> +static int subsystem_dump(struct venus_core *core)
> +{
> +       struct device_node *node;
> +       struct device *dev;
> +       struct resource r;
> +       void *mem_va;
> +       size_t mem_size;
> +       void *data;
> +       int ret;
> +
> +       dev = core->dev;
> +       node = of_parse_phandle(dev->of_node, "memory-region", 0);

Any chance this could be done at probe time and saved away as some sort
of pointer?

> +       if (!node)
> +               return -EINVAL;
> +
> +       ret = of_address_to_resource(node, 0, &r);

of_node_put(node);

> +       if (ret)
> +               goto err_put_node;

And then just return ret;

> +
> +       mem_size = resource_size(&r);
> +
> +       mem_va = memremap(r.start, mem_size, MEMREMAP_WC);
> +       if (!mem_va) {
> +               ret = -ENOMEM;
> +               goto err_put_node;

And return -ENOMEM;

> +       }
> +
> +       data = vmalloc(mem_size);
> +       if (!data) {
> +               ret = -EINVAL;
> +               goto err_unmap;
> +       }
> +
> +       memcpy(data, mem_va, mem_size);
> +
> +       dev_coredumpv(dev, data, mem_size, GFP_KERNEL);
> +err_unmap:
> +       memunmap(mem_va);
> +err_put_node:
> +       of_node_put(node);
> +       return ret;
> +}
>  static void venus_event_notify(struct venus_core *core, u32 event)
>  {
>         struct venus_inst *inst;
> @@ -67,6 +111,9 @@ static void venus_sys_error_handler(struct work_struct *work)
>  
>         venus_shutdown(core);
>  
> +       dev_warn(core->dev, "dumping FW region!\n");

Do we need this warning?

> +       subsystem_dump(core);

Maybe call it venus_do_coredump() so it isn't so generic.

> +
>         pm_runtime_put_sync(core->dev);
>  
>         while (core->pmdomains[0] && pm_runtime_active(core->pmdomains[0]))

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

end of thread, other threads:[~2020-12-03  7:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-30  5:36 [PATCH] venus: core: add support to dump FW region Dikshita Agarwal
2020-11-30 10:27 ` Stanimir Varbanov
2020-12-03  7:18 ` 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).