/* SPDX-License-Identifier: GPL-2.0 OR MIT */ /* * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA * 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 */ #define pr_fmt(fmt) … #include <linux/debugfs.h> #include <linux/mm.h> #include <drm/ttm/ttm_bo.h> #include <drm/ttm/ttm_device.h> #include <drm/ttm/ttm_tt.h> #include <drm/ttm/ttm_placement.h> #include "ttm_module.h" /* * ttm_global_mutex - protecting the global state */ static DEFINE_MUTEX(ttm_global_mutex); static unsigned ttm_glob_use_count; struct ttm_global ttm_glob; EXPORT_SYMBOL(…); struct dentry *ttm_debugfs_root; static void ttm_global_release(void) { … } static int ttm_global_init(void) { … } /* * A buffer object shrink method that tries to swap out the first * buffer object on the global::swap_lru list. */ int ttm_global_swapout(struct ttm_operation_ctx *ctx, gfp_t gfp_flags) { … } int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, gfp_t gfp_flags) { … } EXPORT_SYMBOL(…); /** * ttm_device_init * * @bdev: A pointer to a struct ttm_device to initialize. * @funcs: Function table for the device. * @dev: The core kernel device pointer for DMA mappings and allocations. * @mapping: The address space to use for this bo. * @vma_manager: A pointer to a vma manager. * @use_dma_alloc: If coherent DMA allocation API should be used. * @use_dma32: If we should use GFP_DMA32 for device memory allocations. * * Initializes a struct ttm_device: * Returns: * !0: Failure. */ int ttm_device_init(struct ttm_device *bdev, const struct ttm_device_funcs *funcs, struct device *dev, struct address_space *mapping, struct drm_vma_offset_manager *vma_manager, bool use_dma_alloc, bool use_dma32) { … } EXPORT_SYMBOL(…); void ttm_device_fini(struct ttm_device *bdev) { … } EXPORT_SYMBOL(…); static void ttm_device_clear_lru_dma_mappings(struct ttm_device *bdev, struct list_head *list) { … } void ttm_device_clear_dma_mappings(struct ttm_device *bdev) { … } EXPORT_SYMBOL(…);