From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang Subject: [PATCH V2] amd iommu: re-enable iommu msi if dom0 disabled it Date: Tue, 12 Jun 2012 14:02:44 +0200 Message-ID: <4FD72FE4.80009@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050807040804010300090702" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , Andrew Cooper Cc: Jeremy Fitzhardinge , "xen-devel@lists.xensource.com" , Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org --------------050807040804010300090702 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Hi Jan & Andrew I had attached a revised patch, please check it. I found that the following Linux commit triggers this issue. It has been included into 3.4 pv_ops. " commit a776c491ca5e38c26d9f66923ff574d041e747f4 Author: Eric W. Biederman Date: Mon Oct 17 11:46:06 2011 -0700 PCI: msi: Disable msi interrupts when we initialize a pci device " Thanks, Wei --------------050807040804010300090702 Content-Type: text/x-patch; name="iommu-msi.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="iommu-msi.patch" Content-Description: iommu-msi.patch # HG changeset patch # Parent f6bfaf9daa508c31b2bca0e461202db2759426fc # User Wei Wang Re-enable iommu msi capability block if it is disabled by dom0 Linux commit a776c491ca5e38c26d9f66923ff574d041e747f4 disables msi interrupts. If is running as a dom0, iommu interrupt will be disabled and hypervisor cannot process any event and ppr logs afterwards. Signed-off-by: Wei Wang diff -r f6bfaf9daa50 xen/drivers/passthrough/amd/pci_amd_iommu.c --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Jun 06 16:37:05 2012 +0100 +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Tue Jun 12 13:58:40 2012 +0200 @@ -81,6 +81,30 @@ static void disable_translation(u32 *dte dte[0] = entry; } +static void iommu_msi_check_enable(struct amd_iommu *iommu) +{ + unsigned long flags; + uint16_t control; + uint8_t bus = PCI_BUS(iommu->bdf); + uint8_t dev = PCI_SLOT(iommu->bdf); + uint8_t func = PCI_FUNC(iommu->bdf); + + ASSERT( iommu->msi_cap ); + + spin_lock_irqsave(&iommu->lock, flags); + + control = pci_conf_read16(iommu->seg, bus, dev, func, + iommu->msi_cap + PCI_MSI_FLAGS); + if ( !(control & PCI_MSI_FLAGS_ENABLE) ) + { + control |= PCI_MSI_FLAGS_ENABLE; + pci_conf_write16(iommu->seg, bus, dev, func, + iommu->msi_cap + PCI_MSI_FLAGS, control); + } + + spin_unlock_irqrestore(&iommu->lock, flags); +} + static void amd_iommu_setup_domain_device( struct domain *domain, struct amd_iommu *iommu, int bdf) { @@ -101,6 +125,12 @@ static void amd_iommu_setup_domain_devic if ( ats_enabled ) dte_i = 1; + /* + * In some cases, dom0 disables iommu msi capability, + * check and re-enable it here. + */ + iommu_msi_check_enable(iommu); + /* get device-table entry */ req_id = get_dma_requestor_id(iommu->seg, bdf); dte = iommu->dev_table.buffer + (req_id * IOMMU_DEV_TABLE_ENTRY_SIZE); --------------050807040804010300090702 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 --------------050807040804010300090702--