FreeBSD/sys/dev/drm2/i915/i915_gem_gtt.c
/* PPGTT support for Sandybdrige/Gen6 and later */
PPGTT support for Sandybdrige/Gen6 and later
PPGTT support for Sandybdrige / Gen6 and later
static void i915_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt,
				   unsigned first_entry,
				   unsigned num_entries)
{
	gtt_pte_t *pt_vaddr;
	gtt_pte_t scratch_pte;
	unsigned act_pd = first_entry / I915_PPGTT_PT_ENTRIES;
	unsigned first_pte = first_entry % I915_PPGTT_PT_ENTRIES;
	unsigned last_pte, i;
	struct sf_buf *sf;
	scratch_pte = pte_encode(ppgtt->dev, ppgtt->scratch_page_dma_addr,
				 I915_CACHE_LLC);
	while (num_entries) {
		last_pte = first_pte + num_entries;
		if (last_pte > I915_PPGTT_PT_ENTRIES)
			last_pte = I915_PPGTT_PT_ENTRIES;
		sched_pin();
		sf = sf_buf_alloc(ppgtt->pt_pages[act_pd], SFB_CPUPRIVATE);
		pt_vaddr = (uint32_t *)(uintptr_t)sf_buf_kva(sf);
		for (i = first_pte; i < last_pte; i++)
			pt_vaddr[i] = scratch_pte;
		sf_buf_free(sf);
		sched_unpin();
		num_entries -= last_pte - first_pte;
		first_pte = 0;
		act_pd++;
	}
}
static void i915_ppgtt_clear_range ( struct i915_hw_ppgtt * ppgtt , unsigned first_entry , unsigned num_entries ) { gtt_pte_t * pt_vaddr ; gtt_pte_t scratch_pte ; unsigned act_pd = first_entry / I915_PPGTT_PT_ENTRIES ; unsigned first_pte = first_entry % I915_PPGTT_PT_ENTRIES ; unsigned last_pte , i ; struct sf_buf * sf ; scratch_pte = pte_encode ( ppgtt -> dev , ppgtt -> scratch_page_dma_addr , I915_CACHE_LLC ) ; while ( num_entries ) { last_pte = first_pte + num_entries ; if ( last_pte > I915_PPGTT_PT_ENTRIES ) last_pte = I915_PPGTT_PT_ENTRIES ; sched_pin ( ) ; sf = sf_buf_alloc ( ppgtt -> pt_pages [ act_pd ] , SFB_CPUPRIVATE ) ; pt_vaddr = ( uint32_t * ) ( uintptr_t ) sf_buf_kva ( sf ) ; for ( i = first_pte ; i < last_pte ; i ++ ) pt_vaddr [ i ] = scratch_pte ; sf_buf_free ( sf ) ; sched_unpin ( ) ; num_entries -= last_pte - first_pte ; first_pte = 0 ; act_pd ++ ; } }
PPGTT support for Sandybdrige/Gen6 and later
PPGTT support for Sandybdrige / Gen6 and later