summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-04-19 20:59:11 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-04-19 20:59:11 +0000
commit994f435dff0deaed38be43fd4e8de1efe2b6fc36 (patch)
treecdd8d39b4a08345031ab6ec05bca9c95ce6421c1 /sys/dev/pci/drm
parentd4e77e708d19a8e182726ac36dc1accfa0579726 (diff)
calculate size correctly if PAGE_SIZE != ATI_PCIGART_PAGE_SIZE.
from upstream a while back.
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r--sys/dev/pci/drm/ati_pcigart.c15
1 files changed, 8 insertions, 7 deletions
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);