From 016be156e0964094bf2d383d94aef409a35dc78c Mon Sep 17 00:00:00 2001 From: rnoland Date: Tue, 9 Sep 2008 02:05:03 +0000 Subject: We should never call drm_pci_alloc() while holding locks, due the the calls to bus_dma. There were multiple paths that held different locks or no locks at all. This patch ensures that all of the calling paths drop their lock(s) before calling drm_pci_alloc(). Reviewed by: kib --- sys/dev/drm/drm_pci.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sys/dev/drm/drm_pci.c') diff --git a/sys/dev/drm/drm_pci.c b/sys/dev/drm/drm_pci.c index a6ddfdf..4aa6d03 100644 --- a/sys/dev/drm/drm_pci.c +++ b/sys/dev/drm/drm_pci.c @@ -74,7 +74,12 @@ drm_pci_alloc(struct drm_device *dev, size_t size, return NULL; #ifdef __FreeBSD__ - DRM_UNLOCK(); + /* Make sure we aren't holding locks here */ + if (mtx_owned(&dev->dev_lock)) + DRM_ERROR("called while holding dev_lock\n"); + if (mtx_owned(&dev->dma_lock)) + DRM_ERROR("called while holding dma_lock\n"); + ret = bus_dma_tag_create(NULL, align, 0, /* tag, align, boundary */ maxaddr, BUS_SPACE_MAXADDR, /* lowaddr, highaddr */ NULL, NULL, /* filtfunc, filtfuncargs */ @@ -83,7 +88,6 @@ drm_pci_alloc(struct drm_device *dev, size_t size, &dmah->tag); if (ret != 0) { free(dmah, M_DRM); - DRM_LOCK(); return NULL; } @@ -92,10 +96,9 @@ drm_pci_alloc(struct drm_device *dev, size_t size, if (ret != 0) { bus_dma_tag_destroy(dmah->tag); free(dmah, M_DRM); - DRM_LOCK(); return NULL; } - DRM_LOCK(); + ret = bus_dmamap_load(dmah->tag, dmah->map, dmah->vaddr, size, drm_pci_busdma_callback, dmah, 0); if (ret != 0) { -- cgit v1.1