linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: fix stack usage warning on old gcc
@ 2020-04-28 21:53 Arnd Bergmann
  2020-04-29  7:56 ` Tomi Valkeinen
  2020-04-29 20:46 ` Sam Ravnborg
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2020-04-28 21:53 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, David Airlie, Daniel Vetter,
	Peter Ujfalusi
  Cc: Arnd Bergmann, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Tomi Valkeinen, Boris Brezillon, Sebastian Reichel, dri-devel,
	linux-kernel

Some older versions of gcc badly optimize code that passes
an inline function argument into another function by reference,
causing huge stack usage:

drivers/gpu/drm/bridge/tc358768.c: In function 'tc358768_bridge_pre_enable':
drivers/gpu/drm/bridge/tc358768.c:840:1: error: the frame size of 2256 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]

Use a temporary variable as a workaround and add a comment pointing
to the gcc bug.

Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/bridge/tc358768.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c
index 1b39e8d37834..6650fe4cfc20 100644
--- a/drivers/gpu/drm/bridge/tc358768.c
+++ b/drivers/gpu/drm/bridge/tc358768.c
@@ -178,6 +178,8 @@ static int tc358768_clear_error(struct tc358768_priv *priv)
 
 static void tc358768_write(struct tc358768_priv *priv, u32 reg, u32 val)
 {
+	/* work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */
+	int tmpval = val;
 	size_t count = 2;
 
 	if (priv->error)
@@ -187,7 +189,7 @@ static void tc358768_write(struct tc358768_priv *priv, u32 reg, u32 val)
 	if (reg < 0x100 || reg >= 0x600)
 		count = 1;
 
-	priv->error = regmap_bulk_write(priv->regmap, reg, &val, count);
+	priv->error = regmap_bulk_write(priv->regmap, reg, &tmpval, count);
 }
 
 static void tc358768_read(struct tc358768_priv *priv, u32 reg, u32 *val)
-- 
2.26.0


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

* Re: [PATCH] drm/bridge: fix stack usage warning on old gcc
  2020-04-28 21:53 [PATCH] drm/bridge: fix stack usage warning on old gcc Arnd Bergmann
@ 2020-04-29  7:56 ` Tomi Valkeinen
  2020-04-29  8:02   ` Arnd Bergmann
  2020-04-29 20:46 ` Sam Ravnborg
  1 sibling, 1 reply; 5+ messages in thread
From: Tomi Valkeinen @ 2020-04-29  7:56 UTC (permalink / raw)
  To: Arnd Bergmann, Andrzej Hajda, Neil Armstrong, David Airlie,
	Daniel Vetter, Peter Ujfalusi
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Boris Brezillon,
	Sebastian Reichel, dri-devel, linux-kernel

On 29/04/2020 00:53, Arnd Bergmann wrote:
> Some older versions of gcc badly optimize code that passes
> an inline function argument into another function by reference,
> causing huge stack usage:
> 
> drivers/gpu/drm/bridge/tc358768.c: In function 'tc358768_bridge_pre_enable':
> drivers/gpu/drm/bridge/tc358768.c:840:1: error: the frame size of 2256 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
> 
> Use a temporary variable as a workaround and add a comment pointing
> to the gcc bug.
> 
> Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/gpu/drm/bridge/tc358768.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c
> index 1b39e8d37834..6650fe4cfc20 100644
> --- a/drivers/gpu/drm/bridge/tc358768.c
> +++ b/drivers/gpu/drm/bridge/tc358768.c
> @@ -178,6 +178,8 @@ static int tc358768_clear_error(struct tc358768_priv *priv)
>   
>   static void tc358768_write(struct tc358768_priv *priv, u32 reg, u32 val)
>   {
> +	/* work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */
> +	int tmpval = val;
>   	size_t count = 2;
>   
>   	if (priv->error)
> @@ -187,7 +189,7 @@ static void tc358768_write(struct tc358768_priv *priv, u32 reg, u32 val)
>   	if (reg < 0x100 || reg >= 0x600)
>   		count = 1;
>   
> -	priv->error = regmap_bulk_write(priv->regmap, reg, &val, count);
> +	priv->error = regmap_bulk_write(priv->regmap, reg, &tmpval, count);
>   }
>   
>   static void tc358768_read(struct tc358768_priv *priv, u32 reg, u32 *val)
> 

tc358768_write is not inline. What is the inline function here? Or is tc358768_write optimized to 
inline by the compiler?

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH] drm/bridge: fix stack usage warning on old gcc
  2020-04-29  7:56 ` Tomi Valkeinen
@ 2020-04-29  8:02   ` Arnd Bergmann
  2020-04-29  8:13     ` Tomi Valkeinen
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2020-04-29  8:02 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Andrzej Hajda, Neil Armstrong, David Airlie, Daniel Vetter,
	Peter Ujfalusi, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Boris Brezillon, Sebastian Reichel, dri-devel, linux-kernel

On Wed, Apr 29, 2020 at 9:56 AM Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
> > diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c
> > index 1b39e8d37834..6650fe4cfc20 100644
> > --- a/drivers/gpu/drm/bridge/tc358768.c
> > +++ b/drivers/gpu/drm/bridge/tc358768.c
> > @@ -178,6 +178,8 @@ static int tc358768_clear_error(struct tc358768_priv *priv)
> >
> >   static void tc358768_write(struct tc358768_priv *priv, u32 reg, u32 val)
> >   {
> > +     /* work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */
> > +     int tmpval = val;

>
> tc358768_write is not inline. What is the inline function here? Or is tc358768_write optimized to
> inline by the compiler?

I missed the lack of an explicit inline tag when looking at the bug. gcc
usually decides which functions to inline on its own, so there is little
difference in practice. Let me know if I should clarify the changelog and
resend it.

      Arnd

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

* Re: [PATCH] drm/bridge: fix stack usage warning on old gcc
  2020-04-29  8:02   ` Arnd Bergmann
@ 2020-04-29  8:13     ` Tomi Valkeinen
  0 siblings, 0 replies; 5+ messages in thread
From: Tomi Valkeinen @ 2020-04-29  8:13 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Andrzej Hajda, Neil Armstrong, David Airlie, Daniel Vetter,
	Peter Ujfalusi, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Boris Brezillon, Sebastian Reichel, dri-devel, linux-kernel

On 29/04/2020 11:02, Arnd Bergmann wrote:
> On Wed, Apr 29, 2020 at 9:56 AM Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
>>> diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c
>>> index 1b39e8d37834..6650fe4cfc20 100644
>>> --- a/drivers/gpu/drm/bridge/tc358768.c
>>> +++ b/drivers/gpu/drm/bridge/tc358768.c
>>> @@ -178,6 +178,8 @@ static int tc358768_clear_error(struct tc358768_priv *priv)
>>>
>>>    static void tc358768_write(struct tc358768_priv *priv, u32 reg, u32 val)
>>>    {
>>> +     /* work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */
>>> +     int tmpval = val;
> 
>>
>> tc358768_write is not inline. What is the inline function here? Or is tc358768_write optimized to
>> inline by the compiler?
> 
> I missed the lack of an explicit inline tag when looking at the bug. gcc
> usually decides which functions to inline on its own, so there is little
> difference in practice. Let me know if I should clarify the changelog and
> resend it.

Ok. I think this is fine.

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH] drm/bridge: fix stack usage warning on old gcc
  2020-04-28 21:53 [PATCH] drm/bridge: fix stack usage warning on old gcc Arnd Bergmann
  2020-04-29  7:56 ` Tomi Valkeinen
@ 2020-04-29 20:46 ` Sam Ravnborg
  1 sibling, 0 replies; 5+ messages in thread
From: Sam Ravnborg @ 2020-04-29 20:46 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Andrzej Hajda, Neil Armstrong, David Airlie, Daniel Vetter,
	Peter Ujfalusi, Jernej Skrabec, Jonas Karlman, Sebastian Reichel,
	dri-devel, linux-kernel, Tomi Valkeinen, Laurent Pinchart,
	Boris Brezillon

Hi Arnd.

On Tue, Apr 28, 2020 at 11:53:54PM +0200, Arnd Bergmann wrote:
> Some older versions of gcc badly optimize code that passes
> an inline function argument into another function by reference,
> causing huge stack usage:
> 
> drivers/gpu/drm/bridge/tc358768.c: In function 'tc358768_bridge_pre_enable':
> drivers/gpu/drm/bridge/tc358768.c:840:1: error: the frame size of 2256 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
> 
> Use a temporary variable as a workaround and add a comment pointing
> to the gcc bug.
> 
> Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks, pushed to drm-misc-next with Tomi's r-b.

	Sam

> ---
>  drivers/gpu/drm/bridge/tc358768.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c
> index 1b39e8d37834..6650fe4cfc20 100644
> --- a/drivers/gpu/drm/bridge/tc358768.c
> +++ b/drivers/gpu/drm/bridge/tc358768.c
> @@ -178,6 +178,8 @@ static int tc358768_clear_error(struct tc358768_priv *priv)
>  
>  static void tc358768_write(struct tc358768_priv *priv, u32 reg, u32 val)
>  {
> +	/* work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */
> +	int tmpval = val;
>  	size_t count = 2;
>  
>  	if (priv->error)
> @@ -187,7 +189,7 @@ static void tc358768_write(struct tc358768_priv *priv, u32 reg, u32 val)
>  	if (reg < 0x100 || reg >= 0x600)
>  		count = 1;
>  
> -	priv->error = regmap_bulk_write(priv->regmap, reg, &val, count);
> +	priv->error = regmap_bulk_write(priv->regmap, reg, &tmpval, count);
>  }
>  
>  static void tc358768_read(struct tc358768_priv *priv, u32 reg, u32 *val)
> -- 
> 2.26.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2020-04-29 20:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 21:53 [PATCH] drm/bridge: fix stack usage warning on old gcc Arnd Bergmann
2020-04-29  7:56 ` Tomi Valkeinen
2020-04-29  8:02   ` Arnd Bergmann
2020-04-29  8:13     ` Tomi Valkeinen
2020-04-29 20:46 ` Sam Ravnborg

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).