summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOwain Ainsworth <zerooa@googlemail.com>2010-04-19 14:37:33 +0100
committerDave Airlie <airlied@redhat.com>2010-04-21 10:36:04 +1000
commit2a6b409496f26da0436972b5feae6ea035dde08d (patch)
tree41230d7194e7041eb86be4a280b40d4b20f47aa0 /src
parent761f0de5556e46f166280476185977f720efe586 (diff)
Reference count shared driver mappings.
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 Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/radeon_driver.c12
-rw-r--r--src/radeon_probe.h2
2 files changed, 10 insertions, 4 deletions
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index dea2a226..7167ea06 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 5b16f271..fb905959 100644
--- a/src/radeon_probe.h
+++ b/src/radeon_probe.h
@@ -644,7 +644,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;