From nobody Sun Nov 24 15:06:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1722948814; cv=none; d=zohomail.com; s=zohoarc; b=lnhTy9oQZPM4LYeB4fl2DmGT/lt2a7v8atLWE6zPc+nSfMra562mSLLvcGwCe3XsFiVUs9bVpzhwVNDSH+6w/RK88TSHu2RP02SWIPTcdpPXUAExqzwrWUVTlijhADqFna8jQC6W65CQuhF6fuh97qbazv+qAoCmmUBG+mIsVlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722948814; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QwpY/JynEMtTkyIwPRmmw3TCd0WkcVnsonvQjUTWgeg=; b=FTEmvRFG0B40cRQ4XynURyrkXOeJWlV5nQ448a5/n/xnvBgG7uqQ/HRd8J4l1Xut9RH6xPDihCCMWrfsfmdzwhXhrCEsP9d8f/I/subautC2hrLvWLTUaizfTKdbJr3DG24kqRqP9/NWErJ3F/z3IuB7xdAIBOrxnj4l3/ILkWA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722948813998403.4300525893527; Tue, 6 Aug 2024 05:53:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbJgB-0006kd-82; Tue, 06 Aug 2024 08:52:43 -0400 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 1sbJg9-0006c2-0k for qemu-devel@nongnu.org; Tue, 06 Aug 2024 08:52:41 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sbJg6-0008Sq-P9 for qemu-devel@nongnu.org; Tue, 06 Aug 2024 08:52:40 -0400 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a7aac70e30dso58841466b.1 for ; Tue, 06 Aug 2024 05:52:38 -0700 (PDT) Received: from m1x-phil.lan (cor91-h02-176-184-30-206.dsl.sta.abo.bbox.fr. [176.184.30.206]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9ecabb2sm541820766b.214.2024.08.06.05.52.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 06 Aug 2024 05:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722948757; x=1723553557; 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=QwpY/JynEMtTkyIwPRmmw3TCd0WkcVnsonvQjUTWgeg=; b=lZ2HOj26rDFa3qNPPQRQtR6FHpP3NgprbtkESQvdIVDjxuch7MleHyqOzf+B9sdCeB My+DrBX9Gkk3lcTE7cGXMx9zdG83C3UlI5mDQ4pX4KBaQiUhoF6u90XSgjUIutv8MN+U qsvbZl1/24XajnsVNn77OYlPqBNjgyVHY6Ut+yEY2q97NPTiCvgxY04S8FCDElQs0co5 wOv9n2OuzRTkbv9ih6Cmume1TMg2Xwsw6MTl+wIaGIuyruMEopyxV+yR1zumGcZt2nSe TJJvmrzNl4cZ7C46cUcbABqkI6wqOPDju1xmFTIhxN+155QbkL+o+VwwkLkqX8YDJ9Q9 GbZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722948757; x=1723553557; 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=QwpY/JynEMtTkyIwPRmmw3TCd0WkcVnsonvQjUTWgeg=; b=fdUHqDydeI/GrO0R7DyZjHBfMaaFpM4tQA+vvZQCPr+Wom4NotR5hpfvKdpvo0jrl+ CzjzuwGvDNhieVet5Sb7sPnHU6f+Hu360sB56Kp7YJr/cMQpFLpX+h6FNVtiN9xfpBYL Qtn/i+w7PvlWE9wxAP18XY8HxtYgJdi6XYafGKY/VzDlvRuga4JZ7+Uy6vheUqsPHmzT vj9N9XciHwjloYB4H6tWtNMRYiL/Rd2fzeKohmyPhcQib/i88T1Ep208jemlnX0o0RGm fQQStXm+sc+qEmimMlryD7+nJBIn+zQ/wVwYnvhmm1RVkpJ3UjOWms7EQ3ACm9ubKVWu a7hg== X-Gm-Message-State: AOJu0Yzi0eBhROG/OEHrtnl11zywYTpDnMG1pYjaD+RRjDtA3Wb8/+a4 fB3tRqzMc0GLr0jemt7Cc1+aWAvLiM/D7DNWBcnYxn25RE6H3nOTBdUH7/vAQvooFwoUYymp+Sl 4 X-Google-Smtp-Source: AGHT+IGoZ4cizP9vU0oOtnC+ar/pgFKxuStTSHZ4LSVm7L+nCgsEzmGqns5CovGJQi7JZJvXd5IuEQ== X-Received: by 2002:a17:907:3d8d:b0:a7a:97a9:ba23 with SMTP id a640c23a62f3a-a7dc50213b5mr1119445666b.22.1722948756966; Tue, 06 Aug 2024 05:52:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Bibo Mao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Song Gao , Richard Henderson , Jiaxun Yang Subject: [PULL 06/28] hw/intc/loongson_ipi: Move IPICore structure to loongson_ipi_common.h Date: Tue, 6 Aug 2024 14:51:34 +0200 Message-ID: <20240806125157.91185-7-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806125157.91185-1-philmd@linaro.org> References: <20240806125157.91185-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=philmd@linaro.org; helo=mail-ej1-x630.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 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1722948815456116600 From: Bibo Mao Move the IPICore structure and corresponding common fields of LoongsonIPICommonState to "hw/intc/loongson_ipi_common.h". Signed-off-by: Bibo Mao [PMD: Extracted from bigger commit, added commit description] Co-Developed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Bibo Mao Tested-by: Bibo Mao Acked-by: Song Gao Reviewed-by: Richard Henderson Reviewed-by: Jiaxun Yang Tested-by: Jiaxun Yang Message-Id: <20240805180622.21001-7-philmd@linaro.org> --- include/hw/intc/loongson_ipi.h | 17 --------- include/hw/intc/loongson_ipi_common.h | 18 ++++++++++ hw/intc/loongson_ipi.c | 50 ++++++--------------------- hw/intc/loongson_ipi_common.c | 42 ++++++++++++++++++++++ 4 files changed, 70 insertions(+), 57 deletions(-) diff --git a/include/hw/intc/loongson_ipi.h b/include/hw/intc/loongson_ipi.h index 5a52dfbf4d..4e517cc8dc 100644 --- a/include/hw/intc/loongson_ipi.h +++ b/include/hw/intc/loongson_ipi.h @@ -12,22 +12,9 @@ #include "hw/intc/loongson_ipi_common.h" #include "hw/sysbus.h" =20 -#define IPI_MBX_NUM 4 - #define TYPE_LOONGSON_IPI "loongson_ipi" OBJECT_DECLARE_TYPE(LoongsonIPIState, LoongsonIPIClass, LOONGSON_IPI) =20 -typedef struct IPICore { - LoongsonIPIState *ipi; - uint32_t status; - uint32_t en; - uint32_t set; - uint32_t clear; - /* 64bit buf divide into 2 32bit buf */ - uint32_t buf[IPI_MBX_NUM * 2]; - qemu_irq irq; -} IPICore; - struct LoongsonIPIClass { LoongsonIPICommonClass parent_class; =20 @@ -39,10 +26,6 @@ struct LoongsonIPIState { LoongsonIPICommonState parent_obj; =20 MemoryRegion *ipi_mmio_mem; - MemoryRegion ipi_iocsr_mem; - MemoryRegion ipi64_iocsr_mem; - uint32_t num_cpu; - IPICore *cpu; }; =20 #endif diff --git a/include/hw/intc/loongson_ipi_common.h b/include/hw/intc/loongs= on_ipi_common.h index b43b77bda6..967c70ad1c 100644 --- a/include/hw/intc/loongson_ipi_common.h +++ b/include/hw/intc/loongson_ipi_common.h @@ -11,12 +11,30 @@ #include "qom/object.h" #include "hw/sysbus.h" =20 +#define IPI_MBX_NUM 4 + #define TYPE_LOONGSON_IPI_COMMON "loongson_ipi_common" OBJECT_DECLARE_TYPE(LoongsonIPICommonState, LoongsonIPICommonClass, LOONGSON_IPI_COMMON) =20 +typedef struct IPICore { + LoongsonIPICommonState *ipi; + uint32_t status; + uint32_t en; + uint32_t set; + uint32_t clear; + /* 64bit buf divide into 2 32-bit buf */ + uint32_t buf[IPI_MBX_NUM * 2]; + qemu_irq irq; +} IPICore; + struct LoongsonIPICommonState { SysBusDevice parent_obj; + + MemoryRegion ipi_iocsr_mem; + MemoryRegion ipi64_iocsr_mem; + uint32_t num_cpu; + IPICore *cpu; }; =20 struct LoongsonIPICommonClass { diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c index 03878b896f..347bc26729 100644 --- a/hw/intc/loongson_ipi.c +++ b/hw/intc/loongson_ipi.c @@ -64,7 +64,7 @@ static MemTxResult loongson_ipi_iocsr_readl(void *opaque,= hwaddr addr, uint64_t *data, unsigned size, MemTxAttrs attr= s) { - LoongsonIPIState *ipi =3D opaque; + LoongsonIPICommonState *ipi =3D opaque; IPICore *s; =20 if (attrs.requester_id >=3D ipi->num_cpu) { @@ -160,7 +160,7 @@ static MemTxResult loongson_ipi_core_writel(void *opaqu= e, hwaddr addr, MemTxAttrs attrs) { IPICore *s =3D opaque; - LoongsonIPIState *ipi =3D s->ipi; + LoongsonIPICommonState *ipi =3D s->ipi; int index =3D 0; uint32_t cpuid; uint8_t vector; @@ -214,7 +214,7 @@ static MemTxResult loongson_ipi_iocsr_writel(void *opaq= ue, hwaddr addr, uint64_t val, unsigned size, MemTxAttrs attrs) { - LoongsonIPIState *ipi =3D opaque; + LoongsonIPICommonState *ipi =3D opaque; IPICore *s; =20 if (attrs.requester_id >=3D ipi->num_cpu) { @@ -277,7 +277,7 @@ static const MemoryRegionOps loongson_ipi64_ops =3D { =20 static void loongson_ipi_common_realize(DeviceState *dev, Error **errp) { - LoongsonIPIState *s =3D LOONGSON_IPI(dev); + LoongsonIPICommonState *s =3D LOONGSON_IPI_COMMON(dev); SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); int i; =20 @@ -310,6 +310,7 @@ static void loongson_ipi_common_realize(DeviceState *de= v, Error **errp) =20 static void loongson_ipi_realize(DeviceState *dev, Error **errp) { + LoongsonIPICommonState *sc =3D LOONGSON_IPI_COMMON(dev); LoongsonIPIState *s =3D LOONGSON_IPI(dev); SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); Error *local_err =3D NULL; @@ -320,18 +321,19 @@ static void loongson_ipi_realize(DeviceState *dev, Er= ror **errp) return; } =20 - s->ipi_mmio_mem =3D g_new0(MemoryRegion, s->num_cpu); - for (unsigned i =3D 0; i < s->num_cpu; i++) { + s->ipi_mmio_mem =3D g_new0(MemoryRegion, sc->num_cpu); + for (unsigned i =3D 0; i < sc->num_cpu; i++) { g_autofree char *name =3D g_strdup_printf("loongson_ipi_cpu%d_mmio= ", i); + memory_region_init_io(&s->ipi_mmio_mem[i], OBJECT(dev), - &loongson_ipi_core_ops, &s->cpu[i], name, 0x= 48); + &loongson_ipi_core_ops, &sc->cpu[i], name, 0= x48); sysbus_init_mmio(sbd, &s->ipi_mmio_mem[i]); } } =20 static void loongson_ipi_common_unrealize(DeviceState *dev) { - LoongsonIPIState *s =3D LOONGSON_IPI(dev); + LoongsonIPICommonState *s =3D LOONGSON_IPI_COMMON(dev); =20 g_free(s->cpu); } @@ -345,36 +347,6 @@ static void loongson_ipi_unrealize(DeviceState *dev) loongson_ipi_common_unrealize(dev); } =20 -static const VMStateDescription vmstate_ipi_core =3D { - .name =3D "ipi-single", - .version_id =3D 2, - .minimum_version_id =3D 2, - .fields =3D (const VMStateField[]) { - VMSTATE_UINT32(status, IPICore), - VMSTATE_UINT32(en, IPICore), - VMSTATE_UINT32(set, IPICore), - VMSTATE_UINT32(clear, IPICore), - VMSTATE_UINT32_ARRAY(buf, IPICore, IPI_MBX_NUM * 2), - VMSTATE_END_OF_LIST() - } -}; - -static const VMStateDescription vmstate_loongson_ipi =3D { - .name =3D TYPE_LOONGSON_IPI, - .version_id =3D 2, - .minimum_version_id =3D 2, - .fields =3D (const VMStateField[]) { - VMSTATE_STRUCT_VARRAY_POINTER_UINT32(cpu, LoongsonIPIState, num_cp= u, - vmstate_ipi_core, IPICore), - VMSTATE_END_OF_LIST() - } -}; - -static Property ipi_properties[] =3D { - DEFINE_PROP_UINT32("num-cpu", LoongsonIPIState, num_cpu, 1), - DEFINE_PROP_END_OF_LIST(), -}; - static void loongson_ipi_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -384,8 +356,6 @@ static void loongson_ipi_class_init(ObjectClass *klass,= void *data) &lic->parent_realize); device_class_set_parent_unrealize(dc, loongson_ipi_unrealize, &lic->parent_unrealize); - device_class_set_props(dc, ipi_properties); - dc->vmsd =3D &vmstate_loongson_ipi; } =20 static const TypeInfo loongson_ipi_types[] =3D { diff --git a/hw/intc/loongson_ipi_common.c b/hw/intc/loongson_ipi_common.c index 43002fe556..47796f7ece 100644 --- a/hw/intc/loongson_ipi_common.c +++ b/hw/intc/loongson_ipi_common.c @@ -8,6 +8,47 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" #include "hw/intc/loongson_ipi_common.h" +#include "hw/qdev-properties.h" +#include "migration/vmstate.h" + +static const VMStateDescription vmstate_ipi_core =3D { + .name =3D "ipi-single", + .version_id =3D 2, + .minimum_version_id =3D 2, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(status, IPICore), + VMSTATE_UINT32(en, IPICore), + VMSTATE_UINT32(set, IPICore), + VMSTATE_UINT32(clear, IPICore), + VMSTATE_UINT32_ARRAY(buf, IPICore, IPI_MBX_NUM * 2), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_loongson_ipi_common =3D { + .name =3D "loongson_ipi", + .version_id =3D 2, + .minimum_version_id =3D 2, + .fields =3D (const VMStateField[]) { + VMSTATE_STRUCT_VARRAY_POINTER_UINT32(cpu, LoongsonIPICommonState, + num_cpu, vmstate_ipi_core, + IPICore), + VMSTATE_END_OF_LIST() + } +}; + +static Property ipi_common_properties[] =3D { + DEFINE_PROP_UINT32("num-cpu", LoongsonIPICommonState, num_cpu, 1), + DEFINE_PROP_END_OF_LIST(), +}; + +static void loongson_ipi_common_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + device_class_set_props(dc, ipi_common_properties); + dc->vmsd =3D &vmstate_loongson_ipi_common; +} =20 static const TypeInfo loongarch_ipi_common_types[] =3D { { @@ -15,6 +56,7 @@ static const TypeInfo loongarch_ipi_common_types[] =3D { .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(LoongsonIPICommonState), .class_size =3D sizeof(LoongsonIPICommonClass), + .class_init =3D loongson_ipi_common_class_init, .abstract =3D true, } }; --=20 2.45.2