From patchwork Thu Jul 18 13:33:04 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: 813201 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp296575wro; Thu, 18 Jul 2024 06:34:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVRmBi2WRRkA4AJSfyp8Wvnea4XtXuvsphWQt9Kjat6dBZ22rTPKX8OVyDljC4Mi1M4Dh17WuKtQX5cnIku92l2 X-Google-Smtp-Source: AGHT+IF+TJBCQB3FPuMoOL9v1UA7hWpJ61TjH4e7VnxsIutX+RS4sAO23b7IXRayJSwaGJXTNFxM X-Received: by 2002:a05:620a:370f:b0:79f:1731:ae24 with SMTP id af79cd13be357-7a19390b964mr103630185a.32.1721309685601; Thu, 18 Jul 2024 06:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721309685; cv=none; d=google.com; s=arc-20160816; b=q93oo7feDGrx+k0KTeo2I2x9Fs8gvSY1G3SWINiy3bRmYo2bYLJHaC0EZmNLA5DuDc KfX4wtJBoENAf4ITxrjK1Uk3MeqWy7h9euhA7pD3qi55Ds6UON0mlmW0Qq+kcH/8nOvd MwnJRUdV6csQzl2fNZLhSZW38xRNoW2M6Uege8yE8TKKlwO/5zPAzy30uxgg33fNnVJn ZSkzS3Jq0gwMJ5jz8jXuPWxkrKuXdWVmlg89YlCBuNubUAJKrcWiOXYQQk7xjpI7opn7 Xbj8oLsQH9jTwfIs99X38/NHbcdqh57DaCbNYoIlx7p/uTfMYIcBhT4B+54WYoHS4iDe /tqg== 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=0+OxJiG+z3ssF/3QJZPn0rn/Ivu5hISnKA+KGQ086vg=; fh=UvpztvDzfIrJXBGeMpateaxtmz8AES1IeU4CVSQy5xk=; b=0zN/6LT8ZaiYO6GSmhWJi79VikQtnoeNNofb/YEqFwL7bqi+o8dspYTinOev1RFZ1w FXNK0dq9KLeGZlcsY+8oQ5OQfdumVXRQmmiXbHRnKc3SK5whS2/9GhK2qmD2VQH+1aow +mOktju5grY7aZhz6ByDAIPomLXvdSrIV/zgsmJLYL/W79rL8kVmiRezsSnuNlLZkisi XhE9c8YRj3zuw3v4NquTTS9oWEVyPKAhr97XBdj4eDj2AyKZZmPPPSKwkXLoqgNuvUKK ajl7fwZXivunYQeEKyUzAxSx5bZPoREamfegNbS9DAMZb+/QIZXTX1P5Xa27gsfpmeN0 BSLg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hwDyVAfT; 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-7a1939b2ad1si56858585a.583.2024.07.18.06.34.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 06:34:45 -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=hwDyVAfT; 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 1sURHC-0001Bw-4v; Thu, 18 Jul 2024 09:34:30 -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 1sURHA-00010k-5g for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:34:28 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sURH8-00005i-E4 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:34:27 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-367b8a60b60so526070f8f.2 for ; Thu, 18 Jul 2024 06:34:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721309665; x=1721914465; 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=0+OxJiG+z3ssF/3QJZPn0rn/Ivu5hISnKA+KGQ086vg=; b=hwDyVAfTKPofCaxYMKdnFC5+csFksV2A1cLZgt+QaOwseFktExvtWW7hIYKJFDqwD0 fzlOm7NKNU8J1Rj9bWemW7t4+rrWkRfjEBfsjdBQAmp7IG3YY4xO9AFCUPf+MyNMeHmi nHqCJz+yqe/HLS+YwvB7nRXSUIuRPxssEvju97jeEYPQLFQsF3iXqM2tKaCRC5sgZQyt JKUTnfdkq9cfF6xJF8RmWNLeTvAnVPbifESnON4Vo+5l+MD//Eyc3b4euqNieDWEUAP2 +XPFbKZOoOffKttAjrNfhRTebJLfnnBI4S06NRBmjKFo3sVj0+WFwSA9UrqmjM1SCDJU ka4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721309665; x=1721914465; 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=0+OxJiG+z3ssF/3QJZPn0rn/Ivu5hISnKA+KGQ086vg=; b=IHwwJIlCi3TJNLmep1M2kDffjggjVl1BMSpT5h0NmtzZgM7fpgvBM9l3praZrwqdF1 FpRsV3VSrQ0ujBb/2MSEFvhgzh47s+ZX49yqRMjB04stA+RukW9Ik6JG9Jp8E4oMnUee P9bZW9DbIr4b8qTCPJph0sCJWJe8ugAYYdPefN79Zmw9vuXXAzgwEAICGNbwz/SI8+tA /5l006hTEQPLTwolE4gFTcBg7oP6Jjm+tMCP0iVi8dtobdfOlTsCUx7GQOzDnM0XlTer c14MikYdWgycFNb75WJ1Ln5pvpp5CAM28ltRK/mHw5cNtov8VT/rj2S2NVv2T32zlRyc uO2w== X-Forwarded-Encrypted: i=1; AJvYcCVgKqKbfeM5V2XF5Wus84TZ8LzLGNLmTKReINCF1kK8LE3utSJx+2f3RR7w2gP8EnOAGXosgxmql8KVWvHJn9mANboC5mM= X-Gm-Message-State: AOJu0Yz1KYBRw4Fc5rv7My4+CradJPoHFuaZZBDZIRMRy2z+u/eLQVFg khCkkSrG4NkzHBVrLVINbtWEGI/MCjvuny4QjFyipQ7mlrN7Td/x3UWnCwNuP6E= X-Received: by 2002:a5d:6488:0:b0:367:f245:d847 with SMTP id ffacd0b85a97d-368315edb49mr4725844f8f.2.1721309664766; Thu, 18 Jul 2024 06:34:24 -0700 (PDT) Received: from localhost.localdomain ([176.176.173.113]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680db047c4sm14339224f8f.108.2024.07.18.06.34.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 18 Jul 2024 06:34:24 -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 12/19] hw/intc/loongson_ipi: Add LoongsonIPICommonClass::cpu_by_arch_id handler Date: Thu, 18 Jul 2024 15:33:04 +0200 Message-ID: <20240718133312.10324-13-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::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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 --- 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 e49c156db3..5447e9f650 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 2c8829c3cc..39bcf0031d 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; } @@ -349,6 +352,7 @@ static void loongson_ipi_class_init(ObjectClass *klass, void *data) device_class_set_parent_realize(dc, loongson_ipi_realize, &lic->parent_realize); licc->get_iocsr_as = get_iocsr_as; + licc->cpu_by_arch_id = cpu_by_arch_id; } static void loongson_ipi_finalize(Object *obj)