From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=121.127.44.66 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796420511; b=pXPlbpm4+Nbcpn6Ydxnt54FhsT23C7tYtSzzUVCGt1KZVLTy0S0D+Ay4aQZU8VJcLX4M 3XC0CdzfVp6n1uKSXx6qCpamvQe8WEkLeou6nzZWlqLFdQMXOyKzWZtoN4oOCmxcHwqOG jRkz0QlGAO2Z5V2Q8dr5xiuVwbMmxHDbRlgV4D5LJoTcrFnZpHY2/bm/X3SiCWGQ4DbAz Hpt+k9R4sSNugpVljNQDls5F6wQ88XwqGSEYdPi5oXCOfHRoMTklRnh5nOba8gvhHWK4i 8YZIcbDkNXn/EmFpRba/mtGWzc2RUWAguAqt4KLVFAlgOXXs3a6QSntGvnqhTasAWdg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796420511; h=DMARC-Filter:DKIM-Signature:DKIM-Signature:CFBL-Feedback-ID: CFBL-Address:X-Forward-Email-ID:X-Forward-Email-Sender: X-Forward-Email-Version:X-Forward-Email-Website:X-Complaints-To: X-Report-Abuse:X-Report-Abuse-To:Message-ID:Subject:From:To:Cc:Date: In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version; bh=odXyZ2HtR1BVbEHK9BG2RidEfYOScztcaZEz049aZFw=; b=wUGEqeUEyxFzOv9jUX/GN3q6uHq78wJEtwXxIiYQQkzdIyCMrOlt2m69O8AF2KPDvkIm vQJTvdgI85g9DjpFNQkQ5xq1OnTtSa47TRganEbX5O++kemktMZS4hgzon9Ka+x2A5yN5 QS0YC3Okgg+/do+hxmhJXoo+AG0If3Byp+oEDJStairMzpB5PrVw7to+Yvuc/QM8s6iPn +zboiHPIuQKeh5Z6YMks//C7NGq5MJbebT9FOuCHesbpu0VvuO+ZjHdR0qF0Ri80u603N /uCHmGOkAffpfLWUHagVsAnZhoVY7pa9Al7m7u2jK+RWJSDqxb7MUpenCMa7U3boPZA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=maintainer.cc; spf=pass smtp.mailfrom=fe-bounces.maintainer.cc; dkim=pass header.d=maintainer.cc header.i=@maintainer.cc header.a=rsa-sha256 header.s=fe-54a0ea1b23 header.b=MJCX4ixI; dkim=pass header.d=forwardemail.net header.i=@forwardemail.net header.a=rsa-sha256 header.s=default header.b=AmLrhBmz; arc=none smtp.remote-ip=121.127.44.66 Received: from smtp.forwardemail.net (smtp.forwardemail.net [121.127.44.66]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD908606A322 for ; Fri, 4 Dec 2026 21:41:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CD908606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=maintainer.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fe-bounces.maintainer.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=maintainer.cc header.i=@maintainer.cc header.a=rsa-sha256 header.s=fe-54a0ea1b23 header.b=MJCX4ixI; dkim=pass (1024-bit key, unprotected) header.d=forwardemail.net header.i=@forwardemail.net header.a=rsa-sha256 header.s=default header.b=AmLrhBmz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maintainer.cc; h=MIME-Version: Content-Transfer-Encoding: Content-Type: References: In-Reply-To: Date: Cc: To: From: Subject: Message-ID: CFBL-Address: CFBL-Feedback-ID; q=dns/txt; s=fe-54a0ea1b23; t=1796420504; bh=odXyZ2HtR1BVbEHK9BG2RidEfYOScztcaZEz049aZFw=; b=MJCX4ixIOWfLJDnM9FPiJ8FytU87MTByzl7aksRI9FOfuNlkTzBDmqYDnl6pI3mDHmDpa4+Qx 1znPOPEkw1/YGEKwY5GwzRS7VI9OQro91LpndbM1QD0jlOgj7Q/6O4Qm+QlRUPxsu3Tk/SsvCA1 oKdekncQP3VIRnWi+OWjF4I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=forwardemail.net; h=MIME-Version: Content-Transfer-Encoding: Content-Type: References: In-Reply-To: Date: Cc: To: From: Subject: Message-ID: CFBL-Address: CFBL-Feedback-ID; q=dns/txt; s=default; t=1796420504; bh=odXyZ2HtR1BVbEHK9BG2RidEfYOScztcaZEz049aZFw=; b=AmLrhBmzwO0eH8kvkw/q4ODUzyucOXNJ6aWufBQp1wG1UQqWd8wS+S/qUJVFeBe4kPS1fwXmt k8dS1GHU/wZt93iHtsWAJcLsqtHOdeIm2nt/lP8oS8Yzk5GBz6imKPvku1y+Beb2hAYectBI/4T h9zvp3jwEl3XtN+nmQ8aOLY= CFBL-Feedback-ID: 6b133397c4bd187740cb0202:bf05151085599f5882c4bfefad762d50 CFBL-Address: abuse@forwardemail.net; report=arf X-Forward-Email-ID: 6b133397c4bd187740cb0202 X-Forward-Email-Sender: rfc822; lyude.paul@maintainer.cc, smtp.forwardemail.net, 121.127.44.66 X-Forward-Email-Version: 2.19.47 X-Forward-Email-Website: https://forwardemail.net X-Complaints-To: abuse@forwardemail.net X-Report-Abuse: abuse@forwardemail.net X-Report-Abuse-To: abuse@forwardemail.net Message-ID: Subject: Re: [PATCH] drm/nouveau/dispnv50: use exponential backoff when polling display notifiers From: Lyude Paul To: Munique Feitoza , Danilo Krummrich Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Fri, 04 Dec 2026 16:41:42 -0500 In-Reply-To: <20261201194223.3802-1-muniquefeitoz4@gmail.com> References: <20261201194223.3802-1-muniquefeitoz4@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-2.fc43) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 JFYI - it's been delayed quite a bit because I've been busy working on nova and rust KMS, but we actually do have a plan for fixing this issue which involves actually adding proper support for awaken interrupts which removes the need for busy-waiting entirely. I already have patches written up for this, there's just a few kinks around GSP I need to workout before getting it upstream. So NAK on this for the time being. On Tue, 2026-12-01 at 16:42 -0300, Munique Feitoza wrote: > The dispnv50 notifier wait helpers (base507c_ntfy_wait_begun(), > core507d_ntfy_wait_done(), corec37d_ntfy_wait_done(), > ovly827e_ntfy_wait_begun(), and the core507d/core907d caps_init > waits) > poll in a nvif_msec(..., 2000ULL, ...) loop using a fixed > usleep_range(1, 2). >=20 > Because display flip/update notifiers can take milliseconds (up to a > full > vblank interval), waking every 1-2 us causes excessive hrtimer churn, > context switches, and repeated nvif_device_time() -> > nvkm_udevice_mthd() > -> nv04_timer_read() PCIe MMIO reads on pre-Volta GPUs. >=20 > Introduce nv50_disp_ntfy_wait() in disp.h using exponential backoff > starting at 10 us and doubling up to 500 us. The fast path (notifier > already signaled on the first check) remains unchanged with zero > sleeps. >=20 > Measured on an AMD Ryzen 5 5500 + NVIDIA GeForce GT 730 (GF108) > running > v7.4.0-rc1 with clocksource=3Dtsc during 10s of 'vblank_mode=3D0 glmark2' > (perf record -F 999 -a -g; perf stat -e cycles,context- > switches,timer:hrtimer_start): >=20 > =C2=A0 Metric=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 Before=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Afte= r > =C2=A0 nv50_disp_atomic_commit_tail=C2=A0=C2=A0 35.02%=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1.50% > =C2=A0 base507c_ntfy_wait_begun=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 31.62= %=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0.66% > =C2=A0 nvkm_udevice_mthd=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=C2=A0 2.46%=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 0.04% > =C2=A0 Total CPU cycles (10s)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 27,233,642,404=C2=A0 13,252,205,119 (- > 51.3%) > =C2=A0 context-switches (10s)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 895,686=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 138,650=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (- > 84.5%) > =C2=A0 timer:hrtimer_start (10s)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 504,206=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 129,581=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (- > 74.3%) >=20 > Signed-off-by: Munique Feitoza > --- > =C2=A0drivers/gpu/drm/nouveau/dispnv50/base507c.c |=C2=A0 7 ++----- > =C2=A0drivers/gpu/drm/nouveau/dispnv50/core507d.c | 16 +++++----------- > =C2=A0drivers/gpu/drm/nouveau/dispnv50/core907d.c |=C2=A0 9 +++------ > =C2=A0drivers/gpu/drm/nouveau/dispnv50/corec37d.c |=C2=A0 7 ++----- > =C2=A0drivers/gpu/drm/nouveau/dispnv50/disp.h=C2=A0=C2=A0=C2=A0=C2=A0 | 1= 9 +++++++++++++++++++ > =C2=A0drivers/gpu/drm/nouveau/dispnv50/ovly827e.c |=C2=A0 7 ++----- > =C2=A06 files changed, 33 insertions(+), 32 deletions(-) >=20 > diff --git a/drivers/gpu/drm/nouveau/dispnv50/base507c.c > b/drivers/gpu/drm/nouveau/dispnv50/base507c.c > index 41b648ab3c5e57..2f7ac655db898d 100644 > --- a/drivers/gpu/drm/nouveau/dispnv50/base507c.c > +++ b/drivers/gpu/drm/nouveau/dispnv50/base507c.c > @@ -147,11 +147,8 @@ int > =C2=A0base507c_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset, > =C2=A0 struct nvif_device *device) > =C2=A0{ > - s64 time =3D nvif_msec(device, 2000ULL, > - if (NVBO_TD32(bo, offset, NV_DISP_BASE_NOTIFIER_1, > _0, STATUS, =3D=3D, BEGUN)) > - break; > - usleep_range(1, 2); > - ); > + s64 time =3D nv50_disp_ntfy_wait(device, > + NVBO_TD32(bo, offset, NV_DISP_BASE_NOTIFIER_1, _0, > STATUS, =3D=3D, BEGUN)); > =C2=A0 return time < 0 ? time : 0; > =C2=A0} > =C2=A0 > diff --git a/drivers/gpu/drm/nouveau/dispnv50/core507d.c > b/drivers/gpu/drm/nouveau/dispnv50/core507d.c > index 46c94548052259..afd6fb87eeb5cb 100644 > --- a/drivers/gpu/drm/nouveau/dispnv50/core507d.c > +++ b/drivers/gpu/drm/nouveau/dispnv50/core507d.c > @@ -62,11 +62,8 @@ int > =C2=A0core507d_ntfy_wait_done(struct nouveau_bo *bo, u32 offset, > =C2=A0 struct nvif_device *device) > =C2=A0{ > - s64 time =3D nvif_msec(device, 2000ULL, > - if (NVBO_TD32(bo, offset, NV_DISP_CORE_NOTIFIER_1, > COMPLETION_0, DONE, =3D=3D, TRUE)) > - break; > - usleep_range(1, 2); > - ); > + s64 time =3D nv50_disp_ntfy_wait(device, > + NVBO_TD32(bo, offset, NV_DISP_CORE_NOTIFIER_1, > COMPLETION_0, DONE, =3D=3D, TRUE)); > =C2=A0 return time < 0 ? time : 0; > =C2=A0} > =C2=A0 > @@ -115,12 +112,9 @@ core507d_caps_init(struct nouveau_drm *drm, > struct nv50_disp *disp) > =C2=A0 if (ret < 0) > =C2=A0 return ret; > =C2=A0 > - time =3D nvif_msec(core->chan.base.device, 2000ULL, > - if (NVBO_TD32(bo, NV50_DISP_CORE_NTFY, > - =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NV_DISP_CORE_NOTIFIER_1, > CAPABILITIES_1, DONE, =3D=3D, TRUE)) > - break; > - usleep_range(1, 2); > - ); > + time =3D nv50_disp_ntfy_wait(core->chan.base.device, > + NVBO_TD32(bo, NV50_DISP_CORE_NTFY, > + =C2=A0 NV_DISP_CORE_NOTIFIER_1, CAPABILITIES_1, > DONE, =3D=3D, TRUE)); > =C2=A0 if (time < 0) > =C2=A0 NV_ERROR(drm, "core caps notifier timeout\n"); > =C2=A0 > diff --git a/drivers/gpu/drm/nouveau/dispnv50/core907d.c > b/drivers/gpu/drm/nouveau/dispnv50/core907d.c > index 8564d4dffaff0a..ca5f9692ef9df6 100644 > --- a/drivers/gpu/drm/nouveau/dispnv50/core907d.c > +++ b/drivers/gpu/drm/nouveau/dispnv50/core907d.c > @@ -44,12 +44,9 @@ core907d_caps_init(struct nouveau_drm *drm, struct > nv50_disp *disp) > =C2=A0 if (ret < 0) > =C2=A0 return ret; > =C2=A0 > - time =3D nvif_msec(core->chan.base.device, 2000ULL, > - if (NVBO_TD32(bo, NV50_DISP_CORE_NTFY, > - =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NV907D_CORE_NOTIFIER_3, > CAPABILITIES_4, DONE, =3D=3D, TRUE)) > - break; > - usleep_range(1, 2); > - ); > + time =3D nv50_disp_ntfy_wait(core->chan.base.device, > + NVBO_TD32(bo, NV50_DISP_CORE_NTFY, > + =C2=A0 NV907D_CORE_NOTIFIER_3, CAPABILITIES_4, > DONE, =3D=3D, TRUE)); > =C2=A0 if (time < 0) > =C2=A0 NV_ERROR(drm, "core caps notifier timeout\n"); > =C2=A0 > diff --git a/drivers/gpu/drm/nouveau/dispnv50/corec37d.c > b/drivers/gpu/drm/nouveau/dispnv50/corec37d.c > index 83eec2f091f02e..ccf3e441ee8dca 100644 > --- a/drivers/gpu/drm/nouveau/dispnv50/corec37d.c > +++ b/drivers/gpu/drm/nouveau/dispnv50/corec37d.c > @@ -82,11 +82,8 @@ int > =C2=A0corec37d_ntfy_wait_done(struct nouveau_bo *bo, u32 offset, > =C2=A0 struct nvif_device *device) > =C2=A0{ > - s64 time =3D nvif_msec(device, 2000ULL, > - if (NVBO_TD32(bo, offset, NV_DISP_NOTIFIER, _0, > STATUS, =3D=3D, FINISHED)) > - break; > - usleep_range(1, 2); > - ); > + s64 time =3D nv50_disp_ntfy_wait(device, > + NVBO_TD32(bo, offset, NV_DISP_NOTIFIER, _0, STATUS, > =3D=3D, FINISHED)); > =C2=A0 return time < 0 ? time : 0; > =C2=A0} > =C2=A0 > diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.h > b/drivers/gpu/drm/nouveau/dispnv50/disp.h > index 5d998f0319dcc2..b98e183d4e12a8 100644 > --- a/drivers/gpu/drm/nouveau/dispnv50/disp.h > +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.h > @@ -1,8 +1,11 @@ > =C2=A0#ifndef __NV50_KMS_H__ > =C2=A0#define __NV50_KMS_H__ > +#include > +#include > =C2=A0#include > =C2=A0#include > =C2=A0#include > +#include > =C2=A0 > =C2=A0#include "nouveau_display.h" > =C2=A0 > @@ -105,4 +108,20 @@ extern const u64 disp50xx_modifiers[]; > =C2=A0extern const u64 disp90xx_modifiers[]; > =C2=A0extern const u64 wndwc57e_modifiers[]; > =C2=A0extern const u64 wndwca7e_modifiers[]; > + > +/* > + * Display notifiers (flip/update completion) can take up to a full > frame > + * (~16 ms) to signal. Back off the sleep interval exponentially > instead of > + * polling every 1-2 us, avoiding excessive hrtimer churn and PTIMER > MMIO > + * reads on pre-Volta GPUs. > + */ > +#define nv50_disp_ntfy_wait(device, cond) > ({ \ > + unsigned long _delay_us =3D > 10; \ > + nvif_msec((device), > 2000ULL, \ > + if > (cond) \ > + break; =09 > \ > + usleep_range(_delay_us, _delay_us * > 2); \ > + _delay_us =3D min(_delay_us * 2, > 500UL); \ > + ); =09 > \ > +}) > =C2=A0#endif > diff --git a/drivers/gpu/drm/nouveau/dispnv50/ovly827e.c > b/drivers/gpu/drm/nouveau/dispnv50/ovly827e.c > index a5ae22ed663d7d..06d6a74b0e3cbb 100644 > --- a/drivers/gpu/drm/nouveau/dispnv50/ovly827e.c > +++ b/drivers/gpu/drm/nouveau/dispnv50/ovly827e.c > @@ -69,11 +69,8 @@ int > =C2=A0ovly827e_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset, > =C2=A0 struct nvif_device *device) > =C2=A0{ > - s64 time =3D nvif_msec(device, 2000ULL, > - if (NVBO_TD32(bo, offset, NV_DISP_NOTIFICATION_1, > _3, STATUS, =3D=3D, BEGUN)) > - break; > - usleep_range(1, 2); > - ); > + s64 time =3D nv50_disp_ntfy_wait(device, > + NVBO_TD32(bo, offset, NV_DISP_NOTIFICATION_1, _3, > STATUS, =3D=3D, BEGUN)); > =C2=A0 return time < 0 ? time : 0; > =C2=A0} > =C2=A0