From patchwork Mon Aug 5 18:06:09 2024 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: 816743 Delivered-To: patch@linaro.org Received: by 2002:adf:e00d:0:b0:367:895a:4699 with SMTP id s13csp1469770wrh; Mon, 5 Aug 2024 11:07:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWEvCNEsTUX5J7L+nKU6LwLTIJWCzBb6/5USDrtqfXtlONUr+OO7jk6ctweLcExFCwtINsWMDd51zOPG1yudf20 X-Google-Smtp-Source: AGHT+IHa6p0jK1E85sThZxNZ6BbDgw3DId4BIvfh9wxls9z4UTXpmaPabVGaQbpN+zvKDZv84QmM X-Received: by 2002:a05:6902:1505:b0:e0b:f4bd:24d2 with SMTP id 3f1490d57ef6-e0bf4bd2569mr10255308276.30.1722881278770; Mon, 05 Aug 2024 11:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722881278; cv=none; d=google.com; s=arc-20160816; b=lWQTyIhGLji9MyooIYd3vicvaWrCJq+7JlaMcOElwv9Rc7QHGKvGw2usP9HBEwNj/L utWioFivg3URfAQba6YnnG6TWnFtKmMfysAoC/ALoeB9ABss1PfJBek6ISVz5R2G3tuS baHCFPyfea5QpGVy0mTA3Me8Az0n3XJ601AENB9u+lW8mPUS6ohSuCCiDEPJhio6q6ZT gjmcjALB7j2o1Cs2axmdq1I3jhqW0gM1FosDYYQBOA2XMONQUnyd3cquj18Zr9sSrtk2 17bdU3cE8JDRhsRNkJ0mPW7pDT/35cW19P57llYaoqG1L7j+QP4bpfZQE6K/grlssQmd RG1A== 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=X5uNst4W6LAAfy5PWyCP4yG159IePDhcmfia8qBHksY=; fh=9FIv2ryHyUdV0M0E/xImFOb7ha8RVmpB9WW8IcVSbKs=; b=Gsr4PZoxja1m3+M0al5TtrnVen8OuoTTLyQHajSlCzhux+HMVDoFVpbBinJcidah1f 3DBxlPeoeCZB766Ormct83LYgSG6QeGiP0SlKUKbv5xhzcnGC2ypQybbYoeFTFkFev5m 7HlSCen+Jbnnz51S7XUQ+pjW4WvA5GpG7rtzLUCcXYDaWrG5AFIMeYfypCOWMxyEsnvL T+ynMH42F0f8DJikOJMcUba+x9eMjn6/mmHTEcQDVQY2iLF3qsAJsu2jAB79niNm04cx X5i52Tjh1kO79IG6DAj4NtRRWCswsCuJ44UP7v/qIbno6i6u/t9JK2/iKXP7ipiYoLNu iAGg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y1Xw4TQt; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a3514ee7fcsi960366185a.329.2024.08.05.11.07.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Aug 2024 11:07:58 -0700 (PDT) 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=y1Xw4TQt; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sb26W-0005kQ-F9; Mon, 05 Aug 2024 14:06:44 -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 1sb26V-0005jg-9d for qemu-devel@nongnu.org; Mon, 05 Aug 2024 14:06:43 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sb26T-0006O9-Ij for qemu-devel@nongnu.org; Mon, 05 Aug 2024 14:06:43 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42819654737so67693345e9.1 for ; Mon, 05 Aug 2024 11:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722881200; x=1723486000; 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=X5uNst4W6LAAfy5PWyCP4yG159IePDhcmfia8qBHksY=; b=y1Xw4TQtsidYL/UnDxqVe8SG3Gacakh4ZjFJhQv3Y55GTQDto7e6hRhjJaATYdrluW mZ/v07m77zR5PbIiALA3jj/dTMLjltqogzp5Iv5l6Z/jKldd8DdJZA0u/n5/JzqGU87t qS7bcDyFxK+RIylLOLr9LdyDNoW7R94WsUKh8ZcZ5HJTDM9TYQGtqAKf73bmJCiX/RuZ SIK3CPUMbiqVy9xk2Qt931TXbuFNs+CUUfR0Z7I3JOsHtKyWhgj+nOQnsZUBuXh15QFR en7oAjXiqNy/Z8JcHPBdq+pEIF4ersYSSF2S225vBZR1zLhxrNkp+ueoK/xD42mW95S4 1QWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722881200; x=1723486000; 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=X5uNst4W6LAAfy5PWyCP4yG159IePDhcmfia8qBHksY=; b=ttVykInKF8s47l4BcSgAzCSDclomauEwGWGnJaxYuYrNByaYTqcniX8Yn140/EyoEy bGoQ6HDgfFV+gW7QdrhVXhGpnFh1llL9cd7yDItNoP797g1FRF+qoXRMIDJpqoLy/rrQ 6a7xzNe92aOBYX6FJaZ9o+yDBG+U1uNiNP++FNO5a9ZH8g7tEdO5Hxi0Llo+OgJOSuMB KoQLPf8H80B69Hg1cZUS74HuvNj1lprLwOVQFeRjpca0BxRbUrYTogGxCKDsGe6BfFzk ccye73IPEEDWcBFLNH+Fr1A/67tH7LYLf+Gy31oTDT/O+YMbcNYGH7iT27g5TulPk0sl RFdg== X-Gm-Message-State: AOJu0YylbqqGbe4WiPeFBztTICzGPeZV7sH1vodb3nqE/pL5DP9MT8jr 4TcARZk6gGOGALhCNgGHdT27h4eMJ69EXIpQCwySjIaF4NDdhTMwv1MlKxVUDcp/1KdCfByGZGl X X-Received: by 2002:a5d:4fc7:0:b0:368:7fd3:291c with SMTP id ffacd0b85a97d-36bbc180c19mr7926345f8f.60.1722881199386; Mon, 05 Aug 2024 11:06:39 -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 ffacd0b85a97d-36bbd06fbfdsm10519622f8f.106.2024.08.05.11.06.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 05 Aug 2024 11:06:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Bibo Mao Cc: Song Gao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Jiaxun Yang Subject: [PATCH-for-9.1 v6 02/15] hw/intc/loongson_ipi: Extract loongson_ipi_common_realize() Date: Mon, 5 Aug 2024 20:06:09 +0200 Message-ID: <20240805180622.21001-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805180622.21001-1-philmd@linaro.org> References: <20240805180622.21001-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Signed-off-by: Philippe Mathieu-Daudé 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: <20240718133312.10324-6-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 = { .endianness = DEVICE_LITTLE_ENDIAN, }; -static void loongson_ipi_realize(DeviceState *dev, Error **errp) +static void loongson_ipi_common_realize(DeviceState *dev, Error **errp) { LoongsonIPIState *s = LOONGSON_IPI(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); @@ -301,30 +301,46 @@ static void loongson_ipi_realize(DeviceState *dev, Error **errp) sysbus_init_mmio(sbd, &s->ipi64_iocsr_mem); s->cpu = g_new0(IPICore, s->num_cpu); - if (s->cpu == NULL) { - error_setg(errp, "Memory allocation for IPICore faile"); - return; - } - for (i = 0; i < s->num_cpu; i++) { s->cpu[i].ipi = s; - s->cpu[i].ipi_mmio_mem = g_new0(MemoryRegion, 1); - g_autofree char *name = 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, 0x48); - sysbus_init_mmio(sbd, s->cpu[i].ipi_mmio_mem); qdev_init_gpio_out(dev, &s->cpu[i].irq, 1); } } -static void loongson_ipi_unrealize(DeviceState *dev) +static void loongson_ipi_realize(DeviceState *dev, Error **errp) +{ + LoongsonIPIState *s = LOONGSON_IPI(dev); + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + Error *local_err = NULL; + + loongson_ipi_common_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + for (unsigned i = 0; i < s->num_cpu; i++) { + s->cpu[i].ipi_mmio_mem = g_new0(MemoryRegion, 1); + g_autofree char *name = 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, 0x48); + sysbus_init_mmio(sbd, s->cpu[i].ipi_mmio_mem); + } +} + +static void loongson_ipi_common_unrealize(DeviceState *dev) { LoongsonIPIState *s = LOONGSON_IPI(dev); g_free(s->cpu); } +static void loongson_ipi_unrealize(DeviceState *dev) +{ + loongson_ipi_common_unrealize(dev); +} + static const VMStateDescription vmstate_ipi_core = { .name = "ipi-single", .version_id = 2,