Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Declare hashtable as legacy

The DRM hashtable code is only used by internal functions for legacy
UMS drivers. Move the implementation behind CONFIG_DRM_LEGACY and the
declarations into legacy header files. Unexport the symbols.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211129094841.22499-4-tzimmermann@suse.de

+59 -96
+3 -3
drivers/gpu/drm/Makefile
··· 6 6 drm-y := drm_aperture.o drm_auth.o drm_cache.o \ 7 7 drm_file.o drm_gem.o drm_ioctl.o \ 8 8 drm_drv.o \ 9 - drm_sysfs.o drm_hashtab.o drm_mm.o \ 9 + drm_sysfs.o drm_mm.o \ 10 10 drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o drm_displayid.o \ 11 11 drm_trace_points.o drm_prime.o \ 12 12 drm_vma_manager.o \ ··· 20 20 drm_managed.o drm_vblank_work.o 21 21 22 22 drm-$(CONFIG_DRM_LEGACY) += drm_agpsupport.o drm_bufs.o drm_context.o drm_dma.o \ 23 - drm_irq.o drm_legacy_misc.o drm_lock.o drm_memory.o \ 24 - drm_scatter.o drm_vm.o 23 + drm_hashtab.o drm_irq.o drm_legacy_misc.o drm_lock.o \ 24 + drm_memory.o drm_scatter.o drm_vm.o 25 25 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o 26 26 drm-$(CONFIG_COMPAT) += drm_ioc32.o 27 27 drm-$(CONFIG_DRM_PANEL) += drm_panel.o
+2 -8
drivers/gpu/drm/drm_hashtab.c
··· 32 32 * Thomas Hellström <thomas-at-tungstengraphics-dot-com> 33 33 */ 34 34 35 - #include <linux/export.h> 36 35 #include <linux/hash.h> 37 36 #include <linux/mm.h> 38 37 #include <linux/rculist.h> 39 38 #include <linux/slab.h> 40 39 #include <linux/vmalloc.h> 41 40 42 - #include <drm/drm_hashtab.h> 43 41 #include <drm/drm_print.h> 42 + 43 + #include "drm_legacy.h" 44 44 45 45 int drm_ht_create(struct drm_open_hash *ht, unsigned int order) 46 46 { ··· 58 58 } 59 59 return 0; 60 60 } 61 - EXPORT_SYMBOL(drm_ht_create); 62 61 63 62 void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key) 64 63 { ··· 134 135 } 135 136 return 0; 136 137 } 137 - EXPORT_SYMBOL(drm_ht_insert_item); 138 138 139 139 /* 140 140 * Just insert an item and return any "bits" bit key that hasn't been ··· 162 164 } 163 165 return 0; 164 166 } 165 - EXPORT_SYMBOL(drm_ht_just_insert_please); 166 167 167 168 int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, 168 169 struct drm_hash_item **item) ··· 175 178 *item = hlist_entry(list, struct drm_hash_item, head); 176 179 return 0; 177 180 } 178 - EXPORT_SYMBOL(drm_ht_find_item); 179 181 180 182 int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key) 181 183 { ··· 193 197 hlist_del_init_rcu(&item->head); 194 198 return 0; 195 199 } 196 - EXPORT_SYMBOL(drm_ht_remove_item); 197 200 198 201 void drm_ht_remove(struct drm_open_hash *ht) 199 202 { ··· 201 206 ht->table = NULL; 202 207 } 203 208 } 204 - EXPORT_SYMBOL(drm_ht_remove);
+39 -1
drivers/gpu/drm/drm_legacy.h
··· 35 35 #include <drm/drm_legacy.h> 36 36 37 37 struct agp_memory; 38 + struct drm_buf_desc; 38 39 struct drm_device; 39 40 struct drm_file; 40 - struct drm_buf_desc; 41 + struct drm_hash_item; 42 + struct drm_open_hash; 43 + 44 + /* 45 + * Hash-table Support 46 + */ 47 + 48 + #define drm_hash_entry(_ptr, _type, _member) container_of(_ptr, _type, _member) 49 + 50 + /* drm_hashtab.c */ 51 + #if IS_ENABLED(CONFIG_DRM_LEGACY) 52 + int drm_ht_create(struct drm_open_hash *ht, unsigned int order); 53 + int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item); 54 + int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item, 55 + unsigned long seed, int bits, int shift, 56 + unsigned long add); 57 + int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, struct drm_hash_item **item); 58 + 59 + void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key); 60 + int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key); 61 + int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item); 62 + void drm_ht_remove(struct drm_open_hash *ht); 63 + #endif 64 + 65 + /* 66 + * RCU-safe interface 67 + * 68 + * The user of this API needs to make sure that two or more instances of the 69 + * hash table manipulation functions are never run simultaneously. 70 + * The lookup function drm_ht_find_item_rcu may, however, run simultaneously 71 + * with any of the manipulation functions as long as it's called from within 72 + * an RCU read-locked section. 73 + */ 74 + #define drm_ht_insert_item_rcu drm_ht_insert_item 75 + #define drm_ht_just_insert_please_rcu drm_ht_just_insert_please 76 + #define drm_ht_remove_key_rcu drm_ht_remove_key 77 + #define drm_ht_remove_item_rcu drm_ht_remove_item 78 + #define drm_ht_find_item_rcu drm_ht_find_item 41 79 42 80 /* 43 81 * Generic DRM Contexts
+1 -4
include/drm/drm_device.h
··· 6 6 #include <linux/mutex.h> 7 7 #include <linux/idr.h> 8 8 9 - #include <drm/drm_hashtab.h> 9 + #include <drm/drm_legacy.h> 10 10 #include <drm/drm_mode_config.h> 11 11 12 12 struct drm_driver; 13 13 struct drm_minor; 14 14 struct drm_master; 15 - struct drm_device_dma; 16 15 struct drm_vblank_crtc; 17 - struct drm_sg_mem; 18 - struct drm_local_map; 19 16 struct drm_vma_offset_manager; 20 17 struct drm_vram_mm; 21 18 struct drm_fb_helper;
-79
include/drm/drm_hashtab.h
··· 1 - /************************************************************************** 2 - * 3 - * Copyright 2006 Tungsten Graphics, Inc., Bismack, ND. USA. 4 - * All Rights Reserved. 5 - * 6 - * Permission is hereby granted, free of charge, to any person obtaining a 7 - * copy of this software and associated documentation files (the 8 - * "Software"), to deal in the Software without restriction, including 9 - * without limitation the rights to use, copy, modify, merge, publish, 10 - * distribute, sub license, and/or sell copies of the Software, and to 11 - * permit persons to whom the Software is furnished to do so, subject to 12 - * the following conditions: 13 - * 14 - * The above copyright notice and this permission notice (including the 15 - * next paragraph) shall be included in all copies or substantial portions 16 - * of the Software. 17 - * 18 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 21 - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 22 - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 23 - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 24 - * USE OR OTHER DEALINGS IN THE SOFTWARE. 25 - * 26 - * 27 - **************************************************************************/ 28 - /* 29 - * Simple open hash tab implementation. 30 - * 31 - * Authors: 32 - * Thomas Hellström <thomas-at-tungstengraphics-dot-com> 33 - */ 34 - 35 - #ifndef DRM_HASHTAB_H 36 - #define DRM_HASHTAB_H 37 - 38 - #include <linux/list.h> 39 - 40 - #define drm_hash_entry(_ptr, _type, _member) container_of(_ptr, _type, _member) 41 - 42 - struct drm_hash_item { 43 - struct hlist_node head; 44 - unsigned long key; 45 - }; 46 - 47 - struct drm_open_hash { 48 - struct hlist_head *table; 49 - u8 order; 50 - }; 51 - 52 - int drm_ht_create(struct drm_open_hash *ht, unsigned int order); 53 - int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item); 54 - int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item, 55 - unsigned long seed, int bits, int shift, 56 - unsigned long add); 57 - int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, struct drm_hash_item **item); 58 - 59 - void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key); 60 - int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key); 61 - int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item); 62 - void drm_ht_remove(struct drm_open_hash *ht); 63 - 64 - /* 65 - * RCU-safe interface 66 - * 67 - * The user of this API needs to make sure that two or more instances of the 68 - * hash table manipulation functions are never run simultaneously. 69 - * The lookup function drm_ht_find_item_rcu may, however, run simultaneously 70 - * with any of the manipulation functions as long as it's called from within 71 - * an RCU read-locked section. 72 - */ 73 - #define drm_ht_insert_item_rcu drm_ht_insert_item 74 - #define drm_ht_just_insert_please_rcu drm_ht_just_insert_please 75 - #define drm_ht_remove_key_rcu drm_ht_remove_key 76 - #define drm_ht_remove_item_rcu drm_ht_remove_item 77 - #define drm_ht_find_item_rcu drm_ht_find_item 78 - 79 - #endif
+14 -1
include/drm/drm_legacy.h
··· 37 37 38 38 #include <drm/drm.h> 39 39 #include <drm/drm_auth.h> 40 - #include <drm/drm_hashtab.h> 41 40 42 41 struct drm_device; 43 42 struct drm_driver; ··· 49 50 * If you add a new driver and it uses any of these functions or structures, 50 51 * you're doing it terribly wrong. 51 52 */ 53 + 54 + /* 55 + * Hash-table Support 56 + */ 57 + 58 + struct drm_hash_item { 59 + struct hlist_node head; 60 + unsigned long key; 61 + }; 62 + 63 + struct drm_open_hash { 64 + struct hlist_head *table; 65 + u8 order; 66 + }; 52 67 53 68 /** 54 69 * DMA buffer.