diff options
author | Srikant Patnaik | 2015-01-11 19:41:45 +0530 |
---|---|---|
committer | Srikant Patnaik | 2015-01-11 19:41:45 +0530 |
commit | abc18728f7736823a28540346129bbeafb3b5866 (patch) | |
tree | 036140abf92bd5ebc4bfa605cb686e1f1638ca1d /drivers/gpu/mali/ump/linux/ump_kernel_random_mapping.h | |
parent | b9ae4882794bcdc8d26671dfdbc406173d76c739 (diff) | |
download | FOSSEE-netbook-kernel-source-abc18728f7736823a28540346129bbeafb3b5866.tar.gz FOSSEE-netbook-kernel-source-abc18728f7736823a28540346129bbeafb3b5866.tar.bz2 FOSSEE-netbook-kernel-source-abc18728f7736823a28540346129bbeafb3b5866.zip |
This commit is dedicacted to MALI, UMP and MALI_DRM. This includes MALI-r3p2 from other source
Diffstat (limited to 'drivers/gpu/mali/ump/linux/ump_kernel_random_mapping.h')
-rw-r--r-- | drivers/gpu/mali/ump/linux/ump_kernel_random_mapping.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/drivers/gpu/mali/ump/linux/ump_kernel_random_mapping.h b/drivers/gpu/mali/ump/linux/ump_kernel_random_mapping.h new file mode 100644 index 00000000..7f89ef82 --- /dev/null +++ b/drivers/gpu/mali/ump/linux/ump_kernel_random_mapping.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2010-2011, 2013-2014 ARM Limited. All rights reserved. + * + * This program is free software and is provided to you under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence. + * + * A copy of the licence is included with the program, and can also be obtained from Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** + * @file ump_kernel_random_mapping.h + */ + +#ifndef __UMP_KERNEL_RANDOM_MAPPING_H__ +#define __UMP_KERNEL_RANDOM_MAPPING_H__ + +#include "mali_osk.h" +#include <linux/rbtree.h> + +#define UMP_RANDOM_MAP_DELAY 1 +#define UMP_FAILED_LOOKUP_DELAY 10 /* ms */ +#define UMP_FAILED_LOOKUPS_ALLOWED 10 /* number of allowed failed lookups */ + +/** + * The random mapping object + * Provides a separate namespace where we can map an integer to a pointer + */ +typedef struct ump_random_mapping { + _mali_osk_mutex_rw_t *lock; /**< Lock protecting access to the mapping object */ + struct rb_root root; +#if UMP_RANDOM_MAP_DELAY + struct { + unsigned long count; + unsigned long timestamp; + } failed; +#endif +} ump_random_mapping; + +/** + * Create a random mapping object + * Create a random mapping capable of holding 2^20 entries + * @return Pointer to a random mapping object, NULL on failure + */ +ump_random_mapping *ump_random_mapping_create(void); + +/** + * Destroy a random mapping object + * @param map The map to free + */ +void ump_random_mapping_destroy(ump_random_mapping *map); + +/** + * Allocate a new mapping entry (random ID) + * Allocates a new entry in the map. + * @param map The map to allocate a new entry in + * @param target The value to map to + * @return The random allocated, a negative value on error + */ +int ump_random_mapping_insert(ump_random_mapping *map, ump_dd_mem *mem); + +/** + * Get the value mapped to by a random ID + * + * If the lookup fails, punish the calling thread by applying a delay. + * + * @param map The map to lookup the random id in + * @param id The ID to lookup + * @param target Pointer to a pointer which will receive the stored value + * @return ump_dd_mem pointer on successful lookup, NULL on error + */ +ump_dd_mem *ump_random_mapping_get(ump_random_mapping *map, int id); + +void ump_random_mapping_put(ump_dd_mem *mem); + +/** + * Free the random ID + * For the random to be reused it has to be freed + * @param map The map to free the random from + * @param id The ID to free + */ +ump_dd_mem *ump_random_mapping_remove(ump_random_mapping *map, int id); + +#endif /* __UMP_KERNEL_RANDOM_MAPPING_H__ */ |