All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/dbi: Print errors for mipi_dbi_command()
@ 2021-07-01 22:25 Linus Walleij
  2021-07-02  5:45 ` Sam Ravnborg
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2021-07-01 22:25 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, dri-devel
  Cc: Noralf Trønnes, Douglas Anderson

The macro mipi_dbi_command() does not report errors unless you wrap it
in another macro to do the error reporting.

Report a rate-limited error so we know what is going on.

Drop the only user in DRM using mipi_dbi_command() and actually checking
the error explicitly, let it use mipi_dbi_command_buf() directly
instead.

After this any code wishing to send command arrays can rely on
mipi_dbi_command() providing an appropriate error message if something
goes wrong.

Suggested-by: Noralf Trønnes <noralf@tronnes.org>
Suggested-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpu/drm/drm_mipi_dbi.c | 2 +-
 include/drm/drm_mipi_dbi.h     | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index 3854fb9798e9..c7c1b75df190 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -645,7 +645,7 @@ static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi_dev *dbidev, bool
 		return 1;
 
 	mipi_dbi_hw_reset(dbi);
-	ret = mipi_dbi_command(dbi, MIPI_DCS_SOFT_RESET);
+	ret = mipi_dbi_command_buf(dbi, MIPI_DCS_SOFT_RESET, NULL, 0);
 	if (ret) {
 		DRM_DEV_ERROR(dev, "Failed to send reset command (%d)\n", ret);
 		if (dbidev->regulator)
diff --git a/include/drm/drm_mipi_dbi.h b/include/drm/drm_mipi_dbi.h
index f543d6e3e822..2057ad32760c 100644
--- a/include/drm/drm_mipi_dbi.h
+++ b/include/drm/drm_mipi_dbi.h
@@ -183,7 +183,10 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,
 #define mipi_dbi_command(dbi, cmd, seq...) \
 ({ \
 	const u8 d[] = { seq }; \
-	mipi_dbi_command_stackbuf(dbi, cmd, d, ARRAY_SIZE(d)); \
+	int ret; \
+	ret = mipi_dbi_command_stackbuf(dbi, cmd, d, ARRAY_SIZE(d)); \
+	if (ret) \
+		pr_err_ratelimited("MIPI DBI: error %d when sending command\n", ret); \
 })
 
 #ifdef CONFIG_DEBUG_FS
-- 
2.31.1


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

* Re: [PATCH] drm/dbi: Print errors for mipi_dbi_command()
  2021-07-01 22:25 [PATCH] drm/dbi: Print errors for mipi_dbi_command() Linus Walleij
@ 2021-07-02  5:45 ` Sam Ravnborg
  2021-07-02  9:58   ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Sam Ravnborg @ 2021-07-02  5:45 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Thierry Reding, Douglas Anderson, dri-devel, Noralf Trønnes

Hi Linus,

On Fri, Jul 02, 2021 at 12:25:18AM +0200, Linus Walleij wrote:
> The macro mipi_dbi_command() does not report errors unless you wrap it
> in another macro to do the error reporting.
> 
> Report a rate-limited error so we know what is going on.
> 
> Drop the only user in DRM using mipi_dbi_command() and actually checking
> the error explicitly, let it use mipi_dbi_command_buf() directly
> instead.
> 
> After this any code wishing to send command arrays can rely on
> mipi_dbi_command() providing an appropriate error message if something
> goes wrong.
> 
> Suggested-by: Noralf Trønnes <noralf@tronnes.org>
> Suggested-by: Douglas Anderson <dianders@chromium.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpu/drm/drm_mipi_dbi.c | 2 +-
>  include/drm/drm_mipi_dbi.h     | 5 ++++-
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
> index 3854fb9798e9..c7c1b75df190 100644
> --- a/drivers/gpu/drm/drm_mipi_dbi.c
> +++ b/drivers/gpu/drm/drm_mipi_dbi.c
> @@ -645,7 +645,7 @@ static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi_dev *dbidev, bool
>  		return 1;
>  
>  	mipi_dbi_hw_reset(dbi);
> -	ret = mipi_dbi_command(dbi, MIPI_DCS_SOFT_RESET);
> +	ret = mipi_dbi_command_buf(dbi, MIPI_DCS_SOFT_RESET, NULL, 0);
>  	if (ret) {
>  		DRM_DEV_ERROR(dev, "Failed to send reset command (%d)\n", ret);
>  		if (dbidev->regulator)
I do not see the value in this change??
There are many other mipi_dbi_command() users and the error return
continues to be checked?!??!


> diff --git a/include/drm/drm_mipi_dbi.h b/include/drm/drm_mipi_dbi.h
> index f543d6e3e822..2057ad32760c 100644
> --- a/include/drm/drm_mipi_dbi.h
> +++ b/include/drm/drm_mipi_dbi.h
> @@ -183,7 +183,10 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,
>  #define mipi_dbi_command(dbi, cmd, seq...) \
>  ({ \
>  	const u8 d[] = { seq }; \
> -	mipi_dbi_command_stackbuf(dbi, cmd, d, ARRAY_SIZE(d)); \
> +	int ret; \
> +	ret = mipi_dbi_command_stackbuf(dbi, cmd, d, ARRAY_SIZE(d)); \
> +	if (ret) \
> +		pr_err_ratelimited("MIPI DBI: error %d when sending command\n", ret); \
>  })
Coud this be more informative if the spi device was printed, it is
available? Maybe in 99% of the cases there is only one user anyway so it
will not help?

	Sam

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

* Re: [PATCH] drm/dbi: Print errors for mipi_dbi_command()
  2021-07-02  5:45 ` Sam Ravnborg
@ 2021-07-02  9:58   ` Linus Walleij
  2021-07-02 10:26     ` Sam Ravnborg
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2021-07-02  9:58 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Thierry Reding, Douglas Anderson, open list:DRM PANEL DRIVERS,
	Noralf Trønnes

On Fri, Jul 2, 2021 at 7:45 AM Sam Ravnborg <sam@ravnborg.org> wrote:

> > -     ret = mipi_dbi_command(dbi, MIPI_DCS_SOFT_RESET);
> > +     ret = mipi_dbi_command_buf(dbi, MIPI_DCS_SOFT_RESET, NULL, 0);
> >       if (ret) {
> >               DRM_DEV_ERROR(dev, "Failed to send reset command (%d)\n", ret);
> >               if (dbidev->regulator)
>
> I do not see the value in this change??
> There are many other mipi_dbi_command() users and the error return
> continues to be checked?!??!

When we change the mipi_dbi_command() macro to check the error
value we can no longer retrieve the return value from the macro
so we need to use the call the command buf directly so that we
can obtain the return code.

I do not know any other way. Suggestions welcome!

> >  #define mipi_dbi_command(dbi, cmd, seq...) \
> >  ({ \
> >       const u8 d[] = { seq }; \
> > -     mipi_dbi_command_stackbuf(dbi, cmd, d, ARRAY_SIZE(d)); \
> > +     int ret; \
> > +     ret = mipi_dbi_command_stackbuf(dbi, cmd, d, ARRAY_SIZE(d)); \
> > +     if (ret) \
> > +             pr_err_ratelimited("MIPI DBI: error %d when sending command\n", ret); \
> >  })
>
> Coud this be more informative if the spi device was printed, it is
> available? Maybe in 99% of the cases there is only one user anyway so it
> will not help?

Hm I can get to the SPI device, lemme try this.

Yours,
Linus Walleij

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

* Re: [PATCH] drm/dbi: Print errors for mipi_dbi_command()
  2021-07-02  9:58   ` Linus Walleij
@ 2021-07-02 10:26     ` Sam Ravnborg
  0 siblings, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2021-07-02 10:26 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Thierry Reding, Douglas Anderson, open list:DRM PANEL DRIVERS,
	Noralf Trønnes

Hi Linus,

On Fri, Jul 02, 2021 at 11:58:52AM +0200, Linus Walleij wrote:
> On Fri, Jul 2, 2021 at 7:45 AM Sam Ravnborg <sam@ravnborg.org> wrote:
> 
> > > -     ret = mipi_dbi_command(dbi, MIPI_DCS_SOFT_RESET);
> > > +     ret = mipi_dbi_command_buf(dbi, MIPI_DCS_SOFT_RESET, NULL, 0);
> > >       if (ret) {
> > >               DRM_DEV_ERROR(dev, "Failed to send reset command (%d)\n", ret);
> > >               if (dbidev->regulator)
> >
> > I do not see the value in this change??
> > There are many other mipi_dbi_command() users and the error return
> > continues to be checked?!??!
> 
> When we change the mipi_dbi_command() macro to check the error
> value we can no longer retrieve the return value from the macro
> so we need to use the call the command buf directly so that we
> can obtain the return code.
Thanks, got it now.

	Sam

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

end of thread, other threads:[~2021-07-02 10:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 22:25 [PATCH] drm/dbi: Print errors for mipi_dbi_command() Linus Walleij
2021-07-02  5:45 ` Sam Ravnborg
2021-07-02  9:58   ` Linus Walleij
2021-07-02 10:26     ` Sam Ravnborg

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.