Commit 5a8e9943 authored by Michel Thierry's avatar Michel Thierry Committed by Daniel Vetter

drm/i915/gen8: Initialize page tables

Similar to gen6, while setting up a page table, make all entries of the
pt point to the scratch page before mapping; this is to be safe in case
of out of bound access or proactive prefetch.

Systems without LLC require an explicit flush.

v2: Expanded commit text and fixed indentation (Mika)
Signed-off-by: default avatarMichel Thierry <michel.thierry@intel.com>
Reviewed-by: default avatarMika Kuoppala <mika.kuoppala@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 9c57f070
...@@ -332,6 +332,24 @@ static void unmap_and_free_pt(struct i915_page_table *pt, ...@@ -332,6 +332,24 @@ static void unmap_and_free_pt(struct i915_page_table *pt,
kfree(pt); kfree(pt);
} }
static void gen8_initialize_pt(struct i915_address_space *vm,
struct i915_page_table *pt)
{
gen8_pte_t *pt_vaddr, scratch_pte;
int i;
pt_vaddr = kmap_atomic(pt->page);
scratch_pte = gen8_pte_encode(vm->scratch.addr,
I915_CACHE_LLC, true);
for (i = 0; i < GEN8_PTES; i++)
pt_vaddr[i] = scratch_pte;
if (!HAS_LLC(vm->dev))
drm_clflush_virt_range(pt_vaddr, PAGE_SIZE);
kunmap_atomic(pt_vaddr);
}
static struct i915_page_table *alloc_pt_single(struct drm_device *dev) static struct i915_page_table *alloc_pt_single(struct drm_device *dev)
{ {
struct i915_page_table *pt; struct i915_page_table *pt;
...@@ -429,7 +447,7 @@ static struct i915_page_directory *alloc_pd_single(void) ...@@ -429,7 +447,7 @@ static struct i915_page_directory *alloc_pd_single(void)
if (!pd) if (!pd)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
pd->page = alloc_page(GFP_KERNEL | __GFP_ZERO); pd->page = alloc_page(GFP_KERNEL);
if (!pd->page) { if (!pd->page) {
kfree(pd); kfree(pd);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -719,6 +737,8 @@ static int gen8_ppgtt_setup_page_tables(struct i915_hw_ppgtt *ppgtt, ...@@ -719,6 +737,8 @@ static int gen8_ppgtt_setup_page_tables(struct i915_hw_ppgtt *ppgtt,
struct page *p = ptab->page; struct page *p = ptab->page;
int ret; int ret;
gen8_initialize_pt(&ppgtt->base, ptab);
pt_addr = pci_map_page(ppgtt->base.dev->pdev, pt_addr = pci_map_page(ppgtt->base.dev->pdev,
p, 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); p, 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
ret = pci_dma_mapping_error(ppgtt->base.dev->pdev, pt_addr); ret = pci_dma_mapping_error(ppgtt->base.dev->pdev, pt_addr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment