Re: [PATCH kernel 4/9] powerpc/powernv/iommu: Add real mode version of xchg()
From: Paul Mackerras <hidden>
Date: 2016-03-10 08:44:03
Also in:
kvm
On Mon, Mar 07, 2016 at 02:41:12PM +1100, Alexey Kardashevskiy wrote:
In real mode, TCE tables are invalidated using different cache-inhibited store instructions which is different from the virtual mode. This defines and implements exchange_rm() callback. This does not define set_rm/clear_rm/flush_rm callbacks as there is no user for those - exchange/exchange_rm are only to be used by KVM for VFIO. The exchange_rm callback is defined for IODA1/IODA2 powernv platforms. This replaces list_for_each_entry_rcu with its lockless version as from now on pnv_pci_ioda2_tce_invalidate() can be called in the real mode too.
[snip]
quoted hunk ↗ jump to hunk
@@ -1062,6 +1062,21 @@ void iommu_release_ownership(struct iommu_table *tbl) } EXPORT_SYMBOL_GPL(iommu_release_ownership); +long iommu_tce_xchg_rm(struct iommu_table *tbl, unsigned long entry, + unsigned long *hpa, enum dma_data_direction *direction) +{ + long ret; + + ret = tbl->it_ops->exchange_rm(tbl, entry, hpa, direction); + + if (!ret && ((*direction == DMA_FROM_DEVICE) || + (*direction == DMA_BIDIRECTIONAL))) + SetPageDirty(realmode_pfn_to_page(*hpa >> PAGE_SHIFT));
realmode_pfn_to_page can fail and return NULL, can't it? You need to handle that situation somehow. Paul.