drm: add modesetting as a driver feature.
This change adds a driver feature that for i915 is controlled by a module parameter. You now need to do insmod i915.ko modeset=1 to enable it the modesetting paths. It also fixes up lots of X paths. I can run my new DDX driver on this code with and without modesetting enabledmain
parent
132ba667f4
commit
01dcc47d89
|
@ -106,6 +106,7 @@ struct drm_file;
|
|||
#define DRIVER_IRQ_SHARED 0x80
|
||||
#define DRIVER_DMA_QUEUE 0x100
|
||||
#define DRIVER_FB_DMA 0x200
|
||||
#define DRIVER_MODESET 0x400
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
|
|
@ -414,6 +414,7 @@ static void drm_cleanup(struct drm_device * dev)
|
|||
drm_ht_remove(&dev->object_hash);
|
||||
|
||||
drm_put_minor(&dev->primary);
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
drm_put_minor(&dev->control);
|
||||
if (drm_put_dev(dev))
|
||||
DRM_ERROR("Cannot unload module\n");
|
||||
|
|
|
@ -481,6 +481,7 @@ int drm_release(struct inode *inode, struct file *filp)
|
|||
}
|
||||
mutex_unlock(&dev->ctxlist_mutex);
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
drm_fb_release(filp);
|
||||
|
||||
file_priv->master = NULL;
|
||||
|
|
|
@ -261,6 +261,9 @@ int drm_irq_uninstall(struct drm_device * dev)
|
|||
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
|
||||
return -EINVAL;
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
return 0;
|
||||
|
||||
mutex_lock(&dev->struct_mutex);
|
||||
irq_enabled = dev->irq_enabled;
|
||||
dev->irq_enabled = 0;
|
||||
|
@ -306,6 +309,8 @@ int drm_control(struct drm_device *dev, void *data,
|
|||
case DRM_INST_HANDLER:
|
||||
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
|
||||
return 0;
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
return 0;
|
||||
if (dev->if_version < DRM_IF_VERSION(1, 2) &&
|
||||
ctl->irq != dev->irq)
|
||||
return -EINVAL;
|
||||
|
|
|
@ -343,6 +343,8 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
|
|||
goto err_g3;
|
||||
}
|
||||
|
||||
/* only add the control node on a modesetting platform */
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
if ((ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL)))
|
||||
goto err_g3;
|
||||
|
||||
|
@ -361,6 +363,7 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
|
|||
err_g5:
|
||||
drm_put_minor(&dev->primary);
|
||||
err_g4:
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
drm_put_minor(&dev->control);
|
||||
err_g3:
|
||||
if (!drm_fb_loaded)
|
||||
|
|
|
@ -39,6 +39,9 @@ static struct pci_device_id pciidlist[] = {
|
|||
i915_PCI_IDS
|
||||
};
|
||||
|
||||
unsigned int i915_modeset = 0;
|
||||
module_param_named(modeset, i915_modeset, int, 0400);
|
||||
|
||||
#ifdef I915_HAVE_FENCE
|
||||
extern struct drm_fence_driver i915_fence_driver;
|
||||
#endif
|
||||
|
@ -563,8 +566,8 @@ static struct drm_driver driver = {
|
|||
DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
|
||||
.load = i915_driver_load,
|
||||
.unload = i915_driver_unload,
|
||||
/* .lastclose = i915_driver_lastclose,
|
||||
.preclose = i915_driver_preclose, */
|
||||
.lastclose = i915_driver_lastclose,
|
||||
.preclose = i915_driver_preclose,
|
||||
.suspend = i915_suspend,
|
||||
.resume = i915_resume,
|
||||
.device_is_agp = i915_driver_device_is_agp,
|
||||
|
@ -624,6 +627,9 @@ static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
static int __init i915_init(void)
|
||||
{
|
||||
driver.num_ioctls = i915_max_ioctl;
|
||||
if (i915_modeset == 1)
|
||||
driver.driver_features |= DRIVER_MODESET;
|
||||
|
||||
return drm_init(&driver, pciidlist);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,11 @@ void i915_kernel_lost_context(struct drm_device * dev)
|
|||
struct drm_i915_private *dev_priv = dev->dev_private;
|
||||
struct drm_i915_ring_buffer *ring = &(dev_priv->ring);
|
||||
|
||||
/* we should never lose context on the ring with modesetting
|
||||
* as we don't expose it to userspace */
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
return;
|
||||
|
||||
ring->head = I915_READ(LP_RING + RING_HEAD) & HEAD_ADDR;
|
||||
ring->tail = I915_READ(LP_RING + RING_TAIL) & TAIL_ADDR;
|
||||
ring->space = ring->head - (ring->tail + 8);
|
||||
|
@ -75,6 +80,11 @@ void i915_kernel_lost_context(struct drm_device * dev)
|
|||
|
||||
int i915_dma_cleanup(struct drm_device * dev)
|
||||
{
|
||||
struct drm_i915_private *dev_priv = dev->dev_private;
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
return 0;
|
||||
|
||||
/* Make sure interrupts are disabled here because the uninstall ioctl
|
||||
* may not have been called from userspace and after dev_private
|
||||
* is freed, it's too late.
|
||||
|
@ -82,6 +92,28 @@ int i915_dma_cleanup(struct drm_device * dev)
|
|||
if (dev->irq)
|
||||
drm_irq_uninstall(dev);
|
||||
|
||||
if (dev_priv->ring.virtual_start) {
|
||||
drm_core_ioremapfree(&dev_priv->ring.map, dev);
|
||||
dev_priv->ring.virtual_start = 0;
|
||||
dev_priv->ring.map.handle = 0;
|
||||
dev_priv->ring.map.size = 0;
|
||||
dev_priv->ring.Size = 0;
|
||||
}
|
||||
|
||||
if (dev_priv->status_page_dmah) {
|
||||
drm_pci_free(dev, dev_priv->status_page_dmah);
|
||||
dev_priv->status_page_dmah = NULL;
|
||||
/* Need to rewrite hardware status page */
|
||||
I915_WRITE(0x02080, 0x1ffff000);
|
||||
}
|
||||
|
||||
if (dev_priv->status_gfx_addr) {
|
||||
dev_priv->status_gfx_addr = 0;
|
||||
drm_core_ioremapfree(&dev_priv->hws_map, dev);
|
||||
I915_WRITE(0x02080, 0x1ffff000);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -153,12 +185,16 @@ static int i915_initialize(struct drm_device * dev,
|
|||
struct drm_i915_private *dev_priv = dev->dev_private;
|
||||
struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
|
||||
|
||||
if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
|
||||
if (init->mmio_offset != 0)
|
||||
dev_priv->mmio_map = drm_core_findmap(dev, init->mmio_offset);
|
||||
if (!dev_priv->mmio_map) {
|
||||
i915_dma_cleanup(dev);
|
||||
DRM_ERROR("can not find mmio map!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef I915_HAVE_BUFFER
|
||||
dev_priv->max_validate_buffers = I915_MAX_VALIDATE_BUFFERS;
|
||||
|
@ -246,6 +282,9 @@ static int i915_dma_resume(struct drm_device * dev)
|
|||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
return 0;
|
||||
|
||||
if (!dev_priv->mmio_map) {
|
||||
DRM_ERROR("can not find mmio map!\n");
|
||||
return -EINVAL;
|
||||
|
|
|
@ -153,17 +153,24 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
|
|||
DRM_DEBUG("fb_base: 0x%08lx\n", dev->mode_config.fb_base);
|
||||
|
||||
ret = drm_addmap(dev, dev_priv->mmiobase, dev_priv->mmiolen,
|
||||
_DRM_REGISTERS, _DRM_READ_ONLY|_DRM_DRIVER, &dev_priv->mmio_map);
|
||||
_DRM_REGISTERS, _DRM_KERNEL|_DRM_READ_ONLY|_DRM_DRIVER, &dev_priv->mmio_map);
|
||||
if (ret != 0) {
|
||||
DRM_ERROR("Cannot add mapping for MMIO registers\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
|
||||
intel_init_chipset_flush_compat(dev);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialize the memory manager for local and AGP space
|
||||
*/
|
||||
drm_bo_driver_init(dev);
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
|
||||
i915_probe_agp(dev->pdev, &agp_size, &prealloc_size);
|
||||
printk("setting up %ld bytes of VRAM space\n", prealloc_size);
|
||||
printk("setting up %ld bytes of TT space\n", (agp_size - prealloc_size));
|
||||
|
@ -244,7 +251,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
|
|||
DRM_DEBUG("Error\n");
|
||||
}
|
||||
|
||||
|
||||
intel_modeset_init(dev);
|
||||
drm_initial_config(dev, false);
|
||||
|
||||
|
@ -252,6 +258,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
|
|||
drm_mm_print(&dev->bm.man[DRM_BO_MEM_TT].manager, "TT");
|
||||
|
||||
drm_irq_install(dev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -262,7 +269,10 @@ int i915_driver_unload(struct drm_device *dev)
|
|||
|
||||
I915_WRITE(LP_RING + RING_LEN, 0);
|
||||
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
|
||||
intel_modeset_cleanup(dev);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (dev_priv->ring.virtual_start) {
|
||||
|
@ -298,6 +308,7 @@ int i915_driver_unload(struct drm_device *dev)
|
|||
I915_WRITE(I915REG_HWS_PGA, 0x1ffff000);
|
||||
}
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
|
||||
drm_mem_reg_iounmap(dev, &dev_priv->ring_buffer->mem,
|
||||
dev_priv->ring.virtual_start);
|
||||
|
||||
|
@ -314,9 +325,16 @@ int i915_driver_unload(struct drm_device *dev)
|
|||
"Delaying takedown\n");
|
||||
}
|
||||
mutex_unlock(&dev->struct_mutex);
|
||||
}
|
||||
|
||||
drm_bo_driver_finish(dev);
|
||||
|
||||
#ifdef __linux__
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
|
||||
intel_init_chipset_flush_compat(dev);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
DRM_DEBUG("%p\n", dev_priv->mmio_map);
|
||||
drm_rmmap(dev, dev_priv->mmio_map);
|
||||
|
||||
|
@ -363,3 +381,23 @@ void i915_master_destroy(struct drm_device *dev, struct drm_master *master)
|
|||
|
||||
master->driver_priv = NULL;
|
||||
}
|
||||
|
||||
void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
|
||||
{
|
||||
struct drm_i915_private *dev_priv = dev->dev_private;
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
i915_mem_release(dev, file_priv, dev_priv->agp_heap);
|
||||
}
|
||||
|
||||
void i915_driver_lastclose(struct drm_device * dev)
|
||||
{
|
||||
struct drm_i915_private *dev_priv = dev->dev_private;
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
return;
|
||||
|
||||
if (dev_priv->agp_heap)
|
||||
i915_mem_takedown(&(dev_priv->agp_heap));
|
||||
|
||||
i915_dma_cleanup(dev);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue