FreeBSD/sys/dev/drm2/ttm/ttm_tt.c
/*
 * Change caching policy for the linear kernel map
 * for range of pages in a ttm.
 */
Change caching policy for the linear kernel map
for range of pages in a ttm.
Change caching policy for the linear kernel map for range of pages in a ttm .
static int ttm_tt_set_caching(struct ttm_tt *ttm,
			      enum ttm_caching_state c_state)
{
	int i, j;
	vm_page_t cur_page;
	int ret;
	if (ttm->caching_state == c_state)
		return 0;
	if (ttm->state == tt_unpopulated) {
		ttm->caching_state = c_state;
		return 0;
	}
	if (ttm->caching_state == tt_cached)
		drm_clflush_pages(ttm->pages, ttm->num_pages);
	for (i = 0; i < ttm->num_pages; ++i) {
		cur_page = ttm->pages[i];
		if (likely(cur_page != NULL)) {
			ret = ttm_tt_set_page_caching(cur_page,
						      ttm->caching_state,
						      c_state);
			if (unlikely(ret != 0))
				goto out_err;
		}
	}
	ttm->caching_state = c_state;
	return 0;
out_err:
	for (j = 0; j < i; ++j) {
		cur_page = ttm->pages[j];
		if (cur_page != NULL) {
			(void)ttm_tt_set_page_caching(cur_page, c_state,
						      ttm->caching_state);
		}
	}
	return ret;
}
static int ttm_tt_set_caching ( struct ttm_tt * ttm , enum ttm_caching_state c_state ) { int i , j ; vm_page_t cur_page ; int ret ; if ( ttm -> caching_state == c_state ) return 0 ; if ( ttm -> state == tt_unpopulated ) { ttm -> caching_state = c_state ; return 0 ; } if ( ttm -> caching_state == tt_cached ) drm_clflush_pages ( ttm -> pages , ttm -> num_pages ) ; for ( i = 0 ; i < ttm -> num_pages ; ++ i ) { cur_page = ttm -> pages [ i ] ; if ( likely ( cur_page != NULL ) ) { ret = ttm_tt_set_page_caching ( cur_page , ttm -> caching_state , c_state ) ; if ( unlikely ( ret != 0 ) ) goto out_err ; } } ttm -> caching_state = c_state ; return 0 ; out_err : for ( j = 0 ; j < i ; ++ j ) { cur_page = ttm -> pages [ j ] ; if ( cur_page != NULL ) { ( void ) ttm_tt_set_page_caching ( cur_page , c_state , ttm -> caching_state ) ; } } return ret ; }
Change caching policy for the linear kernel map
 for range of pages in a ttm.
Change caching policy for the linear kernel map for range of pages in a ttm .
/* Change caching but don't populate */