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

drm/gma500: Add driver private mutex for the fault handler

There's currently two places where the gma500 fault handler relies
upon dev->struct_mutex:
- To protect r->mappping
- To make sure vm_insert_pfn isn't called concurrently (in which case
the 2nd thread would get an error code).

Everything else (specifically psb_gtt_pin) is already protected by
some other locks. Hence just create a new driver-private mmap_mutex
just for this function.

With this gma500 is complete dev->struct_mutex free!

Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1448271183-20523-21-git-send-email-daniel.vetter@ffwll.ch

+5 -2
+2 -2
drivers/gpu/drm/gma500/gem.c
··· 182 182 183 183 /* Make sure we don't parallel update on a fault, nor move or remove 184 184 something from beneath our feet */ 185 - mutex_lock(&dev->struct_mutex); 185 + mutex_lock(&dev_priv->mmap_mutex); 186 186 187 187 /* For now the mmap pins the object and it stays pinned. As things 188 188 stand that will do us no harm */ ··· 208 208 ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn); 209 209 210 210 fail: 211 - mutex_unlock(&dev->struct_mutex); 211 + mutex_unlock(&dev_priv->mmap_mutex); 212 212 switch (ret) { 213 213 case 0: 214 214 case -ERESTARTSYS:
+1
drivers/gpu/drm/gma500/gtt.c
··· 425 425 426 426 if (!resume) { 427 427 mutex_init(&dev_priv->gtt_mutex); 428 + mutex_init(&dev_priv->mmap_mutex); 428 429 psb_gtt_alloc(dev); 429 430 } 430 431
+2
drivers/gpu/drm/gma500/psb_drv.h
··· 465 465 struct mutex gtt_mutex; 466 466 struct resource *gtt_mem; /* Our PCI resource */ 467 467 468 + struct mutex mmap_mutex; 469 + 468 470 struct psb_mmu_driver *mmu; 469 471 struct psb_mmu_pd *pf_pd; 470 472