brintos

brintos / linux-shallow public Read only

0
0
Text · 3.1 KiB · b3fffe7 Raw
92 lines · c
1/* SPDX-License-Identifier: GPL-2.0 OR MIT */2/**************************************************************************3 *4 * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA5 * All Rights Reserved.6 *7 * Permission is hereby granted, free of charge, to any person obtaining a8 * copy of this software and associated documentation files (the9 * "Software"), to deal in the Software without restriction, including10 * without limitation the rights to use, copy, modify, merge, publish,11 * distribute, sub license, and/or sell copies of the Software, and to12 * permit persons to whom the Software is furnished to do so, subject to13 * the following conditions:14 *15 * The above copyright notice and this permission notice (including the16 * next paragraph) shall be included in all copies or substantial portions17 * of the Software.18 *19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL22 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE25 * USE OR OTHER DEALINGS IN THE SOFTWARE.26 *27 **************************************************************************/28/*29 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>30 * 	    Jerome Glisse31 */32#include <linux/module.h>33#include <linux/device.h>34#include <linux/pgtable.h>35#include <linux/sched.h>36#include <linux/debugfs.h>37#include <drm/drm_sysfs.h>38#include <drm/ttm/ttm_caching.h>39 40#include "ttm_module.h"41 42/**43 * DOC: TTM44 *45 * TTM is a memory manager for accelerator devices with dedicated memory.46 *47 * The basic idea is that resources are grouped together in buffer objects of48 * certain size and TTM handles lifetime, movement and CPU mappings of those49 * objects.50 *51 * TODO: Add more design background and information here.52 */53 54/**55 * ttm_prot_from_caching - Modify the page protection according to the56 * ttm cacing mode57 * @caching: The ttm caching mode58 * @tmp: The original page protection59 *60 * Return: The modified page protection61 */62pgprot_t ttm_prot_from_caching(enum ttm_caching caching, pgprot_t tmp)63{64	/* Cached mappings need no adjustment */65	if (caching == ttm_cached)66		return tmp;67 68#if defined(__i386__) || defined(__x86_64__)69	if (caching == ttm_write_combined)70		tmp = pgprot_writecombine(tmp);71#ifndef CONFIG_UML72	else if (boot_cpu_data.x86 > 3)73		tmp = pgprot_noncached(tmp);74#endif /* CONFIG_UML */75#endif /* __i386__ || __x86_64__ */76#if defined(__ia64__) || defined(__arm__) || defined(__aarch64__) || \77	defined(__powerpc__) || defined(__mips__) || defined(__loongarch__)78	if (caching == ttm_write_combined)79		tmp = pgprot_writecombine(tmp);80	else81		tmp = pgprot_noncached(tmp);82#endif83#if defined(__sparc__)84	tmp = pgprot_noncached(tmp);85#endif86	return tmp;87}88 89MODULE_AUTHOR("Thomas Hellstrom, Jerome Glisse");90MODULE_DESCRIPTION("TTM memory manager subsystem (for DRM device)");91MODULE_LICENSE("GPL and additional rights");92