Esempio n. 1
0
int savage_do_cleanup_bci(drm_device_t *dev)
{
	drm_savage_private_t *dev_priv = dev->dev_private;

	if (dev_priv->cmd_dma == &dev_priv->fake_dma) {
		if (dev_priv->fake_dma.handle)
			drm_free(dev_priv->fake_dma.handle,
				 SAVAGE_FAKE_DMA_SIZE, DRM_MEM_DRIVER);
	} else if (dev_priv->cmd_dma && dev_priv->cmd_dma->handle &&
		   dev_priv->cmd_dma->type == _DRM_AGP &&
		   dev_priv->dma_type == SAVAGE_DMA_AGP)
		drm_core_ioremapfree(dev_priv->cmd_dma, dev);

	if (dev_priv->dma_type == SAVAGE_DMA_AGP &&
	    dev->agp_buffer_map && dev->agp_buffer_map->handle) {
		drm_core_ioremapfree(dev->agp_buffer_map, dev);
		/* make sure the next instance (which may be running
		 * in PCI mode) doesn't try to use an old
		 * agp_buffer_map. */
		dev->agp_buffer_map = NULL;
	}

	if (dev_priv->dma_pages)
		drm_free(dev_priv->dma_pages,
			 sizeof(drm_savage_dma_page_t)*dev_priv->nr_dma_pages,
			 DRM_MEM_DRIVER);

	return 0;
}
Esempio n. 2
0
/* If you boot an IGP board with a discrete card as the primary,
 * the IGP rom is not accessible via the rom bar as the IGP rom is
 * part of the system bios.  On boot, the system bios puts a
 * copy of the igp rom at the start of vram if a discrete card is
 * present.
 */
static bool igp_read_bios_from_vram(struct radeon_device *rdev)
{
	struct drm_local_map bios_map;
	uint8_t __iomem *bios;
	resource_size_t vram_base;
	resource_size_t size = 256 * 1024; /* ??? */

	DRM_INFO("%s: ===> Try IGP's VRAM...\n", __func__);

	if (!(rdev->flags & RADEON_IS_IGP))
		if (!radeon_card_posted(rdev)) {
			DRM_INFO("%s: not POSTed discrete card detected, skipping this method...\n",
			    __func__);
			return false;
		}

	rdev->bios = NULL;
	vram_base = drm_get_resource_start(rdev->ddev, 0);
	DRM_INFO("%s: VRAM base address: 0x%jx\n", __func__, (uintmax_t)vram_base);

	bios_map.offset = vram_base;
	bios_map.size   = size;
	bios_map.type   = 0;
	bios_map.flags  = 0;
	bios_map.mtrr   = 0;
	drm_core_ioremap(&bios_map, rdev->ddev);
	if (bios_map.handle == NULL) {
		DRM_INFO("%s: failed to ioremap\n", __func__);
		return false;
	}
	bios = bios_map.handle;
	size = bios_map.size;
	DRM_INFO("%s: Map address: %p (%ju bytes)\n", __func__, bios, (uintmax_t)size);

	if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) {
		if (size == 0) {
			DRM_INFO("%s: Incorrect BIOS size\n", __func__);
		} else {
			DRM_INFO("%s: Incorrect BIOS signature: 0x%02X%02X\n",
			    __func__, bios[0], bios[1]);
		}
		drm_core_ioremapfree(&bios_map, rdev->ddev);
		return false;
	}
	rdev->bios = malloc(size, DRM_MEM_DRIVER, M_NOWAIT);
	if (rdev->bios == NULL) {
		drm_core_ioremapfree(&bios_map, rdev->ddev);
		return false;
	}
	memcpy_fromio(rdev->bios, bios, size);
	drm_core_ioremapfree(&bios_map, rdev->ddev);
	return true;
}
static int savage_do_cleanup_bci(struct drm_device * dev)
{
	drm_savage_private_t *dev_priv = dev->dev_private;

	if (dev_priv->cmd_dma == &dev_priv->fake_dma) {
		kfree(dev_priv->fake_dma.handle);
	} else if (dev_priv->cmd_dma && dev_priv->cmd_dma->handle &&
		   dev_priv->cmd_dma->type == _DRM_AGP &&
		   dev_priv->dma_type == SAVAGE_DMA_AGP)
		drm_core_ioremapfree(dev_priv->cmd_dma, dev);

	if (dev_priv->dma_type == SAVAGE_DMA_AGP &&
	    dev->agp_buffer_map && dev->agp_buffer_map->handle) {
		drm_core_ioremapfree(dev->agp_buffer_map, dev);
		/* make sure the next instance (which may be running
		 * in PCI mode) doesn't try to use an old
		 * agp_buffer_map. */
		dev->agp_buffer_map = NULL;
	}

	kfree(dev_priv->dma_pages);

	return 0;
}