Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
1
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
de3688e
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
acpi
asm-generic
clocksource
crypto
drm
bridge
dp
i2c
ttm
ttm_bo_api.h
ttm_bo_driver.h
ttm_caching.h
ttm_device.h
ttm_execbuf_util.h
ttm_kmap_iter.h
ttm_placement.h
ttm_pool.h
ttm_range_manager.h
ttm_resource.h
ttm_tt.h
amd_asic_type.h
drm_aperture.h
drm_atomic.h
drm_atomic_helper.h
drm_atomic_state_helper.h
drm_atomic_uapi.h
drm_audio_component.h
drm_auth.h
drm_blend.h
drm_bridge.h
drm_bridge_connector.h
drm_buddy.h
drm_cache.h
drm_client.h
drm_color_mgmt.h
drm_connector.h
drm_crtc.h
drm_crtc_helper.h
drm_damage_helper.h
drm_debugfs.h
drm_debugfs_crc.h
drm_device.h
drm_displayid.h
drm_drv.h
drm_dsc.h
drm_edid.h
drm_encoder.h
drm_encoder_slave.h
drm_fb_cma_helper.h
drm_fb_helper.h
drm_file.h
drm_fixed.h
drm_flip_work.h
drm_format_helper.h
drm_fourcc.h
drm_framebuffer.h
drm_gem.h
drm_gem_atomic_helper.h
drm_gem_cma_helper.h
drm_gem_framebuffer_helper.h
drm_gem_shmem_helper.h
drm_gem_ttm_helper.h
drm_gem_vram_helper.h
drm_hdcp.h
drm_ioctl.h
drm_lease.h
drm_legacy.h
drm_managed.h
drm_mipi_dbi.h
drm_mipi_dsi.h
drm_mm.h
drm_mode_config.h
drm_mode_object.h
drm_modes.h
drm_modeset_helper.h
drm_modeset_helper_vtables.h
drm_modeset_lock.h
drm_module.h
drm_of.h
drm_panel.h
drm_pciids.h
drm_plane.h
drm_plane_helper.h
drm_prime.h
drm_print.h
drm_privacy_screen_consumer.h
drm_privacy_screen_driver.h
drm_privacy_screen_machine.h
drm_probe_helper.h
drm_property.h
drm_rect.h
drm_scdc_helper.h
drm_self_refresh_helper.h
drm_simple_kms_helper.h
drm_syncobj.h
drm_sysfs.h
drm_util.h
drm_utils.h
drm_vblank.h
drm_vblank_work.h
drm_vma_manager.h
drm_writeback.h
gma_drm.h
gpu_scheduler.h
gud.h
i915_component.h
i915_drm.h
i915_mei_hdcp_interface.h
i915_pciids.h
i915_pxp_tee_interface.h
intel-gtt.h
intel_lpe_audio.h
spsc_queue.h
task_barrier.h
dt-bindings
keys
kunit
kvm
linux
math-emu
media
memory
misc
net
pcmcia
ras
rdma
scsi
soc
sound
target
trace
uapi
vdso
video
xen
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
include
/
drm
/
ttm
/
ttm_resource.h
Blame
Blame
Latest commit
History
History
299 lines (271 loc) · 8.83 KB
Breadcrumbs
linux
/
include
/
drm
/
ttm
/
ttm_resource.h
Top
File metadata and controls
Code
Blame
299 lines (271 loc) · 8.83 KB
Raw
/* * Copyright 2020 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: Christian König */ #ifndef _TTM_RESOURCE_H_ #define _TTM_RESOURCE_H_ #include <linux/types.h> #include <linux/mutex.h> #include <linux/dma-buf-map.h> #include <linux/dma-fence.h> #include <drm/drm_print.h> #include <drm/ttm/ttm_caching.h> #include <drm/ttm/ttm_kmap_iter.h> #define TTM_MAX_BO_PRIORITY 4U struct ttm_device; struct ttm_resource_manager; struct ttm_resource; struct ttm_place; struct ttm_buffer_object; struct ttm_placement; struct dma_buf_map; struct io_mapping; struct sg_table; struct scatterlist; struct ttm_resource_manager_func { /** * struct ttm_resource_manager_func member alloc * * @man: Pointer to a memory type manager. * @bo: Pointer to the buffer object we're allocating space for. * @place: Placement details. * @res: Resulting pointer to the ttm_resource. * * This function should allocate space in the memory type managed * by @man. Placement details if applicable are given by @place. If * successful, a filled in ttm_resource object should be returned in * @res. @res::start should be set to a value identifying the beginning * of the range allocated, and the function should return zero. * If the manager can't fulfill the request -ENOSPC should be returned. * If a system error occurred, preventing the request to be fulfilled, * the function should return a negative error code. * * This function may not be called from within atomic context and needs * to take care of its own locking to protect any data structures * managing the space. */ int (*alloc)(struct ttm_resource_manager *man, struct ttm_buffer_object *bo, const struct ttm_place *place, struct ttm_resource **res); /** * struct ttm_resource_manager_func member free * * @man: Pointer to a memory type manager. * @res: Pointer to a struct ttm_resource to be freed. * * This function frees memory type resources previously allocated. * May not be called from within atomic context. */ void (*free)(struct ttm_resource_manager *man, struct ttm_resource *res); /** * struct ttm_resource_manager_func member debug * * @man: Pointer to a memory type manager. * @printer: Prefix to be used in printout to identify the caller. * * This function is called to print out the state of the memory * type manager to aid debugging of out-of-memory conditions. * It may not be called from within atomic context. */ void (*debug)(struct ttm_resource_manager *man, struct drm_printer *printer); }; /** * struct ttm_resource_manager * * @use_type: The memory type is enabled. * @use_tt: If a TT object should be used for the backing store. * @size: Size of the managed region. * @func: structure pointer implementing the range manager. See above * @move_lock: lock for move fence * static information. bdev::driver::io_mem_free is never used. * @lru: The lru list for this memory type. * @move: The fence of the last pipelined move operation. * * This structure is used to identify and manage memory types for a device. */ struct ttm_resource_manager { /* * No protection. Constant from start. */ bool use_type; bool use_tt; uint64_t size; const struct ttm_resource_manager_func *func; spinlock_t move_lock; /* * Protected by the global->lru_lock. */ struct list_head lru[TTM_MAX_BO_PRIORITY]; /* * Protected by @move_lock. */ struct dma_fence *move; }; /** * struct ttm_bus_placement * * @addr: mapped virtual address * @offset: physical addr * @is_iomem: is this io memory ? * @caching: See enum ttm_caching * * Structure indicating the bus placement of an object. */ struct ttm_bus_placement { void *addr; phys_addr_t offset; bool is_iomem; enum ttm_caching caching; }; /** * struct ttm_resource * * @start: Start of the allocation. * @num_pages: Actual size of resource in pages. * @mem_type: Resource type of the allocation. * @placement: Placement flags. * @bus: Placement on io bus accessible to the CPU * * Structure indicating the placement and space resources used by a * buffer object. */ struct ttm_resource { unsigned long start; unsigned long num_pages; uint32_t mem_type; uint32_t placement; struct ttm_bus_placement bus; }; /** * struct ttm_kmap_iter_iomap - Specialization for a struct io_mapping + * struct sg_table backed struct ttm_resource. * @base: Embedded struct ttm_kmap_iter providing the usage interface. * @iomap: struct io_mapping representing the underlying linear io_memory. * @st: sg_table into @iomap, representing the memory of the struct ttm_resource. * @start: Offset that needs to be subtracted from @st to make * sg_dma_address(st->sgl) - @start == 0 for @iomap start. * @cache: Scatterlist traversal cache for fast lookups. * @cache.sg: Pointer to the currently cached scatterlist segment. * @cache.i: First index of @sg. PAGE_SIZE granularity. * @cache.end: Last index + 1 of @sg. PAGE_SIZE granularity. * @cache.offs: First offset into @iomap of @sg. PAGE_SIZE granularity. */ struct ttm_kmap_iter_iomap { struct ttm_kmap_iter base; struct io_mapping *iomap; struct sg_table *st; resource_size_t start; struct { struct scatterlist *sg; pgoff_t i; pgoff_t end; pgoff_t offs; } cache; }; /** * struct ttm_kmap_iter_linear_io - Iterator specialization for linear io * @base: The base iterator * @dmap: Points to the starting address of the region * @needs_unmap: Whether we need to unmap on fini */ struct ttm_kmap_iter_linear_io { struct ttm_kmap_iter base; struct dma_buf_map dmap; bool needs_unmap; }; /** * ttm_resource_manager_set_used * * @man: A memory manager object. * @used: usage state to set. * * Set the manager in use flag. If disabled the manager is no longer * used for object placement. */ static inline void ttm_resource_manager_set_used(struct ttm_resource_manager *man, bool used) { int i; for (i = 0; i < TTM_MAX_BO_PRIORITY; i++) WARN_ON(!list_empty(&man->lru[i])); man->use_type = used; } /** * ttm_resource_manager_used * * @man: Manager to get used state for * * Get the in use flag for a manager. * Returns: * true is used, false if not. */ static inline bool ttm_resource_manager_used(struct ttm_resource_manager *man) { return man->use_type; } /** * ttm_resource_manager_cleanup * * @man: A memory manager object. * * Cleanup the move fences from the memory manager object. */ static inline void ttm_resource_manager_cleanup(struct ttm_resource_manager *man) { dma_fence_put(man->move); man->move = NULL; } void ttm_resource_init(struct ttm_buffer_object *bo, const struct ttm_place *place, struct ttm_resource *res); void ttm_resource_fini(struct ttm_resource_manager *man, struct ttm_resource *res); int ttm_resource_alloc(struct ttm_buffer_object *bo, const struct ttm_place *place, struct ttm_resource **res); void ttm_resource_free(struct ttm_buffer_object *bo, struct ttm_resource **res); bool ttm_resource_compat(struct ttm_resource *res, struct ttm_placement *placement); void ttm_resource_manager_init(struct ttm_resource_manager *man, unsigned long p_size); int ttm_resource_manager_evict_all(struct ttm_device *bdev, struct ttm_resource_manager *man); void ttm_resource_manager_debug(struct ttm_resource_manager *man, struct drm_printer *p); struct ttm_kmap_iter * ttm_kmap_iter_iomap_init(struct ttm_kmap_iter_iomap *iter_io, struct io_mapping *iomap, struct sg_table *st, resource_size_t start); struct ttm_kmap_iter_linear_io; struct ttm_kmap_iter * ttm_kmap_iter_linear_io_init(struct ttm_kmap_iter_linear_io *iter_io, struct ttm_device *bdev, struct ttm_resource *mem); void ttm_kmap_iter_linear_io_fini(struct ttm_kmap_iter_linear_io *iter_io, struct ttm_device *bdev, struct ttm_resource *mem); #endif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
You can’t perform that action at this time.