diff options
author | rnoland <rnoland@FreeBSD.org> | 2008-09-09 02:05:03 +0000 |
---|---|---|
committer | rnoland <rnoland@FreeBSD.org> | 2008-09-09 02:05:03 +0000 |
commit | 016be156e0964094bf2d383d94aef409a35dc78c (patch) | |
tree | b049bd3bd13dc9dbf8c993171dae2fd568b69bed /sys/dev/drm/drm_pci.c | |
parent | 1af31f868a04970e4e460e2e08c563289e42b042 (diff) | |
download | FreeBSD-src-016be156e0964094bf2d383d94aef409a35dc78c.zip FreeBSD-src-016be156e0964094bf2d383d94aef409a35dc78c.tar.gz |
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
Diffstat (limited to 'sys/dev/drm/drm_pci.c')
-rw-r--r-- | sys/dev/drm/drm_pci.c | 11 |
1 files changed, 7 insertions, 4 deletions
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) { |