mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
To: Shayenne Moura <shayenneluzmoura@gmail.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] drm: vkms: Bugfix racing hrtimer vblank handle
Date: Sun, 3 Feb 2019 18:57:30 -0200	[thread overview]
Message-ID: <20190203205730.yvf6n2hz4bnar3nx@smtp.gmail.com> (raw)
In-Reply-To: <e2e4b8f3a5cab7b2dba75bf1930f86b0a4ee08c9.1548856186.git.shayenneluzmoura@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2910 bytes --]

On 01/30, Shayenne Moura wrote:
> When the vblank irq happens, kernel time subsystem executes
> `vkms_vblank_simulate`. In parallel or not, it prepares all stuff
> necessary to the next vblank with arm, and it must flush these
> stuff before the next vblank irq. However, vblank counter is ahead
> when arm is executed in parallel with handle vblank.
> 
> CPU 0:					CPU 1:
>  |					 |
> atomic_commit_tail is ongoing		 |
>  |					 |
>  |					hrtimer: vkms_vblank_simulate()
>  |					 |
>  |					drm_crtc_handle_vblank()
>  |					 |
> drm_crtc_arm_vblank()			 |
>  |					 |
> ->get_vblank_timestamp()		 |
>  |					 |
>  |					hrtimer_forward_now()
> 
> Then, we should guarantee that the vblank interval time is correct
> (not changed) before finish the vblank handle.
> 
> Fix the bug including the call to `hrtimer_forward_now()` in the same
> lock of `drm_crtc_handle_vblank()` to ensure that the timestamp update
> is correct when finish the vblank handle.
> 
> Signed-off-by: Shayenne Moura <shayenneluzmoura@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/vkms/vkms_crtc.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> index 23146ff2a25b..5a095610726b 100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -10,13 +10,17 @@
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_probe_helper.h>
>  
> -static void _vblank_handle(struct vkms_output *output)
> +static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer)
>  {
> +	struct vkms_output *output = container_of(timer, struct vkms_output,
> +						  vblank_hrtimer);
>  	struct drm_crtc *crtc = &output->crtc;
>  	struct vkms_crtc_state *state = to_vkms_crtc_state(crtc->state);
> +	int ret_overrun;
>  	bool ret;
>  
>  	spin_lock(&output->lock);
> +
>  	ret = drm_crtc_handle_vblank(crtc);
>  	if (!ret)
>  		DRM_ERROR("vkms failure on handling vblank");
> @@ -37,19 +41,9 @@ static void _vblank_handle(struct vkms_output *output)
>  			DRM_WARN("failed to queue vkms_crc_work_handle");
>  	}
>  
> -	spin_unlock(&output->lock);
> -}
> -
> -static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer)
> -{
> -	struct vkms_output *output = container_of(timer, struct vkms_output,
> -						  vblank_hrtimer);
> -	int ret_overrun;
> -
> -	_vblank_handle(output);
> -
>  	ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer,
>  					  output->period_ns);
> +	spin_unlock(&output->lock);
>  
>  	return HRTIMER_RESTART;
>  }
> -- 
> 2.17.1
> 

Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>

-- 
Rodrigo Siqueira
https://siqueira.tech
Graduate Student
Department of Computer Science
University of São Paulo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-02-03 20:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 16:05 [PATCH 0/2] drm/vkms: Bugfix for igt-tests Shayenne Moura
2019-01-30 16:06 ` [PATCH 1/2] drm/vkms: Bugfix extra vblank frame Shayenne Moura
2019-02-03 20:57   ` Rodrigo Siqueira
2019-01-30 16:07 ` [PATCH 2/2] drm: vkms: Bugfix racing hrtimer vblank handle Shayenne Moura
2019-02-03 20:57   ` Rodrigo Siqueira [this message]
2019-02-01 23:25 ` [PATCH 0/2] drm/vkms: Bugfix for igt-tests Shayenne Moura
2019-02-03 20:53 ` Rodrigo Siqueira

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190203205730.yvf6n2hz4bnar3nx@smtp.gmail.com \
    --to=rodrigosiqueiramelo@gmail.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shayenneluzmoura@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®