drm: mm always protect change to unused_nodes with unused_lock spinlock
authorJerome Glisse <jglisse@redhat.com>
Fri, 13 Nov 2009 19:56:58 +0000 (20:56 +0100)
committerDave Airlie <airlied@redhat.com>
Tue, 24 Nov 2009 03:02:18 +0000 (13:02 +1000)
commita698cf34ea867efef12fc29dd63d443f0c71a53c
treea396804737c4a7bc972f04fe97d0ec0a2f971668
parent0beb81ab45c67de4b3aa85faad604cff8ed133a8
drm: mm always protect change to unused_nodes with unused_lock spinlock

unused_nodes modification needs to be protected by unused_lock spinlock.
Here is an example of an usage where there is no such protection without
this patch.

  Process 1: 1-drm_mm_pre_get(this function modify unused_nodes list)
             2-spin_lock(spinlock protecting mm struct)
             3-drm_mm_put_block(this function might modify unused_nodes
               list but doesn't protect modification with unused_lock)
             4-spin_unlock(spinlock protecting mm struct)
  Process2:  1-drm_mm_pre_get(this function modify unused_nodes list)
At this point Process1 & Process2 might both be doing modification to
unused_nodes list. This patch add unused_lock protection into
drm_mm_put_block to avoid such issue.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_mm.c