All of lore.kernel.org
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] ARM: KVM: add irqfd and irq routing support
Date: Thu, 19 Jun 2014 15:13:25 +0100	[thread overview]
Message-ID: <20140619141325.GB15659@arm.com> (raw)
In-Reply-To: <20140605143950.GA10079@lvm>

Hi all,

I'm currently adding VFIO support for kvmtool, so I'm interested in this
patch series (although actually from a PCI perspective).

Eric: can you CC me on future versions of this series please? Once things
start to stabilise, I can help with testing.

On Thu, Jun 05, 2014 at 03:39:50PM +0100, Christoffer Dall wrote:
> On Thu, Jun 05, 2014 at 03:15:15PM +0200, Eric Auger wrote:
> > On 06/05/2014 12:28 PM, Christoffer Dall wrote:
> > > On Mon, Jun 02, 2014 at 09:29:56AM +0200, Eric Auger wrote:
> > >> +                  kvm_debug("Inject irqchip routed vIRQ %d\n",
> > >> +                                  e->irqchip.pin);
> > >> +                  kvm_vgic_inject_irq(kvm, 0, spi, level);
> > >> +                  /*
> > >> +                   * toggling down vIRQ wire is directly handled in
> > >> +                   * process_maintenance for this reason:
> > >> +                   * irqfd_resampler_ack is called in
> > >> +                   * process_maintenance which holds the dist lock.
> > >> +                   * irqfd_resampler_ack calls kvm_set_irq
> > >> +                   * which ends_up calling kvm_vgic_inject_irq.
> > >> +                   * This later attempts to take the lock -> deadlock!
> > >> +                   */
> > >
> > > Not sure I understand this comment.  What are we trying to achieve, are
> > > we using some sort of a workaround to avoid a deadlock?
> >
> > What I wanted to point out here is I would have prefered to handle both
> > levels 0 and 1 in a symetrical manner. irqfd_resampler_ack (in eventfd)
> > is calling kvm_set_irq with level 0. This would be the prefered way to
> > toggle down the SPI at GIC input instead of doing this in
> > process_maintenance in a dirty manner. However this does work because
> > irqfd_resampler_ack is called in process_maintenance (the place where
> > the EOI is analyzed). process_maintenance holds the dist lock and would
> > eventually call kvm_vgic_inject_irq which also attempts to take the lock.
> >
> 
> I'm afraid that's too much of a hack.  There's an external mechanism to
> set an interrupt line to active (level=1) or inactive (level=0) and we
> must support both.
> 
> The fact that vgic_process_maintenance() can set the interrupt line to
> inactive is just something we exploit to properly handle level-triggered
> interrupts, but the main API to the VGIC must absolutely be supported.
> 
> Am I completely wrong here?
> 
> The locking issue can be solved by splitting up the locking into a finer
> granularity as needed or deferring the call to irqfd_resampler_ack()
> until after unlocking the distributor lock in kvm_vgic_sync_hwstate().

Why can't we do what PowerPC does for mpic and x86 does for IOAPIC and
simply drop the distributor lock across the call to kvm_notify_acked_irq?

Given that I think the eventfd callbacks can block, holding a spinlock isn't
safe anyway, regardless of the vgic re-entrancy issue.

Will

WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Eric Auger <eric.auger@linaro.org>,
	"eric.auger@st.com" <eric.auger@st.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"patches@linaro.org" <patches@linaro.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"christophe.barnichon@st.com" <christophe.barnichon@st.com>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v2] ARM: KVM: add irqfd and irq routing support
Date: Thu, 19 Jun 2014 15:13:25 +0100	[thread overview]
Message-ID: <20140619141325.GB15659@arm.com> (raw)
In-Reply-To: <20140605143950.GA10079@lvm>

Hi all,

I'm currently adding VFIO support for kvmtool, so I'm interested in this
patch series (although actually from a PCI perspective).

Eric: can you CC me on future versions of this series please? Once things
start to stabilise, I can help with testing.

On Thu, Jun 05, 2014 at 03:39:50PM +0100, Christoffer Dall wrote:
> On Thu, Jun 05, 2014 at 03:15:15PM +0200, Eric Auger wrote:
> > On 06/05/2014 12:28 PM, Christoffer Dall wrote:
> > > On Mon, Jun 02, 2014 at 09:29:56AM +0200, Eric Auger wrote:
> > >> +                  kvm_debug("Inject irqchip routed vIRQ %d\n",
> > >> +                                  e->irqchip.pin);
> > >> +                  kvm_vgic_inject_irq(kvm, 0, spi, level);
> > >> +                  /*
> > >> +                   * toggling down vIRQ wire is directly handled in
> > >> +                   * process_maintenance for this reason:
> > >> +                   * irqfd_resampler_ack is called in
> > >> +                   * process_maintenance which holds the dist lock.
> > >> +                   * irqfd_resampler_ack calls kvm_set_irq
> > >> +                   * which ends_up calling kvm_vgic_inject_irq.
> > >> +                   * This later attempts to take the lock -> deadlock!
> > >> +                   */
> > >
> > > Not sure I understand this comment.  What are we trying to achieve, are
> > > we using some sort of a workaround to avoid a deadlock?
> >
> > What I wanted to point out here is I would have prefered to handle both
> > levels 0 and 1 in a symetrical manner. irqfd_resampler_ack (in eventfd)
> > is calling kvm_set_irq with level 0. This would be the prefered way to
> > toggle down the SPI at GIC input instead of doing this in
> > process_maintenance in a dirty manner. However this does work because
> > irqfd_resampler_ack is called in process_maintenance (the place where
> > the EOI is analyzed). process_maintenance holds the dist lock and would
> > eventually call kvm_vgic_inject_irq which also attempts to take the lock.
> >
> 
> I'm afraid that's too much of a hack.  There's an external mechanism to
> set an interrupt line to active (level=1) or inactive (level=0) and we
> must support both.
> 
> The fact that vgic_process_maintenance() can set the interrupt line to
> inactive is just something we exploit to properly handle level-triggered
> interrupts, but the main API to the VGIC must absolutely be supported.
> 
> Am I completely wrong here?
> 
> The locking issue can be solved by splitting up the locking into a finer
> granularity as needed or deferring the call to irqfd_resampler_ack()
> until after unlocking the distributor lock in kvm_vgic_sync_hwstate().

Why can't we do what PowerPC does for mpic and x86 does for IOAPIC and
simply drop the distributor lock across the call to kvm_notify_acked_irq?

Given that I think the eventfd callbacks can block, holding a spinlock isn't
safe anyway, regardless of the vgic re-entrancy issue.

Will

  parent reply	other threads:[~2014-06-19 14:13 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-02  7:29 [PATCH v2] ARM: KVM: add irqfd and irq routing support Eric Auger
2014-06-02  7:29 ` Eric Auger
2014-06-02 13:54 ` Marc Zyngier
2014-06-02 13:54   ` Marc Zyngier
2014-06-02 14:42   ` Eric Auger
2014-06-02 14:42     ` Eric Auger
2014-06-05 10:37     ` Christoffer Dall
2014-06-05 10:37       ` Christoffer Dall
2014-06-06 12:36       ` Christoffer Dall
2014-06-06 12:36         ` Christoffer Dall
2014-06-06 12:16   ` Christoffer Dall
2014-06-06 12:16     ` Christoffer Dall
2014-06-17 11:42     ` Eric Auger
2014-06-17 11:42       ` Eric Auger
2014-06-05 10:28 ` Christoffer Dall
2014-06-05 10:28   ` Christoffer Dall
2014-06-05 13:15   ` Eric Auger
2014-06-05 13:15     ` Eric Auger
2014-06-05 14:39     ` Christoffer Dall
2014-06-05 14:39       ` Christoffer Dall
2014-06-05 15:58       ` Eric Auger
2014-06-05 15:58         ` Eric Auger
2014-06-05 16:08         ` Christoffer Dall
2014-06-05 16:08           ` Christoffer Dall
2014-06-06  7:41           ` Eric Auger
2014-06-06  7:41             ` Eric Auger
2014-06-19 14:13       ` Will Deacon [this message]
2014-06-19 14:13         ` Will Deacon
2014-06-19 14:40         ` Eric Auger
2014-06-19 14:40           ` Eric Auger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140619141325.GB15659@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.