if (drm_WARN_ONCE(dev, ret, "dma_resv_lock() failed, ret=%d\n", ret))
return ret;
- mutex_lock(&dev_priv->gtt_mutex);
-
if (pobj->in_gart || pobj->stolen)
goto out; /* already mapped */
pages = drm_gem_get_pages(obj);
if (IS_ERR(pages)) {
ret = PTR_ERR(pages);
- goto err_mutex_unlock;
+ goto err_dma_resv_unlock;
}
npages = obj->size / PAGE_SIZE;
out:
++pobj->in_gart;
- mutex_unlock(&dev_priv->gtt_mutex);
dma_resv_unlock(obj->resv);
return 0;
-err_mutex_unlock:
- mutex_unlock(&dev_priv->gtt_mutex);
+err_dma_resv_unlock:
dma_resv_unlock(obj->resv);
return ret;
}
if (drm_WARN_ONCE(dev, ret, "dma_resv_lock() failed, ret=%d\n", ret))
return;
- mutex_lock(&dev_priv->gtt_mutex);
-
WARN_ON(!pobj->in_gart);
--pobj->in_gart;
pobj->pages = NULL;
out:
- mutex_unlock(&dev_priv->gtt_mutex);
dma_resv_unlock(obj->resv);
}
return pdev->gtt_map + (offset >> PAGE_SHIFT);
}
-/*
- * Take our preallocated GTT range and insert the GEM object into
- * the GTT. This is protected via the gtt mutex which the caller
- * must hold.
- */
+/* Acquires GTT mutex internally. */
void psb_gtt_insert_pages(struct drm_psb_private *pdev, const struct resource *res,
struct page **pages)
{
u32 __iomem *gtt_slot;
u32 pte;
+ mutex_lock(&pdev->gtt_mutex);
+
/* Write our page entries into the GTT itself */
npages = resource_size(res) >> PAGE_SHIFT;
/* Make sure all the entries are set before we return */
ioread32(gtt_slot - 1);
+
+ mutex_unlock(&pdev->gtt_mutex);
}
-/*
- * Remove a preallocated GTT range from the GTT. Overwrite all the
- * page table entries with the dummy page. This is protected via the gtt
- * mutex which the caller must hold.
- */
+/* Acquires GTT mutex internally. */
void psb_gtt_remove_pages(struct drm_psb_private *pdev, const struct resource *res)
{
resource_size_t npages, i;
u32 __iomem *gtt_slot;
u32 pte;
+ mutex_lock(&pdev->gtt_mutex);
+
/* Install scratch page for the resource */
pte = psb_gtt_mask_pte(page_to_pfn(pdev->scratch_page), PSB_MMU_CACHED_MEMORY);
/* Make sure all the entries are set before we return */
ioread32(gtt_slot - 1);
+
+ mutex_unlock(&pdev->gtt_mutex);
}
static void psb_gtt_alloc(struct drm_device *dev)
struct psb_gem_object *pobj;
unsigned int restored = 0, total = 0, size = 0;
- /* On resume, the gtt_mutex is already initialized */
- mutex_lock(&dev_priv->gtt_mutex);
psb_gtt_init(dev, 1);
while (r != NULL) {
r = r->sibling;
total++;
}
- mutex_unlock(&dev_priv->gtt_mutex);
+
DRM_DEBUG_DRIVER("Restored %u of %u gtt ranges (%u KB)", restored,
total, (size / 1024));