diff options
author | anholt <anholt@FreeBSD.org> | 2004-08-21 06:24:21 +0000 |
---|---|---|
committer | anholt <anholt@FreeBSD.org> | 2004-08-21 06:24:21 +0000 |
commit | 1095443edbb84334ef9b49955f2116afed0713b4 (patch) | |
tree | 9367643e25e5b1dc1e5685ceef2aba74692bb4dc | |
parent | bab63472f83a82fb9c3d660dca31ffc7034a09f2 (diff) | |
download | FreeBSD-src-1095443edbb84334ef9b49955f2116afed0713b4.zip FreeBSD-src-1095443edbb84334ef9b49955f2116afed0713b4.tar.gz |
Fix aperture size detection on some ALi chipsets by only using the lowest 4 bits
to check aperture size, avoiding hangs. Maintain the rest of the bits when
setting/unsetting ATTBASE. This essentially matches Linux's AGP driver as well.
PR: kern/70037
Submitted by: Mark Tinguely <tinguely at casselton dot net>
Obtained from: NetBSD
-rw-r--r-- | sys/dev/agp/agp_ali.c | 8 | ||||
-rw-r--r-- | sys/pci/agp_ali.c | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/sys/dev/agp/agp_ali.c b/sys/dev/agp/agp_ali.c index 67debd5..b36db9d 100644 --- a/sys/dev/agp/agp_ali.c +++ b/sys/dev/agp/agp_ali.c @@ -129,7 +129,7 @@ agp_ali_attach(device_t dev) /* Install the gatt. */ attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4); pci_write_config(dev, AGP_ALI_ATTBASE, gatt->ag_physical | - (attbase & 0xff), 4); + (attbase & 0xfff), 4); /* Enable the TLB. */ pci_write_config(dev, AGP_ALI_TLBCTRL, 0x10, 1); @@ -154,7 +154,7 @@ agp_ali_detach(device_t dev) /* Put the aperture back the way it started. */ AGP_SET_APERTURE(dev, sc->initial_aperture); attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4); - pci_write_config(dev, AGP_ALI_ATTBASE, attbase & 0xff, 4); + pci_write_config(dev, AGP_ALI_ATTBASE, attbase & 0xfff, 4); agp_free_gatt(sc->gatt); return 0; @@ -184,7 +184,7 @@ agp_ali_get_aperture(device_t dev) * The aperture size is derived from the low bits of attbase. * I'm not sure this is correct.. */ - int i = pci_read_config(dev, AGP_ALI_ATTBASE, 4) & 0xff; + int i = pci_read_config(dev, AGP_ALI_ATTBASE, 4) & 0xf; if (i >= agp_ali_table_size) return 0; return agp_ali_table[i]; @@ -203,7 +203,7 @@ agp_ali_set_aperture(device_t dev, u_int32_t aperture) return EINVAL; attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4); - pci_write_config(dev, AGP_ALI_ATTBASE, (attbase & ~0xff) | i, 4); + pci_write_config(dev, AGP_ALI_ATTBASE, (attbase & ~0xf) | i, 4); return 0; } diff --git a/sys/pci/agp_ali.c b/sys/pci/agp_ali.c index 67debd5..b36db9d 100644 --- a/sys/pci/agp_ali.c +++ b/sys/pci/agp_ali.c @@ -129,7 +129,7 @@ agp_ali_attach(device_t dev) /* Install the gatt. */ attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4); pci_write_config(dev, AGP_ALI_ATTBASE, gatt->ag_physical | - (attbase & 0xff), 4); + (attbase & 0xfff), 4); /* Enable the TLB. */ pci_write_config(dev, AGP_ALI_TLBCTRL, 0x10, 1); @@ -154,7 +154,7 @@ agp_ali_detach(device_t dev) /* Put the aperture back the way it started. */ AGP_SET_APERTURE(dev, sc->initial_aperture); attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4); - pci_write_config(dev, AGP_ALI_ATTBASE, attbase & 0xff, 4); + pci_write_config(dev, AGP_ALI_ATTBASE, attbase & 0xfff, 4); agp_free_gatt(sc->gatt); return 0; @@ -184,7 +184,7 @@ agp_ali_get_aperture(device_t dev) * The aperture size is derived from the low bits of attbase. * I'm not sure this is correct.. */ - int i = pci_read_config(dev, AGP_ALI_ATTBASE, 4) & 0xff; + int i = pci_read_config(dev, AGP_ALI_ATTBASE, 4) & 0xf; if (i >= agp_ali_table_size) return 0; return agp_ali_table[i]; @@ -203,7 +203,7 @@ agp_ali_set_aperture(device_t dev, u_int32_t aperture) return EINVAL; attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4); - pci_write_config(dev, AGP_ALI_ATTBASE, (attbase & ~0xff) | i, 4); + pci_write_config(dev, AGP_ALI_ATTBASE, (attbase & ~0xf) | i, 4); return 0; } |