From: "Jan Beulich" Subject: [PATCH] x86/MSI: fix MSI-X case of freeing IRQ Date: Thu, 02 Oct 2014 08:05:37 +0100 Message-ID: <542D1561020000780003BCB8@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB88DCD51.0__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZaSK-0004LB-Au for xen-devel@lists.xenproject.org; Thu, 02 Oct 2014 07:05:40 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser 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. --=__PartB88DCD51.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Commit d1b6d0a024 ("x86: enable multi-vector MSI") went a little too far with moving things around in msi_free_irqs() in order to streamline the code: We shouldn't drop the MSI-X control page reference before calling destroy_irq(), as the latter will call us back via desc->handler->shutdown() (effectively invoking to msi_set_mask_bit()). Signed-off-by: Jan Beulich --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -496,15 +496,8 @@ int __setup_msi_irq(struct irq_desc *des =20 int msi_free_irq(struct msi_desc *entry) { - unsigned int nr =3D entry->msi.nvec; - - if ( entry->msi_attrib.type =3D=3D PCI_CAP_ID_MSIX ) - { - unsigned long start; - start =3D (unsigned long)entry->mask_base & ~(PAGE_SIZE - 1); - msix_put_fixmap(entry->dev->msix, virt_to_fix(start)); - nr =3D 1; - } + unsigned int nr =3D entry->msi_attrib.type !=3D PCI_CAP_ID_MSIX + ? entry->msi.nvec : 1; =20 while ( nr-- ) { @@ -515,6 +508,10 @@ int msi_free_irq(struct msi_desc *entry) iommu_update_ire_from_msi(entry + nr, NULL); } =20 + if ( entry->msi_attrib.type =3D=3D PCI_CAP_ID_MSIX ) + msix_put_fixmap(entry->dev->msix, + virt_to_fix((unsigned long)entry->mask_base)); + list_del(&entry->list); xfree(entry); return 0; --=__PartB88DCD51.0__= Content-Type: text/plain; name="x86-MSI-X-free-irq.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-MSI-X-free-irq.patch" x86/MSI: fix MSI-X case of freeing IRQ=0A=0ACommit d1b6d0a024 ("x86: = enable multi-vector MSI") went a little too=0Afar with moving things = around in msi_free_irqs() in order to streamline=0Athe code: We shouldn't = drop the MSI-X control page reference before=0Acalling destroy_irq(), as = the latter will call us back via=0Adesc->handler->shutdown() (effectively = invoking to msi_set_mask_bit()).=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/msi.c=0A+++ b/xen/arch/x86/msi.c=0A@@ = -496,15 +496,8 @@ int __setup_msi_irq(struct irq_desc *des=0A =0A int = msi_free_irq(struct msi_desc *entry)=0A {=0A- unsigned int nr =3D = entry->msi.nvec;=0A-=0A- if ( entry->msi_attrib.type =3D=3D PCI_CAP_ID_M= SIX )=0A- {=0A- unsigned long start;=0A- start =3D = (unsigned long)entry->mask_base & ~(PAGE_SIZE - 1);=0A- msix_put_fix= map(entry->dev->msix, virt_to_fix(start));=0A- nr =3D 1;=0A- = }=0A+ unsigned int nr =3D entry->msi_attrib.type !=3D PCI_CAP_ID_MSIX=0A= + ? entry->msi.nvec : 1;=0A =0A while ( nr-- )=0A = {=0A@@ -515,6 +508,10 @@ int msi_free_irq(struct msi_desc *entry)=0A = iommu_update_ire_from_msi(entry + nr, NULL);=0A }=0A =0A+ = if ( entry->msi_attrib.type =3D=3D PCI_CAP_ID_MSIX )=0A+ msix_put_fi= xmap(entry->dev->msix,=0A+ virt_to_fix((unsigned = long)entry->mask_base));=0A+=0A list_del(&entry->list);=0A = xfree(entry);=0A return 0;=0A --=__PartB88DCD51.0__= 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 --=__PartB88DCD51.0__=--