[Intel-gfx] [PATCH] make KMS resource mappings exclusive
Jesse Barnes
jbarnes at virtuousgeek.org
Mon Jan 19 22:00:25 CET 2009
This should help avoid problems with unsupported userspace programs or
configurations running on top of a KMS enabled driver. Updates the
ioremap to nocache as well, since that's really what we want to track.
Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index cde5a1f..6e60671 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -932,9 +932,15 @@ static int i915_load_modeset_init(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
unsigned long agp_size, prealloc_size;
- int fb_bar = IS_I9XX(dev) ? 2 : 0;
+ int fb_bar = IS_I9XX(dev) ? 2 : 0, mmio_bar = IS_I9XX(dev) ? 0 : 1;
int ret = 0;
+ if (pci_request_region_exclusive(dev->pdev, mmio_bar, "i915 regs")) {
+ DRM_ERROR("i915 regs already mapped, aborting\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
dev->devname = kstrdup(DRIVER_NAME, GFP_KERNEL);
if (!dev->devname) {
ret = -ENOMEM;
@@ -1067,7 +1073,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
base = drm_get_resource_start(dev, mmio_bar);
size = drm_get_resource_len(dev, mmio_bar);
- dev_priv->regs = ioremap(base, size);
+ dev_priv->regs = ioremap_nocache(base, size);
if (!dev_priv->regs) {
DRM_ERROR("failed to map registers\n");
ret = -EIO;
@@ -1137,6 +1143,7 @@ free_priv:
int i915_driver_unload(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
+ int mmio_bar = IS_I9XX(dev) ? 0 : 1;
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
io_mapping_free(dev_priv->mm.gtt_mapping);
@@ -1153,6 +1160,7 @@ int i915_driver_unload(struct drm_device *dev)
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
intel_modeset_cleanup(dev);
+ pci_release_region(dev->pdev, mmio_bar);
i915_gem_free_all_phys_object(dev);
More information about the Intel-gfx
mailing list