From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 361A6C2BA83 for ; Sat, 15 Feb 2020 19:18:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0822D206D6 for ; Sat, 15 Feb 2020 19:18:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WAlitRsd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0822D206D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j32xh-0005bX-6O for qemu-devel@archiver.kernel.org; Sat, 15 Feb 2020 14:18:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35268) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j32uw-0008KM-Pp for qemu-devel@nongnu.org; Sat, 15 Feb 2020 14:15:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j32uv-0004GR-CE for qemu-devel@nongnu.org; Sat, 15 Feb 2020 14:15:54 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j32uv-0004Fy-5b; Sat, 15 Feb 2020 14:15:53 -0500 Received: by mail-wr1-x444.google.com with SMTP id k11so14895819wrd.9; Sat, 15 Feb 2020 11:15:53 -0800 (PST) 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=vgwXjH0kKbScO8AvLlOooEIEzKYchoKqFxh3C7QVSgQ=; b=WAlitRsdK6XnOlQKldpaZlsLFM9ctdqv5lYmOk/dewrTKLt09P0W9wnfioy/qL6Unt Z07m2DLtrzRm3gFpbL0WCMiUEcciscTZthcOqCAM5zP/PkeW4v1lC/CqoPbanoNyfWet 0X4FkiNt4APsKFwDeKKs2oXbNjtgZxkV7dz5/JFcEXO1DwHubFUghODGFAshrS1NkcE0 FXnYkTV92PITd86nLz2wcu/01g+uBU7P/WjE7G1ZOaDfcuXVzI19tTLbOXhBLaHptv5F fWQsJZu+qYD9lXZrDgTLEwi9oCIapbYJf30sGbbDfVqF49sFrTfN2PGftskrJ/mu8laV UMhw== 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=vgwXjH0kKbScO8AvLlOooEIEzKYchoKqFxh3C7QVSgQ=; b=lwPQ/dvBhbXlUF0FVyeAReS7uUiqtstY3terr42K3yV2cBWCjnEX/eZPgTw5BjCx1w 82NcXYbCYYQtVKwIhvG4qcEbWJMUNffM7gox2Y6acjG+t/98LlIZDPYHdqmAFnKd/Ywu N5NqDuyFBuEF1a+r/D+x0KvSWzj5LliotHw4S9rWymTey5mO7Gwn0f2rUWcU3CJB4qOi +LypMc9i34imNYn2nsEoyhCV7qkEeaVIMNhlftiMyTtEJMiZHzjwswVOoBjtJdjjZSgM klpILuZFREs1TqJzMjbbiFWuKfxAH7EqsdT4FRygOop+3dwwFq7hpoi2PxgpnwVXi2aP VweQ== X-Gm-Message-State: APjAAAVCYSYu/MqQ3da5N/2unj2c35WLeNWXtQHEOEo4yB4Fd8ZXJMO0 ex/Ah4y316kGRqUT4dFLWnuwCEOgpOg= X-Google-Smtp-Source: APXvYqyYSozLG0aJ8qKSWG7+IEjy/pY1GiR6aZ6fveYZSi5+7N0D+HMplynzPI+ZqvzkKVVNFLUQ1g== X-Received: by 2002:adf:fd87:: with SMTP id d7mr11837100wrr.226.1581794151975; Sat, 15 Feb 2020 11:15:51 -0800 (PST) Received: from localhost.localdomain (78.red-88-21-202.staticip.rima-tde.net. [88.21.202.78]) by smtp.gmail.com with ESMTPSA id o9sm9678605wrw.20.2020.02.15.11.15.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:15:51 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 04/12] hw/arm/raspi: Remove use of the 'version' value in the board code Date: Sat, 15 Feb 2020 20:15:35 +0100 Message-Id: <20200215191543.3235-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200215191543.3235-1-f4bug@amsat.org> References: <20200215191543.3235-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: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-arm@nongnu.org, Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Signed-off-by: Philippe Mathieu-Daudé --- hw/arm/raspi.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index aa0a7e6276..38829195c5 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -98,11 +98,6 @@ static RaspiProcessorId board_processor_id(uint32_t board_rev) return proc_id; } -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 arm_boot_info *info) cpu_set_pc(cs, info->smp_loader_start); } -static void setup_boot(MachineState *machine, int version, size_t ram_size) +static void setup_boot(MachineState *machine, RaspiProcessorId processor_id, + size_t ram_size) { static struct arm_boot_info binfo; int r; @@ -210,12 +206,13 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) binfo.ram_size = ram_size; binfo.nb_cpus = machine->smp.cpus; - if (version <= 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 <= 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 vectors + * 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. */ binfo.board_setup_addr = BOARDSETUP_ADDR; binfo.write_board_setup = write_board_setup; @@ -223,10 +220,10 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) binfo.secure_boot = true; } - /* Pi2 and Pi3 requires SMP setup */ - if (version >= 2) { + /* BCM2836 and BCM2837 requires SMP setup */ + if (processor_id >= PROCESSOR_ID_BCM2836) { binfo.smp_loader_start = SMPBOOT_ADDR; - if (version == 2) { + if (processor_id == PROCESSOR_ID_BCM2836) { binfo.write_secondary_boot = write_smpboot; } else { binfo.write_secondary_boot = write_smpboot64; @@ -238,7 +235,13 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) * the normal Linux boot process */ if (machine->firmware) { - hwaddr firmware_addr = version == 3 ? FIRMWARE_ADDR_3 : FIRMWARE_ADDR_2; + hwaddr firmware_addr; + + if (processor_id == PROCESSOR_ID_BCM2837) { + firmware_addr = FIRMWARE_ADDR_3; + } else { + firmware_addr = FIRMWARE_ADDR_2; + } /* load the firmware image (typically kernel.img) */ r = load_image_targphys(machine->firmware, firmware_addr, ram_size - firmware_addr); @@ -259,7 +262,6 @@ static void raspi_machine_init(MachineState *machine) RaspiMachineClass *mc = RASPI_MACHINE_GET_CLASS(machine); RaspiMachineState *s = RASPI_MACHINE(machine); uint32_t board_rev = mc->board_rev; - int version = board_version(board_rev); uint64_t ram_size = board_ram_size(board_rev); uint32_t vcram_size; DriveInfo *di; @@ -303,7 +305,8 @@ static void raspi_machine_init(MachineState *machine) vcram_size = 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); } static void raspi_machine_class_common_init(MachineClass *mc, -- 2.21.1