diff mbox

[1/2] drm/i915: Limit the ioremap of the PCI bar to the registers

Message ID 1347620267-11275-1-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State Accepted
Headers show

Commit Message

Chris Wilson Sept. 14, 2012, 10:57 a.m. UTC
In the future we may like to experiment with using a WC map of the GTT
portion. However, that will conflict with i915.ko mapping the entire bar
as UC in order to access the GPU registers. Instead we can shrink the
register ioremap to only map the register block.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_dma.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Ben Widawsky Sept. 14, 2012, 6:50 p.m. UTC | #1
On Fri, 14 Sep 2012 11:57:46 +0100
Chris Wilson <chris@chris-wilson.co.uk> wrote:

> In the future we may like to experiment with using a WC map of the GTT
> portion. However, that will conflict with i915.ko mapping the entire bar
> as UC in order to access the GPU registers. Instead we can shrink the
> register ioremap to only map the register block.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Since I really don't want to pull out docs for anything less than
gen6...
Tested-by (IVB): Ben Widawsky <ben@bwidawsk.net>
Acked-by: Ben Widawsky <ben@bwidawsk.net>
Daniel Vetter Sept. 14, 2012, 9:27 p.m. UTC | #2
On Fri, Sep 14, 2012 at 11:50:30AM -0700, Ben Widawsky wrote:
> On Fri, 14 Sep 2012 11:57:46 +0100
> Chris Wilson <chris@chris-wilson.co.uk> wrote:
> 
> > In the future we may like to experiment with using a WC map of the GTT
> > portion. However, that will conflict with i915.ko mapping the entire bar
> > as UC in order to access the GPU registers. Instead we can shrink the
> > register ioremap to only map the register block.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Since I really don't want to pull out docs for anything less than
> gen6...
> Tested-by (IVB): Ben Widawsky <ben@bwidawsk.net>
> Acked-by: Ben Widawsky <ben@bwidawsk.net>

Both patches merged, with the commit message frobbed.

Thanks, Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index ee9fe72..18bb48b 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1460,7 +1460,7 @@  int i915_driver_load(struct drm_device *dev, unsigned long flags)
 {
 	struct drm_i915_private *dev_priv;
 	struct intel_device_info *info;
-	int ret = 0, mmio_bar;
+	int ret = 0, mmio_bar, mmio_size;
 	uint32_t aperture_size;
 
 	info = (struct intel_device_info *) flags;
@@ -1524,8 +1524,18 @@  int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev))
 		dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(32));
 
+	/* Restrict iomap to avoid clobbering the GTT which we want WC mapped.
+	 * Do not attempt to map the whole BAR!
+	 */
 	mmio_bar = IS_GEN2(dev) ? 1 : 0;
-	dev_priv->regs = pci_iomap(dev->pdev, mmio_bar, 0);
+	if (info->gen < 3)
+		mmio_size = 64*1024;
+	else if (info->gen < 5)
+		mmio_size = 512*1024;
+	else
+		mmio_size = 2*1024*1024;
+
+	dev_priv->regs = pci_iomap(dev->pdev, mmio_bar, mmio_size);
 	if (!dev_priv->regs) {
 		DRM_ERROR("failed to map registers\n");
 		ret = -EIO;