summaryrefslogtreecommitdiffstats
path: root/sys/dev/agp
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-10-30 22:09:16 +0000
committerjhb <jhb@FreeBSD.org>2007-10-30 22:09:16 +0000
commitfb7d38331162808946b7a5b8403973e269dec20d (patch)
tree4bbfaaad51fa35b2a857b9a295ba0233f3be30ff /sys/dev/agp
parent21b82a0c2984db5116c4ae71807cffe53301e89e (diff)
downloadFreeBSD-src-fb7d38331162808946b7a5b8403973e269dec20d.zip
FreeBSD-src-fb7d38331162808946b7a5b8403973e269dec20d.tar.gz
Split agp_generic_detach() up into two routines: agp_free_cdev() destroys
/dev/agpgart and agp_free_res() frees resources like the BAR for the aperture. Splitting this up lets chipset-specific detach routines manipulate the aperture during their detach routines without panicing. MFC after: 1 week Reviewed by: anholt
Diffstat (limited to 'sys/dev/agp')
-rw-r--r--sys/dev/agp/agp.c19
-rw-r--r--sys/dev/agp/agp_ali.c6
-rw-r--r--sys/dev/agp/agp_amd.c6
-rw-r--r--sys/dev/agp/agp_amd64.c6
-rw-r--r--sys/dev/agp/agp_ati.c8
-rw-r--r--sys/dev/agp/agp_i810.c6
-rw-r--r--sys/dev/agp/agp_intel.c6
-rw-r--r--sys/dev/agp/agp_nvidia.c6
-rw-r--r--sys/dev/agp/agp_sis.c6
-rw-r--r--sys/dev/agp/agp_via.c6
-rw-r--r--sys/dev/agp/agppriv.h2
11 files changed, 39 insertions, 38 deletions
diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c
index e8e8af0..ec0807a 100644
--- a/sys/dev/agp/agp.c
+++ b/sys/dev/agp/agp.c
@@ -261,16 +261,31 @@ agp_generic_attach(device_t dev)
return 0;
}
-int
-agp_generic_detach(device_t dev)
+void
+agp_free_cdev(device_t dev)
{
struct agp_softc *sc = device_get_softc(dev);
destroy_dev(sc->as_devnode);
+}
+
+void
+agp_free_res(device_t dev)
+{
+ struct agp_softc *sc = device_get_softc(dev);
+
bus_release_resource(dev, SYS_RES_MEMORY, sc->as_aperture_rid,
sc->as_aperture);
mtx_destroy(&sc->as_lock);
agp_flush_cache();
+}
+
+int
+agp_generic_detach(device_t dev)
+{
+
+ agp_free_cdev(dev);
+ agp_free_res(dev);
return 0;
}
diff --git a/sys/dev/agp/agp_ali.c b/sys/dev/agp/agp_ali.c
index a619547..74bd2b1 100644
--- a/sys/dev/agp/agp_ali.c
+++ b/sys/dev/agp/agp_ali.c
@@ -141,12 +141,9 @@ static int
agp_ali_detach(device_t dev)
{
struct agp_ali_softc *sc = device_get_softc(dev);
- int error;
u_int32_t attbase;
- error = agp_generic_detach(dev);
- if (error)
- return error;
+ agp_free_cdev(dev);
/* Disable the TLB.. */
pci_write_config(dev, AGP_ALI_TLBCTRL, 0x90, 1);
@@ -157,6 +154,7 @@ agp_ali_detach(device_t dev)
pci_write_config(dev, AGP_ALI_ATTBASE, attbase & 0xfff, 4);
agp_free_gatt(sc->gatt);
+ agp_free_res(dev);
return 0;
}
diff --git a/sys/dev/agp/agp_amd.c b/sys/dev/agp/agp_amd.c
index 3c9159d..7c3bd0d 100644
--- a/sys/dev/agp/agp_amd.c
+++ b/sys/dev/agp/agp_amd.c
@@ -277,11 +277,8 @@ static int
agp_amd_detach(device_t dev)
{
struct agp_amd_softc *sc = device_get_softc(dev);
- int error;
- error = agp_generic_detach(dev);
- if (error)
- return error;
+ agp_free_cdev(dev);
/* Disable the TLB.. */
WRITE2(AGP_AMD751_STATUS,
@@ -297,6 +294,7 @@ agp_amd_detach(device_t dev)
AGP_SET_APERTURE(dev, sc->initial_aperture);
agp_amd_free_gatt(sc->gatt);
+ agp_free_res(dev);
bus_release_resource(dev, SYS_RES_MEMORY,
AGP_AMD751_REGISTERS, sc->regs);
diff --git a/sys/dev/agp/agp_amd64.c b/sys/dev/agp/agp_amd64.c
index 9e5b6e2..7c1a25d 100644
--- a/sys/dev/agp/agp_amd64.c
+++ b/sys/dev/agp/agp_amd64.c
@@ -250,10 +250,9 @@ static int
agp_amd64_detach(device_t dev)
{
struct agp_amd64_softc *sc = device_get_softc(dev);
- int i, error;
+ int i;
- if ((error = agp_generic_detach(dev)))
- return (error);
+ agp_free_cdev(dev);
for (i = 0; i < sc->n_mctrl; i++)
pci_cfgregwrite(0, sc->mctrl[i], 3, AGP_AMD64_APCTRL,
@@ -262,6 +261,7 @@ agp_amd64_detach(device_t dev)
AGP_SET_APERTURE(dev, sc->initial_aperture);
agp_free_gatt(sc->gatt);
+ agp_free_res(dev);
return (0);
}
diff --git a/sys/dev/agp/agp_ati.c b/sys/dev/agp/agp_ati.c
index 0c3a119..6bc6019 100644
--- a/sys/dev/agp/agp_ati.c
+++ b/sys/dev/agp/agp_ati.c
@@ -248,18 +248,15 @@ static int
agp_ati_detach(device_t dev)
{
struct agp_ati_softc *sc = device_get_softc(dev);
- int error;
u_int32_t apsize_reg, temp;
+ agp_free_cdev(dev);
+
if (sc->is_rs300)
apsize_reg = ATI_RS300_APSIZE;
else
apsize_reg = ATI_RS100_APSIZE;
- error = agp_generic_detach(dev);
- if (error)
- return error;
-
/* Clear the GATT base */
WRITE4(ATI_GART_BASE, 0);
@@ -273,6 +270,7 @@ agp_ati_detach(device_t dev)
free(sc->ag_virtual, M_AGP);
bus_release_resource(dev, SYS_RES_MEMORY, ATI_GART_MMADDR, sc->regs);
+ agp_free_res(dev);
return 0;
}
diff --git a/sys/dev/agp/agp_i810.c b/sys/dev/agp/agp_i810.c
index bd72de5..9e081be 100644
--- a/sys/dev/agp/agp_i810.c
+++ b/sys/dev/agp/agp_i810.c
@@ -583,11 +583,8 @@ static int
agp_i810_detach(device_t dev)
{
struct agp_i810_softc *sc = device_get_softc(dev);
- int error;
- error = agp_generic_detach(dev);
- if (error)
- return error;
+ agp_free_cdev(dev);
/* Clear the GATT base. */
if ( sc->chiptype == CHIP_I810 ) {
@@ -608,6 +605,7 @@ agp_i810_detach(device_t dev)
free(sc->gatt, M_AGP);
bus_release_resources(dev, sc->sc_res_spec, sc->sc_res);
+ agp_free_res(dev);
return 0;
}
diff --git a/sys/dev/agp/agp_intel.c b/sys/dev/agp/agp_intel.c
index d30f0d4..60e0e6f 100644
--- a/sys/dev/agp/agp_intel.c
+++ b/sys/dev/agp/agp_intel.c
@@ -262,13 +262,10 @@ agp_intel_detach(device_t dev)
{
struct agp_intel_softc *sc;
u_int32_t reg;
- int error;
sc = device_get_softc(dev);
- error = agp_generic_detach(dev);
- if (error)
- return (error);
+ agp_free_cdev(dev);
/* Disable aperture accesses. */
switch (pci_get_devid(dev)) {
@@ -305,6 +302,7 @@ agp_intel_detach(device_t dev)
pci_write_config(dev, AGP_INTEL_ATTBASE, 0, 4);
AGP_SET_APERTURE(dev, sc->initial_aperture);
agp_free_gatt(sc->gatt);
+ agp_free_res(dev);
return (0);
}
diff --git a/sys/dev/agp/agp_nvidia.c b/sys/dev/agp/agp_nvidia.c
index 8e4f35f..8e2d243 100644
--- a/sys/dev/agp/agp_nvidia.c
+++ b/sys/dev/agp/agp_nvidia.c
@@ -247,12 +247,9 @@ static int
agp_nvidia_detach (device_t dev)
{
struct agp_nvidia_softc *sc = device_get_softc(dev);
- int error;
u_int32_t temp;
- error = agp_generic_detach(dev);
- if (error)
- return (error);
+ agp_free_cdev(dev);
/* GART Control */
temp = pci_read_config(sc->dev, AGP_NVIDIA_0_APSIZE, 4);
@@ -270,6 +267,7 @@ agp_nvidia_detach (device_t dev)
sc->initial_aperture);
agp_free_gatt(sc->gatt);
+ agp_free_res(dev);
return (0);
}
diff --git a/sys/dev/agp/agp_sis.c b/sys/dev/agp/agp_sis.c
index 3915f5d..a51514a 100644
--- a/sys/dev/agp/agp_sis.c
+++ b/sys/dev/agp/agp_sis.c
@@ -173,11 +173,8 @@ static int
agp_sis_detach(device_t dev)
{
struct agp_sis_softc *sc = device_get_softc(dev);
- int error;
- error = agp_generic_detach(dev);
- if (error)
- return error;
+ agp_free_cdev(dev);
/* Disable the aperture.. */
pci_write_config(dev, AGP_SIS_WINCTRL,
@@ -190,6 +187,7 @@ agp_sis_detach(device_t dev)
AGP_SET_APERTURE(dev, sc->initial_aperture);
agp_free_gatt(sc->gatt);
+ agp_free_res(dev);
return 0;
}
diff --git a/sys/dev/agp/agp_via.c b/sys/dev/agp/agp_via.c
index aa6d640..d60f49a 100644
--- a/sys/dev/agp/agp_via.c
+++ b/sys/dev/agp/agp_via.c
@@ -240,16 +240,14 @@ static int
agp_via_detach(device_t dev)
{
struct agp_via_softc *sc = device_get_softc(dev);
- int error;
- error = agp_generic_detach(dev);
- if (error)
- return error;
+ agp_free_cdev(dev);
pci_write_config(dev, sc->regs[REG_GARTCTRL], 0, 4);
pci_write_config(dev, sc->regs[REG_ATTBASE], 0, 4);
AGP_SET_APERTURE(dev, sc->initial_aperture);
agp_free_gatt(sc->gatt);
+ agp_free_res(dev);
return 0;
}
diff --git a/sys/dev/agp/agppriv.h b/sys/dev/agp/agppriv.h
index 6aa1861..b4c90a0 100644
--- a/sys/dev/agp/agppriv.h
+++ b/sys/dev/agp/agppriv.h
@@ -90,7 +90,9 @@ void agp_flush_cache(void);
u_int8_t agp_find_caps(device_t dev);
struct agp_gatt *agp_alloc_gatt(device_t dev);
void agp_set_aperture_resource(device_t dev, int rid);
+void agp_free_cdev(device_t dev);
void agp_free_gatt(struct agp_gatt *gatt);
+void agp_free_res(device_t dev);
int agp_generic_attach(device_t dev);
int agp_generic_detach(device_t dev);
int agp_generic_get_aperture(device_t dev);
OpenPOWER on IntegriCloud