xf86-video-ati: Branch 'master' - 4 commits

Dave Airlie airlied at kemper.freedesktop.org
Tue Apr 20 17:40:03 PDT 2010


 src/radeon.h        |   10 -------
 src/radeon_cursor.c |    4 +--
 src/radeon_dri.c    |   55 ------------------------------------------
 src/radeon_dri.h    |    4 ---
 src/radeon_driver.c |   68 +++++++++++++++++++++++++++++-----------------------
 src/radeon_probe.h  |    3 ++
 6 files changed, 43 insertions(+), 101 deletions(-)

New commits:
commit 2a6b409496f26da0436972b5feae6ea035dde08d
Author: Owain Ainsworth <zerooa at googlemail.com>
Date:   Mon Apr 19 14:37:33 2010 +0100

    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 at redhat.com>

diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index dea2a22..7167ea0 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 5b16f27..fb90595 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;
 
commit 761f0de5556e46f166280476185977f720efe586
Author: Owain G. Ainsworth <zerooa at googlemail.com>
Date:   Mon Apr 19 04:05:36 2010 +0100

    Make consistent use of fbOffset and share fb mappings.
    
    What we were doing previously was mapping the framebuffer for zaphod for
    only this driver instances chunk, however, fbOffset was (rightly) set to
    the offset into the whole framebuffer we were using.
    
    Since in some cases we did operations on the FB virtual address +
    fbOffset (for example zeroing the framebuffer on entervt) we were
    actually pissing all over ourselves in those cases.
    
    Fix this by implementing shared fb mappings like we do for MMIO already,
    and whenever we wish to refer to our area of FB space we always use
    fbOffset. Fixes zaphod for some users on r600 chipsets, my 4870 is still
    behaving strangely on screen 0, but I suspect that is another bug.
    
    Once calculation (in PreInitAccel) is now wrong because of this, however
    dri on zaphod does now happen so this is irrelavent, add a comment to
    that effect.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/src/radeon_cursor.c b/src/radeon_cursor.c
index 4a171ff..538c8b2 100644
--- a/src/radeon_cursor.c
+++ b/src/radeon_cursor.c
@@ -343,7 +343,7 @@ radeon_crtc_set_cursor_colors (xf86CrtcPtr crtc, int bg, int fg)
     ScrnInfoPtr pScrn = crtc->scrn;
     RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
     RADEONInfoPtr info = RADEONPTR(pScrn);
-    uint32_t *pixels = (uint32_t *)(pointer)(info->FB + radeon_crtc->cursor_offset);
+    uint32_t *pixels = (uint32_t *)(pointer)(info->FB + pScrn->fbOffset + radeon_crtc->cursor_offset);
     int            pixel, i;
     CURSOR_SWAPPING_DECL_MMIO
 
@@ -386,7 +386,7 @@ radeon_crtc_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image)
     RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
     RADEONInfoPtr  info = RADEONPTR(pScrn);
     CURSOR_SWAPPING_DECL_MMIO
-    uint32_t *d = (uint32_t *)(pointer)(info->FB + radeon_crtc->cursor_offset);
+    uint32_t *d = (uint32_t *)(pointer)(info->FB + pScrn->fbOffset + radeon_crtc->cursor_offset);
 
     RADEONCTRACE(("RADEONLoadCursorARGB\n"));
 
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index ac1d022..dea2a22 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -238,7 +238,7 @@ radeonShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode,
     stride = (pScrn->displayWidth * pScrn->bitsPerPixel) / 8;
     *size = stride;
 
-    return ((uint8_t *)info->FB + row * stride + offset);
+    return ((uint8_t *)info->FB + pScrn->fbOffset + row * stride + offset);
 }
 static Bool
 RADEONCreateScreenResources (ScreenPtr pScreen)
@@ -402,6 +402,9 @@ void RADEONFreeRec(ScrnInfoPtr pScrn)
  */
 static Bool RADEONMapMMIO(ScrnInfoPtr pScrn)
 {
+#ifdef XSERVER_LIBPCIACCESS
+    int err;
+#endif
     RADEONInfoPtr  info = RADEONPTR(pScrn);
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
 
@@ -418,15 +421,15 @@ static Bool RADEONMapMMIO(ScrnInfoPtr pScrn)
 			       info->MMIOAddr,
 			       info->MMIOSize);
 
-    if (!info->MMIO) return FALSE;
+    if (!info->MMIO)
+        return FALSE;
 #else
 
-    void** result = (void**)&info->MMIO;
-    int err = pci_device_map_range(info->PciInfo,
+    err = pci_device_map_range(info->PciInfo,
 				   info->MMIOAddr,
 				   info->MMIOSize,
 				   PCI_DEV_MAP_FLAG_WRITABLE,
-				   result);
+				   &info->MMIO);
 
     if (err) {
 	xf86DrvMsg (pScrn->scrnIndex, X_ERROR,
@@ -473,6 +476,12 @@ static Bool RADEONMapFB(ScrnInfoPtr pScrn)
     int err;
 #endif
     RADEONInfoPtr  info = RADEONPTR(pScrn);
+    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+
+    if (pRADEONEnt->FB) {
+        info->FB = pRADEONEnt->FB;
+        return TRUE;
+    }
 
     xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
 		   "Map: 0x%016llx, 0x%08lx\n", info->LinearAddr, info->FbMapSize);
@@ -505,6 +514,7 @@ static Bool RADEONMapFB(ScrnInfoPtr pScrn)
 
 #endif
 
+    pRADEONEnt->FB = info->FB;
     return TRUE;
 }
 
@@ -512,6 +522,13 @@ static Bool RADEONMapFB(ScrnInfoPtr pScrn)
 static Bool RADEONUnmapFB(ScrnInfoPtr pScrn)
 {
     RADEONInfoPtr  info = RADEONPTR(pScrn);
+    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+
+    if (info->IsPrimary || info->IsSecondary) {
+      /* never unmap on zaphod */
+      info->FB = NULL;
+      return TRUE;
+    }
 
 #ifndef XSERVER_LIBPCIACCESS
     xf86UnMapVidMem(pScrn->scrnIndex, info->FB, info->FbMapSize);
@@ -519,6 +536,7 @@ static Bool RADEONUnmapFB(ScrnInfoPtr pScrn)
     pci_device_unmap_range(info->PciInfo, info->FB, info->FbMapSize);
 #endif
 
+    pRADEONEnt->FB = NULL;
     info->FB = NULL;
     return TRUE;
 }
@@ -1766,23 +1784,21 @@ static Bool RADEONPreInitVRAM(ScrnInfoPtr pScrn)
     xf86DrvMsg(pScrn->scrnIndex, from,
 	       "Mapped VideoRAM: %d kByte (%d bit %s SDRAM)\n", pScrn->videoRam, info->RamWidth, info->IsDDR?"DDR":"SDR");
 
+    /* Do this before we truncate since we only map fb once */
+    info->FbMapSize  = (pScrn->videoRam & ~1023) * 1024;
+
     if (info->IsPrimary) {
 	pScrn->videoRam /= 2;
 	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 		   "Using %dk of videoram for primary head\n",
 		   pScrn->videoRam);
-    }
-    
-    if (info->IsSecondary) {
+    } else if (info->IsSecondary) {
 	pScrn->videoRam /= 2;
-	info->LinearAddr += pScrn->videoRam * 1024;
 	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 		   "Using %dk of videoram for secondary head\n",
 		   pScrn->videoRam);
     }
-
     pScrn->videoRam  &= ~1023;
-    info->FbMapSize  = pScrn->videoRam * 1024;
 
     /* if the card is PCI Express reserve the last 32k for the gart table */
 #ifdef XF86DRI
@@ -2134,7 +2150,9 @@ static Bool RADEONPreInitAccel(ScrnInfoPtr pScrn)
 #if defined(USE_EXA) && defined(USE_XAA)
     char *optstr;
 #endif
+#ifdef XF86DRI /* zaphod FbMapSize is wrong, but no dri then */
     int maxy = info->FbMapSize / (pScrn->displayWidth * info->CurrentLayout.pixel_bytes);
+#endif
 
     if (!(info->accel_state = xcalloc(1, sizeof(struct radeon_accel_state)))) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unable to allocate accel_state rec!\n");
@@ -3424,7 +3442,8 @@ Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
     pScrn->fbOffset    = info->dri->frontOffset;
 #endif
 
-    if (info->IsSecondary) pScrn->fbOffset = pScrn->videoRam * 1024;
+    if (info->IsSecondary)
+        pScrn->fbOffset = pScrn->videoRam * 1024;
 #ifdef XF86DRI
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
 		   "RADEONScreenInit %lx %ld %d\n",
@@ -3665,7 +3684,7 @@ Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
 
     if (info->r600_shadow_fb == FALSE) {
 	/* Init fb layer */
-	if (!fbScreenInit(pScreen, info->FB,
+	if (!fbScreenInit(pScreen, info->FB + pScrn->fbOffset,
 			  pScrn->virtualX, pScrn->virtualY,
 			  pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth,
 			  pScrn->bitsPerPixel))
diff --git a/src/radeon_probe.h b/src/radeon_probe.h
index cab077f..5b16f27 100644
--- a/src/radeon_probe.h
+++ b/src/radeon_probe.h
@@ -644,6 +644,7 @@ typedef struct
     RADEONSaveRec     SavedReg;         /* Original (text) mode              */
 
     void              *MMIO;            /* Map of MMIO region                */
+    void              *FB;              /* Map of FB region                  */
     int fd;                             /* for sharing across zaphod heads   */
 } RADEONEntRec, *RADEONEntPtr;
 
commit 2059d628c5fb03222a62502cc1b5724bf296a7b3
Author: Owain G. Ainsworth <zerooa at googlemail.com>
Date:   Mon Apr 19 04:05:35 2010 +0100

    Kill per-context SAREA support.
    
    It has never been used, and since the world is changing it almost
    certainly never will be. Good riddance.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/src/radeon.h b/src/radeon.h
index 4e685dd..56bc076 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -543,13 +543,8 @@ typedef struct {
 } RADEONConfigPrivRec, *RADEONConfigPrivPtr;
 
 typedef struct {
-#ifdef PER_CONTEXT_SAREA
-    drm_context_t ctx_id;
-    drm_handle_t sarea_handle;
-#else
     /* Nothing here yet */
     int dummy;
-#endif
 } RADEONDRIContextRec, *RADEONDRIContextPtr;
 
 struct radeon_dri {
@@ -646,10 +641,6 @@ struct radeon_dri {
 
     int               irq;
 
-#ifdef PER_CONTEXT_SAREA
-    int               perctx_sarea_size;
-#endif
-
 #ifdef USE_XAA
     uint32_t          frontPitchOffset;
     uint32_t          backPitchOffset;
diff --git a/src/radeon_dri.c b/src/radeon_dri.c
index ee62e95..6d12435 100644
--- a/src/radeon_dri.c
+++ b/src/radeon_dri.c
@@ -300,36 +300,6 @@ static Bool RADEONCreateContext(ScreenPtr pScreen, VisualPtr visual,
 				drm_context_t hwContext, void *pVisualConfigPriv,
 				DRIContextType contextStore)
 {
-#ifdef PER_CONTEXT_SAREA
-    ScrnInfoPtr          pScrn = xf86Screens[pScreen->myNum];
-    RADEONInfoPtr        info  = RADEONPTR(pScrn);
-    RADEONDRIContextPtr  ctx_info;
-
-    ctx_info = (RADEONDRIContextPtr)contextStore;
-    if (!ctx_info) return FALSE;
-
-    if (drmAddMap(info->dri->drmFD, 0,
-		  info->dri->perctx_sarea_size,
-		  DRM_SHM,
-		  DRM_REMOVABLE,
-		  &ctx_info->sarea_handle) < 0) {
-	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		   "[dri] could not create private sarea for ctx id (%d)\n",
-		   (int)hwContext);
-	return FALSE;
-    }
-
-    if (drmAddContextPrivateMapping(info->dri->drmFD, hwContext,
-				    ctx_info->sarea_handle) < 0) {
-	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		   "[dri] could not associate private sarea to ctx id (%d)\n",
-		   (int)hwContext);
-	drmRmMap(info->dri->drmFD, ctx_info->sarea_handle);
-	return FALSE;
-    }
-
-    ctx_info->ctx_id = hwContext;
-#endif
     return TRUE;
 }
 
@@ -337,20 +307,6 @@ static Bool RADEONCreateContext(ScreenPtr pScreen, VisualPtr visual,
 static void RADEONDestroyContext(ScreenPtr pScreen, drm_context_t hwContext,
 				 DRIContextType contextStore)
 {
-#ifdef PER_CONTEXT_SAREA
-    ScrnInfoPtr          pScrn = xf86Screens[pScreen->myNum];
-    RADEONInfoPtr        info = RADEONPTR(pScrn);
-    RADEONDRIContextPtr  ctx_info;
-
-    ctx_info = (RADEONDRIContextPtr)contextStore;
-    if (!ctx_info) return;
-
-    if (drmRmMap(info->dri->drmFD, ctx_info->sarea_handle) < 0) {
-	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		   "[dri] could not remove private sarea for ctx id (%d)\n",
-		   (int)hwContext);
-    }
-#endif
 }
 
 /* Called when the X server is woken up to allow the last client's
@@ -1624,12 +1580,6 @@ Bool RADEONDRIScreenInit(ScreenPtr pScreen)
        correctly with pageflip + mergedfb/color tiling */
     pDRIInfo->wrap.AdjustFrame = NULL;
 
-#ifdef PER_CONTEXT_SAREA
-    /* This is only here for testing per-context SAREAs.  When used, the
-       magic number below would be properly defined in a header file. */
-    info->perctx_sarea_size = 64 * 1024;
-#endif
-
 #ifdef NOT_DONE
     /* FIXME: Need to extend DRI protocol to pass this size back to
      * client for SAREA mapping that includes a device private record
@@ -1846,11 +1796,6 @@ Bool RADEONDRIFinishScreenInit(ScreenPtr pScreen)
 
     pRADEONDRI->sarea_priv_offset = sizeof(XF86DRISAREARec);
 
-#ifdef PER_CONTEXT_SAREA
-    /* Set per-context SAREA size */
-    pRADEONDRI->perctx_sarea_size = info->dri->perctx_sarea_size;
-#endif
-
     info->directRenderingInited = TRUE;
 
     /* Wrap CloseScreen */
diff --git a/src/radeon_dri.h b/src/radeon_dri.h
index 6e3ad62..15beb52 100644
--- a/src/radeon_dri.h
+++ b/src/radeon_dri.h
@@ -86,10 +86,6 @@ typedef struct {
     int           log2GARTTexGran;
     int           gartTexOffset;
     unsigned int  sarea_priv_offset;
-
-#ifdef PER_CONTEXT_SAREA
-    drmSize      perctx_sarea_size;
-#endif
 } RADEONDRIRec, *RADEONDRIPtr;
 
 #endif
commit c4b46f56279cc18c8114235ca41cfb41ffede67f
Author: Owain G. Ainsworth <zerooa at googlemail.com>
Date:   Mon Apr 19 04:05:34 2010 +0100

    Remove remnants of the ShowCache option.
    
    The rest of it died a long time ago.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/src/radeon.h b/src/radeon.h
index 859224c..4e685dd 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -971,7 +971,6 @@ typedef struct {
     unsigned int xv_max_height;
 
     /* general */
-    Bool              showCache;
     OptionInfoPtr     Options;
 
     DisplayModePtr currentMode, savedCurrentMode;
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index 0aaf82b..ac1d022 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -181,7 +181,6 @@ static const OptionInfoRec RADEONOptions[] = {
     { OPTION_RENDER_ACCEL,   "RenderAccel",      OPTV_BOOLEAN, {0}, FALSE },
     { OPTION_SUBPIXEL_ORDER, "SubPixelOrder",    OPTV_ANYSTR,  {0}, FALSE },
 #endif
-    { OPTION_SHOWCACHE,      "ShowCache",        OPTV_BOOLEAN, {0}, FALSE },
     { OPTION_CLOCK_GATING,   "ClockGating",      OPTV_BOOLEAN, {0}, FALSE },
     { OPTION_VGA_ACCESS,     "VGAAccess",        OPTV_BOOLEAN, {0}, TRUE  },
     { OPTION_REVERSE_DDC,    "ReverseDDC",       OPTV_BOOLEAN, {0}, FALSE },
@@ -2070,11 +2069,6 @@ static Bool RADEONPreInitChipType(ScrnInfoPtr pScrn)
 	}
     }
 #endif
-    xf86GetOptValBool(info->Options, OPTION_SHOWCACHE, &info->showCache);
-    if (info->showCache)
-	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
-		   "Option ShowCache enabled\n");
-
 #ifdef RENDER
     info->RenderAccel = xf86ReturnOptValBool(info->Options, OPTION_RENDER_ACCEL,
 					     info->Chipset != PCI_CHIP_RN50_515E &&
@@ -5630,15 +5624,6 @@ void RADEONDoAdjustFrame(ScrnInfoPtr pScrn, int x, int y, Bool crtc2)
 		   "RADEONDoAdjustFrame(%d,%d,%d)\n", x, y, clone);
 #endif
 
-    if (info->showCache && y) {
-	        int lastline = info->FbMapSize /
-		    ((pScrn->displayWidth * pScrn->bitsPerPixel) / 8);
-
-		lastline -= pScrn->currentMode->VDisplay;
-		y += (pScrn->virtualY - 1) * (y / 3 + 1);
-		if (y > lastline) y = lastline;
-    }
-
     Base = pScrn->fbOffset;
 
   /* note we cannot really simply use the info->ModeReg.crtc_offset_cntl value, since the


More information about the xorg-commit mailing list