Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1605322 > unrolled thread

[PATCH] soc/tegra: pmc: Don't allocate struct tegra_powergate on stack

Started byViresh Kumar <viresh.kumar@linaro.org>
First post2017-03-21 06:40 +0100
Last post2017-03-21 11:50 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] soc/tegra: pmc: Don't allocate struct tegra_powergate on stack Viresh Kumar <viresh.kumar@linaro.org> - 2017-03-21 06:40 +0100
    Re: [PATCH] soc/tegra: pmc: Don't allocate struct tegra_powergate on  stack Jon Hunter <jonathanh@nvidia.com> - 2017-03-21 11:40 +0100
      Re: [PATCH] soc/tegra: pmc: Don't allocate struct tegra_powergate on  stack Viresh Kumar <viresh.kumar@linaro.org> - 2017-03-21 11:50 +0100

#1605322 — [PATCH] soc/tegra: pmc: Don't allocate struct tegra_powergate on stack

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-03-21 06:40 +0100
Subject[PATCH] soc/tegra: pmc: Don't allocate struct tegra_powergate on stack
Message-ID<tnkGt-7kb-7@gated-at.bofh.it>
The size of the struct tegra_powergate is quite big and if any more
fields are added to the internal genpd structure, following warnings are
thrown:

drivers/soc/tegra/pmc.c:577:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]

Avoid such warnings by allocating the structure dynamically.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/soc/tegra/pmc.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index e233dd5dcab3..c94196b939a4 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -557,22 +557,28 @@ EXPORT_SYMBOL(tegra_powergate_remove_clamping);
 int tegra_powergate_sequence_power_up(unsigned int id, struct clk *clk,
 				      struct reset_control *rst)
 {
-	struct tegra_powergate pg;
+	struct tegra_powergate *pg;
 	int err;
 
 	if (!tegra_powergate_is_available(id))
 		return -EINVAL;
 
-	pg.id = id;
-	pg.clks = &clk;
-	pg.num_clks = 1;
-	pg.resets = &rst;
-	pg.num_resets = 1;
+	pg = kzalloc(sizeof(*pg), GFP_KERNEL);
+	if (!pg)
+		return -ENOMEM;
+
+	pg->id = id;
+	pg->clks = &clk;
+	pg->num_clks = 1;
+	pg->resets = &rst;
+	pg->num_resets = 1;
 
-	err = tegra_powergate_power_up(&pg, false);
+	err = tegra_powergate_power_up(pg, false);
 	if (err)
 		pr_err("failed to turn on partition %d: %d\n", id, err);
 
+	kfree(pg);
+
 	return err;
 }
 EXPORT_SYMBOL(tegra_powergate_sequence_power_up);
-- 
2.12.0.432.g71c3a4f4ba37

[toc] | [next] | [standalone]


#1605492 — Re: [PATCH] soc/tegra: pmc: Don't allocate struct tegra_powergate on stack

FromJon Hunter <jonathanh@nvidia.com>
Date2017-03-21 11:40 +0100
SubjectRe: [PATCH] soc/tegra: pmc: Don't allocate struct tegra_powergate on stack
Message-ID<tnpmO-24D-9@gated-at.bofh.it>
In reply to#1605322
On 21/03/17 05:24, Viresh Kumar wrote:
> The size of the struct tegra_powergate is quite big and if any more
> fields are added to the internal genpd structure, following warnings are
> thrown:
> 
> drivers/soc/tegra/pmc.c:577:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]

Hmmm ... AFAICT the size of the tegra_powergate struct is 312 bytes
(based upon next-20170321) and so it looks like something massive needs
to be added to the genpd struct to blow this up to over 1024 bytes. Are
there some genpd changes in-flight that are causing this?

Cheers
Jon

-- 
nvpublic

[toc] | [prev] | [next] | [standalone]


#1605499 — Re: [PATCH] soc/tegra: pmc: Don't allocate struct tegra_powergate on stack

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-03-21 11:50 +0100
SubjectRe: [PATCH] soc/tegra: pmc: Don't allocate struct tegra_powergate on stack
Message-ID<tnpwu-28I-17@gated-at.bofh.it>
In reply to#1605492
On 21-03-17, 10:37, Jon Hunter wrote:
> 
> On 21/03/17 05:24, Viresh Kumar wrote:
> > The size of the struct tegra_powergate is quite big and if any more
> > fields are added to the internal genpd structure, following warnings are
> > thrown:
> > 
> > drivers/soc/tegra/pmc.c:577:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> 
> Hmmm ... AFAICT the size of the tegra_powergate struct is 312 bytes
> (based upon next-20170321) and so it looks like something massive needs
> to be added to the genpd struct to blow this up to over 1024 bytes. Are
> there some genpd changes in-flight that are causing this?

https://marc.info/?l=linux-kernel&m=149000247329743&w=2

This is up for discussion right now though and we don't know if it
will surely get merged or not.

-- 
viresh

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web