mutex_unlock(&pdev->gtt_mutex);
}
-void psb_gtt_takedown(struct drm_device *dev)
+void psb_gtt_fini(struct drm_device *dev)
{
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
struct pci_dev *pdev = to_pci_dev(dev->dev);
- if (dev_priv->gtt_map) {
- iounmap(dev_priv->gtt_map);
- dev_priv->gtt_map = NULL;
- }
- if (dev_priv->gtt_initialized) {
- pci_write_config_word(pdev, PSB_GMCH_CTRL,
- dev_priv->gmch_ctrl);
- PSB_WVDC32(dev_priv->pge_ctl, PSB_PGETBL_CTL);
- (void) PSB_RVDC32(PSB_PGETBL_CTL);
- }
- if (dev_priv->vram_addr)
- iounmap(dev_priv->gtt_map);
+ iounmap(dev_priv->vram_addr);
+ iounmap(dev_priv->gtt_map);
+
+ pci_write_config_word(pdev, PSB_GMCH_CTRL, dev_priv->gmch_ctrl);
+ PSB_WVDC32(dev_priv->pge_ctl, PSB_PGETBL_CTL);
+ (void)PSB_RVDC32(PSB_PGETBL_CTL);
+
+ mutex_destroy(&dev_priv->mmap_mutex);
+ mutex_destroy(&dev_priv->gtt_mutex);
}
/* Clear GTT. Use a scratch page to avoid accidents or scribbles. */
(void) PSB_RVDC32(PSB_PGETBL_CTL);
/* The root resource we allocate address space from */
- dev_priv->gtt_initialized = 1;
-
pg->gtt_phys_start = dev_priv->pge_ctl & PAGE_MASK;
/*
if (!dev_priv->gtt_map) {
dev_err(dev->dev, "Failure to map gtt.\n");
ret = -ENOMEM;
- goto out_err;
+ goto err_gtt_disable;
}
dev_priv->vram_addr = ioremap_wc(dev_priv->stolen_base, stolen_size);
if (!dev_priv->vram_addr) {
dev_err(dev->dev, "Failure to map stolen base.\n");
ret = -ENOMEM;
- goto out_err;
+ goto err_iounmap;
}
psb_gtt_clear(dev_priv);
return 0;
-out_err:
- psb_gtt_takedown(dev);
+err_iounmap:
+ iounmap(dev_priv->gtt_map);
+err_gtt_disable:
+ pci_write_config_word(pdev, PSB_GMCH_CTRL, dev_priv->gmch_ctrl);
+ PSB_WVDC32(dev_priv->pge_ctl, PSB_PGETBL_CTL);
+ (void)PSB_RVDC32(PSB_PGETBL_CTL);
+ mutex_destroy(&dev_priv->mmap_mutex);
+ mutex_destroy(&dev_priv->gtt_mutex);
return ret;
}
(void) PSB_RVDC32(PSB_PGETBL_CTL);
/* The root resource we allocate address space from */
- dev_priv->gtt_initialized = 1;
-
pg->gtt_phys_start = dev_priv->pge_ctl & PAGE_MASK;
/*
if ((gtt_pages != pg->gtt_pages) && (stolen_size != pg->stolen_size)) {
dev_err(dev->dev, "GTT resume error.\n");
ret = -EINVAL;
- goto out_err;
+ goto err_gtt_disable;
}
pg->gtt_pages = gtt_pages;
return 0;
-out_err:
- psb_gtt_takedown(dev);
+err_gtt_disable:
+ pci_write_config_word(pdev, PSB_GMCH_CTRL, dev_priv->gmch_ctrl);
+ PSB_WVDC32(dev_priv->pge_ctl, PSB_PGETBL_CTL);
+ (void)PSB_RVDC32(PSB_PGETBL_CTL);
return ret;
}