From nobody Sun Nov 24 14:10:15 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=1722948752; cv=none; d=zohomail.com; s=zohoarc; b=m1fzV059CrTz4aB7Opgq0vikukxk58gWoWkGQ9fFgv7MP1P2hZxyaXIaeK6P/M6W/Kw9vUAyWa2CenspXcS/M5jcgvinUcoI/kh2ux0ALtJg0q94DDVVh6Jh5HmezFfjqQYARX0vK9vQcqD5R/xsZHS3aoY/ZWOY+0krCP9kmjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722948752; 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=c3ILWy+ncwfc6QydM5V2TsF6gCu3vRJehqiG1EZoOS0=; b=SKXynC1FDc9jHBw90JL5h8p5f7QWoKG0fmIgbS5SFS3Muo8kUGwvMgWdZ9JmNBiHbDxDMlX/8ZsspnbkywIMsfuIywamFcLvwm4k1EPGcLRI7MUiPdsZj1fYvWFBtYfi+Jkg4HEHCwPXpJCJsPzVwuRttt6BmsJgjmI4BECBmqQ= 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 1722948752842581.0372231815077; Tue, 6 Aug 2024 05:52:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbJfj-0005KG-Uw; Tue, 06 Aug 2024 08:52:15 -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 1sbJfj-0005Hj-AZ for qemu-devel@nongnu.org; Tue, 06 Aug 2024 08:52:15 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sbJfh-0008Hi-DR for qemu-devel@nongnu.org; Tue, 06 Aug 2024 08:52:14 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5b5b67d0024so931808a12.0 for ; Tue, 06 Aug 2024 05:52:12 -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-a7dc9bc3cf3sm556585666b.13.2024.08.06.05.52.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 06 Aug 2024 05:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722948731; x=1723553531; 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=c3ILWy+ncwfc6QydM5V2TsF6gCu3vRJehqiG1EZoOS0=; b=XfUsLN/1hEwxDPU+Iwe6d6z4GT29++AU6jbVXWtxvl/52+U+1IblRNIS324J2l+yTq dSHX19ySUflsm4YH4/a0tmTXMf+EoXZmEDg+u3/v3Wp4Jpq8f+nsREWh7OIK157tNlEW quEcrIGnIvn6Jl+mfs6wdI4wWwRAaLUXFgE0vPqnbt/szXRBIHRDcAQQ/1daCWHEdqp4 Z+IAyswko3TuUQ3qufXk870/md7pP4hiSprABTgLLioIfy51VBii6IlwiEHXs6oVY4ZW 4dXQ7towbBz6qFOPMH0dLUvIyLeKkvUkfr2yWyyx8mP+EWcZhptBHxgrxh6cVcL4XQGi x+Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722948731; x=1723553531; 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=c3ILWy+ncwfc6QydM5V2TsF6gCu3vRJehqiG1EZoOS0=; b=VN9svrnX9S0Zbk7eigtG88q9IjSK/L/t3+rQ76D0gXDVXlBA5OQ5I19TJZf4qwPRAA puQgYaVSBTRXBeXrslwhFsC67+hjcNu4cJux0IJ8S5XqpIZMdvh9KW7oYbtt8Y+ITAC+ aKzPXCESfSoLf37QAv7Aq/NyoUJboPWtm3nUljAgEl1pFtE5PXL6Pfz+BMNfPPEVjsAV YPGbeV2jh0ThJrSafNu3dQu8lRgyG18qqyiTDA08g0+HpA7W1OVtU/Z/p7ufUB6hz2kw osDqmBkia9Q0GEFpZ43VcD3d3Gws5cGNERRFo59nVoJIe6PN7gx+OPEsNt2FZ6enuXUr EuyQ== X-Gm-Message-State: AOJu0YzjXbjkJvXtOGl27PMU12wBdsqrWNo1s1wikroLQ2h+EuM2bqPm tUgd5saLqhMreD6Rvm6gxFf96ubaaxTxBOO5xPRaDb7PqoKUsfWd8FTKLNwbxUbxGFwcb70eiG8 b X-Google-Smtp-Source: AGHT+IF/8iVuUEILhbMKAhGlXHPgFPqIxxY8NDVzXN0S+2jr7J63kyUrpsOJA1ktb622tYALz8sUoQ== X-Received: by 2002:a17:907:2cc2:b0:a7a:a46e:dc3c with SMTP id a640c23a62f3a-a7dc4e50c0cmr962164766b.15.1722948731604; Tue, 06 Aug 2024 05:52:11 -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 02/28] hw/intc/loongson_ipi: Extract loongson_ipi_common_realize() Date: Tue, 6 Aug 2024 14:51:30 +0200 Message-ID: <20240806125157.91185-3-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::52b; envelope-from=philmd@linaro.org; helo=mail-ed1-x52b.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: 1722948753471116600 From: Bibo Mao In preparation to extract common IPI code in few commits, extract loongson_ipi_common_realize(). 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-3-philmd@linaro.org> --- hw/intc/loongson_ipi.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c index 903483ae80..8aab7e48e8 100644 --- a/hw/intc/loongson_ipi.c +++ b/hw/intc/loongson_ipi.c @@ -275,7 +275,7 @@ static const MemoryRegionOps loongson_ipi64_ops =3D { .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 -static void loongson_ipi_realize(DeviceState *dev, Error **errp) +static void loongson_ipi_common_realize(DeviceState *dev, Error **errp) { LoongsonIPIState *s =3D LOONGSON_IPI(dev); SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); @@ -301,30 +301,46 @@ static void loongson_ipi_realize(DeviceState *dev, Er= ror **errp) sysbus_init_mmio(sbd, &s->ipi64_iocsr_mem); =20 s->cpu =3D g_new0(IPICore, s->num_cpu); - if (s->cpu =3D=3D NULL) { - error_setg(errp, "Memory allocation for IPICore faile"); - return; - } - for (i =3D 0; i < s->num_cpu; i++) { s->cpu[i].ipi =3D s; - s->cpu[i].ipi_mmio_mem =3D g_new0(MemoryRegion, 1); - g_autofree char *name =3D g_strdup_printf("loongson_ipi_cpu%d_mmio= ", i); - memory_region_init_io(s->cpu[i].ipi_mmio_mem, OBJECT(dev), - &loongson_ipi_core_ops, &s->cpu[i], name, 0x= 48); - sysbus_init_mmio(sbd, s->cpu[i].ipi_mmio_mem); =20 qdev_init_gpio_out(dev, &s->cpu[i].irq, 1); } } =20 -static void loongson_ipi_unrealize(DeviceState *dev) +static void loongson_ipi_realize(DeviceState *dev, Error **errp) +{ + LoongsonIPIState *s =3D LOONGSON_IPI(dev); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + Error *local_err =3D NULL; + + loongson_ipi_common_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + for (unsigned i =3D 0; i < s->num_cpu; i++) { + s->cpu[i].ipi_mmio_mem =3D g_new0(MemoryRegion, 1); + g_autofree char *name =3D g_strdup_printf("loongson_ipi_cpu%d_mmio= ", i); + memory_region_init_io(s->cpu[i].ipi_mmio_mem, OBJECT(dev), + &loongson_ipi_core_ops, &s->cpu[i], name, 0x= 48); + sysbus_init_mmio(sbd, s->cpu[i].ipi_mmio_mem); + } +} + +static void loongson_ipi_common_unrealize(DeviceState *dev) { LoongsonIPIState *s =3D LOONGSON_IPI(dev); =20 g_free(s->cpu); } =20 +static void loongson_ipi_unrealize(DeviceState *dev) +{ + loongson_ipi_common_unrealize(dev); +} + static const VMStateDescription vmstate_ipi_core =3D { .name =3D "ipi-single", .version_id =3D 2, --=20 2.45.2