[PATCH] Reference count shared driver mappings.
Owain G. Ainsworth
oga at openbsd.org
Mon Apr 19 06:28:29 PDT 2010
With MMIO it wasn't *such* a bit deal if we leaked the smallish mapping.
with FB it could be a larger deal. So instead of worrying about this,
reference count the mappings in the entity structure and unmap them when
no one cares anymore.
Prompted by a discussion with airlied
---
src/radeon_driver.c | 12 ++++++++----
src/radeon_probe.h | 2 ++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index e138492..4c69eca 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -409,6 +409,7 @@ static Bool RADEONMapMMIO(ScrnInfoPtr pScrn)
RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
if (pRADEONEnt->MMIO) {
+ pRADEONEnt->MMIO_cnt++;
info->MMIO = pRADEONEnt->MMIO;
return TRUE;
}
@@ -441,6 +442,7 @@ static Bool RADEONMapMMIO(ScrnInfoPtr pScrn)
#endif
pRADEONEnt->MMIO = info->MMIO;
+ pRADEONEnt->MMIO_cnt = 1;
return TRUE;
}
@@ -452,8 +454,8 @@ static Bool RADEONUnmapMMIO(ScrnInfoPtr pScrn)
RADEONInfoPtr info = RADEONPTR(pScrn);
RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
- if (info->IsPrimary || info->IsSecondary) {
- /* never unmap on zaphod */
+ /* refcount for zaphod */
+ if (--pRADEONEnt->MMIO_cnt != 0) {
info->MMIO = NULL;
return TRUE;
}
@@ -479,6 +481,7 @@ static Bool RADEONMapFB(ScrnInfoPtr pScrn)
RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
if (pRADEONEnt->FB) {
+ pRADEONEnt->FB_cnt++;
info->FB = pRADEONEnt->FB;
return TRUE;
}
@@ -515,6 +518,7 @@ static Bool RADEONMapFB(ScrnInfoPtr pScrn)
#endif
pRADEONEnt->FB = info->FB;
+ pRADEONEnt->FB_cnt = 1;
return TRUE;
}
@@ -524,8 +528,8 @@ static Bool RADEONUnmapFB(ScrnInfoPtr pScrn)
RADEONInfoPtr info = RADEONPTR(pScrn);
RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
- if (info->IsPrimary || info->IsSecondary) {
- /* never unmap on zaphod */
+ /* refcount for zaphod */
+ if (--pRADEONEnt->FB_cnt != 0) {
info->FB = NULL;
return TRUE;
}
diff --git a/src/radeon_probe.h b/src/radeon_probe.h
index 405f5b4..2538df9 100644
--- a/src/radeon_probe.h
+++ b/src/radeon_probe.h
@@ -638,7 +638,9 @@ typedef struct
RADEONSaveRec SavedReg; /* Original (text) mode */
void *MMIO; /* Map of MMIO region */
+ int *MMIO_cnt; /* Map of FB region refcount */
void *FB; /* Map of FB region */
+ int *FB_cnt; /* Map of FB region refcount */
int fd; /* for sharing across zaphod heads */
} RADEONEntRec, *RADEONEntPtr;
--
1.6.5.7
More information about the xorg-driver-ati
mailing list