From patchwork Thu Jul 18 08:38:35 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: 813147 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp189053wro; Thu, 18 Jul 2024 01:41:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWJIAN8apgBUu4JU4uxVbjsqCt7lRhtE2dfMajozeJXNWvMIYkDRcKbPN6X1D4Uxp1S0LrzgYVQowCev5ojOC3t X-Google-Smtp-Source: AGHT+IEfZCNEwy43HZr3dgfWrXqqQlwRb3xw/DiWjVWXDwCbq3a2ojgIlDAh5JxkscnfQ/FW1G9/ X-Received: by 2002:a05:6102:8007:b0:48f:8b6b:75a3 with SMTP id ada2fe7eead31-491598b1ff7mr5432529137.8.1721292092525; Thu, 18 Jul 2024 01:41:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721292092; cv=none; d=google.com; s=arc-20160816; b=EjdT+zjjXXHFkBMyL3NNjIwaW7U3dS66WVzpe9hgl/UPjYjTHNefctrFk2hSOYbHUH X58PqVsDO9m4Mkc9UPMIIm9WhPgD7C5QFs/9VA4IepGnK8lGeM7spxWmP/2ssxB7Aof1 r0tutpYqcPYVr3bxl+/G6F0lMfW3xtmPJVVoQJjt7KOsETtENFAjKGGKrHMHlassdzvT ToMVCJRScVXYXzwQGnF8MZ/o5TOPuwedpJuS8fjdn+eK8a79YRD8ta1kovLGNDrXPQL1 /Pr+JoGQgGrh2dnn3ME7d5gFT42moc+sZQBbU6kKVUK35k+t+80AoY8lMN3LPVgx2Rap XC6w== 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=2fEZNDPPoxKFs7H+NykCV578N/mSSTlQ4AcK8WKF7wg=; fh=NLZWUfvz+g+MnoIWE6nGov3chqHrPo6wetxAC/CDqtI=; b=Uv26y/Wu7LONEFALatzQGNZTKNlC3XHSFwvma6gBhh2O1cQiguCGJBCWWn6asvXYlP Ap4zwFa8CC+hykj++wePFI+QIavTs61pv4vw4wGl7DAzGfSA8ck+vEkrqEPXSxX2FyTV 4miRzsi1IsA6R7yxZdXUMU76Pr05k5vuBi6OMjxtpTpye7eoo7Ueeoa8MPRMIzQBBEgx XCD5/1ZPwgPirqRxmdIZy7th5o32ZhPjM2r+LH8TQfdN7zU/LyALXaST9Ph80B7qG8IA b6F+powQCk1JkQrQOGqHwYYcw8yfGF4PZ2bdi3hNo5Vltli1jOLJ6hssMzA/p5//xklz A/xA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uTZ4wTLc; 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 6a1803df08f44-6b79c7fb7d1si14951126d6.387.2024.07.18.01.41.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 01:41:32 -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=uTZ4wTLc; 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 1sUMgZ-0008Hb-TU; Thu, 18 Jul 2024 04:40:23 -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 1sUMgS-0007bw-43 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 04:40:17 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUMgO-00050P-T0 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 04:40:15 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4266f535e82so458285e9.1 for ; Thu, 18 Jul 2024 01:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721292010; x=1721896810; 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=2fEZNDPPoxKFs7H+NykCV578N/mSSTlQ4AcK8WKF7wg=; b=uTZ4wTLczI+btDEFXH4SXV9IEsLHPUZqWWTBHAG93UP01dp4gycuezrcpYBNrnxFNR RmwdBDHoqSgT9PXRrBPCUdyJUQleMzlr9bfGKkaV+9G3Cuv1rhw1KIXesD7Iw+LWxWUE 6LT+1qRNFaUJfxGFAqfK4+SjUkqpwpVpdkY6I7DXkR9RYS/SN5GQGoQnn84LvlyorzxJ ROmyPQ4cqSJgbjPymp3X2OJro6VLPPrw7PSBVIV4tD4/sQKs5GhXBw2dz1z+3XoL2gTw cx4Tcd7W0pQQGn2cwThu76T9iBnmpqUdWyxXF8a+cRcfzbxnS31GKaaxsQltX/JB31Uc +JUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721292010; x=1721896810; 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=2fEZNDPPoxKFs7H+NykCV578N/mSSTlQ4AcK8WKF7wg=; b=vTImp92B/Xcmv6tltedz2FJI2CzEZdMCeERbZRyvoYtHyIOSUZdBEqK9nFCc7I/7Ij RjhAx0/dwTwoLKeDTIon1eQm4l7KVnnCTmbFrOwbYZwxDHT0tmttbkYICnUtLG0fsWHw nDTgTH1k56tFSiqo+ocxsmn4Y/toOCq7ViUZb1qmKaWXI8nAYy+6LZflob1Nmal9J2Ld XLm1dYEjB9HTfjOKx5x2TqaQ2kRx+i/QQ+37/wQxoEHVrYXxU+EmBckJ0YGoFyeP4iBB qTi+xHZ6pYmipnEGxg7wdJHhMLxzmn9xVLcBoAXp/lHhxkLVx9GKp+M8zJbJngFw0ZOd Luxw== X-Gm-Message-State: AOJu0Yz7mPIKH2E6YmLmtQim0exx3q/0Cakuoq1U0+aP1XXEfXDasvK5 GkJwZxzJ3DOH/JcUgslN71RCR1xcD0MbhjzCld0jHPzbtjWb+H9Nsc2c6+pm3U+M5XeLutVwc21 lWC0= X-Received: by 2002:a05:600c:4f56:b0:426:6f17:531 with SMTP id 5b1f17b1804b1-427c2cb15cbmr36424125e9.13.1721292010081; Thu, 18 Jul 2024 01:40:10 -0700 (PDT) Received: from localhost.localdomain ([176.187.208.21]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2b133bdsm1495305e9.10.2024.07.18.01.40.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 18 Jul 2024 01:40:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Bibo Mao , Jiaxun Yang Cc: Song Gao , Xianglai Li , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Xiaojuan Yang , Paolo Bonzini Subject: [PATCH v4 11/18] hw/intc/loongson_ipi: Add LoongsonIPICommonClass::get_iocsr_as handler Date: Thu, 18 Jul 2024 10:38:35 +0200 Message-ID: <20240718083842.81199-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240718083842.81199-1-philmd@linaro.org> References: <20240718083842.81199-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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 get_iocsr_as() 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 Reviewed-by: Richard Henderson --- include/hw/intc/loongson_ipi_common.h | 2 ++ hw/intc/loongson_ipi.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/hw/intc/loongson_ipi_common.h b/include/hw/intc/loongson_ipi_common.h index 891b43644d..e49c156db3 100644 --- a/include/hw/intc/loongson_ipi_common.h +++ b/include/hw/intc/loongson_ipi_common.h @@ -39,6 +39,8 @@ struct LoongsonIPICommonState { struct LoongsonIPICommonClass { SysBusDeviceClass parent_class; + + AddressSpace *(*get_iocsr_as)(CPUState *cpu); }; /* Mainy used by iocsr read and write */ diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c index a54db87638..2c8829c3cc 100644 --- a/hw/intc/loongson_ipi.c +++ b/hw/intc/loongson_ipi.c @@ -75,24 +75,30 @@ static MemTxResult loongson_ipi_iocsr_readl(void *opaque, hwaddr addr, return loongson_ipi_core_readl(s, addr, data, size, attrs); } -static AddressSpace *get_cpu_iocsr_as(CPUState *cpu) -{ #ifdef TARGET_LOONGARCH64 +static AddressSpace *get_iocsr_as(CPUState *cpu) +{ return LOONGARCH_CPU(cpu)->env.address_space_iocsr; +} #endif + #ifdef TARGET_MIPS +static AddressSpace *get_iocsr_as(CPUState *cpu) +{ if (ase_lcsr_available(&MIPS_CPU(cpu)->env)) { return &MIPS_CPU(cpu)->env.iocsr.as; } -#endif + return NULL; } +#endif static MemTxResult send_ipi_data(LoongsonIPICommonState *ipi, CPUState *cpu, uint64_t val, hwaddr addr, MemTxAttrs attrs) { + LoongsonIPICommonClass *licc = LOONGSON_IPI_COMMON_GET_CLASS(ipi); int i, mask = 0, data = 0; - AddressSpace *iocsr_as = get_cpu_iocsr_as(cpu); + AddressSpace *iocsr_as = licc->get_iocsr_as(cpu); if (!iocsr_as) { return MEMTX_DECODE_ERROR; @@ -338,9 +344,11 @@ static void loongson_ipi_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); LoongsonIPIClass *lic = LOONGSON_IPI_CLASS(klass); + LoongsonIPICommonClass *licc = LOONGSON_IPI_COMMON_CLASS(klass); device_class_set_parent_realize(dc, loongson_ipi_realize, &lic->parent_realize); + licc->get_iocsr_as = get_iocsr_as; } static void loongson_ipi_finalize(Object *obj)