From patchwork Tue Sep 19 06:56:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Wei X-Patchwork-Id: 1836743 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Verisilicon.com header.i=@Verisilicon.com header.a=rsa-sha256 header.s=default header.b=SrzK9l2e; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rqkd658Nmz1ynX for ; Wed, 20 Sep 2023 00:31:54 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qibki-00029k-0P; Tue, 19 Sep 2023 10:31:00 -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 1qiUkV-00055V-0X; Tue, 19 Sep 2023 03:02:19 -0400 Received: from shasxm03.verisilicon.com ([101.89.135.44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1qiUkS-0007vD-A4; Tue, 19 Sep 2023 03:02:18 -0400 Content-Language: zh-CN DKIM-Signature: v=1; a=rsa-sha256; d=Verisilicon.com; s=default; c=simple/simple; t=1695106588; h=from:subject:to:date:message-id; bh=AcqL0GPwR8yVgYjpwTXOYquzOfSzOhx0HrKi6AZ/J+U=; b=SrzK9l2eE/eZ1V4UufOAh/byTJaYRzVhMsILusWHY4K4FfDJYkmZfuv0U35fq3QBv+DsHv43urf th0j5JSJvdi36M7FsMbQ9hshFrPjRHrZ141VzpQB0EJEILSEktnko4a0Dp9D/sSyrdcZlpo7JnOnn Wrp27KFt7ckLO0UQ6OY= Received: from SHASXM06.verisilicon.com ([fe80::59a8:ce34:dc14:ddda]) by SHASXM03.verisilicon.com ([::1]) with mapi id 14.03.0408.000; Tue, 19 Sep 2023 14:56:28 +0800 From: Luca Wei To: "qemu-devel@nongnu.org" , "peter.maydell@linaro.org" , "richard.henderson@linaro.org" , "philmd@linaro.org" , "alex.williamson@redhat.com" CC: "eric.auger@linaro.org" , "qemu-stable@nongnu.org" , Luca Wei , Zijian Wang , Zhe Pan Subject: [PATCH] hw/intc/arm_gicv3_kvm.c: Set the qemu_irq/gsi mapping for VFIO platform Thread-Topic: [PATCH] hw/intc/arm_gicv3_kvm.c: Set the qemu_irq/gsi mapping for VFIO platform Thread-Index: AdnqxmktPrHVh4ILQ0GyPV2lkqMP1Q== Date: Tue, 19 Sep 2023 06:56:28 +0000 Message-ID: <2FDAC4096138FA4DB2F2BDCE0F9521C00182151E@SHASXM06.verisilicon.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.10.91.89] MIME-Version: 1.0 Received-SPF: pass client-ip=101.89.135.44; envelope-from=Luca.Wei@verisilicon.com; helo=shasxm03.verisilicon.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 19 Sep 2023 10:30:57 -0400 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Eric added the qemu_irq/gsi hash table to let VFIO platform device setup irqfd when kvm enabled [1]. And he setup the qemu_irq/gsi mapping in arm_gic_kvm.c [2]. But this mapping is not setting up in arm_gicv3_kvm.c. When VM use VFIO platform device with gicv3, the irqfd setup will fail and fallback to userspace handled eventfd in `vfio_start_irqfd_injection`. This patch will setup the qemu_irq/gsi mapping for gicv3, so that VFIO platform device with gicv3 can use kvm irqfd to accelerate. [1] https://lore.kernel.org/qemu-devel/20150706183506.15635.61812.stgit@gimli.home/ [2] https://lore.kernel.org/qemu-devel/20150706183512.15635.915.stgit@gimli.home/ Signed-off-by: Luca Wei --- hw/intc/arm_gicv3_kvm.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.41.0.windows.3 diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 72ad916d3d..7e90f8b723 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -807,6 +807,11 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL); + for (i = 0; i < s->num_irq - GIC_INTERNAL; i++) { + qemu_irq irq = qdev_get_gpio_in(dev, i); + kvm_irqchip_set_qemuirq_gsi(kvm_state, irq, i); + } + for (i = 0; i < s->num_cpu; i++) { ARMCPU *cpu = ARM_CPU(qemu_get_cpu(i));