From patchwork Mon Aug 14 08:54:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 135280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2627573vqi; Mon, 14 Aug 2023 02:40:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQ5o38mku8ql9nnQ03uxkngs9ezPWVC316fNJn7Ll06Z+jmYayCQ0HiF+KWoJI4nahhz5M X-Received: by 2002:aa7:cc0e:0:b0:523:48d7:70b1 with SMTP id q14-20020aa7cc0e000000b0052348d770b1mr6679327edt.19.1692006041449; Mon, 14 Aug 2023 02:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692006041; cv=none; d=google.com; s=arc-20160816; b=pQwvA+BOJM4B2DT1GQ2UB1MOWIJe/IVtNHPdDl0nGXYlsRxtFvbbKVNQvytqgoCK6e is5RKhkPjIEAXr7LXAVhyKjLzLL5H9ux0Oft2KcZKyCy23WbZGICPBWr9Oo/uNy1Z3BJ MrZHWYLSj0SSDh/0PHLU7VvR4WasB7pxoGXTAqGHETL3Ad6DlrH/G13QEBFv4Gk0AJVL BeOVnq5B6lY8k2mzdVqKv3A+1nGPJQjSOMpA4ss1ZZmvzO5LLcXjimnSQ2sQOx4e6THm Ve5H5y/KFZqS4MJ9KBO/EqvkTFrUz2waVhBaJm9wnIk89Er45MuDYpLyCwcoCuy8fjsZ Q3DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=0PoVb6rqRl+3XDmFLX4OhuCpuMKU4+OQIAfP3H7EqAk=; fh=vmKIJtcbtoHWhyuxI4oEq8r1SWZ2V9Rrbp1Orw2DxqA=; b=kgCNRxc7T+gZV9AieDqXmF3RFR3vm4n2xzB0w6yC+iJy0bTcC6yRUjOF+4oF530rid 8oFwxCiXIKIKdqdHljOkDtNakBxyUcrKQjCi5/n7OJLgotaqpQR2UkVpo3rxnV7+b1cv LdpereXxxw7ddNCJcLMD64pNy0+SILTqQ7Bdo123UedF1GYnoJk023qxMV/ZTXbLCWgG 5tuEgptEKLhp6NdFAwwcsUtMVPApAwIMd+8hf2iIY1BqrHOGYXSiwiQXov0isASTxrxh w31wdDm7sFsPiHUcWAXv7DlahdlFeg9Z47yJOyVPz8u/oC83q2lEo4E9+jjrBD07Sriz sIAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NZ4I7uW7; dkim=neutral (no key) header.i=@linutronix.de header.b=PqMlJ9MH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020aa7c6c3000000b0052337f4402asi7874748eds.474.2023.08.14.02.40.17; Mon, 14 Aug 2023 02:40:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NZ4I7uW7; dkim=neutral (no key) header.i=@linutronix.de header.b=PqMlJ9MH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235085AbjHNIzB (ORCPT + 99 others); Mon, 14 Aug 2023 04:55:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234966AbjHNIyD (ORCPT ); Mon, 14 Aug 2023 04:54:03 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90FDA10C for ; Mon, 14 Aug 2023 01:54:02 -0700 (PDT) Message-ID: <20230814085113.054064391@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1692003241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=0PoVb6rqRl+3XDmFLX4OhuCpuMKU4+OQIAfP3H7EqAk=; b=NZ4I7uW72RvN4r52jupLg6yEbY/xeziDeEZ7d0VX5ovMT2oy70KGafFdmRSjVH9r4TPLiS 9ftDRVMHRn3mA2uunb8yBVMmW5d69q9Cb+Fw3Pbh/qENuRIr7Ckz2jBKVi1I+wZbDQ82Lf j01GlWAuzJxAtvlovi/94wQXYbtufy2Q/QOP1Z1zACnjYQtIeKCYZouMAkUhoBspXNv1u5 zVe4odVYPytqPU5QulPBs7QCMjAd+Ijns5hbeRdjxZv10HX9qkWrMMQhe6vL3A4mY0iYdu XL3oGe0y7tTdZLPMWBkuZWccI0pyWPLWKUEL9KUqqb4dCEE10v0KqjebNm5qyg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1692003241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=0PoVb6rqRl+3XDmFLX4OhuCpuMKU4+OQIAfP3H7EqAk=; b=PqMlJ9MHaYDJyJXoDogrDMo8iQLesd+Oaak3bL8C/fyi1ZktkoM7jV5lHKZia2BNpVSDwY THS71yiXWrEk76BQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , Huang Rui , Juergen Gross , Dimitri Sivanich , Michael Kelley , Wei Liu , Pu Wen , Qiuxu Zhuo , Sohil Mehta Subject: [patch V4 17/41] x86/apic: Use u32 for cpu_present_to_apicid() References: <20230814085006.593997112@linutronix.de> MIME-Version: 1.0 Date: Mon, 14 Aug 2023 10:54:00 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774196927013709044 X-GMAIL-MSGID: 1774196927013709044 APIC IDs are used with random data types u16, u32, int, unsigned int, unsigned long. Make it all consistently use u32 because that reflects the hardware register width and fixup a few related usage sites for consistency sake. Signed-off-by: Thomas Gleixner Tested-by: Juergen Gross Tested-by: Sohil Mehta Tested-by: Michael Kelley Reviewed-by: Arjan van de Ven --- arch/x86/include/asm/apic.h | 4 ++-- arch/x86/kernel/apic/apic_common.c | 2 +- arch/x86/kernel/cpu/common.c | 3 ++- arch/x86/kernel/smpboot.c | 10 +++++----- arch/x86/xen/apic.c | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -295,7 +295,7 @@ struct apic { bool (*check_apicid_used)(physid_mask_t *map, u32 apicid); void (*init_apic_ldr)(void); void (*ioapic_phys_id_map)(physid_mask_t *phys_map, physid_mask_t *retmap); - int (*cpu_present_to_apicid)(int mps_cpu); + u32 (*cpu_present_to_apicid)(int mps_cpu); int (*phys_pkg_id)(int cpuid_apic, int index_msb); u32 (*get_apic_id)(unsigned long x); @@ -539,7 +539,7 @@ extern u32 apic_default_calc_apicid(unsi extern u32 apic_flat_calc_apicid(unsigned int cpu); extern void default_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap); -extern int default_cpu_present_to_apicid(int mps_cpu); +extern u32 default_cpu_present_to_apicid(int mps_cpu); #else /* CONFIG_X86_LOCAL_APIC */ --- a/arch/x86/kernel/apic/apic_common.c +++ b/arch/x86/kernel/apic/apic_common.c @@ -28,7 +28,7 @@ void default_ioapic_phys_id_map(physid_m *retmap = *phys_map; } -int default_cpu_present_to_apicid(int mps_cpu) +u32 default_cpu_present_to_apicid(int mps_cpu) { if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu)) return (int)per_cpu(x86_cpu_to_apicid, mps_cpu); --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1747,7 +1747,8 @@ static void generic_identify(struct cpui static void validate_apic_and_package_id(struct cpuinfo_x86 *c) { #ifdef CONFIG_SMP - unsigned int apicid, cpu = smp_processor_id(); + unsigned int cpu = smp_processor_id(); + u32 apicid; apicid = apic->cpu_present_to_apicid(cpu); --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -816,7 +816,7 @@ static void __init smp_quirk_init_udelay /* * Wake up AP by INIT, INIT, STARTUP sequence. */ -static void send_init_sequence(int phys_apicid) +static void send_init_sequence(u32 phys_apicid) { int maxlvt = lapic_get_maxlvt(); @@ -842,7 +842,7 @@ static void send_init_sequence(int phys_ /* * Wake up AP by INIT, INIT, STARTUP sequence. */ -static int wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) +static int wakeup_secondary_cpu_via_init(u32 phys_apicid, unsigned long start_eip) { unsigned long send_status = 0, accept_status = 0; int num_starts, j, maxlvt; @@ -989,7 +989,7 @@ int common_cpu_up(unsigned int cpu, stru * Returns zero if startup was successfully sent, else error code from * ->wakeup_secondary_cpu. */ -static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) +static int do_boot_cpu(u32 apicid, int cpu, struct task_struct *idle) { unsigned long start_ip = real_mode_header->trampoline_start; int ret; @@ -1057,7 +1057,7 @@ static int do_boot_cpu(int apicid, int c int native_kick_ap(unsigned int cpu, struct task_struct *tidle) { - int apicid = apic->cpu_present_to_apicid(cpu); + u32 apicid = apic->cpu_present_to_apicid(cpu); int err; lockdep_assert_irqs_enabled(); @@ -1250,7 +1250,7 @@ void arch_thaw_secondary_cpus_end(void) bool smp_park_other_cpus_in_init(void) { unsigned int cpu, this_cpu = smp_processor_id(); - unsigned int apicid; + u32 apicid; if (apic->wakeup_secondary_cpu_64 || apic->wakeup_secondary_cpu) return false; --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -115,7 +115,7 @@ static int xen_phys_pkg_id(int initial_a return initial_apic_id >> index_msb; } -static int xen_cpu_present_to_apicid(int cpu) +static u32 xen_cpu_present_to_apicid(int cpu) { if (cpu_present(cpu)) return cpu_data(cpu).topo.apicid;