* [PATCH] cpufreq: exynos5440: Protect opp search calls with rcu lock @ 2013-04-15 6:24 Amit Daniel Kachhap 2013-04-15 14:10 ` Nishanth Menon 2013-04-21 23:32 ` Rafael J. Wysocki 0 siblings, 2 replies; 4+ messages in thread From: Amit Daniel Kachhap @ 2013-04-15 6:24 UTC (permalink / raw) To: linux-pm, Rafael J. Wysocki Cc: linux-kernel, linux-samsung-soc, linux-arm-kernel, Kukjin Kim, cpufreq, Nishanth Menon As per the OPP library documentation(Documentation/power/opp.txt) all opp find/get calls should be protected by rcu locks. Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com> --- This patch is created against linux-next tree and is suggested by Nishanth Menon. (https://lkml.org/lkml/2013/4/12/119) drivers/cpufreq/exynos5440-cpufreq.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c index ead7ed4..0c74018 100644 --- a/drivers/cpufreq/exynos5440-cpufreq.c +++ b/drivers/cpufreq/exynos5440-cpufreq.c @@ -120,11 +120,13 @@ static int init_div_table(void) int i = 0; struct opp *opp; + rcu_read_lock(); for (i = 0; freq_tbl[i].frequency != CPUFREQ_TABLE_END; i++) { opp = opp_find_freq_exact(dvfs_info->dev, freq_tbl[i].frequency * 1000, true); if (IS_ERR(opp)) { + rcu_read_unlock(); dev_err(dvfs_info->dev, "failed to find valid OPP for %u KHZ\n", freq_tbl[i].frequency); @@ -159,6 +161,7 @@ static int init_div_table(void) __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * i); } + rcu_read_unlock(); return 0; } -- 1.7.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cpufreq: exynos5440: Protect opp search calls with rcu lock 2013-04-15 6:24 [PATCH] cpufreq: exynos5440: Protect opp search calls with rcu lock Amit Daniel Kachhap @ 2013-04-15 14:10 ` Nishanth Menon 2013-04-16 6:51 ` amit daniel kachhap 2013-04-21 23:32 ` Rafael J. Wysocki 1 sibling, 1 reply; 4+ messages in thread From: Nishanth Menon @ 2013-04-15 14:10 UTC (permalink / raw) To: Amit Daniel Kachhap Cc: linux-pm, Rafael J. Wysocki, Kukjin Kim, lkml, cpufreq, linux-samsung-soc, linux-arm-kernel@lists.infradead.org Daniel, On Mon, Apr 15, 2013 at 1:24 AM, Amit Daniel Kachhap <amit.daniel@samsung.com> wrote: > As per the OPP library documentation(Documentation/power/opp.txt) all > opp find/get calls should be protected by rcu locks. > > Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com> > --- > > This patch is created against linux-next tree and is suggested by > Nishanth Menon. (https://lkml.org/lkml/2013/4/12/119) > > drivers/cpufreq/exynos5440-cpufreq.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c > index ead7ed4..0c74018 100644 > --- a/drivers/cpufreq/exynos5440-cpufreq.c > +++ b/drivers/cpufreq/exynos5440-cpufreq.c > @@ -120,11 +120,13 @@ static int init_div_table(void) > int i = 0; > struct opp *opp; > > + rcu_read_lock(); > for (i = 0; freq_tbl[i].frequency != CPUFREQ_TABLE_END; i++) { > > opp = opp_find_freq_exact(dvfs_info->dev, > freq_tbl[i].frequency * 1000, true); > if (IS_ERR(opp)) { > + rcu_read_unlock(); > dev_err(dvfs_info->dev, > "failed to find valid OPP for %u KHZ\n", > freq_tbl[i].frequency); > @@ -159,6 +161,7 @@ static int init_div_table(void) > __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * i); > } > > + rcu_read_unlock(); Is it not possible to reduce the amount of code protected by RCU lock? something like this: + rcu_read_lock(); opp = opp_find_freq_exact(dvfs_info->dev, freq_tbl[i].frequency * 1000, true); if (IS_ERR(opp)) { + rcu_read_unlock(); dev_err(dvfs_info->dev, "failed to find valid OPP for %u KHZ\n", freq_tbl[i].frequency); return PTR_ERR(opp); } + volt_id = opp_get_voltage(opp); + rcu_unlock(); ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cpufreq: exynos5440: Protect opp search calls with rcu lock 2013-04-15 14:10 ` Nishanth Menon @ 2013-04-16 6:51 ` amit daniel kachhap 0 siblings, 0 replies; 4+ messages in thread From: amit daniel kachhap @ 2013-04-16 6:51 UTC (permalink / raw) To: Nishanth Menon Cc: linux-samsung-soc, linux-pm, lkml, cpufreq, Rafael J. Wysocki, Kukjin Kim, linux-arm-kernel@lists.infradead.org Hi Nishanth, Thanks for reviewing this patch. On Mon, Apr 15, 2013 at 7:40 PM, Nishanth Menon <nm@ti.com> wrote: > Daniel, > On Mon, Apr 15, 2013 at 1:24 AM, Amit Daniel Kachhap > <amit.daniel@samsung.com> wrote: >> As per the OPP library documentation(Documentation/power/opp.txt) all >> opp find/get calls should be protected by rcu locks. >> >> Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com> >> --- >> >> This patch is created against linux-next tree and is suggested by >> Nishanth Menon. (https://lkml.org/lkml/2013/4/12/119) >> >> drivers/cpufreq/exynos5440-cpufreq.c | 3 +++ >> 1 files changed, 3 insertions(+), 0 deletions(-) >> >> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c >> index ead7ed4..0c74018 100644 >> --- a/drivers/cpufreq/exynos5440-cpufreq.c >> +++ b/drivers/cpufreq/exynos5440-cpufreq.c >> @@ -120,11 +120,13 @@ static int init_div_table(void) >> int i = 0; >> struct opp *opp; >> >> + rcu_read_lock(); >> for (i = 0; freq_tbl[i].frequency != CPUFREQ_TABLE_END; i++) { >> >> opp = opp_find_freq_exact(dvfs_info->dev, >> freq_tbl[i].frequency * 1000, true); >> if (IS_ERR(opp)) { >> + rcu_read_unlock(); >> dev_err(dvfs_info->dev, >> "failed to find valid OPP for %u KHZ\n", >> freq_tbl[i].frequency); >> @@ -159,6 +161,7 @@ static int init_div_table(void) >> __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * i); >> } >> >> + rcu_read_unlock(); > > Is it not possible to reduce the amount of code protected by RCU lock? > something like this: Yes it is possible but then this part of code is a loop of max 8 iteration so rcu_read_lock will be called those many times. Also this code blocks are just register writes and not doing any time consuming operations. Thanks, Amit Daniel > + rcu_read_lock(); > opp = opp_find_freq_exact(dvfs_info->dev, > freq_tbl[i].frequency * 1000, true); > if (IS_ERR(opp)) { > + rcu_read_unlock(); > dev_err(dvfs_info->dev, > "failed to find valid OPP for %u KHZ\n", > freq_tbl[i].frequency); > return PTR_ERR(opp); > } > + volt_id = opp_get_voltage(opp); > + rcu_unlock(); > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cpufreq: exynos5440: Protect opp search calls with rcu lock 2013-04-15 6:24 [PATCH] cpufreq: exynos5440: Protect opp search calls with rcu lock Amit Daniel Kachhap 2013-04-15 14:10 ` Nishanth Menon @ 2013-04-21 23:32 ` Rafael J. Wysocki 1 sibling, 0 replies; 4+ messages in thread From: Rafael J. Wysocki @ 2013-04-21 23:32 UTC (permalink / raw) To: Amit Daniel Kachhap Cc: linux-pm, linux-kernel, linux-samsung-soc, linux-arm-kernel, Kukjin Kim, cpufreq, Nishanth Menon On Monday, April 15, 2013 11:54:47 AM Amit Daniel Kachhap wrote: > As per the OPP library documentation(Documentation/power/opp.txt) all > opp find/get calls should be protected by rcu locks. > > Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com> > --- > > This patch is created against linux-next tree and is suggested by > Nishanth Menon. (https://lkml.org/lkml/2013/4/12/119) Applied. Thanks, Rafael > drivers/cpufreq/exynos5440-cpufreq.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c > index ead7ed4..0c74018 100644 > --- a/drivers/cpufreq/exynos5440-cpufreq.c > +++ b/drivers/cpufreq/exynos5440-cpufreq.c > @@ -120,11 +120,13 @@ static int init_div_table(void) > int i = 0; > struct opp *opp; > > + rcu_read_lock(); > for (i = 0; freq_tbl[i].frequency != CPUFREQ_TABLE_END; i++) { > > opp = opp_find_freq_exact(dvfs_info->dev, > freq_tbl[i].frequency * 1000, true); > if (IS_ERR(opp)) { > + rcu_read_unlock(); > dev_err(dvfs_info->dev, > "failed to find valid OPP for %u KHZ\n", > freq_tbl[i].frequency); > @@ -159,6 +161,7 @@ static int init_div_table(void) > __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * i); > } > > + rcu_read_unlock(); > return 0; > } > > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-21 23:24 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-04-15 6:24 [PATCH] cpufreq: exynos5440: Protect opp search calls with rcu lock Amit Daniel Kachhap 2013-04-15 14:10 ` Nishanth Menon 2013-04-16 6:51 ` amit daniel kachhap 2013-04-21 23:32 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox