From patchwork Tue Dec 12 16:29:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 753114 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c83:0:b0:333:3a04:f257 with SMTP id z3csp2012877wrs; Tue, 12 Dec 2023 08:35:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IETvRdf5cdbwuhfZvM+6YRDA3IMg1eUTIhoBTxKRdOqwL6J5PUK8EOkjut4OWjLgOUC29ar X-Received: by 2002:a05:620a:8012:b0:77e:fba3:9d11 with SMTP id ee18-20020a05620a801200b0077efba39d11mr7907346qkb.117.1702398945808; Tue, 12 Dec 2023 08:35:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702398945; cv=none; d=google.com; s=arc-20160816; b=fOlJ4AioqRyS0lFgMRh9c1A584ASu6qzVDZ5LqIMzaZSdY2aCTZfO11mdTVyJSv83j gWpLN7q7twvLUrwCzkcf8SjYlMDtS71b9PKJCmvJyfofkFTQmQbmhlXYwZa/quAKk4gU dBTDt5G1Oq7IskGt1P8sIYuiQGjRtWGvi08lH2/SJG7NOF0W+WIZmhDP/DGKyn8LourX Iw9NgAyIwlRy5iggVmrzMe3F79tPKn5RtuDFX3cetrZAkbbn/e9vvoGwlQkmBWdD3E0V ftOsKDyoMFJ1H/2eBD6ho/PkhUcJdG5En0K/8wgig9c5k1lB5nDt8Fb2EjoEDnD4MLiO l0sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uwsCbOQwC9LRQg37XGNzhzNIEGJSgHKY9wlcygMw6kk=; fh=CkupYgn1Qmdh7jizui9HJgGegpqbRR5NXz1VyjRE1Hs=; b=Akc+lxNhL8Gr5KZ/srmOwjPu5Vzw1pbl+oC9xGDo3eWPdrJmOSxOLfTRnStUuVXWx6 Aac091T5Rklz9RkQ279cER2bq26JzKwypKIz0avcE5s22sKz5/0EHOJq8ZB2r/glCJb0 3b4BrzXSpe2OHLzXPH/z6bGM177TefsiuViH2hMMKKQXD8WAjvEykssk6J5nqFfWAGUU a7hJqYmXOZKkD1Pv8U0zncOkemVtwH9yIuu21KTM0pSylwogoYCUv3wgvqcP6tw79wel WoVRxe1YJnqxz3QOo7l0TUmtWGVbq4B2wc/zUc9jqRoMWYVWBMS+mcS/n92myApF7GNW qYEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bz6iM7cG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a5-20020a05620a438500b0077efdc96f7esi11544458qkp.66.2023.12.12.08.35.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Dec 2023 08:35:45 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bz6iM7cG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rD5h7-0000cX-GD; Tue, 12 Dec 2023 11:33:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rD5gj-0008S0-TQ for qemu-devel@nongnu.org; Tue, 12 Dec 2023 11:33:00 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rD5gh-0007so-BY for qemu-devel@nongnu.org; Tue, 12 Dec 2023 11:32:53 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3331752d2b9so3987791f8f.3 for ; Tue, 12 Dec 2023 08:32:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702398769; x=1703003569; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uwsCbOQwC9LRQg37XGNzhzNIEGJSgHKY9wlcygMw6kk=; b=bz6iM7cG9T1jq/ndztSoLMibc69ADT/bQfXeLkTXigMhzOqVcMwKoquVVt0bm6rPG8 PfTWYMN5wgApfE0yfHSiudMWwmDjkKjk8WZjfvupcKrqZjPfnROhI9ewaIxD9dkpHpX3 yEUPUPqCyfZHHKwCBVizHxDkdBSFooqeGZ9Kvhkxvs4YtQ5XWnfQas56TzbiRrwPMixf +BeEP7JkWj/eOsV/xCwtmAosTHpmjfF1PWNA8RKrPGW8g/mlyPncyIFJPzJ/mE61EBmA IkDkBgYpnCinx5nZ2Q0ZQ+fD1jODGIDEsNKKXErNNJ72E/Cd53GvNc8Cd59jxVx1bFZ7 EPBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702398769; x=1703003569; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uwsCbOQwC9LRQg37XGNzhzNIEGJSgHKY9wlcygMw6kk=; b=EeGOfHL6p1Hdj3i21jgMpwHzsDYIkzFjePlXDCejI/VjP4eFH2FUl6OoGeHlQnkeBS HDXD8RXzdDupvkJFs9dsob8Wq+0tkTK51tVbG7XtyvVanLXMgaCrPSwQtZUTIFCAFtgt wZjZ0Q9QfX6h8INDP+hukIxqsnbsuKJlWnubgIEUoxA92xKaG2veZ5jx4R5PWejTwMPY K697kAy14XI75/ytIDjiUlvPqTP8OOrX6q14lKmZzKjgI8z55/3vMoR0InGIDNEBBVtr +tQkV+DsJT6hD8iMsvB9i21ub7tsIJv5Bd/230BaEV3wzMtS4a5tDa335BrZHNTJx/AG UaHA== X-Gm-Message-State: AOJu0YzXF+qgk/k5RV/1yG0n+6FSRG1sCz1sKBnZKQeFBHmCBt/v3vVK Ff//6a3Ab8JzBPIvLI8mJPTpty/PEn0ojdwwMgI= X-Received: by 2002:adf:fcc9:0:b0:336:9f9:6e6 with SMTP id f9-20020adffcc9000000b0033609f906e6mr3118511wrs.97.1702398768756; Tue, 12 Dec 2023 08:32:48 -0800 (PST) Received: from m1x-phil.lan ([176.176.175.193]) by smtp.gmail.com with ESMTPSA id v4-20020a5d4a44000000b003342e0745absm11105691wrs.93.2023.12.12.08.32.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 12 Dec 2023 08:32:48 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Tyrone Ting , =?utf-8?q?Alex_Benn=C3=A9e?= , Manos Pitsidianakis , Eduardo Habkost , Joel Stanley , Alistair Francis , Anton Johansson , Andrey Smirnov , Peter Maydell , Hao Wu , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Jean-Christophe Dubois , Igor Mitsyanko , "Edgar E. Iglesias" , Andrew Jeffery , Rob Herring , qemu-arm@nongnu.org, Mark Cave-Ayland , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 26/33] hw/arm/fsl-imx7: Let the A7MPcore create/wire the CPU cores Date: Tue, 12 Dec 2023 17:29:26 +0100 Message-ID: <20231212162935.42910-27-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231212162935.42910-1-philmd@linaro.org> References: <20231212162935.42910-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Set the properties on the a7mpcore object to let it create and wire the CPU cores. Remove the redundant code. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/arm/fsl-imx7.h | 4 --- hw/arm/fsl-imx7.c | 62 +++++---------------------------------- hw/arm/mcimx7d-sabre.c | 3 +- 3 files changed, 10 insertions(+), 59 deletions(-) diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h index a6f3a96029..77771f916c 100644 --- a/include/hw/arm/fsl-imx7.h +++ b/include/hw/arm/fsl-imx7.h @@ -36,7 +36,6 @@ #include "hw/net/imx_fec.h" #include "hw/pci-host/designware.h" #include "hw/usb/chipidea.h" -#include "cpu.h" #include "qom/object.h" #include "qemu/units.h" @@ -63,11 +62,8 @@ enum FslIMX7Configuration { }; struct FslIMX7State { - /*< private >*/ DeviceState parent_obj; - /*< public >*/ - ARMCPU cpu[FSL_IMX7_NUM_CPUS]; CortexMPPrivState a7mpcore; IMXGPTState gpt[FSL_IMX7_NUM_GPTS]; IMXGPIOState gpio[FSL_IMX7_NUM_GPIOS]; diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c index bd9266b8b5..f71ffe7910 100644 --- a/hw/arm/fsl-imx7.c +++ b/hw/arm/fsl-imx7.c @@ -26,25 +26,16 @@ #include "sysemu/sysemu.h" #include "qemu/error-report.h" #include "qemu/module.h" +#include "target/arm/cpu.h" /* qom */ #define NAME_SIZE 20 static void fsl_imx7_init(Object *obj) { - MachineState *ms = MACHINE(qdev_get_machine()); FslIMX7State *s = FSL_IMX7(obj); char name[NAME_SIZE]; int i; - /* - * CPUs - */ - for (i = 0; i < MIN(ms->smp.cpus, FSL_IMX7_NUM_CPUS); i++) { - snprintf(name, NAME_SIZE, "cpu%d", i); - object_initialize_child(obj, name, &s->cpu[i], - ARM_CPU_TYPE_NAME("cortex-a7")); - } - /* * A7MPCORE */ @@ -163,7 +154,6 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) MachineState *ms = MACHINE(qdev_get_machine()); FslIMX7State *s = FSL_IMX7(dev); DeviceState *gic; - Object *o; int i; qemu_irq irq; char name[NAME_SIZE]; @@ -175,56 +165,20 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) return; } - /* - * CPUs - */ - for (i = 0; i < smp_cpus; i++) { - o = OBJECT(&s->cpu[i]); - - /* On uniprocessor, the CBAR is set to 0 */ - if (smp_cpus > 1) { - object_property_set_int(o, "reset-cbar", FSL_IMX7_A7MPCORE_ADDR, - &error_abort); - } - - if (i) { - /* - * Secondary CPUs start in powered-down state (and can be - * powered up via the SRC system reset controller) - */ - object_property_set_bool(o, "start-powered-off", true, - &error_abort); - } - - qdev_realize(DEVICE(o), NULL, &error_abort); - } - /* * A7MPCORE */ - object_property_set_int(OBJECT(&s->a7mpcore), "num-cores", smp_cpus, - &error_abort); - object_property_set_int(OBJECT(&s->a7mpcore), "num-irq", - FSL_IMX7_MAX_IRQ + GIC_INTERNAL, &error_abort); - + qdev_prop_set_uint32(DEVICE(&s->a7mpcore), "num-cores", ms->smp.cpus); + qdev_prop_set_string(DEVICE(&s->a7mpcore), "cpu-type", + ARM_CPU_TYPE_NAME("cortex-a7")); + qdev_prop_set_uint64(DEVICE(&s->a7mpcore), "cpu-reset-cbar", + FSL_IMX7_A7MPCORE_ADDR); + qdev_prop_set_uint32(DEVICE(&s->a7mpcore), "gic-spi-num", + FSL_IMX7_MAX_IRQ + GIC_INTERNAL); sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort); sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, FSL_IMX7_A7MPCORE_ADDR); gic = DEVICE(&s->a7mpcore); - for (i = 0; i < smp_cpus; i++) { - SysBusDevice *sbd = SYS_BUS_DEVICE(&s->a7mpcore); - DeviceState *d = DEVICE(qemu_get_cpu(i)); - - irq = qdev_get_gpio_in(d, ARM_CPU_IRQ); - sysbus_connect_irq(sbd, i, irq); - irq = qdev_get_gpio_in(d, ARM_CPU_FIQ); - sysbus_connect_irq(sbd, i + smp_cpus, irq); - irq = qdev_get_gpio_in(d, ARM_CPU_VIRQ); - sysbus_connect_irq(sbd, i + 2 * smp_cpus, irq); - irq = qdev_get_gpio_in(d, ARM_CPU_VFIQ); - sysbus_connect_irq(sbd, i + 3 * smp_cpus, irq); - } - /* * A7MPCORE DAP */ diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c index 693a1023b6..782f7591db 100644 --- a/hw/arm/mcimx7d-sabre.c +++ b/hw/arm/mcimx7d-sabre.c @@ -20,6 +20,7 @@ #include "hw/qdev-properties.h" #include "qemu/error-report.h" #include "sysemu/qtest.h" +#include "target/arm/cpu.h" /* qom */ static void mcimx7d_sabre_init(MachineState *machine) { @@ -64,7 +65,7 @@ static void mcimx7d_sabre_init(MachineState *machine) } if (!qtest_enabled()) { - arm_load_kernel(&s->cpu[0], machine, &boot_info); + arm_load_kernel(s->a7mpcore.cpu[0], machine, &boot_info); } }