Skip to content

Commit

Permalink
agp/intel: Remove confusion of stolen entries not stolen memory
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
  • Loading branch information
Chris Wilson committed Nov 23, 2010
1 parent 1b6064d commit c64f7ba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 42 deletions.
40 changes: 7 additions & 33 deletions drivers/char/agp/intel-gtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,26 +477,17 @@ static const struct aper_size_info_fixed const intel_fake_agp_sizes[] = {
{512, 131072, 7},
};

static unsigned int intel_gtt_stolen_entries(void)
static unsigned int intel_gtt_stolen_size(void)
{
u16 gmch_ctrl;
u8 rdct;
int local = 0;
static const int ddt[4] = { 0, 16, 32, 64 };
unsigned int overhead_entries;
unsigned int stolen_size = 0;

pci_read_config_word(intel_private.bridge_dev,
I830_GMCH_CTRL, &gmch_ctrl);

if (INTEL_GTT_GEN > 4 || IS_PINEVIEW)
overhead_entries = 0;
else
overhead_entries = intel_private.base.gtt_mappable_entries
/ 1024;

overhead_entries += 1; /* BIOS popup */

if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
Expand Down Expand Up @@ -631,7 +622,7 @@ static unsigned int intel_gtt_stolen_entries(void)
stolen_size = 0;
}

return stolen_size/KB(4) - overhead_entries;
return stolen_size;
}

static void i965_adjust_pgetbl_size(unsigned int size_flag)
Expand Down Expand Up @@ -817,8 +808,8 @@ static int intel_gtt_init(void)
global_cache_flush(); /* FIXME: ? */

/* we have to call this as early as possible after the MMIO base address is known */
intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries();
if (intel_private.base.gtt_stolen_entries == 0) {
intel_private.base.stolen_size = intel_gtt_stolen_size();
if (intel_private.base.stolen_size == 0) {
intel_private.driver->cleanup();
iounmap(intel_private.registers);
iounmap(intel_private.gtt);
Expand Down Expand Up @@ -1006,8 +997,7 @@ static int intel_fake_agp_configure(void)

agp_bridge->gart_bus_addr = intel_private.gma_bus_addr;

for (i = intel_private.base.gtt_stolen_entries;
i < intel_private.base.gtt_total_entries; i++) {
for (i = 0; i < intel_private.base.gtt_total_entries; i++) {
intel_private.driver->write_entry(intel_private.scratch_page_dma,
i, 0);
}
Expand Down Expand Up @@ -1065,17 +1055,7 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem,
if (mem->page_count == 0)
goto out;

if (pg_start < intel_private.base.gtt_stolen_entries) {
dev_printk(KERN_DEBUG, &intel_private.pcidev->dev,
"pg_start == 0x%.8lx, gtt_stolen_entries == 0x%.8x\n",
pg_start, intel_private.base.gtt_stolen_entries);

dev_info(&intel_private.pcidev->dev,
"trying to insert into local/stolen memory\n");
goto out_err;
}

if ((pg_start + mem->page_count) > intel_private.base.gtt_total_entries)
if (pg_start + mem->page_count > intel_private.base.gtt_total_entries)
goto out_err;

if (type != mem->type)
Expand Down Expand Up @@ -1118,12 +1098,6 @@ static int intel_fake_agp_remove_entries(struct agp_memory *mem,
if (mem->page_count == 0)
return 0;

if (pg_start < intel_private.base.gtt_stolen_entries) {
dev_info(&intel_private.pcidev->dev,
"trying to disable local/stolen memory\n");
return -EINVAL;
}

if (USE_PCI_DMA_API && INTEL_GTT_GEN > 2)
intel_agp_unmap_memory(mem);

Expand Down Expand Up @@ -1629,7 +1603,7 @@ int intel_gmch_probe(struct pci_dev *pdev,
}
EXPORT_SYMBOL(intel_gmch_probe);

struct intel_gtt *intel_gtt_get(void)
const struct intel_gtt *intel_gtt_get(void)
{
return &intel_private.base;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/i915/i915_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ static unsigned long i915_stolen_to_phys(struct drm_device *dev, u32 offset)
pci_read_config_byte(pdev, 0x9c, &val);
base = val >> 3 << 27;
}
base -= dev_priv->mm.gtt->gtt_stolen_entries << PAGE_SHIFT;
base -= dev_priv->mm.gtt->stolen_size;
#endif

return base + offset;
Expand Down Expand Up @@ -1168,7 +1168,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
unsigned long prealloc_size, gtt_size, mappable_size;
int ret = 0;

prealloc_size = dev_priv->mm.gtt->gtt_stolen_entries << PAGE_SHIFT;
prealloc_size = dev_priv->mm.gtt->stolen_size;
gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT;
mappable_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/i915_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ typedef struct drm_i915_private {

struct {
/** Bridge to intel-gtt-ko */
struct intel_gtt *gtt;
const struct intel_gtt *gtt;
/** Memory allocator for GTT stolen memory */
struct drm_mm stolen;
/** Memory allocator for GTT */
Expand Down
11 changes: 5 additions & 6 deletions include/drm/intel-gtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

#ifndef _DRM_INTEL_GTT_H
#define _DRM_INTEL_GTT_H
struct intel_gtt {
/* Number of stolen gtt entries at the beginning. */
unsigned int gtt_stolen_entries;

const struct intel_gtt {
/* Size of memory reserved for graphics by the BIOS */
unsigned int stolen_size;
/* Total number of gtt entries. */
unsigned int gtt_total_entries;
/* Part of the gtt that is mappable by the cpu, for those chips where
* this is not the full gtt. */
unsigned int gtt_mappable_entries;
};

struct intel_gtt *intel_gtt_get(void);
} *intel_gtt_get(void);

#endif

0 comments on commit c64f7ba

Please sign in to comment.