This mostly boils down to initialising the Cache Coherent Interconnect
(CCI). We do this by looking in the device-tree for a CCI node, that way
the same semihosting bootwrapper binary can be used on both the
big.LITTLE models and on the A15 models which don't have a CCI.
[PATCH 1/3] bootwrapper: Allow for multiple clusters in boot CPU
[PATCH 2/3] bootwrapper: Factor out parsing of fdt #address-cells
[PATCH 3/3] bootwrapper: Initialise CCI device if found in the fdt
boot.S | 2 +-
semi_loader.c | 104 +++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 84 insertions(+), 22 deletions(-)
Hi Thomas,
I haven't tested it much till now. I am sending this patch just to check if the
initial idea looks fine to you guys or not.
Till now, we weren't migrating a running timer because with migration
del_timer_sync() can't detect that the timer's handler yet has not finished.
Now, when can we actually to reach to the code (inside __mod_timer()) where
base->running_timer == timer ? i.e. We are trying to migrate current timer
I can see only following case:
- Timer re-armed itself. i.e. Currently we are running interrupt handler of a
timer and it rearmed itself from there. At this time user might have called
del_timer_sync() or not. If not, then there is no harm in re-arming the timer?
Now, when somebody tries to delete a timer, obviously he doesn't want to run it
any more for now. So, why should we ever re-arm a timer, which is scheduled for
deletion?
This patch tries to fix "migration of running timer", assuming above theory is
correct :)
So, now when we get a call to del_timer_sync(), we will mark it scheduled for
deletion in an additional variable. This would be checked whenever we try to
modify/arm it again. If it was currently scheduled for deletion, we must not
modify/arm it.
And so, whenever we reach to the situation where:
base->running_timer == timer
We are sure, nobody is waiting in del_timer_sync().
We will clear this flag as soon as the timer is deleted, so that it can be
started again after deleting it successfully.
Waiting for initial comments on it.
Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
---
include/linux/timer.h | 1 +
kernel/timer.c | 58 +++++++++++++++++++++++++++++----------------------
2 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 8c5a197..ea36ce9 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -22,6 +22,7 @@ struct timer_list {
unsigned long data;
int slack;
+ int sched_del;
#ifdef CONFIG_TIMER_STATS
int start_pid;
diff --git a/kernel/timer.c b/kernel/timer.c
index 1cf8a91..536e7a3 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -620,6 +620,7 @@ static void do_init_timer(struct timer_list *timer, unsigned int flags,
timer->entry.next = NULL;
timer->base = (void *)((unsigned long)base | flags);
timer->slack = -1;
+ timer->sched_del = 0;
#ifdef CONFIG_TIMER_STATS
timer->start_site = NULL;
timer->start_pid = -1;
@@ -727,38 +728,35 @@ __mod_timer(struct timer_list *timer, unsigned long expires,
base = lock_timer_base(timer, &flags);
+ if (timer->sched_del) {
+ /* Don't schedule it again, as it is getting deleted */
+ ret = -EBUSY;
+ goto out_unlock;
+ }
+
ret = detach_if_pending(timer, base, false);
if (!ret && pending_only)
goto out_unlock;
debug_activate(timer, expires);
- /*
- * Should we try to migrate timer?
- * However we can't change timer's base while it is running, otherwise
- * del_timer_sync() can't detect that the timer's handler yet has not
- * finished. This also guarantees that the timer is serialized wrt
- * itself.
- */
- if (likely(base->running_timer != timer)) {
#if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)
- if (!pinned && get_sysctl_timer_migration())
- cpu = get_nohz_timer_target();
- else
- cpu = smp_processor_id();
-#else
+ if (!pinned && get_sysctl_timer_migration())
+ cpu = get_nohz_timer_target();
+ else
cpu = smp_processor_id();
+#else
+ cpu = smp_processor_id();
#endif
- new_base = per_cpu(tvec_bases, cpu);
-
- if (base != new_base) {
- /* See the comment in lock_timer_base() */
- timer_set_base(timer, NULL);
- spin_unlock(&base->lock);
- base = new_base;
- spin_lock(&base->lock);
- timer_set_base(timer, base);
- }
+ new_base = per_cpu(tvec_bases, cpu);
+
+ if (base != new_base) {
+ /* See the comment in lock_timer_base() */
+ timer_set_base(timer, NULL);
+ spin_unlock(&base->lock);
+ base = new_base;
+ spin_lock(&base->lock);
+ timer_set_base(timer, base);
}
timer->expires = expires;
@@ -1037,9 +1035,11 @@ EXPORT_SYMBOL(try_to_del_timer_sync);
*/
int del_timer_sync(struct timer_list *timer)
{
-#ifdef CONFIG_LOCKDEP
+ struct tvec_base *base;
unsigned long flags;
+#ifdef CONFIG_LOCKDEP
+
/*
* If lockdep gives a backtrace here, please reference
* the synchronization rules above.
@@ -1049,6 +1049,12 @@ int del_timer_sync(struct timer_list *timer)
lock_map_release(&timer->lockdep_map);
local_irq_restore(flags);
#endif
+
+ /* Timer is scheduled for deletion, don't let it re-arm itself */
+ base = lock_timer_base(timer, &flags);
+ timer->sched_del = 1;
+ spin_unlock_irqrestore(&base->lock, flags);
+
/*
* don't use it in hardirq context, because it
* could lead to deadlock.
@@ -1056,8 +1062,10 @@ int del_timer_sync(struct timer_list *timer)
WARN_ON(in_irq() && !tbase_get_irqsafe(timer->base));
for (;;) {
int ret = try_to_del_timer_sync(timer);
- if (ret >= 0)
+ if (ret >= 0) {
+ timer->sched_del = 0;
return ret;
+ }
cpu_relax();
}
}
--
1.7.12.rc2.18.g61b472e
> On 27 September 2012 13:50, MyungJoo Ham <myungjoo.ham(a)samsung.com> wrote:
> >> Prepare devfreq core framework to support devices which
> >> can idle. When device idleness is detected perhaps through
> >> runtime-pm, need some mechanism to suspend devfreq load
> >> monitoring and resume back when device is online. Present
> >> code continues monitoring unless device is removed from
> >> devfreq core.
> >>
> >> This patch introduces following design changes,
> >>
> >> - use per device work instead of global work to monitor device
> >> load. This enables suspend/resume of device devfreq and
> >> reduces monitoring code complexity.
> >> - decouple delayed work based load monitoring logic from core
> >> by introducing helpers functions to be used by governors. This
> >> provides flexibility for governors either to use delayed work
> >> based monitoring functions or to implement their own mechanism.
> >> - devfreq core interacts with governors via events to perform
> >> specific actions. These events include start/stop devfreq.
> >> This sets ground for adding suspend/resume events.
> >>
> >> The devfreq apis are not modified and are kept intact.
> >>
> >> Signed-off-by: Rajagopal Venkat <rajagopal.venkat(a)linaro.org>
> >
> > Hello,
> >
> >
> > I'll do more through review tomorrow (sorry, I was occuppied by
> > something other than Linux tasks for a while again); however,
> > there are two concerns in this patch.
> >
> > 1. (minor but may bothersome in some rare but not-ignorable cases)
> > Serialization issue between suspend/resume
> > functions; this may happen with some failure or interrupts while entering STR or
> > unexpected usage of the API at drivers.
>
> Regarding the invalid usage of suspend/resume apis, we can have
> additional checks
> something like,
>
> void devfreq_monitor_suspend(struct devfreq *devfreq)
> {
> .....
> if (devfreq->stop_polling)
> return;
> ......
> }
>
> void devfreq_monitor_resume(struct devfreq *devfreq)
> {
> .....
> if (!devfreq->stop_polling)
> return;
> ......
> }
>
> >
> > For example, if devfreq_monitor_suspend() and devfreq_montir_resume() are called
> > almost simultaneously, we may execute 1) locked part of suspend, 2) locked part of
> > resume, 3) cancel_delayed_work_sync of suspend.
> >
> > Then, we may have stop_polling = false w/ cancel_delayed_work_sync() in effect.
> >
> > Let's not assume that suspend() and resume() may called almost simultaneously,
> > especially in subsystem core code.
(sorry, I missed "not be" between "may" and "called" here)
> >
>
> These devfreq_monitor_suspend() and devfreq_monitor_resume() functions are
> executed when device idleness is detected. Perhaps,
> - using runtime-pm: the runtime_suspend() and runtime_resume() are mutually
> exclusive and is guaranteed not to run in parallel.
> - driver may have its own mechanism: in my opinion, driver should ensure
> suspend/resume are sequential even for it to know its devfreq status.
>
> Assuming even if above sequence occurs, I don't see any problem having
> stop_polling = false w/ cancel_delayed_work_sync() in effect. Since the suspend
> is the last one to complete, monitoring will not continue.
Why don't you simply extend the mutex-locked context?
I.e.,
+ mutex_lock(&devfreq->lock);
+ devfreq->stop_polling = true;
+ mutex_unlock(&devfreq->lock);
+ cancel_delayed_work_sync(&devfreq->work);
-->
+ mutex_lock(&devfreq->lock);
+ devfreq->stop_polling = true;
+ cancel_delayed_work_sync(&devfreq->work);
+ mutex_unlock(&devfreq->lock);
This serializes data-update and the execution based on the data-update,
resolving any inconsistency issues with the queue-status and devfreq
variable.
It doesn't have a heavy overhead to extend it and we have the
probably of inconsistency due to serialization issues.
>
> >
> > 2. What if polling_ms = 0 w/ active governors (such as ondemand)?
> >
> > Users may declare the initial polling_ms = 0 w/ simple-ondemand in order to
> > pause sampling at boot-time and start sampling at run-time some time later.
> >
> > It appears that this patch will start forcibly at boot-time in such a case.
>
> Yes. This is a valid case which can be handled by
>
> void devfreq_monitor_start(struct devfreq *devfreq)
> {
> INIT_DELAYED_WORK_DEFERRABLE(&devfreq->work, devfreq_monitor);
> + if (devfreq->profile->polling_ms)
> queue_delayed_work(devfreq_wq, &devfreq->work,
> msecs_to_jiffies(devfreq->profile->polling_ms));
> }
Please add the checking statement to every queue_delayed_work() statement:
resume and interval-update functions.
Cheers!
MyungJoo
Hello,
Firstly, sorry if this is the wrong forum - please feel free to
re-direct me to a more appropriate place.
I've been searching around for the 'net for a while but really have
not come across a conclusive answer to just how well the free software
community is supported by ARM vendors. Now I know that is a rather
vague statement, so I will elaborate by framing it is a personal
desire...
What I would like is a 'device' which I can hack on (and contribute to
the community) with the following features:
- Ethernet (at least 100Mb/s, but 1Gb/s and/or WiFi would be a bonus)
- USB 2.0 (3.0 would be a bonus)
- HDMI (dual monitor support would be a big bonus)
- 1080p video output
- Hi-definition video codec
- SATA
- MMC/SD
- 3D graphics not a big desire, but would be a bonus
Essentially, I'm after a device I can use as a media box / thin-client
X-term / hacker platform where every single byte of code that runs on
the device is free software. This includes:
- Boot loader (including SDRAM init)
- Operating system (GNU / Linux would be my personal choice)
- All drivers (no binary blobs, no 'firmware' blobs)
- All application software
I have yet to see such a platform. A lot come close, but it seems to
me that most fall short when it comes to drivers for the video codecs.
Am I living a pipe-dream, or does such a device really exist?
Regards,
Graeme
Hello,
I recently acquired a Gumstix Overo Water with a Tobi and decided to put
Node.js on it to turn it into a web server of sorts.
The build dies with an "Illegal instruction" error, and I am thoroughly
confused.
In order to set up the build, I did the following:
1. imaged a microSD card with the Linaro binaries indicated by
http://wiki.gumstix.org/index.php?title=Installing_Linaro_Image
2. booted
3. dd'd/enabled 200MB of swap on the SD card
4. apt-get update/upgrade everything
5. installed various development dependencies (git, libc6-dev, g++, and
many others)
6. cloned Joyent's repo.
7. modified `wscript` in the repo with V8-specific changes for ARM
(including enabling hard-float) (modified the scons invocation in v0.8)
8. ./configure
8. make
9. observed 'illegal instruction' death in the make process:
/root/node/deps/v8/src/arguments.h: In constructor
'v8::internal::CustomArguments::CustomArguments(v8::internal::Isolate*,
v8::internal::Object*, v8::internal::Object*, v8::internal::JSObject*)':
/root/node/deps/v8/src/arguments.h:93:65: internal compiler error: Illegal
instruction
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.
scons: *** [obj/release/runtime-profiler.o] Error 1
scons: building terminated because of errors.
If I restart the build, it works fine for a while (including rebuilding the
object it died building) then dies again. A different portion of the build
is running and it usually receives a segfault:
[ 9/35] cxx: src/node_javascript.cc -> out/Release/src/node_javascript_5.o
/usr/bin/g++ -pthread -g -O3 -DHAVE_OPENSSL=1 -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -DHAVE_FDATASYNC=1 -DARCH="arm" -DPLATFORM="linux"
-D__POSIX__=1 -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -IRelease/src
-I../src -IRelease/deps/http_parser -I../deps/http_parser
-IRelease/deps/uv/include -I../deps/uv/include -IRelease/deps/uv/src/ares
-I../deps/uv/src/ares -IRelease/deps/v8/include -I../deps/v8/include
-Ideps/v8/include ../src/node_javascript.cc -c -o
Release/src/node_javascript_5.o
g++: internal compiler error: Segmentation fault (program as)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Waf: Leaving directory `/root/node/out'
I am confused. I've made a few observations about my setup:
* Thinking that it might be a thermal problem because it was under heavy
load at 600MHz in open air, I dug out a small heat sink, attached it, and
pointed a small fan at it. It now runs cool to the touch. I still get the
same 'illegal instruction' deaths under load.
* Usually three invocations of 'make' are required before it actually
finishes, but it does finish. I can run the command-line interpreter and it
seems to behave inasmuch as I've used it.
* 'make test' fails, but I think that's a Node.js/ARM problem.
* I run htop to monitor the build, and sometimes the build system works
fine while htop dies with an 'illegal instruction' error.
* Node.js on ARM is presently somewhat sticky, so I checked out the v0.6.6
tag. v0.6.18 encounters the same problem. v0.8.9 simply segfaults instead.
* I have an Overo Water (GS3503W-R2889) on a Tobi.
* MLO version: I haven't the foggiest, but I get the U-Boot version string
twice, once being before u-boot.bin is loaded.
* U-Boot 2012.04.01 (Jul 19 2012 - 17:31:34)
* I moved the SD card to a different Water/Tobi pair and I got the same
error (illegal instruction, Node.js v0.8.9)
It feels like a task swapping bug in the kernel. Perhaps it's related to
errata on the OMAP3530. It could also be read timeouts from the swap file
on the SD card, though dmesg doesn't say anything of the sort. I found a
kernel patch regarding inconsistent caches on ARM, but it hit in 2.6.33 and
I'm running 3.2.1.
Has anyone seen something like this?
Would anyone be willing to replicate the problem? I'd be happy to share my
tweaks to Node.js' build system to get it to build.
Thanks for reading!
Jon Kunkee