Re: [PATCH v5 16/16] iommu/hyperv: setup an IO-APIC IRQ remapping domain for root partition

Wei Liu
2021-02-04T16:50:39Z

On Thu, Feb 04, 2021 at 04:41:47PM +0000, Michael Kelley wrote:
> From: Wei Liu <wei.liu@kernel.org> Sent: Wednesday, February 3, 2021 4:47 AM
[...]
> > > > +
> > > > + if (level)
> > > > + intr_desc->trigger_mode = HV_INTERRUPT_TRIGGER_MODE_LEVEL;
> > > > + else
> > > > + intr_desc->trigger_mode = HV_INTERRUPT_TRIGGER_MODE_EDGE;
> > > > +
> > > > + __set_bit(vcpu, (unsigned long *)&intr_desc->target.vp_mask);
> > > > +
> > > > + status = hv_do_rep_hypercall(HVCALL_MAP_DEVICE_INTERRUPT, 0, 0, input,
> > output) &
> > > > + HV_HYPERCALL_RESULT_MASK;
> > > > + local_irq_restore(flags);
> > > > +
> > > > + *entry = output->interrupt_entry;
> > > > +
> > > > + return status;
> > >
> > > As a cross-check, I was comparing this code against hv_map_msi_interrupt(). They are
> > > mostly parallel, though some of the assignments are done in a different order. It's a nit,
> > > but making them as parallel as possible would be nice. :-)
> > >
> >
> > Indeed. I will see about factoring out a function.
>
> If factoring out a separate helper function is clumsy, just having the parallel code
> in the two functions be as similar as possible makes it easier to see what's the
> same and what's different.
>

No. It is not clumsy at all. I've done it in the newly posted v6.

I was baffled why I wrote hv_unmap_interrupt helper to be used by both
hv_unmap_ioapic_interrupt and hv_unmap_msi_interrupt in the previous
patch, but didn't write a hv_map_interrupt. Maybe I didn't have enough
coffee that day. :-/

Thanks for pointing out that issue. It definitely helped improve the
quality of this series.

Wei.