Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A31AFC433EF for ; Sun, 15 May 2022 18:40:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E48EF83FEC; Sun, 15 May 2022 20:40:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aDZ4lYRG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 861A383FAA; Sun, 15 May 2022 20:40:38 +0200 (CEST) Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AD06283EB0 for ; Sun, 15 May 2022 20:40:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ovpanait@gmail.com Received: by mail-ej1-x630.google.com with SMTP id ks9so24890858ejb.2 for ; Sun, 15 May 2022 11:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NQgQmnZCZU5Kr4zKC4eO9V+2ZuNZC7jb9pBZHTHYJdI=; b=aDZ4lYRGyucu0SgX8hUI/18XbDI2A/fDfQYGb4yjWRgdY65NesbRkA/TozULcnYofD aJWEykfVvM/ywNYXysAI8Ho1StdV2qPXA9CEWeMaF8TEcn580tk+tqrPFLrDOlo6rIlE nXVeCQp86sArBZmBrSBTIPWFI3AQtveBbpqWnhzueLtlffFSPKbVWkA2ZYIAV+3vXvep 0tWr6Awwc3O0PV6jbl2wrmH0RlQVZHjvNEDhyiClabtlL4jXaz6H3CQimNOFjzmEtsYY Ie1n3CG+oPUiPjLvJ6TCsa+6Hn9Jci3Kfy2dFt6tijad4ugC8Ne8AEyNzSLcdwUWAqx6 g20Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NQgQmnZCZU5Kr4zKC4eO9V+2ZuNZC7jb9pBZHTHYJdI=; b=4gH0tYr3wQ5qr97EwjXq2q8IH5VRcGwrH+Hd7/LX7A0ehoST9v5GAHDl1uG848JDMZ 1LCiWqtjgVZatOYSJIAmH1lq4oqita28QCFonWUIi/pFCzq7kAHMu5BYp8vAxYqvaQ2m PxCWQsRpBJADuxSELR9CHq7KWiw1fO6j64D15y08MF81OqJ0StWJcLw8Z/OICMEk1qAL kP5GIAm4xHG1eJTe5rXi1me/BzerT6wmfl77YlPBWdHM8oSO6ma3Vk61EUMglU7miXNq Ey4vsih0PhjSG+kUdtmss13Q3xKf/UqF8octg3ufx4mlS+rNKLyzQX2e4sZIF//f2pUf 2Aew== X-Gm-Message-State: AOAM533b67gMHEewACy0UsH9W88sKcSQxk/X3I8v93C839NIAkeZJhpy gVb6HlDDtXS7tM1bDVC2F86agpnf7cc19Q== X-Google-Smtp-Source: ABdhPJyNH02EwgSPzjczuXgSaK8MMYB/Ku92o5xix3vg5G+5PRre3gedwzDFi6bUj9t2V1Y+9B3FUQ== X-Received: by 2002:a17:907:2d8e:b0:6f4:92ad:e38a with SMTP id gt14-20020a1709072d8e00b006f492ade38amr12589650ejc.365.1652640035261; Sun, 15 May 2022 11:40:35 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f07:610c:b900:8a2a:17d4:f466:481d]) by smtp.gmail.com with ESMTPSA id zp16-20020a17090684f000b006f3ef214e16sm2873458ejb.124.2022.05.15.11.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 May 2022 11:40:34 -0700 (PDT) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: Ovidiu Panait , Dzmitry Sankouski , Heinrich Schuchardt , Rick Chen , Simon Glass , Tim Harvey Subject: [PATCH 2/2] event: fix static events for CONFIG_NEEDS_MANUAL_RELOC Date: Sun, 15 May 2022 21:40:29 +0300 Message-Id: <20220515184029.2169025-2-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220515184029.2169025-1-ovpanait@gmail.com> References: <20220515184029.2169025-1-ovpanait@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 --- 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 #include #include +#include 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