From 994f435dff0deaed38be43fd4e8de1efe2b6fc36 Mon Sep 17 00:00:00 2001 From: Owain Ainsworth Date: Sun, 19 Apr 2009 20:59:11 +0000 Subject: calculate size correctly if PAGE_SIZE != ATI_PCIGART_PAGE_SIZE. from upstream a while back. --- sys/dev/pci/drm/ati_pcigart.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'sys/dev/pci/drm') diff --git a/sys/dev/pci/drm/ati_pcigart.c b/sys/dev/pci/drm/ati_pcigart.c index 77f3450626c..9290ef3327b 100644 --- a/sys/dev/pci/drm/ati_pcigart.c +++ b/sys/dev/pci/drm/ati_pcigart.c @@ -96,7 +96,7 @@ drm_ati_pcigart_init(struct drm_device *dev, u_int32_t *pci_gart; bus_addr_t entry_addr; - u_long pages, max_pages; + u_long pages, max_ati_pages, max_real_pages; int i, j, ret; /* we need to support large memory configurations */ @@ -130,13 +130,14 @@ drm_ati_pcigart_init(struct drm_device *dev, (unsigned int)bus_address, (unsigned long)address); } - pci_gart = (u_int32_t *) gart_info->addr; + pci_gart = (u_int32_t *)gart_info->addr; - max_pages = (gart_info->table_size / sizeof(u_int32_t)); - pages = (dev->sg->mem->map->dm_nsegs <= max_pages) ? - dev->sg->mem->map->dm_nsegs : max_pages; + max_ati_pages = (gart_info->table_size / sizeof(u_int32_t)); + max_real_pages = max_ati_pages / (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); + pages = (dev->sg->mem->map->dm_nsegs <= max_real_pages) ? + dev->sg->mem->map->dm_nsegs : max_real_pages; - memset(pci_gart, 0, max_pages * sizeof(u32)); + memset(pci_gart, 0, max_ati_pages * sizeof(u_int32_t)); KASSERT(PAGE_SIZE >= ATI_PCIGART_PAGE_SIZE); @@ -151,7 +152,7 @@ drm_ati_pcigart_init(struct drm_device *dev, return (0); - error: +error: gart_info->addr = NULL; gart_info->bus_addr = 0; return (ret); -- cgit v1.2.3