13bf3710eSThomas Hellström /* SPDX-License-Identifier: MIT */ 23bf3710eSThomas Hellström /* 33bf3710eSThomas Hellström * Copyright © 2021 Intel Corporation 43bf3710eSThomas Hellström */ 53bf3710eSThomas Hellström #ifndef __TTM_KMAP_ITER_H__ 63bf3710eSThomas Hellström #define __TTM_KMAP_ITER_H__ 73bf3710eSThomas Hellström 83bf3710eSThomas Hellström #include <linux/types.h> 93bf3710eSThomas Hellström 103bf3710eSThomas Hellström struct ttm_kmap_iter; 11*7938f421SLucas De Marchi struct iosys_map; 123bf3710eSThomas Hellström 133bf3710eSThomas Hellström /** 143bf3710eSThomas Hellström * struct ttm_kmap_iter_ops - Ops structure for a struct 153bf3710eSThomas Hellström * ttm_kmap_iter. 163bf3710eSThomas Hellström * @maps_tt: Whether the iterator maps TT memory directly, as opposed 173bf3710eSThomas Hellström * mapping a TT through an aperture. Both these modes have 183bf3710eSThomas Hellström * struct ttm_resource_manager::use_tt set, but the latter typically 193bf3710eSThomas Hellström * returns is_iomem == true from ttm_mem_io_reserve. 203bf3710eSThomas Hellström */ 213bf3710eSThomas Hellström struct ttm_kmap_iter_ops { 223bf3710eSThomas Hellström /** 233bf3710eSThomas Hellström * kmap_local() - Map a PAGE_SIZE part of the resource using 243bf3710eSThomas Hellström * kmap_local semantics. 253bf3710eSThomas Hellström * @res_iter: Pointer to the struct ttm_kmap_iter representing 263bf3710eSThomas Hellström * the resource. 27*7938f421SLucas De Marchi * @dmap: The struct iosys_map holding the virtual address after 283bf3710eSThomas Hellström * the operation. 293bf3710eSThomas Hellström * @i: The location within the resource to map. PAGE_SIZE granularity. 303bf3710eSThomas Hellström */ 313bf3710eSThomas Hellström void (*map_local)(struct ttm_kmap_iter *res_iter, 32*7938f421SLucas De Marchi struct iosys_map *dmap, pgoff_t i); 333bf3710eSThomas Hellström /** 343bf3710eSThomas Hellström * unmap_local() - Unmap a PAGE_SIZE part of the resource previously 353bf3710eSThomas Hellström * mapped using kmap_local. 363bf3710eSThomas Hellström * @res_iter: Pointer to the struct ttm_kmap_iter representing 373bf3710eSThomas Hellström * the resource. 38*7938f421SLucas De Marchi * @dmap: The struct iosys_map holding the virtual address after 393bf3710eSThomas Hellström * the operation. 403bf3710eSThomas Hellström */ 413bf3710eSThomas Hellström void (*unmap_local)(struct ttm_kmap_iter *res_iter, 42*7938f421SLucas De Marchi struct iosys_map *dmap); 433bf3710eSThomas Hellström bool maps_tt; 443bf3710eSThomas Hellström }; 453bf3710eSThomas Hellström 463bf3710eSThomas Hellström /** 473bf3710eSThomas Hellström * struct ttm_kmap_iter - Iterator for kmap_local type operations on a 483bf3710eSThomas Hellström * resource. 493bf3710eSThomas Hellström * @ops: Pointer to the operations struct. 503bf3710eSThomas Hellström * 513bf3710eSThomas Hellström * This struct is intended to be embedded in a resource-specific specialization 523bf3710eSThomas Hellström * implementing operations for the resource. 533bf3710eSThomas Hellström * 543bf3710eSThomas Hellström * Nothing stops us from extending the operations to vmap, vmap_pfn etc, 553bf3710eSThomas Hellström * replacing some or parts of the ttm_bo_util. cpu-map functionality. 563bf3710eSThomas Hellström */ 573bf3710eSThomas Hellström struct ttm_kmap_iter { 583bf3710eSThomas Hellström const struct ttm_kmap_iter_ops *ops; 593bf3710eSThomas Hellström }; 603bf3710eSThomas Hellström 613bf3710eSThomas Hellström #endif /* __TTM_KMAP_ITER_H__ */ 62