diff mbox series

[14/19] gpu: drm: selftests: test-drm_dp_mst_helper: Place 'struct drm_dp_sideband_msg_req_body' onto the heap

Message ID 20201105144517.1826692-15-lee.jones@linaro.org
State Superseded
Headers show
Series Rid W=1 warnings from GPU | expand

Commit Message

Lee Jones Nov. 5, 2020, 2:45 p.m. UTC
The stack is too full.

Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function ‘sideband_msg_req_encode_decode’:
 drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]

Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Lyude Paul <lyude@redhat.com>
Cc: David Francis <David.Francis@amd.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 .../drm/selftests/test-drm_dp_mst_helper.c    | 29 ++++++++++++-------
 1 file changed, 18 insertions(+), 11 deletions(-)

Comments

Lyude Paul Nov. 6, 2020, 7:17 p.m. UTC | #1
On Thu, 2020-11-05 at 14:45 +0000, Lee Jones wrote:
> The stack is too full.
> 
> Fixes the following W=1 kernel build warning(s):
> 
>  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function
> ‘sideband_msg_req_encode_decode’:
>  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame
> size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> 
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: David Francis <David.Francis@amd.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  .../drm/selftests/test-drm_dp_mst_helper.c    | 29 ++++++++++++-------
>  1 file changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> index 1d696ec001cff..0a539456f6864 100644
> --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> @@ -120,44 +120,51 @@ sideband_msg_req_equal(const struct
> drm_dp_sideband_msg_req_body *in,
>  static bool
>  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
>  {
> -       struct drm_dp_sideband_msg_req_body out = {0};
> +       struct drm_dp_sideband_msg_req_body *out;
>         struct drm_printer p = drm_err_printer(PREFIX_STR);
>         struct drm_dp_sideband_msg_tx txmsg;
>         int i, ret;
> +       bool result = true;
> +
> +       out = kzalloc(sizeof(*out), GFP_KERNEL);
> 

You're missing a NULL check here

>  
>         drm_dp_encode_sideband_req(in, &txmsg);
> -       ret = drm_dp_decode_sideband_req(&txmsg, &out);
> +       ret = drm_dp_decode_sideband_req(&txmsg, out);
>         if (ret < 0) {
>                 drm_printf(&p, "Failed to decode sideband request: %d\n",
>                            ret);
> -               return false;
> +               result = false;
> +               goto out;
>         }
>  
> -       if (!sideband_msg_req_equal(in, &out)) {
> +       if (!sideband_msg_req_equal(in, out)) {
>                 drm_printf(&p, "Encode/decode failed, expected:\n");
>                 drm_dp_dump_sideband_msg_req_body(in, 1, &p);
>                 drm_printf(&p, "Got:\n");
> -               drm_dp_dump_sideband_msg_req_body(&out, 1, &p);
> -               return false;
> +               drm_dp_dump_sideband_msg_req_body(out, 1, &p);
> +               result = false;
> +               goto out;
>         }
>  
>         switch (in->req_type) {
>         case DP_REMOTE_DPCD_WRITE:
> -               kfree(out.u.dpcd_write.bytes);
> +               kfree(out->u.dpcd_write.bytes);
>                 break;
>         case DP_REMOTE_I2C_READ:
> -               for (i = 0; i < out.u.i2c_read.num_transactions; i++)
> -                       kfree(out.u.i2c_read.transactions[i].bytes);
> +               for (i = 0; i < out->u.i2c_read.num_transactions; i++)
> +                       kfree(out->u.i2c_read.transactions[i].bytes);
>                 break;
>         case DP_REMOTE_I2C_WRITE:
> -               kfree(out.u.i2c_write.bytes);
> +               kfree(out->u.i2c_write.bytes);
>                 break;
>         }
>  
>         /* Clear everything but the req_type for the input */
>         memset(&in->u, 0, sizeof(in->u));
>  
> -       return true;
> +out:
> +       kfree(out);
> +       return result;
>  }
>  
>  int igt_dp_mst_sideband_msg_req_decode(void *unused)
Lee Jones Nov. 6, 2020, 7:25 p.m. UTC | #2
On Fri, 06 Nov 2020, Lyude Paul wrote:

> On Thu, 2020-11-05 at 14:45 +0000, Lee Jones wrote:
> > The stack is too full.
> > 
> > Fixes the following W=1 kernel build warning(s):
> > 
> >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function
> > ‘sideband_msg_req_encode_decode’:
> >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame
> > size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > 
> > Cc: David Airlie <airlied@linux.ie>
> > Cc: Daniel Vetter <daniel@ffwll.ch>
> > Cc: Lyude Paul <lyude@redhat.com>
> > Cc: David Francis <David.Francis@amd.com>
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >  .../drm/selftests/test-drm_dp_mst_helper.c    | 29 ++++++++++++-------
> >  1 file changed, 18 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > index 1d696ec001cff..0a539456f6864 100644
> > --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > @@ -120,44 +120,51 @@ sideband_msg_req_equal(const struct
> > drm_dp_sideband_msg_req_body *in,
> >  static bool
> >  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
> >  {
> > -       struct drm_dp_sideband_msg_req_body out = {0};
> > +       struct drm_dp_sideband_msg_req_body *out;
> >         struct drm_printer p = drm_err_printer(PREFIX_STR);
> >         struct drm_dp_sideband_msg_tx txmsg;
> >         int i, ret;
> > +       bool result = true;
> > +
> > +       out = kzalloc(sizeof(*out), GFP_KERNEL);
> > 
> 
> You're missing a NULL check here

You're right.  School-boy error!  Will fix.

> >         drm_dp_encode_sideband_req(in, &txmsg);

Wow, what are all these?

What mailer are you using?
Ville Syrjälä Nov. 9, 2020, 3:19 p.m. UTC | #3
On Thu, Nov 05, 2020 at 02:45:12PM +0000, Lee Jones wrote:
> The stack is too full.
> 
> Fixes the following W=1 kernel build warning(s):
> 
>  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function ‘sideband_msg_req_encode_decode’:
>  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> 
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: David Francis <David.Francis@amd.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  .../drm/selftests/test-drm_dp_mst_helper.c    | 29 ++++++++++++-------
>  1 file changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> index 1d696ec001cff..0a539456f6864 100644
> --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> @@ -120,44 +120,51 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in,
>  static bool
>  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
>  {
> -	struct drm_dp_sideband_msg_req_body out = {0};
> +	struct drm_dp_sideband_msg_req_body *out;

How big is it? And why is it that big?
Lee Jones Nov. 9, 2020, 4:12 p.m. UTC | #4
On Mon, 09 Nov 2020, Ville Syrjälä wrote:

> On Thu, Nov 05, 2020 at 02:45:12PM +0000, Lee Jones wrote:
> > The stack is too full.
> > 
> > Fixes the following W=1 kernel build warning(s):
> > 
> >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function ‘sideband_msg_req_encode_decode’:
> >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > 
> > Cc: David Airlie <airlied@linux.ie>
> > Cc: Daniel Vetter <daniel@ffwll.ch>
> > Cc: Lyude Paul <lyude@redhat.com>
> > Cc: David Francis <David.Francis@amd.com>
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >  .../drm/selftests/test-drm_dp_mst_helper.c    | 29 ++++++++++++-------
> >  1 file changed, 18 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > index 1d696ec001cff..0a539456f6864 100644
> > --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > @@ -120,44 +120,51 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in,
> >  static bool
> >  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
> >  {
> > -	struct drm_dp_sideband_msg_req_body out = {0};
> > +	struct drm_dp_sideband_msg_req_body *out;
> 
> How big is it? And why is it that big?

It's a struct of a union of structs.

And it's all allocated on the stack.  Bad news!
Lee Jones Nov. 9, 2020, 4:13 p.m. UTC | #5
On Mon, 09 Nov 2020, Lee Jones wrote:

> On Mon, 09 Nov 2020, Ville Syrjälä wrote:
> 
> > On Thu, Nov 05, 2020 at 02:45:12PM +0000, Lee Jones wrote:
> > > The stack is too full.
> > > 
> > > Fixes the following W=1 kernel build warning(s):
> > > 
> > >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function ‘sideband_msg_req_encode_decode’:
> > >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > > 
> > > Cc: David Airlie <airlied@linux.ie>
> > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > Cc: Lyude Paul <lyude@redhat.com>
> > > Cc: David Francis <David.Francis@amd.com>
> > > Cc: dri-devel@lists.freedesktop.org
> > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > > ---
> > >  .../drm/selftests/test-drm_dp_mst_helper.c    | 29 ++++++++++++-------
> > >  1 file changed, 18 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > index 1d696ec001cff..0a539456f6864 100644
> > > --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > @@ -120,44 +120,51 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in,
> > >  static bool
> > >  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
> > >  {
> > > -	struct drm_dp_sideband_msg_req_body out = {0};
> > > +	struct drm_dp_sideband_msg_req_body *out;
> > 
> > How big is it? And why is it that big?
> 
> It's a struct of a union of structs.
> 
> And it's all allocated on the stack.  Bad news!

FYI, I have a v2 of this patch.  Just waiting to send it.
Ville Syrjälä Nov. 9, 2020, 4:20 p.m. UTC | #6
On Mon, Nov 09, 2020 at 04:12:58PM +0000, Lee Jones wrote:
> On Mon, 09 Nov 2020, Ville Syrjälä wrote:
> 
> > On Thu, Nov 05, 2020 at 02:45:12PM +0000, Lee Jones wrote:
> > > The stack is too full.
> > > 
> > > Fixes the following W=1 kernel build warning(s):
> > > 
> > >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function ‘sideband_msg_req_encode_decode’:
> > >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > > 
> > > Cc: David Airlie <airlied@linux.ie>
> > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > Cc: Lyude Paul <lyude@redhat.com>
> > > Cc: David Francis <David.Francis@amd.com>
> > > Cc: dri-devel@lists.freedesktop.org
> > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > > ---
> > >  .../drm/selftests/test-drm_dp_mst_helper.c    | 29 ++++++++++++-------
> > >  1 file changed, 18 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > index 1d696ec001cff..0a539456f6864 100644
> > > --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > @@ -120,44 +120,51 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in,
> > >  static bool
> > >  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
> > >  {
> > > -	struct drm_dp_sideband_msg_req_body out = {0};
> > > +	struct drm_dp_sideband_msg_req_body *out;
> > 
> > How big is it? And why is it that big?
> 
> It's a struct of a union of structs.
> 
> And it's all allocated on the stack.  Bad news!

That doesn't answer my questions.
Lee Jones Nov. 9, 2020, 4:40 p.m. UTC | #7
On Mon, 09 Nov 2020, Ville Syrjälä wrote:

> On Mon, Nov 09, 2020 at 04:12:58PM +0000, Lee Jones wrote:
> > On Mon, 09 Nov 2020, Ville Syrjälä wrote:
> > 
> > > On Thu, Nov 05, 2020 at 02:45:12PM +0000, Lee Jones wrote:
> > > > The stack is too full.
> > > > 
> > > > Fixes the following W=1 kernel build warning(s):
> > > > 
> > > >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function ‘sideband_msg_req_encode_decode’:
> > > >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > > > 
> > > > Cc: David Airlie <airlied@linux.ie>
> > > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > > Cc: Lyude Paul <lyude@redhat.com>
> > > > Cc: David Francis <David.Francis@amd.com>
> > > > Cc: dri-devel@lists.freedesktop.org
> > > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > > > ---
> > > >  .../drm/selftests/test-drm_dp_mst_helper.c    | 29 ++++++++++++-------
> > > >  1 file changed, 18 insertions(+), 11 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > > index 1d696ec001cff..0a539456f6864 100644
> > > > --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > > +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > > @@ -120,44 +120,51 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in,
> > > >  static bool
> > > >  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
> > > >  {
> > > > -	struct drm_dp_sideband_msg_req_body out = {0};
> > > > +	struct drm_dp_sideband_msg_req_body *out;
> > > 
> > > How big is it? And why is it that big?
> > 
> > It's a struct of a union of structs.
> > 
> > And it's all allocated on the stack.  Bad news!
> 
> That doesn't answer my questions.

It answers the second question.

The answer to the first question you can `grep` for yourself. ;)
Ville Syrjälä Nov. 9, 2020, 5:03 p.m. UTC | #8
On Mon, Nov 09, 2020 at 04:40:04PM +0000, Lee Jones wrote:
> On Mon, 09 Nov 2020, Ville Syrjälä wrote:
> 
> > On Mon, Nov 09, 2020 at 04:12:58PM +0000, Lee Jones wrote:
> > > On Mon, 09 Nov 2020, Ville Syrjälä wrote:
> > > 
> > > > On Thu, Nov 05, 2020 at 02:45:12PM +0000, Lee Jones wrote:
> > > > > The stack is too full.
> > > > > 
> > > > > Fixes the following W=1 kernel build warning(s):
> > > > > 
> > > > >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function ‘sideband_msg_req_encode_decode’:
> > > > >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > > > > 
> > > > > Cc: David Airlie <airlied@linux.ie>
> > > > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > > > Cc: Lyude Paul <lyude@redhat.com>
> > > > > Cc: David Francis <David.Francis@amd.com>
> > > > > Cc: dri-devel@lists.freedesktop.org
> > > > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > > > > ---
> > > > >  .../drm/selftests/test-drm_dp_mst_helper.c    | 29 ++++++++++++-------
> > > > >  1 file changed, 18 insertions(+), 11 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > > > index 1d696ec001cff..0a539456f6864 100644
> > > > > --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > > > +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > > > @@ -120,44 +120,51 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in,
> > > > >  static bool
> > > > >  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
> > > > >  {
> > > > > -	struct drm_dp_sideband_msg_req_body out = {0};
> > > > > +	struct drm_dp_sideband_msg_req_body *out;
> > > > 
> > > > How big is it? And why is it that big?
> > > 
> > > It's a struct of a union of structs.
> > > 
> > > And it's all allocated on the stack.  Bad news!
> > 
> > That doesn't answer my questions.
> 
> It answers the second question.

Not really. A combination of structs and unions could be
pretty much any size.

> 
> The answer to the first question you can `grep` for yourself. ;)

I would rather run pahole on it. But why would you require
reviewers to jump through such extra hoops when you could
just put that information into the commit message? With that
anyone could review this without having to do a lot of extra
work.
Lee Jones Nov. 9, 2020, 5:17 p.m. UTC | #9
On Mon, 09 Nov 2020, Ville Syrjälä wrote:

> On Mon, Nov 09, 2020 at 04:40:04PM +0000, Lee Jones wrote:
> > On Mon, 09 Nov 2020, Ville Syrjälä wrote:
> > 
> > > On Mon, Nov 09, 2020 at 04:12:58PM +0000, Lee Jones wrote:
> > > > On Mon, 09 Nov 2020, Ville Syrjälä wrote:
> > > > 
> > > > > On Thu, Nov 05, 2020 at 02:45:12PM +0000, Lee Jones wrote:
> > > > > > The stack is too full.
> > > > > > 
> > > > > > Fixes the following W=1 kernel build warning(s):
> > > > > > 
> > > > > >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function ‘sideband_msg_req_encode_decode’:
> > > > > >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > > > > > 
> > > > > > Cc: David Airlie <airlied@linux.ie>
> > > > > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > > > > Cc: Lyude Paul <lyude@redhat.com>
> > > > > > Cc: David Francis <David.Francis@amd.com>
> > > > > > Cc: dri-devel@lists.freedesktop.org
> > > > > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > > > > > ---
> > > > > >  .../drm/selftests/test-drm_dp_mst_helper.c    | 29 ++++++++++++-------
> > > > > >  1 file changed, 18 insertions(+), 11 deletions(-)
> > > > > > 
> > > > > > diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > > > > index 1d696ec001cff..0a539456f6864 100644
> > > > > > --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > > > > +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> > > > > > @@ -120,44 +120,51 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in,
> > > > > >  static bool
> > > > > >  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
> > > > > >  {
> > > > > > -	struct drm_dp_sideband_msg_req_body out = {0};
> > > > > > +	struct drm_dp_sideband_msg_req_body *out;
> > > > > 
> > > > > How big is it? And why is it that big?
> > > > 
> > > > It's a struct of a union of structs.
> > > > 
> > > > And it's all allocated on the stack.  Bad news!
> > > 
> > > That doesn't answer my questions.
> > 
> > It answers the second question.
> 
> Not really. A combination of structs and unions could be
> pretty much any size.
> 
> > 
> > The answer to the first question you can `grep` for yourself. ;)
> 
> I would rather run pahole on it. But why would you require
> reviewers to jump through such extra hoops when you could
> just put that information into the commit message? With that
> anyone could review this without having to do a lot of extra
> work.

Because the exact numbers aren't all that relevant.

Before the patch is applied, the local variables take the frame size
over the accepted threshold.  The patch brings the size back down to
an accepted level.

I'm not actually aware of the exact numbers, but you can see by taking
a quick look that 'struct drm_dp_sideband_msg_req_body' is large
enough to make a significant improvement once shifted onto the heap.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
index 1d696ec001cff..0a539456f6864 100644
--- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
+++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
@@ -120,44 +120,51 @@  sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in,
 static bool
 sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
 {
-	struct drm_dp_sideband_msg_req_body out = {0};
+	struct drm_dp_sideband_msg_req_body *out;
 	struct drm_printer p = drm_err_printer(PREFIX_STR);
 	struct drm_dp_sideband_msg_tx txmsg;
 	int i, ret;
+	bool result = true;
+
+	out = kzalloc(sizeof(*out), GFP_KERNEL);
 
 	drm_dp_encode_sideband_req(in, &txmsg);
-	ret = drm_dp_decode_sideband_req(&txmsg, &out);
+	ret = drm_dp_decode_sideband_req(&txmsg, out);
 	if (ret < 0) {
 		drm_printf(&p, "Failed to decode sideband request: %d\n",
 			   ret);
-		return false;
+		result = false;
+		goto out;
 	}
 
-	if (!sideband_msg_req_equal(in, &out)) {
+	if (!sideband_msg_req_equal(in, out)) {
 		drm_printf(&p, "Encode/decode failed, expected:\n");
 		drm_dp_dump_sideband_msg_req_body(in, 1, &p);
 		drm_printf(&p, "Got:\n");
-		drm_dp_dump_sideband_msg_req_body(&out, 1, &p);
-		return false;
+		drm_dp_dump_sideband_msg_req_body(out, 1, &p);
+		result = false;
+		goto out;
 	}
 
 	switch (in->req_type) {
 	case DP_REMOTE_DPCD_WRITE:
-		kfree(out.u.dpcd_write.bytes);
+		kfree(out->u.dpcd_write.bytes);
 		break;
 	case DP_REMOTE_I2C_READ:
-		for (i = 0; i < out.u.i2c_read.num_transactions; i++)
-			kfree(out.u.i2c_read.transactions[i].bytes);
+		for (i = 0; i < out->u.i2c_read.num_transactions; i++)
+			kfree(out->u.i2c_read.transactions[i].bytes);
 		break;
 	case DP_REMOTE_I2C_WRITE:
-		kfree(out.u.i2c_write.bytes);
+		kfree(out->u.i2c_write.bytes);
 		break;
 	}
 
 	/* Clear everything but the req_type for the input */
 	memset(&in->u, 0, sizeof(in->u));
 
-	return true;
+out:
+	kfree(out);
+	return result;
 }
 
 int igt_dp_mst_sideband_msg_req_decode(void *unused)