This enables userspace view of TCE tables to start from non-zero offset
on a bus. This will be used for huge DMA windows.
This only changes the internal structure, the user interface needs to
change in order to use an offset.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
        u64 liobn;
        struct rcu_head rcu;
        u32 page_shift;
+       u64 offset;             /* in pages */
        u64 size;               /* window size in pages */
        struct page *pages[0];
 };
 
        unsigned long mask = (1ULL << stt->page_shift) - 1;
        unsigned long idx = ioba >> stt->page_shift;
 
-       if ((ioba & mask) || (idx + npages > stt->size) || (idx + npages < idx))
+       if ((ioba & mask) || (idx < stt->offset) ||
+                       (idx - stt->offset + npages > stt->size) ||
+                       (idx + npages < idx))
                return H_PARAMETER;
 
        return H_SUCCESS;
        struct page *page;
        u64 *tbl;
 
+       idx -= stt->offset;
        page = stt->pages[idx / TCES_PER_PAGE];
        tbl = kvmppc_page_address(page);
 
        if (ret != H_SUCCESS)
                return ret;
 
-       idx = ioba >> stt->page_shift;
+       idx = (ioba >> stt->page_shift) - stt->offset;
        page = stt->pages[idx / TCES_PER_PAGE];
        tbl = (u64 *)page_address(page);