Exemplo n.º 1
0
void radeon_agp_fini(struct radeon_device *rdev)
{
#if __OS_HAS_AGP
    if (rdev->ddev->agp && rdev->ddev->agp->acquired) {
        drm_agp_release(rdev->ddev);
    }
#endif
}
Exemplo n.º 2
0
int drm_agp_release_ioctl(struct inode *inode, struct file *filp,
			  unsigned int cmd, unsigned long arg)
{
	drm_file_t *priv = filp->private_data;
	drm_device_t *dev = priv->head->dev;
	
	return drm_agp_release(dev);
}
Exemplo n.º 3
0
void
nouveau_agp_fini(struct nouveau_drm *drm)
{
#if __OS_HAS_AGP
	struct drm_device *dev = drm->dev;
	if (dev->agp && dev->agp->acquired)
		drm_agp_release(dev);
#endif
}
Exemplo n.º 4
0
int drm_agp_release_ioctl(struct drm_device *dev, void *data,
			  struct drm_file *file_priv)
{

	return drm_agp_release(dev);
}
Exemplo n.º 5
0
int radeon_agp_init(struct radeon_device *rdev)
{
#if __OS_HAS_AGP
    struct radeon_agpmode_quirk *p = radeon_agpmode_quirk_list;
    struct drm_agp_mode mode;
    struct drm_agp_info info;
    uint32_t agp_status;
    int default_mode;
    bool is_v3;
    int ret;

    /* Acquire AGP. */
    if (!rdev->ddev->agp->acquired) {
        ret = drm_agp_acquire(rdev->ddev);
        if (ret) {
            DRM_ERROR("Unable to acquire AGP: %d\n", ret);
            return ret;
        }
    }

    ret = drm_agp_info(rdev->ddev, &info);
    if (ret) {
        drm_agp_release(rdev->ddev);
        DRM_ERROR("Unable to get AGP info: %d\n", ret);
        return ret;
    }

    if (rdev->ddev->agp->agp_info.aper_size < 32) {
        drm_agp_release(rdev->ddev);
        dev_warn(rdev->dev, "AGP aperture too small (%zuM) "
                 "need at least 32M, disabling AGP\n",
                 rdev->ddev->agp->agp_info.aper_size);
        return -EINVAL;
    }

    mode.mode = info.mode;
    agp_status = (RREG32(RADEON_AGP_STATUS) | RADEON_AGPv3_MODE) & mode.mode;
    is_v3 = !!(agp_status & RADEON_AGPv3_MODE);

    if (is_v3) {
        default_mode = (agp_status & RADEON_AGPv3_8X_MODE) ? 8 : 4;
    } else {
        if (agp_status & RADEON_AGP_4X_MODE) {
            default_mode = 4;
        } else if (agp_status & RADEON_AGP_2X_MODE) {
            default_mode = 2;
        } else {
            default_mode = 1;
        }
    }

    /* Apply AGPMode Quirks */
    while (p && p->chip_device != 0) {
        if (info.id_vendor == p->hostbridge_vendor &&
                info.id_device == p->hostbridge_device &&
                rdev->pdev->vendor == p->chip_vendor &&
                rdev->pdev->device == p->chip_device &&
                rdev->pdev->subsystem_vendor == p->subsys_vendor &&
                rdev->pdev->subsystem_device == p->subsys_device) {
            default_mode = p->default_mode;
        }
        ++p;
    }

    if (radeon_agpmode > 0) {
        if ((radeon_agpmode < (is_v3 ? 4 : 1)) ||
                (radeon_agpmode > (is_v3 ? 8 : 4)) ||
                (radeon_agpmode & (radeon_agpmode - 1))) {
            DRM_ERROR("Illegal AGP Mode: %d (valid %s), leaving at %d\n",
                      radeon_agpmode, is_v3 ? "4, 8" : "1, 2, 4",
                      default_mode);
            radeon_agpmode = default_mode;
        } else {
            DRM_INFO("AGP mode requested: %d\n", radeon_agpmode);
        }
    } else {
        radeon_agpmode = default_mode;
    }

    mode.mode &= ~RADEON_AGP_MODE_MASK;
    if (is_v3) {
        switch (radeon_agpmode) {
        case 8:
            mode.mode |= RADEON_AGPv3_8X_MODE;
            break;
        case 4:
        default:
            mode.mode |= RADEON_AGPv3_4X_MODE;
            break;
        }
    } else {
        switch (radeon_agpmode) {
        case 4:
            mode.mode |= RADEON_AGP_4X_MODE;
            break;
        case 2:
            mode.mode |= RADEON_AGP_2X_MODE;
            break;
        case 1:
        default:
            mode.mode |= RADEON_AGP_1X_MODE;
            break;
        }
    }

    mode.mode &= ~RADEON_AGP_FW_MODE; /* disable fw */
    ret = drm_agp_enable(rdev->ddev, mode);
    if (ret) {
        DRM_ERROR("Unable to enable AGP (mode = 0x%lx)\n", mode.mode);
        drm_agp_release(rdev->ddev);
        return ret;
    }

    rdev->mc.agp_base = rdev->ddev->agp->agp_info.aper_base;
    rdev->mc.gtt_size = rdev->ddev->agp->agp_info.aper_size << 20;

    /* workaround some hw issues */
    if (rdev->family < CHIP_R200) {
        WREG32(RADEON_AGP_CNTL, RREG32(RADEON_AGP_CNTL) | 0x000e0000);
    }
    return 0;
#else
    return 0;
#endif
}
Exemplo n.º 6
0
/**
 * Take down the DRM device.
 *
 * \param dev DRM device structure.
 *
 * Frees every resource in \p dev.
 *
 * \sa drm_device
 */
int drm_lastclose(drm_device_t * dev)
{
	drm_magic_entry_t *pt, *next;
	drm_map_list_t *r_list;
	drm_vma_entry_t *vma, *vma_next;
	int i;

	DRM_DEBUG("\n");

	if (dev->driver->lastclose)
		dev->driver->lastclose(dev);
	DRM_DEBUG("driver lastclose completed\n");

	if (dev->unique) {
		drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER);
		dev->unique=NULL;
		dev->unique_len=0;
	}

	if (dev->irq_enabled)
		drm_irq_uninstall(dev);

	down(&dev->struct_sem);
	del_timer(&dev->timer);

	if (dev->unique) {
		drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER);
		dev->unique = NULL;
		dev->unique_len = 0;
	}

	/* Clear pid list */
	for (i = 0; i < DRM_HASH_SIZE; i++) {
		for (pt = dev->magiclist[i].head; pt; pt = next) {
			next = pt->next;
			drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
		}
		dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
	}

	/* Clear AGP information */
	if (drm_core_has_AGP(dev) && dev->agp) {
		drm_agp_mem_t *entry;
		drm_agp_mem_t *nexte;

		/* Remove AGP resources, but leave dev->agp
		   intact until drv_cleanup is called. */
		for (entry = dev->agp->memory; entry; entry = nexte) {
			nexte = entry->next;
			if (entry->bound)
				drm_unbind_agp(entry->memory);
			drm_free_agp(entry->memory, entry->pages);
			drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
		}
		dev->agp->memory = NULL;

		if (dev->agp->acquired)
			drm_agp_release(dev);

		dev->agp->acquired = 0;
		dev->agp->enabled = 0;
	}
	if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg) {
		drm_sg_cleanup(dev->sg);
		dev->sg = NULL;
	}

	/* Clear vma list (only built for debugging) */
	if (dev->vmalist) {
		for (vma = dev->vmalist; vma; vma = vma_next) {
			vma_next = vma->next;
			drm_free(vma, sizeof(*vma), DRM_MEM_VMAS);
		}
		dev->vmalist = NULL;
	}

	if (dev->maplist) {
		while (!list_empty(&dev->maplist->head)) {
			struct list_head *list = dev->maplist->head.next;
			r_list = list_entry(list, drm_map_list_t, head);
			drm_rmmap_locked(dev, r_list->map);
		}
	}

	if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) {
		for (i = 0; i < dev->queue_count; i++) {

			if (dev->queuelist[i]) {
				drm_free(dev->queuelist[i],
					 sizeof(*dev->queuelist[0]),
					 DRM_MEM_QUEUES);
				dev->queuelist[i] = NULL;
			}
		}
		drm_free(dev->queuelist,
			 dev->queue_slots * sizeof(*dev->queuelist),
			 DRM_MEM_QUEUES);
		dev->queuelist = NULL;
	}
	dev->queue_count = 0;

	if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
		drm_dma_takedown(dev);

	if (dev->lock.hw_lock) {
		dev->sigdata.lock = dev->lock.hw_lock = NULL;	/* SHM removed */
		dev->lock.filp = NULL;
		wake_up_interruptible(&dev->lock.lock_queue);
	}
	up(&dev->struct_sem);

	DRM_DEBUG("lastclose completed\n");
	return 0;
}
Exemplo n.º 7
0
int drm_agp_release_ioctl(DRM_IOCTL_ARGS)
{
	DRM_DEVICE;

	return drm_agp_release(dev);
}