From patchwork Tue Dec 12 16:29:11 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: 753097 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c83:0:b0:333:3a04:f257 with SMTP id z3csp2011554wrs; Tue, 12 Dec 2023 08:33:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5ZHTrCwcUUBGQke60vO+tiGjD05X8Z4mpogCt9XiJaphPbl/5Rpixv+XSr9Xk6BeZH+vR X-Received: by 2002:ac8:5a8d:0:b0:425:4043:96fa with SMTP id c13-20020ac85a8d000000b00425404396famr10248434qtc.135.1702398807357; Tue, 12 Dec 2023 08:33:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702398807; cv=none; d=google.com; s=arc-20160816; b=C+ZG4al04F00iI2m6Jn+4YkxyQUwUW3DYQrvGRNdbpGqD1cjxCzB+fFySVD/IlZMm7 cEOtaRDMKRbgFBgQnqYuE7f+wUotpjD72zAwaO2wGkMDLs3iN+JhXdWgXmk120MdSVnc Nb4qIJj5WiU0UPzzBsLdbR0Hft55i559A58XAZiTvHJSVwO1auCyqypuTtFefBkuN7+c oBc/DP+zRZyJk5siO1kFLtRWkbMYWTKxPrpDDC+OqG5vkBfbnbRpsqOLO+WsKI/zolq6 mtdA3dDyw4qbaE4nR02UZADAti7NtuXNxuNxbVQloak/7/oU0q3HJh2RqZNQS4QmZ3St N6Eg== 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=suvN+YJQ4ci7BcP7cxgDGLkeAASL5qV684+uLcglZPc=; fh=CkupYgn1Qmdh7jizui9HJgGegpqbRR5NXz1VyjRE1Hs=; b=eeeMy4T8KmuhTI1GDnm66QZXf9Wx6XDOylyaMdhQAM/8QYEdrLVqTZyTdd3ZBwhLfU 5gf6ZEN/CZqSk3JShhXYi08oZfEpwoqPEnmaJC0ldVs9QOii5WtsGbRv8mkYSvDf2uVs J1gaymShfjxqh8prINZkCR3ejVRAZlUx2FzfAeUMCZ2QSE8ypdCCtsijm211+xE5IXhL MlcMJO/WutHqEG228BuZYpFronGx25rHiN86HVSlO/v3VU8Co73fbbaR8+IJgHfYIweZ 2zJ/PqHY5Kz8zg9AHg4kYSC/zCFFcNgk02YkNUQGrtszIpy2paMSn5FBdoEsfl0q8l64 F28A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iZSOobZP; 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 a2-20020a05622a02c200b00425d0d2b0cbsi4029788qtx.632.2023.12.12.08.33.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Dec 2023 08:33:27 -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=iZSOobZP; 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 1rD5f1-0002st-0S; Tue, 12 Dec 2023 11:31:07 -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 1rD5ey-0002db-KQ for qemu-devel@nongnu.org; Tue, 12 Dec 2023 11:31:04 -0500 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rD5ew-0007TO-Ed for qemu-devel@nongnu.org; Tue, 12 Dec 2023 11:31:04 -0500 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-55114c073b8so3625687a12.1 for ; Tue, 12 Dec 2023 08:31:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702398661; x=1703003461; 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=suvN+YJQ4ci7BcP7cxgDGLkeAASL5qV684+uLcglZPc=; b=iZSOobZPgB19Lma4mfVXBo4Iw3Z71FxjL5fN/OLw25cHgqtg7d5pi6Yn6+8As8ef/V 06uL5NqzTpNsp2IXznB/V9FLgbFqtI0BXs7DryCvOqeT/uju0jEw9yMvTZ1nnVsb5Fju yiYCWhy+Di+x6TDKccZw6kEuNoRN92NUmL21KJbypHcQzp63jzMEDqSA3mvx/wAxTmPD YWM8M7yw6BwOzGzMA5basKGcBbVebuQzYjO2Oky0y4zXME1zr4j+UmcXxxahpF3uosRD VxoRl65Ri+Wdnnzai4XoMFYkmfNFaWo9q5get8SN7JsmGcCWFaV8LVbRmb6Uibjk2YRF 7nMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702398661; x=1703003461; 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=suvN+YJQ4ci7BcP7cxgDGLkeAASL5qV684+uLcglZPc=; b=prKDlP6yoFixVH/9DnMfJvIImhyiBK++9aVft3VMLn3jj3OOfz5N1gObtWSErg2mzq MQGf5qarikuRC5YblByiMUfLdTTr92FLklrXK44bCAOSB4SJl3Z/md8pp8ouQpOxhill tFkdMymNpFG/t7LuBnKmPXBpiZWHFsVp2aHqGFSA9Sa8gr1Y1T7bw3Bsfd7KFcMuIgi5 frUSJwSVDSogEYM42j6hlsey4OdXCVqf/LT10nR6pGumYXPl/kJMOx7HHVY8n1LAmKV4 DDFzttnk62VEzLNjT4infHYA15OMG5A6trYv0AL2cDucuMquMKenrOzgkCdCtQ/3eW6y BqfA== X-Gm-Message-State: AOJu0Yzj6kWuZWazIbR/P9BOGCBNNL3+r2IROd9y6Ty7+nPxE3h/90MC 1jjGzR3Ipc2eJVGAPqlq8xKWtHGOpAzeTsGgjXM= X-Received: by 2002:a17:906:51c7:b0:a1b:70fb:4517 with SMTP id v7-20020a17090651c700b00a1b70fb4517mr2121788ejk.151.1702398660769; Tue, 12 Dec 2023 08:31:00 -0800 (PST) Received: from m1x-phil.lan ([176.176.175.193]) by smtp.gmail.com with ESMTPSA id uh17-20020a170906b39100b00a1d5063b01csm6482417ejc.190.2023.12.12.08.30.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 12 Dec 2023 08:31:00 -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 11/33] hw/cpu/arm: Have A9MPCORE/A15MPCORE inheritate common CORTEX_MPCORE_PRIV Date: Tue, 12 Dec 2023 17:29:11 +0100 Message-ID: <20231212162935.42910-12-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::52d; envelope-from=philmd@linaro.org; helo=mail-ed1-x52d.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 TYPE_CORTEX_MPCORE_PRIV becomes the common parent to TYPE_A9MPCORE_PRIV and TYPE_A15MPCORE_PRIV. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- include/hw/cpu/cortex_mpcore.h | 6 ++++-- hw/cpu/a15mpcore.c | 14 ++++++++++++-- hw/cpu/a9mpcore.c | 13 +++++++++++-- hw/arm/Kconfig | 2 ++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/include/hw/cpu/cortex_mpcore.h b/include/hw/cpu/cortex_mpcore.h index c5dd7200d0..4084c6003a 100644 --- a/include/hw/cpu/cortex_mpcore.h +++ b/include/hw/cpu/cortex_mpcore.h @@ -32,6 +32,8 @@ OBJECT_DECLARE_TYPE(CortexMPPrivState, CortexMPPrivClass, CORTEX_MPCORE_PRIV) struct CortexMPPrivClass { SysBusDeviceClass parent_class; + + DeviceRealize parent_realize; }; struct CortexMPPrivState { @@ -42,7 +44,7 @@ struct CortexMPPrivState { OBJECT_DECLARE_SIMPLE_TYPE(A9MPPrivState, A9MPCORE_PRIV) struct A9MPPrivState { - SysBusDevice parent_obj; + CortexMPPrivState parent_obj; uint32_t num_cpu; MemoryRegion container; @@ -59,7 +61,7 @@ struct A9MPPrivState { OBJECT_DECLARE_SIMPLE_TYPE(A15MPPrivState, A15MPCORE_PRIV) struct A15MPPrivState { - SysBusDevice parent_obj; + CortexMPPrivState parent_obj; uint32_t num_cpu; uint32_t num_irq; diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c index 0f56c40b86..5a57145179 100644 --- a/hw/cpu/a15mpcore.c +++ b/hw/cpu/a15mpcore.c @@ -48,15 +48,23 @@ static void a15mp_priv_initfn(Object *obj) static void a15mp_priv_realize(DeviceState *dev, Error **errp) { + CortexMPPrivClass *cc = CORTEX_MPCORE_PRIV_GET_CLASS(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); A15MPPrivState *s = A15MPCORE_PRIV(dev); DeviceState *gicdev; SysBusDevice *gicsbd; + Error *local_err = NULL; int i; bool has_el3; bool has_el2 = false; Object *cpuobj; + cc->parent_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + gicdev = DEVICE(&s->gic); qdev_prop_set_uint32(gicdev, "num-cpu", s->num_cpu); qdev_prop_set_uint32(gicdev, "num-irq", s->num_irq); @@ -158,8 +166,10 @@ static Property a15mp_priv_properties[] = { static void a15mp_priv_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + CortexMPPrivClass *cc = CORTEX_MPCORE_PRIV_CLASS(klass); - dc->realize = a15mp_priv_realize; + device_class_set_parent_realize(dc, a15mp_priv_realize, + &cc->parent_realize); device_class_set_props(dc, a15mp_priv_properties); /* We currently have no saveable state */ } @@ -167,7 +177,7 @@ static void a15mp_priv_class_init(ObjectClass *klass, void *data) static const TypeInfo a15mp_types[] = { { .name = TYPE_A15MPCORE_PRIV, - .parent = TYPE_SYS_BUS_DEVICE, + .parent = TYPE_CORTEX_MPCORE_PRIV, .instance_size = sizeof(A15MPPrivState), .instance_init = a15mp_priv_initfn, .class_init = a15mp_priv_class_init, diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c index e9cd71e92f..d59e49126b 100644 --- a/hw/cpu/a9mpcore.c +++ b/hw/cpu/a9mpcore.c @@ -46,11 +46,13 @@ static void a9mp_priv_initfn(Object *obj) static void a9mp_priv_realize(DeviceState *dev, Error **errp) { + CortexMPPrivClass *cc = CORTEX_MPCORE_PRIV_GET_CLASS(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); A9MPPrivState *s = A9MPCORE_PRIV(dev); DeviceState *scudev, *gicdev, *gtimerdev, *mptimerdev, *wdtdev; SysBusDevice *scubusdev, *gicbusdev, *gtimerbusdev, *mptimerbusdev, *wdtbusdev; + Error *local_err = NULL; int i; bool has_el3; CPUState *cpu0; @@ -65,6 +67,12 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp) return; } + cc->parent_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + scudev = DEVICE(&s->scu); qdev_prop_set_uint32(scudev, "num-cpu", s->num_cpu); if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) { @@ -173,15 +181,16 @@ static Property a9mp_priv_properties[] = { static void a9mp_priv_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + CortexMPPrivClass *cc = CORTEX_MPCORE_PRIV_CLASS(klass); - dc->realize = a9mp_priv_realize; + device_class_set_parent_realize(dc, a9mp_priv_realize, &cc->parent_realize); device_class_set_props(dc, a9mp_priv_properties); } static const TypeInfo a9mp_types[] = { { .name = TYPE_A9MPCORE_PRIV, - .parent = TYPE_SYS_BUS_DEVICE, + .parent = TYPE_CORTEX_MPCORE_PRIV, .instance_size = sizeof(A9MPPrivState), .instance_init = a9mp_priv_initfn, .class_init = a9mp_priv_class_init, diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 3040342fcb..ec6e585797 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -648,6 +648,7 @@ config CORTEX_MPCORE config A9MPCORE bool + select CORTEX_MPCORE select A9_GTIMER select A9SCU # snoop control unit select ARM_GIC @@ -655,6 +656,7 @@ config A9MPCORE config A15MPCORE bool + select CORTEX_MPCORE select ARM_GIC config ARM11MPCORE