diff options
author | Owain Ainsworth <zerooa@googlemail.com> | 2010-04-19 14:37:33 +0100 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-04-21 10:36:04 +1000 |
commit | 2a6b409496f26da0436972b5feae6ea035dde08d (patch) | |
tree | 41230d7194e7041eb86be4a280b40d4b20f47aa0 /src/radeon_driver.c | |
parent | 761f0de5556e46f166280476185977f720efe586 (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/radeon_driver.c')
-rw-r--r-- | src/radeon_driver.c | 12 |
1 files changed, 8 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; } |