atomisp: hmm: Release the spin lock before unref'ing a block object
authorIlkka Koskinen <ilkka.koskinen@intel.com>
Wed, 4 Jan 2012 14:36:11 +0000 (16:36 +0200)
committerbuildbot <buildbot@intel.com>
Mon, 16 Jan 2012 16:06:15 +0000 (08:06 -0800)
BZ: 19462

hmm_bo_device_destroy_free_bo_list held a spin lock when
unreferencing a block object. Moreover, hmm_bo_release
tries to acquire the same spin lock.

In addition, reduce the time interrupts are disabled by
changing list handling.

Change-Id: I7bbb5559f8caa8d6c696040e8ec04205e30b7c90
Signed-off-by: Ilkka Koskinen <ilkka.koskinen@intel.com>
Reviewed-on: http://android.intel.com:8080/30889
Reviewed-by: Cohen, David A <david.a.cohen@intel.com>
Reviewed-by: Kruger, Jozef <jozef.kruger@intel.com>
Reviewed-by: Toivonen, Tuukka <tuukka.toivonen@intel.com>
Reviewed-by: Yang, Fei <fei.yang@intel.com>
Reviewed-by: Wang, Wen W <wen.w.wang@intel.com>
Reviewed-by: Gross, Mark <mark.gross@intel.com>
Tested-by: Lampila, KalleX <kallex.lampila@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/media/video/atomisp/hmm/hmm_bo_dev.c

index e3b55e5..b8959e3 100644 (file)
@@ -207,20 +207,20 @@ found:
  */
 void hmm_bo_device_destroy_free_bo_list(struct hmm_bo_device *bdev)
 {
-       struct hmm_buffer_object *bo;
+       struct hmm_buffer_object *bo, *tmp;
        unsigned long flags;
+       struct list_head new_head;
 
        check_bodev_null_return(bdev, (void)0);
 
        spin_lock_irqsave(&bdev->list_lock, flags);
-       while (!list_empty(&bdev->free_bo_list)) {
-               bo = list_first_entry(&bdev->free_bo_list,
-                                     struct hmm_buffer_object, list);
+       list_replace_init(&bdev->free_bo_list, &new_head);
+       spin_unlock_irqrestore(&bdev->list_lock, flags);
 
+       list_for_each_entry_safe(bo, tmp, &new_head, list) {
                list_del(&bo->list);
                hmm_bo_unref(bo);
        }
-       spin_unlock_irqrestore(&bdev->list_lock, flags);
 }
 
 /*