From nobody Tue Apr 23 23:51:40 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1559471264; cv=none; d=zoho.com; s=zohoarc; b=a3mpQyMYjDHYDHy0zsCmPgOrh0neixJPXF0qTLq8c7uD1qrp2qtYWDc91kts/yG593dSo0EYqLW5OLpybc9oY6wP0QdOszNHZnrHNpHPPZ5g6MtKmrxbYAKXgohPot3qJKRjmYXKrvQ0Q4JgFVa3dhzdNnkDzY6T8bjg6moF/NI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559471264; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=g7NBlk9d0GVm9Z42UiE19jOaeZ7IurtWu2R7RQi0eeE=; b=ds5zDCJ8BCZyQslpXe+nQUZORm88WoMI9zGJwzqppiTE6btLneneLIB/O8r1YbHBMOITviCuElJFLx9ypy1EdVflYOig3eIKq5+tnMuLYAPrxifMuYxve4FHy4d8xwzsavVrctiVUKUGjvU6KD6SV5M0ogMaKGDYQDZPmW0ZkrY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1559471263933705.6446035114959; Sun, 2 Jun 2019 03:27:43 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXNh1-00015j-5o; Sun, 02 Jun 2019 10:26:23 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXNgz-00015e-KL for xen-devel@lists.xenproject.org; Sun, 02 Jun 2019 10:26:21 +0000 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id dcae1dce-8520-11e9-8980-bc764e045a96; Sun, 02 Jun 2019 10:26:20 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B59AE374; Sun, 2 Jun 2019 03:26:19 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A50733F5AF; Sun, 2 Jun 2019 03:26:18 -0700 (PDT) X-Inumbo-ID: dcae1dce-8520-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Sun, 2 Jun 2019 11:26:14 +0100 Message-Id: <20190602102614.22640-1-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 Subject: [Xen-devel] [PATCH v2] xen/arm: irq: Don't use _IRQ_PENDING when handling host interrupt X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, andrii_anisov@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" While SPIs are shared between CPU, it is not possible to receive the same interrupts on a different CPU while the interrupt is in active state. For host interrupt (i.e routed to Xen), the deactivation of the interrupt is done at the end of the handling. This can alternatively be done outside of the handler by calling gic_set_active_state(). At the moment, gic_set_active_state() is only called by the vGIC for interrupt routed to the guest. It is hard to find a reason for Xen to directly play with the active state for interrupt routed to Xen. To simplify the handling of host interrupt, gic_set_activate_state() is now restricted to interrupts routed to guest. This means the _IRQ_PENDING logic is now unecessary on Arm as a same interrupt can never come up while in the loop and nobody should play with the flag behind our back. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov Reviewed-by: Stefano Stabellini --- Changes in v2: - gic_set_active_state should only be called on interrupt routed to guest. - Update the commit message --- xen/arch/arm/irq.c | 32 ++++++++++---------------------- xen/include/asm-arm/gic.h | 4 ++++ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index c51cf333ce..3877657a52 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -199,6 +199,7 @@ int request_irq(unsigned int irq, unsigned int irqflags, void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq) { struct irq_desc *desc =3D irq_to_desc(irq); + struct irqaction *action; =20 perfc_incr(irqs); =20 @@ -242,35 +243,22 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int = irq, int is_fiq) goto out_no_end; } =20 - set_bit(_IRQ_PENDING, &desc->status); - - /* - * Since we set PENDING, if another processor is handling a different - * instance of this same irq, the other processor will take care of it. - */ - if ( test_bit(_IRQ_DISABLED, &desc->status) || - test_bit(_IRQ_INPROGRESS, &desc->status) ) + if ( test_bit(_IRQ_DISABLED, &desc->status) ) goto out; =20 set_bit(_IRQ_INPROGRESS, &desc->status); =20 - while ( test_bit(_IRQ_PENDING, &desc->status) ) - { - struct irqaction *action; + action =3D desc->action; =20 - clear_bit(_IRQ_PENDING, &desc->status); - action =3D desc->action; + spin_unlock_irq(&desc->lock); =20 - spin_unlock_irq(&desc->lock); - - do - { - action->handler(irq, action->dev_id, regs); - action =3D action->next; - } while ( action ); + do + { + action->handler(irq, action->dev_id, regs); + action =3D action->next; + } while ( action ); =20 - spin_lock_irq(&desc->lock); - } + spin_lock_irq(&desc->lock); =20 clear_bit(_IRQ_INPROGRESS, &desc->status); =20 diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index fab02f19f7..876727c144 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -400,9 +400,13 @@ static inline unsigned int gic_get_nr_lrs(void) * Set the active state of an IRQ. This should be used with care, as this * directly forces the active bit, without considering the GIC state machi= ne. * For private IRQs this only works for those of the current CPU. + * + * This should only be called with interrupt routed to guest. The flow + * of interrupt routed to Xen any software change of the state. */ static inline void gic_set_active_state(struct irq_desc *irqd, bool state) { + ASSERT(test_bit(_IRQ_GUEST, &irqd->status)); gic_hw_ops->set_active_state(irqd, state); } =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel