Yuji Shimada
2009-Mar-13 04:59 UTC
[Xen-devel] [PATCH] ioemu: unmap INTx interrupt on hot-remove
This patch unmaps INTx interrupt on hot-remove. Please apply this patch after applying the following patch. [Xen-devel] [PATCH] ioemu: msi/msix clean up on hotplug remove Thanks, -- Yuji Shimada Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp> diff --git a/hw/pass-through.c b/hw/pass-through.c index ee52960..4e7f447 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -46,6 +46,8 @@ struct dpci_infos { } dpci_infos; +char mapped_machine_irq[PT_NR_IRQS] = {0}; + /* prototype */ static uint32_t pt_common_reg_init(struct pt_dev *ptdev, struct pt_reg_info_tbl *reg, uint32_t real_offset); @@ -3657,6 +3659,7 @@ struct pt_dev * register_real_device(PCIBus *e_bus, { machine_irq = pirq; assigned_device->machine_irq = pirq; + mapped_machine_irq[machine_irq]++; } } @@ -3737,6 +3740,19 @@ int unregister_real_device(int php_slot) if (assigned_device->msix) pt_msix_disable(assigned_device); + if (machine_irq) + { + mapped_machine_irq[machine_irq]--; + + if (mapped_machine_irq[machine_irq] == 0) + { + rc = xc_physdev_unmap_pirq(xc_handle, domid, machine_irq); + + if (rc < 0) + PT_LOG("Error: Unmaping of interrupt failed! rc=%d\n", rc); + } + } + /* delete all emulated config registers */ pt_config_delete(assigned_device); diff --git a/hw/pass-through.h b/hw/pass-through.h index e86d311..6679fc2 100644 --- a/hw/pass-through.h +++ b/hw/pass-through.h @@ -40,6 +40,7 @@ #define PT_MACHINE_IRQ_AUTO (0xFFFFFFFF) #define PT_VIRT_DEVFN_AUTO (-1) +#define PT_NR_IRQS (256) /* Misc PCI constants that should be moved to a separate library :) */ #define PCI_CONFIG_SIZE (256) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Mar-26 05:12 UTC
Re: [Xen-devel] [PATCH] ioemu: unmap INTx interrupt on hot-remove
On Fri, Mar 13, 2009 at 01:59:24PM +0900, Yuji Shimada wrote:> This patch unmaps INTx interrupt on hot-remove. > > Please apply this patch after applying the following patch. > > [Xen-devel] [PATCH] ioemu: msi/msix clean up on hotplug remove > > Thanks, > -- > Yuji Shimada > > > Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp> > > diff --git a/hw/pass-through.c b/hw/pass-through.c > index ee52960..4e7f447 100644 > --- a/hw/pass-through.c > +++ b/hw/pass-through.c > @@ -46,6 +46,8 @@ struct dpci_infos { > > } dpci_infos; > > +char mapped_machine_irq[PT_NR_IRQS] = {0};This only initialises the first element of mapped_machine_irq[] to 0.> + > /* prototype */ > static uint32_t pt_common_reg_init(struct pt_dev *ptdev, > struct pt_reg_info_tbl *reg, uint32_t real_offset); > @@ -3657,6 +3659,7 @@ struct pt_dev * register_real_device(PCIBus *e_bus, > { > machine_irq = pirq; > assigned_device->machine_irq = pirq; > + mapped_machine_irq[machine_irq]++; > } > } > > @@ -3737,6 +3740,19 @@ int unregister_real_device(int php_slot) > if (assigned_device->msix) > pt_msix_disable(assigned_device); > > + if (machine_irq) > + { > + mapped_machine_irq[machine_irq]--; > + > + if (mapped_machine_irq[machine_irq] == 0) > + { > + rc = xc_physdev_unmap_pirq(xc_handle, domid, machine_irq); > + > + if (rc < 0) > + PT_LOG("Error: Unmaping of interrupt failed! rc=%d\n", rc); > + } > + } > + > /* delete all emulated config registers */ > pt_config_delete(assigned_device); > > diff --git a/hw/pass-through.h b/hw/pass-through.h > index e86d311..6679fc2 100644 > --- a/hw/pass-through.h > +++ b/hw/pass-through.h > @@ -40,6 +40,7 @@ > > #define PT_MACHINE_IRQ_AUTO (0xFFFFFFFF) > #define PT_VIRT_DEVFN_AUTO (-1) > +#define PT_NR_IRQS (256) > > /* Misc PCI constants that should be moved to a separate library :) */ > #define PCI_CONFIG_SIZE (256) > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel-- Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Yuji Shimada
2009-Mar-26 08:11 UTC
Re: [Xen-devel] [PATCH] ioemu: unmap INTx interrupt on hot-remove
On Thu, 26 Mar 2009 16:12:38 +1100 Simon Horman <horms@verge.net.au> wrote:> > +char mapped_machine_irq[PT_NR_IRQS] = {0}; > > This only initialises the first element of mapped_machine_irq[] to 0.Do you have any issue relating to this code? I think remaining elements are initialized to 0. Please read the following page. http://flash-gordon.me.uk/ansi.c.txt (3.5.7 Initialization) http://www.eskimo.com/~scs/cclass/notes/sx4aa.html http://stackoverflow.com/questions/201101/how-to-initialize-an-array-in-c Thanks, -- Yuji Shimada _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Mar-26 21:26 UTC
Re: [Xen-devel] [PATCH] ioemu: unmap INTx interrupt on hot-remove
On Thu, Mar 26, 2009 at 05:11:29PM +0900, Yuji Shimada wrote:> On Thu, 26 Mar 2009 16:12:38 +1100 > Simon Horman <horms@verge.net.au> wrote: > > > > +char mapped_machine_irq[PT_NR_IRQS] = {0}; > > > > This only initialises the first element of mapped_machine_irq[] to 0. > > Do you have any issue relating to this code? > I think remaining elements are initialized to 0.My issue is that the code doesn''t seem to be correct - though I have not experienced any problems. My understanding is that it may well be the case that the rest of the array is initialised to zero, by virtue of being a page that hasn''t been used since being received from the kernel. But I don''t believe that there are any guarantees that it doesn''t contain non-zero values. If my assumptions are wrong and it is the case that the contents of the array is guaranteed to be zeroed then the "{0}" seems to be misleading and it could just be removed. -- Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Cui, Dexuan
2009-Mar-27 07:29 UTC
RE: [Xen-devel] [PATCH] ioemu: unmap INTx interrupt on hot-remove
> +char mapped_machine_irq[PT_NR_IRQS] = {0};My understanding is: This does ensure all the elements of the array are 0, no matter the array is global or local. Because in C99's 6.7.8 Initialization, we can find 19 The initialization shall occur in initializer list order, each initializer provided for a particular subobject overriding any previously listed initializer for the same subobject; all subobjects that are not initialized explicitly shall be initialized implicitly the same as objects that have static storage duration. And as we all know, the default initial values for objects with static storage duration is 0. Considering the array mapped_machine_irq here, actually we don't need the "{0}" initializer as the array is global so its default initial values are just 0. I personally think adding a redundant "{0}" for a global array is somewhat misleading. :-) Thanks, -- Dexuan -----Original Message----- From: xen-devel-bounces@lists.xensource.com [mailto:xen-devel-bounces@lists.xensource.com] On Behalf Of Simon Horman Sent: 2009年3月27日 5:26 To: Yuji Shimada Cc: xen-devel@lists.xensource.com Subject: Re: [Xen-devel] [PATCH] ioemu: unmap INTx interrupt on hot-remove On Thu, Mar 26, 2009 at 05:11:29PM +0900, Yuji Shimada wrote:> On Thu, 26 Mar 2009 16:12:38 +1100 > Simon Horman <horms@verge.net.au> wrote: > > > > +char mapped_machine_irq[PT_NR_IRQS] = {0}; > > > > This only initialises the first element of mapped_machine_irq[] to 0. > > Do you have any issue relating to this code? > I think remaining elements are initialized to 0.My issue is that the code doesn't seem to be correct - though I have not experienced any problems. My understanding is that it may well be the case that the rest of the array is initialised to zero, by virtue of being a page that hasn't been used since being received from the kernel. But I don't believe that there are any guarantees that it doesn't contain non-zero values. If my assumptions are wrong and it is the case that the contents of the array is guaranteed to be zeroed then the "{0}" seems to be misleading and it could just be removed. -- Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2009-Mar-27 08:54 UTC
Re: [Xen-devel] [PATCH] ioemu: unmap INTx interrupt on hot-remove
On 27/03/2009 07:29, "Cui, Dexuan" <dexuan.cui@intel.com> wrote:>> +char mapped_machine_irq[PT_NR_IRQS] = {0}; > My understanding is: > This does ensure all the elements of the array are 0, no matter the array is > global or local. Because in C99''s 6.7.8 Initialization, we can findDexuan is correct. If you specify an incomplete initializer, the unspecified data values default to zero. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Mar-29 21:44 UTC
Re: [Xen-devel] [PATCH] ioemu: unmap INTx interrupt on hot-remove
On Fri, Mar 27, 2009 at 08:54:33AM +0000, Keir Fraser wrote:> On 27/03/2009 07:29, "Cui, Dexuan" <dexuan.cui@intel.com> wrote: > > >> +char mapped_machine_irq[PT_NR_IRQS] = {0}; > > My understanding is: > > This does ensure all the elements of the array are 0, no matter the array is > > global or local. Because in C99''s 6.7.8 Initialization, we can find > > Dexuan is correct. If you specify an incomplete initializer, the unspecified > data values default to zero.Thanks, I wasn''t aware of that. -- Simon Horman VA Linux Systems Japan K.K., Sydney, Australia Satellite Office H: www.vergenet.net/~horms/ W: www.valinux.co.jp/en _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2009-Mar-30 15:13 UTC
Re: [Xen-devel] [PATCH] ioemu: unmap INTx interrupt on hot-remove
Simon Horman writes ("Re: [Xen-devel] [PATCH] ioemu: unmap INTx interrupt on hot-remove"):> On Fri, Mar 13, 2009 at 01:59:24PM +0900, Yuji Shimada wrote: > > +char mapped_machine_irq[PT_NR_IRQS] = {0}; > > This only initialises the first element of mapped_machine_irq[] to 0.Statically allocated objects (that is, ones in the data and code segments rather than on the stack) are initialised to 0 by the system anyway. But I agree that it''s an unusual style. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel