From patchwork Mon Aug 5 18:06:16 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: 816740 Delivered-To: patch@linaro.org Received: by 2002:adf:e00d:0:b0:367:895a:4699 with SMTP id s13csp1469782wrh; Mon, 5 Aug 2024 11:08:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXiCVC32mP+l547aErsto7NWnIriz9b/jvlQy57b4rylbL4qovFTVjApD6Xu+AQLVHlHcR8xmF0GZyPwOZJEyhI X-Google-Smtp-Source: AGHT+IGz0CbHOuNhjrFBELzjuZMBprT3bdT46FKYoiwGxbKG/ro4abcEnkVMwWm7/Wq/yf6EWf9T X-Received: by 2002:a05:620a:178f:b0:7a2:d64:14ff with SMTP id af79cd13be357-7a34eec29c9mr1581427985a.9.1722881280105; Mon, 05 Aug 2024 11:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722881280; cv=none; d=google.com; s=arc-20160816; b=fm3+T3tHSIUXdmnnBMhDqSoODY6zBKBNmNg0mruKqWe28ecqy/lfgVJ5E37XoKW1es e8mj075egd2RbL/d81SwtEmwTdqW5ccR+tryB5BmhEpRTNoDXLyrTDmMVUhGiY/2VGVS ru+WWVcYJ/4wCxtzEi77tNphrKd9SaCBvzTWyXjIXT30iPn/0HDHcj47XIiGz5e4hUXz gfNv+p0jRYDU1CRL4UOpu2xwwRLRyjvK0zs/wVNzHMRRL7fu5qFMPsGagx47W8QHZ8HC S20EyQnLfmWgxBE+u0yN40MqzALuRkPQBvp7e0gnFkVdyWQm+Ih1ENBGd0P/notPVyJa 0TMw== 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=TWI9WsLINkzAsWulOrb1N3N13JevfSw6Gy6N0mmyEKk=; fh=9FIv2ryHyUdV0M0E/xImFOb7ha8RVmpB9WW8IcVSbKs=; b=R1I8xzFyWPgMcIN8r2W61tbPN67RO4gPzl9Q3dBezIzewkk68jBdO5LSNKU13pdWvy rH4jZkInOuHRxmCypr2Uz7WgkEAIub906pWXG1g5qxW+CmT5ztqSb+Pavbgr/SWTwqoE 8YozJQz3jtl+xnMC0Fk4EWIBnYWIzaAbG3zMYWGrDlhktgNTEzGzXT1/Ft+dCyGzD+QO ZVntBKg4KDIXMwq1K91rILF6mUwlUofLsMMCsac+Shh6/CM6oZI2cdWpnIsOG0OUfy+K 1Gw6pwJN2QGk6TwW43OIOsXC0Ncts8fQJKuGy8WFGNmjJZxA1PU0ndSnhZIwdRWB2mXm hnLQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fHrTqtHX; 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-7a34f74b541si1008094985a.262.2024.08.05.11.07.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Aug 2024 11:08:00 -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=fHrTqtHX; 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 1sb27F-0000RP-2i; Mon, 05 Aug 2024 14:07:29 -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 1sb27E-0000H2-09 for qemu-devel@nongnu.org; Mon, 05 Aug 2024 14:07:28 -0400 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sb27C-0006QN-0U for qemu-devel@nongnu.org; Mon, 05 Aug 2024 14:07:27 -0400 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2f1798eaee6so18244461fa.0 for ; Mon, 05 Aug 2024 11:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722881244; x=1723486044; 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=TWI9WsLINkzAsWulOrb1N3N13JevfSw6Gy6N0mmyEKk=; b=fHrTqtHXd2ZcTORlSrRbkbNjor9biQl4Ff0C5gJky1QVXZo47A9fCXVuVAa8l2Q0U6 fR/BOuAE8hw2Uec+j14I4cFQVXeZSXEnL5jPcjMbfmeqKl4t6LTk6OHzBrsVVPVItHCV ffPkVhiy19aesTRilUjw6QvXY8YSL9kHcIkeaHYKrKLsnkaT8NQZKQn/vYf9sODRO9Gc OgO2iLm+OZh+v0tzGVTGz8jo65n7tnBDeQI4ZdZYdK5i5zKLLveMZVPjTxCmKRV8nTQl 826LGFp759bmaDuFLyLRD1HYtZUzVPCYCCWtJ7pRCiTncJd3K7nlc2Ctn7TiA8GWiw3C XxuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722881244; x=1723486044; 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=TWI9WsLINkzAsWulOrb1N3N13JevfSw6Gy6N0mmyEKk=; b=HPF2DaUJwwig4TvRL8miwFrFaOS2fB4uMoZyTwMa3CNlHao3QAFBk+vyeiIykEahyl Jn0iNPfWP5xQnuw/PcP1iJUaiUxWHFvR7YjAVpn4LC2qMSEOQoHdu5ZtTEc+DYvIiwht KcZhfnGLHNIvBjp/0sWheCP06f3G3EjEgEYfJd1dv62pnUI3a6n7YykKpph2Tp1zScxy x7wgVYHYFiJHE6OHhtu+qziV4iygmMpT+vv/d+K2nSu59aM6S14CvxIRjatIb09im+El 5nM3XK0E9sunUbLs3BbqD8dT2TfYZqGPCPOdRShVyVGBD/pFgeAoY3o4oaOMwRBDdLwS 9DbQ== X-Gm-Message-State: AOJu0YyjXQ2jh+UZZlW2gC1cPGtKarvYbY4alqgMtwAaKPLLuQzedWDj 9B7xaM8kXb9ENHGTgdEpDQsDHwu/Fzg4xgzIdy3ySQ4EzEm2XlBRGHIJSNJqVhB+/6j5dkZqBf4 g X-Received: by 2002:a2e:9b58:0:b0:2ed:5c34:4082 with SMTP id 38308e7fff4ca-2f15aa8354emr81576271fa.8.1722881243507; Mon, 05 Aug 2024 11:07:23 -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-36bbd059841sm10737504f8f.89.2024.08.05.11.07.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 05 Aug 2024 11:07:22 -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 09/15] hw/intc/loongson_ipi: Add LoongsonIPICommonClass::cpu_by_arch_id handler Date: Mon, 5 Aug 2024 20:06:16 +0200 Message-ID: <20240805180622.21001-10-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::22b; envelope-from=philmd@linaro.org; helo=mail-lj1-x22b.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 Allow Loongson IPI implementations to have their own cpu_by_arch_id() handler. 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-13-philmd@linaro.org> --- include/hw/intc/loongson_ipi_common.h | 1 + hw/intc/loongson_ipi.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/hw/intc/loongson_ipi_common.h b/include/hw/intc/loongson_ipi_common.h index 1a2ee41cc9..8997676f0d 100644 --- a/include/hw/intc/loongson_ipi_common.h +++ b/include/hw/intc/loongson_ipi_common.h @@ -41,6 +41,7 @@ struct LoongsonIPICommonClass { SysBusDeviceClass parent_class; AddressSpace *(*get_iocsr_as)(CPUState *cpu); + CPUState *(*cpu_by_arch_id)(int64_t id); }; /* Mainy used by iocsr read and write */ diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c index eb99de9068..4a8e743528 100644 --- a/hw/intc/loongson_ipi.c +++ b/hw/intc/loongson_ipi.c @@ -128,12 +128,13 @@ static MemTxResult send_ipi_data(LoongsonIPICommonState *ipi, CPUState *cpu, static MemTxResult mail_send(LoongsonIPICommonState *ipi, uint64_t val, MemTxAttrs attrs) { + LoongsonIPICommonClass *licc = LOONGSON_IPI_COMMON_GET_CLASS(ipi); uint32_t cpuid; hwaddr addr; CPUState *cs; cpuid = extract32(val, 16, 10); - cs = cpu_by_arch_id(cpuid); + cs = licc->cpu_by_arch_id(cpuid); if (cs == NULL) { return MEMTX_DECODE_ERROR; } @@ -147,12 +148,13 @@ static MemTxResult mail_send(LoongsonIPICommonState *ipi, static MemTxResult any_send(LoongsonIPICommonState *ipi, uint64_t val, MemTxAttrs attrs) { + LoongsonIPICommonClass *licc = LOONGSON_IPI_COMMON_GET_CLASS(ipi); uint32_t cpuid; hwaddr addr; CPUState *cs; cpuid = extract32(val, 16, 10); - cs = cpu_by_arch_id(cpuid); + cs = licc->cpu_by_arch_id(cpuid); if (cs == NULL) { return MEMTX_DECODE_ERROR; } @@ -169,6 +171,7 @@ static MemTxResult loongson_ipi_core_writel(void *opaque, hwaddr addr, { IPICore *s = opaque; LoongsonIPICommonState *ipi = s->ipi; + LoongsonIPICommonClass *licc = LOONGSON_IPI_COMMON_GET_CLASS(ipi); int index = 0; uint32_t cpuid; uint8_t vector; @@ -203,7 +206,7 @@ static MemTxResult loongson_ipi_core_writel(void *opaque, hwaddr addr, cpuid = extract32(val, 16, 10); /* IPI status vector */ vector = extract8(val, 0, 5); - cs = cpu_by_arch_id(cpuid); + cs = licc->cpu_by_arch_id(cpuid); if (cs == NULL || cs->cpu_index >= ipi->num_cpu) { return MEMTX_DECODE_ERROR; } @@ -367,6 +370,7 @@ static void loongson_ipi_class_init(ObjectClass *klass, void *data) device_class_set_parent_unrealize(dc, loongson_ipi_unrealize, &lic->parent_unrealize); licc->get_iocsr_as = get_iocsr_as; + licc->cpu_by_arch_id = cpu_by_arch_id; } static const TypeInfo loongson_ipi_types[] = {