summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2008-07-12 17:31:07 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2008-07-12 17:31:07 +0000
commit210331eb1cf317ef7f319200d68f4a74bc4881a0 (patch)
treefa073e5dbc91380e210743c91bd7e8325cacb705
parentb1993d180a1e04dc9fc813dd8b8eeeafde798727 (diff)
Right now agp_generic_enable() is wrong. It has been since 2006. It
assumes that the display device and the agp bridge are the same device. In almost all cases this is incorrect. In order to correctly enable the agp device with the correct mode, we need to set the AGP_COMMAND register on both the display and the bridge with the right bits. Since agp is currently attaching at vga(4), due to the problems with the intel integrated graphics (a problem that I still need to solve, to be honest), for now just provide both pci_attach_args to the agp init, and get what we need from there to do the enable. This fixes the "agp bug" which i have been known to rant about, a lot. So agp radeons now work with dri without needing to be forced to pci mode. This wasn't detected before, since the only non-drm consumer of agp is the intel X driver, the i810 agp driver has its own enable function. tested by many. ok kettenis@.
-rw-r--r--sys/dev/pci/agp.c14
-rw-r--r--sys/dev/pci/agp_i810.c3
-rw-r--r--sys/dev/pci/agpvar.h6
-rw-r--r--sys/dev/pci/vga_pci.c3
4 files changed, 19 insertions, 7 deletions
diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c
index 7f35a12af09..e61894f9307 100644
--- a/sys/dev/pci/agp.c
+++ b/sys/dev/pci/agp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp.c,v 1.23 2008/07/07 07:54:48 bernd Exp $ */
+/* $OpenBSD: agp.c,v 1.24 2008/07/12 17:31:06 oga Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
* All rights reserved.
@@ -174,6 +174,9 @@ agp_attach(struct device *parent, struct device *self, void *aux)
sc->sc_pc = pa->pa_pc;
sc->sc_id = pa->pa_id;
sc->sc_dmat = pa->pa_dmat;
+ sc->sc_memt = pa->pa_memt;
+ sc->sc_vgapcitag = aaa->apa_vga_args.pa_tag;
+ sc->sc_vgapc = aaa->apa_vga_args.pa_pc;
pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_AGP,
&sc->sc_capoff, NULL);
@@ -426,7 +429,7 @@ agp_generic_enable(struct agp_softc *sc, u_int32_t mode)
pcireg_t command;
int rq, sba, fw, rate, capoff;
- if (pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_AGP,
+ if (pci_get_capability(sc->sc_vgapc, sc->sc_vgapcitag, PCI_CAP_AGP,
&capoff, NULL) == 0) {
printf("agp_generic_enable: not an AGP capable device\n");
return (-1);
@@ -434,7 +437,8 @@ agp_generic_enable(struct agp_softc *sc, u_int32_t mode)
tstatus = pci_conf_read(sc->sc_pc, sc->sc_pcitag,
sc->sc_capoff + AGP_STATUS);
- mstatus = pci_conf_read(sc->sc_pc, sc->sc_pcitag,
+ /* display agp mode */
+ mstatus = pci_conf_read(sc->sc_vgapc, sc->sc_vgapcitag,
capoff + AGP_STATUS);
/* Set RQ to the min of mode, tstatus and mstatus */
@@ -471,9 +475,11 @@ agp_generic_enable(struct agp_softc *sc, u_int32_t mode)
command = AGP_MODE_SET_FW(command, fw);
command = AGP_MODE_SET_RATE(command, rate);
command = AGP_MODE_SET_AGP(command, 1);
+
pci_conf_write(sc->sc_pc, sc->sc_pcitag,
sc->sc_capoff + AGP_COMMAND, command);
- pci_conf_write(sc->sc_pc, sc->sc_pcitag, capoff + AGP_COMMAND, command);
+ pci_conf_write(sc->sc_vgapc, sc->sc_vgapcitag, capoff + AGP_COMMAND,
+ command);
return (0);
}
diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c
index 7861bd07511..815e1506671 100644
--- a/sys/dev/pci/agp_i810.c
+++ b/sys/dev/pci/agp_i810.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp_i810.c,v 1.39 2008/07/07 07:54:48 bernd Exp $ */
+/* $OpenBSD: agp_i810.c,v 1.40 2008/07/12 17:31:06 oga Exp $ */
/* $NetBSD: agp_i810.c,v 1.15 2003/01/31 00:07:39 thorpej Exp $ */
/*-
@@ -191,6 +191,7 @@ agp_i810_attach(struct agp_softc *sc, struct pci_attach_args *pa)
/* XXXfvdl */
sc->sc_dmat = isc->vga_pa.pa_dmat;
+ sc->sc_memt = isc->vga_pa.pa_memt;
switch (PCI_PRODUCT(isc->vga_pa.pa_id)) {
case PCI_PRODUCT_INTEL_82810_IGD:
diff --git a/sys/dev/pci/agpvar.h b/sys/dev/pci/agpvar.h
index 8f80f7769eb..f363ae5e5a9 100644
--- a/sys/dev/pci/agpvar.h
+++ b/sys/dev/pci/agpvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: agpvar.h,v 1.13 2008/05/06 19:19:02 oga Exp $ */
+/* $OpenBSD: agpvar.h,v 1.14 2008/07/12 17:31:06 oga Exp $ */
/* $NetBSD: agpvar.h,v 1.4 2001/10/01 21:54:48 fvdl Exp $ */
/*-
@@ -45,6 +45,7 @@
struct agpbus_attach_args {
struct pci_attach_args apa_pci_args;
+ struct pci_attach_args apa_vga_args;
};
enum agp_acquire_state {
@@ -134,6 +135,9 @@ struct agp_softc {
pcireg_t sc_id;
pci_chipset_tag_t sc_pc;
+ pci_chipset_tag_t sc_vgapc;
+ pcitag_t sc_vgapcitag;
+
struct agp_methods *sc_methods;
void *sc_chipc; /* chipset-dependent state */
diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c
index 3142f136510..7d4413c86b5 100644
--- a/sys/dev/pci/vga_pci.c
+++ b/sys/dev/pci/vga_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vga_pci.c,v 1.33 2008/06/12 00:58:47 oga Exp $ */
+/* $OpenBSD: vga_pci.c,v 1.34 2008/07/12 17:31:06 oga Exp $ */
/* $NetBSD: vga_pci.c,v 1.3 1998/06/08 06:55:58 thorpej Exp $ */
/*
@@ -201,6 +201,7 @@ vga_pci_attach(struct device *parent, struct device *self, void *aux)
*/
if (agp_pchb_pa_set) {
aba.apa_pci_args = agp_pchb_pa;
+ memcpy(&aba.apa_vga_args, pa, sizeof(struct pci_attach_args));
config_found_sm(self, &aba, agpbus_print, agpsubmatch);
}