Skip to contentSkip to conversation

DSPBRIDGE: MMU-Fault debugging enhancements

PATCH Applied Guzman Lugo, Fernando 5 participants 7 messages Apr 9, 2010 – May 13, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 DSPBRIDGE: MMU-Fault debugging enhancements

Quoted 1 line

From db3d76a2e89a1c227322a2732ddf7ebf5cd4b4cf Mon Sep 17 00:00:00 2001

From: Ernesto Ramos <[email protected]>
Date: Wed, 24 Mar 2010 11:12:05 -0600
Subject: [PATCH] DSPBRIDGE: MMU-Fault debugging enhancements

These changes allow for DSP task information to be printed by the MPU dspbridge when DSP MMU fault ocurrs.

[change to open source coding style]
---
 arch/arm/plat-omap/include/dspbridge/cod.h   |    1 +
 arch/arm/plat-omap/include/dspbridge/dbll.h  |    3 +-
 arch/arm/plat-omap/include/dspbridge/gh.h    |    2 +
 arch/arm/plat-omap/include/dspbridge/io_sm.h |    5 +
 arch/arm/plat-omap/include/dspbridge/nldr.h  |    2 +
 arch/arm/plat-omap/include/dspbridge/node.h  |   15 +
 drivers/dsp/bridge/Makefile                  |    1 +
 drivers/dsp/bridge/gen/gh.c                  |   24 ++
 drivers/dsp/bridge/pmgr/dbll.c               |   84 ++++
 drivers/dsp/bridge/rmgr/nldr.c               |   80 ++++
 drivers/dsp/bridge/rmgr/node.c               |   31 ++
 drivers/dsp/bridge/wmd/io_sm.c               |  568 +++++++++++++++++++++-----
 drivers/dsp/bridge/wmd/ue_deh.c              |   74 +++-
 13 files changed, 780 insertions(+), 110 deletions(-)
arch/arm/plat-omap/include/dspbridge/cod.h +1 -0
index 3d76a6b..92311cd 100644
@@ -26,6 +26,7 @@
 #define COD_MAXPATHLENGTH       255
 #define COD_TRACEBEG            "SYS_PUTCBEG"
 #define COD_TRACEEND            "SYS_PUTCEND"
+#define COD_TRACECURPOS        "BRIDGE_SYS_PUTC_current"
 #define COD_TRACESECT           "trace"
 #define COD_TRACEBEGOLD         "PUTCBEG"
 #define COD_TRACEENDOLD         "PUTCEND"
arch/arm/plat-omap/include/dspbridge/dbll.h +2 -1
index daf8a0a..01c4647 100644
@@ -51,5 +51,6 @@ extern void dbll_set_attrs(struct dbll_tar_obj *target,
 extern void dbll_unload(struct dbll_library_obj *lib, struct dbll_attrs *attrs);
 extern dsp_status dbll_unload_sect(struct dbll_library_obj *lib,
                                   char *sectName, struct dbll_attrs *attrs);
-
+bool dbll_find_dsp_symbol(struct dbll_library_obj *zl_lib, u32 address,
+               u32 offset_range, u32 *sym_addr_output, char *name_output);
 #endif /* DBLL_ */
arch/arm/plat-omap/include/dspbridge/gh.h +2 -0
index e4da0f2..55c0489 100644
@@ -27,4 +27,6 @@ extern void gh_exit(void);
 extern void *gh_find(struct gh_t_hash_tab *hash_tab, void *key);
 extern void gh_init(void);
 extern void *gh_insert(struct gh_t_hash_tab *hash_tab, void *key, void *value);
+void gh_iterate(struct gh_t_hash_tab *hash_tab,
+       void (*callback)(void *, void *), void *user_data);
 #endif /* GH_ */
arch/arm/plat-omap/include/dspbridge/io_sm.h +5 -0
index aa4d0cf..66aa50f 100644
@@ -293,4 +293,9 @@ extern void io_sm_init(void);
 extern dsp_status print_dsp_trace_buffer(struct wmd_dev_context
                                         *hwmd_context);
 
+dsp_status dump_dsp_stack(struct wmd_dev_context *wmd_context);
+
+void dump_dl_modules(struct wmd_dev_context *wmd_context);
+
+
 #endif /* IOSM_ */
arch/arm/plat-omap/include/dspbridge/nldr.h +2 -0
index 2ec928a..2b930d1 100644
@@ -49,5 +49,7 @@ extern dsp_status nldr_load(struct nldr_nodeobject *nldr_node_obj,
                            enum nldr_phase phase);
 extern dsp_status nldr_unload(struct nldr_nodeobject *nldr_node_obj,
                              enum nldr_phase phase);
+dsp_status nldr_find_addr(struct nldr_nodeobject *nldr_node, u32 sym_addr,
+       u32 offset_range, void *offset_output, char *sym_name);
 
 #endif /* NLDR_ */
arch/arm/plat-omap/include/dspbridge/node.h +15 -0
index ec0dcf3..e3c98f9 100644
@@ -566,4 +566,19 @@ extern dsp_status node_get_uuid_props(void *hprocessor,
                                      OUT struct dsp_ndbprops
                                      *node_props);
 
+/**
+ * node_find_addr() - Find the closest symbol to the given address.
+ *
+ * @node_mgr:          Node manager handle
+ * @sym_addr:          Given address to find the closest symbol
+ * @offset_range:              offset range to look fo the closest symbol
+ * @sym_addr_output:   Symbol Output address
+ * @sym_name:          String with the symbol name of the closest symbol
+ *
+ *     This function finds the closest symbol to the address where a MMU
+ *     Fault occurred on the DSP side.
+ */
+dsp_status node_find_addr(struct node_mgr *node_mgr, u32 sym_addr,
+                               u32 offset_range, void *sym_addr_output,
+                               char *sym_name);
 #endif /* NODE_ */
drivers/dsp/bridge/Makefile +1 -0
index 5a28374..75a6d69 100644
@@ -30,5 +30,6 @@ ccflags-y += -Idrivers/dsp/bridge/services
 ccflags-y += -Idrivers/dsp/bridge/wmd
 ccflags-y += -Idrivers/dsp/bridge/pmgr
 ccflags-y += -Idrivers/dsp/bridge/rmgr
+ccflags-y += -Idrivers/dsp/bridge/dynload
 ccflags-y += -Idrivers/dsp/bridge/hw
 ccflags-y += -Iarch/arm
drivers/dsp/bridge/gen/gh.c +24 -0
index dc211ae..d1e7b38 100644
@@ -187,3 +187,27 @@ static void myfree(void *ptr, s32 size)
 {
        gs_free(ptr);
 }
+
+/**
+ * gh_iterate() - This function goes through all the elements in the hash table
+ *             looking for the dsp symbols.
+ * @hash_tab:  Hash table
+ * @callback:  pointer to callback function
+ * @user_data: User data, contains the find_symbol_context pointer
+ *
+ */
+void gh_iterate(struct gh_t_hash_tab *hash_tab,
+               void (*callback)(void *, void *), void *user_data)
+{
+       struct element *elem;
+       u32 i;
+
+       if (hash_tab && hash_tab->buckets)
+               for (i = 0; i < hash_tab->max_bucket; i++) {
+                       elem = hash_tab->buckets[i];
+                       while (elem) {
+                               callback(&elem->data, user_data);
+                               elem = elem->next;
+                       }
+               }
+}
drivers/dsp/bridge/pmgr/dbll.c +84 -0

87 lines not on this page · raw message

drivers/dsp/bridge/rmgr/nldr.c +80 -0

83 lines not on this page · raw message

drivers/dsp/bridge/rmgr/node.c +31 -0
index 32df890..66e28c7 100644
@@ -3206,3 +3206,34 @@ static u32 mem_write(void *priv_ref, u32 ulDspAddr, void *pbuf,
 
        return ul_num_bytes;
 }
+
+/*
+ *  ======== node_find_addr ========
+ */
+dsp_status node_find_addr(struct node_mgr *node_mgr, u32 sym_addr,
+               u32 offset_range, void *sym_addr_output, char *sym_name)
+{
+       struct node_object *node_obj;
+       dsp_status status = DSP_ENOTFOUND;
+       u32 n;
+
+       pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x,  %s)\n", __func__,
+                       (unsigned int) node_mgr,
+                       sym_addr, offset_range,
+                       (unsigned int) sym_addr_output, sym_name);
+
+       node_obj = (struct node_object *)(node_mgr->node_list->head.next);
+
+       for (n = 0; n < node_mgr->num_nodes; n++) {
+               status = nldr_find_addr(node_obj->nldr_node_obj, sym_addr,
+                       offset_range, sym_addr_output, sym_name);
+
+               if (DSP_SUCCEEDED(status))
+                       break;
+
+               node_obj = (struct node_object *) (node_obj->list_elem.next);
+       }
+
+       return status;
+}
+
drivers/dsp/bridge/wmd/io_sm.c +464 -104

634 lines not on this page · raw message

drivers/dsp/bridge/wmd/ue_deh.c +69 -5

131 lines not on this page · raw message

--
1.6.0.4

#1 lore raw
Quoted 6 lines

From db3d76a2e89a1c227322a2732ddf7ebf5cd4b4cf Mon Sep 17 00:00:00 2001
From: Ernesto Ramos <[email protected]>
Date: Wed, 24 Mar 2010 11:12:05 -0600
Subject: [PATCH] DSPBRIDGE: MMU-Fault debugging enhancements

Quoted 7 lines

These changes allow for DSP task information to be printed by the MPU dspbridge when DSP MMU fault ocurrs.

[change to open source coding style]

---

Pushed to dspbridge.

- omar

#2 lore raw
In reply to Guzman Lugo, Fernando
Quoted 11 lines · Fernando

From db3d76a2e89a1c227322a2732ddf7ebf5cd4b4cf Mon Sep 17 00:00:00 2001
From: Ernesto Ramos <[email protected]>
Date: Wed, 24 Mar 2010 11:12:05 -0600
Subject: [PATCH] DSPBRIDGE: MMU-Fault debugging enhancements

These changes allow for DSP task information to be printed by the MPU dspbridge when DSP MMU fault ocurrs.

[change to open source coding style]

This patch seems to be doing a lot of things. Couldn't it have been split?

Also, from the commit message it seems to implement a new feature, however, I heard it's supposed to fix memory corruption too. Is that true? If that's the case the code that fixes that would have to be separate.

I understand this patch was already pushed to dspbridge branch, but I think such important changes should be properly recorded in the history.

Cheers.

Signature · 1 line
Felipe Contreras
#3 lore raw

Hi,

Quoted 29 lines

-----Original Message-----
From: Felipe Contreras [mailto:[email protected]]
Sent: Friday, April 30, 2010 10:21 AM
To: Guzman Lugo, Fernando; Ramos Falcon, Ernesto
Cc: [email protected]; Hiroshi DOYU; Ameya Palande; [email protected]
Subject: Re: [PATCH] DSPBRIDGE: MMU-Fault debugging enhancements

Quoted 11 lines · Fernando

From db3d76a2e89a1c227322a2732ddf7ebf5cd4b4cf Mon Sep 17 00:00:00 2001
From: Ernesto Ramos <[email protected]>
Date: Wed, 24 Mar 2010 11:12:05 -0600
Subject: [PATCH] DSPBRIDGE: MMU-Fault debugging enhancements

These changes allow for DSP task information to be printed by the MPU dspbridge when DSP MMU fault ocurrs.

[change to open source coding style]

This patch seems to be doing a lot of things. Couldn't it have been split?

Also, from the commit message it seems to implement a new feature, however, I heard it's supposed to fix memory corruption too. Is that true? If that's the case the code that fixes that would have to be separate.

Quoted 6 lines

I understand this patch was already pushed to dspbridge branch, but I think such important changes should be properly recorded in the history.

Cheers.

Hi Felipe,
I agree important changes must be properly recorded but in this case the patch introduces only one new feature and because of the way that it is implemented using gpt8 overflow interrupt instead of mailbox to inform about the MMU Fault, the problem of the memory corruption was fixed indirectly, however these changes are part of the feature design itself and I don't see the need to split this new feature.

Saludos,
Ernesto

Quoted 2 lines

--
Felipe Contreras

#4 lore raw

Hey Ernesto,

Quoted 12 lines · Ernesto
Quoted 11 lines

This patch seems to be doing a lot of things. Couldn't it have been split?

Also, from the commit message it seems to implement a new feature, however, I heard it's supposed to fix memory corruption too. Is that true? If that's the case the code that fixes that would have to be separate.

I understand this patch was already pushed to dspbridge branch, but I think such important changes should be properly recorded in the history.

Quoted 6 lines

I agree important changes must be properly recorded but in this case the patch introduces only one new feature and because of the way that it is implemented using gpt8 overflow interrupt instead of mailbox to inform about the MMU Fault, the problem of the memory corruption was fixed indirectly, however these changes are part of the feature design itself and I don't see the need to split this new feature.

In general, logically independent changes should end up as separate patches. Many times it looks like a patch cannot be split further, but with a little bit of creativity it usually can.

I can think of one patch that switches to gpt8 overflow, and another one that actually shows the extra information.

Anyway, I ask because we found some issues with the latest commits of dspbridge, and I would like to isolate the memory corruption fix just to be safe.

Also, from that description it looks like there might be still a problem in the mailbox that is hidded by this patch... so it's more like a workaround, not really a fix.

Cheers.

Signature · 1 line
Felipe Contreras
#5 lore raw

PATCH 1/1 dspbridge: deh: use GPT8

From: Ernesto Ramos <[email protected]>

Cleaned up by Felipe Contreras.

---
 drivers/dsp/bridge/wmd/ue_deh.c |   55 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 52 insertions(+), 3 deletions(-)
drivers/dsp/bridge/wmd/ue_deh.c +52 -3
index 451ee3c..3678e1d 100644
@@ -53,8 +53,17 @@
 #include "_tiomap_pwr.h"
 #include <dspbridge/io_sm.h>
 
+#include <plat/dmtimer.h>
+
 #define ALIGN_DOWN(x, a)  ((x)&(~((a)-1)))
 
+/* GP Timer number to trigger interrupt for MMU-fault ISR on DSP */
+#define GPTIMER_FOR_DSP_MMU_FAULT      8
+/* Bit mask to enable overflow interrupt */
+#define GPTIMER_IRQ_OVERFLOW           2
+/* Max time to check for GP Timer IRQ */
+#define GPTIMER_IRQ_WAIT_MAX_CNT       1000
+
 static struct hw_mmu_map_attrs_t map_attrs = { HW_LITTLE_ENDIAN,
 	HW_ELEM_SIZE16BIT,
 	HW_MMU_CPUES
@@ -62,6 +71,8 @@ static struct hw_mmu_map_attrs_t map_attrs = { HW_LITTLE_ENDIAN,
 
 static void *dummy_va_addr;
 
+static struct omap_dm_timer *timer;
+
 dsp_status bridge_deh_create(struct deh_mgr **ret_deh_mgr,
 		struct dev_object *hdev_obj)
 {
@@ -128,6 +139,15 @@ err:
 		bridge_deh_destroy(deh_mgr);
 		deh_mgr = NULL;
 	}
+	else {
+		timer = omap_dm_timer_request_specific(
+					GPTIMER_FOR_DSP_MMU_FAULT);
+		if (!timer) {
+			pr_err("%s: GPTimer not available\n", __func__);
+			return -ENODEV;
+		}
+		omap_dm_timer_disable(timer);
+	}
 
 leave:
 	*ret_deh_mgr = deh_mgr;
@@ -156,6 +176,10 @@ dsp_status bridge_deh_destroy(struct deh_mgr *deh_mgr)
 	/* Deallocate the DEH manager object */
 	MEM_FREE_OBJECT(deh_mgr);
 
+	/* The GPTimer is no longer needed */
+	omap_dm_timer_free(timer);
+	timer = NULL;
+
 	return DSP_SOK;
 }
 
@@ -177,6 +201,31 @@ dsp_status bridge_deh_register_notify(struct deh_mgr *deh_mgr, u32 event_mask,
 	return status;
 }
 
+static void wait_for_timer()
+{
+	int c;
+
+	omap_dm_timer_enable(timer);
+	/* Enable overflow interrupt */
+	omap_dm_timer_set_int_enable(timer,
+			GPTIMER_IRQ_OVERFLOW);
+	/*
+	 * Set counter value to overflow counter after
+	 * one tick and start timer.
+	 */
+	omap_dm_timer_set_load_start(timer, 0, 0xfffffffe);
+
+	/* Wait 80us for timer to overflow */
+	udelay(80);
+
+	/* Check interrupt status and wait for interrupt */
+	for (c = 0; c < GPTIMER_IRQ_WAIT_MAX_CNT; c++)
+		if ((omap_dm_timer_read_status(timer) & GPTIMER_IRQ_OVERFLOW))
+			return;
+
+	pr_err("%s: GPTimer interrupt failed\n", __func__);
+}
+
 void bridge_deh_notify(struct deh_mgr *deh_mgr, u32 ulEventMask, u32 dwErrInfo)
 {
 	struct wmd_dev_context *dev_context;
@@ -241,9 +290,9 @@ void bridge_deh_notify(struct deh_mgr *deh_mgr, u32 ulEventMask, u32 dwErrInfo)
 						HW_PAGE_SIZE4KB, 1,
 						&map_attrs, HW_SET, HW_SET);
 		}
-		/* send an interrupt to DSP */
-		omap_mbox_msg_send(dev_context->mbox,
-				MBX_DEH_CLASS | MBX_DEH_EMMU);
+
+		wait_for_timer();
+
 		/* Clear MMU interrupt */
 		hw_mmu_event_ack(resources.dw_dmmu_base,
 				HW_MMU_TRANSLATION_FAULT);
Signature · 1 line
1.7.1
#6 lore raw
In reply to Felipe Contreras
Quoted 26 lines · Felipe Contreras

Hey Ernesto,

Quoted 12 lines · Ernesto
Quoted 11 lines

This patch seems to be doing a lot of things. Couldn't it have been split?

Also, from the commit message it seems to implement a new feature, however, I heard it's supposed to fix memory corruption too. Is that true? If that's the case the code that fixes that would have to be separate.

I understand this patch was already pushed to dspbridge branch, but I think such important changes should be properly recorded in the history.

Quoted 6 lines

I agree important changes must be properly recorded but in this case the patch introduces only one new feature and because of the way that it is implemented using gpt8 overflow interrupt instead of mailbox to inform about the MMU Fault, the problem of the memory corruption was fixed indirectly, however these changes are part of the feature design itself and I don't see the need to split this new feature.

In general, logically independent changes should end up as separate patches. Many times it looks like a patch cannot be split further, but with a little bit of creativity it usually can.

Quoted 6 lines

I can think of one patch that switches to gpt8 overflow, and another one that actually shows the extra information.

Anyway, I ask because we found some issues with the latest commits of dspbridge, and I would like to isolate the memory corruption fix just to be safe.

Disregard that. This patch doesn't actually fix the corruption. I sent one proposal for a patch that does.

Quoted 3 lines

Also, from that description it looks like there might be still a problem in the mailbox that is hidded by this patch... so it's more like a workaround, not really a fix.

I've extracted the GPT8 related changes, which are good in themselves, and I sent a separate patch for reference. I also cleaned the patch a bit.

Now I wonder if there are some situations where we might not want to use GPT8, but the mailbox interrupt. Maybe some baseimages are not using GPT8, or maybe the system doesn't have OMAP_DM_TIMER.

Also, all this MMU fault backtracing and so on seems to consume quite a bit of code. Production systems most likely would want to have this off (specially when constrained by size), so it should be a configuration option.

Cheers.

Signature · 1 line
Felipe Contreras