From patchwork Tue Aug 6 12:51:37 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: 817038 Delivered-To: patch@linaro.org Received: by 2002:adf:e00d:0:b0:367:895a:4699 with SMTP id s13csp1782723wrh; Tue, 6 Aug 2024 05:53:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUOd/cHdDh4xtQHuQbi9H6e6g66YbbjUCOtLbHTz8LOJgD1pp9JhquUj0pGoVJkNKmmCXnqNbTZpWDeV2fNRzQn X-Google-Smtp-Source: AGHT+IH97AwNFaLHiwDa/EfCSwhX679VSGxYPvgEDUrz5st2sOHL9I9HW0bOoDhaURxgLR7M1yD1 X-Received: by 2002:a05:622a:4d09:b0:451:a12d:b9e7 with SMTP id d75a77b69052e-451a12dbddfmr158624771cf.12.1722948818665; Tue, 06 Aug 2024 05:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722948818; cv=none; d=google.com; s=arc-20160816; b=RMABETfVsweT2cRg0YhUrNf52ZME3HSbiJksKsfJCNFnRlwUMc/bJ7VryL8R78EGPT p23XtKwXaA8ZyBevT7DSns32JRe4UYoGN2fNAfPgcQHuS6K729w9/SMxbPBRHO3UV1wp jtSs7fmDasYM2tbZbqZFTUPaYlmw9TXtWGLSjIvUmKNBVImZky2N9M4rExaA5Ey4IKxR v/ddYe616flMbnVxH3gyWAQMnnx4m8kwRPPbjjQM48GL+besIr44NZ/Rp7IZSd7gM6nD qBWwtlpb2jNM6o4UeSQX2ZAVU7qKnzz5Nbjdrmk0ZJzhz70eVSNzKlGWknmc/MTw7n/Z FC7g== 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=Pc4HRKn0ABU9Etyo/i6+qtUkhxyrZpQEkVJjk1kRbzM=; fh=rxGWTSOrq9MmYE4+hMcV/u38d68oc92wX5eFok0A+84=; b=MHnxrMkoKxsfqky1eGTsAQwV7AH86jwWsSq3erhRcPra2o54Fg5oh/5wn0mhJebPBQ RJ0ehT/cPNPS6p8/v5UZWSRjOXNVGo6TJmXfTvIoPmczXxNP4Z4oFixkSg0GnEDu7H/k 4XcKSJEwlKz1dKo8EipjsgR6YBALzSVn4NQIV/Vv/NE64V6kZjE8zM4sEv2TrYm9v10w VMBa+04hzUbwkRzXVwzUA8gZoDgskT5E9oEUVbi4uruCkKw7Vs4Z8goHbAPo1O0RKipp 5tnIKevtppA0vnfokjgLCm8NYTLIgmugPxzOk1dDol1hVEVAObhRUvZWF1XrAyoTUNIL QPPw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zGVH41lO; 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 d75a77b69052e-4518a6e0da3si118137251cf.186.2024.08.06.05.53.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Aug 2024 05:53:38 -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=zGVH41lO; 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 1sbJgY-0000Op-VF; Tue, 06 Aug 2024 08:53:07 -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 1sbJgW-0000Cc-2R for qemu-devel@nongnu.org; Tue, 06 Aug 2024 08:53:04 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sbJgS-0008TS-Oy for qemu-devel@nongnu.org; Tue, 06 Aug 2024 08:53:03 -0400 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2ef2cce8be8so5935571fa.1 for ; Tue, 06 Aug 2024 05:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722948776; x=1723553576; 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=Pc4HRKn0ABU9Etyo/i6+qtUkhxyrZpQEkVJjk1kRbzM=; b=zGVH41lOfI9QobnLVPP3IKg1NYgCrWieIp1p3WUTV+RpcWc23XXHBfQe5+VMpMPUEE yufuoKP5ENFt5lTxe2FrRLNOtcrGgjJJXvZ4keeZi1/IiSa0fEHsdOkAs0k4sIhmFkmm cJJnBKDvTce82KL0gf4+9F7uDRQS/gHL0i8cyZ5KQ4GpAuK1jx4uisMPCDZP1/MJ/nDD LSVQ2DiLP9/Yzy+V7w/1QCOx9ubQQfUhbz4oldB2eSDlWoO50uynR16CXkAssPIQY3hr Zy0yL5JGhnHc9WMoqwtEa8FC599cadtyt4QiTTf304j78t2LzhPDOidCSEofP0mdU8qn wiaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722948776; x=1723553576; 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=Pc4HRKn0ABU9Etyo/i6+qtUkhxyrZpQEkVJjk1kRbzM=; b=ewmZ/2qylKEBxE9AqYJZx/jwuQ+5AYw1E7+A9dHKunHRgMYyeEKZyY/2zBXGzKV71E 1F8LCrWw5ZW3KexblnmxfFTjvgg59G3WcQMZfgO/2GZVoPnvig/rw5mRCMfMA4N8V2Pe 9O3NAg3HWb8h+j51LtlJ38aDRD4MQLS5s2xXpk63G+zv7TEkcnKaJDNeXYMGF5S5Wthl IrKy7neFGS4e4P9pkGYXn1yMcwXle2whyQUD8YMRwTKvLoEuHKZYYRRY3ATSsge4YSQH NZgzQpZbmSMU+pEIkIMErP57LCTtJ5pJ2bvE4x2ic8yuWz24mJbD9XDGaqQMCafkU7V/ YaiQ== X-Gm-Message-State: AOJu0YzFzSvwW8cNyf0SvMOSRNK+3vKB9R2T5PfN8lkNaKpZf4BC9cP7 vRNQKXTlqYBCFW6KIyGvK/cVqsdBci6YJm83IhUkDPV+fADisdTGNMvVhEh6RVNgwNCq3h8Elru X X-Received: by 2002:a05:6512:1051:b0:51a:f689:b4df with SMTP id 2adb3069b0e04-530bb39b06cmr11086986e87.44.1722948776211; Tue, 06 Aug 2024 05:52:56 -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-a7dc9e83eccsm543566666b.184.2024.08.06.05.52.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 06 Aug 2024 05:52:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Bibo Mao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Song Gao , Richard Henderson , Jiaxun Yang Subject: [PULL 09/28] hw/intc/loongson_ipi: Add LoongsonIPICommonClass::cpu_by_arch_id handler Date: Tue, 6 Aug 2024 14:51:37 +0200 Message-ID: <20240806125157.91185-10-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 Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=philmd@linaro.org; helo=mail-lj1-x235.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: <20240805180622.21001-10-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[] = {