From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hunter Subject: Re: [PATCH 6/8] drm/bochs: phase 3: provide a custom ->atomic_commit implementation Date: Mon, 20 Jul 2015 07:56:36 +0800 Message-ID: References: <1437049241-11972-1-git-send-email-zhjwpku@gmail.com> <1437049241-11972-7-git-send-email-zhjwpku@gmail.com> <20150717090809.6c9d7d02@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0363417161==" Return-path: Received: from mail-oi0-f52.google.com (mail-oi0-f52.google.com [209.85.218.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B1F56E3E4 for ; Sun, 19 Jul 2015 16:56:37 -0700 (PDT) Received: by oige126 with SMTP id e126so99581330oig.0 for ; Sun, 19 Jul 2015 16:56:36 -0700 (PDT) In-Reply-To: <20150717090809.6c9d7d02@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Pekka Paalanen Cc: Daniel Vetter , "dri-devel@lists.freedesktop.org" List-Id: dri-devel@lists.freedesktop.org --===============0363417161== Content-Type: multipart/alternative; boundary=e89a8fb20348e27508051b432bd4 --e89a8fb20348e27508051b432bd4 Content-Type: text/plain; charset=UTF-8 Hi Pekka, Thanks for the information, I will talk to my mentor Daniel and try to find out what I can do about this. Cheers, Zhao Junwang On Fri, Jul 17, 2015 at 2:08 PM, Pekka Paalanen wrote: > On Thu, 16 Jul 2015 20:20:39 +0800 > John Hunter wrote: > > > From: Zhao Junwang > > > > This supports the asynchronous commits, required for page-flipping > > Since it's virtual hw it's ok to commit async stuff right away, we > > never have to wait for vblank. > > Hi, > > in theory, yes. This is what a patch to bochs implemented not too long > ago, so AFAIK you are only replicating the existing behaviour. > > However, if userspace doing an async commit (or sync, I suppose) does > not incur any waits in the kernel in e.g. sending the page flip event, > then flip driven programs (e.g. a Wayland compositor, say, Weston) > will be running its rendering loop as a busy-loop, because the kernel > does not throttle it to the (virtual) display refresh rate. > > This will cause maximal CPU usage and poor user experience as > everything else needs to fight for CPU time and event dispatch to get > through, like input. > > I would hope someone could do a follow-up to implement a refresh cycle > emulation based on a clock. Userspace expects page flips to happen at > most at refresh rate when asking for vblank-synced flips. It's only > natural for userspace to drive its rendering loop based on the vblank > cycle. > > > Thanks, > pq > > > Cc: Maarten Lankhorst > > Cc: Daniel Vetter > > Signed-off-by: Zhao Junwang > > --- > > drivers/gpu/drm/bochs/bochs_mm.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/bochs/bochs_mm.c > b/drivers/gpu/drm/bochs/bochs_mm.c > > index c1d819c..37ac2ca 100644 > > --- a/drivers/gpu/drm/bochs/bochs_mm.c > > +++ b/drivers/gpu/drm/bochs/bochs_mm.c > > @@ -545,8 +545,15 @@ bochs_user_framebuffer_create(struct drm_device > *dev, > > return &bochs_fb->base; > > } > > > > +static int bochs_atomic_commit(struct drm_device *dev, > > + struct drm_atomic_state *a, > > + bool async) > > +{ > > + return drm_atomic_helper_commit(dev, a, false); > > +} > > + > > const struct drm_mode_config_funcs bochs_mode_funcs = { > > .fb_create = bochs_user_framebuffer_create, > > .atomic_check = drm_atomic_helper_check, > > - .atomic_commit = drm_atomic_helper_commit, > > + .atomic_commit = bochs_atomic_commit, > > }; > > -- Best regards Junwang Zhao Microprocessor Research and Develop Center Department of Computer Science &Technology Peking University Beijing, 100871, PRC --e89a8fb20348e27508051b432bd4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Pekka,

Thanks for the information, I will = talk to my mentor Daniel and try to find out
what I can do about = this.

Cheers,
Zhao Junwang

On Fri, Jul 1= 7, 2015 at 2:08 PM, Pekka Paalanen <ppaalanen@gmail.com> w= rote:
On Thu, 16 Jul 2015 20:20:39 +0800<= br> John Hunter <zhjwpku@gmail.com&= gt; wrote:

> From: Zhao Junwang <zhjwpku@gm= ail.com>
>
> This supports the asynchronous commits, required for page-flipping
> Since it's virtual hw it's ok to commit async stuff right away= , we
> never have to wait for vblank.

Hi,

in theory, yes. This is what a patch to bochs implemented not too long
ago, so AFAIK you are only replicating the existing behaviour.

However, if userspace doing an async commit (or sync, I suppose) does
not incur any waits in the kernel in e.g. sending the page flip event,
then flip driven programs (e.g. a Wayland compositor, say, Weston)
will be running its rendering loop as a busy-loop, because the kernel
does not throttle it to the (virtual) display refresh rate.

This will cause maximal CPU usage and poor user experience as
everything else needs to fight for CPU time and event dispatch to get
through, like input.

I would hope someone could do a follow-up to implement a refresh cycle
emulation based on a clock. Userspace expects page flips to happen at
most at refresh rate when asking for vblank-synced flips. It's only
natural for userspace to drive its rendering loop based on the vblank
cycle.


Thanks,
pq

> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Daniel Vetter <daniel= .vetter@ffwll.ch>
> Signed-off-by: Zhao Junwang <z= hjwpku@gmail.com>
> ---
>=C2=A0 drivers/gpu/drm/bochs/bochs_mm.c |=C2=A0 =C2=A0 9 ++++++++-
>=C2=A0 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/= bochs_mm.c
> index c1d819c..37ac2ca 100644
> --- a/drivers/gpu/drm/bochs/bochs_mm.c
> +++ b/drivers/gpu/drm/bochs/bochs_mm.c
> @@ -545,8 +545,15 @@ bochs_user_framebuffer_create(struct drm_device *= dev,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0return &bochs_fb->base;
>=C2=A0 }
>
> +static int bochs_atomic_commit(struct drm_device *dev,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 struct drm_atomic_state *a,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 bool async)
> +{
> +=C2=A0 =C2=A0 =C2=A0return drm_atomic_helper_commit(dev, a, false); > +}
> +
>=C2=A0 const struct drm_mode_config_funcs bochs_mode_funcs =3D {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0.fb_create =3D bochs_user_framebuffer_create= ,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0.atomic_check =3D drm_atomic_helper_check, > -=C2=A0 =C2=A0 =C2=A0.atomic_commit =3D drm_atomic_helper_commit,
> +=C2=A0 =C2=A0 =C2=A0.atomic_commit =3D bochs_atomic_commit,
>=C2=A0 };




--
Best regards
Junwa= ng Zhao
Microprocessor Research and Develop Center
Depa= rtment of Computer Science &Technology
Peking University
Beijing, 100871, PRC
--e89a8fb20348e27508051b432bd4-- --===============0363417161== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9kcmktZGV2ZWwK --===============0363417161==--