From nobody Tue Feb 10 03:40:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) client-ip=209.85.221.67; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f67.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1600675001; cv=none; d=zohomail.com; s=zohoarc; b=IM8rcWww5bLPLXUgfDm7G1mfSCd91WYelqPgbwCdH0IeH1Pe9lylhB1uO0CeYAQkJuDOKQViRMVqT2ZhY3IjEFsZBWmAS/m9CbkjklwLpnaw+LeVN0gBZSyYDvr0IHXjcgS8bpsHefefwBWAswpFq0dJWeX0YyRwspiPpSlpm1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600675001; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3cUAmcXEySvZuiPUDhUwrBrWEw0aliYA7aOM+n1UWOI=; b=QiSD/bUpfLoZQqqvF3CKZMcEt0wFe20GRH4KiVVtkfd8UHBIO1orOU+mh++WA+OcXMNZgehW4RnINErB0nP0inTOS+WCOuuKkFDGB18VFCcZoBCsfWYrWNAUQ8MUN4sOdWao5G6Hv3W+tCvTsgNo/prrcx4/p2WI5s94Tv5aj+c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.zohomail.com with SMTPS id 160067500143646.297574708450384; Mon, 21 Sep 2020 00:56:41 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id z4so11644427wrr.4 for ; Mon, 21 Sep 2020 00:56:40 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (65.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.65]) by smtp.gmail.com with ESMTPSA id o15sm17807538wmh.29.2020.09.21.00.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 00:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3cUAmcXEySvZuiPUDhUwrBrWEw0aliYA7aOM+n1UWOI=; b=HHGnt+RFag9XZfkWzme5pKMLKAPNbLZq1vHaYb2qtu+SFuxHrDXFvaz3DELv/QkAnk 3Y74UyD9FYSZZXOW32Al4PVpx6coBMzUUlB5rXR9DY1MEkc9yliI9D6bMBamMtLrwlBg cBZ9qnuA1VX16P2t9zB27TTJDy2Gc86hcgGVedGlSiIDlY24HIRRe7dxzV8bAYMesxCL Gdcrr7HR51fxftvwjXNoGOD0Dfxnjzm8na99RtXDUO1geAN1Glumrqea8QiH5+CA37rz /GaGcyLk0FsEfykRgqEwFapqYMamvd8MCnry759Uh/0kiA9Q06uc5PI2rmhWCq1H2Fd6 Obdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3cUAmcXEySvZuiPUDhUwrBrWEw0aliYA7aOM+n1UWOI=; b=ZxtywnGpNZ+8klupgTPJ2iFT4LtmOsClQ5maoeu/57m3uAOYfS7yhNEsBesV0ws+hT 33Zbl2y589t5Sc12DHm67mZzvSJTRbsrxZQ+nPynGiJnbE+henmi1Kn3bYJ3hxBctC/c JkNh2MuQFyVtZqiqqLjkMzap5v3WV3Wsz2pE1w0UnBzRkhAYUa6didow/BucfCngl7SC DEL1AGTEDxRIdcLB5JdyovjmhXabOPWB6uCHBHlwPzvhlTFqn9TIikEv/cx/KDTnEDV0 qiZeV99yi4AIEyAbTT0H6I06XU+E+SzWKL0t8S78puSK034Q0RfyfDKNjbD/lWcvH/jM vYiw== X-Gm-Message-State: AOAM533EjusMElb4dWCyDIbvPpKw9escneKM2iFc1KuYAL3NaqsOyg+4 2TIJOc8DITHQKlUnKoBLufU= X-Google-Smtp-Source: ABdhPJyYhBHjfebxHKTyJVFY+HdnLw1Z/14Lys9WpMdXMRbXNFVqgci3j600qn/bWT8Imrxom2LVeg== X-Received: by 2002:a5d:60c6:: with SMTP id x6mr19007867wrt.157.1600674999332; Mon, 21 Sep 2020 00:56:39 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paul Zimmerman , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel , Andrew Baumann , qemu-arm@nongnu.org Subject: [PATCH v3 8/8] hw/arm/raspi: Remove use of the 'version' value in the board code Date: Mon, 21 Sep 2020 09:56:28 +0200 Message-Id: <20200921075628.466506-9-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200921075628.466506-1-f4bug@amsat.org> References: <20200921075628.466506-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) We expected the 'version' ID to match the board processor ID, but this is not always true (for example boards with revision id 0xa02042/0xa22042 are Raspberry Pi 2 with a BCM2837 SoC). This was not important because we were not modelling them, but since the recent refactor now allow to model these boards, it is safer to check the processor id directly. Remove the version check. Suggested-by: Peter Maydell Reviewed-by: Luc Michel Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/raspi.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index ae98a2fbfca..b5b30f0f38f 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -98,11 +98,6 @@ static RaspiProcessorId board_processor_id(uint32_t boar= d_rev) return proc_id; } =20 -static int board_version(uint32_t board_rev) -{ - return board_processor_id(board_rev) + 1; -} - static const char *board_soc_type(uint32_t board_rev) { return soc_property[board_processor_id(board_rev)].type; @@ -201,7 +196,8 @@ static void reset_secondary(ARMCPU *cpu, const struct a= rm_boot_info *info) cpu_set_pc(cs, info->smp_loader_start); } =20 -static void setup_boot(MachineState *machine, int version, size_t ram_size) +static void setup_boot(MachineState *machine, RaspiProcessorId processor_i= d, + size_t ram_size) { RaspiMachineState *s =3D RASPI_MACHINE(machine); int r; @@ -210,12 +206,13 @@ static void setup_boot(MachineState *machine, int ver= sion, size_t ram_size) s->binfo.ram_size =3D ram_size; s->binfo.nb_cpus =3D machine->smp.cpus; =20 - if (version <=3D 2) { - /* The rpi1 and 2 require some custom setup code to run in Secure - * mode before booting a kernel (to set up the SMC vectors so - * that we get a no-op SMC; this is used by Linux to call the + if (processor_id <=3D PROCESSOR_ID_BCM2836) { + /* + * The BCM2835 and BCM2836 require some custom setup code to run + * in Secure mode before booting a kernel (to set up the SMC vecto= rs + * so that we get a no-op SMC; this is used by Linux to call the * firmware for some cache maintenance operations. - * The rpi3 doesn't need this. + * The BCM2837 doesn't need this. */ s->binfo.board_setup_addr =3D BOARDSETUP_ADDR; s->binfo.write_board_setup =3D write_board_setup; @@ -223,10 +220,10 @@ static void setup_boot(MachineState *machine, int ver= sion, size_t ram_size) s->binfo.secure_boot =3D true; } =20 - /* Pi2 and Pi3 requires SMP setup */ - if (version >=3D 2) { + /* BCM2836 and BCM2837 requires SMP setup */ + if (processor_id >=3D PROCESSOR_ID_BCM2836) { s->binfo.smp_loader_start =3D SMPBOOT_ADDR; - if (version =3D=3D 2) { + if (processor_id =3D=3D PROCESSOR_ID_BCM2836) { s->binfo.write_secondary_boot =3D write_smpboot; } else { s->binfo.write_secondary_boot =3D write_smpboot64; @@ -260,7 +257,6 @@ static void raspi_machine_init(MachineState *machine) RaspiMachineClass *mc =3D RASPI_MACHINE_GET_CLASS(machine); RaspiMachineState *s =3D RASPI_MACHINE(machine); uint32_t board_rev =3D mc->board_rev; - int version =3D board_version(board_rev); uint64_t ram_size =3D board_ram_size(board_rev); uint32_t vcram_size; DriveInfo *di; @@ -301,7 +297,8 @@ static void raspi_machine_init(MachineState *machine) =20 vcram_size =3D object_property_get_uint(OBJECT(&s->soc), "vcram-size", &error_abort); - setup_boot(machine, version, machine->ram_size - vcram_size); + setup_boot(machine, board_processor_id(mc->board_rev), + machine->ram_size - vcram_size); } =20 static void raspi_machine_class_common_init(MachineClass *mc, --=20 2.26.2