All of lore.kernel.org
 help / color / mirror / Atom feed
* [psplash][PATCH 1/1] psplash-fb: Avoid racing issues on reading fb0
@ 2020-02-13 10:30 Andrei Gherzan
  2020-02-14  7:32 ` [yocto] " Khem Raj
  0 siblings, 1 reply; 4+ messages in thread
From: Andrei Gherzan @ 2020-02-13 10:30 UTC (permalink / raw)
  To: yocto; +Cc: Andrei Gherzan

When starting psplash as early as possible in the boot process, the fb
device node might not be ready. This patch adds a loop on reading the
fb0 device with a timeout of 5 seconds.

Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
---
 psplash-fb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/psplash-fb.c b/psplash-fb.c
index 6603572..6700a3b 100644
--- a/psplash-fb.c
+++ b/psplash-fb.c
@@ -137,6 +137,7 @@ psplash_fb_new (int angle, int fbdev_id)
   struct fb_fix_screeninfo fb_fix;
   int                      off;
   char                     fbdev[9] = "/dev/fb0";
+  int retries = 0;
 
   PSplashFB *fb = NULL;
 
@@ -156,7 +157,9 @@ psplash_fb_new (int angle, int fbdev_id)
 
   fb->fd = -1;
 
-  if ((fb->fd = open (fbdev, O_RDWR)) < 0)
+  while ((fb->fd = open(fbdev, O_RDWR)) < 0 && retries++ <= 100)
+	  usleep(50000);
+  if (fb->fd < 0)
     {
       fprintf(stderr,
               "Error opening %s\n",
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [yocto] [psplash][PATCH 1/1] psplash-fb: Avoid racing issues on reading fb0
  2020-02-13 10:30 [psplash][PATCH 1/1] psplash-fb: Avoid racing issues on reading fb0 Andrei Gherzan
@ 2020-02-14  7:32 ` Khem Raj
  2020-02-20 17:58   ` Andrei Gherzan
  0 siblings, 1 reply; 4+ messages in thread
From: Khem Raj @ 2020-02-14  7:32 UTC (permalink / raw)
  To: Andrei Gherzan, yocto

On 2/13/20 2:30 AM, Andrei Gherzan wrote:
> When starting psplash as early as possible in the boot process, the fb
> device node might not be ready. This patch adds a loop on reading the
> fb0 device with a timeout of 5 seconds.
> 
> Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
> ---
>   psplash-fb.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/psplash-fb.c b/psplash-fb.c
> index 6603572..6700a3b 100644
> --- a/psplash-fb.c
> +++ b/psplash-fb.c
> @@ -137,6 +137,7 @@ psplash_fb_new (int angle, int fbdev_id)
>     struct fb_fix_screeninfo fb_fix;
>     int                      off;
>     char                     fbdev[9] = "/dev/fb0";
> +  int retries = 0;
>   
>     PSplashFB *fb = NULL;
>   
> @@ -156,7 +157,9 @@ psplash_fb_new (int angle, int fbdev_id)
>   
>     fb->fd = -1;
>   
> -  if ((fb->fd = open (fbdev, O_RDWR)) < 0)
> +  while ((fb->fd = open(fbdev, O_RDWR)) < 0 && retries++ <= 100)
> +	  usleep(50000);
> +  if (fb->fd < 0)

i wonder if there should be a different way to ensure this dependency 
perhaps sd_notify for systemd or udev notification maybe ..

>       {
>         fprintf(stderr,
>                 "Error opening %s\n",
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [yocto] [psplash][PATCH 1/1] psplash-fb: Avoid racing issues on reading fb0
  2020-02-14  7:32 ` [yocto] " Khem Raj
@ 2020-02-20 17:58   ` Andrei Gherzan
  2020-02-20 18:03     ` Khem Raj
  0 siblings, 1 reply; 4+ messages in thread
From: Andrei Gherzan @ 2020-02-20 17:58 UTC (permalink / raw)
  To: Khem Raj; +Cc: yocto

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

Hi,

On Fri, Feb 14, 2020 at 7:32 AM Khem Raj <raj.khem@gmail.com> wrote:

> On 2/13/20 2:30 AM, Andrei Gherzan wrote:
> > When starting psplash as early as possible in the boot process, the fb
> > device node might not be ready. This patch adds a loop on reading the
> > fb0 device with a timeout of 5 seconds.
> >
> > Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
> > ---
> >   psplash-fb.c | 5 ++++-
> >   1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/psplash-fb.c b/psplash-fb.c
> > index 6603572..6700a3b 100644
> > --- a/psplash-fb.c
> > +++ b/psplash-fb.c
> > @@ -137,6 +137,7 @@ psplash_fb_new (int angle, int fbdev_id)
> >     struct fb_fix_screeninfo fb_fix;
> >     int                      off;
> >     char                     fbdev[9] = "/dev/fb0";
> > +  int retries = 0;
> >
> >     PSplashFB *fb = NULL;
> >
> > @@ -156,7 +157,9 @@ psplash_fb_new (int angle, int fbdev_id)
> >
> >     fb->fd = -1;
> >
> > -  if ((fb->fd = open (fbdev, O_RDWR)) < 0)
> > +  while ((fb->fd = open(fbdev, O_RDWR)) < 0 && retries++ <= 100)
> > +       usleep(50000);
> > +  if (fb->fd < 0)
>
> i wonder if there should be a different way to ensure this dependency
> perhaps sd_notify for systemd or udev notification maybe ..
>

That makes sense. The only issue is that in my use-case, initramfs doesn't
have systemd. And usually, you will be wanting to run a splash way before
any init system. What is your proposal with udev notifications? Can you
expand that?

Regards,
Andrei

[-- Attachment #2: Type: text/html, Size: 2220 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [yocto] [psplash][PATCH 1/1] psplash-fb: Avoid racing issues on reading fb0
  2020-02-20 17:58   ` Andrei Gherzan
@ 2020-02-20 18:03     ` Khem Raj
  0 siblings, 0 replies; 4+ messages in thread
From: Khem Raj @ 2020-02-20 18:03 UTC (permalink / raw)
  To: Andrei Gherzan; +Cc: yocto



On 2/20/20 9:58 AM, Andrei Gherzan wrote:
> Hi,
> 
> On Fri, Feb 14, 2020 at 7:32 AM Khem Raj <raj.khem@gmail.com 
> <mailto:raj.khem@gmail.com>> wrote:
> 
>     On 2/13/20 2:30 AM, Andrei Gherzan wrote:
>      > When starting psplash as early as possible in the boot process,
>     the fb
>      > device node might not be ready. This patch adds a loop on reading the
>      > fb0 device with a timeout of 5 seconds.
>      >
>      > Signed-off-by: Andrei Gherzan <andrei@gherzan.ro
>     <mailto:andrei@gherzan.ro>>
>      > ---
>      >   psplash-fb.c | 5 ++++-
>      >   1 file changed, 4 insertions(+), 1 deletion(-)
>      >
>      > diff --git a/psplash-fb.c b/psplash-fb.c
>      > index 6603572..6700a3b 100644
>      > --- a/psplash-fb.c
>      > +++ b/psplash-fb.c
>      > @@ -137,6 +137,7 @@ psplash_fb_new (int angle, int fbdev_id)
>      >     struct fb_fix_screeninfo fb_fix;
>      >     int                      off;
>      >     char                     fbdev[9] = "/dev/fb0";
>      > +  int retries = 0;
>      >
>      >     PSplashFB *fb = NULL;
>      >
>      > @@ -156,7 +157,9 @@ psplash_fb_new (int angle, int fbdev_id)
>      >
>      >     fb->fd = -1;
>      >
>      > -  if ((fb->fd = open (fbdev, O_RDWR)) < 0)
>      > +  while ((fb->fd = open(fbdev, O_RDWR)) < 0 && retries++ <= 100)
>      > +       usleep(50000);
>      > +  if (fb->fd < 0)
> 
>     i wonder if there should be a different way to ensure this dependency
>     perhaps sd_notify for systemd or udev notification maybe ..
> 
> 
> That makes sense. The only issue is that in my use-case, initramfs 
> doesn't have systemd. And usually, you will be wanting to run a splash 
> way before any init system. What is your proposal with udev 
> notifications? Can you expand that?
> 

something like 
https://www.tecmint.com/udev-for-device-detection-management-in-linux/


> Regards,
> Andrei

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-20 18:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-13 10:30 [psplash][PATCH 1/1] psplash-fb: Avoid racing issues on reading fb0 Andrei Gherzan
2020-02-14  7:32 ` [yocto] " Khem Raj
2020-02-20 17:58   ` Andrei Gherzan
2020-02-20 18:03     ` Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.