From: Benjamin Gaignard <benjamin.gaignard@st.com>
To: <fweisbec@gmail.com>, <tglx@linutronix.de>, <mingo@kernel.org>,
<marc.zyngier@arm.com>, <daniel.lezcano@linaro.org>
Cc: <linux-kernel@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
Benjamin Gaignard <benjamin.gaignard@st.com>
Subject: [PATCH] tick: check if broadcast device could really be stopped
Date: Wed, 9 Oct 2019 18:02:46 +0200 [thread overview]
Message-ID: <20191009160246.17898-1-benjamin.gaignard@st.com> (raw)
If the CPU isn't able to go in states where the clock event will
be stopped we can ignore CLOCK_EVT_FEAT_C3STOP flag.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
---
kernel/time/tick-broadcast.c | 6 +++---
kernel/time/tick-common.c | 4 ++--
kernel/time/tick-internal.h | 12 ++++++++++++
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index e51778c312f1..5393778d7703 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -78,7 +78,7 @@ static bool tick_check_broadcast_device(struct clock_event_device *curdev,
{
if ((newdev->features & CLOCK_EVT_FEAT_DUMMY) ||
(newdev->features & CLOCK_EVT_FEAT_PERCPU) ||
- (newdev->features & CLOCK_EVT_FEAT_C3STOP))
+ tick_broadcast_could_stop(newdev))
return false;
if (tick_broadcast_device.mode == TICKDEV_MODE_ONESHOT &&
@@ -188,7 +188,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
* Clear the broadcast bit for this cpu if the
* device is not power state affected.
*/
- if (!(dev->features & CLOCK_EVT_FEAT_C3STOP))
+ if (!tick_broadcast_could_stop(dev))
cpumask_clear_cpu(cpu, tick_broadcast_mask);
else
tick_device_setup_broadcast_func(dev);
@@ -368,7 +368,7 @@ void tick_broadcast_control(enum tick_broadcast_mode mode)
/*
* Is the device not affected by the powerstate ?
*/
- if (!dev || !(dev->features & CLOCK_EVT_FEAT_C3STOP))
+ if (!dev || !tick_broadcast_could_stop(dev))
goto out;
if (!tick_device_is_functional(dev))
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index 59225b484e4e..a300ee941c56 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -72,7 +72,7 @@ int tick_is_oneshot_available(void)
if (!dev || !(dev->features & CLOCK_EVT_FEAT_ONESHOT))
return 0;
- if (!(dev->features & CLOCK_EVT_FEAT_C3STOP))
+ if (!tick_broadcast_could_stop(dev))
return 1;
return tick_broadcast_oneshot_available();
}
@@ -393,7 +393,7 @@ int tick_broadcast_oneshot_control(enum tick_broadcast_state state)
{
struct tick_device *td = this_cpu_ptr(&tick_cpu_device);
- if (!(td->evtdev->features & CLOCK_EVT_FEAT_C3STOP))
+ if (!tick_broadcast_could_stop(td->evtdev))
return 0;
return __tick_broadcast_oneshot_control(state);
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
index 7b2496136729..99aa7b5a8dae 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -2,6 +2,7 @@
/*
* tick internal variable and functions used by low/high res code
*/
+#include <linux/cpuidle.h>
#include <linux/hrtimer.h>
#include <linux/tick.h>
@@ -48,6 +49,17 @@ static inline void clockevent_set_state(struct clock_event_device *dev,
dev->state_use_accessors = state;
}
+/**
+ * Return true if the cpu could go in states where the device will be stopped
+ */
+static inline int tick_broadcast_could_stop(struct clock_event_device *dev)
+{
+ struct cpuidle_driver *drv = cpuidle_get_driver();
+
+ return !!((dev->features & CLOCK_EVT_FEAT_C3STOP)
+ && drv && drv->bctimer);
+}
+
extern void clockevents_shutdown(struct clock_event_device *dev);
extern void clockevents_exchange_device(struct clock_event_device *old,
struct clock_event_device *new);
--
2.15.0
next reply other threads:[~2019-10-09 16:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 16:02 Benjamin Gaignard [this message]
2019-10-14 12:56 ` Thomas Gleixner
2019-10-14 13:14 ` Benjamin GAIGNARD
2019-10-14 13:40 ` Thomas Gleixner
2019-10-14 14:11 ` Benjamin GAIGNARD
2019-10-14 14:28 ` Thomas Gleixner
2019-10-14 15:22 ` Benjamin GAIGNARD
2019-10-14 18:34 ` Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191009160246.17898-1-benjamin.gaignard@st.com \
--to=benjamin.gaignard@st.com \
--cc=daniel.lezcano@linaro.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=marc.zyngier@arm.com \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®