All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed
@ 2014-12-24  8:56 ` Liang Li
  0 siblings, 0 replies; 12+ messages in thread
From: Liang Li @ 2014-12-24  8:56 UTC (permalink / raw)
  To: qemu-devel, xen-devel
  Cc: Liang Li, stefano.stabellini, mtosatti, mst, aliguori, robert.hu,
	yang.z.zhang, pbonzini, rth

Use the 'xl pci-attach $DomU $BDF' command to attach more then
one PCI devices to the guest, then detach the devices with
'xl pci-detach $DomU $BDF', after that, re-attach these PCI
devices again, an error message will be reported like following:

libxl: error: libxl_qmp.c:287:qmp_handle_error_response: receive
an error message from QMP server: Duplicate ID 'pci-pt-03_10.1'
for device.

The count of calling xen_pt_region_add and xen_pt_region_del are
not the same will cause the XenPCIPassthroughState and it's related
QemuOpts object not be released properly.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Reported-by: Longtao Pang <longtaox.pang@intel.com>
---
 hw/xen/xen_pt.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
index c1bf357..523b8a2 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -588,7 +588,6 @@ static void xen_pt_region_add(MemoryListener *l, MemoryRegionSection *sec)
     XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
                                              memory_listener);
 
-    memory_region_ref(sec->mr);
     xen_pt_region_update(s, sec, true);
 }
 
@@ -598,7 +597,6 @@ static void xen_pt_region_del(MemoryListener *l, MemoryRegionSection *sec)
                                              memory_listener);
 
     xen_pt_region_update(s, sec, false);
-    memory_region_unref(sec->mr);
 }
 
 static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection *sec)
@@ -606,7 +604,6 @@ static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection *sec)
     XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
                                              io_listener);
 
-    memory_region_ref(sec->mr);
     xen_pt_region_update(s, sec, true);
 }
 
@@ -616,7 +613,6 @@ static void xen_pt_io_region_del(MemoryListener *l, MemoryRegionSection *sec)
                                              io_listener);
 
     xen_pt_region_update(s, sec, false);
-    memory_region_unref(sec->mr);
 }
 
 static const MemoryListener xen_pt_memory_listener = {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] xen-pt: Fix PCI devices re-attach failed
@ 2014-12-24  8:56 ` Liang Li
  0 siblings, 0 replies; 12+ messages in thread
From: Liang Li @ 2014-12-24  8:56 UTC (permalink / raw)
  To: qemu-devel, xen-devel
  Cc: Liang Li, stefano.stabellini, mtosatti, mst, aliguori, robert.hu,
	yang.z.zhang, pbonzini, rth

Use the 'xl pci-attach $DomU $BDF' command to attach more then
one PCI devices to the guest, then detach the devices with
'xl pci-detach $DomU $BDF', after that, re-attach these PCI
devices again, an error message will be reported like following:

libxl: error: libxl_qmp.c:287:qmp_handle_error_response: receive
an error message from QMP server: Duplicate ID 'pci-pt-03_10.1'
for device.

The count of calling xen_pt_region_add and xen_pt_region_del are
not the same will cause the XenPCIPassthroughState and it's related
QemuOpts object not be released properly.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Reported-by: Longtao Pang <longtaox.pang@intel.com>
---
 hw/xen/xen_pt.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
index c1bf357..523b8a2 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -588,7 +588,6 @@ static void xen_pt_region_add(MemoryListener *l, MemoryRegionSection *sec)
     XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
                                              memory_listener);
 
-    memory_region_ref(sec->mr);
     xen_pt_region_update(s, sec, true);
 }
 
@@ -598,7 +597,6 @@ static void xen_pt_region_del(MemoryListener *l, MemoryRegionSection *sec)
                                              memory_listener);
 
     xen_pt_region_update(s, sec, false);
-    memory_region_unref(sec->mr);
 }
 
 static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection *sec)
@@ -606,7 +604,6 @@ static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection *sec)
     XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
                                              io_listener);
 
-    memory_region_ref(sec->mr);
     xen_pt_region_update(s, sec, true);
 }
 
@@ -616,7 +613,6 @@ static void xen_pt_io_region_del(MemoryListener *l, MemoryRegionSection *sec)
                                              io_listener);
 
     xen_pt_region_update(s, sec, false);
-    memory_region_unref(sec->mr);
 }
 
 static const MemoryListener xen_pt_memory_listener = {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed
  2014-12-24  8:56 ` Liang Li
@ 2015-01-12 11:36   ` Stefano Stabellini
  -1 siblings, 0 replies; 12+ messages in thread
From: Stefano Stabellini @ 2015-01-12 11:36 UTC (permalink / raw)
  To: Liang Li
  Cc: xen-devel, stefano.stabellini, mtosatti, qemu-devel, mst,
	aliguori, robert.hu, yang.z.zhang, pbonzini, rth

On Wed, 24 Dec 2014, Liang Li wrote:
> Use the 'xl pci-attach $DomU $BDF' command to attach more then
> one PCI devices to the guest, then detach the devices with
> 'xl pci-detach $DomU $BDF', after that, re-attach these PCI
> devices again, an error message will be reported like following:
> 
> libxl: error: libxl_qmp.c:287:qmp_handle_error_response: receive
> an error message from QMP server: Duplicate ID 'pci-pt-03_10.1'
> for device.
> 
> The count of calling xen_pt_region_add and xen_pt_region_del are
> not the same will cause the XenPCIPassthroughState and it's related
> QemuOpts object not be released properly.

Thanks for the patch!

>From this description, I don't quite understand why the
memory_region_ref and memory_region_unref calls are wrong.  What do you
mean by "The count of calling xen_pt_region_add and xen_pt_region_del
are not the same"?

On unplug xen_pt_region_del does not get called?
Or the memory region argument is not exactly the same as the one
initially passed to xen_pt_region_add?


> Signed-off-by: Liang Li <liang.z.li@intel.com>
> Reported-by: Longtao Pang <longtaox.pang@intel.com>
> ---
>  hw/xen/xen_pt.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
> index c1bf357..523b8a2 100644
> --- a/hw/xen/xen_pt.c
> +++ b/hw/xen/xen_pt.c
> @@ -588,7 +588,6 @@ static void xen_pt_region_add(MemoryListener *l, MemoryRegionSection *sec)
>      XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
>                                               memory_listener);
>  
> -    memory_region_ref(sec->mr);
>      xen_pt_region_update(s, sec, true);
>  }
>  
> @@ -598,7 +597,6 @@ static void xen_pt_region_del(MemoryListener *l, MemoryRegionSection *sec)
>                                               memory_listener);
>  
>      xen_pt_region_update(s, sec, false);
> -    memory_region_unref(sec->mr);
>  }
>  
>  static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection *sec)
> @@ -606,7 +604,6 @@ static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection *sec)
>      XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
>                                               io_listener);
>  
> -    memory_region_ref(sec->mr);
>      xen_pt_region_update(s, sec, true);
>  }
>  
> @@ -616,7 +613,6 @@ static void xen_pt_io_region_del(MemoryListener *l, MemoryRegionSection *sec)
>                                               io_listener);
>  
>      xen_pt_region_update(s, sec, false);
> -    memory_region_unref(sec->mr);
>  }
>  
>  static const MemoryListener xen_pt_memory_listener = {
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] xen-pt: Fix PCI devices re-attach failed
@ 2015-01-12 11:36   ` Stefano Stabellini
  0 siblings, 0 replies; 12+ messages in thread
From: Stefano Stabellini @ 2015-01-12 11:36 UTC (permalink / raw)
  To: Liang Li
  Cc: xen-devel, stefano.stabellini, mtosatti, qemu-devel, mst,
	aliguori, robert.hu, yang.z.zhang, pbonzini, rth

On Wed, 24 Dec 2014, Liang Li wrote:
> Use the 'xl pci-attach $DomU $BDF' command to attach more then
> one PCI devices to the guest, then detach the devices with
> 'xl pci-detach $DomU $BDF', after that, re-attach these PCI
> devices again, an error message will be reported like following:
> 
> libxl: error: libxl_qmp.c:287:qmp_handle_error_response: receive
> an error message from QMP server: Duplicate ID 'pci-pt-03_10.1'
> for device.
> 
> The count of calling xen_pt_region_add and xen_pt_region_del are
> not the same will cause the XenPCIPassthroughState and it's related
> QemuOpts object not be released properly.

Thanks for the patch!

>From this description, I don't quite understand why the
memory_region_ref and memory_region_unref calls are wrong.  What do you
mean by "The count of calling xen_pt_region_add and xen_pt_region_del
are not the same"?

On unplug xen_pt_region_del does not get called?
Or the memory region argument is not exactly the same as the one
initially passed to xen_pt_region_add?


> Signed-off-by: Liang Li <liang.z.li@intel.com>
> Reported-by: Longtao Pang <longtaox.pang@intel.com>
> ---
>  hw/xen/xen_pt.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
> index c1bf357..523b8a2 100644
> --- a/hw/xen/xen_pt.c
> +++ b/hw/xen/xen_pt.c
> @@ -588,7 +588,6 @@ static void xen_pt_region_add(MemoryListener *l, MemoryRegionSection *sec)
>      XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
>                                               memory_listener);
>  
> -    memory_region_ref(sec->mr);
>      xen_pt_region_update(s, sec, true);
>  }
>  
> @@ -598,7 +597,6 @@ static void xen_pt_region_del(MemoryListener *l, MemoryRegionSection *sec)
>                                               memory_listener);
>  
>      xen_pt_region_update(s, sec, false);
> -    memory_region_unref(sec->mr);
>  }
>  
>  static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection *sec)
> @@ -606,7 +604,6 @@ static void xen_pt_io_region_add(MemoryListener *l, MemoryRegionSection *sec)
>      XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
>                                               io_listener);
>  
> -    memory_region_ref(sec->mr);
>      xen_pt_region_update(s, sec, true);
>  }
>  
> @@ -616,7 +613,6 @@ static void xen_pt_io_region_del(MemoryListener *l, MemoryRegionSection *sec)
>                                               io_listener);
>  
>      xen_pt_region_update(s, sec, false);
> -    memory_region_unref(sec->mr);
>  }
>  
>  static const MemoryListener xen_pt_memory_listener = {
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [Xen-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed
  2015-01-12 11:36   ` Stefano Stabellini
@ 2015-01-12 12:02     ` Tian, Kevin
  -1 siblings, 0 replies; 12+ messages in thread
From: Tian, Kevin @ 2015-01-12 12:02 UTC (permalink / raw)
  To: Stefano Stabellini, Li, Liang Z
  Cc: xen-devel, mst, mtosatti, qemu-devel, aliguori, pbonzini, Zhang,
	Yang Z, Hu, Robert, rth

> From: Stefano Stabellini
> Sent: Monday, January 12, 2015 7:36 PM
> 
> On Wed, 24 Dec 2014, Liang Li wrote:
> > Use the 'xl pci-attach $DomU $BDF' command to attach more then
> > one PCI devices to the guest, then detach the devices with
> > 'xl pci-detach $DomU $BDF', after that, re-attach these PCI
> > devices again, an error message will be reported like following:
> >
> > libxl: error: libxl_qmp.c:287:qmp_handle_error_response: receive
> > an error message from QMP server: Duplicate ID 'pci-pt-03_10.1'
> > for device.
> >
> > The count of calling xen_pt_region_add and xen_pt_region_del are
> > not the same will cause the XenPCIPassthroughState and it's related
> > QemuOpts object not be released properly.
> 
> Thanks for the patch!
> 
> From this description, I don't quite understand why the
> memory_region_ref and memory_region_unref calls are wrong.  What do
> you
> mean by "The count of calling xen_pt_region_add and xen_pt_region_del
> are not the same"?
> 
> On unplug xen_pt_region_del does not get called?
> Or the memory region argument is not exactly the same as the one
> initially passed to xen_pt_region_add?
> 

agree. Liang, could you elaborate how the patch is associated with above 
explanation? :-)

> 
> > Signed-off-by: Liang Li <liang.z.li@intel.com>
> > Reported-by: Longtao Pang <longtaox.pang@intel.com>
> > ---
> >  hw/xen/xen_pt.c | 4 ----
> >  1 file changed, 4 deletions(-)
> >
> > diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
> > index c1bf357..523b8a2 100644
> > --- a/hw/xen/xen_pt.c
> > +++ b/hw/xen/xen_pt.c
> > @@ -588,7 +588,6 @@ static void xen_pt_region_add(MemoryListener *l,
> MemoryRegionSection *sec)
> >      XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
> >                                               memory_listener);
> >
> > -    memory_region_ref(sec->mr);
> >      xen_pt_region_update(s, sec, true);
> >  }
> >
> > @@ -598,7 +597,6 @@ static void xen_pt_region_del(MemoryListener *l,
> MemoryRegionSection *sec)
> >                                               memory_listener);
> >
> >      xen_pt_region_update(s, sec, false);
> > -    memory_region_unref(sec->mr);
> >  }
> >
> >  static void xen_pt_io_region_add(MemoryListener *l,
> MemoryRegionSection *sec)
> > @@ -606,7 +604,6 @@ static void xen_pt_io_region_add(MemoryListener
> *l, MemoryRegionSection *sec)
> >      XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
> >                                               io_listener);
> >
> > -    memory_region_ref(sec->mr);
> >      xen_pt_region_update(s, sec, true);
> >  }
> >
> > @@ -616,7 +613,6 @@ static void xen_pt_io_region_del(MemoryListener *l,
> MemoryRegionSection *sec)
> >                                               io_listener);
> >
> >      xen_pt_region_update(s, sec, false);
> > -    memory_region_unref(sec->mr);
> >  }
> >
> >  static const MemoryListener xen_pt_memory_listener = {
> > --
> > 1.9.1
> >
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] xen-pt: Fix PCI devices re-attach failed
@ 2015-01-12 12:02     ` Tian, Kevin
  0 siblings, 0 replies; 12+ messages in thread
From: Tian, Kevin @ 2015-01-12 12:02 UTC (permalink / raw)
  To: Stefano Stabellini, Li, Liang Z
  Cc: xen-devel, mst, mtosatti, qemu-devel, aliguori, pbonzini, Zhang,
	Yang Z, Hu, Robert, rth

> From: Stefano Stabellini
> Sent: Monday, January 12, 2015 7:36 PM
> 
> On Wed, 24 Dec 2014, Liang Li wrote:
> > Use the 'xl pci-attach $DomU $BDF' command to attach more then
> > one PCI devices to the guest, then detach the devices with
> > 'xl pci-detach $DomU $BDF', after that, re-attach these PCI
> > devices again, an error message will be reported like following:
> >
> > libxl: error: libxl_qmp.c:287:qmp_handle_error_response: receive
> > an error message from QMP server: Duplicate ID 'pci-pt-03_10.1'
> > for device.
> >
> > The count of calling xen_pt_region_add and xen_pt_region_del are
> > not the same will cause the XenPCIPassthroughState and it's related
> > QemuOpts object not be released properly.
> 
> Thanks for the patch!
> 
> From this description, I don't quite understand why the
> memory_region_ref and memory_region_unref calls are wrong.  What do
> you
> mean by "The count of calling xen_pt_region_add and xen_pt_region_del
> are not the same"?
> 
> On unplug xen_pt_region_del does not get called?
> Or the memory region argument is not exactly the same as the one
> initially passed to xen_pt_region_add?
> 

agree. Liang, could you elaborate how the patch is associated with above 
explanation? :-)

> 
> > Signed-off-by: Liang Li <liang.z.li@intel.com>
> > Reported-by: Longtao Pang <longtaox.pang@intel.com>
> > ---
> >  hw/xen/xen_pt.c | 4 ----
> >  1 file changed, 4 deletions(-)
> >
> > diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
> > index c1bf357..523b8a2 100644
> > --- a/hw/xen/xen_pt.c
> > +++ b/hw/xen/xen_pt.c
> > @@ -588,7 +588,6 @@ static void xen_pt_region_add(MemoryListener *l,
> MemoryRegionSection *sec)
> >      XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
> >                                               memory_listener);
> >
> > -    memory_region_ref(sec->mr);
> >      xen_pt_region_update(s, sec, true);
> >  }
> >
> > @@ -598,7 +597,6 @@ static void xen_pt_region_del(MemoryListener *l,
> MemoryRegionSection *sec)
> >                                               memory_listener);
> >
> >      xen_pt_region_update(s, sec, false);
> > -    memory_region_unref(sec->mr);
> >  }
> >
> >  static void xen_pt_io_region_add(MemoryListener *l,
> MemoryRegionSection *sec)
> > @@ -606,7 +604,6 @@ static void xen_pt_io_region_add(MemoryListener
> *l, MemoryRegionSection *sec)
> >      XenPCIPassthroughState *s = container_of(l, XenPCIPassthroughState,
> >                                               io_listener);
> >
> > -    memory_region_ref(sec->mr);
> >      xen_pt_region_update(s, sec, true);
> >  }
> >
> > @@ -616,7 +613,6 @@ static void xen_pt_io_region_del(MemoryListener *l,
> MemoryRegionSection *sec)
> >                                               io_listener);
> >
> >      xen_pt_region_update(s, sec, false);
> > -    memory_region_unref(sec->mr);
> >  }
> >
> >  static const MemoryListener xen_pt_memory_listener = {
> > --
> > 1.9.1
> >
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [Xen-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed
  2015-01-12 12:02     ` Tian, Kevin
@ 2015-01-12 13:35       ` Li, Liang Z
  -1 siblings, 0 replies; 12+ messages in thread
From: Li, Liang Z @ 2015-01-12 13:35 UTC (permalink / raw)
  To: Tian, Kevin, Stefano Stabellini
  Cc: xen-devel, mst, mtosatti, qemu-devel, aliguori, pbonzini, Zhang,
	Yang Z, Hu, Robert, rth

> > > Use the 'xl pci-attach $DomU $BDF' command to attach more than one
> > > PCI devices to the guest, then detach the devices with 'xl
> > > pci-detach $DomU $BDF', after that, re-attach these PCI devices
> > > again, an error message will be reported like following:
> > >
> > > libxl: error: libxl_qmp.c:287:qmp_handle_error_response: receive an
> > > error message from QMP server: Duplicate ID 'pci-pt-03_10.1'
> > > for device.
> > >
> > > The count of calling xen_pt_region_add and xen_pt_region_del are not
> > > the same will cause the XenPCIPassthroughState and it's related
> > > QemuOpts object not be released properly.
> >
> > Thanks for the patch!
> >
> > From this description, I don't quite understand why the
> > memory_region_ref and memory_region_unref calls are wrong.  What do
> > you mean by "The count of calling xen_pt_region_add and
> > xen_pt_region_del are not the same"?

I means for some memory regions , only the xen_pt_region_add callback function
was called while the xen_pt_region_del was not called.

> > On unplug xen_pt_region_del does not get called?
> > Or the memory region argument is not exactly the same as the one
> > initially passed to xen_pt_region_add?
> >
> 
> agree. Liang, could you elaborate how the patch is associated with above
> explanation? :-)


I have verified the following patch can work too:

diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index c1bf357..f2893b2 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -736,7 +736,7 @@ static int xen_pt_initfn(PCIDevice *d)
     }
 
 out:
-    memory_listener_register(&s->memory_listener, &address_space_memory);
+    memory_listener_register(&s->memory_listener, 
+ &s->dev.bus_master_as);
     memory_listener_register(&s->io_listener, &address_space_io);
     XEN_PT_LOG(d,
                "Real physical device %02x:%02x.%d registered successfully!\n",

By further debugging, I found when using 'address_space_memory',  'xen_pt_region_del' 
won't be called when the memory region's name is not  ' xen-pci-pt-*', when using
 ' s->dev.bus_master_as ', there is no such issue.

I think use the device related address space here is more reasonable, but I am not sure.
 Could you give some suggestion?

Liang

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed
@ 2015-01-12 13:35       ` Li, Liang Z
  0 siblings, 0 replies; 12+ messages in thread
From: Li, Liang Z @ 2015-01-12 13:35 UTC (permalink / raw)
  To: Tian, Kevin, Stefano Stabellini
  Cc: xen-devel, mst, mtosatti, qemu-devel, aliguori, pbonzini, Zhang,
	Yang Z, Hu, Robert, rth

> > > Use the 'xl pci-attach $DomU $BDF' command to attach more than one
> > > PCI devices to the guest, then detach the devices with 'xl
> > > pci-detach $DomU $BDF', after that, re-attach these PCI devices
> > > again, an error message will be reported like following:
> > >
> > > libxl: error: libxl_qmp.c:287:qmp_handle_error_response: receive an
> > > error message from QMP server: Duplicate ID 'pci-pt-03_10.1'
> > > for device.
> > >
> > > The count of calling xen_pt_region_add and xen_pt_region_del are not
> > > the same will cause the XenPCIPassthroughState and it's related
> > > QemuOpts object not be released properly.
> >
> > Thanks for the patch!
> >
> > From this description, I don't quite understand why the
> > memory_region_ref and memory_region_unref calls are wrong.  What do
> > you mean by "The count of calling xen_pt_region_add and
> > xen_pt_region_del are not the same"?

I means for some memory regions , only the xen_pt_region_add callback function
was called while the xen_pt_region_del was not called.

> > On unplug xen_pt_region_del does not get called?
> > Or the memory region argument is not exactly the same as the one
> > initially passed to xen_pt_region_add?
> >
> 
> agree. Liang, could you elaborate how the patch is associated with above
> explanation? :-)


I have verified the following patch can work too:

diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index c1bf357..f2893b2 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -736,7 +736,7 @@ static int xen_pt_initfn(PCIDevice *d)
     }
 
 out:
-    memory_listener_register(&s->memory_listener, &address_space_memory);
+    memory_listener_register(&s->memory_listener, 
+ &s->dev.bus_master_as);
     memory_listener_register(&s->io_listener, &address_space_io);
     XEN_PT_LOG(d,
                "Real physical device %02x:%02x.%d registered successfully!\n",

By further debugging, I found when using 'address_space_memory',  'xen_pt_region_del' 
won't be called when the memory region's name is not  ' xen-pci-pt-*', when using
 ' s->dev.bus_master_as ', there is no such issue.

I think use the device related address space here is more reasonable, but I am not sure.
 Could you give some suggestion?

Liang

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [Xen-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed
  2015-01-12 13:35       ` Li, Liang Z
@ 2015-01-12 14:49         ` Paolo Bonzini
  -1 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2015-01-12 14:49 UTC (permalink / raw)
  To: Li, Liang Z, Tian, Kevin, Stefano Stabellini
  Cc: xen-devel, mst, mtosatti, qemu-devel, aliguori, Zhang, Yang Z,
	Hu, Robert, rth



On 12/01/2015 14:35, Li, Liang Z wrote:
> 
> diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index c1bf357..f2893b2 100644
> --- a/hw/xen/xen_pt.c
> +++ b/hw/xen/xen_pt.c
> @@ -736,7 +736,7 @@ static int xen_pt_initfn(PCIDevice *d)
>      }
>  
>  out:
> -    memory_listener_register(&s->memory_listener, &address_space_memory);
> +    memory_listener_register(&s->memory_listener, 
> + &s->dev.bus_master_as);
>      memory_listener_register(&s->io_listener, &address_space_io);
>      XEN_PT_LOG(d,
>                 "Real physical device %02x:%02x.%d registered successfully!\n",
> 
> By further debugging, I found when using 'address_space_memory',  'xen_pt_region_del' 
> won't be called when the memory region's name is not  ' xen-pci-pt-*', when using
>  ' s->dev.bus_master_as ', there is no such issue.
> 
> I think use the device related address space here is more reasonable, but I am not sure.
>  Could you give some suggestion?

Yes, this patch makes sense.  The listener will be called every time the
command register is written.

Paolo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed
@ 2015-01-12 14:49         ` Paolo Bonzini
  0 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2015-01-12 14:49 UTC (permalink / raw)
  To: Li, Liang Z, Tian, Kevin, Stefano Stabellini
  Cc: xen-devel, mst, mtosatti, qemu-devel, aliguori, Zhang, Yang Z,
	Hu, Robert, rth



On 12/01/2015 14:35, Li, Liang Z wrote:
> 
> diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index c1bf357..f2893b2 100644
> --- a/hw/xen/xen_pt.c
> +++ b/hw/xen/xen_pt.c
> @@ -736,7 +736,7 @@ static int xen_pt_initfn(PCIDevice *d)
>      }
>  
>  out:
> -    memory_listener_register(&s->memory_listener, &address_space_memory);
> +    memory_listener_register(&s->memory_listener, 
> + &s->dev.bus_master_as);
>      memory_listener_register(&s->io_listener, &address_space_io);
>      XEN_PT_LOG(d,
>                 "Real physical device %02x:%02x.%d registered successfully!\n",
> 
> By further debugging, I found when using 'address_space_memory',  'xen_pt_region_del' 
> won't be called when the memory region's name is not  ' xen-pci-pt-*', when using
>  ' s->dev.bus_master_as ', there is no such issue.
> 
> I think use the device related address space here is more reasonable, but I am not sure.
>  Could you give some suggestion?

Yes, this patch makes sense.  The listener will be called every time the
command register is written.

Paolo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [Xen-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed
  2015-01-12 14:49         ` Paolo Bonzini
@ 2015-01-12 15:46           ` Stefano Stabellini
  -1 siblings, 0 replies; 12+ messages in thread
From: Stefano Stabellini @ 2015-01-12 15:46 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Tian, Kevin, Li, Liang Z, Stefano Stabellini, mtosatti,
	qemu-devel, xen-devel, mst, aliguori, Zhang, Yang Z, Hu, Robert,
	rth

On Mon, 12 Jan 2015, Paolo Bonzini wrote:
> On 12/01/2015 14:35, Li, Liang Z wrote:
> > 
> > diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index c1bf357..f2893b2 100644
> > --- a/hw/xen/xen_pt.c
> > +++ b/hw/xen/xen_pt.c
> > @@ -736,7 +736,7 @@ static int xen_pt_initfn(PCIDevice *d)
> >      }
> >  
> >  out:
> > -    memory_listener_register(&s->memory_listener, &address_space_memory);
> > +    memory_listener_register(&s->memory_listener, 
> > + &s->dev.bus_master_as);
> >      memory_listener_register(&s->io_listener, &address_space_io);
> >      XEN_PT_LOG(d,
> >                 "Real physical device %02x:%02x.%d registered successfully!\n",
> > 
> > By further debugging, I found when using 'address_space_memory',  'xen_pt_region_del' 
> > won't be called when the memory region's name is not  ' xen-pci-pt-*', when using
> >  ' s->dev.bus_master_as ', there is no such issue.
> > 
> > I think use the device related address space here is more reasonable, but I am not sure.
> >  Could you give some suggestion?
> 
> Yes, this patch makes sense.  The listener will be called every time the
> command register is written.

Paolo, thanks for reviewing!

Liang, please resend with an appropriate patch description and
sign-off-by line.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Xen-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed
@ 2015-01-12 15:46           ` Stefano Stabellini
  0 siblings, 0 replies; 12+ messages in thread
From: Stefano Stabellini @ 2015-01-12 15:46 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Tian, Kevin, Li, Liang Z, Stefano Stabellini, mtosatti,
	qemu-devel, xen-devel, mst, aliguori, Zhang, Yang Z, Hu, Robert,
	rth

On Mon, 12 Jan 2015, Paolo Bonzini wrote:
> On 12/01/2015 14:35, Li, Liang Z wrote:
> > 
> > diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index c1bf357..f2893b2 100644
> > --- a/hw/xen/xen_pt.c
> > +++ b/hw/xen/xen_pt.c
> > @@ -736,7 +736,7 @@ static int xen_pt_initfn(PCIDevice *d)
> >      }
> >  
> >  out:
> > -    memory_listener_register(&s->memory_listener, &address_space_memory);
> > +    memory_listener_register(&s->memory_listener, 
> > + &s->dev.bus_master_as);
> >      memory_listener_register(&s->io_listener, &address_space_io);
> >      XEN_PT_LOG(d,
> >                 "Real physical device %02x:%02x.%d registered successfully!\n",
> > 
> > By further debugging, I found when using 'address_space_memory',  'xen_pt_region_del' 
> > won't be called when the memory region's name is not  ' xen-pci-pt-*', when using
> >  ' s->dev.bus_master_as ', there is no such issue.
> > 
> > I think use the device related address space here is more reasonable, but I am not sure.
> >  Could you give some suggestion?
> 
> Yes, this patch makes sense.  The listener will be called every time the
> command register is written.

Paolo, thanks for reviewing!

Liang, please resend with an appropriate patch description and
sign-off-by line.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-01-12 15:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-24  8:56 [Qemu-devel] [PATCH] xen-pt: Fix PCI devices re-attach failed Liang Li
2014-12-24  8:56 ` Liang Li
2015-01-12 11:36 ` [Qemu-devel] " Stefano Stabellini
2015-01-12 11:36   ` Stefano Stabellini
2015-01-12 12:02   ` [Qemu-devel] [Xen-devel] " Tian, Kevin
2015-01-12 12:02     ` Tian, Kevin
2015-01-12 13:35     ` [Qemu-devel] [Xen-devel] " Li, Liang Z
2015-01-12 13:35       ` Li, Liang Z
2015-01-12 14:49       ` [Qemu-devel] " Paolo Bonzini
2015-01-12 14:49         ` Paolo Bonzini
2015-01-12 15:46         ` [Qemu-devel] " Stefano Stabellini
2015-01-12 15:46           ` Stefano Stabellini

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.