[PATCH 3/5] Defer initial modeset until the first BlockHandler invocation

Mike Lothian mike at fireburn.co.uk
Sun Apr 26 11:04:05 PDT 2015


Hi Michel

The xf86-video-ati driver has been segfaulting on me the last few days
I've git bisected back to this patch - I run a prime system, I think
it might be related seeing as noone else seems to have noticed this
issue

I'm unable to revert the patch cleanly

# bad: [80f3d727f93cb6efedd2b39338d2301035965fe2] On screen resize,
clear the new buffer before displaying it
git bisect bad 80f3d727f93cb6efedd2b39338d2301035965fe2
# good: [43159ef400c3b18b9f4d3e6fa1c4aef2d60d38fe] Add Option "TearFree" v4
git bisect good 43159ef400c3b18b9f4d3e6fa1c4aef2d60d38fe
# good: [37874a4eeace5df04b02c8fc28f67b824e3f0f5f] Defer initial
drmmode_copy_fb call until root window creation
git bisect good 37874a4eeace5df04b02c8fc28f67b824e3f0f5f
# good: [37874a4eeace5df04b02c8fc28f67b824e3f0f5f] Defer initial
drmmode_copy_fb call until root window creation
git bisect good 37874a4eeace5df04b02c8fc28f67b824e3f0f5f
# good: [37874a4eeace5df04b02c8fc28f67b824e3f0f5f] Defer initial
drmmode_copy_fb call until root window creation
git bisect good 37874a4eeace5df04b02c8fc28f67b824e3f0f5f
# bad: [a4a8cdbcc10c1c5f07485a2af9e9e81e490c3e1d] Update scanout
pixmap contents before setting a mode with it
git bisect bad a4a8cdbcc10c1c5f07485a2af9e9e81e490c3e1d
# bad: [a4a8cdbcc10c1c5f07485a2af9e9e81e490c3e1d] Update scanout
pixmap contents before setting a mode with it
git bisect bad a4a8cdbcc10c1c5f07485a2af9e9e81e490c3e1d
# bad: [673e1c7637687c74fc9bdeeeffb7ace0d04b734f] Defer initial
modeset until the first BlockHandler invocation
git bisect bad 673e1c7637687c74fc9bdeeeffb7ace0d04b734f
# first bad commit: [673e1c7637687c74fc9bdeeeffb7ace0d04b734f] Defer
initial modeset until the first BlockHandler invocation

I've just raised a bug for this
https://bugs.freedesktop.org/show_bug.cgi?id=90187

Cheers

Mike

On 21 April 2015 at 10:49, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> This ensures that the screen pixmap contents have been initialized when
> the initial modes are set.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=27757
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
>  src/drmmode_display.c | 44 ++++++++++++++------------------------------
>  src/drmmode_display.h |  3 ++-
>  src/radeon_kms.c      | 17 ++++++++++++++---
>  3 files changed, 30 insertions(+), 34 deletions(-)
>
> diff --git a/src/drmmode_display.c b/src/drmmode_display.c
> index 76b2577..064a64c 100644
> --- a/src/drmmode_display.c
> +++ b/src/drmmode_display.c
> @@ -395,8 +395,6 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
>         ScreenPtr pScreen = pScrn->pScreen;
>         int fbcon_id = 0;
>         int i;
> -       int pitch;
> -       uint32_t tiling_flags = 0;
>         Bool ret;
>
>         for (i = 0; i < xf86_config->num_crtc; i++) {
> @@ -422,28 +420,7 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
>         if (!src)
>                 return;
>
> -       if (info->allowColorTiling) {
> -               if (info->ChipFamily >= CHIP_FAMILY_R600) {
> -                       if (info->allowColorTiling2D) {
> -                               tiling_flags |= RADEON_TILING_MACRO;
> -                       } else {
> -                               tiling_flags |= RADEON_TILING_MICRO;
> -                       }
> -               } else
> -                       tiling_flags |= RADEON_TILING_MACRO;
> -       }
> -
> -       pitch = RADEON_ALIGN(pScrn->displayWidth,
> -                            drmmode_get_pitch_align(pScrn, info->pixel_bytes, tiling_flags)) *
> -               info->pixel_bytes;
> -
> -       dst = drmmode_create_bo_pixmap(pScrn, pScrn->virtualX,
> -                                      pScrn->virtualY, pScrn->depth,
> -                                      pScrn->bitsPerPixel, pitch,
> -                                      tiling_flags, info->front_bo, &info->front_surface);
> -       if (!dst)
> -               goto out_free_src;
> -
> +       dst = pScreen->GetScreenPixmap(pScreen);
>         ret = info->accel_state->exa->PrepareCopy (src, dst,
>                                                    -1, -1, GXcopy, FB_ALLONES);
>         if (!ret)
> @@ -454,7 +431,6 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
>         radeon_cs_flush_indirect(pScrn);
>
>         pScreen->canDoBGNoneRoot = TRUE;
> -       drmmode_destroy_bo_pixmap(dst);
>   out_free_src:
>         drmmode_destroy_bo_pixmap(src);
>         return;
> @@ -2109,7 +2085,8 @@ void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y)
>         }
>  }
>
> -Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
> +Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
> +                              Bool set_hw)
>  {
>         xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(pScrn);
>         int c;
> @@ -2121,7 +2098,7 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
>                 int             o;
>
>                 /* Skip disabled CRTCs */
> -               if (!crtc->enabled) {
> +               if (set_hw && !crtc->enabled) {
>                         drmmode_do_crtc_dpms(crtc, DPMSModeOff);
>                         drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
>                                        0, 0, 0, NULL, 0, NULL);
> @@ -2157,9 +2134,16 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
>                         crtc->desiredY = 0;
>                 }
>
> -               if (!crtc->funcs->set_mode_major(crtc, &crtc->desiredMode, crtc->desiredRotation,
> -                                                crtc->desiredX, crtc->desiredY))
> -                       return FALSE;
> +               if (set_hw) {
> +                       if (!crtc->funcs->set_mode_major(crtc, &crtc->desiredMode, crtc->desiredRotation,
> +                                                        crtc->desiredX, crtc->desiredY))
> +                               return FALSE;
> +               } else {
> +                       crtc->mode = crtc->desiredMode;
> +                       crtc->rotation = crtc->desiredRotation;
> +                       crtc->x = crtc->desiredX;
> +                       crtc->y = crtc->desiredY;
> +               }
>         }
>         return TRUE;
>  }
> diff --git a/src/drmmode_display.h b/src/drmmode_display.h
> index 49b02d6..2fdd3e0 100644
> --- a/src/drmmode_display.h
> +++ b/src/drmmode_display.h
> @@ -126,7 +126,8 @@ extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
>  extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr);
>  extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo);
>  void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
> -extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
> +extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
> +                                     Bool set_hw);
>  #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 10
>  extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
>  #endif
> diff --git a/src/radeon_kms.c b/src/radeon_kms.c
> index 2a84ff6..eda3f33 100644
> --- a/src/radeon_kms.c
> +++ b/src/radeon_kms.c
> @@ -245,7 +245,7 @@ static Bool RADEONCreateScreenResources_KMS(ScreenPtr pScreen)
>         return FALSE;
>      pScreen->CreateScreenResources = RADEONCreateScreenResources_KMS;
>
> -    if (!drmmode_set_desired_modes(pScrn, &info->drmmode))
> +    if (!drmmode_set_desired_modes(pScrn, &info->drmmode, FALSE))
>         return FALSE;
>
>      drmmode_uevent_init(pScrn, &info->drmmode);
> @@ -535,6 +535,17 @@ static void RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
>  #endif
>  }
>
> +static void RADEONBlockHandler_oneshot(BLOCKHANDLER_ARGS_DECL)
> +{
> +    SCREEN_PTR(arg);
> +    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
> +    RADEONInfoPtr info = RADEONPTR(pScrn);
> +
> +    drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE);
> +
> +    RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS);
> +}
> +
>  static void
>  radeon_flush_callback(CallbackListPtr *list,
>                       pointer user_data, pointer call_data)
> @@ -1707,7 +1718,7 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
>      pScreen->CloseScreen = RADEONCloseScreen_KMS;
>      pScreen->SaveScreen  = RADEONSaveScreen_KMS;
>      info->BlockHandler = pScreen->BlockHandler;
> -    pScreen->BlockHandler = RADEONBlockHandler_KMS;
> +    pScreen->BlockHandler = RADEONBlockHandler_oneshot;
>
>      if (!AddCallback(&FlushCallback, radeon_flush_callback, pScrn))
>          return FALSE;
> @@ -1765,7 +1776,7 @@ Bool RADEONEnterVT_KMS(VT_FUNC_ARGS_DECL)
>         drmmode_copy_fb(pScrn, &info->drmmode);
>  #endif
>
> -    if (!drmmode_set_desired_modes(pScrn, &info->drmmode))
> +    if (!drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE))
>         return FALSE;
>
>      return TRUE;
> --
> 2.1.4
>
> _______________________________________________
> xorg-driver-ati mailing list
> xorg-driver-ati at lists.x.org
> http://lists.x.org/mailman/listinfo/xorg-driver-ati
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Xorg.0.log
Type: text/x-log
Size: 46209 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-driver-ati/attachments/20150426/404243ab/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Xorg.0.log.old
Type: application/x-trash
Size: 28311 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-driver-ati/attachments/20150426/404243ab/attachment-0001.old>


More information about the xorg-driver-ati mailing list