From: Ovidiu Panait <ovpanait@gmail.com>
To: u-boot@lists.denx.de
Cc: Ovidiu Panait <ovpanait@gmail.com>,
Dzmitry Sankouski <dsankouski@gmail.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Rick Chen <rick@andestech.com>, Simon Glass <sjg@chromium.org>,
Tim Harvey <tharvey@gateworks.com>
Subject: [PATCH 2/2] event: fix static events for CONFIG_NEEDS_MANUAL_RELOC
Date: Sun, 15 May 2022 21:40:29 +0300 [thread overview]
Message-ID: <20220515184029.2169025-2-ovpanait@gmail.com> (raw)
In-Reply-To: <20220515184029.2169025-1-ovpanait@gmail.com>
Static events do not currently work post-relocation for boards that enable
CONFIG_NEEDS_MANUAL_RELOC. Relocate event handler pointers for all event
spies to fix this.
Tested on Microblaze.
Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
---
common/board_r.c | 3 +++
common/event.c | 15 +++++++++++++++
include/event.h | 10 ++++++++++
3 files changed, 28 insertions(+)
diff --git a/common/board_r.c b/common/board_r.c
index 6f4aca2077..01a1728c3f 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -612,6 +612,9 @@ static init_fnc_t init_sequence_r[] = {
*/
#endif
initr_reloc_global_data,
+#if CONFIG_IS_ENABLED(NEEDS_MANUAL_RELOC) && CONFIG_IS_ENABLED(EVENT)
+ event_manual_reloc,
+#endif
#if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
initr_unlock_ram_in_cache,
#endif
diff --git a/common/event.c b/common/event.c
index 063647447d..af1ed4121d 100644
--- a/common/event.c
+++ b/common/event.c
@@ -17,6 +17,7 @@
#include <malloc.h>
#include <asm/global_data.h>
#include <linux/list.h>
+#include <relocate.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -148,6 +149,20 @@ void event_show_spy_list(void)
}
}
+#if CONFIG_IS_ENABLED(NEEDS_MANUAL_RELOC)
+int event_manual_reloc(void)
+{
+ struct evspy_info *spy, *end;
+
+ spy = ll_entry_start(struct evspy_info, evspy_info);
+ end = ll_entry_end(struct evspy_info, evspy_info);
+ for (; spy < end; spy++)
+ MANUAL_RELOC(spy->func);
+
+ return 0;
+}
+#endif
+
#if CONFIG_IS_ENABLED(EVENT_DYNAMIC)
static void spy_free(struct event_spy *spy)
{
diff --git a/include/event.h b/include/event.h
index 62e72a7bd3..a8f0c3fa2b 100644
--- a/include/event.h
+++ b/include/event.h
@@ -144,6 +144,16 @@ int event_register(const char *id, enum event_t type, event_handler_t func,
/** event_show_spy_list( - Show a list of event spies */
void event_show_spy_list(void);
+/**
+ * event_manual_reloc() - Relocate event handler pointers
+ *
+ * Relocate event handler pointers for all static event spies. It is called
+ * during the generic board init sequence, after relocation.
+ *
+ * Return: 0 if OK
+ */
+int event_manual_reloc(void);
+
#if CONFIG_IS_ENABLED(EVENT)
/**
* event_notify() - notify spies about an event
--
2.25.1
next prev parent reply other threads:[~2022-05-15 18:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-15 18:40 [PATCH 1/2] event: remove CONFIG_EVENT_DYNAMIC check in event_register() Ovidiu Panait
2022-05-15 18:40 ` Ovidiu Panait [this message]
2022-06-07 16:46 ` [PATCH 2/2] event: fix static events for CONFIG_NEEDS_MANUAL_RELOC Tom Rini
2022-06-07 16:46 ` [PATCH 1/2] event: remove CONFIG_EVENT_DYNAMIC check in event_register() Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220515184029.2169025-2-ovpanait@gmail.com \
--to=ovpanait@gmail.com \
--cc=dsankouski@gmail.com \
--cc=rick@andestech.com \
--cc=sjg@chromium.org \
--cc=tharvey@gateworks.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).