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
This commit is contained in:
parent
74674ea7f2
commit
8c9610c9fe
@ -129,7 +129,7 @@ agp_ali_attach(device_t dev)
|
|||||||
/* Install the gatt. */
|
/* Install the gatt. */
|
||||||
attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
|
attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
|
||||||
pci_write_config(dev, AGP_ALI_ATTBASE, gatt->ag_physical |
|
pci_write_config(dev, AGP_ALI_ATTBASE, gatt->ag_physical |
|
||||||
(attbase & 0xff), 4);
|
(attbase & 0xfff), 4);
|
||||||
|
|
||||||
/* Enable the TLB. */
|
/* Enable the TLB. */
|
||||||
pci_write_config(dev, AGP_ALI_TLBCTRL, 0x10, 1);
|
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. */
|
/* Put the aperture back the way it started. */
|
||||||
AGP_SET_APERTURE(dev, sc->initial_aperture);
|
AGP_SET_APERTURE(dev, sc->initial_aperture);
|
||||||
attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
|
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);
|
agp_free_gatt(sc->gatt);
|
||||||
return 0;
|
return 0;
|
||||||
@ -184,7 +184,7 @@ agp_ali_get_aperture(device_t dev)
|
|||||||
* The aperture size is derived from the low bits of attbase.
|
* The aperture size is derived from the low bits of attbase.
|
||||||
* I'm not sure this is correct..
|
* 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)
|
if (i >= agp_ali_table_size)
|
||||||
return 0;
|
return 0;
|
||||||
return agp_ali_table[i];
|
return agp_ali_table[i];
|
||||||
@ -203,7 +203,7 @@ agp_ali_set_aperture(device_t dev, u_int32_t aperture)
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ agp_ali_attach(device_t dev)
|
|||||||
/* Install the gatt. */
|
/* Install the gatt. */
|
||||||
attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
|
attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
|
||||||
pci_write_config(dev, AGP_ALI_ATTBASE, gatt->ag_physical |
|
pci_write_config(dev, AGP_ALI_ATTBASE, gatt->ag_physical |
|
||||||
(attbase & 0xff), 4);
|
(attbase & 0xfff), 4);
|
||||||
|
|
||||||
/* Enable the TLB. */
|
/* Enable the TLB. */
|
||||||
pci_write_config(dev, AGP_ALI_TLBCTRL, 0x10, 1);
|
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. */
|
/* Put the aperture back the way it started. */
|
||||||
AGP_SET_APERTURE(dev, sc->initial_aperture);
|
AGP_SET_APERTURE(dev, sc->initial_aperture);
|
||||||
attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
|
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);
|
agp_free_gatt(sc->gatt);
|
||||||
return 0;
|
return 0;
|
||||||
@ -184,7 +184,7 @@ agp_ali_get_aperture(device_t dev)
|
|||||||
* The aperture size is derived from the low bits of attbase.
|
* The aperture size is derived from the low bits of attbase.
|
||||||
* I'm not sure this is correct..
|
* 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)
|
if (i >= agp_ali_table_size)
|
||||||
return 0;
|
return 0;
|
||||||
return agp_ali_table[i];
|
return agp_ali_table[i];
|
||||||
@ -203,7 +203,7 @@ agp_ali_set_aperture(device_t dev, u_int32_t aperture)
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
attbase = pci_read_config(dev, AGP_ALI_ATTBASE, 4);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user