From patchwork Wed Jul 17 21:46:55 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: 813022 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp17005wro; Wed, 17 Jul 2024 14:50:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUA0tMZEYZq9sbLR9V0a85w6rEJzfex4fV+fq8NfDkg5Cw9YUD+sLTsFQ578U3GIuHupLVsWnKVhREdZ1whxOm1 X-Google-Smtp-Source: AGHT+IFnR3LcLdLvamXddihi0lf4FYLIq5g0Vx0wCeK4wpsebzVQ5qhTgi7HsKGuFGURx5LvvRG0 X-Received: by 2002:a05:620a:29c6:b0:79f:b8f:e1d5 with SMTP id af79cd13be357-7a1874929afmr374537985a.34.1721253008064; Wed, 17 Jul 2024 14:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721253008; cv=none; d=google.com; s=arc-20160816; b=05LMCOYCL38jC9SlFqLYGn2JQBDD4SF7ZALPou7MQqA4PUWtFgu5NeZadF3Ezm4jbH hpR4DMMgPxEwv4OnLyrWgkLQmpUKNLf1Ra/DV6m1mpbvJgxMu51jmjnvRtSdAgD+e+SC cNVdHg2YNrhBGoMPNXonwmwp/KbjNNvUdEQcuFGcymSZ7LFgkdrrg0mHwNn6m6TeErnf gXPYcy3b5w/XXyNvAdJxZ7gxBlMSkdLr2ifpQfGUhp5+1oFCaWsrq2c+hFY5YhIoTKfp 7HARG+p5qIc/PNgZM30kd4BiuOGLU8V//tLUafZDPLAkSWAQsOOGaAeEKn1UUlb75v0V S3xA== 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=exmNDPsH0KpZQ3m+4rsADpeyE4/2w009QzC3/hhmhHY=; fh=JV7UaWPrKY2Ztxzt7/ckSjge0bz3dqOAw9CzPuRipLs=; b=OO5JlrNN4UAdMErK1DcQ9SqlWRDIMJVT/XN8Joh0EL7YO9CDKVymIbbSTjMTtAAXVf zlpf8Q/g3VGJ7OJu4xhXtQvmggj1oQfi5bkiDRoXMQpTbsdSZBizU+XLsM0Ym7bVAFWz 80AWswFUYrjTiWCG9szUBYJSzUGo/7ntbJ4VZznIQyZ2hnJfoGf5E1ep6OQFBzGOWWuW csiSY/DtikbIr1N0VNazo1I8LKNNLkxn9wN5L9Hd55PN/Q2mOIceYvv3L05j1cg43aIx qemxT3DDXhxgOEYrNTKsc5ucfXdLZFaD2F51kJOis1pGo3ZyUeWd8GifS9nzaOLU+X8I vkbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hn2cTS58; 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-7a160c6954asi1094138885a.395.2024.07.17.14.50.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jul 2024 14:50:08 -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=hn2cTS58; 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 1sUCVE-0008CP-9w; Wed, 17 Jul 2024 17:48:00 -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 1sUCVB-0007uK-ST for qemu-devel@nongnu.org; Wed, 17 Jul 2024 17:47:57 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUCVA-0002CE-2c for qemu-devel@nongnu.org; Wed, 17 Jul 2024 17:47:57 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-367a9ab4d81so91204f8f.1 for ; Wed, 17 Jul 2024 14:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721252872; x=1721857672; 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=exmNDPsH0KpZQ3m+4rsADpeyE4/2w009QzC3/hhmhHY=; b=hn2cTS58emJ7YjvIbdBWILM3mU5dzTRCFWe/1GP8mZb6R0KqiL5YNYDL1kC1x/s0kf 9jmD/OCusVewGBmbmUNkKeLRUYv/bEq8hAHyMUzNSfHAwkF0TJOLgyDl/foUbFn1fbo4 KSdKQitJv+Qyutk1YbLRmN8NR4A8n9+IVxCU+ocHA34wqFFYoRaE6L1gHFzrujPt08oI /jrI+atDHohSbpur7YkdCEf4B5SGc5ZH0Q/0MTeSu+b3XcMW75HrzPXy+MxlAb+IiTki nRtugK1sqiNr1v7FPZcGenTb3KJt+DYG4xctd72K8+zs2x3nK6ckStOuAB0nNkOuWbgn blng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721252872; x=1721857672; 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=exmNDPsH0KpZQ3m+4rsADpeyE4/2w009QzC3/hhmhHY=; b=FZGtK7xAtjX+KvTfXCZLwvm2OPXuX3Ap2+wPA8m6Sou/VahuwzWeudkgY8PK2MG5s3 PGPLSbCunVar6gjX9sKK3EPFqwtgY4w6lVR1fdCgfVco/jEySNCsa7IFYU+lzLeMFo+p qGZdcitvjVtjDBV60twH9sSwqUq/KLt8sewF2GC5i58axi7Arpbu5FTZfVAWU86r7her ZTLBws8CY249VVF35FCBBcAGHz4uKqb/3WrVnHvZqRJJmdUH0Zti1PUxBzFsBVnDFoEI YnskpRqt6FfScnGO8gMkcQSGyuNJS5n3hropVxSQZevmKQOSPoNgXur22cOGMu7BVxZV Xu1g== X-Forwarded-Encrypted: i=1; AJvYcCUuVDEpsb94N9ZbYLhSxlponjPlzeLpQqh+4vqVpxONSOHYqxFOi6aqRnZ2cNBfQOCX4w5B6uzNmRt0U13pOLOIkLW0pRw= X-Gm-Message-State: AOJu0YxhuvrIpSrws+toCFdS3MNlSbMQIGk2xhZuDrLuolsGWdwy+XWc IKAmGcuAcwgm9uwfbV7Gh6MjlmUldOPsAQVQCA9xvfOvq8NbFZFWRFoObBhjVS4= X-Received: by 2002:a05:6000:2a8:b0:367:95d2:4ec0 with SMTP id ffacd0b85a97d-368317b4061mr1931740f8f.62.1721252872108; Wed, 17 Jul 2024 14:47:52 -0700 (PDT) Received: from localhost.localdomain ([176.187.208.21]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427c7797d74sm12319205e9.4.2024.07.17.14.47.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Jul 2024 14:47:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Bibo Mao , Jiaxun Yang , qemu-devel@nongnu.org Cc: Xianglai Li , Paolo Bonzini , Huacai Chen , Xiaojuan Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Song Gao Subject: [PATCH v3 04/17] hw/intc/loongson_ipi: Extract loongson_ipi_common_realize() Date: Wed, 17 Jul 2024 23:46:55 +0200 Message-ID: <20240717214708.78403-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240717214708.78403-1-philmd@linaro.org> References: <20240717214708.78403-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Bibo Mao Tested-by: Bibo Mao --- hw/intc/loongson_ipi.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c index 3b3481c43e..40ac769aad 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,20 +301,31 @@ 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"); + for (i = 0; i < s->num_cpu; i++) { + s->cpu[i].ipi = s; + + qdev_init_gpio_out(dev, &s->cpu[i].irq, 1); + } +} + +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 (i = 0; i < s->num_cpu; i++) { - s->cpu[i].ipi = s; + 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); - - qdev_init_gpio_out(dev, &s->cpu[i].irq, 1); } }