[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging-4.13] VT-d: clear_fault_bits() should clear all fault bits
commit 7907ab8a4f63d7f1d20ede8c91125976496f4f92 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Thu Jul 15 09:42:47 2021 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Jul 15 09:42:47 2021 +0200 VT-d: clear_fault_bits() should clear all fault bits If there is any way for one fault to be left set in the recording registers, there's no reason there couldn't also be multiple ones. If PPF set set (being the OR or all F fields), simply loop over the entire range of fault recording registers, clearing F everywhere. Since PPF is a r/o bit, also remove it from DMA_FSTS_FAULTS (arguably the constant's name is ambiguous as well). Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx> master commit: 80589800ae62fce43fd3921e8fbd362465fe5ba3 master date: 2021-06-24 16:29:42 +0200 --- xen/drivers/passthrough/vtd/iommu.c | 16 +++++++++++++--- xen/drivers/passthrough/vtd/iommu.h | 3 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 0ee18bdcc3..2804d0b1b7 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -2119,13 +2119,23 @@ static int __hwdom_init setup_hwdom_device(u8 devfn, struct pci_dev *pdev) void clear_fault_bits(struct vtd_iommu *iommu) { - u64 val; unsigned long flags; spin_lock_irqsave(&iommu->register_lock, flags); - val = dmar_readq(iommu->reg, cap_fault_reg_offset(iommu->cap) + 8); - dmar_writeq(iommu->reg, cap_fault_reg_offset(iommu->cap) + 8, val); + + if ( dmar_readl(iommu->reg, DMAR_FSTS_REG) & DMA_FSTS_PPF ) + { + unsigned int reg = cap_fault_reg_offset(iommu->cap); + unsigned int end = reg + cap_num_fault_regs(iommu->cap); + + do { + dmar_writel(iommu->reg, reg + 12, DMA_FRCD_F); + reg += PRIMARY_FAULT_REG_LEN; + } while ( reg < end ); + } + dmar_writel(iommu->reg, DMAR_FSTS_REG, DMA_FSTS_FAULTS); + spin_unlock_irqrestore(&iommu->register_lock, flags); } diff --git a/xen/drivers/passthrough/vtd/iommu.h b/xen/drivers/passthrough/vtd/iommu.h index e002dc6f01..32b39c606a 100644 --- a/xen/drivers/passthrough/vtd/iommu.h +++ b/xen/drivers/passthrough/vtd/iommu.h @@ -174,7 +174,8 @@ #define DMA_FSTS_IQE ((u64)1 << 4) #define DMA_FSTS_ICE ((u64)1 << 5) #define DMA_FSTS_ITE ((u64)1 << 6) -#define DMA_FSTS_FAULTS DMA_FSTS_PFO | DMA_FSTS_PPF | DMA_FSTS_AFO | DMA_FSTS_APF | DMA_FSTS_IQE | DMA_FSTS_ICE | DMA_FSTS_ITE +#define DMA_FSTS_FAULTS (DMA_FSTS_PFO | DMA_FSTS_AFO | DMA_FSTS_APF | \ + DMA_FSTS_IQE | DMA_FSTS_ICE | DMA_FSTS_ITE) #define dma_fsts_fault_record_index(s) (((s) >> 8) & 0xff) /* FRCD_REG, 32 bits access */ -- generated by git-patchbot for /home/xen/git/xen.git#staging-4.13
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |