From: Tong Zhang <ztong0001@gmail.com>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
Sam Ravnborg <sam@ravnborg.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] video: fbdev: pm2fb: avoid stall on fb_sync
Date: Sat, 20 Feb 2021 19:00:31 -0500 [thread overview]
Message-ID: <CAA5qM4D0y9-gL7AAMQvtwrfJC_UvSTB5_S5PX3qkYSxHRUS-Qw@mail.gmail.com> (raw)
In-Reply-To: <ea1c5ff3-0b24-71c9-7a44-08b184c4854d@infradead.org>
Hi Randy,
Thanks for the comment.
I currently have this problem on my machine.
I have submitted a revised patch -- which includes the console log.
Thanks!
- Tong
On Sat, Feb 20, 2021 at 6:33 PM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> Hi--
>
> On 2/20/21 3:02 PM, Tong Zhang wrote:
> > pm2fb_sync is called when doing /dev/fb read or write.
> > The original pm2fb_sync wait indefinitely on hardware flags which can
> > possibly stall kernel and make everything unresponsive.
> > Instead of waiting indefinitely, we can timeout to give user a chance to
> > get back control.
>
> Is this a real problem or theoretical?
> Does someone still use this driver?
>
>
> > Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> > ---
> > drivers/video/fbdev/pm2fb.c | 29 ++++++++++++++++++++++++++---
> > 1 file changed, 26 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c
> > index 27893fa139b0..8578c64a0c54 100644
> > --- a/drivers/video/fbdev/pm2fb.c
> > +++ b/drivers/video/fbdev/pm2fb.c
> > @@ -183,12 +183,23 @@ static inline void pm2v_RDAC_WR(struct pm2fb_par *p, s32 idx, u32 v)
> >
> > #ifdef CONFIG_FB_PM2_FIFO_DISCONNECT
> > #define WAIT_FIFO(p, a)
> > +#define WAIT_FIFO_TIMEOUT(p, a) (0)
> > #else
> > static inline void WAIT_FIFO(struct pm2fb_par *p, u32 a)
> > {
> > while (pm2_RD(p, PM2R_IN_FIFO_SPACE) < a)
> > cpu_relax();
> > }
> > +static int inline void WAIT_FIFO_TIMEOUT(struct pm2fb_par *p, u32 a)
>
> drop void ^^^
> It's already "int".
> Did you compile this?
>
> > +{
> > + int timeout = 10000;
> > + while (pm2_RD(p, PM2R_IN_FIFO_SPACE) < a) {
> > + cpu_relax();
> > + if (--timeout==0)
>
> spaces around ==
>
> > + return 1;
> > + }
> > + return 0;
> > +}
> > #endif
> >
> > /*
> > @@ -1031,15 +1042,27 @@ static int pm2fb_blank(int blank_mode, struct fb_info *info)
> > static int pm2fb_sync(struct fb_info *info)
> > {
> > struct pm2fb_par *par = info->par;
> > + int timeout_sync = 10000;
> > + int timeout_fifo;
> >
> > - WAIT_FIFO(par, 1);
> > + if (WAIT_FIFO_TIMEOUT(par, 1))
> > + goto end;
> > pm2_WR(par, PM2R_SYNC, 0);
> > mb();
> > do {
> > - while (pm2_RD(par, PM2R_OUT_FIFO_WORDS) == 0)
> > + timeout_fifo = 10000;
> > + while (pm2_RD(par, PM2R_OUT_FIFO_WORDS) == 0) {
> > cpu_relax();
> > - } while (pm2_RD(par, PM2R_OUT_FIFO) != PM2TAG(PM2R_SYNC));
> > + if (--timeout_fifo==0)
>
> spaces around ==
>
> > + goto end;
> > + }
> > + if (pm2_RD(par, PM2R_OUT_FIFO) == PM2TAG(PM2R_SYNC))
> > + break;
> > + } while (--timeout_sync>0);
>
> spaces around >
>
> >
> > +end:
> > + if ((!timeout_sync) || (!timeout_fifo))
> > + printk_ratelimited(KERN_WARNING "pm2fb: sync timeout!\n");
> > return 0;
> > }
> >
> >
>
>
> thanks.
> --
> ~Randy
next prev parent reply other threads:[~2021-02-21 0:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-20 23:02 [PATCH] video: fbdev: pm2fb: avoid stall on fb_sync Tong Zhang
2021-02-20 23:32 ` Randy Dunlap
2021-02-21 0:00 ` [PATCH v2] " Tong Zhang
2021-02-21 0:35 ` Randy Dunlap
2021-02-21 2:28 ` [PATCH v3] " Tong Zhang
2021-02-21 2:34 ` [PATCH v2] " Tong Zhang
2021-02-21 0:00 ` Tong Zhang [this message]
2021-02-24 11:35 ` [PATCH] " Geert Uytterhoeven
2021-02-24 12:24 ` Tong Zhang
2021-02-21 0:51 ` kernel test robot
2021-02-21 2:02 ` kernel test robot
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=CAA5qM4D0y9-gL7AAMQvtwrfJC_UvSTB5_S5PX3qkYSxHRUS-Qw@mail.gmail.com \
--to=ztong0001@gmail.com \
--cc=b.zolnierkie@samsung.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavoars@kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=sam@ravnborg.org \
/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;
as well as URLs for NNTP newsgroup(s).