From patchwork Mon Jul 6 03:37:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1323257 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=n14TG5yi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B0WWg5x16z9sR4 for ; Mon, 6 Jul 2020 13:38:55 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6CCB981BE8; Mon, 6 Jul 2020 05:37:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="n14TG5yi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 96AF881BF0; Mon, 6 Jul 2020 05:37:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 D35F681BC0 for ; Mon, 6 Jul 2020 05:37:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id f23so37903667iof.6 for ; Sun, 05 Jul 2020 20:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IGMKzg7vsLNO2faaWG5NNzJulyqeTy85imAcUrqmKLE=; b=n14TG5yisdfQDBiFR4as9YmFUW6pNdd9Mhs7smzhnV77j4FJDOS126RxkMxoBQJbpS gLig1VRceHOVXzliTTu+HT93C8WvjBD+itnMsrumxSSBKV5LX8H3Fn1gALM2vOzLo9Pw Gi/bJrPzgLtWuTQQYtykcKXKTP3BDBNd/WU2A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IGMKzg7vsLNO2faaWG5NNzJulyqeTy85imAcUrqmKLE=; b=OKvoOI9/u85UaNzCBYJ+mNSl3y8gHLYZoW41VGJwtfLb8t2kFxSwK41ZsV8yN5Y20R wvSZPL9/YBmA1Xb+QXg64YsjN1ow9H0s8z1JKpm7Q8VLsQA9nnJTOmQ05ElziKqq6N91 qi+fKzRUUpeYtimXqDBC4zEa6k+CA0Z/CinfLTOwrEaXC8S7YhTIl1iNJ/XeDQ50vLyc K35l4xqVPfNsr60v9P+cmeDfT4lhyvNL2tiawfMB7Za3b8l8AXWXconMRFS2bVZD5x6U AtOuRQw1Ho9pgDa8uY4RYb1cLxKXKMi3PG/Ahod1biKH+GPHOyiqLvhyNSHNg5L9IgZ6 Wtag== X-Gm-Message-State: AOAM533hbMIo4j9tkoUbkiWNkRE5Ch4kclnobLGlMnNCXzSxiBrq1SvS iPBaw92tqhc/vlMAs0awmTWk0LgIuDo9Ww== X-Google-Smtp-Source: ABdhPJxyOCBJxVDJ7jJKBIg3oPR416v7x1DmB1hXJzqRkqF1zJpKAtnuBbzv4XhQK3H1K8KJU22pFw== X-Received: by 2002:a6b:9246:: with SMTP id u67mr23283635iod.51.1594006670611; Sun, 05 Jul 2020 20:37:50 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id v16sm10163631iow.19.2020.07.05.20.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 20:37:50 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Andy Shevchenko , Wolfgang Wallner , Simon Glass Subject: [PATCH v3 05/25] x86: mp_init: Drop the num_cpus static variable Date: Sun, 5 Jul 2020 21:37:21 -0600 Message-Id: <20200706033741.2169374-6-sjg@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200706033741.2169374-1-sjg@chromium.org> References: <20200706033741.2169374-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean This does not need to be global across all functions in this file. Pass a parameter instead. Signed-off-by: Simon Glass Reviewed-by: Wolfgang Wallner Reviewed-by: Bin Meng --- Changes in v3: - Update bsp_do_flight_plan() to say 'on the BSP' arch/x86/cpu/mp_init.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/arch/x86/cpu/mp_init.c b/arch/x86/cpu/mp_init.c index 8b00d57c88..df43f71572 100644 --- a/arch/x86/cpu/mp_init.c +++ b/arch/x86/cpu/mp_init.c @@ -31,9 +31,6 @@ DECLARE_GLOBAL_DATA_PTR; -/* Total CPUs include BSP */ -static int num_cpus; - /* This also needs to match the sipi.S assembly code for saved MSR encoding */ struct saved_msr { uint32_t index; @@ -384,13 +381,23 @@ static int start_aps(int num_aps, atomic_t *ap_count) return 0; } -static int bsp_do_flight_plan(struct udevice *cpu, struct mp_flight_plan *plan) +/** + * bsp_do_flight_plan() - Do the flight plan on the BSP + * + * This runs the flight plan on the main CPU used to boot U-Boot + * + * @cpu: Device for the main CPU + * @plan: Flight plan to run + * @num_aps: Number of APs (CPUs other than the BSP) + * @returns 0 on success, -ETIMEDOUT if an AP failed to come up + */ +static int bsp_do_flight_plan(struct udevice *cpu, struct mp_flight_plan *plan, + int num_aps) { int i; int ret = 0; const int timeout_us = 100000; const int step_us = 100; - int num_aps = num_cpus - 1; for (i = 0; i < plan->num_records; i++) { struct mp_flight_record *rec = &plan->records[i]; @@ -410,6 +417,7 @@ static int bsp_do_flight_plan(struct udevice *cpu, struct mp_flight_plan *plan) release_barrier(&rec->barrier); } + return ret; } @@ -454,7 +462,7 @@ static struct mp_flight_record mp_steps[] = { int mp_init(void) { - int num_aps; + int num_aps, num_cpus; atomic_t *ap_count; struct udevice *cpu; int ret; @@ -516,7 +524,7 @@ int mp_init(void) } /* Walk the flight plan for the BSP */ - ret = bsp_do_flight_plan(cpu, &mp_info); + ret = bsp_do_flight_plan(cpu, &mp_info, num_aps); if (ret) { debug("CPU init failed: err=%d\n", ret); return ret;