From: "Jan Beulich" Subject: Re: [Xen-unstable] regression in pci passthrough to HVM guests due to commit 568da4f8c43d2e5b614964c6aefd768de3e3af14 "pt-irq fixes and improvements". Date: Tue, 05 Aug 2014 09:54:02 +0100 Message-ID: <53E0B7CA020000780002958C@mail.emea.novell.com> References: <482403364.20140804142907@eikelenboom.it> <53E0B242020000780002953E@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartFAC844BA.2__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XEaVS-0006D8-Lb for xen-devel@lists.xenproject.org; Tue, 05 Aug 2014 08:54:06 +0000 In-Reply-To: <53E0B242020000780002953E@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Sander Eikelenboom Cc: andrew.cooper3@citrix.com, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartFAC844BA.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline >>> On 05.08.14 at 10:30, wrote: > I'm testing a fix... Mind giving this a try? Jan pass-through: fix unbinding of MSI interrupts Commit 568da4f8 ("pt-irq fixes and improvements") went a little too far in its cleaning up of pt_irq_destroy_bind(): While neither of the two lists need any maintenance, the actualunbinding still needs to be done. Fix this and at once enhance the final (optional) log message to make clear how much cleaning up was actually done. Reported-by: Sander Eikelenboom Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/io.c @@ -300,17 +300,15 @@ int pt_irq_destroy_bind( unsigned int intx =3D pt_irq_bind->u.pci.intx; unsigned int guest_gsi =3D hvm_pci_intx_gsi(device, intx); unsigned int link =3D hvm_pci_intx_link(device, intx); - struct dev_intx_gsi_link *digl, *tmp; - struct hvm_girq_dpci_mapping *girq; struct pirq *pirq; + const char *what; =20 switch ( pt_irq_bind->irq_type ) { case PT_IRQ_TYPE_PCI: + case PT_IRQ_TYPE_MSI: case PT_IRQ_TYPE_MSI_TRANSLATE: break; - case PT_IRQ_TYPE_MSI: - return 0; default: return -EOPNOTSUPP; } @@ -331,27 +329,32 @@ int pt_irq_destroy_bind( return -EINVAL; } =20 - list_for_each_entry ( girq, &hvm_irq_dpci->girq[guest_gsi], list ) + if ( pt_irq_bind->irq_type !=3D PT_IRQ_TYPE_MSI ) { - if ( girq->bus =3D=3D bus && - girq->device =3D=3D device && - girq->intx =3D=3D intx && - girq->machine_gsi =3D=3D machine_gsi ) + struct hvm_girq_dpci_mapping *girq; + + list_for_each_entry ( girq, &hvm_irq_dpci->girq[guest_gsi], list = ) { - list_del(&girq->list); - xfree(girq); - girq =3D NULL; - break; + if ( girq->bus =3D=3D bus && + girq->device =3D=3D device && + girq->intx =3D=3D intx && + girq->machine_gsi =3D=3D machine_gsi ) + { + list_del(&girq->list); + xfree(girq); + girq =3D NULL; + break; + } } - } =20 - if ( girq ) - { - spin_unlock(&d->event_lock); - return -EINVAL; - } + if ( girq ) + { + spin_unlock(&d->event_lock); + return -EINVAL; + } =20 - hvm_irq_dpci->link_cnt[link]--; + hvm_irq_dpci->link_cnt[link]--; + } =20 pirq =3D pirq_info(d, machine_gsi); pirq_dpci =3D pirq_dpci(pirq); @@ -359,14 +362,19 @@ int pt_irq_destroy_bind( /* clear the mirq info */ if ( pirq_dpci && (pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) ) { - list_for_each_entry_safe ( digl, tmp, &pirq_dpci->digl_list, list = ) + if ( pt_irq_bind->irq_type !=3D PT_IRQ_TYPE_MSI ) { - if ( digl->bus =3D=3D bus && - digl->device =3D=3D device && - digl->intx =3D=3D intx ) + struct dev_intx_gsi_link *digl, *tmp; + + list_for_each_entry_safe ( digl, tmp, &pirq_dpci->digl_list, = list ) { - list_del(&digl->list); - xfree(digl); + if ( digl->bus =3D=3D bus && + digl->device =3D=3D device && + digl->intx =3D=3D intx ) + { + list_del(&digl->list); + xfree(digl); + } } } =20 @@ -379,14 +387,20 @@ int pt_irq_destroy_bind( pirq_dpci->dom =3D NULL; pirq_dpci->flags =3D 0; pirq_cleanup_check(pirq, d); + what =3D "final"; } + else + what =3D "partial"; } + else + what =3D "bogus"; + spin_unlock(&d->event_lock); =20 if ( iommu_verbose ) dprintk(XENLOG_G_INFO, - "d%d unmap: m_irq=3D%u dev=3D%02x:%02x.%u intx=3D%u\n", - d->domain_id, machine_gsi, bus, + "d%d %s unmap: m_irq=3D%u dev=3D%02x:%02x.%u intx=3D%u\n",= + d->domain_id, what, machine_gsi, bus, PCI_SLOT(device), PCI_FUNC(device), intx); =20 return 0; --=__PartFAC844BA.2__= Content-Type: text/plain; name="pt-IRQ-destroy-MSI.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pt-IRQ-destroy-MSI.patch" pass-through: fix unbinding of MSI interrupts=0A=0ACommit 568da4f8 = ("pt-irq fixes and improvements") went a little too far=0Ain its cleaning = up of pt_irq_destroy_bind(): While neither of the two=0Alists need any = maintenance, the actualunbinding still needs to be done.=0AFix this and at = once enhance the final (optional) log message to make=0Aclear how much = cleaning up was actually done.=0A=0AReported-by: Sander Eikelenboom = =0ASigned-off-by: Jan Beulich =0A= =0A--- a/xen/drivers/passthrough/io.c=0A+++ b/xen/drivers/passthrough/io.c= =0A@@ -300,17 +300,15 @@ int pt_irq_destroy_bind(=0A unsigned int intx = =3D pt_irq_bind->u.pci.intx;=0A unsigned int guest_gsi =3D hvm_pci_intx= _gsi(device, intx);=0A unsigned int link =3D hvm_pci_intx_link(device, = intx);=0A- struct dev_intx_gsi_link *digl, *tmp;=0A- struct = hvm_girq_dpci_mapping *girq;=0A struct pirq *pirq;=0A+ const char = *what;=0A =0A switch ( pt_irq_bind->irq_type )=0A {=0A case = PT_IRQ_TYPE_PCI:=0A+ case PT_IRQ_TYPE_MSI:=0A case PT_IRQ_TYPE_MSI_T= RANSLATE:=0A break;=0A- case PT_IRQ_TYPE_MSI:=0A- return = 0;=0A default:=0A return -EOPNOTSUPP;=0A }=0A@@ -331,27 = +329,32 @@ int pt_irq_destroy_bind(=0A return -EINVAL;=0A }=0A = =0A- list_for_each_entry ( girq, &hvm_irq_dpci->girq[guest_gsi], list = )=0A+ if ( pt_irq_bind->irq_type !=3D PT_IRQ_TYPE_MSI )=0A {=0A- = if ( girq->bus =3D=3D bus &&=0A- girq->device = =3D=3D device &&=0A- girq->intx =3D=3D intx &&=0A- = girq->machine_gsi =3D=3D machine_gsi )=0A+ struct hvm_girq_dp= ci_mapping *girq;=0A+=0A+ list_for_each_entry ( girq, &hvm_irq_dpci-= >girq[guest_gsi], list )=0A {=0A- list_del(&girq->list);= =0A- xfree(girq);=0A- girq =3D NULL;=0A- = break;=0A+ if ( girq->bus =3D=3D bus &&=0A+ = girq->device =3D=3D device &&=0A+ girq->intx = =3D=3D intx &&=0A+ girq->machine_gsi =3D=3D machine_gsi = )=0A+ {=0A+ list_del(&girq->list);=0A+ = xfree(girq);=0A+ girq =3D NULL;=0A+ = break;=0A+ }=0A }=0A- }=0A =0A- if ( girq )=0A- = {=0A- spin_unlock(&d->event_lock);=0A- return -EINVAL;=0A- = }=0A+ if ( girq )=0A+ {=0A+ spin_unlock(&d->even= t_lock);=0A+ return -EINVAL;=0A+ }=0A =0A- hvm_irq_dpc= i->link_cnt[link]--;=0A+ hvm_irq_dpci->link_cnt[link]--;=0A+ = }=0A =0A pirq =3D pirq_info(d, machine_gsi);=0A pirq_dpci =3D = pirq_dpci(pirq);=0A@@ -359,14 +362,19 @@ int pt_irq_destroy_bind(=0A = /* clear the mirq info */=0A if ( pirq_dpci && (pirq_dpci->flags & = HVM_IRQ_DPCI_MAPPED) )=0A {=0A- list_for_each_entry_safe ( = digl, tmp, &pirq_dpci->digl_list, list )=0A+ if ( pt_irq_bind->irq_t= ype !=3D PT_IRQ_TYPE_MSI )=0A {=0A- if ( digl->bus = =3D=3D bus &&=0A- digl->device =3D=3D device &&=0A- = digl->intx =3D=3D intx )=0A+ struct dev_intx_gsi_link= *digl, *tmp;=0A+=0A+ list_for_each_entry_safe ( digl, tmp, = &pirq_dpci->digl_list, list )=0A {=0A- = list_del(&digl->list);=0A- xfree(digl);=0A+ = if ( digl->bus =3D=3D bus &&=0A+ digl->device = =3D=3D device &&=0A+ digl->intx =3D=3D intx )=0A+ = {=0A+ list_del(&digl->list);=0A+ = xfree(digl);=0A+ }=0A }=0A }=0A = =0A@@ -379,14 +387,20 @@ int pt_irq_destroy_bind(=0A pirq_dpci-= >dom =3D NULL;=0A pirq_dpci->flags =3D 0;=0A = pirq_cleanup_check(pirq, d);=0A+ what =3D "final";=0A = }=0A+ else=0A+ what =3D "partial";=0A }=0A+ = else=0A+ what =3D "bogus";=0A+=0A spin_unlock(&d->event_lock);= =0A =0A if ( iommu_verbose )=0A dprintk(XENLOG_G_INFO,=0A- = "d%d unmap: m_irq=3D%u dev=3D%02x:%02x.%u intx=3D%u\n",=0A- = d->domain_id, machine_gsi, bus,=0A+ "d%d %s = unmap: m_irq=3D%u dev=3D%02x:%02x.%u intx=3D%u\n",=0A+ = d->domain_id, what, machine_gsi, bus,=0A PCI_SLOT(device), = PCI_FUNC(device), intx);=0A =0A return 0;=0A --=__PartFAC844BA.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartFAC844BA.2__=--