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 74139C433EF for ; Tue, 31 May 2022 18:15:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6C5608429D; Tue, 31 May 2022 20:15:14 +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="T04CLdWk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 68D9B83F33; Tue, 31 May 2022 20:15:12 +0200 (CEST) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (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 F0F7F83E3C for ; Tue, 31 May 2022 20:14:50 +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-wr1-x436.google.com with SMTP id t6so19784630wra.4 for ; Tue, 31 May 2022 11:14:50 -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=ov627HCEiQBkpzWT+vqjWJFv1D0Z+SprVm4R6AUZlng=; b=T04CLdWkGHMW/3ILm7D0lJZ5S5kz1/BwGe1l3vEC7+JBXR+YCi/zLWB3YyJiwZulvc 7o5m42DETFY5OXTeWxfWFZYLx0ceNNJiZA3Ap6gbg5utXlLn6zi9Qca9MA3oU0oAJzVV lS05v45oKeA89O+DtCVicmjH97ixPCERZgHTqcLWn9t33cH0I44hypdDPYe6jaMjcYxB tBQF705+O0b7hq4Jti7QjH3x1/FbIdPSqRzj6wYH7a3u8DNr4GvwuEnl0Gc8OV9SK4i4 HCjejwkEz2mbfyMWHiP29DsKivjK12Vvil6JY8PkGzTnO1wzWf9Da78XR3N2/OmIFOHO BVhg== 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=ov627HCEiQBkpzWT+vqjWJFv1D0Z+SprVm4R6AUZlng=; b=J6PPUBlZ7fDkfJ0ywe8LuIqMdq6s+dsiSXJgTV3aRHVLDlOOVEMro86xaWFJIcPbdK /U9Y5WClc73Rm0UDOQ1bQaU/mKM0CdUHBK9JcYw+par4v/5jiqzr/EN08lx++4UbYFbh rohUiWLfsmKYVsdal6OMXwQM94ZlcJu+HfVmkV5UYiq++gGCrIEHjrDqgnxc3SoB+CJN n2YiHhBTUjDwB22ve1HWIuRx+CYe/K9ue19ssHjtKG+xGpwY2J+ePZw83gpekZKQTaZk A1pNyP3LkkUFoKJQVO64yqQIeZ5bDR3fYKd2/kNiGEvtpfdbbdJ+UJ2p6a8n9pi1O0JH nF2g== X-Gm-Message-State: AOAM532nVFPshbaklypZUqsm3HwbmxrqyYAGZNCb/5TqDqqZlqdUNdp0 nYcQeQY5IGUuisEZdWOsL+U03G1wrHE= X-Google-Smtp-Source: ABdhPJyLa4kYAFf0p0qdKpvxAqfsiTUNNnHCHOTPmVU9eipUaP150xiUHRYrAfNF2vWar23mmX+HcQ== X-Received: by 2002:a5d:4906:0:b0:20f:fc2a:987a with SMTP id x6-20020a5d4906000000b0020ffc2a987amr26819600wrq.228.1654020890460; Tue, 31 May 2022 11:14:50 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c003:7c00:45d1:29c0:7802:f752]) by smtp.gmail.com with ESMTPSA id l3-20020a1c7903000000b003974027722csm2682980wme.47.2022.05.31.11.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 11:14:50 -0700 (PDT) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: monstr@monstr.eu, Ovidiu Panait , Patrick Delaunay , Simon Glass Subject: [PATCH v2 02/14] cpu-uclass: relocate ops pointers for CONFIG_NEEDS_MANUAL_RELOC Date: Tue, 31 May 2022 21:14:23 +0300 Message-Id: <20220531181435.3473549-2-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220531181435.3473549-1-ovpanait@gmail.com> References: <20220531181435.3473549-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 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 --- 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 #include #include +#include + +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