Re: [PATCH v4 11/16] powerpc/powernv: Release replaced TCE

2014-08-05 Thread Benjamin Herrenschmidt
On Wed, 2014-07-30 at 19:31 +1000, Alexey Kardashevskiy wrote: > > static int pnv_tce_build(struct iommu_table *tbl, long index, long npages, > -unsigned long uaddr, enum dma_data_direction > direction, > +unsigned long uaddr, unsigned long *old_t

Re: [PATCH v4 11/16] powerpc/powernv: Release replaced TCE

2014-08-05 Thread Benjamin Herrenschmidt
On Wed, 2014-07-30 at 19:31 +1000, Alexey Kardashevskiy wrote: > > This adds a set_and_get() callback to iommu_table_ops which does the > same > thing as set() plus it returns replaced TCE(s) so the caller can > release > the pages afterwards. Call it xchg() instead of set_and_get(), it better re

Re: [PATCH v4 11/16] powerpc/powernv: Release replaced TCE

2014-08-05 Thread Benjamin Herrenschmidt
On Wed, 2014-07-30 at 19:31 +1000, Alexey Kardashevskiy wrote: > + if (oldtce & (TCE_PCI_WRITE | TCE_PCI_READ)) > + put_page(pfn_to_page(__pa(oldtce) >> PAGE_SHIFT)); That probably needs set_page_dirty if TCE_PCI_WRITE is set Cheers, Ben.

[PATCH v4 11/16] powerpc/powernv: Release replaced TCE

2014-07-30 Thread Alexey Kardashevskiy
At the moment writing new TCE value to the IOMMU table fails with EBUSY if there is a valid entry already. However PAPR specification allows the guest to write new TCE value without clearing it first. This adds a set_and_get() callback to iommu_table_ops which does the same thing as set() plus it