All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ovidiu Panait <ovpanait@gmail.com>
To: u-boot@lists.denx.de
Cc: monstr@monstr.eu, Ovidiu Panait <ovpanait@gmail.com>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Simon Glass <sjg@chromium.org>
Subject: [PATCH v2 02/14] cpu-uclass: relocate ops pointers for CONFIG_NEEDS_MANUAL_RELOC
Date: Tue, 31 May 2022 21:14:23 +0300	[thread overview]
Message-ID: <20220531181435.3473549-2-ovpanait@gmail.com> (raw)
In-Reply-To: <20220531181435.3473549-1-ovpanait@gmail.com>

Relocate cpu_ops pointers when CONFIG_NEEDS_MANUAL_RELOC is enabled.

The (gd->flags & GD_FLG_RELOC) check was added to make sure the reloc_done
logic works for drivers that use DM_FLAG_PRE_RELOC.

Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
---

Changes in v2:
- New patch.

 drivers/cpu/cpu-uclass.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c
index a5cda6a62c..71e5900d70 100644
--- a/drivers/cpu/cpu-uclass.c
+++ b/drivers/cpu/cpu-uclass.c
@@ -14,6 +14,9 @@
 #include <dm/lists.h>
 #include <dm/root.h>
 #include <linux/err.h>
+#include <relocate.h>
+
+DECLARE_GLOBAL_DATA_PTR;
 
 int cpu_probe_all(void)
 {
@@ -136,9 +139,36 @@ static int uclass_cpu_init(struct uclass *uc)
 	return ret;
 }
 
+static int uclass_cpu_post_bind(struct udevice *dev)
+{
+	if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC) &&
+	    (gd->flags & GD_FLG_RELOC)) {
+		struct cpu_ops *ops = cpu_get_ops(dev);
+		static int reloc_done;
+
+		if (!reloc_done) {
+			if (ops->get_desc)
+				MANUAL_RELOC(ops->get_desc);
+			if (ops->get_info)
+				MANUAL_RELOC(ops->get_info);
+			if (ops->get_count)
+				MANUAL_RELOC(ops->get_count);
+			if (ops->get_vendor)
+				MANUAL_RELOC(ops->get_vendor);
+			if (ops->is_current)
+				MANUAL_RELOC(ops->is_current);
+
+			reloc_done++;
+		}
+	}
+
+	return 0;
+}
+
 UCLASS_DRIVER(cpu) = {
 	.id		= UCLASS_CPU,
 	.name		= "cpu",
 	.flags		= DM_UC_FLAG_SEQ_ALIAS,
 	.init		= uclass_cpu_init,
+	.post_bind	= uclass_cpu_post_bind,
 };
-- 
2.25.1


  reply	other threads:[~2022-05-31 18:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-31 18:14 [PATCH v2 01/14] cmd: cpu: migrate cpu command to U_BOOT_CMD_WITH_SUBCMDS() Ovidiu Panait
2022-05-31 18:14 ` Ovidiu Panait [this message]
2022-05-31 18:14 ` [PATCH v2 03/14] microblaze: start.S: remove unused code Ovidiu Panait
2022-05-31 18:14 ` [PATCH v2 04/14] microblaze: cache: replace XILINX_USE_DCACHE -> CONFIG_DCACHE Ovidiu Panait
2022-05-31 18:14 ` [PATCH v2 05/14] microblaze: cache: improve dcache Kconfig options Ovidiu Panait
2022-05-31 18:14 ` [PATCH v2 06/14] microblaze: cache: improve icache " Ovidiu Panait
2022-05-31 18:14 ` [PATCH v2 07/14] microblaze: cache: split flush_cache() function Ovidiu Panait
2022-05-31 18:14 ` [PATCH v2 08/14] microblaze: cache: introduce Kconfig options for icache/dcache sizes Ovidiu Panait
2022-05-31 18:14 ` [PATCH v2 09/14] microblaze: cache: introduce flush_cache_all() Ovidiu Panait
2022-05-31 18:14 ` [PATCH v2 10/14] microblaze: cache: introduce cpuinfo structure Ovidiu Panait
2022-06-07  8:40   ` Michal Simek
2022-05-31 18:14 ` [PATCH v2 11/14] microblaze: cache: introduce flush_dcache_range() Ovidiu Panait
2022-05-31 18:14 ` [PATCH v2 12/14] microblaze: Kconfig: introduce XILINX_MICROBLAZE0_FPGA_FAMILY option Ovidiu Panait
2022-05-31 18:14 ` [PATCH v2 13/14] microblaze: add support for handling PVR data Ovidiu Panait
2022-05-31 18:14 ` [PATCH v2 14/14] cpu: add CPU driver for microblaze Ovidiu Panait
2022-06-07  8:33 ` [PATCH v2 01/14] cmd: cpu: migrate cpu command to U_BOOT_CMD_WITH_SUBCMDS() Michal Simek
2022-06-07  9:55   ` Ovidiu Panait

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=20220531181435.3473549-2-ovpanait@gmail.com \
    --to=ovpanait@gmail.com \
    --cc=monstr@monstr.eu \
    --cc=patrick.delaunay@foss.st.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.