From patchwork Thu Jul 18 13:32:57 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: 813198 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp296345wro; Thu, 18 Jul 2024 06:34:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXdjSLr7pVU3fFOFbcVHPrjaKMKi8Gd3+w74I7ZGJON22kxwynpx9kjoAYlbNGHlYB7kNHfOfs3hJ2Ks7VibZZO X-Google-Smtp-Source: AGHT+IEibew8sVzjm1+a1RRIjWmAWOJcu+iin9v/DkfLxShP3NfGYLE8Ugp3/RKrFvYy1YvKo1mv X-Received: by 2002:a05:6122:3d10:b0:4ef:5a4c:ab5e with SMTP id 71dfb90a1353d-4f4df688316mr6450953e0c.5.1721309659384; Thu, 18 Jul 2024 06:34:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721309659; cv=none; d=google.com; s=arc-20160816; b=Lu8vS8ChtrjukaFStdOXSJUg4s38xCSbRoFjM/vaDbMN8ZLiMdmCyFRhkKvLUu+SXm lBJASoMgwNA3dbqKxGggiKuslFV8vSbrUOz/JDV42fsvkWGyJlsFRfqIHIyuuUX4sS2n tFwgIhg0cTSY+UFWFZIwodvMJKdhq9dAczRPWRhD0LlLkaxYLqRP7uCs+8HKd6kbnQpm jTl7Or3QssOIvvKXkV5r4YIf04eVIiHDB6DzuSG/yzaHVtGMBJ9Exx926HS0d2R1VwbS oahQwNiVImOzLGVu/0OTAtN7pbT0dr3BcOxBbJvcfxc9zYx8zfOzxrSlIYSeErHw53Am 595w== 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=dJ1Jzmp+9J5R2QdMsXruspBz2Qg6XytMsq9xTnRszl0=; fh=Ma3NITrTLTG+PofQVfaX8SyzK2cu8WMhBV0JvV/fBpU=; b=aW/siqvXweHwYG4w9GSZyDlhwdRGkSsj1pIqKnJnrU+PYI+zTFTMGHtIPNes6ROvNA Z/wnnMvV9xIMWj31xE/q4ryKCb6h0zNHC7Uolq4ixxa1/jNLlRRX0lAzlJXCoBZuAGo/ oItCxoHhA0dh+Lwoe/ralK57vGwS2OraEFy2DTqsKEQivKzt4+n1DJImndTII+V6zNZL YQ6wu9prAgZomgdqpL7uS4xVbu5Kit8/VJqzOZBPfCM8UHJ4i9qZ66EnsvHXkpv1HB7b huKHGv/+EWvHZoanUN0eeUFzB8ZviG9HesAcU2oRAUgceJ5EKBkMu2JqvOvSROOpXQbh vnWw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ieHRK1T5; 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 ada2fe7eead31-491560a2cd4si1021602137.111.2024.07.18.06.34.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 06:34:18 -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=ieHRK1T5; 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 1sURGZ-0004p1-04; Thu, 18 Jul 2024 09:33:51 -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 1sURGV-0004c2-LM for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:33:47 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sURGS-0008SK-VM for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:33:46 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4266b1f1b21so2808235e9.1 for ; Thu, 18 Jul 2024 06:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721309623; x=1721914423; 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=dJ1Jzmp+9J5R2QdMsXruspBz2Qg6XytMsq9xTnRszl0=; b=ieHRK1T5Ezk1fvP0vGybye/1zaS0mdq2hKS5mJttBmYDokg1ZqhpziDAmeah3MIiW3 3fbK+1Kt79EE1CSEcwEG5UEV21SPnmXZAtERDB+GOlk8mda2f4SfQC1LwSRyyq2GRoCW vjcAYQHnVs9Bj0uCJcBbfBUWR8lesmOBbM3rj5BBXwlifztD8/AaKh0k67M3iqEHp/RF f5OdxGEAFK4PA7MsNikX6ln4vYB7uVYgoG5d3hm7yyUGWQKoFneVeWwf+0I8TDqLGqxc M/Rgyl73kZNmdNRQakn5RNmpyrFOS4fZHomN7G46dIbeiCk1SPLBO7YR4DCQRAnSqICy u4HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721309623; x=1721914423; 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=dJ1Jzmp+9J5R2QdMsXruspBz2Qg6XytMsq9xTnRszl0=; b=gjVaSfgcJvTKgvhYkDBKj8z4bHJRN+JSgBYKZK5qMT+5VtF5DxWfK5KEe69hFHhCe0 YkNl4dAZ7l/YBMtM+4RMiO+p4FBg7eQxz7z5pangDrD+VGbIN6xYW/dcSI+Defoaws9p GKmR9tDHummSdyMGggOQlkXJdbMgku45GdAKpii9ixR1jTqVxMVz36VVCXNRfKxB97Hj jdyxPzWVNxzGrvgCj9lxlcnQV0zIyQL2A/kTpQBisneFhgd9l/e5LWal7KaW7P9Tlobe eH2h2lXfIaF6d97Hn/KLkYnoOrNK+vKqhcEegML5LsB0xFjUHNtDbFIVeuG+QtsZ8rBk PnXQ== X-Forwarded-Encrypted: i=1; AJvYcCVenk2hjsKMKSE3SYgHZh1MgAkmv0kSUxdIQEN87V3RbQpnNJcwYK5FSnZrtmPfFreyL/R9faDDXc03edv+j9eeWHQhVAo= X-Gm-Message-State: AOJu0YxCStksGdXg5N9wVEpltodD2bVbwhzdXaZvf45tjCBEoCvvXBFX E2ra2+Vr4DxznOV9YngCnT4Dt9P2AaJoizLLSligethD1ifSCGll5xrHXXVQpIc= X-Received: by 2002:a05:600c:4ec6:b0:427:9dad:8063 with SMTP id 5b1f17b1804b1-427c2cc3000mr34172355e9.12.1721309623577; Thu, 18 Jul 2024 06:33:43 -0700 (PDT) Received: from localhost.localdomain ([176.176.173.113]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2b1815esm13697925e9.13.2024.07.18.06.33.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 18 Jul 2024 06:33:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Bibo Mao , qemu-devel@nongnu.org, Jiaxun Yang Cc: Song Gao , Paolo Bonzini , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Xiaojuan Yang , Xianglai Li Subject: [PATCH v5 05/19] hw/intc/loongson_ipi: Extract loongson_ipi_common_realize() Date: Thu, 18 Jul 2024 15:32:57 +0200 Message-ID: <20240718133312.10324-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240718133312.10324-1-philmd@linaro.org> References: <20240718133312.10324-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 --- 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 960d1e604f..bab4d8816b 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); } }