> -----Original Message-----
> From: Alex Williamson [mailto:alex.william...@redhat.com]
> Sent: Wednesday, October 14, 2020 10:32 AM
> To: tiantao (H) <tiant...@hisilicon.com>
> Cc: eric.au...@redhat.com; coh...@redhat.com; k...@vger.kernel.org;
> linux-kernel@vger.kernel.org; Song Bao Hua (Barry Song)
> <song.bao....@hisilicon.com>; Linuxarm <linux...@huawei.com>
> Subject: Re: [PATCH] vfio/platform: Replace spin_lock_irqsave by spin_lock in
> hard IRQ
> 
> On Tue, 13 Oct 2020 10:00:58 +0800
> Tian Tao <tiant...@hisilicon.com> wrote:
> 
> > It is redundant to do irqsave and irqrestore in hardIRQ context.
> 
> But this function is also called from non-IRQ context.  Thanks,

It seems you mean
vfio_platform_set_irqs_ioctl() ->
vfio_platform_set_irq_trigger ->
handler() ?

so, will it be better to move the irqsave out of the 
vfio_automasked_irq_handler()
and put it to where the function is called in non-IRQ context?

I mean:

irqhandler()
{
        spin_lock()  //without irqsave
        spin_unlock()
}

Non-irq context which is calling this handler:
irqsave();
irqhandler();
irqrestore();

Anyway, if it is called in IRQ context, it is redundant to do irqsave.

> 
> Alex
> 
> > Signed-off-by: Tian Tao <tiant...@hisilicon.com>
> > ---
> >  drivers/vfio/platform/vfio_platform_irq.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/vfio/platform/vfio_platform_irq.c
> b/drivers/vfio/platform/vfio_platform_irq.c
> > index c5b09ec..24fd6c5 100644
> > --- a/drivers/vfio/platform/vfio_platform_irq.c
> > +++ b/drivers/vfio/platform/vfio_platform_irq.c
> > @@ -139,10 +139,9 @@ static int vfio_platform_set_irq_unmask(struct
> vfio_platform_device *vdev,
> >  static irqreturn_t vfio_automasked_irq_handler(int irq, void *dev_id)
> >  {
> >     struct vfio_platform_irq *irq_ctx = dev_id;
> > -   unsigned long flags;
> >     int ret = IRQ_NONE;
> >
> > -   spin_lock_irqsave(&irq_ctx->lock, flags);
> > +   spin_lock(&irq_ctx->lock);
> >
> >     if (!irq_ctx->masked) {
> >             ret = IRQ_HANDLED;
> > @@ -152,7 +151,7 @@ static irqreturn_t vfio_automasked_irq_handler(int
> irq, void *dev_id)
> >             irq_ctx->masked = true;
> >     }
> >
> > -   spin_unlock_irqrestore(&irq_ctx->lock, flags);
> > +   spin_unlock(&irq_ctx->lock);
> >
> >     if (ret == IRQ_HANDLED)
> >             eventfd_signal(irq_ctx->trigger, 1);

Thanks
Barry

Reply via email to