kill drm cruft with fire
Subsystems (7)
cover kill drm cruft with fire
Hi all,
It's that time of the year again when the weather gets crappy, people depressed and danvet wades through drm cruft. Not that any of this is related in any way.
Actually I only wanted to port users of drm_mm to the new interfaces, completing a work I've started a while ago. It lead to a littel detour.
Patches 1-10 kill drm_sman (hereby reducing the number of users of the old drm_mm interface by one). I don't have either sis or via hw but given
- how lightly the dri1 removal went down
- you can't really ebay this hw anymore (at least not here, I've tried)
- and that no one really changes much in them anymore (last time was me a year ago, killing cruft)
I think the risk is worth it. Worst case I expect to some oops-decoding because this doesn't change neither userspace nor hw facing code, only pure kernel book-keeping.
Patches 11-17 clean the reclaim_buffers support by the drm core by moving everything into driver specific preclose functions. I've noticed this horrid stuff while writing the buffer tracking code for via/sis.
Patches 18-20 rip out the dma queue code, which was totally unused. The two risky steps of that surgery are split out.
Patches 21-23 finish this series by killing a few random smaller things I've noticed.
Entire pile tested on my i810, that's the last fully working dri1 setup I still have. The reclaim_buffers rework actually improves things there.
Two patches have a potential userspace abi impact, one is i810 specific (didn't break anything in testing), the other breaks libdrm that is older than 10 years (by killing proc).
The drm fd release path looks now much less scary with this series (mostly due to the reclaim_buffers rework), but there's still the context support seemingly only used by via left. I might look into that as soon as I can get these images of horribly slaugthered kittens out of my brain ...
Review, flames highly welcome.
Cheers, Daniel
Daniel Vetter (23):
drm/sis: track obj->drm_fd relations in the driver drm/via: track obj->drm_fd relations in the driver drm/sman: kill owner tracking interface functions drm/sman: rip out owner tracking
drm/via: track user->memblock mapping with idr drm/sis: track user->memblock mapping with idr drm/sman: kill user_hash_tab
drm/via: use drm_mm instead of drm_sman drm/sis: use drm_mm instead of drm_sman
drm: kill drm_sman
drm/via: clean up reclaim_buffers
drm/sis: clean up reclaim_buffers
drm: kill reclaim_buffers_idlelocked functions
drm/i810: cleanup reclaim_buffers
drm: kill reclaim_buffers_locked
drm/savage: clean up reclaim_buffers
drm: kill reclaim_buffers callback
drm: ditch strange DRIVER_DMA_QUEUE only error bail-out
drm: kill dma queue support
drm: unconditionally clean up dma buffers of closing clients
drm: kill i915/i830 ids from drm_pciids.h
drm: kill procfs support
drm: kill a few unused remnants from drm_memory.c
drivers/gpu/drm/Makefile | 4 +- drivers/gpu/drm/drm_bufs.c | 16 +-- drivers/gpu/drm/drm_debugfs.c | 1 - drivers/gpu/drm/drm_dma.c | 5 - drivers/gpu/drm/drm_drv.c | 19 -- drivers/gpu/drm/drm_fops.c | 63 +------ drivers/gpu/drm/drm_info.c | 36 ---- drivers/gpu/drm/drm_lock.c | 6 +- drivers/gpu/drm/drm_memory.c | 19 -- drivers/gpu/drm/drm_proc.c | 221 --------------------- drivers/gpu/drm/drm_sman.c | 350 --------------------------------- drivers/gpu/drm/drm_stub.c | 25 +-- drivers/gpu/drm/i810/i810_dma.c | 17 +- drivers/gpu/drm/i810/i810_drv.c | 3 +- drivers/gpu/drm/i810/i810_drv.h | 6 +- drivers/gpu/drm/i915/i915_drv.c | 1 - drivers/gpu/drm/mga/mga_drv.c | 1 - drivers/gpu/drm/nouveau/nouveau_drv.c | 1 - drivers/gpu/drm/r128/r128_drv.c | 1 - drivers/gpu/drm/radeon/radeon_drv.c | 2 - drivers/gpu/drm/savage/savage_bci.c | 7 +- drivers/gpu/drm/savage/savage_drv.c | 2 +- drivers/gpu/drm/sis/sis_drv.c | 36 +++- drivers/gpu/drm/sis/sis_drv.h | 7 +- drivers/gpu/drm/sis/sis_mm.c | 210 ++++++++++++-------- drivers/gpu/drm/tdfx/tdfx_drv.c | 1 - drivers/gpu/drm/via/via_drv.c | 29 +++- drivers/gpu/drm/via/via_drv.h | 7 +- drivers/gpu/drm/via/via_map.c | 10 +- drivers/gpu/drm/via/via_mm.c | 145 +++++++++----- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 1 - drivers/staging/gma500/psb_drv.c | 1 - include/drm/drmP.h | 28 +--- include/drm/drm_pciids.h | 42 ---- include/drm/drm_sman.h | 176 ----------------- include/drm/sis_drm.h | 4 + include/drm/via_drm.h | 4 + 37 files changed, 337 insertions(+), 1170 deletions(-) delete mode 100644 drivers/gpu/drm/drm_proc.c delete mode 100644 drivers/gpu/drm/drm_sman.c delete mode 100644 include/drm/drm_sman.h
Signature · 1 line
1.7.7.1
PATCH 1/23 drm/sis: track obj->drm_fd relations in the driver
By attach a driver private struct to each open drm fd.
Because we steal the owner_list from drm_sman until things settle, use list_move instead of list_add.
This requires to export a drm_sman function temporarily before drm_sman will die for real completely.
--- drivers/gpu/drm/drm_sman.c | 3 ++- drivers/gpu/drm/sis/sis_drv.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/sis/sis_mm.c | 22 ++++++++++++++-------- include/drm/drm_sman.h | 1 + include/drm/sis_drm.h | 4 ++++ 5 files changed, 46 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_sman.c +2 -1
@@ -243,7 +243,7 @@ out:EXPORT_SYMBOL (drm_sman_alloc); -static void drm_sman_free (struct drm_memblock_item *item) +void drm_sman_free (struct drm_memblock_item *item) {struct drm_sman *sman = item->sman;
@@ -252,6 +252,7 @@ static void drm_sman_free(struct drm_memblock_item *item) item->mm->free (item->mm->private, item->mm_info);kfree (item); } +EXPORT_SYMBOL (drm_sman_free);int drm_sman_free_key (struct drm_sman *sman,unsigned int key) {
drivers/gpu/drm/sis/sis_drv.c +25 -0
@@ -63,10 +63,35 @@ static int sis_driver_unload(struct drm_device *dev)return 0 ; } +static int sis_driver_open (struct drm_device *dev,struct drm_file *file) +{ +struct sis_file_private *file_priv; + +DRM_DEBUG_DRIVER ("\n" ); + file_priv =kmalloc (sizeof (*file_priv),GFP_KERNEL ); +if (!file_priv) +return -ENOMEM ; + + file->driver_priv = file_priv; + +INIT_LIST_HEAD (&file_priv->obj_list); + +return 0 ; +} + +void sis_driver_postclose (struct drm_device *dev,struct drm_file *file) +{ +struct sis_file_private *file_priv = file->driver_priv; + +kfree (file_priv); +} +static struct drm_driver driver = { .driver_features =DRIVER_USE_AGP |DRIVER_USE_MTRR , .load = sis_driver_load, .unload = sis_driver_unload, + .open = sis_driver_open, + .postclose = sis_driver_postclose, .dma_quiescent = sis_idle, .reclaim_buffers =NULL , .reclaim_buffers_idlelocked = sis_reclaim_buffers_locked,
drivers/gpu/drm/sis/sis_mm.c +14 -8
@@ -120,13 +120,14 @@ static int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *filereturn 0 ; } -static int sis_drm_alloc (struct drm_device *dev,struct drm_file *file_priv, +static int sis_drm_alloc (struct drm_device *dev,struct drm_file *file,void *data,int pool) {drm_sis_private_t *dev_priv = dev->dev_private;drm_sis_mem_t *mem = data;int retval =0 ;struct drm_memblock_item *item; +struct sis_file_private *file_priv = file->driver_priv;mutex_lock (&dev->struct_mutex);
@@ -139,11 +140,10 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv, } mem->size = (mem->size +SIS_MM_ALIGN_MASK ) >>SIS_MM_ALIGN_SHIFT ; - item =drm_sman_alloc (&dev_priv->sman, pool, mem->size,0 , - (unsigned long )file_priv); + item =drm_sman_alloc (&dev_priv->sman, pool, mem->size,0 ,0 ); -mutex_unlock (&dev->struct_mutex);if (item) { +list_move (&item->owner_list, &file_priv->obj_list); mem->offset = ((pool ==0 ) ? dev_priv->vram_offset : dev_priv->agp_offset) + (item->mm->
@@ -156,6 +156,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv, mem->free =0 ; retval = -ENOMEM ; } +mutex_unlock (&dev->struct_mutex);DRM_DEBUG ("alloc %d, size = %d, offset = %d\n" , pool, mem->size, mem->offset);
@@ -301,12 +302,13 @@ void sis_lastclose(struct drm_device *dev) }void sis_reclaim_buffers_locked (struct drm_device *dev, -struct drm_file *file_priv) +struct drm_file *file) { -drm_sis_private_t *dev_priv = dev->dev_private; +struct sis_file_private *file_priv = file->driver_priv; +struct drm_memblock_item *entry, *next;mutex_lock (&dev->struct_mutex); -if (drm_sman_owner_clean (&dev_priv->sman, (unsigned long )file_priv)) { +if (list_empty (&file_priv->obj_list)) {mutex_unlock (&dev->struct_mutex);return ; }
@@ -314,7 +316,11 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,if (dev->driver->dma_quiescent) dev->driver->dma_quiescent (dev); -drm_sman_owner_cleanup (&dev_priv->sman, (unsigned long )file_priv); + +list_for_each_entry_safe (entry, next, &file_priv->obj_list, + owner_list) { +drm_sman_free (entry); + }mutex_unlock (&dev->struct_mutex);return ; }
include/drm/drm_sman.h +1 -0
@@ -146,6 +146,7 @@ extern struct drm_memblock_item *drm_sman_alloc(struct drm_sman * sman,*/ extern int drm_sman_free_key (struct drm_sman * sman,unsigned int key); +extern void drm_sman_free (struct drm_memblock_item *item);/* * returns 1 iff there are no stale memory blocks associated with this owner.
include/drm/sis_drm.h +4 -0
@@ -64,4 +64,8 @@ typedef struct { unsigned int offset, size; } drm_sis_fb_t; +struct sis_file_private { +struct list_head obj_list; +}; +#endif /* __SIS_DRM_H__ */
Signature · 1 line
1.7.7.1
PATCH 2/23 drm/via: track obj->drm_fd relations in the driver
In reply to Daniel VetterExactly like the previous patch for sis.
--- drivers/gpu/drm/via/via_drv.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/via/via_mm.c | 22 ++++++++++++++-------- include/drm/via_drm.h | 4 ++++ 3 files changed, 43 insertions(+), 8 deletions(-)
drivers/gpu/drm/via/via_drv.c +25 -0
@@ -28,6 +28,29 @@#include "drm_pciids.h" +static int via_driver_open (struct drm_device *dev,struct drm_file *file) +{ +struct via_file_private *file_priv; + +DRM_DEBUG_DRIVER ("\n" ); + file_priv =kmalloc (sizeof (*file_priv),GFP_KERNEL ); +if (!file_priv) +return -ENOMEM ; + + file->driver_priv = file_priv; + +INIT_LIST_HEAD (&file_priv->obj_list); + +return 0 ; +} + +void via_driver_postclose (struct drm_device *dev,struct drm_file *file) +{ +struct via_file_private *file_priv = file->driver_priv; + +kfree (file_priv); +} +static struct pci_device_id pciidlist[] = { viadrv_PCI_IDS };
@@ -38,6 +61,8 @@ static struct drm_driver driver = { DRIVER_IRQ_SHARED, .load = via_driver_load, .unload = via_driver_unload, + .open = via_driver_open, + .postclose = via_driver_postclose, .context_dtor = via_final_context, .get_vblank_counter = via_get_vblank_counter, .enable_vblank = via_enable_vblank,
drivers/gpu/drm/via/via_mm.c +14 -8
@@ -115,12 +115,13 @@ void via_lastclose(struct drm_device *dev) }int via_mem_alloc (struct drm_device *dev,void *data, -struct drm_file *file_priv) +struct drm_file *file) {drm_via_mem_t *mem = data;int retval =0 ;struct drm_memblock_item *item;drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; +struct via_file_private *file_priv = file->driver_priv;unsigned long tmpSize;if (mem->type >VIA_MEM_AGP ) {
@@ -137,10 +138,10 @@ int via_mem_alloc(struct drm_device *dev, void *data, } tmpSize = (mem->size +VIA_MM_ALIGN_MASK ) >>VIA_MM_ALIGN_SHIFT ; - item =drm_sman_alloc (&dev_priv->sman, mem->type, tmpSize,0 , - (unsigned long )file_priv); -mutex_unlock (&dev->struct_mutex); + item =drm_sman_alloc (&dev_priv->sman, mem->type, tmpSize,0 ,0 ); +if (item) { +list_move (&item->owner_list, &file_priv->obj_list); mem->offset = ((mem->type ==VIA_MEM_VIDEO ) ? dev_priv->vram_offset : dev_priv->agp_offset) + (item->mm->
@@ -153,6 +154,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,DRM_DEBUG ("Video memory allocation failed\n" ); retval = -ENOMEM ; } +mutex_unlock (&dev->struct_mutex);return retval; }
@@ -173,12 +175,13 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv)void via_reclaim_buffers_locked (struct drm_device *dev, -struct drm_file *file_priv) +struct drm_file *file) { -drm_via_private_t *dev_priv = dev->dev_private; +struct via_file_private *file_priv = file->driver_priv; +struct drm_memblock_item *entry, *next;mutex_lock (&dev->struct_mutex); -if (drm_sman_owner_clean (&dev_priv->sman, (unsigned long )file_priv)) { +if (list_empty (&file_priv->obj_list)) {mutex_unlock (&dev->struct_mutex);return ; }
@@ -186,7 +189,10 @@ void via_reclaim_buffers_locked(struct drm_device *dev,if (dev->driver->dma_quiescent) dev->driver->dma_quiescent (dev); -drm_sman_owner_cleanup (&dev_priv->sman, (unsigned long )file_priv); +list_for_each_entry_safe (entry, next, &file_priv->obj_list, + owner_list) { +drm_sman_free (entry); + }mutex_unlock (&dev->struct_mutex);return ; }
include/drm/via_drm.h +4 -0
@@ -274,4 +274,8 @@ typedef struct drm_via_dmablit { drm_via_blitsync_t sync; } drm_via_dmablit_t; +struct via_file_private { +struct list_head obj_list; +}; +#endif /* _VIA_DRM_H_ */
Signature · 1 line
1.7.7.1
Re: [PATCH 02/23] drm/via: track obj->drm_fd relations in the driver
Quoted 5 lines
Exactly like the previous patch for sis.
Signed-off-by Daniel Vetter <[email protected]>
Same goes for PATCH 01 which I'm missing in my inbox.
Quoted 140 lines
--- drivers/gpu/drm/via/via_drv.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/via/via_mm.c | 22 ++++++++++++++-------- include/drm/via_drm.h | 4 ++++ 3 files changed, 43 insertions(+), 8 deletions(-)drivers/gpu/drm/via/via_drv.c +25
-0@@ -28,6 +28,29 @@#include "drm_pciids.h" +static int via_driver_open (struct drm_device *dev,struct drm_file *file) +{ +struct via_file_private *file_priv; + +DRM_DEBUG_DRIVER ("\n" ); + file_priv =kmalloc (sizeof (*file_priv),GFP_KERNEL ); +if (!file_priv) +return -ENOMEM ; + + file->driver_priv = file_priv; + +INIT_LIST_HEAD (&file_priv->obj_list); + +return 0 ; +} + +void via_driver_postclose (struct drm_device *dev,struct drm_file *file) +{ +struct via_file_private *file_priv = file->driver_priv; + +kfree (file_priv); +} +static struct pci_device_id pciidlist[] = { viadrv_PCI_IDS };@@ -38,6 +61,8 @@ static struct drm_driver driver = { DRIVER_IRQ_SHARED, .load = via_driver_load, .unload = via_driver_unload, + .open = via_driver_open, + .postclose = via_driver_postclose, .context_dtor = via_final_context, .get_vblank_counter = via_get_vblank_counter, .enable_vblank = via_enable_vblank,drivers/gpu/drm/via/via_mm.c +14
-8@@ -115,12 +115,13 @@ void via_lastclose(struct drm_device *dev) }int via_mem_alloc (struct drm_device *dev,void *data, -struct drm_file *file_priv) +struct drm_file *file) {drm_via_mem_t *mem = data;int retval =0 ;struct drm_memblock_item *item;drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; +struct via_file_private *file_priv = file->driver_priv;unsigned long tmpSize;if (mem->type >VIA_MEM_AGP ) {@@ -137,10 +138,10 @@ int via_mem_alloc(struct drm_device *dev, void *data, } tmpSize = (mem->size +VIA_MM_ALIGN_MASK ) >>VIA_MM_ALIGN_SHIFT ; - item =drm_sman_alloc (&dev_priv->sman, mem->type, tmpSize,0 , - (unsigned long )file_priv); -mutex_unlock (&dev->struct_mutex); + item =drm_sman_alloc (&dev_priv->sman, mem->type, tmpSize,0 ,0 ); +if (item) { +list_move (&item->owner_list, &file_priv->obj_list); mem->offset = ((mem->type ==VIA_MEM_VIDEO ) ? dev_priv->vram_offset : dev_priv->agp_offset) + (item->mm->@@ -153,6 +154,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,DRM_DEBUG ("Video memory allocation failed\n" ); retval = -ENOMEM ; } +mutex_unlock (&dev->struct_mutex);return retval; }@@ -173,12 +175,13 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv)void via_reclaim_buffers_locked (struct drm_device *dev, -struct drm_file *file_priv) +struct drm_file *file) { -drm_via_private_t *dev_priv = dev->dev_private; +struct via_file_private *file_priv = file->driver_priv; +struct drm_memblock_item *entry, *next;mutex_lock (&dev->struct_mutex); -if (drm_sman_owner_clean (&dev_priv->sman, (unsigned long )file_priv)) { +if (list_empty (&file_priv->obj_list)) {mutex_unlock (&dev->struct_mutex);return ; }@@ -186,7 +189,10 @@ void via_reclaim_buffers_locked(struct drm_device *dev,if (dev->driver->dma_quiescent) dev->driver->dma_quiescent (dev); -drm_sman_owner_cleanup (&dev_priv->sman, (unsigned long )file_priv); +list_for_each_entry_safe (entry, next, &file_priv->obj_list, + owner_list) { +drm_sman_free (entry); + }mutex_unlock (&dev->struct_mutex);return ; }include/drm/via_drm.h +4
-0@@ -274,4 +274,8 @@ typedef struct drm_via_dmablit { drm_via_blitsync_t sync; } drm_via_dmablit_t; +struct via_file_private { +struct list_head obj_list; +}; +#endif /* _VIA_DRM_H_ */ Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/23 drm/sman: kill owner tracking interface functions
In reply to Daniel VetterThese are now unused.
--- drivers/gpu/drm/drm_sman.c | 38 -------------------------------------- include/drm/drm_sman.h | 19 ------------------- 2 files changed, 0 insertions(+), 57 deletions(-)
drivers/gpu/drm/drm_sman.c +0 -38
@@ -278,27 +278,6 @@ static void drm_sman_remove_owner(struct drm_sman *sman,kfree (owner_item); } -int drm_sman_owner_clean (struct drm_sman *sman,unsigned long owner) -{ - -struct drm_hash_item *hash_item; -struct drm_owner_item *owner_item; - -if (drm_ht_find_item (&sman->owner_hash_tab, owner, &hash_item)) { -return -1 ; - } - - owner_item = drm_hash_entry(hash_item, struct drm_owner_item, owner_hash); -if (owner_item->mem_blocks.next == &owner_item->mem_blocks) { -drm_sman_remove_owner (sman, owner_item); -return -1 ; - } - -return 0 ; -} - -EXPORT_SYMBOL (drm_sman_owner_clean); -static void drm_sman_do_owner_cleanup (struct drm_sman *sman,struct drm_owner_item *owner_item) {
@@ -311,23 +290,6 @@ static void drm_sman_do_owner_cleanup(struct drm_sman *sman,drm_sman_remove_owner (sman, owner_item); } -void drm_sman_owner_cleanup (struct drm_sman *sman,unsigned long owner) -{ - -struct drm_hash_item *hash_item; -struct drm_owner_item *owner_item; - -if (drm_ht_find_item (&sman->owner_hash_tab, owner, &hash_item)) { - -return ; - } - - owner_item = drm_hash_entry(hash_item, struct drm_owner_item, owner_hash); -drm_sman_do_owner_cleanup (sman, owner_item); -} - -EXPORT_SYMBOL (drm_sman_owner_cleanup); -void drm_sman_cleanup (struct drm_sman *sman) {struct drm_owner_item *entry, *next;
include/drm/drm_sman.h +0 -19
@@ -149,25 +149,6 @@ extern int drm_sman_free_key(struct drm_sman * sman, unsigned int key);extern void drm_sman_free (struct drm_memblock_item *item);/* -* returns 1 iff there are no stale memory blocks associated with this owner. -* Typically called to determine if we need to idle the hardware and call -* drm_sman_owner_cleanup. If there are no stale memory blocks, it removes all -* resources associated with owner. -*/ - -extern int drm_sman_owner_clean (struct drm_sman * sman,unsigned long owner); - -/* -* Frees all stale memory blocks associated with this owner. Note that this -* requires that the hardware is finished with all blocks, so the graphics engine -* should be idled before this call is made. This function also frees -* any resources associated with "owner" and should be called when owner -* is not going to be referenced anymore. -*/ - -extern void drm_sman_owner_cleanup (struct drm_sman * sman,unsigned long owner); - -/* * Frees all stale memory blocks associated with the memory manager. * See idling above. */
Signature · 1 line
1.7.7.1
Re: [PATCH 03/23] drm/sman: kill owner tracking interface functions
Quoted 4 lines
These are now unused.
Signed-off-by Daniel Vetter <[email protected]>
Quoted 99 lines
--- drivers/gpu/drm/drm_sman.c | 38 -------------------------------------- include/drm/drm_sman.h | 19 ------------------- 2 files changed, 0 insertions(+), 57 deletions(-)drivers/gpu/drm/drm_sman.c +0
-38@@ -278,27 +278,6 @@ static void drm_sman_remove_owner(struct drm_sman *sman,kfree (owner_item); } -int drm_sman_owner_clean (struct drm_sman *sman,unsigned long owner) -{ - -struct drm_hash_item *hash_item; -struct drm_owner_item *owner_item; - -if (drm_ht_find_item (&sman->owner_hash_tab, owner, &hash_item)) { -return -1 ; - } - - owner_item = drm_hash_entry(hash_item, struct drm_owner_item, owner_hash); -if (owner_item->mem_blocks.next == &owner_item->mem_blocks) { -drm_sman_remove_owner (sman, owner_item); -return -1 ; - } - -return 0 ; -} - -EXPORT_SYMBOL (drm_sman_owner_clean); -static void drm_sman_do_owner_cleanup (struct drm_sman *sman,struct drm_owner_item *owner_item) {@@ -311,23 +290,6 @@ static void drm_sman_do_owner_cleanup(struct drm_sman *sman,drm_sman_remove_owner (sman, owner_item); } -void drm_sman_owner_cleanup (struct drm_sman *sman,unsigned long owner) -{ - -struct drm_hash_item *hash_item; -struct drm_owner_item *owner_item; - -if (drm_ht_find_item (&sman->owner_hash_tab, owner, &hash_item)) { - -return ; - } - - owner_item = drm_hash_entry(hash_item, struct drm_owner_item, owner_hash); -drm_sman_do_owner_cleanup (sman, owner_item); -} - -EXPORT_SYMBOL (drm_sman_owner_cleanup); -void drm_sman_cleanup (struct drm_sman *sman) {struct drm_owner_item *entry, *next;include/drm/drm_sman.h +0
-19@@ -149,25 +149,6 @@ extern int drm_sman_free_key(struct drm_sman * sman, unsigned int key);extern void drm_sman_free (struct drm_memblock_item *item);/* -* returns 1 iff there are no stale memory blocks associated with this owner. -* Typically called to determine if we need to idle the hardware and call -* drm_sman_owner_cleanup. If there are no stale memory blocks, it removes all -* resources associated with owner. -*/ - -extern int drm_sman_owner_clean (struct drm_sman * sman,unsigned long owner); - -/* -* Frees all stale memory blocks associated with this owner. Note that this -* requires that the hardware is finished with all blocks, so the graphics engine -* should be idled before this call is made. This function also frees -* any resources associated with "owner" and should be called when owner -* is not going to be referenced anymore. -*/ - -extern void drm_sman_owner_cleanup (struct drm_sman * sman,unsigned long owner); - -/* * Frees all stale memory blocks associated with the memory manager. * See idling above. */ Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/23 drm/sman: rip out owner tracking
In reply to Daniel VetterIn contrast to kms drivers, sis/via _always_ associated a buffer with a drm fd. So by the time we reach lastclose, all open drm fds are gone and with them their associated objects.
So when sis/via call drm_sman_cleanup in their lastclose funcs, that will free 0 objects.
The owner tracking now serves no purpose at all, hence rip it ou. We can't kill the corresponding fields in struct drm_memblock_item yet because we hijack these in the new driver private owner tracking. But now that drm_sman.c doesn't touch ->owner_list anymore, we need to kill the list_move hack and properly add the item to the file_priv list.
Also leave the list_del(&obj->owner_list) in drm_sman_free for the moment, it will move to the drivers when sman disappears completely.
--- drivers/gpu/drm/drm_sman.c | 71 ------------------------------------------ drivers/gpu/drm/sis/sis_mm.c | 3 +- drivers/gpu/drm/via/via_mm.c | 3 +- include/drm/drm_sman.h | 2 - 4 files changed, 4 insertions(+), 75 deletions(-)
drivers/gpu/drm/drm_sman.c +0 -71
@@ -47,7 +47,6 @@ struct drm_owner_item {void drm_sman_takedown (struct drm_sman * sman) {drm_ht_remove (&sman->user_hash_tab); -drm_ht_remove (&sman->owner_hash_tab);kfree (sman->mm); }
@@ -65,16 +64,10 @@ drm_sman_init(struct drm_sman * sman, unsigned int num_managers, goto out; } sman->num_managers = num_managers; -INIT_LIST_HEAD (&sman->owner_items); - ret =drm_ht_create (&sman->owner_hash_tab, owner_order); -if (ret) - goto out1; ret =drm_ht_create (&sman->user_hash_tab, user_order);if (!ret) goto out; -drm_ht_remove (&sman->owner_hash_tab); -out1:kfree (sman->mm); out:return ret;
@@ -160,44 +153,12 @@ drm_sman_set_manager(struct drm_sman * sman, unsigned int manager, }EXPORT_SYMBOL (drm_sman_set_manager); -static struct drm_owner_item *drm_sman_get_owner_item (struct drm_sman * sman, -unsigned long owner) -{ -int ret; -struct drm_hash_item *owner_hash_item; -struct drm_owner_item *owner_item; - - ret =drm_ht_find_item (&sman->owner_hash_tab, owner, &owner_hash_item); -if (!ret) { - return drm_hash_entry(owner_hash_item, struct drm_owner_item, - owner_hash); - } - - owner_item =kzalloc (sizeof (*owner_item),GFP_KERNEL ); -if (!owner_item) - goto out; - -INIT_LIST_HEAD (&owner_item->mem_blocks); - owner_item->owner_hash.key = owner; -if (drm_ht_insert_item (&sman->owner_hash_tab, &owner_item->owner_hash)) - goto out1; - -list_add_tail (&owner_item->sman_list, &sman->owner_items); -return owner_item; - -out1: -kfree (owner_item); -out: -return NULL ; -} -struct drm_memblock_item *drm_sman_alloc (struct drm_sman *sman,unsigned int manager,unsigned long size,unsigned alignment,unsigned long owner) {void *tmp;struct drm_sman_mm *sman_mm; -struct drm_owner_item *owner_item;struct drm_memblock_item *memblock;BUG_ON (manager >= sman->num_managers);
@@ -223,16 +184,8 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man (unsigned long)memblock, 32, 0, 0)) goto out1; - owner_item =drm_sman_get_owner_item (sman, owner); -if (!owner_item) - goto out2; - -list_add_tail (&memblock->owner_list, &owner_item->mem_blocks); -return memblock; -out2: -drm_ht_remove_item (&sman->user_hash_tab, &memblock->user_hash); out1:kfree (memblock); out:
@@ -270,35 +223,11 @@ int drm_sman_free_key(struct drm_sman *sman, unsigned int key)EXPORT_SYMBOL (drm_sman_free_key); -static void drm_sman_remove_owner (struct drm_sman *sman, -struct drm_owner_item *owner_item) -{ -list_del (&owner_item->sman_list); -drm_ht_remove_item (&sman->owner_hash_tab, &owner_item->owner_hash); -kfree (owner_item); -} - -static void drm_sman_do_owner_cleanup (struct drm_sman *sman, -struct drm_owner_item *owner_item) -{ -struct drm_memblock_item *entry, *next; - -list_for_each_entry_safe (entry, next, &owner_item->mem_blocks, - owner_list) { -drm_sman_free (entry); - } -drm_sman_remove_owner (sman, owner_item); -} -void drm_sman_cleanup (struct drm_sman *sman) { -struct drm_owner_item *entry, *next;unsigned int i;struct drm_sman_mm *sman_mm; -list_for_each_entry_safe (entry, next, &sman->owner_items, sman_list) { -drm_sman_do_owner_cleanup (sman, entry); - }if (sman->mm) {for (i =0 ; i < sman->num_managers; ++i) { sman_mm = &sman->mm[i];
drivers/gpu/drm/sis/sis_mm.c +2 -1
@@ -143,7 +143,8 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file, item =drm_sman_alloc (&dev_priv->sman, pool, mem->size,0 ,0 );if (item) { -list_move (&item->owner_list, &file_priv->obj_list); +INIT_LIST_HEAD (&item->owner_list); +list_add (&item->owner_list, &file_priv->obj_list); mem->offset = ((pool ==0 ) ? dev_priv->vram_offset : dev_priv->agp_offset) + (item->mm->
drivers/gpu/drm/via/via_mm.c +2 -1
@@ -141,7 +141,8 @@ int via_mem_alloc(struct drm_device *dev, void *data, item =drm_sman_alloc (&dev_priv->sman, mem->type, tmpSize,0 ,0 );if (item) { -list_move (&item->owner_list, &file_priv->obj_list); +INIT_LIST_HEAD (&item->owner_list); +list_add (&item->owner_list, &file_priv->obj_list); mem->offset = ((mem->type ==VIA_MEM_VIDEO ) ? dev_priv->vram_offset : dev_priv->agp_offset) + (item->mm->
include/drm/drm_sman.h +0 -2
@@ -87,9 +87,7 @@ struct drm_memblock_item {struct drm_sman {struct drm_sman_mm *mm;int num_managers; -struct drm_open_hash owner_hash_tab;struct drm_open_hash user_hash_tab; -struct list_head owner_items; };/*
Signature · 1 line
1.7.7.1
Re: [PATCH 04/23] drm/sman: rip out owner tracking
Quoted 15 lines
In contrast to kms drivers, sis/via _always_ associated a buffer with a drm fd. So by the time we reach lastclose, all open drm fds are gone and with them their associated objects.
So when sis/via call
drm_sman_cleanupin their lastclose funcs, that will free 0 objects.The owner tracking now serves no purpose at all, hence rip it ou. We can't kill the corresponding fields in struct
drm_memblock_itemyet because we hijack these in the new driver private owner tracking. But now thatdrm_sman.cdoesn't touch ->owner_list anymore, we need to kill thelist_movehack and properly add the item to thefile_privlist.
Quoted 4 lines
Also leave the
list_del(&obj->owner_list)indrm_sman_freefor the moment, it will move to the drivers when sman disappears completely.Signed-off-by Daniel Vetter <[email protected]>
Quoted 184 lines
--- drivers/gpu/drm/drm_sman.c | 71 ------------------------------------------ drivers/gpu/drm/sis/sis_mm.c | 3 +- drivers/gpu/drm/via/via_mm.c | 3 +- include/drm/drm_sman.h | 2 - 4 files changed, 4 insertions(+), 75 deletions(-)drivers/gpu/drm/drm_sman.c +0
-71@@ -47,7 +47,6 @@ struct drm_owner_item {void drm_sman_takedown (struct drm_sman * sman) {drm_ht_remove (&sman->user_hash_tab); -drm_ht_remove (&sman->owner_hash_tab);kfree (sman->mm); }@@ -65,16 +64,10 @@ drm_sman_init(struct drm_sman * sman, unsigned int num_managers, goto out; } sman->num_managers = num_managers; -INIT_LIST_HEAD (&sman->owner_items); - ret =drm_ht_create (&sman->owner_hash_tab, owner_order); -if (ret) - goto out1; ret =drm_ht_create (&sman->user_hash_tab, user_order);if (!ret) goto out; -drm_ht_remove (&sman->owner_hash_tab); -out1:kfree (sman->mm); out:return ret;@@ -160,44 +153,12 @@ drm_sman_set_manager(struct drm_sman * sman, unsigned int manager, }EXPORT_SYMBOL (drm_sman_set_manager); -static struct drm_owner_item *drm_sman_get_owner_item (struct drm_sman * sman, -unsigned long owner) -{ -int ret; -struct drm_hash_item *owner_hash_item; -struct drm_owner_item *owner_item; - - ret =drm_ht_find_item (&sman->owner_hash_tab, owner, &owner_hash_item); -if (!ret) { - return drm_hash_entry(owner_hash_item, struct drm_owner_item, - owner_hash); - } - - owner_item =kzalloc (sizeof (*owner_item),GFP_KERNEL ); -if (!owner_item) - goto out; - -INIT_LIST_HEAD (&owner_item->mem_blocks); - owner_item->owner_hash.key = owner; -if (drm_ht_insert_item (&sman->owner_hash_tab, &owner_item->owner_hash)) - goto out1; - -list_add_tail (&owner_item->sman_list, &sman->owner_items); -return owner_item; - -out1: -kfree (owner_item); -out: -return NULL ; -} -struct drm_memblock_item *drm_sman_alloc (struct drm_sman *sman,unsigned int manager,unsigned long size,unsigned alignment,unsigned long owner) {void *tmp;struct drm_sman_mm *sman_mm; -struct drm_owner_item *owner_item;struct drm_memblock_item *memblock;BUG_ON (manager >= sman->num_managers);@@ -223,16 +184,8 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man (unsigned long)memblock, 32, 0, 0)) goto out1; - owner_item =drm_sman_get_owner_item (sman, owner); -if (!owner_item) - goto out2; - -list_add_tail (&memblock->owner_list, &owner_item->mem_blocks); -return memblock; -out2: -drm_ht_remove_item (&sman->user_hash_tab, &memblock->user_hash); out1:kfree (memblock); out:@@ -270,35 +223,11 @@ int drm_sman_free_key(struct drm_sman *sman, unsigned int key)EXPORT_SYMBOL (drm_sman_free_key); -static void drm_sman_remove_owner (struct drm_sman *sman, -struct drm_owner_item *owner_item) -{ -list_del (&owner_item->sman_list); -drm_ht_remove_item (&sman->owner_hash_tab, &owner_item->owner_hash); -kfree (owner_item); -} - -static void drm_sman_do_owner_cleanup (struct drm_sman *sman, -struct drm_owner_item *owner_item) -{ -struct drm_memblock_item *entry, *next; - -list_for_each_entry_safe (entry, next, &owner_item->mem_blocks, - owner_list) { -drm_sman_free (entry); - } -drm_sman_remove_owner (sman, owner_item); -} -void drm_sman_cleanup (struct drm_sman *sman) { -struct drm_owner_item *entry, *next;unsigned int i;struct drm_sman_mm *sman_mm; -list_for_each_entry_safe (entry, next, &sman->owner_items, sman_list) { -drm_sman_do_owner_cleanup (sman, entry); - }if (sman->mm) {for (i =0 ; i < sman->num_managers; ++i) { sman_mm = &sman->mm[i];drivers/gpu/drm/sis/sis_mm.c +2
-1@@ -143,7 +143,8 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file, item =drm_sman_alloc (&dev_priv->sman, pool, mem->size,0 ,0 );if (item) { -list_move (&item->owner_list, &file_priv->obj_list); +INIT_LIST_HEAD (&item->owner_list); +list_add (&item->owner_list, &file_priv->obj_list); mem->offset = ((pool ==0 ) ? dev_priv->vram_offset : dev_priv->agp_offset) + (item->mm->drivers/gpu/drm/via/via_mm.c +2
-1@@ -141,7 +141,8 @@ int via_mem_alloc(struct drm_device *dev, void *data, item =drm_sman_alloc (&dev_priv->sman, mem->type, tmpSize,0 ,0 );if (item) { -list_move (&item->owner_list, &file_priv->obj_list); +INIT_LIST_HEAD (&item->owner_list); +list_add (&item->owner_list, &file_priv->obj_list); mem->offset = ((mem->type ==VIA_MEM_VIDEO ) ? dev_priv->vram_offset : dev_priv->agp_offset) + (item->mm->include/drm/drm_sman.h +0
-2@@ -87,9 +87,7 @@ struct drm_memblock_item {struct drm_sman {struct drm_sman_mm *mm;int num_managers; -struct drm_open_hash owner_hash_tab;struct drm_open_hash user_hash_tab; -struct list_head owner_items; };/* Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/23 drm/via: track user->memblock mapping with idr
In reply to Daniel VetterMassive indirection through a hashtable for a simple key->pointer look-up actually just adds bloat.
--- drivers/gpu/drm/via/via_drv.h | 2 + drivers/gpu/drm/via/via_map.c | 1 + drivers/gpu/drm/via/via_mm.c | 61 +++++++++++++++++++++++++++++++---------- 3 files changed, 49 insertions(+), 15 deletions(-)
drivers/gpu/drm/via/via_drv.h +2 -0
@@ -91,6 +91,8 @@ typedef struct drm_via_private {struct drm_sman sman;int vram_initialized;int agp_initialized; +/** Mapping of userspace keys to mm objects */ +struct idr object_idr;unsigned long vram_offset;unsigned long agp_offset;drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES ];
drivers/gpu/drm/via/via_map.c +1 -0
@@ -104,6 +104,7 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset) dev_priv->chipset = chipset; +idr_init (&dev->object_name_idr); ret =drm_sman_init (&dev_priv->sman,2 ,12 ,8 );if (ret) {kfree (dev_priv);
drivers/gpu/drm/via/via_mm.c +46 -15
88 lines not on this page · raw message
Signature · 1 line
1.7.7.1
Re: [PATCH 05/23] drm/via: track user->memblock mapping with idr
Quoted 10 lines
Massive indirection through a hashtable for a simple
key->pointerlook-up actually just adds bloat.Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/via/via_drv.h | 2 + drivers/gpu/drm/via/via_map.c | 1 + drivers/gpu/drm/via/via_mm.c | 61 +++++++++++++++++++++++++++++++---------- 3 files changed, 49 insertions(+), 15 deletions(-)
Quoted 128 lines
drivers/gpu/drm/via/via_drv.h +2
-0@@ -91,6 +91,8 @@ typedef struct drm_via_private {struct drm_sman sman;int vram_initialized;int agp_initialized; +/** Mapping of userspace keys to mm objects */ +struct idr object_idr;unsigned long vram_offset;unsigned long agp_offset;drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES ];drivers/gpu/drm/via/via_map.c +1
-0@@ -104,6 +104,7 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset) dev_priv->chipset = chipset; +idr_init (&dev->object_name_idr); ret =drm_sman_init (&dev_priv->sman,2 ,12 ,8 );if (ret) {kfree (dev_priv);drivers/gpu/drm/via/via_mm.c +46
-15@@ -118,7 +118,7 @@ int via_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file) {drm_via_mem_t *mem = data; -int retval =0 ; +int retval =0 , user_key;struct drm_memblock_item *item;drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;struct via_file_private *file_priv = file->driver_priv;@@ -139,24 +139,46 @@ int via_mem_alloc(struct drm_device *dev, void *data, tmpSize = (mem->size +VIA_MM_ALIGN_MASK ) >>VIA_MM_ALIGN_SHIFT ; item =drm_sman_alloc (&dev_priv->sman, mem->type, tmpSize,0 ,0 ); +if (!item) { + retval = -ENOMEM ; + goto fail_alloc; + } -if (item) { -INIT_LIST_HEAD (&item->owner_list); -list_add (&item->owner_list, &file_priv->obj_list); - mem->offset = ((mem->type ==VIA_MEM_VIDEO ) ? - dev_priv->vram_offset : dev_priv->agp_offset) + - (item->mm-> -offset (item->mm, item->mm_info) <<VIA_MM_ALIGN_SHIFT ); - mem->index = item->user_hash.key; - }else { - mem->offset =0 ; - mem->size =0 ; - mem->index =0 ; -DRM_DEBUG ("Video memory allocation failed\n" ); +again: +if (idr_pre_get (&dev_priv->object_idr,GFP_KERNEL ) ==0 ) { retval = -ENOMEM ; + goto fail_idr; } + +/* do the allocation under our spinlock */ + retval =idr_get_new_above (&dev_priv->object_idr, item,1 , &user_key); +if (retval == -EAGAIN ) + goto again; +if (retval) + goto fail_idr; + +INIT_LIST_HEAD (&item->owner_list); +list_add (&item->owner_list, &file_priv->obj_list);mutex_unlock (&dev->struct_mutex); + mem->offset = ((mem->type ==VIA_MEM_VIDEO ) ? + dev_priv->vram_offset : dev_priv->agp_offset) + + (item->mm-> +offset (item->mm, item->mm_info) <<VIA_MM_ALIGN_SHIFT ); + mem->index = user_key; + +return 0 ; + +fail_idr: +drm_sman_free (item); +fail_alloc: +mutex_unlock (&dev->struct_mutex); + + mem->offset =0 ; + mem->size =0 ; + mem->index =0 ; +DRM_DEBUG ("Video memory allocation failed\n" ); +return retval; }@@ -164,11 +186,20 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv) {drm_via_private_t *dev_priv = dev->dev_private;drm_via_mem_t *mem = data; +struct drm_memblock_item *obj;int ret;mutex_lock (&dev->struct_mutex); - ret =drm_sman_free_key (&dev_priv->sman, mem->index); + obj =idr_find (&dev_priv->object_idr, mem->index); +if (obj ==NULL ) { +mutex_unlock (&dev->struct_mutex); +return -EINVAL ; + } + +idr_remove (&dev_priv->object_idr, mem->index); +drm_sman_free (obj);mutex_unlock (&dev->struct_mutex); +DRM_DEBUG ("free = 0x%lx\n" , mem->index);return ret;Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/23 drm/sis: track user->memblock mapping with idr
In reply to Daniel Vetter--- drivers/gpu/drm/sis/sis_drv.c | 4 +++ drivers/gpu/drm/sis/sis_drv.h | 2 + drivers/gpu/drm/sis/sis_mm.c | 60 ++++++++++++++++++++++++++++++---------- drivers/gpu/drm/via/via_map.c | 2 + 4 files changed, 53 insertions(+), 15 deletions(-)
drivers/gpu/drm/sis/sis_drv.c +4 -0
@@ -46,6 +46,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset) dev->dev_private = (void *)dev_priv; dev_priv->chipset = chipset; +idr_init (&dev->object_name_idr); ret =drm_sman_init (&dev_priv->sman,2 ,12 ,8 );if (ret)kfree (dev_priv);
@@ -58,6 +59,9 @@ static int sis_driver_unload(struct drm_device *dev)drm_sis_private_t *dev_priv = dev->dev_private;drm_sman_takedown (&dev_priv->sman); +idr_remove_all (&dev_priv->object_idr); +idr_destroy (&dev_priv->object_idr); +kfree (dev_priv);return 0 ;
drivers/gpu/drm/sis/sis_drv.h +2 -0
@@ -60,6 +60,8 @@ typedef struct drm_sis_private {int agp_initialized;unsigned long vram_offset;unsigned long agp_offset; +/** Mapping of userspace keys to mm objects */ +struct idr object_idr; } drm_sis_private_t;extern int sis_idle (struct drm_device *dev);
drivers/gpu/drm/sis/sis_mm.c +45 -15
86 lines not on this page · raw message
drivers/gpu/drm/via/via_map.c +2 -0
@@ -126,6 +126,8 @@ int via_driver_unload(struct drm_device *dev)drm_via_private_t *dev_priv = dev->dev_private;drm_sman_takedown (&dev_priv->sman); +idr_remove_all (&dev_priv->object_idr); +idr_destroy (&dev_priv->object_idr);kfree (dev_priv);
Signature · 1 line
1.7.7.1
Re: [PATCH 06/23] drm/sis: track user->memblock mapping with idr
Quoted 2 lines
Signed-off-by Daniel Vetter <[email protected]>
Quoted 156 lines
--- drivers/gpu/drm/sis/sis_drv.c | 4 +++ drivers/gpu/drm/sis/sis_drv.h | 2 + drivers/gpu/drm/sis/sis_mm.c | 60 ++++++++++++++++++++++++++++++---------- drivers/gpu/drm/via/via_map.c | 2 + 4 files changed, 53 insertions(+), 15 deletions(-)drivers/gpu/drm/sis/sis_drv.c +4
-0@@ -46,6 +46,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset) dev->dev_private = (void *)dev_priv; dev_priv->chipset = chipset; +idr_init (&dev->object_name_idr); ret =drm_sman_init (&dev_priv->sman,2 ,12 ,8 );if (ret)kfree (dev_priv);@@ -58,6 +59,9 @@ static int sis_driver_unload(struct drm_device *dev)drm_sis_private_t *dev_priv = dev->dev_private;drm_sman_takedown (&dev_priv->sman); +idr_remove_all (&dev_priv->object_idr); +idr_destroy (&dev_priv->object_idr); +kfree (dev_priv);return 0 ;drivers/gpu/drm/sis/sis_drv.h +2
-0@@ -60,6 +60,8 @@ typedef struct drm_sis_private {int agp_initialized;unsigned long vram_offset;unsigned long agp_offset; +/** Mapping of userspace keys to mm objects */ +struct idr object_idr; } drm_sis_private_t;extern int sis_idle (struct drm_device *dev);drivers/gpu/drm/sis/sis_mm.c +45
-15@@ -125,7 +125,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file, {drm_sis_private_t *dev_priv = dev->dev_private;drm_sis_mem_t *mem = data; -int retval =0 ; +int retval =0 , user_key;struct drm_memblock_item *item;struct sis_file_private *file_priv = file->driver_priv;@@ -141,24 +141,46 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file, mem->size = (mem->size +SIS_MM_ALIGN_MASK ) >>SIS_MM_ALIGN_SHIFT ; item =drm_sman_alloc (&dev_priv->sman, pool, mem->size,0 ,0 ); +if (!item) { + retval = -ENOMEM ; + goto fail_alloc; + } -if (item) { -INIT_LIST_HEAD (&item->owner_list); -list_add (&item->owner_list, &file_priv->obj_list); - mem->offset = ((pool ==0 ) ? - dev_priv->vram_offset : dev_priv->agp_offset) + - (item->mm-> -offset (item->mm, item->mm_info) <<SIS_MM_ALIGN_SHIFT ); - mem->free = item->user_hash.key; - mem->size = mem->size <<SIS_MM_ALIGN_SHIFT ; - }else { - mem->offset =0 ; - mem->size =0 ; - mem->free =0 ; +again: +if (idr_pre_get (&dev_priv->object_idr,GFP_KERNEL ) ==0 ) { retval = -ENOMEM ; + goto fail_idr; } + +/* do the allocation under our spinlock */ + retval =idr_get_new_above (&dev_priv->object_idr, item,1 , &user_key); +if (retval == -EAGAIN ) + goto again; +if (retval) + goto fail_idr; + +INIT_LIST_HEAD (&item->owner_list); +list_add (&item->owner_list, &file_priv->obj_list); +mutex_unlock (&dev->struct_mutex); + + mem->offset = ((pool ==0 ) ? + dev_priv->vram_offset : dev_priv->agp_offset) + + (item->mm-> +offset (item->mm, item->mm_info) <<SIS_MM_ALIGN_SHIFT ); + mem->free = user_key; + mem->size = mem->size <<SIS_MM_ALIGN_SHIFT ; + +return 0 ; + +fail_idr: +drm_sman_free (item); +fail_alloc:mutex_unlock (&dev->struct_mutex); + mem->offset =0 ; + mem->size =0 ; + mem->free =0 ; +DRM_DEBUG ("alloc %d, size = %d, offset = %d\n" , pool, mem->size, mem->offset);@@ -169,10 +191,18 @@ static int sis_drm_free(struct drm_device *dev, void *data, struct drm_file *fil {drm_sis_private_t *dev_priv = dev->dev_private;drm_sis_mem_t *mem = data; +struct drm_memblock_item *obj;int ret;mutex_lock (&dev->struct_mutex); - ret =drm_sman_free_key (&dev_priv->sman, mem->free); + obj =idr_find (&dev_priv->object_idr, mem->free); +if (obj ==NULL ) { +mutex_unlock (&dev->struct_mutex); +return -EINVAL ; + } + +idr_remove (&dev_priv->object_idr, mem->free); +drm_sman_free (obj);mutex_unlock (&dev->struct_mutex);DRM_DEBUG ("free = 0x%lx\n" , mem->free);drivers/gpu/drm/via/via_map.c +2
-0@@ -126,6 +126,8 @@ int via_driver_unload(struct drm_device *dev)drm_via_private_t *dev_priv = dev->dev_private;drm_sman_takedown (&dev_priv->sman); +idr_remove_all (&dev_priv->object_idr); +idr_destroy (&dev_priv->object_idr);kfree (dev_priv);Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/23 drm/sman: kill user_hash_tab
In reply to Daniel VetterNo longer used.
--- drivers/gpu/drm/drm_sman.c | 36 ++---------------------------------- include/drm/drm_sman.h | 5 ----- 2 files changed, 2 insertions(+), 39 deletions(-)
drivers/gpu/drm/drm_sman.c +2 -34
@@ -46,7 +46,6 @@ struct drm_owner_item {void drm_sman_takedown (struct drm_sman * sman) { -drm_ht_remove (&sman->user_hash_tab);kfree (sman->mm); }
@@ -61,16 +60,11 @@ drm_sman_init(struct drm_sman * sman, unsigned int num_managers, sman->mm =kcalloc (num_managers,sizeof (*sman->mm),GFP_KERNEL );if (!sman->mm) { ret = -ENOMEM ; - goto out; +return ret; } sman->num_managers = num_managers; - ret =drm_ht_create (&sman->user_hash_tab, user_order); -if (!ret) - goto out; -kfree (sman->mm); -out: -return ret; +return 0 ; }EXPORT_SYMBOL (drm_sman_init);
@@ -179,15 +173,8 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man memblock->mm = sman_mm; memblock->sman = sman; -if (drm_ht_just_insert_please - (&sman->user_hash_tab, &memblock->user_hash, - (unsigned long )memblock,32 ,0 ,0 )) - goto out1; -return memblock; -out1: -kfree (memblock); out: sman_mm->free (sman_mm->private, tmp);
@@ -198,31 +185,12 @@ EXPORT_SYMBOL(drm_sman_alloc);void drm_sman_free (struct drm_memblock_item *item) { -struct drm_sman *sman = item->sman; -list_del (&item->owner_list); -drm_ht_remove_item (&sman->user_hash_tab, &item->user_hash); item->mm->free (item->mm->private, item->mm_info);kfree (item); }EXPORT_SYMBOL (drm_sman_free); -int drm_sman_free_key (struct drm_sman *sman,unsigned int key) -{ -struct drm_hash_item *hash_item; -struct drm_memblock_item *memblock_item; - -if (drm_ht_find_item (&sman->user_hash_tab, key, &hash_item)) -return -EINVAL ; - - memblock_item = drm_hash_entry(hash_item, struct drm_memblock_item, - user_hash); -drm_sman_free (memblock_item); -return 0 ; -} - -EXPORT_SYMBOL (drm_sman_free_key); -void drm_sman_cleanup (struct drm_sman *sman) {unsigned int i;
include/drm/drm_sman.h +0 -5
@@ -87,7 +87,6 @@ struct drm_memblock_item {struct drm_sman {struct drm_sman_mm *mm;int num_managers; -struct drm_open_hash user_hash_tab; };/*
@@ -139,11 +138,7 @@ extern struct drm_memblock_item *drm_sman_alloc(struct drm_sman * sman,unsigned long size, unsigned alignment, unsigned long owner); -/* -* Free a memory block identified by its user hash key. -*/ -extern int drm_sman_free_key (struct drm_sman * sman,unsigned int key);extern void drm_sman_free (struct drm_memblock_item *item);/*
Signature · 1 line
1.7.7.1
Re: [PATCH 07/23] drm/sman: kill user_hash_tab
Quoted 4 lines
No longer used.
Signed-off-by Daniel Vetter <[email protected]>
Quoted 116 lines
--- drivers/gpu/drm/drm_sman.c | 36 ++---------------------------------- include/drm/drm_sman.h | 5 ----- 2 files changed, 2 insertions(+), 39 deletions(-)drivers/gpu/drm/drm_sman.c +2
-34@@ -46,7 +46,6 @@ struct drm_owner_item {void drm_sman_takedown (struct drm_sman * sman) { -drm_ht_remove (&sman->user_hash_tab);kfree (sman->mm); }@@ -61,16 +60,11 @@ drm_sman_init(struct drm_sman * sman, unsigned int num_managers, sman->mm =kcalloc (num_managers,sizeof (*sman->mm),GFP_KERNEL );if (!sman->mm) { ret = -ENOMEM ; - goto out; +return ret; } sman->num_managers = num_managers; - ret =drm_ht_create (&sman->user_hash_tab, user_order); -if (!ret) - goto out; -kfree (sman->mm); -out: -return ret; +return 0 ; }EXPORT_SYMBOL (drm_sman_init);@@ -179,15 +173,8 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man memblock->mm = sman_mm; memblock->sman = sman; -if (drm_ht_just_insert_please - (&sman->user_hash_tab, &memblock->user_hash, - (unsigned long )memblock,32 ,0 ,0 )) - goto out1; -return memblock; -out1: -kfree (memblock); out: sman_mm->free (sman_mm->private, tmp);@@ -198,31 +185,12 @@ EXPORT_SYMBOL(drm_sman_alloc);void drm_sman_free (struct drm_memblock_item *item) { -struct drm_sman *sman = item->sman; -list_del (&item->owner_list); -drm_ht_remove_item (&sman->user_hash_tab, &item->user_hash); item->mm->free (item->mm->private, item->mm_info);kfree (item); }EXPORT_SYMBOL (drm_sman_free); -int drm_sman_free_key (struct drm_sman *sman,unsigned int key) -{ -struct drm_hash_item *hash_item; -struct drm_memblock_item *memblock_item; - -if (drm_ht_find_item (&sman->user_hash_tab, key, &hash_item)) -return -EINVAL ; - - memblock_item = drm_hash_entry(hash_item, struct drm_memblock_item, - user_hash); -drm_sman_free (memblock_item); -return 0 ; -} - -EXPORT_SYMBOL (drm_sman_free_key); -void drm_sman_cleanup (struct drm_sman *sman) {unsigned int i;include/drm/drm_sman.h +0
-5@@ -87,7 +87,6 @@ struct drm_memblock_item {struct drm_sman {struct drm_sman_mm *mm;int num_managers; -struct drm_open_hash user_hash_tab; };/* @@ -139,11 +138,7 @@ extern struct drm_memblock_item *drm_sman_alloc(struct drm_sman * sman,unsigned long size, unsigned alignment, unsigned long owner); -/* -* Free a memory block identified by its user hash key. -*/ -extern int drm_sman_free_key (struct drm_sman * sman,unsigned int key);extern void drm_sman_free (struct drm_memblock_item *item);/* Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/23 drm/via: use drm_mm instead of drm_sman
In reply to Daniel VetterNow that we are again in proper control of owner_list, we need to properly list_del it on free.
--- drivers/gpu/drm/via/via_drv.h | 5 ++- drivers/gpu/drm/via/via_map.c | 7 ---- drivers/gpu/drm/via/via_mm.c | 72 ++++++++++++++++++++++------------------ 3 files changed, 43 insertions(+), 41 deletions(-)
drivers/gpu/drm/via/via_drv.h +3 -2
@@ -24,7 +24,7 @@#ifndef _VIA_DRV_H_#define _VIA_DRV_H_ -#include "drm_sman.h" +#include "drm_mm.h" #define DRIVER_AUTHOR "Various"#define DRIVER_NAME "via"
@@ -88,9 +88,10 @@ typedef struct drm_via_private {uint32_t irq_pending_mask;int *irq_map;unsigned int idle_fault; -struct drm_sman sman;int vram_initialized; +struct drm_mm vram_mm;int agp_initialized; +struct drm_mm agp_mm;/** Mapping of userspace keys to mm objects */ struct idr object_idr;unsigned long vram_offset;
drivers/gpu/drm/via/via_map.c +0 -7
@@ -105,15 +105,9 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset) dev_priv->chipset = chipset;idr_init (&dev->object_name_idr); - ret =drm_sman_init (&dev_priv->sman,2 ,12 ,8 ); -if (ret) { -kfree (dev_priv); -return ret; - } ret =drm_vblank_init (dev,1 );if (ret) { -drm_sman_takedown (&dev_priv->sman);kfree (dev_priv);return ret; }
@@ -125,7 +119,6 @@ int via_driver_unload(struct drm_device *dev) {drm_via_private_t *dev_priv = dev->dev_private; -drm_sman_takedown (&dev_priv->sman);idr_remove_all (&dev_priv->object_idr);idr_destroy (&dev_priv->object_idr);
drivers/gpu/drm/via/via_mm.c +40 -32
155 lines not on this page · raw message
Signature · 1 line
1.7.7.1
Re: [PATCH 08/23] drm/via: use drm_mm instead of drm_sman
Quoted 4 lines · Daniel Vetter
Now that we are again in proper control of
owner_list, we need to properlylist_delit on free.Signed-off-by Daniel Vetter <[email protected]>
Chris Wilson rightly complained that this doesn't explain the list_del magic going on. New commit msg reads:
To make the transition in a piece-wise and bisectable way possible, I've hijacked the ->owner_list from drm_sman. While transitioning, the list_add was done by the driver, while the list_del was still done by the dying sman code.
Now that we are in full control of ->owner_list, do the list_del ourselves.
He also noted the superflous additions of INIT_LIST_HEAD and the stale comment about spinlock locking in the idr allocation (protected by dev->struct_mutex) that I've copied over. All fixed up and pushed out for the moment to my fdo repo:
http://cgit.freedesktop.org/~danvet/drm/log/?h=kill-with-fire
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Re: [PATCH 08/23] drm/via: use drm_mm instead of drm_sman
Quoted 12 lines
Chris Wilson rightly complained that this doesn't explain the
list_delmagic going on. New commit msg reads:To make the transition in a piece-wise and bisectable way possible, I've hijacked the ->owner_list from
drm_sman. While transitioning, thelist_addwas done by the driver, while thelist_delwas still done by the dying sman code.Now that we are in full control of ->owner_list, do the
list_delourselves.
Quoted 6 lines
He also noted the superflous additions of
INIT_LIST_HEADand the stale comment about spinlock locking in the idr allocation (protected bydev->struct_mutex) that I've copied over. All fixed up and pushed out for the moment to my fdo repo:http://cgit.freedesktop.org/~danvet/drm/log/?h=kill-with-fire
Speaking of I attempted to clone that repo but it gives me
warning: remote HEAD refers to nonexistent ref, unable to checkout.
Re: [PATCH 08/23] drm/via: use drm_mm instead of drm_sman
Quoted 17 lines · James Simmons
Quoted 17 lines
Chris Wilson rightly complained that this doesn't explain the
list_delmagic going on. New commit msg reads:To make the transition in a piece-wise and bisectable way possible, I've hijacked the ->owner_list from
drm_sman. While transitioning, thelist_addwas done by the driver, while thelist_delwas still done by the dying sman code.Now that we are in full control of ->owner_list, do the
list_delourselves.He also noted the superflous additions of
INIT_LIST_HEADand the stale comment about spinlock locking in the idr allocation (protected bydev->struct_mutex) that I've copied over. All fixed up and pushed out for the moment to my fdo repo:
Quoted 5 lines
Speaking of I attempted to clone that repo but it gives me
warning: remote HEAD refers to nonexistent ref, unable to checkout.
It's a headless git repo, so you have to check out a specific branch explicitly. Simplest way to do so is with
git fetch <repo> <branch>
in an exisiting lk git checkout which should grab that branch into FETCH_HEAD. Then you can check it out, merge it, ... -Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Re: [PATCH 08/23] drm/via: use drm_mm instead of drm_sman
In reply to Daniel VetterQuoted 5 lines
Now that we are again in proper control of
owner_list, we need to properlylist_delit on free.Signed-off-by Daniel Vetter <[email protected]>
Quoted 236 lines
--- drivers/gpu/drm/via/via_drv.h | 5 ++- drivers/gpu/drm/via/via_map.c | 7 ---- drivers/gpu/drm/via/via_mm.c | 72 ++++++++++++++++++++++------------------ 3 files changed, 43 insertions(+), 41 deletions(-)drivers/gpu/drm/via/via_drv.h +3
-2@@ -24,7 +24,7 @@#ifndef _VIA_DRV_H_#define _VIA_DRV_H_ -#include "drm_sman.h" +#include "drm_mm.h" #define DRIVER_AUTHOR "Various"#define DRIVER_NAME "via"@@ -88,9 +88,10 @@ typedef struct drm_via_private {uint32_t irq_pending_mask;int *irq_map;unsigned int idle_fault; -struct drm_sman sman;int vram_initialized; +struct drm_mm vram_mm;int agp_initialized; +struct drm_mm agp_mm;/** Mapping of userspace keys to mm objects */ struct idr object_idr;unsigned long vram_offset;drivers/gpu/drm/via/via_map.c +0
-7@@ -105,15 +105,9 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset) dev_priv->chipset = chipset;idr_init (&dev->object_name_idr); - ret =drm_sman_init (&dev_priv->sman,2 ,12 ,8 ); -if (ret) { -kfree (dev_priv); -return ret; - } ret =drm_vblank_init (dev,1 );if (ret) { -drm_sman_takedown (&dev_priv->sman);kfree (dev_priv);return ret; }@@ -125,7 +119,6 @@ int via_driver_unload(struct drm_device *dev) {drm_via_private_t *dev_priv = dev->dev_private; -drm_sman_takedown (&dev_priv->sman);idr_remove_all (&dev_priv->object_idr);idr_destroy (&dev_priv->object_idr);drivers/gpu/drm/via/via_mm.c +40
-32@@ -28,26 +28,22 @@#include "drmP.h" #include "via_drm.h" #include "via_drv.h" -#include "drm_sman.h" #define VIA_MM_ALIGN_SHIFT 4#define VIA_MM_ALIGN_MASK ((1 << VIA_MM_ALIGN_SHIFT) - 1) +struct via_memblock { +struct drm_mm_node mm_node; +struct list_head owner_list; +}; +int via_agp_init (struct drm_device *dev,void *data,struct drm_file *file_priv) {drm_via_agp_t *agp = data;drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; -int ret;mutex_lock (&dev->struct_mutex); - ret =drm_sman_set_range (&dev_priv->sman,VIA_MEM_AGP ,0 , - agp->size >>VIA_MM_ALIGN_SHIFT ); - -if (ret) { -DRM_ERROR ("AGP memory manager initialisation error\n" ); -mutex_unlock (&dev->struct_mutex); -return ret; - } +drm_mm_init (&dev_priv->agp_mm,0 , agp->size >>VIA_MM_ALIGN_SHIFT ); dev_priv->agp_initialized =1 ; dev_priv->agp_offset = agp->offset;@@ -61,17 +57,9 @@ int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv) {drm_via_fb_t *fb = data;drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; -int ret;mutex_lock (&dev->struct_mutex); - ret =drm_sman_set_range (&dev_priv->sman,VIA_MEM_VIDEO ,0 , - fb->size >>VIA_MM_ALIGN_SHIFT ); - -if (ret) { -DRM_ERROR ("VRAM memory manager initialisation error\n" ); -mutex_unlock (&dev->struct_mutex); -return ret; - } +drm_mm_init (&dev_priv->vram_mm,0 , fb->size >>VIA_MM_ALIGN_SHIFT ); dev_priv->vram_initialized =1 ; dev_priv->vram_offset = fb->offset;@@ -108,9 +96,14 @@ void via_lastclose(struct drm_device *dev)return ;mutex_lock (&dev->struct_mutex); -drm_sman_cleanup (&dev_priv->sman); - dev_priv->vram_initialized =0 ; - dev_priv->agp_initialized =0 ; +if (dev_priv->vram_initialized) { +drm_mm_takedown (&dev_priv->vram_mm); + dev_priv->vram_initialized =0 ; + } +if (dev_priv->agp_initialized) { +drm_mm_takedown (&dev_priv->agp_mm); + dev_priv->agp_initialized =0 ; + }mutex_unlock (&dev->struct_mutex); }@@ -119,7 +112,7 @@ int via_mem_alloc(struct drm_device *dev, void *data, {drm_via_mem_t *mem = data;int retval =0 , user_key; -struct drm_memblock_item *item; +struct via_memblock *item;drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;struct via_file_private *file_priv = file->driver_priv;unsigned long tmpSize;@@ -137,13 +130,24 @@ int via_mem_alloc(struct drm_device *dev, void *data,return -EINVAL ; } - tmpSize = (mem->size +VIA_MM_ALIGN_MASK ) >>VIA_MM_ALIGN_SHIFT ; - item =drm_sman_alloc (&dev_priv->sman, mem->type, tmpSize,0 ,0 ); + item =kzalloc (sizeof (*item),GFP_KERNEL );if (!item) { retval = -ENOMEM ; goto fail_alloc; } + tmpSize = (mem->size +VIA_MM_ALIGN_MASK ) >>VIA_MM_ALIGN_SHIFT ; +if (mem->type ==VIA_MEM_AGP ) + retval =drm_mm_insert_node (&dev_priv->agp_mm, + &item->mm_node, + tmpSize,0 ); +else + retval =drm_mm_insert_node (&dev_priv->vram_mm, + &item->mm_node, + tmpSize,0 ); +if (retval) + goto fail_alloc; + again:if (idr_pre_get (&dev_priv->object_idr,GFP_KERNEL ) ==0 ) { retval = -ENOMEM ;@@ -163,15 +167,15 @@ again: mem->offset = ((mem->type ==VIA_MEM_VIDEO ) ? dev_priv->vram_offset : dev_priv->agp_offset) + - (item->mm-> -offset (item->mm, item->mm_info) <<VIA_MM_ALIGN_SHIFT ); + ((item->mm_node.start) <<VIA_MM_ALIGN_SHIFT ); mem->index = user_key;return 0 ; fail_idr: -drm_sman_free (item); +drm_mm_remove_node (&item->mm_node); fail_alloc: +kfree (item);mutex_unlock (&dev->struct_mutex); mem->offset =0 ;@@ -186,7 +190,7 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv) {drm_via_private_t *dev_priv = dev->dev_private;drm_via_mem_t *mem = data; -struct drm_memblock_item *obj; +struct via_memblock *obj;int ret;mutex_lock (&dev->struct_mutex);@@ -197,7 +201,9 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv) }idr_remove (&dev_priv->object_idr, mem->index); -drm_sman_free (obj); +list_del (&obj->owner_list); +drm_mm_remove_node (&obj->mm_node); +kfree (obj);mutex_unlock (&dev->struct_mutex);DRM_DEBUG ("free = 0x%lx\n" , mem->index);@@ -210,7 +216,7 @@ void via_reclaim_buffers_locked(struct drm_device *dev, struct drm_file *file) {struct via_file_private *file_priv = file->driver_priv; -struct drm_memblock_item *entry, *next; +struct via_memblock *entry, *next;mutex_lock (&dev->struct_mutex);if (list_empty (&file_priv->obj_list)) {@@ -223,7 +229,9 @@ void via_reclaim_buffers_locked(struct drm_device *dev,list_for_each_entry_safe (entry, next, &file_priv->obj_list, owner_list) { -drm_sman_free (entry); +list_del (&entry->owner_list); +drm_mm_remove_node (&entry->mm_node); +kfree (entry); }mutex_unlock (&dev->struct_mutex);return ;Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 9/23 drm/sis: use drm_mm instead of drm_sman
In reply to Daniel Vetter--- drivers/gpu/drm/sis/sis_drv.c | 4 - drivers/gpu/drm/sis/sis_drv.h | 5 +- drivers/gpu/drm/sis/sis_mm.c | 137 +++++++++++++++++++--------------------- 3 files changed, 68 insertions(+), 78 deletions(-)
drivers/gpu/drm/sis/sis_drv.c +0 -4
@@ -47,9 +47,6 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset) dev->dev_private = (void *)dev_priv; dev_priv->chipset = chipset;idr_init (&dev->object_name_idr); - ret =drm_sman_init (&dev_priv->sman,2 ,12 ,8 ); -if (ret) -kfree (dev_priv);return ret; }
@@ -58,7 +55,6 @@ static int sis_driver_unload(struct drm_device *dev) {drm_sis_private_t *dev_priv = dev->dev_private; -drm_sman_takedown (&dev_priv->sman);idr_remove_all (&dev_priv->object_idr);idr_destroy (&dev_priv->object_idr);
drivers/gpu/drm/sis/sis_drv.h +3 -2
@@ -44,7 +44,7 @@ enum sis_family { SIS_CHIP_315 = 1, }; -#include "drm_sman.h" +#include "drm_mm.h" #define SIS_BASE (dev_priv->mmio)
@@ -54,12 +54,13 @@ enum sis_family {typedef struct drm_sis_private {drm_local_map_t *mmio;unsigned int idle_fault; -struct drm_sman sman;unsigned int chipset;int vram_initialized;int agp_initialized;unsigned long vram_offset;unsigned long agp_offset; +struct drm_mm vram_mm; +struct drm_mm agp_mm;/** Mapping of userspace keys to mm objects */ struct idr object_idr; }drm_sis_private_t ;
drivers/gpu/drm/sis/sis_mm.c +65 -72
227 lines not on this page · raw message
Signature · 1 line
1.7.7.1
Re: [PATCH 09/23] drm/sis: use drm_mm instead of drm_sman
On Thu, Oct 27, 2011 at 1:07 PM, Daniel Vetter <[email protected]> wrote:
...
Quoted 1 line
(quoted diff) +0
-0@@ -139,13 +99,35 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file,
...
Quoted 5 lines
+#if
defined(CONFIG_FB_SIS)||defined(CONFIG_FB_SIS_MODULE)
+item->req.size=mem->size;
+sis_malloc(&item->req);
+ if (item->req.size== 0)
+ retval =-ENOMEN;
ENOMEN is omen, I guess this was not compile tested with either CONFIG?
Cheers,
Tormod
PATCH 1/1 drm/sis: Fix building with CONFIG_FB_SIS/CONFIG_FB_SIS_MODULE
From: Tormod Volden <[email protected]>
---
On top of danvet's kill-with-fire ad83cc3.
Tormod
drivers/gpu/drm/sis/sis_mm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/sis/sis_mm.c +2 -2
@@ -116,7 +116,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file, item->req.size = mem->size;sis_malloc (&item->req);if (item->req.size ==0 ) - retval = -ENOMEN ; + retval = -ENOMEM ; offset = item->req.offset;#else retval = drm_mm_insert_node(&dev_priv->vram_mm,
@@ -343,7 +343,7 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,drm_mm_remove_node (&entry->mm_node);#if defined(CONFIG_FB_SIS ) || defined(CONFIG_FB_SIS_MODULE ) else - sis_free(entry->req->offset); + sis_free(entry->req.offset);#endif kfree (entry); }
Signature · 1 line
1.7.5.4
Re: [PATCH 09/23] drm/sis: use drm_mm instead of drm_sman
In reply to Tormod VoldenQuoted 11 lines · Tormod Volden
On Thu, Oct 27, 2011 at 1:07 PM, Daniel Vetter <[email protected]> wrote:
...Quoted 1 line
(quoted diff) +0
-0@@ -139,13 +99,35 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file,...
Quoted 5 lines
+#if
defined(CONFIG_FB_SIS)||defined(CONFIG_FB_SIS_MODULE)
+item->req.size=mem->size;
+sis_malloc(&item->req);
+ if (item->req.size== 0)
+ retval =-ENOMEN;ENOMEN is omen, I guess this was not compile tested with either CONFIG?
Oh gosh, this is embarassing ;-) I've indeed fumbled this and forgotten to check that config option. Smashed your patch on top of mine. btw, do you have some actual hw to test this on, or have you just checked out of curiosity?
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Re: [PATCH 09/23] drm/sis: use drm_mm instead of drm_sman
Quoted 11 lines · Daniel Vetter
Quoted 10 lines · Tormod Volden
On Thu, Oct 27, 2011 at 1:07 PM, Daniel Vetter <[email protected]> wrote:
...Quoted 1 line
(quoted diff) +0
-0@@ -139,13 +99,35 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file,...
Quoted 5 lines
+#if
defined(CONFIG_FB_SIS)||defined(CONFIG_FB_SIS_MODULE)
+item->req.size=mem->size;
+sis_malloc(&item->req);
+ if (item->req.size== 0)
+ retval =-ENOMEN;
Quoted 6 lines
Quoted 1 line
ENOMEN is omen, I guess this was not compile tested with either CONFIG?
Oh gosh, this is embarassing ;-) I've indeed fumbled this and forgotten to check that config option. Smashed your patch on top of mine. btw, do you have some actual hw to test this on, or have you just checked out of curiosity?
I do not have sis hardware, but I am testing this on savage and my config happened to have this option set.
By the way, is there anything in special I can try to (stress-)test this? I have tested Quake III demos and multiple parallel GL screensaver hacks. On the other hand, is there a possibility this might fix some random DMA crashes or lock-ups (I mean the savage locking fix here)?
Thanks,
Tormod
Quoted 6 lines
Thanks, Daniel
--
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
Re: [PATCH 09/23] drm/sis: use drm_mm instead of drm_sman
Quoted 19 lines · Tormod Volden
Quoted 11 lines · Daniel Vetter
Quoted 10 lines · Tormod Volden
On Thu, Oct 27, 2011 at 1:07 PM, Daniel Vetter <[email protected]> wrote:
...Quoted 1 line
(quoted diff) +0
-0@@ -139,13 +99,35 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file,...
Quoted 5 lines
+#if
defined(CONFIG_FB_SIS)||defined(CONFIG_FB_SIS_MODULE)
+item->req.size=mem->size;
+sis_malloc(&item->req);
+ if (item->req.size== 0)
+ retval =-ENOMEN;Quoted 6 lines
Quoted 1 line
ENOMEN is omen, I guess this was not compile tested with either CONFIG?
Oh gosh, this is embarassing ;-) I've indeed fumbled this and forgotten to check that config option. Smashed your patch on top of mine. btw, do you have some actual hw to test this on, or have you just checked out of curiosity?
Quoted 8 lines
I do not have sis hardware, but I am testing this on savage and my config happened to have this option set.
By the way, is there anything in special I can try to (stress-)test this? I have tested Quake III demos and multiple parallel GL screensaver hacks. On the other hand, is there a possibility this might fix some random DMA crashes or lock-ups (I mean the savage locking fix here)?
Well, it only changes the exit path, i.e. the changed code only gets executed when you close a direct rendering client. So if you can restart openaren (and the Xserver sometimes, too) that would test this code decently. The locking is imo pretty borked, so don't expect miracles. Also, I don't change anything of the hw programming, so this won't help for gpu lockups and similar stuff.
If it works for you, Tested-by for the savage patch highly appreciated.
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Re: [PATCH 09/23] drm/sis: use drm_mm instead of drm_sman
In reply to Daniel VetterQuoted 2 lines
Signed-off-by Daniel Vetter <[email protected]>
Can't test on SiS but does nothing to my VIA hardware.
Quoted 306 lines
--- drivers/gpu/drm/sis/sis_drv.c | 4 - drivers/gpu/drm/sis/sis_drv.h | 5 +- drivers/gpu/drm/sis/sis_mm.c | 137 +++++++++++++++++++--------------------- 3 files changed, 68 insertions(+), 78 deletions(-)drivers/gpu/drm/sis/sis_drv.c +0
-4@@ -47,9 +47,6 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset) dev->dev_private = (void *)dev_priv; dev_priv->chipset = chipset;idr_init (&dev->object_name_idr); - ret =drm_sman_init (&dev_priv->sman,2 ,12 ,8 ); -if (ret) -kfree (dev_priv);return ret; }@@ -58,7 +55,6 @@ static int sis_driver_unload(struct drm_device *dev) {drm_sis_private_t *dev_priv = dev->dev_private; -drm_sman_takedown (&dev_priv->sman);idr_remove_all (&dev_priv->object_idr);idr_destroy (&dev_priv->object_idr);drivers/gpu/drm/sis/sis_drv.h +3
-2@@ -44,7 +44,7 @@ enum sis_family { SIS_CHIP_315 = 1, }; -#include "drm_sman.h" +#include "drm_mm.h" #define SIS_BASE (dev_priv->mmio)@@ -54,12 +54,13 @@ enum sis_family {typedef struct drm_sis_private {drm_local_map_t *mmio;unsigned int idle_fault; -struct drm_sman sman;unsigned int chipset;int vram_initialized;int agp_initialized;unsigned long vram_offset;unsigned long agp_offset; +struct drm_mm vram_mm; +struct drm_mm agp_mm;/** Mapping of userspace keys to mm objects */ struct idr object_idr; }drm_sis_private_t ;drivers/gpu/drm/sis/sis_mm.c +65
-72@@ -41,40 +41,18 @@#define AGP_TYPE 1 +struct sis_memblock { +struct drm_mm_node mm_node; +struct sis_memreq req; +struct list_head owner_list; +}; +#if defined(CONFIG_FB_SIS ) || defined(CONFIG_FB_SIS_MODULE )/* fb management via fb device */ #define SIS_MM_ALIGN_SHIFT 0#define SIS_MM_ALIGN_MASK 0 -static void *sis_sman_mm_allocate (void *private,unsigned long size, -unsigned alignment) -{ -struct sis_memreq req; - - req.size = size; -sis_malloc (&req); -if (req.size ==0 ) -return NULL ; -else -return (void *)(unsigned long )~req.offset; -} - -static void sis_sman_mm_free (void *private,void *ref) -{ -sis_free (~((unsigned long )ref)); -} - -static void sis_sman_mm_destroy (void *private) -{ - ; -} - -static unsigned long sis_sman_mm_offset (void *private,void *ref) -{ -return ~((unsigned long )ref); -} -#else /* CONFIG_FB_SIS[_MODULE] */ #define SIS_MM_ALIGN_SHIFT 4@@ -86,30 +64,11 @@ static int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file {drm_sis_private_t *dev_priv = dev->dev_private;drm_sis_fb_t *fb = data; -int ret;mutex_lock (&dev->struct_mutex); -#if defined(CONFIG_FB_SIS ) || defined(CONFIG_FB_SIS_MODULE ) - { -struct drm_sman_mm sman_mm; - sman_mm.private = (void *)0xFFFFFFFF ; - sman_mm.allocate = sis_sman_mm_allocate; - sman_mm.free = sis_sman_mm_free; - sman_mm.destroy = sis_sman_mm_destroy; - sman_mm.offset = sis_sman_mm_offset; - ret = -drm_sman_set_manager (&dev_priv->sman,VIDEO_TYPE , &sman_mm); - } -#else - ret =drm_sman_set_range (&dev_priv->sman,VIDEO_TYPE ,0 , - fb->size >>SIS_MM_ALIGN_SHIFT ); -#endif - -if (ret) { -DRM_ERROR ("VRAM memory manager initialisation error\n" ); -mutex_unlock (&dev->struct_mutex); -return ret; - } +/* Unconditionally init the drm_mm, even though we don't use it when the +* fb sis driver is available - make cleanup easier. */ +drm_mm_init (&dev_priv->vram_mm,0 , fb->size >>SIS_MM_ALIGN_SHIFT ); dev_priv->vram_initialized =1 ; dev_priv->vram_offset = fb->offset;@@ -126,8 +85,9 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file,drm_sis_private_t *dev_priv = dev->dev_private;drm_sis_mem_t *mem = data;int retval =0 , user_key; -struct drm_memblock_item *item; +struct sis_memblock *item;struct sis_file_private *file_priv = file->driver_priv; +unsigned long offset;mutex_lock (&dev->struct_mutex);@@ -139,13 +99,35 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file,return -EINVAL ; } - mem->size = (mem->size +SIS_MM_ALIGN_MASK ) >>SIS_MM_ALIGN_SHIFT ; - item =drm_sman_alloc (&dev_priv->sman, pool, mem->size,0 ,0 ); + item =kzalloc (sizeof (*item),GFP_KERNEL );if (!item) { retval = -ENOMEM ; goto fail_alloc; } + mem->size = (mem->size +SIS_MM_ALIGN_MASK ) >>SIS_MM_ALIGN_SHIFT ; +if (pool ==AGP_TYPE ) { + retval =drm_mm_insert_node (&dev_priv->agp_mm, + &item->mm_node, + mem->size,0 ); + offset = item->mm_node.start; + }else { +#if defined(CONFIG_FB_SIS ) || defined(CONFIG_FB_SIS_MODULE ) + item->req.size = mem->size; +sis_malloc (&item->req); +if (item->req.size ==0 ) + retval = -ENOMEN ; + offset = item->req.offset; +#else + retval =drm_mm_insert_node (&dev_priv->vram_mm, + &item->mm_node, + mem->size,0 ); + offset = item->mm_node.start; +#endif + } +if (retval) + goto fail_alloc; + again:if (idr_pre_get (&dev_priv->object_idr,GFP_KERNEL ) ==0 ) { retval = -ENOMEM ;@@ -165,16 +147,16 @@ again: mem->offset = ((pool ==0 ) ? dev_priv->vram_offset : dev_priv->agp_offset) + - (item->mm-> -offset (item->mm, item->mm_info) <<SIS_MM_ALIGN_SHIFT ); + (offset <<SIS_MM_ALIGN_SHIFT ); mem->free = user_key; mem->size = mem->size <<SIS_MM_ALIGN_SHIFT ;return 0 ; fail_idr: -drm_sman_free (item); +drm_mm_remove_node (&item->mm_node); fail_alloc: +kfree (item);mutex_unlock (&dev->struct_mutex); mem->offset =0 ;@@ -191,7 +173,7 @@ static int sis_drm_free(struct drm_device *dev, void *data, struct drm_file *fil {drm_sis_private_t *dev_priv = dev->dev_private;drm_sis_mem_t *mem = data; -struct drm_memblock_item *obj; +struct sis_memblock *obj;int ret;mutex_lock (&dev->struct_mutex);@@ -202,7 +184,14 @@ static int sis_drm_free(struct drm_device *dev, void *data, struct drm_file *fil }idr_remove (&dev_priv->object_idr, mem->free); -drm_sman_free (obj); +list_del (&obj->owner_list); +if (drm_mm_node_allocated (&obj->mm_node)) +drm_mm_remove_node (&obj->mm_node); +#if defined(CONFIG_FB_SIS ) || defined(CONFIG_FB_SIS_MODULE ) + else + sis_free(obj->req.offset); +#endif +kfree (obj);mutex_unlock (&dev->struct_mutex);DRM_DEBUG ("free = 0x%lx\n" , mem->free);@@ -220,18 +209,10 @@ static int sis_ioctl_agp_init(struct drm_device *dev, void *data, {drm_sis_private_t *dev_priv = dev->dev_private;drm_sis_agp_t *agp = data; -int ret; dev_priv = dev->dev_private;mutex_lock (&dev->struct_mutex); - ret =drm_sman_set_range (&dev_priv->sman,AGP_TYPE ,0 , - agp->size >>SIS_MM_ALIGN_SHIFT ); - -if (ret) { -DRM_ERROR ("AGP memory manager initialisation error\n" ); -mutex_unlock (&dev->struct_mutex); -return ret; - } +drm_mm_init (&dev_priv->agp_mm,0 , agp->size >>SIS_MM_ALIGN_SHIFT ); dev_priv->agp_initialized =1 ; dev_priv->agp_offset = agp->offset;@@ -325,9 +306,14 @@ void sis_lastclose(struct drm_device *dev)return ;mutex_lock (&dev->struct_mutex); -drm_sman_cleanup (&dev_priv->sman); - dev_priv->vram_initialized =0 ; - dev_priv->agp_initialized =0 ; +if (dev_priv->vram_initialized) { +drm_mm_takedown (&dev_priv->vram_mm); + dev_priv->vram_initialized =0 ; + } +if (dev_priv->agp_initialized) { +drm_mm_takedown (&dev_priv->agp_mm); + dev_priv->agp_initialized =0 ; + } dev_priv->mmio =NULL ;mutex_unlock (&dev->struct_mutex); }@@ -336,7 +322,7 @@ void sis_reclaim_buffers_locked(struct drm_device *dev, struct drm_file *file) {struct sis_file_private *file_priv = file->driver_priv; -struct drm_memblock_item *entry, *next; +struct sis_memblock *entry, *next;mutex_lock (&dev->struct_mutex);if (list_empty (&file_priv->obj_list)) {@@ -350,7 +336,14 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,list_for_each_entry_safe (entry, next, &file_priv->obj_list, owner_list) { -drm_sman_free (entry); +list_del (&entry->owner_list); +if (drm_mm_node_allocated (&entry->mm_node)) +drm_mm_remove_node (&entry->mm_node); +#if defined(CONFIG_FB_SIS ) || defined(CONFIG_FB_SIS_MODULE ) + else + sis_free(entry->req->offset); +#endif +kfree (entry); }mutex_unlock (&dev->struct_mutex);return ;Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 10/23 drm: kill drm_sman
In reply to Daniel VetterNo longer used.
--- drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_sman.c | 210 -------------------------------------------- include/drm/drm_sman.h | 151 ------------------------------- 3 files changed, 1 insertions(+), 362 deletions(-) delete mode 100644 drivers/gpu/drm/drm_sman.c delete mode 100644 include/drm/drm_sman.h
drivers/gpu/drm/Makefile +1 -1
@@ -9,7 +9,7 @@ drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \ drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \ drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \ - drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \ + drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \ drm_crtc.o drm_modes.o drm_edid.o \ drm_info.o drm_debugfs.o drm_encoder_slave.o \ drm_trace_points.o drm_global.o drm_usb.o
drivers/gpu/drm/drm_sman.c deleted +0 -210
210 lines not on this page · raw message
include/drm/drm_sman.h deleted +0 -151
151 lines not on this page · raw message
Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 10/23] drm: kill drm_sman
Quoted 4 lines
No longer used.
Signed-off-by Daniel Vetter <[email protected]>
Quoted 402 lines
--- drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_sman.c | 210 -------------------------------------------- include/drm/drm_sman.h | 151 ------------------------------- 3 files changed, 1 insertions(+), 362 deletions(-) delete mode 100644 drivers/gpu/drm/drm_sman.c delete mode 100644 include/drm/drm_sman.hdrivers/gpu/drm/Makefile +1
-1@@ -9,7 +9,7 @@ drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \ drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \ drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \ - drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \ + drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \ drm_crtc.o drm_modes.o drm_edid.o \ drm_info.o drm_debugfs.o drm_encoder_slave.o \ drm_trace_points.o drm_global.o drm_usb.odrivers/gpu/drm/drm_sman.c deleted +0
-210@@ -1,210 +0,0 @@ -/************************************************************************** -* -* Copyright 2006 Tungsten Graphics, Inc., Bismarck., ND., USA. -* All Rights Reserved. -* -* 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. -* -* The above copyright notice and this permission notice (including the -* next paragraph) shall be included in all copies or substantial portions -* of the Software. -* -* -**************************************************************************/ -/* -* Simple memory manager interface that keeps track on allocate regions on a -* per "owner" basis. All regions associated with an "owner" can be released -* with a simple call. Typically if the "owner" exists. The owner is any -* "unsigned long" identifier. Can typically be a pointer to a file private -* struct or a context identifier. -* -* Authors: -* Thomas Hellström <thomas-at-tungstengraphics-dot-com> -*/ - -#include "drm_sman.h" - -struct drm_owner_item { -struct drm_hash_item owner_hash; -struct list_head sman_list; -struct list_head mem_blocks; -}; - -void drm_sman_takedown (struct drm_sman * sman) -{ -kfree (sman->mm); -} - -EXPORT_SYMBOL (drm_sman_takedown); - -int -drm_sman_init (struct drm_sman * sman,unsigned int num_managers, -unsigned int user_order,unsigned int owner_order) -{ -int ret =0 ; - - sman->mm =kcalloc (num_managers,sizeof (*sman->mm),GFP_KERNEL ); -if (!sman->mm) { - ret = -ENOMEM ; -return ret; - } - sman->num_managers = num_managers; - -return 0 ; -} - -EXPORT_SYMBOL (drm_sman_init); - -static void *drm_sman_mm_allocate (void *private,unsigned long size, -unsigned alignment) -{ -struct drm_mm *mm = (struct drm_mm *) private; -struct drm_mm_node *tmp; - - tmp =drm_mm_search_free (mm, size, alignment,1 ); -if (!tmp) { -return NULL ; - } - tmp =drm_mm_get_block (tmp, size, alignment); -return tmp; -} - -static void drm_sman_mm_free (void *private,void *ref) -{ -struct drm_mm_node *node = (struct drm_mm_node *) ref; - -drm_mm_put_block (node); -} - -static void drm_sman_mm_destroy (void *private) -{ -struct drm_mm *mm = (struct drm_mm *) private; -drm_mm_takedown (mm); -kfree (mm); -} - -static unsigned long drm_sman_mm_offset (void *private,void *ref) -{ -struct drm_mm_node *node = (struct drm_mm_node *) ref; -return node->start; -} - -int -drm_sman_set_range (struct drm_sman * sman,unsigned int manager, -unsigned long start,unsigned long size) -{ -struct drm_sman_mm *sman_mm; -struct drm_mm *mm; -int ret; - -BUG_ON (manager >= sman->num_managers); - - sman_mm = &sman->mm[manager]; - mm =kzalloc (sizeof (*mm),GFP_KERNEL ); -if (!mm) { -return -ENOMEM ; - } - sman_mm->private = mm; - ret =drm_mm_init (mm, start, size); - -if (ret) { -kfree (mm); -return ret; - } - - sman_mm->allocate = drm_sman_mm_allocate; - sman_mm->free = drm_sman_mm_free; - sman_mm->destroy = drm_sman_mm_destroy; - sman_mm->offset = drm_sman_mm_offset; - -return 0 ; -} - -EXPORT_SYMBOL (drm_sman_set_range); - -int -drm_sman_set_manager (struct drm_sman * sman,unsigned int manager, -struct drm_sman_mm * allocator) -{ -BUG_ON (manager >= sman->num_managers); - sman->mm[manager] = *allocator; - -return 0 ; -} -EXPORT_SYMBOL (drm_sman_set_manager); - -struct drm_memblock_item *drm_sman_alloc (struct drm_sman *sman,unsigned int manager, -unsigned long size,unsigned alignment, -unsigned long owner) -{ -void *tmp; -struct drm_sman_mm *sman_mm; -struct drm_memblock_item *memblock; - -BUG_ON (manager >= sman->num_managers); - - sman_mm = &sman->mm[manager]; - tmp = sman_mm->allocate (sman_mm->private, size, alignment); - -if (!tmp) { -return NULL ; - } - - memblock =kzalloc (sizeof (*memblock),GFP_KERNEL ); - -if (!memblock) - goto out; - - memblock->mm_info = tmp; - memblock->mm = sman_mm; - memblock->sman = sman; - -return memblock; - -out: - sman_mm->free (sman_mm->private, tmp); - -return NULL ; -} - -EXPORT_SYMBOL (drm_sman_alloc); - -void drm_sman_free (struct drm_memblock_item *item) -{ -list_del (&item->owner_list); - item->mm->free (item->mm->private, item->mm_info); -kfree (item); -} -EXPORT_SYMBOL (drm_sman_free); - -void drm_sman_cleanup (struct drm_sman *sman) -{ -unsigned int i; -struct drm_sman_mm *sman_mm; - -if (sman->mm) { -for (i =0 ; i < sman->num_managers; ++i) { - sman_mm = &sman->mm[i]; -if (sman_mm->private) { - sman_mm->destroy (sman_mm->private); - sman_mm->private =NULL ; - } - } - } -} - -EXPORT_SYMBOL (drm_sman_cleanup);include/drm/drm_sman.h deleted +0
-151@@ -1,151 +0,0 @@ -/************************************************************************** -* -* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA. -* All Rights Reserved. -* -* 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, sub license, 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 (including the -* next paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. -* -* -**************************************************************************/ -/* -* Simple memory MANager interface that keeps track on allocate regions on a -* per "owner" basis. All regions associated with an "owner" can be released -* with a simple call. Typically if the "owner" exists. The owner is any -* "unsigned long" identifier. Can typically be a pointer to a file private -* struct or a context identifier. -* -* Authors: -* Thomas Hellström <thomas-at-tungstengraphics-dot-com> -*/ - -#ifndef DRM_SMAN_H -#define DRM_SMAN_H - -#include "drmP.h" -#include "drm_hashtab.h" - -/* -* A class that is an abstration of a simple memory allocator. -* The sman implementation provides a default such allocator -* using the drm_mm.c implementation. But the user can replace it. -* See the SiS implementation, which may use the SiS FB kernel module -* for memory management. -*/ - -struct drm_sman_mm { -/* private info. If allocated, needs to be destroyed by the destroy -function */ -void *private; - -/* Allocate a memory block with given size and alignment. -Return an opaque reference to the memory block */ - -void *(*allocate) (void *private,unsigned long size, -unsigned alignment); - -/* Free a memory block. "ref" is the opaque reference that we got from -the "alloc" function */ - -void (*free) (void *private,void *ref); - -/* Free all resources associated with this allocator */ - -void (*destroy) (void *private); - -/* Return a memory offset from the opaque reference returned from the -"alloc" function */ - -unsigned long (*offset) (void *private,void *ref); -}; - -struct drm_memblock_item { -struct list_head owner_list; -struct drm_hash_item user_hash; -void *mm_info; -struct drm_sman_mm *mm; -struct drm_sman *sman; -}; - -struct drm_sman { -struct drm_sman_mm *mm; -int num_managers; -}; - -/* -* Take down a memory manager. This function should only be called after a -* successful init and after a call to drm_sman_cleanup. -*/ - -extern void drm_sman_takedown (struct drm_sman * sman); - -/* -* Allocate structures for a manager. -* num_managers are the number of memory pools to manage. (VRAM, AGP, ....) -* user_order is the log2 of the number of buckets in the user hash table. -* set this to approximately log2 of the max number of memory regions -* that will be allocated for _all_ pools together. -* owner_order is the log2 of the number of buckets in the owner hash table. -* set this to approximately log2 of -* the number of client file connections that will -* be using the manager. -* -*/ - -extern int drm_sman_init (struct drm_sman * sman,unsigned int num_managers, -unsigned int user_order,unsigned int owner_order); - -/* -* Initialize a drm_mm.c allocator. Should be called only once for each -* manager unless a customized allogator is used. -*/ - -extern int drm_sman_set_range (struct drm_sman * sman,unsigned int manager, -unsigned long start,unsigned long size); - -/* -* Initialize a customized allocator for one of the managers. -* (See the SiS module). The object pointed to by "allocator" is copied, -* so it can be destroyed after this call. -*/ - -extern int drm_sman_set_manager (struct drm_sman * sman,unsigned int mananger, -struct drm_sman_mm * allocator); - -/* -* Allocate a memory block. Aligment is not implemented yet. -*/ - -extern struct drm_memblock_item *drm_sman_alloc (struct drm_sman * sman, -unsigned int manager, -unsigned long size, -unsigned alignment, -unsigned long owner); - -extern void drm_sman_free (struct drm_memblock_item *item); - -/* -* Frees all stale memory blocks associated with the memory manager. -* See idling above. -*/ - -extern void drm_sman_cleanup (struct drm_sman * sman); - -#endif Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 11/23 drm/via: clean up reclaim_buffers
In reply to Daniel VetterA few things
- kill reclaim_buffers, it's never ever called because via does not set DRIVER_HAVE_DMA
- inline the idlelock dance into the buffer reclaim logic and make it a simple preclose cleanup function
- directly call the the dma_quiescent function and kill the needless if check.
Export the idlelock drm functions so that drivers can call them.
--- drivers/gpu/drm/drm_lock.c | 2 ++ drivers/gpu/drm/via/via_drv.c | 4 +--- drivers/gpu/drm/via/via_mm.c | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_lock.c +2 -0
@@ -345,6 +345,7 @@ void drm_idlelock_take(struct drm_lock_data *lock_data) }spin_unlock_bh (&lock_data->spinlock); } +EXPORT_SYMBOL (drm_idlelock_take);void drm_idlelock_release (struct drm_lock_data *lock_data) {
@@ -364,6 +365,7 @@ void drm_idlelock_release(struct drm_lock_data *lock_data) }spin_unlock_bh (&lock_data->spinlock); } +EXPORT_SYMBOL (drm_idlelock_release);int drm_i_have_hw_lock (struct drm_device *dev,struct drm_file *file_priv) {
drivers/gpu/drm/via/via_drv.c +1 -3
@@ -62,6 +62,7 @@ static struct drm_driver driver = { .load = via_driver_load, .unload = via_driver_unload, .open = via_driver_open, + .preclose = via_reclaim_buffers_locked, .postclose = via_driver_postclose, .context_dtor = via_final_context, .get_vblank_counter = via_get_vblank_counter,
@@ -72,9 +73,6 @@ static struct drm_driver driver = { .irq_uninstall = via_driver_irq_uninstall, .irq_handler = via_driver_irq_handler, .dma_quiescent = via_driver_dma_quiescent, - .reclaim_buffers = drm_core_reclaim_buffers, - .reclaim_buffers_locked = NULL, - .reclaim_buffers_idlelocked = via_reclaim_buffers_locked, .lastclose = via_lastclose, .ioctls = via_ioctls, .fops = {
drivers/gpu/drm/via/via_mm.c +9 -2
@@ -217,6 +217,10 @@ void via_reclaim_buffers_locked(struct drm_device *dev, {struct via_file_private *file_priv = file->driver_priv;struct via_memblock *entry, *next; +int release_idlelock =0 ; + +if (file->master && file->master->lock.hw_lock) +drm_idlelock_take (&file->master->lock);mutex_lock (&dev->struct_mutex);if (list_empty (&file_priv->obj_list)) {
@@ -224,8 +228,7 @@ void via_reclaim_buffers_locked(struct drm_device *dev,return ; } -if (dev->driver->dma_quiescent) - dev->driver->dma_quiescent (dev); +via_driver_dma_quiescent (dev);list_for_each_entry_safe (entry, next, &file_priv->obj_list, owner_list) {
@@ -234,5 +237,9 @@ void via_reclaim_buffers_locked(struct drm_device *dev,kfree (entry); }mutex_unlock (&dev->struct_mutex); + +if (release_idlelock) +drm_idlelock_release (&file->master->lock); +return ; }
Signature · 1 line
1.7.7.1
Re: [PATCH 11/23] drm/via: clean up reclaim_buffers
Quoted 31 lines
A few things
- killreclaim_buffers, it's never ever called because via does not setDRIVER_HAVE_DMA
- inline the idlelock dance into the buffer reclaim logic and make it a simple preclose cleanup function
- directly call the thedma_quiescentfunction and kill the needless if check.Export the idlelock drm functions so that drivers can call them.
Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_lock.c | 2 ++ drivers/gpu/drm/via/via_drv.c | 4 +--- drivers/gpu/drm/via/via_mm.c | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_lock.c +1
-0@@ -345,6 +345,7 @@ void drm_idlelock_take(struct drm_lock_data *lock_data) }spin_unlock_bh (&lock_data->spinlock); } +EXPORT_SYMBOL (drm_idlelock_take);void drm_idlelock_release (struct drm_lock_data *lock_data) {
drivers/gpu/drm/drm_lock.c void drm_idlelock_release(struct drm_lock_data *lock_data) · line 371
Quoted 7 lines
drivers/gpu/drm/drm_lock.c +1
-0@@ -364,6 +365,7 @@ void drm_idlelock_release(struct drm_lock_data *lock_data) }spin_unlock_bh (&lock_data->spinlock); } +EXPORT_SYMBOL (drm_idlelock_release);int drm_i_have_hw_lock (struct drm_device *dev,struct drm_file *file_priv) {
Need the following for modules to work.
#include <linux/export.h>
Quoted 48 lines
drivers/gpu/drm/via/via_drv.c +1
-3@@ -62,6 +62,7 @@ static struct drm_driver driver = { .load = via_driver_load, .unload = via_driver_unload, .open = via_driver_open, + .preclose = via_reclaim_buffers_locked, .postclose = via_driver_postclose, .context_dtor = via_final_context, .get_vblank_counter = via_get_vblank_counter,@@ -72,9 +73,6 @@ static struct drm_driver driver = { .irq_uninstall = via_driver_irq_uninstall, .irq_handler = via_driver_irq_handler, .dma_quiescent = via_driver_dma_quiescent, - .reclaim_buffers = drm_core_reclaim_buffers, - .reclaim_buffers_locked = NULL, - .reclaim_buffers_idlelocked = via_reclaim_buffers_locked, .lastclose = via_lastclose, .ioctls = via_ioctls, .fops = {drivers/gpu/drm/via/via_mm.c +5
-2@@ -217,6 +217,10 @@ void via_reclaim_buffers_locked(struct drm_device *dev, {struct via_file_private *file_priv = file->driver_priv;struct via_memblock *entry, *next; +int release_idlelock =0 ; + +if (file->master && file->master->lock.hw_lock) +drm_idlelock_take (&file->master->lock);mutex_lock (&dev->struct_mutex);if (list_empty (&file_priv->obj_list)) {@@ -224,8 +228,7 @@ void via_reclaim_buffers_locked(struct drm_device *dev,return ; } -if (dev->driver->dma_quiescent) - dev->driver->dma_quiescent (dev); +via_driver_dma_quiescent (dev);list_for_each_entry_safe (entry, next, &file_priv->obj_list, owner_list) {
drivers/gpu/drm/via/via_mm.c void via_reclaim_buffers_locked(struct drm_device *dev, · line 243
Quoted 7 lines
drivers/gpu/drm/via/via_mm.c +4
-0@@ -234,5 +237,9 @@ void via_reclaim_buffers_locked(struct drm_device *dev,kfree (entry); }mutex_unlock (&dev->struct_mutex); + +if (release_idlelock) +drm_idlelock_release (&file->master->lock); +
When does release_idlelock get set?
Quoted 10 lines
drivers/gpu/drm/via/via_mm.c +0
-0return ; }Signature · 6 lines
1.7.7.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 12/23 drm/sis: clean up reclaim_buffers
In reply to Daniel VetterLike for via.
--- drivers/gpu/drm/sis/sis_drv.c | 3 +-- drivers/gpu/drm/sis/sis_mm.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/sis/sis_drv.c +1 -2
@@ -91,10 +91,9 @@ static struct drm_driver driver = { .load = sis_driver_load, .unload = sis_driver_unload, .open = sis_driver_open, + .preclose = sis_reclaim_buffers_locked, .postclose = sis_driver_postclose, .dma_quiescent = sis_idle, - .reclaim_buffers = NULL, - .reclaim_buffers_idlelocked = sis_reclaim_buffers_locked, .lastclose = sis_lastclose, .ioctls = sis_ioctls, .fops = {
drivers/gpu/drm/sis/sis_mm.c +10 -2
@@ -324,14 +324,18 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,struct sis_file_private *file_priv = file->driver_priv;struct sis_memblock *entry, *next; +int release_idlelock =0 ; + +if (file->master && file->master->lock.hw_lock) +drm_idlelock_take (&file->master->lock); +mutex_lock (&dev->struct_mutex);if (list_empty (&file_priv->obj_list)) {mutex_unlock (&dev->struct_mutex);return ; } -if (dev->driver->dma_quiescent) - dev->driver->dma_quiescent (dev); +sis_idle (dev); list_for_each_entry_safe(entry, next, &file_priv->obj_list,
@@ -346,6 +350,10 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,kfree (entry); }mutex_unlock (&dev->struct_mutex); + +if (release_idlelock) +drm_idlelock_release (&file->master->lock); +return ; }
Signature · 1 line
1.7.7.1
PATCH 13/23 drm: kill reclaim_buffers_idlelocked functions
In reply to Daniel VetterThe only two users are now folded into the drivers preclose functions, so this is unused.
--- drivers/gpu/drm/drm_fops.c | 8 -------- include/drm/drmP.h | 2 -- 2 files changed, 0 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_fops.c +0 -8
@@ -407,14 +407,6 @@ static void drm_master_release(struct drm_device *dev, struct file *filp) file_priv->master->lock.hw_lock)drm_reclaim_locked_buffers (dev, filp); -if (dev->driver->reclaim_buffers_idlelocked && - file_priv->master->lock.hw_lock) { -drm_idlelock_take (&file_priv->master->lock); - dev->driver->reclaim_buffers_idlelocked (dev, file_priv); -drm_idlelock_release (&file_priv->master->lock); - } - -if (drm_i_have_hw_lock (dev, file_priv)) {DRM_DEBUG ("File %p released, freeing lock for context %d\n" , filp,_DRM_LOCKING_CONTEXT (file_priv->master->lock.hw_lock->lock));
include/drm/drmP.h +0 -2
@@ -857,8 +857,6 @@ struct drm_driver { struct drm_file * file_priv);void (*reclaim_buffers_locked) (struct drm_device *dev,struct drm_file *file_priv); -void (*reclaim_buffers_idlelocked) (struct drm_device *dev, -struct drm_file *file_priv);void (*set_version) (struct drm_device *dev,struct drm_set_version *sv);
Signature · 1 line
1.7.7.1
PATCH 14/23 drm/i810: cleanup reclaim_buffers
In reply to Daniel VetterMy dear old i815 always hits the deadlocked on reclaim_buffers warning. Switch over to the idlelock duct-tape on hope that works better. I've fired up my i815 and now closing glxgears doesn't take 5 seconds anymore. \o/
--- drivers/gpu/drm/i810/i810_dma.c | 17 +++++++++++------ drivers/gpu/drm/i810/i810_drv.c | 1 - drivers/gpu/drm/i810/i810_drv.h | 6 ++---- 3 files changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/i810/i810_dma.c +11 -6
@@ -888,7 +888,7 @@ static int i810_flush_queue(struct drm_device *dev) }/* Must be called with the lock held */ -static void i810_reclaim_buffers (struct drm_device *dev, +void i810_driver_reclaim_buffers (struct drm_device *dev,struct drm_file *file_priv) {struct drm_device_dma *dma = dev->dma;
@@ -1225,12 +1225,17 @@ void i810_driver_preclose(struct drm_device *dev, struct drm_file *file_priv)if (dev_priv->page_flipping)i810_do_cleanup_pageflip (dev); } -} -void i810_driver_reclaim_buffers_locked (struct drm_device *dev, -struct drm_file *file_priv) -{ -i810_reclaim_buffers (dev, file_priv); +if (file_priv->master && file_priv->master->lock.hw_lock) { +drm_idlelock_take (&file_priv->master->lock); +i810_driver_reclaim_buffers (dev, file_priv); +drm_idlelock_release (&file_priv->master->lock); + }else { +/* master disappeared, clean up stuff anyway and hope nothing +* goes wrong */ +i810_driver_reclaim_buffers (dev, file_priv); + } + }int i810_driver_dma_quiescent (struct drm_device *dev)
drivers/gpu/drm/i810/i810_drv.c +0 -1
@@ -50,7 +50,6 @@ static struct drm_driver driver = { .lastclose = i810_driver_lastclose, .preclose = i810_driver_preclose, .device_is_agp = i810_driver_device_is_agp, - .reclaim_buffers_locked = i810_driver_reclaim_buffers_locked, .dma_quiescent = i810_driver_dma_quiescent, .ioctls = i810_ioctls, .fops = {
drivers/gpu/drm/i810/i810_drv.h +2 -4
@@ -116,14 +116,12 @@ typedef struct drm_i810_private {/* i810_dma.c */ extern int i810_driver_dma_quiescent (struct drm_device *dev); -extern void i810_driver_reclaim_buffers_locked (struct drm_device *dev, -struct drm_file *file_priv); +void i810_driver_reclaim_buffers (struct drm_device *dev, +struct drm_file *file_priv);extern int i810_driver_load (struct drm_device *,unsigned long flags);extern void i810_driver_lastclose (struct drm_device *dev);extern void i810_driver_preclose (struct drm_device *dev,struct drm_file *file_priv); -extern void i810_driver_reclaim_buffers_locked (struct drm_device *dev, -struct drm_file *file_priv);extern int i810_driver_device_is_agp (struct drm_device *dev);extern long i810_ioctl (struct file *file,unsigned int cmd,unsigned long arg);
Signature · 1 line
1.7.7.1
PATCH 15/23 drm: kill reclaim_buffers_locked
In reply to Daniel Vetteri810 was the last user of this code, with that gone, kill it.
--- drivers/gpu/drm/drm_fops.c | 46 +---------------------------------- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 1 - include/drm/drmP.h | 2 - 3 files changed, 1 insertions(+), 48 deletions(-)
drivers/gpu/drm/drm_fops.c +1 -45
@@ -360,53 +360,10 @@ int drm_fasync(int fd, struct file *filp, int on) }EXPORT_SYMBOL (drm_fasync); -/* -* Reclaim locked buffers; note that this may be a bad idea if the current -* context doesn't have the hw lock... -*/ -static void drm_reclaim_locked_buffers (struct drm_device *dev,struct file *f) -{ -struct drm_file *file_priv = f->private_data; - -if (drm_i_have_hw_lock (dev, file_priv)) { - dev->driver->reclaim_buffers_locked (dev, file_priv); - }else { -unsigned long _end = jiffies +3 *DRM_HZ ; -int locked =0 ; - -drm_idlelock_take (&file_priv->master->lock); - -/* -* Wait for a while. -*/ -do { -spin_lock_bh (&file_priv->master->lock.spinlock); - locked = file_priv->master->lock.idle_has_lock; -spin_unlock_bh (&file_priv->master->lock.spinlock); -if (locked) -break ; -schedule (); - }while (!time_after_eq (jiffies, _end)); - -if (!locked) { -DRM_ERROR ("reclaim_buffers_locked() deadlock. Please rework this\n" -"\tdriver to use reclaim_buffers_idlelocked() instead.\n" -"\tI will go on reclaiming the buffers anyway.\n" ); - } - - dev->driver->reclaim_buffers_locked (dev, file_priv); -drm_idlelock_release (&file_priv->master->lock); - } -} -static void drm_master_release (struct drm_device *dev,struct file *filp) {struct drm_file *file_priv = filp->private_data; -if (dev->driver->reclaim_buffers_locked && - file_priv->master->lock.hw_lock) -drm_reclaim_locked_buffers (dev, filp); -if (drm_i_have_hw_lock (dev, file_priv)) {DRM_DEBUG ("File %p released, freeing lock for context %d\n" , filp,_DRM_LOCKING_CONTEXT (file_priv->master->lock.hw_lock->lock));
@@ -414,8 +371,7 @@ static void drm_master_release(struct drm_device *dev, struct file *filp) _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); } -if (drm_core_check_feature (dev,DRIVER_HAVE_DMA ) && - !dev->driver->reclaim_buffers_locked) { +if (drm_core_check_feature (dev,DRIVER_HAVE_DMA )) { dev->driver->reclaim_buffers (dev, file_priv); } }
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +0 -1
@@ -886,7 +886,6 @@ static struct drm_driver driver = { .irq_uninstall = vmw_irq_uninstall, .irq_handler = vmw_irq_handler, .get_vblank_counter = vmw_get_vblank_counter, - .reclaim_buffers_locked = NULL, .ioctls = vmw_ioctls, .num_ioctls = DRM_ARRAY_SIZE(vmw_ioctls), .dma_quiescent = NULL, /*vmw_dma_quiescent, */
include/drm/drmP.h +0 -2
@@ -855,8 +855,6 @@ struct drm_driver {void (*irq_uninstall) (struct drm_device *dev);void (*reclaim_buffers) (struct drm_device *dev,struct drm_file * file_priv); -void (*reclaim_buffers_locked) (struct drm_device *dev, -struct drm_file *file_priv);void (*set_version) (struct drm_device *dev,struct drm_set_version *sv);
Signature · 1 line
1.7.7.1
PATCH 16/23 drm/savage: clean up reclaim_buffers
In reply to Daniel VetterThe reclaim_buffers function of the savage driver actually wants to run with the hw_lock held - at least there are printks in the call-chain to that effect. But the drm core only calls reclaim_buffers as used by savage _after_ forcefully dropping the hwlock (in case it's still hold by the closing fd).
So do the same idlelock dance as for the other dma drivers and hope that papers over any issues.
--- drivers/gpu/drm/savage/savage_bci.c | 7 +++++-- drivers/gpu/drm/savage/savage_drv.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/savage/savage_bci.c +5 -2
@@ -1050,6 +1050,7 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv) {struct drm_device_dma *dma = dev->dma;drm_savage_private_t *dev_priv = dev->dev_private; +int release_idlelock =0 ;int i;if (!dma)
@@ -1059,7 +1060,8 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)if (!dma->buflist)return ; -/*i830_flush_queue(dev); */ +if (file_priv->master && file_priv->master->lock.hw_lock) +drm_idlelock_take (&file_priv->master->lock);for (i =0 ; i < dma->buf_count; i++) {struct drm_buf *buf = dma->buflist[i];
@@ -1075,7 +1077,8 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv) } } -drm_core_reclaim_buffers (dev, file_priv); +if (release_idlelock) +drm_idlelock_release (&file_priv->master->lock); }struct drm_ioctl_desc savage_ioctls[] = {
drivers/gpu/drm/savage/savage_drv.c +1 -1
@@ -39,9 +39,9 @@ static struct drm_driver driver = { .dev_priv_size = sizeof(drm_savage_buf_priv_t), .load = savage_driver_load, .firstopen = savage_driver_firstopen, + .preclose = savage_reclaim_buffers, .lastclose = savage_driver_lastclose, .unload = savage_driver_unload, - .reclaim_buffers = savage_reclaim_buffers, .ioctls = savage_ioctls, .dma_ioctl = savage_bci_buffers, .fops = {
Signature · 1 line
1.7.7.1
Re: [PATCH 16/23] drm/savage: clean up reclaim_buffers
Quoted 63 lines · Daniel Vetter
The
reclaim_buffersfunction of the savage driver actually wants to run with thehw_lockheld - at least there are printks in the call-chain to that effect. But the drm core only callsreclaim_buffersas used by savage _after_ forcefully dropping the hwlock (in case it's still hold by the closing fd).So do the same idlelock dance as for the other dma drivers and hope that papers over any issues.
Signed-off-by Daniel Vetter <[email protected]>---
drivers/gpu/drm/savage/savage_bci.c | 7 +++++--drivers/gpu/drm/savage/savage_drv.c| 2 +-2 files changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/savage/savage_bci.c +5
-2@@ -1050,6 +1050,7 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv) { struct drm_device_dma *dma = dev->dma; drm_savage_private_t *dev_priv = dev->dev_private; + int release_idlelock = 0; int i; if (!dma)@@ -1059,7 +1060,8 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv) if (!dma->buflist) return; - /*i830_flush_queue(dev); */ + if (file_priv->master && file_priv->master->lock.hw_lock) + drm_idlelock_take(&file_priv->master->lock); for (i = 0; i < dma->buf_count; i++) { struct drm_buf *buf = dma->buflist[i];@@ -1075,7 +1077,8 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv) } } - drm_core_reclaim_buffers(dev, file_priv); + if (release_idlelock) + drm_idlelock_release(&file_priv->master->lock); } struct drm_ioctl_desc savage_ioctls[] = {drivers/gpu/drm/savage/savage_drv.c +1
-2@@ -39,9 +39,9 @@ static struct drm_driver driver = { .dev_priv_size = sizeof(drm_savage_buf_priv_t), .load = savage_driver_load, .firstopen = savage_driver_firstopen, + .preclose = savage_reclaim_buffers, .lastclose = savage_driver_lastclose, .unload = savage_driver_unload, - .reclaim_buffers = savage_reclaim_buffers, .ioctls = savage_ioctls, .dma_ioctl = savage_bci_buffers, .fops = { --
Quoted 1 line
1.7.7.1
Hi Daniel,
This works fine on my savage Twister card (laptop).
Cheers,
Tormod
PATCH 17/23 drm: kill reclaim_buffers callback
In reply to Daniel VetterAll leftover users either haven't set DRIVER_HAVE_DMA, in which case this will never be called, or use the drm_core implementation.
Call that directly in the only callsite.
--- drivers/gpu/drm/drm_fops.c | 5 ++--- drivers/gpu/drm/i915/i915_drv.c | 1 - drivers/gpu/drm/mga/mga_drv.c | 1 - drivers/gpu/drm/nouveau/nouveau_drv.c | 1 - drivers/gpu/drm/r128/r128_drv.c | 1 - drivers/gpu/drm/radeon/radeon_drv.c | 2 -- drivers/gpu/drm/tdfx/tdfx_drv.c | 1 - drivers/staging/gma500/psb_drv.c | 1 - include/drm/drmP.h | 2 -- 9 files changed, 2 insertions(+), 13 deletions(-)
drivers/gpu/drm/drm_fops.c +2 -3
@@ -371,9 +371,8 @@ static void drm_master_release(struct drm_device *dev, struct file *filp) _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); } -if (drm_core_check_feature (dev,DRIVER_HAVE_DMA )) { - dev->driver->reclaim_buffers (dev, file_priv); - } +if (drm_core_check_feature (dev,DRIVER_HAVE_DMA )) +drm_core_reclaim_buffers (dev, file_priv); }static void drm_events_release (struct drm_file *file_priv)
drivers/gpu/drm/i915/i915_drv.c +0 -1
@@ -803,7 +803,6 @@ static struct drm_driver driver = { .resume = i915_resume, .device_is_agp = i915_driver_device_is_agp, - .reclaim_buffers = drm_core_reclaim_buffers, .master_create = i915_master_create, .master_destroy = i915_master_destroy,#if defined(CONFIG_DEBUG_FS )
drivers/gpu/drm/mga/mga_drv.c +0 -1
@@ -59,7 +59,6 @@ static struct drm_driver driver = { .irq_postinstall = mga_driver_irq_postinstall, .irq_uninstall = mga_driver_irq_uninstall, .irq_handler = mga_driver_irq_handler, - .reclaim_buffers = drm_core_reclaim_buffers, .ioctls = mga_ioctls, .dma_ioctl = mga_dma_buffers, .fops = {
drivers/gpu/drm/nouveau/nouveau_drv.c +0 -1
@@ -410,7 +410,6 @@ static struct drm_driver driver = { .get_vblank_counter = drm_vblank_count, .enable_vblank = nouveau_vblank_enable, .disable_vblank = nouveau_vblank_disable, - .reclaim_buffers = drm_core_reclaim_buffers, .ioctls = nouveau_ioctls, .fops = { .owner = THIS_MODULE,
drivers/gpu/drm/r128/r128_drv.c +0 -1
@@ -55,7 +55,6 @@ static struct drm_driver driver = { .irq_postinstall = r128_driver_irq_postinstall, .irq_uninstall = r128_driver_irq_uninstall, .irq_handler = r128_driver_irq_handler, - .reclaim_buffers = drm_core_reclaim_buffers, .ioctls = r128_ioctls, .dma_ioctl = r128_cce_buffers, .fops = {
drivers/gpu/drm/radeon/radeon_drv.c +0 -2
@@ -223,7 +223,6 @@ static struct drm_driver driver_old = { .irq_postinstall = radeon_driver_irq_postinstall, .irq_uninstall = radeon_driver_irq_uninstall, .irq_handler = radeon_driver_irq_handler, - .reclaim_buffers = drm_core_reclaim_buffers, .ioctls = radeon_ioctls, .dma_ioctl = radeon_cp_buffers, .fops = {
@@ -325,7 +324,6 @@ static struct drm_driver kms_driver = { .irq_postinstall = radeon_driver_irq_postinstall_kms, .irq_uninstall = radeon_driver_irq_uninstall_kms, .irq_handler = radeon_driver_irq_handler_kms, - .reclaim_buffers = drm_core_reclaim_buffers, .ioctls = radeon_ioctls_kms, .gem_init_object = radeon_gem_object_init, .gem_free_object = radeon_gem_object_free,
drivers/gpu/drm/tdfx/tdfx_drv.c +0 -1
@@ -41,7 +41,6 @@ static struct pci_device_id pciidlist[] = {static struct drm_driver driver = { .driver_features =DRIVER_USE_MTRR , - .reclaim_buffers = drm_core_reclaim_buffers, .fops = { .owner =THIS_MODULE , .open = drm_open,
drivers/staging/gma500/psb_drv.c +0 -1
@@ -1170,7 +1170,6 @@ static struct drm_driver driver = { .open = psb_driver_open, .preclose = psb_driver_preclose, .postclose = psb_driver_close, - .reclaim_buffers = drm_core_reclaim_buffers, .gem_init_object = psb_gem_init_object, .gem_free_object = psb_gem_free_object,
include/drm/drmP.h +0 -2
@@ -853,8 +853,6 @@ struct drm_driver {void (*irq_preinstall) (struct drm_device *dev);int (*irq_postinstall) (struct drm_device *dev);void (*irq_uninstall) (struct drm_device *dev); -void (*reclaim_buffers) (struct drm_device *dev, -struct drm_file * file_priv);void (*set_version) (struct drm_device *dev,struct drm_set_version *sv);
Signature · 1 line
1.7.7.1
PATCH 18/23 drm: ditch strange DRIVER_DMA_QUEUE only error bail-out
In reply to Daniel VetterOnly one driver (i810) even sets that flag. Now the actual locking code uncoditionally promotes lock->context to an unsigned int.
Closer inspection of the userspace reveals that the drm lock context is defined as an unsigned int (at least on linux). I suspect we just have a strange case of signedness confusion going on.
Tested on my i815, doesn't seem to break anything.
--- drivers/gpu/drm/drm_lock.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_lock.c +0 -4
@@ -69,10 +69,6 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) lock->context,task_pid_nr (current), master->lock.hw_lock->lock, lock->flags); -if (drm_core_check_feature (dev,DRIVER_DMA_QUEUE )) -if (lock->context <0 ) -return -EINVAL ; -add_wait_queue (&master->lock.lock_queue, &entry);spin_lock_bh (&master->lock.spinlock); master->lock.user_waiters++;
Signature · 1 line
1.7.7.1
PATCH 19/23 drm: kill dma queue support
In reply to Daniel VetterAbsolutely unused. All the values are only ever initialized and then used at most in some debug printout functions.
--- drivers/gpu/drm/drm_bufs.c | 16 ++-------------- drivers/gpu/drm/drm_debugfs.c | 1 - drivers/gpu/drm/drm_dma.c | 5 ----- drivers/gpu/drm/drm_drv.c | 11 ----------- drivers/gpu/drm/drm_fops.c | 4 ---- drivers/gpu/drm/drm_info.c | 36 ------------------------------------ drivers/gpu/drm/drm_proc.c | 1 - drivers/gpu/drm/i810/i810_drv.c | 2 +- include/drm/drmP.h | 8 +------- 9 files changed, 4 insertions(+), 80 deletions(-)
drivers/gpu/drm/drm_bufs.c +2 -14
@@ -640,8 +640,6 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)if (order <DRM_MIN_ORDER || order >DRM_MAX_ORDER )return -EINVAL ; -if (dev->queue_count) -return -EBUSY ;/* Not while in use */ /* Make sure buffers are located in AGP memory that we own */ valid =0 ;
@@ -703,7 +701,6 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request) buf->next =NULL ; buf->waiting =0 ; buf->pending =0 ; -init_waitqueue_head (&buf->dma_wait); buf->file_priv =NULL ; buf->dev_priv_size = dev->driver->dev_priv_size;
@@ -795,13 +792,11 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request) order =drm_order (request->size); size =1 << order; -DRM_DEBUG ("count=%d, size=%d (%d), order=%d, queue_count=%d\n" , - request->count, request->size, size, order, dev->queue_count); +DRM_DEBUG ("count=%d, size=%d (%d), order=%d\n" , + request->count, request->size, size, order);if (order <DRM_MIN_ORDER || order >DRM_MAX_ORDER )return -EINVAL ; -if (dev->queue_count) -return -EBUSY ;/* Not while in use */ alignment = (request->flags & _DRM_PAGE_ALIGN) ?PAGE_ALIGN (size) : size;
@@ -903,7 +898,6 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request) buf->next =NULL ; buf->waiting =0 ; buf->pending =0 ; -init_waitqueue_head (&buf->dma_wait); buf->file_priv =NULL ; buf->dev_priv_size = dev->driver->dev_priv_size;
@@ -1018,8 +1012,6 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * requestif (order <DRM_MIN_ORDER || order >DRM_MAX_ORDER )return -EINVAL ; -if (dev->queue_count) -return -EBUSY ;/* Not while in use */ spin_lock (&dev->count_lock);if (dev->buf_use) {
@@ -1070,7 +1062,6 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request buf->next =NULL ; buf->waiting =0 ; buf->pending =0 ; -init_waitqueue_head (&buf->dma_wait); buf->file_priv =NULL ; buf->dev_priv_size = dev->driver->dev_priv_size;
@@ -1176,8 +1167,6 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * requestif (order <DRM_MIN_ORDER || order >DRM_MAX_ORDER )return -EINVAL ; -if (dev->queue_count) -return -EBUSY ;/* Not while in use */ spin_lock (&dev->count_lock);if (dev->buf_use) {
@@ -1227,7 +1216,6 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request buf->next =NULL ; buf->waiting =0 ; buf->pending =0 ; -init_waitqueue_head (&buf->dma_wait); buf->file_priv =NULL ; buf->dev_priv_size = dev->driver->dev_priv_size;
drivers/gpu/drm/drm_debugfs.c +0 -1
@@ -45,7 +45,6 @@ static struct drm_info_list drm_debugfs_list[] = { {"name", drm_name_info, 0}, {"vm", drm_vm_info, 0}, {"clients", drm_clients_info, 0}, - {"queues", drm_queues_info, 0}, {"bufs", drm_bufs_info, 0}, {"gem_names", drm_gem_name_info, DRIVER_GEM}, #if DRM_DEBUG_CODE
drivers/gpu/drm/drm_dma.c +0 -5
@@ -119,11 +119,6 @@ void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf) buf->pending =0 ; buf->file_priv =NULL ; buf->used =0 ; - -if (drm_core_check_feature (dev,DRIVER_DMA_QUEUE ) - &&waitqueue_active (&buf->dma_wait)) { -wake_up_interruptible (&buf->dma_wait); - } }/**
drivers/gpu/drm/drm_drv.c +0 -11
@@ -171,7 +171,6 @@ static struct drm_ioctl_desc drm_ioctls[] = {int drm_lastclose (struct drm_device * dev) {struct drm_vma_entry *vma, *vma_temp; -int i;DRM_DEBUG ("\n" );
@@ -217,16 +216,6 @@ int drm_lastclose(struct drm_device * dev)kfree (vma); } -if (drm_core_check_feature (dev,DRIVER_DMA_QUEUE ) && dev->queuelist) { -for (i =0 ; i < dev->queue_count; i++) { -kfree (dev->queuelist[i]); - dev->queuelist[i] =NULL ; - } -kfree (dev->queuelist); - dev->queuelist =NULL ; - } - dev->queue_count =0 ; -if (drm_core_check_feature (dev,DRIVER_HAVE_DMA ) && !drm_core_check_feature (dev,DRIVER_MODESET ))drm_dma_takedown (dev);
drivers/gpu/drm/drm_fops.c +0 -4
@@ -74,10 +74,6 @@ static int drm_setup(struct drm_device * dev) dev->sigdata.lock =NULL ; - dev->queue_count =0 ; - dev->queue_reserved =0 ; - dev->queue_slots =0 ; - dev->queuelist =NULL ; dev->context_flag =0 ; dev->interrupt_flag =0 ; dev->dma_flag =0 ;
drivers/gpu/drm/drm_info.c +0 -36
@@ -110,42 +110,6 @@ int drm_vm_info(struct seq_file *m, void *data) }/** -* Called when "/proc/dri/.../queues" is read. -*/ -int drm_queues_info (struct seq_file *m,void *data) -{ -struct drm_info_node *node = (struct drm_info_node *) m->private; -struct drm_device *dev = node->minor->dev; -int i; -struct drm_queue *q; - -mutex_lock (&dev->struct_mutex); -seq_printf (m," ctx/flags use fin" -" blk/rw/rwf wait flushed queued" -" locks\n\n" ); -for (i =0 ; i < dev->queue_count; i++) { - q = dev->queuelist[i]; -atomic_inc (&q->use_count); -seq_printf (m,"%5d/0x%03x %5d %5d" -" %5d/%c%c/%c%c%c %5Zd\n" , - i, - q->flags, -atomic_read (&q->use_count), -atomic_read (&q->finalization), -atomic_read (&q->block_count), -atomic_read (&q->block_read) ?'r' :'-' , -atomic_read (&q->block_write) ?'w' :'-' , -waitqueue_active (&q->read_queue) ?'r' :'-' , -waitqueue_active (&q->write_queue) ?'w' :'-' , -waitqueue_active (&q->flush_queue) ?'f' :'-' , -DRM_BUFCOUNT (&q->waitlist)); -atomic_dec (&q->use_count); - } -mutex_unlock (&dev->struct_mutex); -return 0 ; -} - -/** * Called when "/proc/dri/.../bufs" is read. */ int drm_bufs_info (struct seq_file *m,void *data)
drivers/gpu/drm/drm_proc.c +0 -1
@@ -52,7 +52,6 @@ static struct drm_info_list drm_proc_list[] = { {"name", drm_name_info, 0}, {"vm", drm_vm_info, 0}, {"clients", drm_clients_info, 0}, - {"queues", drm_queues_info, 0}, {"bufs", drm_bufs_info, 0}, {"gem_names", drm_gem_name_info, DRIVER_GEM}, #if DRM_DEBUG_CODE
drivers/gpu/drm/i810/i810_drv.c +1 -1
@@ -44,7 +44,7 @@ static struct pci_device_id pciidlist[] = {static struct drm_driver driver = { .driver_features =DRIVER_USE_AGP |DRIVER_REQUIRE_AGP |DRIVER_USE_MTRR | -DRIVER_HAVE_DMA |DRIVER_DMA_QUEUE , +DRIVER_HAVE_DMA , .dev_priv_size =sizeof (drm_i810_buf_priv_t), .load = i810_driver_load, .lastclose = i810_driver_lastclose,
include/drm/drmP.h +1 -7
@@ -339,7 +339,6 @@ struct drm_buf {struct drm_buf *next;/**< Kernel-only: used for free list */ __volatile__ int waiting; /**< On kernel DMA queue */ __volatile__ int pending; /**< On hardware DMA queue */ -wait_queue_head_t dma_wait;/**< Processes waiting */ struct drm_file *file_priv;/**< Private of holding file descr */ int context;/**< Kernel queue for this buffer */ int while_locked;/**< Dispatch this buffer while locked */
@@ -1063,12 +1062,8 @@ struct drm_device {/*@} */ -/** \name DMA queues (contexts) */ +/** \name DMA support */ /*@{ */ -int queue_count;/**< Number of active DMA queues */ -int queue_reserved;/**< Number of reserved DMA queues */ -int queue_slots;/**< Actual length of queuelist */ -struct drm_queue **queuelist;/**< Vector of pointers to DMA queues */ struct drm_device_dma *dma;/**< Optional pointer for DMA support */ /*@} */
@@ -1486,7 +1481,6 @@ extern int drm_debugfs_cleanup(struct drm_minor *minor);/* Info file support */ extern int drm_name_info (struct seq_file *m,void *data);extern int drm_vm_info (struct seq_file *m,void *data); -extern int drm_queues_info (struct seq_file *m,void *data);extern int drm_bufs_info (struct seq_file *m,void *data);extern int drm_vblank_info (struct seq_file *m,void *data);extern int drm_clients_info (struct seq_file *m,void * data);
Signature · 1 line
1.7.7.1
PATCH 20/23 drm: unconditionally clean up dma buffers of closing clients
In reply to Daniel VetterWith the last patch to ditch DMA_QUEUE support, we should be able to call the dma cleanup uncoditionally, even when the master has disappeared.
Do so because it just makes more sense.
--- drivers/gpu/drm/drm_fops.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_fops.c +3 -3
@@ -366,9 +366,6 @@ static void drm_master_release(struct drm_device *dev, struct file *filp)drm_lock_free (&file_priv->master->lock,_DRM_LOCKING_CONTEXT (file_priv->master->lock.hw_lock->lock)); } - -if (drm_core_check_feature (dev,DRIVER_HAVE_DMA )) -drm_core_reclaim_buffers (dev, file_priv); }static void drm_events_release (struct drm_file *file_priv)
@@ -433,6 +430,9 @@ int drm_release(struct inode *inode, struct file *filp)if (file_priv->minor->master)drm_master_release (dev, filp); +if (drm_core_check_feature (dev,DRIVER_HAVE_DMA )) +drm_core_reclaim_buffers (dev, file_priv); +drm_events_release (file_priv);if (dev->driver->driver_features &DRIVER_GEM )
Signature · 1 line
1.7.7.1
PATCH 21/23 drm: kill i915/i830 ids from drm_pciids.h
In reply to Daniel Vetter--- include/drm/drm_pciids.h | 42 ------------------------------------------ 1 files changed, 0 insertions(+), 42 deletions(-)
include/drm/drm_pciids.h +0 -42
@@ -603,14 +603,6 @@ {0x8086, 0x1132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0, 0, 0} -#define i830_PCI_IDS \ - {0x8086, 0x3577, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ - {0x8086, 0x2562, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ - {0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ - {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ - {0x8086, 0x358e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ - {0, 0, 0} -#define gamma_PCI_IDS \ {0x3d3d, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0, 0, 0}
@@ -643,37 +635,3 @@#define ffb_PCI_IDS \ {0, 0, 0} - -#define i915_PCI_IDS \ - {0x8086, 0x3577, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2562, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x258a, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x27ae, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2972, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2982, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2992, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x29a2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x29b2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x29c2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x29d2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2a02, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2a12, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2a42, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2e02, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2e12, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2e22, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2e32, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x2e42, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0xa001, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0xa011, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x35e8, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x0042, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x0046, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0x8086, 0x0102, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0}, \ - {0, 0, 0}
Signature · 1 line
1.7.7.1
PATCH 22/23 drm: kill procfs support
In reply to Daniel VetterWe have debugfs and sysfs for these things now!
Digging through the dungeons of old code and wading through countless result pages on google indeed turned up one user of this:
libdrm before 2001 checks via the presence of /proc/dri/0 whether the kernel drm is present and has a module successfully loaded.
Frankly I think that demanding from users that they upgrade to a more modern libdrm is in order.
--- drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_drv.c | 8 -- drivers/gpu/drm/drm_proc.c | 220 -------------------------------------------- drivers/gpu/drm/drm_stub.c | 25 ++---- include/drm/drmP.h | 9 -- 5 files changed, 8 insertions(+), 256 deletions(-) delete mode 100644 drivers/gpu/drm/drm_proc.c
drivers/gpu/drm/Makefile +1 -1
@@ -7,7 +7,7 @@ ccflags-y := -Iinclude/drm drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ drm_context.o drm_dma.o \ drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \ - drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \ + drm_lock.o drm_memory.o drm_stub.o drm_vm.o \ drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \ drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \ drm_crtc.o drm_modes.o drm_edid.o \
drivers/gpu/drm/drm_drv.c +0 -8
@@ -251,13 +251,6 @@ static int __init drm_core_init(void) goto err_p2; } - drm_proc_root =proc_mkdir ("dri" ,NULL ); -if (!drm_proc_root) { -DRM_ERROR ("Cannot create /proc/dri\n" ); - ret =-1 ; - goto err_p3; - } - drm_debugfs_root =debugfs_create_dir ("dri" ,NULL );if (!drm_debugfs_root) {DRM_ERROR ("Cannot create /sys/kernel/debug/dri\n" );
@@ -280,7 +273,6 @@ err_p1: static void __exit drm_core_exit(void) { -remove_proc_entry ("dri" ,NULL );debugfs_remove (drm_debugfs_root);drm_sysfs_destroy ();
drivers/gpu/drm/drm_proc.c deleted +0 -220
220 lines not on this page · raw message
drivers/gpu/drm/drm_stub.c +7 -18
@@ -60,7 +60,6 @@ module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600)struct idr drm_minors_idr;struct class *drm_class; -struct proc_dir_entry *drm_proc_root;struct dentry *drm_debugfs_root;int drm_err (const char *func,const char *format, ...)
@@ -329,7 +328,7 @@ int drm_fill_in_dev(struct drm_device *dev,* \return negative number on failure. * * Search an empty entry and initialize it to the given parameters, and -* create the proc init entry via proc_init(). This routines assigns +* create the sysfs/debugfs init entry. This routines assigns * minor numbers to secondary heads of multi-headed cards */ int drm_get_minor (struct drm_device *dev,struct drm_minor **minor,int type)
@@ -358,20 +357,11 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)idr_replace (&drm_minors_idr, new_minor, minor_id); -if (type ==DRM_MINOR_LEGACY ) { - ret =drm_proc_init (new_minor, minor_id, drm_proc_root); -if (ret) { -DRM_ERROR ("DRM: Failed to initialize /proc/dri.\n" ); - goto err_mem; - } - }else - new_minor->proc_root =NULL ; -#if defined(CONFIG_DEBUG_FS ) ret =drm_debugfs_init (new_minor, minor_id, drm_debugfs_root);if (ret) {DRM_ERROR ("DRM: Failed to initialize /sys/kernel/debug/dri.\n" ); - goto err_g2; + goto err_mem; }#endif
@@ -379,7 +369,7 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)if (ret) {printk (KERN_ERR "DRM: Error sysfs_device_add.\n" ); - goto err_g2; + goto err_debugfs; } *minor = new_minor;
@@ -387,9 +377,10 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)return 0 ; -err_g2: -if (new_minor->type ==DRM_MINOR_LEGACY ) -drm_proc_cleanup (new_minor, drm_proc_root); +err_debugfs: +#if defined(CONFIG_DEBUG_FS ) +drm_debugfs_cleanup (new_minor); +#endif err_mem:kfree (new_minor); err_idr:
@@ -414,8 +405,6 @@ int drm_put_minor(struct drm_minor **minor_p)DRM_DEBUG ("release secondary minor %d\n" , minor->index); -if (minor->type ==DRM_MINOR_LEGACY ) -drm_proc_cleanup (minor, drm_proc_root);#if defined(CONFIG_DEBUG_FS )drm_debugfs_cleanup (minor);#endif
include/drm/drmP.h +0 -9
@@ -46,7 +46,6 @@#include <linux/kernel.h> #include <linux/miscdevice.h> #include <linux/fs.h> -#include <linux/proc_fs.h> #include <linux/init.h> #include <linux/file.h> #include <linux/platform_device.h>
@@ -979,8 +978,6 @@ struct drm_minor {struct device kdev;/**< Linux device */ struct drm_device *dev; -struct proc_dir_entry *proc_root;/**< proc directory entry */ -struct drm_info_node proc_nodes;struct dentry *debugfs_root;struct drm_info_node debugfs_nodes;
@@ -1455,18 +1452,12 @@ extern unsigned int drm_vblank_offdelay;extern unsigned int drm_timestamp_precision;extern struct class *drm_class; -extern struct proc_dir_entry *drm_proc_root;extern struct dentry *drm_debugfs_root;extern struct idr drm_minors_idr;extern struct drm_local_map *drm_getsarea (struct drm_device *dev); -/* Proc support (drm_proc.h) */ -extern int drm_proc_init (struct drm_minor *minor,int minor_id, -struct proc_dir_entry *root); -extern int drm_proc_cleanup (struct drm_minor *minor,struct proc_dir_entry *root); -/* Debugfs support */ #if defined(CONFIG_DEBUG_FS ) extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
Signature · 1 line
1.7.7.1
PATCH 23/23 drm: kill a few unused remnants from drm_memory.c
In reply to Daniel VetterNoticed while killing code in the area ...
--- drivers/gpu/drm/drm_memory.c | 19 ------------------- include/drm/drmP.h | 5 ----- 2 files changed, 0 insertions(+), 24 deletions(-)
drivers/gpu/drm/drm_memory.c +0 -19
@@ -36,25 +36,6 @@#include <linux/highmem.h> #include "drmP.h" -/** -* Called when "/proc/dri/%dev%/mem" is read. -* -* \param buf output buffer. -* \param start start of output data. -* \param offset requested start offset. -* \param len requested number of bytes. -* \param eof whether there is no more data to return. -* \param data private data. -* \return number of written bytes. -* -* No-op. -*/ -int drm_mem_info (char *buf,char **start,off_t offset, -int len,int *eof,void *data) -{ -return 0 ; -} -#if __OS_HAS_AGPstatic void *agp_remap (unsigned long offset,unsigned long size,struct drm_device * dev)
include/drm/drmP.h +0 -5
@@ -1247,11 +1247,6 @@ extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);/* Memory management support (drm_memory.h) */ #include "drm_memory.h" -extern void drm_mem_init (void ); -extern int drm_mem_info (char *buf,char **start,off_t offset, -int request,int *eof,void *data); -extern void *drm_realloc (void *oldpt,size_t oldsize,size_t size,int area); -extern void drm_free_agp (DRM_AGP_MEM * handle,int pages);extern int drm_bind_agp (DRM_AGP_MEM * handle,unsigned int start); extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
Signature · 1 line
1.7.7.1
Quoted 17 lines
Review, flames highly welcome.
Cheers, Daniel
Daniel Vetter (23):
drm/sis: trackobj->drm_fdrelations in the driver drm/via: trackobj->drm_fdrelations in the driver drm/sman: kill owner tracking interface functions drm/sman: rip out owner tracking
drm/via: trackuser->memblockmapping with idr drm/sis: trackuser->memblockmapping with idr drm/sman: killuser_hash_tab
drm/via: usedrm_mminstead ofdrm_smandrm/sis: usedrm_mminstead ofdrm_sman
drm: killdrm_sman
Quoted 7 lines
drm/via: clean up
reclaim_buffers
drm/sis: clean upreclaim_buffers
drm: killreclaim_buffers_idlelockedfunctions
drm/i810: cleanupreclaim_buffers
drm: killreclaim_buffers_locked
drm/savage: clean upreclaim_buffers
drm: killreclaim_bufferscallback
Should I test this set of patches for the VIA driver or wait until you have a second version of this patch?
Quoted 25 lines · James Simmons
Quoted 17 lines
Review, flames highly welcome.
Cheers, Daniel
Daniel Vetter (23):
drm/sis: trackobj->drm_fdrelations in the driver drm/via: trackobj->drm_fdrelations in the driver drm/sman: kill owner tracking interface functions drm/sman: rip out owner tracking
drm/via: trackuser->memblockmapping with idr drm/sis: trackuser->memblockmapping with idr drm/sman: killuser_hash_tab
drm/via: usedrm_mminstead ofdrm_smandrm/sis: usedrm_mminstead ofdrm_sman
drm: killdrm_smanQuoted 7 lines
drm/via: clean up
reclaim_buffers
drm/sis: clean upreclaim_buffers
drm: killreclaim_buffers_idlelockedfunctions
drm/i810: cleanupreclaim_buffers
drm: killreclaim_buffers_locked
drm/savage: clean upreclaim_buffers
drm: killreclaim_bufferscallback
Quoted 2 lines
Should I test this set of patches for the VIA driver or wait until you have a second version of this patch?
Testing this on via would be awesome! Iirc I haven't changed anything in the via specific patches, but if it's more convenient you can also directly test my branch:
http://cgit.freedesktop.org/~danvet/drm/log/?h=kill-with-fire
Yours, Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Quoted 9 lines
Quoted 3 lines
Should I test this set of patches for the VIA driver or wait until you have a second version of this patch?
Testing this on via would be awesome! Iirc I haven't changed anything in the via specific patches, but if it's more convenient you can also directly test my branch:
http://cgit.freedesktop.org/~danvet/drm/log/?h=kill-with-fire
Okay I tried the patches and it locked up the openchrome X server. I'm going to try your branch tonight to see if it makes any difference. If it still fails I will have to track down what the problem is.
Quoted 7 lines · James Simmons
Quoted 7 lines
Quoted 2 lines
Should I test this set of patches for the VIA driver or wait until you have a second version of this patch?
Testing this on via would be awesome! Iirc I haven't changed anything in the via specific patches, but if it's more convenient you can also directly test my branch:
Quoted 5 lines
Okay I tried the patches and it locked up the openchrome X server. I'm going to try your branch tonight to see if it makes any difference. If it still fails I will have to track down what the problem is.
If you can bisect the issue, that would be awesome. Meanwhile my sis card arrived, so I'm hopefully get around to test that part of the series rsn. I'm traveling atm though, so response time will suffer a bit.
-Daniel
Signature · 2 lines
Daniel Vetter [email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · James Simmons
Quoted 8 lines
Quoted 2 lines
Should I test this set of patches for the VIA driver or wait until you have a second version of this patch?
Testing this on via would be awesome! Iirc I haven't changed anything in the via specific patches, but if it's more convenient you can also directly test my branch:
http://cgit.freedesktop.org/~danvet/drm/log/?h=kill-with-fire
Quoted 8 lines
Quoted 3 lines
Okay I tried the patches and it locked up the openchrome X server. I'm going to try your branch tonight to see if it makes any difference. If it still fails I will have to track down what the problem is.
If you can bisect the issue, that would be awesome. Meanwhile my sis card arrived, so I'm hopefully get around to test that part of the series rsn. I'm traveling atm though, so response time will suffer a bit.
Any updates on testing results?
Yours, Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
Testing this on via would be awesome! Iirc I haven't changed anything in the via specific patches, but if it's more convenient you can also directly test my branch:
http://cgit.freedesktop.org/~danvet/drm/log/?h=kill-with-fire
Okay I tried the patches and it locked up the openchrome X server. I'm going to try your branch tonight to see if it makes any difference. If it still fails I will have to track down what the problem is.
Quoted 6 lines
Quoted 4 lines
If you can bisect the issue, that would be awesome. Meanwhile my sis card arrived, so I'm hopefully get around to test that part of the series rsn. I'm traveling atm though, so response time will suffer a bit.
Any updates on testing results?
Yes I do. I'm using the patches you posted. Patches 1 to 10 work with no problems. Ist patch 11 that breaks the openchrome xorg driver. Have to do some digging to find the exact problem.
Quoted 16 lines · James Simmons
Quoted 16 lines
Quoted 15 lines
Quoted 10 lines
Quoted 6 lines
Testing this on via would be awesome! Iirc I haven't changed anything in the via specific patches, but if it's more convenient you can also directly test my branch:
http://cgit.freedesktop.org/~danvet/drm/log/?h=kill-with-fire
Okay I tried the patches and it locked up the openchrome X server. I'm going to try your branch tonight to see if it makes any difference. If it still fails I will have to track down what the problem is.
If you can bisect the issue, that would be awesome. Meanwhile my sis card arrived, so I'm hopefully get around to test that part of the series rsn. I'm traveling atm though, so response time will suffer a bit.
Quoted 5 lines
Quoted 1 line
Any updates on testing results?
Yes I do. I'm using the patches you posted. Patches 1 to 10 work with no problems. Ist patch 11 that breaks the openchrome xorg driver. Have to do some digging to find the exact problem.
Thanks a lot for digging through these patches. As you've noted in patch 11, I don't set release_idlelock anywhere which results in the via driver deadlocking when clients close. The same holds for the equivalent sis patch. Updated patch series pushed to my kill-with-fire branch. Please test and yell at me if it's still broken.
Yours, Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48