Re: [RFC] Default child of a cgroup

2008-01-31 Thread Peter Zijlstra

On Thu, 2008-01-31 at 18:39 -0800, Paul Menage wrote:
> On Jan 30, 2008 6:40 PM, Srivatsa Vaddagiri <[EMAIL PROTECTED]> wrote:
> >
> > Here are some questions that arise in this picture:
> >
> > 1. What is the relationship of the task-group in A/tasks with the
> >task-group in A/a1/tasks? In otherwords do they form siblings
> >of the same parent A?
> 
> I'd argue the same as Balbir - tasks in A/tasks are are children of A
> and are siblings of a1, a2, etc.
> 
> >
> > 2. Somewhat related to the above question, how much resource should the
> >task-group A/a1/tasks get in relation to A/tasks? Is it 1/2 of parent
> >A's share or 1/(1 + N) of parent A's share (where N = number of tasks
> >in A/tasks)?
> 
> Each process in A should have a scheduler weight that's derived from
> its static_prio field. Similarly each subgroup of A will have a
> scheduler weight that's determined by its cpu.shares value. So the cpu
> share of any child (be it a task or a subgroup) would be equal to its
> own weight divided by the sum of weights of all children.
> 
> So yes, if a task in A forks lots of children, those children could
> end up getting a disproportionate amount of the CPU compared to tasks
> in A/a1 - but that's the same as the situation without cgroups. If you
> want to control cpu usage between different sets of processes in A,
> they should be in sibling cgroups, not directly in A.
> 
> Is there a restriction in CFS that stops a given group from
> simultaneously holding tasks and sub-groups? If so, couldn't we change
> CFS to make it possible rather than enforcing awkward restructions on
> cgroups?

I think it is possible, just way more work than the proposed hack.

> If we really can't change CFS in that way, then an alternative would
> be similar to Peter's suggestion - make cpu_cgroup_can_attach() fail
> if the cgroup has children, and make cpu_cgroup_create() fail if the
> cgroup has any tasks - that way you limit the restriction to just the
> hierarchy that has CFS attached to it, rather than generically for all
> cgroups

Agreed.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] nozomi: constify driver

2008-01-31 Thread Frank Seidel
On Friday 01 February 2008 08:28, Sam Ravnborg wrote:
> __devinitdata is for non-const data.
> __devinitconst is for const data.
>
> You cannot mix const and non-const data in the same section,
> if you do so gcc will complain.
> It may build for you if all uses of __devinitdata in the
> same source file is either const or non-const but when you
> mix it then it breaks.
> 
> So please use the correct annotation.

Ok, i see .. thanks for this explanation.
I'll repost with this fixed

BTW in this case those drivers also need to be fixed in current
git tree, should they?
drivers/edac/amd76x_edac.c
drivers/edac/e752x_edac.c
drivers/edac/e7xxx_edac.c
drivers/edac/i3000_edac.c
drivers/edac/i5000_edac.c
drivers/edac/i82443bxgx_edac.c
drivers/edac/i82860_edac.c
drivers/edac/i82875p_edac.c
drivers/edac/i82975x_edac.c
drivers/edac/r82600_edac.c
drivers/macintosh/macio_asic.c
drivers/mmc/host/ricoh_mmc.c
drivers/mmc/host/sdhci.c
drivers/net/natsemi.c
drivers/net/via-velocity.c
drivers/scsi/aic94xx/aic94xx_init.c

> We do small incremental steps whenever we can. The challenge is
> often to split up patches and not to combine them.
> 
> Where we combine two patches this is when the second patch fix
> a bug in the first patch.

To me it felt like those changes are so trivial and kind of
belong together so that i thought it would be ok here. But
i'll repost it as two patches in a few moments.

Thanks,
Frank
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch] NULL pointer check for vma->vm_mm

2008-01-31 Thread Andrew Morton
On Fri, 1 Feb 2008 16:39:07 +0900 "Kenichi Okuyama" <[EMAIL PROTECTED]> wrote:

> Dear all,
> 
> I was looking at the ./mm/rmap.c .. I found that, in function
> "page_referenced_one()",
>struct mm_struct *mm = vma->vm_mm;
> was being refererred without NULL check.
> 
> Though I do agree that this works for most of the cases, I thought it
> is better to add
> BUG_ON() for case of mm being NULL.
> 
> attached is the patch for this

If we dereference NULL then the kernel will display basically the same
information as would a BUG, and it takes the same action.  So adding a
BUG_ON here really doesn't gain us anything.

Also, I think vma->vm_mm == 0 is not a valid state, so this just shouldn't
happen - the code is OK to assume that a particular invariant is being
honoured.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel BUG at ide-cd.c:1726 in 2.6.24-03863-g0ba6c33 && -g8561b089

2008-01-31 Thread Borislav Petkov
On Thu, Jan 31, 2008 at 05:35:56PM -0500, Kiyoshi Ueda wrote:
> Hi Boris,
> 
> Thank you for the confirmation of original behavior.
> 
> On Thu, 31 Jan 2008 22:37:40 +0100, Borislav Petkov wrote:
> > On Thu, Jan 31, 2008 at 02:05:58PM +0100, Jens Axboe wrote:
> > > On Thu, Jan 31 2008, Nai Xia wrote:
> > > > My dmesg relevant info is quite similar:
> > > > 
> > > > [6.875041] Freeing unused kernel memory: 320k freed
> > > > [8.143120] ide-cd: rq still having bio: dev hdc: type=2, flags=114c8
> > > > [8.144439]
> > > > [8.144439] sector 10824201199534213, nr/cnr 0/0
> > > > [8.144439] bio cf029280, biotail cf029280, buffer , data
> > > > , len 158
> > > > [8.144439] cdb: 12 00 00 00 fe 00 00 00 00 00 00 00 00 00 00 00
> > > > [8.144439] backup: data_len=158  bi_size=158
> > > > [8.160756] ide-cd: rq still having bio: dev hdc: type=2, flags=114c8
> > > > [8.160756]
> > > > [8.160756] sector 2669858, nr/cnr 0/0
> > > > [8.160756] bio cf029300, biotail cf029300, buffer , data
> > > > , len 158
> > > > [8.160756] cdb: 12 01 00 00 fe 00 00 00 00 00 00 00 00 00 00 00
> > > > [8.160756] backup: data_len=158  bi_size=158
> > > > [   14.851101] eth0: link up
> > > > [   27.121883] eth0: no IPv6 routers present
> > > > 
> > > > 
> > > > And by the way, Kiyoshi,
> > > > This can be reproduced in a typical setup vmware workstation 6.02 with
> > > > a vritual IDE cdrom,
> > > > in case you wanna catch that with your own eyes. :-)
> > > > Thanks for your trying hard to correct this annoying bug.
> > > 
> > > The below fix should be enough. It's perfectly legal to have leftover
> > > byte counts when the drive signals completion, happens all the time for
> > > eg user issued commands where you don't know an exact byte count.
> > 
> > Actually, this behavior has been the case even before the 
> > __blk_end_request()
> > changes. I did test plain 2.6.24 with the following
> > 
> > 
> > --- linux-2.6/drivers/ide/ide-cd.c  2008-01-31 22:18:59.0 +0100
> > +++ linux-2.6/drivers/ide/ide-cd.c-new  2008-01-31 22:18:50.0 
> > +0100
> > @@ -1711,8 +1711,12 @@ static ide_startstop_t cdrom_newpc_intr(
> > /*
> >  * If DRQ is clear, the command has completed.
> >  */
> > -   if ((stat & DRQ_STAT) == 0)
> > +   if ((stat & DRQ_STAT) == 0) {
> > +   blk_dump_rq_flags(rq, "ide-cd: rq still having bio");
> > +   printk("backup: data_len=%u  bi_size=%u\n",
> > +   rq->data_len, rq->bio->bi_size);
> > goto end_request;
> > +   }
> >  
> > /*
> >  * check which way to transfer data
> > 
> > 
> > to see whether we've been getting residual byte counts:
> > 
> > Jan 31 22:10:06 gollum kernel: [   26.702877] ide-cd: rq still having bio: 
> > dev hdc: type=2, flags=114c8
> > Jan 31 22:10:06 gollum kernel: [   26.702945]
> > Jan 31 22:10:06 gollum kernel: [   26.702946] sector 2673511, nr/cnr 0/0
> > Jan 31 22:10:06 gollum kernel: [   26.703052] bio dfa8ec40, biotail 
> > dfa8ec40, buffer , data , len 158
> > Jan 31 22:10:06 gollum kernel: [   26.703122] cdb: 12 00 00 00 fe 00 00 00 
> > 00 00 00 00 00 00 00 00
> > Jan 31 22:10:06 gollum kernel: [   26.703877] backup: data_len=158  
> > bi_size=158
> > 
> > ... so we've been simply silently ignoring this until now so i guess we 
> > don't
> > need to BUG() for something that's totally benign.

Hi Kiyoshi,
 
> end_that_request_last() is not called when __blk_end_reuqest()
> returns 1.  Then, the issuer isn't waken up.
> So I think the BUG() or error messages should be there.

you mean, end_that_request_last() isn't called when __end_that_request_first()
returns an error and this is the case only for fs and pc requests. Otherwise it
_is_ called, thus simulating somewhat the previous behavior. However, we never 
BUG()'ged
on residual byte counts before and this driver has been in the kernel tree for
ages, so what puzzles me now is how is BUG()'ing here better than before and
shouldn't we simply issue a warning instead of killing the interrupt handler...

..or am i missing something?

-- 
Regards/Gruß,
Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Regression] 2.6.24-git9: RT sched mishandles artswrapper (bisected)

2008-01-31 Thread Peter Zijlstra

On Fri, 2008-02-01 at 03:04 +0100, Rafael J. Wysocki wrote:
> On Friday, 1 of February 2008, Rafael J. Wysocki wrote:
> > Hi,
> > 
> > This is related to the problem I reported earlier this week:
> > http://lkml.org/lkml/2008/1/30/554
> > 
> > Apparently artswrapper, run by KDE in openSUSE 10.3 with a real time 
> > priority,
> > is mishandled by the scheduler.  The problem is that after the user logs 
> > out,
> > artswrapper stays in TASK_RUNNING forever and prevents other tasks from 
> > being
> > scheduled on the CPU occupied by it.  In this state it also breaks suspend 
> > and
> > hibernation (it cannot be frozen).
> > 
> > Since the problem is 100% reproducible on my test boxes, I carried out a
> > bisection which turned out the following commit:
> > 
> > commit 6f505b16425a51270058e4a93441fe64de3dd435
> > Author: Peter Zijlstra <[EMAIL PROTECTED]>
> > Date:   Fri Jan 25 21:08:30 2008 +0100
> > 
> > sched: rt group scheduling
> > 
> > I'm now checking if the problem disappears after reverting this patch 
> > (along a
> > couple of dependent ones).
> 
> Yes, it does.
> 
> Please let me know what I can do to debug it further.

It arts run as root, or does it use RLIMIT_RTPRIO to allow users to
execute realtime tasks?



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 07/07]: remove dead timer int pending code

2008-01-31 Thread Greg Ungerer
Remove all the dead timer interrupt checking functions for the ColdFire
CPU "timers" hardware that are not used after switching to GENERIC_TIME.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---

 5206/config.c  |   14 --
 5206e/config.c |   14 --
 5249/config.c  |   14 --
 5272/config.c  |   13 -
 5307/config.c  |   14 --
 532x/config.c  |   14 --
 5407/config.c  |   14 --
 7 files changed, 97 deletions(-)


diff -Naurp linux-2.6.24.1/arch/m68knommu/platform/5206/config.c 
linux-2.6.24.2/arch/m68knommu/platform/5206/config.c
--- linux-2.6.24.1/arch/m68knommu/platform/5206/config.c2008-02-01 
15:21:26.0 +1000
+++ linux-2.6.24.2/arch/m68knommu/platform/5206/config.c2008-02-01 
16:13:27.0 +1000
@@ -109,20 +109,6 @@ void mcf_settimericr(unsigned int timer,
 
 /***/
 
-int mcf_timerirqpending(int timer)
-{
-   unsigned int imr = 0;
-
-   switch (timer) {
-   case 1:  imr = MCFSIM_IMR_TIMER1; break;
-   case 2:  imr = MCFSIM_IMR_TIMER2; break;
-   default: break;
-   }
-   return (mcf_getipr() & imr);
-}
-
-/***/
-
 void __init config_BSP(char *commandp, int size)
 {
mcf_setimr(MCFSIM_IMR_MASKALL);
diff -Naurp linux-2.6.24.1/arch/m68knommu/platform/5206e/config.c 
linux-2.6.24.2/arch/m68knommu/platform/5206e/config.c
--- linux-2.6.24.1/arch/m68knommu/platform/5206e/config.c   2008-02-01 
15:25:21.0 +1000
+++ linux-2.6.24.2/arch/m68knommu/platform/5206e/config.c   2008-02-01 
16:13:33.0 +1000
@@ -108,20 +108,6 @@ void mcf_settimericr(unsigned int timer,
 
 /***/
 
-int mcf_timerirqpending(int timer)
-{
-   unsigned int imr = 0;
-
-   switch (timer) {
-   case 1:  imr = MCFSIM_IMR_TIMER1; break;
-   case 2:  imr = MCFSIM_IMR_TIMER2; break;
-   default: break;
-   }
-   return (mcf_getipr() & imr);
-}
-
-/***/
-
 void __init config_BSP(char *commandp, int size)
 {
mcf_setimr(MCFSIM_IMR_MASKALL);
diff -Naurp linux-2.6.24.1/arch/m68knommu/platform/5249/config.c 
linux-2.6.24.2/arch/m68knommu/platform/5249/config.c
--- linux-2.6.24.1/arch/m68knommu/platform/5249/config.c2008-02-01 
15:41:28.0 +1000
+++ linux-2.6.24.2/arch/m68knommu/platform/5249/config.c2008-02-01 
16:13:40.0 +1000
@@ -105,20 +105,6 @@ void mcf_settimericr(unsigned int timer,
 
 /***/
 
-int mcf_timerirqpending(int timer)
-{
-   unsigned int imr = 0;
-
-   switch (timer) {
-   case 1:  imr = MCFSIM_IMR_TIMER1; break;
-   case 2:  imr = MCFSIM_IMR_TIMER2; break;
-   default: break;
-   }
-   return (mcf_getipr() & imr);
-}
-
-/***/
-
 void __init config_BSP(char *commandp, int size)
 {
mcf_setimr(MCFSIM_IMR_MASKALL);
diff -Naurp linux-2.6.24.1/arch/m68knommu/platform/5272/config.c 
linux-2.6.24.2/arch/m68knommu/platform/5272/config.c
--- linux-2.6.24.1/arch/m68knommu/platform/5272/config.c2008-02-01 
15:44:22.0 +1000
+++ linux-2.6.24.2/arch/m68knommu/platform/5272/config.c2008-02-01 
16:13:46.0 +1000
@@ -123,19 +123,6 @@ void mcf_settimericr(int timer, int leve
 
 /***/
 
-int mcf_timerirqpending(int timer)
-{
-   volatile unsigned long *icrp;
-
-   if ((timer >= 1 ) && (timer <= 4)) {
-   icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
-   return (*icrp & (0x8 << ((4 - timer) * 4)));
-   }
-   return 0;
-}
-
-/***/
-
 void __init config_BSP(char *commandp, int size)
 {
 #if defined (CONFIG_MOD5272)
diff -Naurp linux-2.6.24.1/arch/m68knommu/platform/5307/config.c 
linux-2.6.24.2/arch/m68knommu/platform/5307/config.c
--- linux-2.6.24.1/arch/m68knommu/platform/5307/config.c2008-02-01 
15:46:11.0 +1000
+++ linux-2.6.24.2/arch/m68knommu/platform/5307/config.c2008-02-01 
16:13:51.0 +1000
@@ -119,20 +119,6 @@ void mcf_settimericr(unsigned int timer,
 
 /***/
 
-int mcf_timerirqpending(int timer)
-{
-   unsigned int imr = 0;
-
-   switch (timer) {
-   case 1:  imr = MCFSIM_IMR_TIMER1; break;
-   case 2:  imr = MCFSIM_IMR_TIMER2; break;
-   default: break;
-   }
-   return (mcf_getipr() & imr);
-}
-
-/***/
-
 void __init 

[M68KNOMMU 03/07]: switch ColdFire TIMER to use GENERIC_TIME

2008-01-31 Thread Greg Ungerer
Switch the ColdFire TIMER timer to use GENERIC_TIME.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24.1/arch/m68knommu/platform/coldfire/timers.c 
linux-2.6.24.2/arch/m68knommu/platform/coldfire/timers.c
--- linux-2.6.24.1/arch/m68knommu/platform/coldfire/timers.c2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24.2/arch/m68knommu/platform/coldfire/timers.c2008-02-01 
16:15:50.0 +1000
@@ -3,7 +3,7 @@
 /*
  * timers.c -- generic ColdFire hardware timer support.
  *
- * Copyright (C) 1999-2007, Greg Ungerer ([EMAIL PROTECTED])
+ * Copyright (C) 1999-2008, Greg Ungerer <[EMAIL PROTECTED]>
  */
 
 /***/
@@ -13,6 +13,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -25,6 +27,7 @@
 /*
  * By default use timer1 as the system clock timer.
  */
+#defineFREQ(MCF_BUSCLK / 16)
 #defineTA(a)   (MCF_MBAR + MCFTIMER_BASE1 + (a))
 
 /*
@@ -41,7 +44,7 @@ unsigned int  mcf_timerlevel = 5;
  * Unfortunately it is a little different on each ColdFire.
  */
 extern void mcf_settimericr(int timer, int level);
-extern int mcf_timerirqpending(int timer);
+void coldfire_profile_init(void);
 
 #if defined(CONFIG_M532x)
 #define__raw_readtrr   __raw_readl
@@ -51,38 +54,70 @@ extern int mcf_timerirqpending(int timer
 #define__raw_writetrr  __raw_writew
 #endif
 
+static u32 mcftmr_cycles_per_jiffy;
+static u32 mcftmr_cnt;
+
 /***/
 
-static irqreturn_t hw_tick(int irq, void *dummy)
+static irqreturn_t mcftmr_tick(int irq, void *dummy)
 {
/* Reset the ColdFire timer */
__raw_writeb(MCFTIMER_TER_CAP | MCFTIMER_TER_REF, TA(MCFTIMER_TER));
 
+   mcftmr_cnt += mcftmr_cycles_per_jiffy;
return arch_timer_interrupt(irq, dummy);
 }
 
 /***/
 
-static struct irqaction coldfire_timer_irq = {
+static struct irqaction mcftmr_timer_irq = {
.name= "timer",
.flags   = IRQF_DISABLED | IRQF_TIMER,
-   .handler = hw_tick,
+   .handler = mcftmr_tick,
 };
 
 /***/
 
-static int ticks_per_intr;
+static cycle_t mcftmr_read_clk(void)
+{
+   unsigned long flags;
+   u32 cycles;
+   u16 tcn;
+
+   local_irq_save(flags);
+   tcn = __raw_readw(TA(MCFTIMER_TCN));
+   cycles = mcftmr_cnt;
+   local_irq_restore(flags);
+
+   return cycles + tcn;
+}
+
+/***/
+
+static struct clocksource mcftmr_clk = {
+   .name   = "tmr",
+   .rating = 250,
+   .read   = mcftmr_read_clk,
+   .shift  = 20,
+   .mask   = CLOCKSOURCE_MASK(32),
+   .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
+};
+
+/***/
 
 void hw_timer_init(void)
 {
-   setup_irq(mcf_timervector, _timer_irq);
+   setup_irq(mcf_timervector, _timer_irq);
 
__raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR));
-   ticks_per_intr = (MCF_BUSCLK / 16) / HZ;
-   __raw_writetrr(ticks_per_intr - 1, TA(MCFTIMER_TRR));
+   mcftmr_cycles_per_jiffy = FREQ / HZ;
+   __raw_writetrr(mcftmr_cycles_per_jiffy, TA(MCFTIMER_TRR));
__raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 |
MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR));
 
+   mcftmr_clk.mult = clocksource_hz2mult(FREQ, mcftmr_clk.shift);
+   clocksource_register(_clk);
+
mcf_settimericr(1, mcf_timerlevel);
 
 #ifdef CONFIG_HIGHPROFILE
@@ -91,21 +126,6 @@ void hw_timer_init(void)
 }
 
 /***/
-
-unsigned long hw_timer_offset(void)
-{
-   unsigned long tcn, offset;
-
-   tcn = __raw_readw(TA(MCFTIMER_TCN));
-   offset = ((tcn + 1) * (100 / HZ)) / ticks_per_intr;
-
-   /* Check if we just wrapped the counters and maybe missed a tick */
-   if ((offset < (100 / HZ / 2)) && mcf_timerirqpending(1))
-   offset += 100 / HZ;
-   return offset;
-}
-
-/***/
 #ifdef CONFIG_HIGHPROFILE
 /***/
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 05/07]: remove local gettimeofday code

2008-01-31 Thread Greg Ungerer
Remove unused local gettimeofday functions, now that we are using
GENERIC_TIME.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/kernel/time.c 
linux-2.6.24-uc0/arch/m68knommu/kernel/time.c
--- linux-2.6.24/arch/m68knommu/kernel/time.c   2008-01-25 08:58:37.0 
+1000
+++ linux-2.6.24-uc0/arch/m68knommu/kernel/time.c   2008-01-15 
16:33:28.0 +1000
@@ -112,60 +112,3 @@ void time_init(void)
hw_timer_init();
 }
 
-/*
- * This version of gettimeofday has near microsecond resolution.
- */
-void do_gettimeofday(struct timeval *tv)
-{
-   unsigned long flags;
-   unsigned long seq;
-   unsigned long usec, sec;
-
-   do {
-   seq = read_seqbegin_irqsave(_lock, flags);
-   usec = hw_timer_offset();
-   sec = xtime.tv_sec;
-   usec += (xtime.tv_nsec / 1000);
-   } while (read_seqretry_irqrestore(_lock, seq, flags));
-
-   while (usec >= 100) {
-   usec -= 100;
-   sec++;
-   }
-
-   tv->tv_sec = sec;
-   tv->tv_usec = usec;
-}
-
-EXPORT_SYMBOL(do_gettimeofday);
-
-int do_settimeofday(struct timespec *tv)
-{
-   time_t wtm_sec, sec = tv->tv_sec;
-   long wtm_nsec, nsec = tv->tv_nsec;
-
-   if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
-   return -EINVAL;
-
-   write_seqlock_irq(_lock);
-   /*
-* This is revolting. We need to set the xtime.tv_usec
-* correctly. However, the value in this location is
-* is value at the last tick.
-* Discover what correction gettimeofday
-* would have done, and then undo it!
-*/
-   nsec -= (hw_timer_offset() * 1000);
-
-   wtm_sec  = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
-   wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
-
-   set_normalized_timespec(, sec, nsec);
-   set_normalized_timespec(_to_monotonic, wtm_sec, wtm_nsec);
-
-   ntp_clear();
-   write_sequnlock_irq(_lock);
-   clock_was_set();
-   return 0;
-}
-EXPORT_SYMBOL(do_settimeofday);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 06/07]: remove empty timer offset function for 68360

2008-01-31 Thread Greg Ungerer
Switching to GENERIC_TIME means we no longer need the empty timer offset
function for the 68360 CPU.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/68360/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/68360/config.c
--- linux-2.6.24/arch/m68knommu/platform/68360/config.c 2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/68360/config.c 2008-01-11 
20:33:46.0 +1000
@@ -103,11 +103,6 @@ void hw_timer_init(void)
   pquicc->timer_tgcr  = tgcr_save;
 }
 
-unsigned long hw_timer_offset(void)
-{
-  return 0;
-}
-
 void BSP_gettod (int *yearp, int *monp, int *dayp,
   int *hourp, int *minp, int *secp)
 {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 02/07]: switch ColdFire PIT timer to use GENERIC_TIME

2008-01-31 Thread Greg Ungerer
Switch the ColdFire PIT timer to using GENERIC_TIME.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24.1/arch/m68knommu/platform/coldfire/pit.c 
linux-2.6.24.2/arch/m68knommu/platform/coldfire/pit.c
--- linux-2.6.24.1/arch/m68knommu/platform/coldfire/pit.c   2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24.2/arch/m68knommu/platform/coldfire/pit.c   2008-02-01 
16:29:26.0 +1000
@@ -3,9 +3,10 @@
 /*
  * pit.c -- Freescale ColdFire PIT timer. Currently this type of
  *  hardware timer only exists in the Freescale ColdFire
- *  5270/5271, 5282 and other CPUs.
+ *  5270/5271, 5282 and 5208 CPUs. No doubt newer ColdFire
+ *  family members will probably use it too.
  *
- * Copyright (C) 1999-2007, Greg Ungerer ([EMAIL PROTECTED])
+ * Copyright (C) 1999-2008, Greg Ungerer ([EMAIL PROTECTED])
  * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com)
  */
 
@@ -17,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -28,70 +30,84 @@
 /*
  * By default use timer1 as the system clock timer.
  */
+#defineFREQ((MCF_CLK / 2) / 64)
 #defineTA(a)   (MCF_IPSBAR + MCFPIT_BASE1 + (a))
+#defineINTC0   (MCF_IPSBAR + MCFICM_INTC0)
+
+static u32 pit_cycles_per_jiffy;
+static u32 pit_cnt;
 
 /***/
 
-static irqreturn_t hw_tick(int irq, void *dummy)
+static irqreturn_t pit_tick(int irq, void *dummy)
 {
-   unsigned short pcsr;
+   u16 pcsr;
 
/* Reset the ColdFire timer */
pcsr = __raw_readw(TA(MCFPIT_PCSR));
__raw_writew(pcsr | MCFPIT_PCSR_PIF, TA(MCFPIT_PCSR));
 
+   pit_cnt += pit_cycles_per_jiffy;
return arch_timer_interrupt(irq, dummy);
 }
 
 /***/
 
-static struct irqaction coldfire_pit_irq = {
+static struct irqaction pit_irq = {
.name= "timer",
.flags   = IRQF_DISABLED | IRQF_TIMER,
-   .handler = hw_tick,
+   .handler = pit_tick,
 };
 
-void hw_timer_init(void)
+/***/
+
+static cycle_t pit_read_clk(void)
 {
-   volatile unsigned char *icrp;
-   volatile unsigned long *imrp;
+   unsigned long flags;
+   u32 cycles;
+   u16 pcntr;
 
-   setup_irq(MCFINT_VECBASE + MCFINT_PIT1, _pit_irq);
+   local_irq_save(flags);
+   pcntr = __raw_readw(TA(MCFPIT_PCNTR));
+   cycles = pit_cnt;
+   local_irq_restore(flags);
 
-   icrp = (volatile unsigned char *) (MCF_IPSBAR + MCFICM_INTC0 +
-   MCFINTC_ICR0 + MCFINT_PIT1);
-   *icrp = ICR_INTRCONF;
+   return cycles + pit_cycles_per_jiffy - pcntr;
+}
 
-   imrp = (volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + 
MCFPIT_IMR);
-   *imrp &= ~MCFPIT_IMR_IBIT;
+/***/
 
-   /* Set up PIT timer 1 as poll clock */
-   __raw_writew(MCFPIT_PCSR_DISABLE, TA(MCFPIT_PCSR));
-   __raw_writew(((MCF_CLK / 2) / 64) / HZ, TA(MCFPIT_PMR));
-   __raw_writew(MCFPIT_PCSR_EN | MCFPIT_PCSR_PIE | MCFPIT_PCSR_OVW |
-   MCFPIT_PCSR_RLD | MCFPIT_PCSR_CLK64, TA(MCFPIT_PCSR));
-}
+static struct clocksource pit_clk = {
+   .name   = "pit",
+   .rating = 250,
+   .read   = pit_read_clk,
+   .shift  = 20,
+   .mask   = CLOCKSOURCE_MASK(32),
+   .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
+};
 
 /***/
 
-unsigned long hw_timer_offset(void)
+void hw_timer_init(void)
 {
-   volatile unsigned long *ipr;
-   unsigned long pmr, pcntr, offset;
+   u32 imr;
 
-   ipr = (volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + 
MCFPIT_IMR);
+   setup_irq(MCFINT_VECBASE + MCFINT_PIT1, _irq);
 
-   pmr = __raw_readw(TA(MCFPIT_PMR));
-   pcntr = __raw_readw(TA(MCFPIT_PCNTR));
+   __raw_writeb(ICR_INTRCONF, INTC0 + MCFINTC_ICR0 + MCFINT_PIT1);
+   imr = __raw_readl(INTC0 + MCFPIT_IMR);
+   imr &= ~MCFPIT_IMR_IBIT;
+   __raw_writel(imr, INTC0 + MCFPIT_IMR);
+
+   /* Set up PIT timer 1 as poll clock */
+   pit_cycles_per_jiffy = FREQ / HZ;
+   __raw_writew(MCFPIT_PCSR_DISABLE, TA(MCFPIT_PCSR));
+   __raw_writew(pit_cycles_per_jiffy, TA(MCFPIT_PMR));
+   __raw_writew(MCFPIT_PCSR_EN | MCFPIT_PCSR_PIE | MCFPIT_PCSR_OVW |
+   MCFPIT_PCSR_RLD | MCFPIT_PCSR_CLK64, TA(MCFPIT_PCSR));
 
-   /*
-* If we are still in the first half of the upcount and a
-* timer interrupt is pending, then add on a ticks worth of time.
-*/
-   offset = ((pmr - pcntr) * (100 / HZ)) / pmr;
-   if ((offset < (100 / HZ / 2)) && (*ipr & MCFPIT_IMR_IBIT))
-   offset += 100 / HZ;
-   return offset;  
+ 

[M68KNOMMU 04/07]: set config to use GENERIC_TIME

2008-01-31 Thread Greg Ungerer
Switch m68knommu arch to using GENERIC_TIME.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/Kconfig 
linux-2.6.24-uc0/arch/m68knommu/Kconfig
--- linux-2.6.24/arch/m68knommu/Kconfig 2008-01-25 08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/Kconfig 2008-01-25 14:32:36.0 
+1000
@@ -53,6 +53,10 @@ config GENERIC_CALIBRATE_DELAY
bool
default y
 
+config GENERIC_TIME
+   bool
+   default y
+
 config TIME_LOW_RES
bool
default y
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 00/07]: switch to GENERIC_TIME

2008-01-31 Thread Greg Ungerer
Switch the m68knommu arch to using CONFIG_GENERIC_TIME.

There is a number of different timers on the vairous m68knommu
family members, so there is a few files affected.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]

 linux-2.6.24/arch/m68knommu/Kconfig|4
 linux-2.6.24/arch/m68knommu/kernel/time.c  |   57 -
 linux-2.6.24/arch/m68knommu/platform/68328/timers.c|   56 +++--
 linux-2.6.24/arch/m68knommu/platform/68360/config.c|5
 linux-2.6.24/arch/m68knommu/platform/5206/config.c |   14 --
 linux-2.6.24/arch/m68knommu/platform/5206e/config.c|   14 --
 linux-2.6.24/arch/m68knommu/platform/5249/config.c |   14 --
 linux-2.6.24/arch/m68knommu/platform/5272/config.c |   13 --
 linux-2.6.24/arch/m68knommu/platform/5307/config.c |   14 --
 linux-2.6.24/arch/m68knommu/platform/532x/config.c |   14 --
 linux-2.6.24/arch/m68knommu/platform/5407/config.c |   14 --
 linux-2.6.24/arch/m68knommu/platform/coldfire/pit.c|   86 ---
 linux-2.6.24/arch/m68knommu/platform/coldfire/timers.c |   68 +++
 13 files changed, 142 insertions(+), 231 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 01/07]: switch 68328 timer to use GENERIC_TIME

2008-01-31 Thread Greg Ungerer
Switch the 68328 CPU timer code to using GENERIC_TIME.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/68328/timers.c 
linux-2.6.24-uc0/arch/m68knommu/platform/68328/timers.c
--- linux-2.6.24/arch/m68knommu/platform/68328/timers.c 2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/68328/timers.c 2008-01-25 
14:32:37.0 +1000
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -51,6 +52,19 @@
 #define TICKS_PER_JIFFY10
 #endif
 
+static u32 m68328_tick_cnt;
+
+/***/
+
+static irqreturn_t hw_tick(int irq, void *dummy)
+{
+   /* Reset Timer1 */
+   TSTAT &= 0;
+
+   m68328_tick_cnt += TICKS_PER_JIFFY;
+   return arch_timer_interrupt(irq, dummy);
+}
+
 /***/
 
 static irqreturn_t hw_tick(int irq, void *dummy)
@@ -69,6 +83,33 @@ static struct irqaction m68328_timer_irq
.handler = hw_tick,
 };
 
+/***/
+
+static cycle_t m68328_read_clk(void)
+{
+   unsigned long flags;
+   u32 cycles;
+
+   local_irq_save(flags);
+   cycles = m68328_tick_cnt + TCN;
+   local_irq_restore(flags);
+
+   return cycles;
+}
+
+/***/
+
+static struct clocksource m68328_clk = {
+   .name   = "timer",
+   .rating = 250,
+   .read   = m68328_read_clk,
+   .shift  = 20,
+   .mask   = CLOCKSOURCE_MASK(32),
+   .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
+};
+
+/***/
+
 void hw_timer_init(void)
 {
/* disable timer 1 */
@@ -84,19 +125,8 @@ void hw_timer_init(void)
 
/* Enable timer 1 */
TCTL |= TCTL_TEN;
-}
-
-/***/
-
-unsigned long hw_timer_offset(void)
-{
-   unsigned long ticks = TCN, offset = 0;
-
-   /* check for pending interrupt */
-   if (ticks < (TICKS_PER_JIFFY >> 1) && (ISR & (1 << TMR_IRQ_NUM)))
-   offset = 100 / HZ;
-   ticks = (ticks * 100 / HZ) / TICKS_PER_JIFFY;
-   return ticks + offset;
+   m68328_clk.mult = clocksource_hz2mult(TICKS_PER_JIFFY*HZ, 
m68328_clk.shift);
+   clocksource_register(_clk);
 }
 
 /***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [1/2] POHMELFS - network filesystem with local coherent cache.

2008-01-31 Thread Evgeniy Polyakov
Hi.

On Fri, Feb 01, 2008 at 02:04:39AM +0100, Jan Engelhardt ([EMAIL PROTECTED]) 
wrote:
> >POHMELFS stands for Parallel Optimized Host Message Exchange
> >Layered File System. It allows to mount remote servers to local
> >directory via network. This filesystem supports local caching
> >and writeback flushing.
> >POHMELFS is a brick in a future distributed filesystem.
> 
> A brick is usually something that is in the way -
> Or you also say "the user has bricked his machine"
> when it's quite unusable :)
> Hope you did not mean /that/.

No, this brick as a building block :)

> >This set includes two patches:
> > * network filesystem with write-through cache (slow, but works with
> > remote userspace server)
> > * hack to show how local cache works and how faster it is compared
> > to async NFS (see below). hack disables writeback flush and
> > performs local allocation of the objects only.
> >
> >Now, some vaporware aka food for thoughts and your brains.
> >
> >A small benchmark of the local cached mode (above hack):
> >
> >$ time tar -xf /home/zbr/threading.tar
> >
> > POHMELFSNFS v3 (async)
> >real0m0.043s 0m1.679s
> >
> >Which is damn 40 times!
> 
> Needs a bigger data set to compare. But what is much more
> important: does it use a single port for networing, or some
> firewall-unfriendly-by-default multiple dynamic-port-allocation
> like NFS?

It uses single port, configurable at mount time.
POHMELFS client can connect to different addresses (including ipv6) and
via different protocols (like sctp). Metadata server will provide that
information dynamically, so pohmelfs client will be able to connect to
different nodes and perform operations in parallell.

> >Next task is to think about how to generically solve the problem with
> >syncing local changes with remote server, when remote server maintains 
> >inodes with
> >completely different numbers.
> >This, among others, will allow offline work with automatic syncing after 
> >reconnect.
> 
> What will happen when both nodes change an inode in disconnected state?
> Which inode wins out?

Who will be online first. Second node will be told that there is a
merge collision and it has to be resolved by hands.

> >This is not intended for inclusion, CRFS by Zach Brown is a bit ahead of 
> >POHMELFS,
> >but it is not generic enough (because of above problem), works only with 
> >BTRFS,
> >and was closed by Oracle so far :)
> 
> btrfs is all we need :p

Well, at least it has some very interesting ideas.
Although there are things which are not that good imho, time will
show, maybe there will be another state-of-the-art filesystem at the
moment...

This was for information.
 
> Where's the parallelism that is advertised by the "POH" in pohmelfs?

First, clients work with local caches and sync them either in writeback
or via cache coherency algorithm. This work is effectively parallel.
Second, pohmelfs as in distributed filesystem is developed as a transport
layer to eliminate mount operation for each different node, so that
after client asks for data it would be just sent to different server.
This allows to make parallel transactions. Essentially it looks like
mounting different remote server to virtual directory working with it,
except that connection setup should be done not at mount time, but at
run time.

-- 
Evgeniy Polyakov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: remove unused CONFIG_DISKtel symbol

2008-01-31 Thread Greg Ungerer
Remove unused CONFIG_DISKtel define.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/include/asm-m68knommu/mcfuart.h 
linux-2.6.24-uc0/include/asm-m68knommu/mcfuart.h
--- linux-2.6.24/include/asm-m68knommu/mcfuart.h2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/include/asm-m68knommu/mcfuart.h2007-07-13 
11:28:58.0 +1000
@@ -12,7 +12,6 @@
 #definemcfuart_h
 //
 
-
 /*
  * Define the base address of the UARTS within the MBAR address
  * space.
@@ -33,7 +32,7 @@
 #define MCFUART_BASE2  0x240   /* Base address of UART2 */
 #define MCFUART_BASE3  0x280   /* Base address of UART3 */
 #elif defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407)
-#if defined(CONFIG_NETtel) || defined(CONFIG_DISKtel) || 
defined(CONFIG_SECUREEDGEMP3)
+#if defined(CONFIG_NETtel) || defined(CONFIG_SECUREEDGEMP3)
 #define MCFUART_BASE1  0x200   /* Base address of UART1 */
 #define MCFUART_BASE2  0x1c0   /* Base address of UART2 */
 #else
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2.6.24] Add new string functions strict_strto* and convert kernel params to use them, take 2

2008-01-31 Thread Andrew Morton
On Fri, 01 Feb 2008 06:11:43 +0800 Yi Yang <[EMAIL PROTECTED]> wrote:

> --- a/include/linux/kernel.h  2008-01-31 00:41:46.0 +0800
> --- b/include/linux/kernel.h  2008-02-01 04:30:49.0 +0800

This isn't a patch.  I wonder how that happened?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: fix 528x ColdFire cache settings

2008-01-31 Thread Greg Ungerer
Fix problems with the 528x ColdFire CPU cache setup.
Do not cache the flash region (if present), and make the runtime
settings consistent with the init setting.

Problems pointed out by Bernd Buttner <[EMAIL PROTECTED]>

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/include/asm-m68knommu/cacheflush.h 
linux-2.6.24-uc0/include/asm-m68knommu/cacheflush.h
--- linux-2.6.24/include/asm-m68knommu/cacheflush.h 2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/include/asm-m68knommu/cacheflush.h 2007-10-29 
16:43:08.0 +1000
@@ -53,7 +53,7 @@ static inline void __flush_cache_all(voi
 #endif /* CONFIG_M5407 */
 #if defined(CONFIG_M527x) || defined(CONFIG_M528x)
__asm__ __volatile__ (
-   "movel  #0x81400100, %%d0\n\t"
+   "movel  #0x81000200, %%d0\n\t"
"movec  %%d0, %%CACR\n\t"
"nop\n\t"
: : : "d0" );
diff -Naurp linux-2.6.24/include/asm-m68knommu/mcfcache.h 
linux-2.6.24-uc0/include/asm-m68knommu/mcfcache.h
--- linux-2.6.24/include/asm-m68knommu/mcfcache.h   2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/include/asm-m68knommu/mcfcache.h   2007-10-29 
16:43:08.0 +1000
@@ -60,7 +60,7 @@
nop
movel   #0xc020, %d0/* Set SDRAM cached only */
movec   %d0, %ACR0
-   movel   #0xff00c000, %d0/* Cache Flash also */
+   movel   #0x, %d0/* No other regions cached */
movec   %d0, %ACR1
movel   #0x8200, %d0/* Setup cache mask */
movec   %d0, %CACR  /* Enable cache */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 06/06]: modify Makefiles to support common coldfire directory

2008-01-31 Thread Greg Ungerer
Modify Makefiles to support separate coldfire platform directory.

Currently the common ColdFire CPU family code sits in the
arch/m68knommu/platform/5307 directory. This is confusing, the files
containing this common code are in no way specific to the 5307 ColdFire.
Create an arch/m68knommu/platform/coldfire directory to contain this
common code. Other m68knommu CPU varients do not need use this code
though, so it doesn't make sense to move it to arch/m68knommu/kernel.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]


diff -Naurp linux-2.6.24/arch/m68knommu/Makefile 
linux-2.6.24.1/arch/m68knommu/Makefile
--- linux-2.6.24/arch/m68knommu/Makefile2008-01-25 08:58:37.0 
+1000
+++ linux-2.6.24.1/arch/m68knommu/Makefile  2008-01-31 17:04:07.0 
+1000
@@ -61,17 +61,17 @@ MODEL := $(model-y)
 # for the selected cpu. ONLY need to define this for the non-base member
 # of the family.
 #
-cpuclass-$(CONFIG_M5206)   := 5307
-cpuclass-$(CONFIG_M5206e)  := 5307
-cpuclass-$(CONFIG_M520x)   := 5307
-cpuclass-$(CONFIG_M523x)   := 5307
-cpuclass-$(CONFIG_M5249)   := 5307
-cpuclass-$(CONFIG_M527x)   := 5307
-cpuclass-$(CONFIG_M5272)   := 5307
-cpuclass-$(CONFIG_M528x)   := 5307
-cpuclass-$(CONFIG_M5307)   := 5307
-cpuclass-$(CONFIG_M532x)   := 5307
-cpuclass-$(CONFIG_M5407)   := 5307
+cpuclass-$(CONFIG_M5206)   := coldfire
+cpuclass-$(CONFIG_M5206e)  := coldfire
+cpuclass-$(CONFIG_M520x)   := coldfire
+cpuclass-$(CONFIG_M523x)   := coldfire
+cpuclass-$(CONFIG_M5249)   := coldfire
+cpuclass-$(CONFIG_M527x)   := coldfire
+cpuclass-$(CONFIG_M5272)   := coldfire
+cpuclass-$(CONFIG_M528x)   := coldfire
+cpuclass-$(CONFIG_M5307)   := coldfire
+cpuclass-$(CONFIG_M532x)   := coldfire
+cpuclass-$(CONFIG_M5407)   := coldfire
 cpuclass-$(CONFIG_M68328)  := 68328
 cpuclass-$(CONFIG_M68EZ328):= 68328
 cpuclass-$(CONFIG_M68VZ328):= 68328
diff -Naurp linux-2.6.24/arch/m68knommu/platform/5307/Makefile 
linux-2.6.24.1/arch/m68knommu/platform/5307/Makefile
--- linux-2.6.24/arch/m68knommu/platform/5307/Makefile  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24.1/arch/m68knommu/platform/5307/Makefile2008-01-31 
16:35:54.0 +1000
@@ -16,17 +16,5 @@ ifdef CONFIG_FULLDEBUG
 EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
-obj-$(CONFIG_COLDFIRE) += entry.o vectors.o
-obj-$(CONFIG_M5206)+= timers.o
-obj-$(CONFIG_M5206e)   += timers.o
-obj-$(CONFIG_M520x)+= pit.o
-obj-$(CONFIG_M523x)+= pit.o
-obj-$(CONFIG_M5249)+= timers.o
-obj-$(CONFIG_M527x) += pit.o
-obj-$(CONFIG_M5272)+= timers.o
-obj-$(CONFIG_M5307)+= config.o timers.o
-obj-$(CONFIG_M532x)+= timers.o
-obj-$(CONFIG_M528x) += pit.o
-obj-$(CONFIG_M5407)+= timers.o
+obj-y  += config.o
 
-extra-y := head.o
diff -Naurp linux-2.6.24/arch/m68knommu/platform/coldfire/Makefile 
linux-2.6.24.1/arch/m68knommu/platform/coldfire/Makefile
--- linux-2.6.24/arch/m68knommu/platform/coldfire/Makefile  1970-01-01 
10:00:00.0 +1000
+++ linux-2.6.24.1/arch/m68knommu/platform/coldfire/Makefile2008-01-31 
16:35:13.0 +1000
@@ -0,0 +1,32 @@
+#
+# Makefile for the m68knommu kernel.
+#
+
+#
+# If you want to play with the HW breakpoints then you will
+# need to add define this,  which will give you a stack backtrace
+# on the console port whenever a DBG interrupt occurs. You have to
+# set up you HW breakpoints to trigger a DBG interrupt:
+#
+# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT
+# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
+#
+
+ifdef CONFIG_FULLDEBUG
+AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+endif
+
+obj-$(CONFIG_COLDFIRE) += dma.o entry.o vectors.o
+obj-$(CONFIG_M5206)+= timers.o
+obj-$(CONFIG_M5206e)   += timers.o
+obj-$(CONFIG_M520x)+= pit.o
+obj-$(CONFIG_M523x)+= pit.o
+obj-$(CONFIG_M5249)+= timers.o
+obj-$(CONFIG_M527x)+= pit.o
+obj-$(CONFIG_M5272)+= timers.o
+obj-$(CONFIG_M528x)+= pit.o
+obj-$(CONFIG_M5307)+= timers.o
+obj-$(CONFIG_M532x)+= timers.o
+obj-$(CONFIG_M5407)+= timers.o
+
+extra-y := head.o
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: remove dead code from m68knommu timer code

2008-01-31 Thread Greg Ungerer
Remove unused LED heartbeat code from m68knommu timer code.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/kernel/time.c 
linux-2.6.24-uc0/arch/m68knommu/kernel/time.c
--- linux-2.6.24/arch/m68knommu/kernel/time.c   2008-01-25 08:58:37.0 
+1000
+++ linux-2.6.24-uc0/arch/m68knommu/kernel/time.c   2008-01-15 
16:33:28.0 +1000
@@ -22,7 +22,6 @@
 #include 
 
 #include 
-#include 
 #include 
 
 #defineTICK_SIZE (tick_nsec / 1000)
@@ -66,29 +65,6 @@ irqreturn_t arch_timer_interrupt(int irq
  else
last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
}
-#ifdef CONFIG_HEARTBEAT
-   /* use power LED as a heartbeat instead -- much more useful
-  for debugging -- based on the version for PReP by Cort */
-   /* acts like an actual heart beat -- ie thump-thump-pause... */
-   if (mach_heartbeat) {
-   static unsigned cnt = 0, period = 0, dist = 0;
-
-   if (cnt == 0 || cnt == dist)
-   mach_heartbeat( 1 );
-   else if (cnt == 7 || cnt == dist+7)
-   mach_heartbeat( 0 );
-
-   if (++cnt > period) {
-   cnt = 0;
-   /* The hyperbolic function below modifies the heartbeat period
-* length in dependency of the current (5min) load. It goes
-* through the points f(0)=126, f(1)=86, f(5)=51,
-* f(inf)->30. */
-   period = ((672

Re: [PATCH 2.6.24] Add new string functions strict_strto* and convert kernel params to use them, take 2

2008-01-31 Thread Andrew Morton
On Fri, 01 Feb 2008 06:11:43 +0800 Yi Yang <[EMAIL PROTECTED]> wrote:

> --- a/include/linux/kernel.h  2008-01-31 00:41:46.0 +0800
> --- b/include/linux/kernel.h  2008-02-01 04:30:49.0 +0800
> @@ -141,6 +141,10 @@ extern unsigned long simple_strtoul(cons
>  extern long simple_strtol(const char *,char **,unsigned int);
>  extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
>  extern long long simple_strtoll(const char *,char **,unsigned int);
> +extern int strict_strtoul(const char *, unsigned int, unsigned long *);
> +extern int strict_strtol(const char *, unsigned int, long *);
> +extern int strict_strtoull(const char *, unsigned int, unsigned long long *);
> +extern int strict_strtoll(const char *, unsigned int, long long *);
>  extern int sprintf(char * buf, const char * fmt, ...)
>   __attribute__ ((format (printf, 2, 3)));
>  extern int vsprintf(char *buf, const char *, va_list)
> --- a/lib/vsprintf.c  2008-01-30 08:13:03.0 +0800
> --- b/lib/vsprintf.c  2008-02-01 04:33:27.0 +0800
> @@ -126,6 +126,52 @@ long long simple_strtoll(const char *cp,
>   return simple_strtoull(cp,endp,base);
>  }
>  
> +#define define_strict_strtoux(type, valtype) \
> +int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\
> +{\
> + char *tail; \
> + valtype val;\
> + size_t len; \
> + \
> + *res = 0;   \
> + len = strlen(cp);   \
> + if (len == 0)   \
> + return -EINVAL; \
> + \
> + val = simple_strtoul(cp, , base);  \
> + if ((*tail == '\0') ||  \
> + (len == (size_t)(tail - cp) + 1) && (*tail == '\n')) {  \
> + *res = val; \
> + return 0;   \
> + }   \
> + \
> + return -EINVAL; \
> +}\
> +
> +#define define_strict_strtox(type, valtype)  \
> +int strict_strto##type(const char *cp, unsigned int base, valtype *res)  
> \
> +{\
> + int ret;\
> + if (*cp == '-') {   \
> + ret = strict_strtou##type(cp+1, base, res); \
> + if (ret != 0)   \
> + *res = -(*res); \
> + } else  \
> + ret = strict_strtou##type(cp+1, base, res); \
> + \
> + return ret; \
> +}\
> +
> +define_strict_strtoux(l, unsigned long)
> +define_strict_strtox(l, long)
> +define_strict_strtoux(ll, unsigned long long)
> +define_strict_strtox(ll, long long)
> +
> +EXPORT_SYMBOL(strict_strtoul);
> +EXPORT_SYMBOL(strict_strtol);
> +EXPORT_SYMBOL(strict_strtoll);
> +EXPORT_SYMBOL(strict_strtoull);

These are global, exported-to-modules library functions.  Documentation is
compulsory (as far as I'm concerned).

Could you please add a comment block in there which at least explains how
they differ from the other strto* functions?


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch] NULL pointer check for vma->vm_mm

2008-01-31 Thread Kenichi Okuyama
Dear all,

I was looking at the ./mm/rmap.c .. I found that, in function
"page_referenced_one()",
   struct mm_struct *mm = vma->vm_mm;
was being refererred without NULL check.

Though I do agree that this works for most of the cases, I thought it
is better to add
BUG_ON() for case of mm being NULL.

attached is the patch for this

thank you in advance for taking your time.
best regards,
-- 
(Kenichi Okuyama)
URL: http://www.dd.iij4u.or.jp/~okuyamak/


patch.mm
Description: Binary data


[M68KNOMMU]: use container_of in mcf.c

2008-01-31 Thread Greg Ungerer
Use container_of() instead of assuming local uart struct is first member
of uart_port struct.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/drivers/serial/mcf.c 
linux-2.6.24-uc0/drivers/serial/mcf.c
--- linux-2.6.24/drivers/serial/mcf.c   2008-01-25 08:58:37.0 +1000
+++ linux-2.6.24-uc0/drivers/serial/mcf.c   2007-10-29 11:59:53.0 
+1000
@@ -69,7 +69,7 @@ static unsigned int mcf_tx_empty(struct 
 
 static unsigned int mcf_get_mctrl(struct uart_port *port)
 {
-   struct mcf_uart *pp = (struct mcf_uart *) port;
+   struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
unsigned long flags;
unsigned int sigs;
 
@@ -87,7 +87,7 @@ static unsigned int mcf_get_mctrl(struct
 
 static void mcf_set_mctrl(struct uart_port *port, unsigned int sigs)
 {
-   struct mcf_uart *pp = (struct mcf_uart *) port;
+   struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
unsigned long flags;
 
spin_lock_irqsave(>lock, flags);
@@ -104,7 +104,7 @@ static void mcf_set_mctrl(struct uart_po
 
 static void mcf_start_tx(struct uart_port *port)
 {
-   struct mcf_uart *pp = (struct mcf_uart *) port;
+   struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
unsigned long flags;
 
spin_lock_irqsave(>lock, flags);
@@ -117,7 +117,7 @@ static void mcf_start_tx(struct uart_por
 
 static void mcf_stop_tx(struct uart_port *port)
 {
-   struct mcf_uart *pp = (struct mcf_uart *) port;
+   struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
unsigned long flags;
 
spin_lock_irqsave(>lock, flags);
@@ -130,7 +130,7 @@ static void mcf_stop_tx(struct uart_port
 
 static void mcf_stop_rx(struct uart_port *port)
 {
-   struct mcf_uart *pp = (struct mcf_uart *) port;
+   struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
unsigned long flags;
 
spin_lock_irqsave(>lock, flags);
@@ -163,7 +163,7 @@ static void mcf_enable_ms(struct uart_po
 
 static int mcf_startup(struct uart_port *port)
 {
-   struct mcf_uart *pp = (struct mcf_uart *) port;
+   struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
unsigned long flags;
 
spin_lock_irqsave(>lock, flags);
@@ -189,7 +189,7 @@ static int mcf_startup(struct uart_port 
 
 static void mcf_shutdown(struct uart_port *port)
 {
-   struct mcf_uart *pp = (struct mcf_uart *) port;
+   struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
unsigned long flags;
 
spin_lock_irqsave(>lock, flags);
@@ -273,7 +273,7 @@ static void mcf_set_termios(struct uart_
 
 static void mcf_rx_chars(struct mcf_uart *pp)
 {
-   struct uart_port *port = (struct uart_port *) pp;
+   struct uart_port *port = >port;
unsigned char status, ch, flag;
 
while ((status = readb(port->membase + MCFUART_USR)) & 
MCFUART_USR_RXREADY) {
@@ -319,7 +319,7 @@ static void mcf_rx_chars(struct mcf_uart
 
 static void mcf_tx_chars(struct mcf_uart *pp)
 {
-   struct uart_port *port = (struct uart_port *) pp;
+   struct uart_port *port = >port;
struct circ_buf *xmit = >info->xmit;
 
if (port->x_char) {
@@ -352,7 +352,7 @@ static void mcf_tx_chars(struct mcf_uart
 static irqreturn_t mcf_interrupt(int irq, void *data)
 {
struct uart_port *port = data;
-   struct mcf_uart *pp = (struct mcf_uart *) port;
+   struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
unsigned int isr;
 
isr = readb(port->membase + MCFUART_UISR) & pp->imr;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 05/06]: move ColdFire vectors.c to its own coldfire directory

2008-01-31 Thread Greg Ungerer
Move common ColdFire CPU vectors.c to common coldfire platform directory.

Currently the common ColdFire CPU family code sits in the
arch/m68knommu/platform/5307 directory. This is confusing, the files
containing this common code are in no way specific to the 5307 ColdFire.
Create an arch/m68knommu/platform/coldfire directory to contain this
common code. Other m68knommu CPU varients do not need use this code
though, so it doesn't make sense to move it to arch/m68knommu/kernel.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5307/vectors.c 
linux-2.6.24.1/arch/m68knommu/platform/5307/vectors.c
--- linux-2.6.24/arch/m68knommu/platform/5307/vectors.c 2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24.1/arch/m68knommu/platform/5307/vectors.c   1970-01-01 
10:00:00.0 +1000
@@ -1,105 +0,0 @@
-/***/
-
-/*
- * linux/arch/m68knommu/platform/5307/vectors.c
- *
- * Copyright (C) 1999-2007, Greg Ungerer <[EMAIL PROTECTED]>
- */
-
-/***/
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/***/
-
-#ifdef TRAP_DBG_INTERRUPT
-
-asmlinkage void dbginterrupt_c(struct frame *fp)
-{
-   extern void dump(struct pt_regs *fp);
-   printk(KERN_DEBUG "%s(%d): BUS ERROR TRAP\n", __FILE__, __LINE__);
-   dump((struct pt_regs *) fp);
-   asm("halt");
-}
-
-#endif
-
-/***/
-
-extern e_vector*_ramvec;
-
-void set_evector(int vecnum, void (*handler)(void))
-{
-   if (vecnum >= 0 && vecnum <= 255)
-   _ramvec[vecnum] = handler;
-}
-
-/***/
-
-/* Assembler routines */
-asmlinkage void buserr(void);
-asmlinkage void trap(void);
-asmlinkage void system_call(void);
-asmlinkage void inthandler(void);
-
-void __init init_vectors(void)
-{
-   int i;
-
-   /*
-*  There is a common trap handler and common interrupt
-*  handler that handle almost every vector. We treat
-*  the system call and bus error special, they get their
-*  own first level handlers.
-*/
-   for (i = 3; (i <= 23); i++)
-   _ramvec[i] = trap;
-   for (i = 33; (i <= 63); i++)
-   _ramvec[i] = trap;
-   for (i = 24; (i <= 31); i++)
-   _ramvec[i] = inthandler;
-   for (i = 64; (i < 255); i++)
-   _ramvec[i] = inthandler;
-   _ramvec[255] = 0;
-
-   _ramvec[2] = buserr;
-   _ramvec[32] = system_call;
-
-#ifdef TRAP_DBG_INTERRUPT
-   _ramvec[12] = dbginterrupt;
-#endif
-}
-
-/***/
-
-void enable_vector(unsigned int irq)
-{
-   /* Currently no action on ColdFire */
-}
-
-void disable_vector(unsigned int irq)
-{
-   /* Currently no action on ColdFire */
-}
-
-void ack_vector(unsigned int irq)
-{
-   /* Currently no action on ColdFire */
-}
-
-/***/
-
-void coldfire_reset(void)
-{
-   HARD_RESET_NOW();
-}
-
-/***/
diff -Naurp linux-2.6.24/arch/m68knommu/platform/coldfire/vectors.c 
linux-2.6.24.1/arch/m68knommu/platform/coldfire/vectors.c
--- linux-2.6.24/arch/m68knommu/platform/coldfire/vectors.c 1970-01-01 
10:00:00.0 +1000
+++ linux-2.6.24.1/arch/m68knommu/platform/coldfire/vectors.c   2008-01-25 
08:58:37.0 +1000
@@ -0,0 +1,105 @@
+/***/
+
+/*
+ * linux/arch/m68knommu/platform/5307/vectors.c
+ *
+ * Copyright (C) 1999-2007, Greg Ungerer <[EMAIL PROTECTED]>
+ */
+
+/***/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/***/
+
+#ifdef TRAP_DBG_INTERRUPT
+
+asmlinkage void dbginterrupt_c(struct frame *fp)
+{
+   extern void dump(struct pt_regs *fp);
+   printk(KERN_DEBUG "%s(%d): BUS ERROR TRAP\n", __FILE__, __LINE__);
+   dump((struct pt_regs *) fp);
+   asm("halt");
+}
+
+#endif
+
+/***/
+
+extern e_vector*_ramvec;
+
+void set_evector(int vecnum, void (*handler)(void))
+{
+   if (vecnum >= 0 && vecnum <= 255)
+   _ramvec[vecnum] = handler;
+}
+
+/***/
+
+/* Assembler routines */
+asmlinkage void buserr(void);

[M68KNOMMU]: use IRQF_DISABLE in m68328serial.c

2008-01-31 Thread Greg Ungerer
Use IRQF_DISABLED instead of obsolete IRQ_FLG_STD for request_irq() flags
in m68328serial.c driver.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/drivers/serial/68328serial.c 
linux-2.6.24-uc0/drivers/serial/68328serial.c
--- linux-2.6.24/drivers/serial/68328serial.c   2008-01-25 08:58:37.0 
+1000
+++ linux-2.6.24-uc0/drivers/serial/68328serial.c   2008-01-11 
20:34:32.0 +1000
@@ -1410,7 +1410,7 @@ rs68328_init(void)
 
if (request_irq(uart_irqs[i],
rs_interrupt,
-   IRQ_FLG_STD,
+   IRQF_DISABLED,
"M68328_UART", NULL))
 panic("Unable to attach 68328 serial interrupt\n");
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 02/06]: move ColdFire head.S to its own coldfire directory

2008-01-31 Thread Greg Ungerer
Move common ColdFire CPU head.S to common coldfire platform directory.

Currently the common ColdFire CPU family code sits in the
arch/m68knommu/platform/5307 directory. This is confusing, the files
containing this common code are in no way specific to the 5307 ColdFire.
Create an arch/m68knommu/platform/coldfire directory to contain this
common code. Other m68knommu CPU varients do not need use this code
though, so it doesn't make sense to move it to arch/m68knommu/kernel.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5307/head.S 
linux-2.6.24.1/arch/m68knommu/platform/5307/head.S
--- linux-2.6.24/arch/m68knommu/platform/5307/head.S2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24.1/arch/m68knommu/platform/5307/head.S  1970-01-01 
10:00:00.0 +1000
@@ -1,222 +0,0 @@
-/*/
-
-/*
- * head.S -- common startup code for ColdFire CPUs.
- *
- * (C) Copyright 1999-2006, Greg Ungerer <[EMAIL PROTECTED]>.
- */
-
-/*/
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/*/
-
-/*
- * If we don't have a fixed memory size, then lets build in code
- * to auto detect the DRAM size. Obviously this is the prefered
- * method, and should work for most boards. It won't work for those
- * that do not have their RAM starting at address 0, and it only
- * works on SDRAM (not boards fitted with SRAM).
- */
-#if CONFIG_RAMSIZE != 0
-.macro GET_MEM_SIZE
-   movel   #CONFIG_RAMSIZE,%d0 /* hard coded memory size */
-.endm
-
-#elif defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
-  defined(CONFIG_M5249) || defined(CONFIG_M527x) || \
-  defined(CONFIG_M528x) || defined(CONFIG_M5307) || \
-  defined(CONFIG_M5407)
-/*
- * Not all these devices have exactly the same DRAM controller,
- * but the DCMR register is virtually identical - give or take
- * a couple of bits. The only exception is the 5272 devices, their
- * DRAM controller is quite different.
- */
-.macro GET_MEM_SIZE
-   movel   MCF_MBAR+MCFSIM_DMR0,%d0 /* get mask for 1st bank */
-   btst#0,%d0  /* check if region enabled */
-   beq 1f
-   andl#0xfffc,%d0
-   beq 1f
-   addl#0x0004,%d0 /* convert mask to size */
-1:
-   movel   MCF_MBAR+MCFSIM_DMR1,%d1 /* get mask for 2nd bank */
-   btst#0,%d1  /* check if region enabled */
-   beq 2f
-   andl#0xfffc, %d1
-   beq 2f
-   addl#0x0004,%d1
-   addl%d1,%d0 /* total mem size in d0 */
-2:
-.endm
-
-#elif defined(CONFIG_M5272)
-.macro GET_MEM_SIZE
-   movel   MCF_MBAR+MCFSIM_CSOR7,%d0 /* get SDRAM address mask */
-   andil   #0xf000,%d0 /* mask out chip select options */
-   negl%d0 /* negate bits */
-.endm
-
-#elif defined(CONFIG_M520x)
-.macro GET_MEM_SIZE
-   clrl%d0
-   movel   MCF_MBAR+MCFSIM_SDCS0, %d2 /* Get SDRAM chip select 0 config */
-   andl#0x1f, %d2  /* Get only the chip select size */
-   beq 3f  /* Check if it is enabled */
-   addql   #1, %d2 /* Form exponent */
-   moveql  #1, %d0
-   lsll%d2, %d0/* 2 ^ exponent */
-3:
-   movel   MCF_MBAR+MCFSIM_SDCS1, %d2 /* Get SDRAM chip select 1 config */
-   andl#0x1f, %d2  /* Get only the chip select size */
-   beq 4f  /* Check if it is enabled */
-   addql   #1, %d2 /* Form exponent */
-   moveql  #1, %d1
-   lsll%d2, %d1/* 2 ^ exponent */
-   addl%d1, %d0/* Total size of SDRAM in d0 */
-4:
-.endm
-
-#else
-#error "ERROR: I don't know how to probe your boards memory size?"
-#endif
-
-/*/
-
-/*
- * Boards and platforms can do specific early hardware setup if
- * they need to. Most don't need this, define away if not required.
- */
-#ifndef PLATFORM_SETUP
-#definePLATFORM_SETUP
-#endif
-
-/*/
-
-.global_start
-.global _rambase
-.global _ramvec
-.global_ramstart
-.global_ramend
-
-/*/
-
-.data
-
-/*
- * During startup we store away the RAM setup. These are not in the
- * bss, since their values are determined and written before the bss
- * has been cleared.
- */
-_rambase:
-.long  0
-_ramvec:
-.long  0
-_ramstart:
-.long  0
-_ramend:
-.long  0
-

[M68KNOMMU]: create common DMA table for ColdFire CPUs

2008-01-31 Thread Greg Ungerer
Move the ColdFire DMA address table into its own file, and out
of each of the different CPU config files. No need to have a copy
of it in each of the config setup files.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/coldfire/dma.c 
linux-2.6.24-uc0/arch/m68knommu/platform/coldfire/dma.c
--- linux-2.6.24/arch/m68knommu/platform/coldfire/dma.c 1970-01-01 
10:00:00.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/coldfire/dma.c 2008-01-11 
21:02:34.0 +1000
@@ -0,0 +1,39 @@
+/***/
+
+/*
+ * dma.c -- Freescale ColdFire DMA support
+ *
+ * Copyright (C) 2007, Greg Ungerer ([EMAIL PROTECTED])
+ */
+
+/***/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/***/
+
+/*
+ *  DMA channel base address table.
+ */
+unsigned int dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
+#ifdef MCFDMA_BASE0
+   MCF_MBAR + MCFDMA_BASE0,
+#endif
+#ifdef MCFDMA_BASE1
+   MCF_MBAR + MCFDMA_BASE1,
+#endif
+#ifdef MCFDMA_BASE2
+   MCF_MBAR + MCFDMA_BASE2,
+#endif
+#ifdef MCFDMA_BASE3
+   MCF_MBAR + MCFDMA_BASE3,
+#endif
+};
+
+unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+
+/***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 03/06]: move ColdFire pit.c to its own coldfire directory

2008-01-31 Thread Greg Ungerer
Move common ColdFire CPU pit.c to common coldfire platform directory.

Currently the common ColdFire CPU family code sits in the
arch/m68knommu/platform/5307 directory. This is confusing, the files
containing this common code are in no way specific to the 5307 ColdFire.
Create an arch/m68knommu/platform/coldfire directory to contain this
common code. Other m68knommu CPU varients do not need use this code
though, so it doesn't make sense to move it to arch/m68knommu/kernel.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5307/pit.c 
linux-2.6.24.1/arch/m68knommu/platform/5307/pit.c
--- linux-2.6.24/arch/m68knommu/platform/5307/pit.c 2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24.1/arch/m68knommu/platform/5307/pit.c   1970-01-01 
10:00:00.0 +1000
@@ -1,97 +0,0 @@
-/***/
-
-/*
- * pit.c -- Freescale ColdFire PIT timer. Currently this type of
- *  hardware timer only exists in the Freescale ColdFire
- *  5270/5271, 5282 and other CPUs.
- *
- * Copyright (C) 1999-2007, Greg Ungerer ([EMAIL PROTECTED])
- * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com)
- */
-
-/***/
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/***/
-
-/*
- * By default use timer1 as the system clock timer.
- */
-#defineTA(a)   (MCF_IPSBAR + MCFPIT_BASE1 + (a))
-
-/***/
-
-static irqreturn_t hw_tick(int irq, void *dummy)
-{
-   unsigned short pcsr;
-
-   /* Reset the ColdFire timer */
-   pcsr = __raw_readw(TA(MCFPIT_PCSR));
-   __raw_writew(pcsr | MCFPIT_PCSR_PIF, TA(MCFPIT_PCSR));
-
-   return arch_timer_interrupt(irq, dummy);
-}
-
-/***/
-
-static struct irqaction coldfire_pit_irq = {
-   .name= "timer",
-   .flags   = IRQF_DISABLED | IRQF_TIMER,
-   .handler = hw_tick,
-};
-
-void hw_timer_init(void)
-{
-   volatile unsigned char *icrp;
-   volatile unsigned long *imrp;
-
-   setup_irq(MCFINT_VECBASE + MCFINT_PIT1, _pit_irq);
-
-   icrp = (volatile unsigned char *) (MCF_IPSBAR + MCFICM_INTC0 +
-   MCFINTC_ICR0 + MCFINT_PIT1);
-   *icrp = ICR_INTRCONF;
-
-   imrp = (volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + 
MCFPIT_IMR);
-   *imrp &= ~MCFPIT_IMR_IBIT;
-
-   /* Set up PIT timer 1 as poll clock */
-   __raw_writew(MCFPIT_PCSR_DISABLE, TA(MCFPIT_PCSR));
-   __raw_writew(((MCF_CLK / 2) / 64) / HZ, TA(MCFPIT_PMR));
-   __raw_writew(MCFPIT_PCSR_EN | MCFPIT_PCSR_PIE | MCFPIT_PCSR_OVW |
-   MCFPIT_PCSR_RLD | MCFPIT_PCSR_CLK64, TA(MCFPIT_PCSR));
-}
-
-/***/
-
-unsigned long hw_timer_offset(void)
-{
-   volatile unsigned long *ipr;
-   unsigned long pmr, pcntr, offset;
-
-   ipr = (volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + 
MCFPIT_IMR);
-
-   pmr = __raw_readw(TA(MCFPIT_PMR));
-   pcntr = __raw_readw(TA(MCFPIT_PCNTR));
-
-   /*
-* If we are still in the first half of the upcount and a
-* timer interrupt is pending, then add on a ticks worth of time.
-*/
-   offset = ((pmr - pcntr) * (100 / HZ)) / pmr;
-   if ((offset < (100 / HZ / 2)) && (*ipr & MCFPIT_IMR_IBIT))
-   offset += 100 / HZ;
-   return offset;  
-}
-
-/***/
diff -Naurp linux-2.6.24/arch/m68knommu/platform/coldfire/pit.c 
linux-2.6.24.1/arch/m68knommu/platform/coldfire/pit.c
--- linux-2.6.24/arch/m68knommu/platform/coldfire/pit.c 1970-01-01 
10:00:00.0 +1000
+++ linux-2.6.24.1/arch/m68knommu/platform/coldfire/pit.c   2008-01-25 
08:58:37.0 +1000
@@ -0,0 +1,97 @@
+/***/
+
+/*
+ * pit.c -- Freescale ColdFire PIT timer. Currently this type of
+ *  hardware timer only exists in the Freescale ColdFire
+ *  5270/5271, 5282 and other CPUs.
+ *
+ * Copyright (C) 1999-2007, Greg Ungerer ([EMAIL PROTECTED])
+ * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com)
+ */
+
+/***/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/***/
+
+/*
+ * By default use timer1 as the system clock timer.
+ */
+#defineTA(a)   (MCF_IPSBAR + 

[M68KNOMMU 04/06]: move ColdFire timers.c to its own coldfire directory

2008-01-31 Thread Greg Ungerer
Move common ColdFire CPU timers.c to common coldfire platform directory.

Currently the common ColdFire CPU family code sits in the
arch/m68knommu/platform/5307 directory. This is confusing, the files
containing this common code are in no way specific to the 5307 ColdFire.
Create an arch/m68knommu/platform/coldfire directory to contain this
common code. Other m68knommu CPU varients do not need use this code
though, so it doesn't make sense to move it to arch/m68knommu/kernel.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5307/timers.c 
linux-2.6.24.1/arch/m68knommu/platform/5307/timers.c
--- linux-2.6.24/arch/m68knommu/platform/5307/timers.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24.1/arch/m68knommu/platform/5307/timers.c1970-01-01 
10:00:00.0 +1000
@@ -1,155 +0,0 @@
-/***/
-
-/*
- * timers.c -- generic ColdFire hardware timer support.
- *
- * Copyright (C) 1999-2007, Greg Ungerer ([EMAIL PROTECTED])
- */
-
-/***/
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/***/
-
-/*
- * By default use timer1 as the system clock timer.
- */
-#defineTA(a)   (MCF_MBAR + MCFTIMER_BASE1 + (a))
-
-/*
- * Default the timer and vector to use for ColdFire. Some ColdFire
- * CPU's and some boards may want different. Their sub-architecture
- * startup code (in config.c) can change these if they want.
- */
-unsigned int   mcf_timervector = 29;
-unsigned int   mcf_profilevector = 31;
-unsigned int   mcf_timerlevel = 5;
-
-/*
- * These provide the underlying interrupt vector support.
- * Unfortunately it is a little different on each ColdFire.
- */
-extern void mcf_settimericr(int timer, int level);
-extern int mcf_timerirqpending(int timer);
-
-#if defined(CONFIG_M532x)
-#define__raw_readtrr   __raw_readl
-#define__raw_writetrr  __raw_writel
-#else
-#define__raw_readtrr   __raw_readw
-#define__raw_writetrr  __raw_writew
-#endif
-
-/***/
-
-static irqreturn_t hw_tick(int irq, void *dummy)
-{
-   /* Reset the ColdFire timer */
-   __raw_writeb(MCFTIMER_TER_CAP | MCFTIMER_TER_REF, TA(MCFTIMER_TER));
-
-   return arch_timer_interrupt(irq, dummy);
-}
-
-/***/
-
-static struct irqaction coldfire_timer_irq = {
-   .name= "timer",
-   .flags   = IRQF_DISABLED | IRQF_TIMER,
-   .handler = hw_tick,
-};
-
-/***/
-
-static int ticks_per_intr;
-
-void hw_timer_init(void)
-{
-   setup_irq(mcf_timervector, _timer_irq);
-
-   __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR));
-   ticks_per_intr = (MCF_BUSCLK / 16) / HZ;
-   __raw_writetrr(ticks_per_intr - 1, TA(MCFTIMER_TRR));
-   __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 |
-   MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR));
-
-   mcf_settimericr(1, mcf_timerlevel);
-
-#ifdef CONFIG_HIGHPROFILE
-   coldfire_profile_init();
-#endif
-}
-
-/***/
-
-unsigned long hw_timer_offset(void)
-{
-   unsigned long tcn, offset;
-
-   tcn = __raw_readw(TA(MCFTIMER_TCN));
-   offset = ((tcn + 1) * (100 / HZ)) / ticks_per_intr;
-
-   /* Check if we just wrapped the counters and maybe missed a tick */
-   if ((offset < (100 / HZ / 2)) && mcf_timerirqpending(1))
-   offset += 100 / HZ;
-   return offset;
-}
-
-/***/
-#ifdef CONFIG_HIGHPROFILE
-/***/
-
-/*
- * By default use timer2 as the profiler clock timer.
- */
-#definePA(a)   (MCF_MBAR + MCFTIMER_BASE2 + (a))
-
-/*
- * Choose a reasonably fast profile timer. Make it an odd value to
- * try and get good coverage of kernel operations.
- */
-#definePROFILEHZ   1013
-
-/*
- * Use the other timer to provide high accuracy profiling info.
- */
-irqreturn_t coldfire_profile_tick(int irq, void *dummy)
-{
-   /* Reset ColdFire timer2 */
-   __raw_writeb(MCFTIMER_TER_CAP | MCFTIMER_TER_REF, PA(MCFTIMER_TER));
-   if (current->pid)
-   profile_tick(CPU_PROFILING, regs);
-   return IRQ_HANDLED;
-}
-
-/***/
-
-void coldfire_profile_init(void)
-{
-   printk(KERN_INFO "PROFILE: lodging TIMER2 @ %dHz as profile timer\n", 

[M68KNOMMU 00/06]: move common ColdFire code to its own directory

2008-01-31 Thread Greg Ungerer
Move common ColdFire CPU code into its own platform directory.

Currently the common ColdFire CPU family code sits in the
arch/m68knommu/platform/5307 directory. This is confusing, the files
containing this common code are in no way specific to the 5307 ColdFire.
Create an arch/m68knommu/platform/coldfire directory to contain this
common code. Other m68knommu CPU varients do not need use this code
though, so it doesn't make sense to move it to arch/m68knommu/kernel.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]


 Makefile|   22 ++--
 platform/5307/Makefile  |   14 --
 platform/5307/entry.S   |  235 
 platform/5307/head.S|  222 
-
 platform/5307/pit.c |   97 --
 platform/5307/timers.c  |  155 -
 platform/5307/vectors.c |  105 ---
 platform/coldfire/Makefile  |   32 +
 platform/coldfire/dma.c |   39 +++
 platform/coldfire/entry.S   |  235 
 platform/coldfire/head.S|  222 
+
 platform/coldfire/pit.c |   97 ++
 platform/coldfire/timers.c  |  155 +
 platform/coldfire/vectors.c |  105 +++
 14 files changed, 897 insertions(+), 838 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU 01/06]: move ColdFire entry.S to its own coldfire directory

2008-01-31 Thread Greg Ungerer
Move common ColdFire CPU entry.S to common coldfire platform directory.

Currently the common ColdFire CPU family code sits in the
arch/m68knommu/platform/5307 directory. This is confusing, the files
containing this common code are in no way specific to the 5307 ColdFire.
Create an arch/m68knommu/platform/coldfire directory to contain this
common code. Other m68knommu CPU varients do not need use this code
though, so it doesn't make sense to move it to arch/m68knommu/kernel.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5307/entry.S 
linux-2.6.24.1/arch/m68knommu/platform/5307/entry.S
--- linux-2.6.24/arch/m68knommu/platform/5307/entry.S   2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24.1/arch/m68knommu/platform/5307/entry.S 1970-01-01 
10:00:00.0 +1000
@@ -1,235 +0,0 @@
-/*
- *  linux/arch/m68knommu/platform/5307/entry.S
- *
- *  Copyright (C) 1999-2007, Greg Ungerer ([EMAIL PROTECTED])
- *  Copyright (C) 1998  D. Jeff Dionne <[EMAIL PROTECTED]>,
- *  Kenneth Albanowski <[EMAIL PROTECTED]>,
- *  Copyright (C) 2000  Lineo Inc. (www.lineo.com)
- *  Copyright (C) 2004-2006  Macq Electronique SA. (www.macqel.com)
- *
- * Based on:
- *
- *  linux/arch/m68k/kernel/entry.S
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file README.legal in the main directory of this archive
- * for more details.
- *
- * Linux/m68k support by Hamish Macdonald
- *
- * 68060 fixes by Jesper Skov
- * ColdFire support by Greg Ungerer ([EMAIL PROTECTED])
- * 5307 fixes by David W. Miller
- * linux 2.4 support David McCullough <[EMAIL PROTECTED]>
- * Bug, speed and maintainability fixes by Philippe De Muyter <[EMAIL 
PROTECTED]>
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-.bss
-
-sw_ksp:
-.long  0
-
-sw_usp:
-.long  0
-
-.text
-
-.globl system_call
-.globl resume
-.globl ret_from_exception
-.globl ret_from_signal
-.globl sys_call_table
-.globl ret_from_interrupt
-.globl inthandler
-.globl fasthandler
-
-enosys:
-   mov.l   #sys_ni_syscall,%d3
-   bra 1f
-
-ENTRY(system_call)
-   SAVE_ALL
-   move#0x2000,%sr /* enable intrs again */
-
-   cmpl#NR_syscalls,%d0
-   jcc enosys
-   lea sys_call_table,%a0
-   lsll#2,%d0  /* movel %a0@(%d0:l:4),%d3 */
-   movel   %a0@(%d0),%d3
-   jeq enosys
-
-1:
-   movel   %sp,%d2 /* get thread_info pointer */
-   andl#-THREAD_SIZE,%d2   /* at start of kernel stack */
-   movel   %d2,%a0
-   movel   %a0@,%a1/* save top of frame */
-   movel   %sp,%a1@(TASK_THREAD+THREAD_ESP0)
-   btst#(TIF_SYSCALL_TRACE%8),%a0@(TI_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
-   bnes1f
-
-   movel   %d3,%a0
-   jbsr%a0@
-   movel   %d0,%sp@(PT_D0) /* save the return value */
-   jra ret_from_exception
-1:
-   movel   #-ENOSYS,%d2/* strace needs -ENOSYS in PT_D0 */
-   movel   %d2,PT_D0(%sp)  /* on syscall entry */
-   subql   #4,%sp
-   SAVE_SWITCH_STACK
-   jbsrsyscall_trace
-   RESTORE_SWITCH_STACK
-   addql   #4,%sp
-   movel   %d3,%a0
-   jbsr%a0@
-   movel   %d0,%sp@(PT_D0) /* save the return value */
-   subql   #4,%sp  /* dummy return address */
-   SAVE_SWITCH_STACK
-   jbsrsyscall_trace
-
-ret_from_signal:
-   RESTORE_SWITCH_STACK
-   addql   #4,%sp
-
-ret_from_exception:
-   btst#5,%sp@(PT_SR)  /* check if returning to kernel */
-   jeq Luser_return/* if so, skip resched, signals */
-
-Lkernel_return:
-   moveml  %sp@,%d1-%d5/%a0-%a2
-   lea %sp@(32),%sp/* space for 8 regs */
-   movel   [EMAIL PROTECTED],%d0
-   addql   #4,%sp  /* orig d0 */
-   addl[EMAIL PROTECTED],%sp   /* stk adj */
-   rte
-
-Luser_return:
-   movel   %sp,%d1 /* get thread_info pointer */
-   andl#-THREAD_SIZE,%d1   /* at base of kernel stack */
-   movel   %d1,%a0
-   movel   %a0@(TI_FLAGS),%d1  /* get thread_info->flags */
-   andl#_TIF_WORK_MASK,%d1
-   jne Lwork_to_do /* still work to do */
-
-Lreturn:
-   move#0x2700,%sr /* disable intrs */
-   movel   sw_usp,%a0  /* get usp */
-   movel   %sp@(PT_PC),[EMAIL PROTECTED]   /* copy exception program 
counter */
-   movel   %sp@(PT_FORMATVEC),[EMAIL PROTECTED]/* copy exception 
format/vector/sr */
-   moveml  %sp@,%d1-%d5/%a0-%a2
-   lea %sp@(32),%sp/* space for 8 regs */
-   movel   [EMAIL PROTECTED],%d0
-   addql   #4,%sp  /* orig d0 */
-   addl[EMAIL 

[M68KNOMMU]: platform setup for 528x ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 528x ColdFire parts.
Initial support is for the UARTs. DMA support moved to common code
for all ColdFire parts.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/528x/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/528x/config.c
--- linux-2.6.24/arch/m68knommu/platform/528x/config.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/528x/config.c  2007-11-30 
11:03:11.0 +1000
@@ -16,11 +16,15 @@
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
 
 /***/
 
@@ -28,14 +32,67 @@ void coldfire_reset(void);
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
-MCF_MBAR + MCFDMA_BASE0,
+static struct mcf_platform_uart m528x_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= MCFINT_VECBASE + MCFINT_UART0,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= MCFINT_VECBASE + MCFINT_UART0 + 1,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE3,
+   .irq= MCFINT_VECBASE + MCFINT_UART0 + 2,
+   },
+   { },
 };
 
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+static struct platform_device m528x_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m528x_uart_platform,
+};
+
+static struct platform_device *m528x_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+#defineINTC0   (MCF_MBAR + MCFICM_INTC0)
+
+static void __init m528x_uart_init_line(int line, int irq)
+{
+   u8 port;
+   u32 imr;
+
+   if ((line < 0) || (line > 2))
+   return;
+
+   /* level 6, line based priority */
+   writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
+
+   imr = readl(INTC0 + MCFINTC_IMRL);
+   imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
+   writel(imr, INTC0 + MCFINTC_IMRL);
+
+   /* make sure PUAPAR is set for UART0 and UART1 */
+   if (line < 2) {
+   port = readb(MCF_MBAR + MCF5282_GPIO_PUAPAR);
+   port |= (0x03 << (line * 2));
+   writeb(port, MCF_MBAR + MCF5282_GPIO_PUAPAR);
+   }
+}
+
+static void __init m528x_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m528x_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m528x_uart_init_line(line, m528x_uart_platform[line].irq);
+}
 
 /***/
 
@@ -54,10 +111,21 @@ void mcf_autovector(unsigned int vec)
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
mcf_disableall();
mach_reset = coldfire_reset;
 }
 
 /***/
+
+static int __init init_BSP(void)
+{
+   m528x_uarts_init();
+   platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices));
+   return 0;
+}
+
+arch_initcall(init_BSP);
+
+/***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: platform setup for 527x ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 527x ColdFire parts.
Initial support is for the UARTs. DMA support moved to common code
for all ColdFire parts.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/527x/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/527x/config.c
--- linux-2.6.24/arch/m68knommu/platform/527x/config.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/527x/config.c  2007-11-30 
11:03:11.0 +1000
@@ -16,11 +16,11 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /***/
 
@@ -28,14 +28,72 @@ void coldfire_reset(void);
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
-MCF_MBAR + MCFDMA_BASE0,
+static struct mcf_platform_uart m527x_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= MCFINT_VECBASE + MCFINT_UART0,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= MCFINT_VECBASE + MCFINT_UART1,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE3,
+   .irq= MCFINT_VECBASE + MCFINT_UART2,
+   },
+   { },
 };
 
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+static struct platform_device m527x_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m527x_uart_platform,
+};
+
+static struct platform_device *m527x_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+#defineINTC0   (MCF_MBAR + MCFICM_INTC0)
+
+static void __init m527x_uart_init_line(int line, int irq)
+{
+   u16 sepmask;
+   u32 imr;
+
+   if ((line < 0) || (line > 2))
+   return;
+
+   /* level 6, line based priority */
+   writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
+
+   imr = readl(INTC0 + MCFINTC_IMRL);
+   imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
+   writel(imr, INTC0 + MCFINTC_IMRL);
+
+   /*
+* External Pin Mask Setting & Enable External Pin for Interface
+*/
+   sepmask = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
+   if (line == 0)
+   sepmask |= UART0_ENABLE_MASK;
+   else if (line == 1)
+   sepmask |= UART1_ENABLE_MASK;
+   else if (line == 2)
+   sepmask |= UART2_ENABLE_MASK;
+   writew(sepmask, MCF_IPSBAR + MCF_GPIO_PAR_UART);
+}
+
+static void __init m527x_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m527x_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m527x_uart_init_line(line, m527x_uart_platform[line].irq);
+}
 
 /***/
 
@@ -54,10 +112,21 @@ void mcf_autovector(unsigned int vec)
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
mcf_disableall();
mach_reset = coldfire_reset;
 }
 
 /***/
+
+static int __init init_BSP(void)
+{
+   m527x_uarts_init();
+   platform_add_devices(m527x_devices, ARRAY_SIZE(m527x_devices));
+   return 0;
+}
+
+arch_initcall(init_BSP);
+
+/***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2.6.24] Add new string functions strict_strto* and convert kernel params to use them, take 2

2008-01-31 Thread Andrew Morton
On Fri, 01 Feb 2008 06:11:43 +0800 Yi Yang <[EMAIL PROTECTED]> wrote:

> This patch is a resend, it changes previous name "real_" to "strict_" 
> according to Randy Dunlap's feedback. Please consider to apply. thanks.
> 
> Currently, for every sysfs node, the callers will be responsible for
> implementing store operation, so many many callers are doing duplicate
> things to validate input, they have the same mistakes because they are
> calling simple_strtol/ul/ll/uul, especially for module params, they are
> just numeric, but you can echo such values as 0x1234xxx, 0888 and
> 1234aaa, for these cases, module params store operation just ignores
> succesive invalid char and converts prefix part to a numeric although
> input is acctually invalid.
> 
> This patch tries to fix the aforementioned issues and implements strict_strtox
> serial functions, kernel/params.c uses them to strictly validate input,
> so module params will reject such values as 0x1234 and returns an error:
> 
> write error: Invalid argument
> 
> Any modules which export numeric sysfs node can use strict_strtox instead of
> simple_strtox to reject any invalid input.
> 
> Here are some test results:
> 
> Before applying this patch:
> 
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]# echo 0x1000 > /sys/module/e1000/parameters/copybreak
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]# echo 0x1000g > /sys/module/e1000/parameters/copybreak
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]# echo 0x1000 > 
> /sys/module/e1000/parameters/copybreak
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]# echo 01 > /sys/module/e1000/parameters/copybreak
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]# echo 018 > /sys/module/e1000/parameters/copybreak
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]# echo 01a > 
> /sys/module/e1000/parameters/copybreak
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]#
> 
> 
> After applying this patch:
> 
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]# echo 0x1000 > /sys/module/e1000/parameters/copybreak
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]# echo 0x1000g > /sys/module/e1000/parameters/copybreak
> -bash: echo: write error: Invalid argument
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]# echo 0x1000 > 
> /sys/module/e1000/parameters/copybreak
> -bash: echo: write error: Invalid argument
> [EMAIL PROTECTED] /]# echo 01 > /sys/module/e1000/parameters/copybreak
> [EMAIL PROTECTED] /]# echo 018 > /sys/module/e1000/parameters/copybreak
> -bash: echo: write error: Invalid argument
> [EMAIL PROTECTED] /]# echo 01a > 
> /sys/module/e1000/parameters/copybreak
> -bash: echo: write error: Invalid argument
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]# echo -n 4096 > /sys/module/e1000/parameters/copybreak
> [EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
> 4096
> [EMAIL PROTECTED] /]#
> 

Oh dear.  So if someone has an existing script which does

echo 0x1000g > /sys/module/e1000/parameters/copybreak

we just broke their setup.

This is what happens when we screw up kernel interfaces: we should remain
bug-for-bug compatible with earlier releases.  argh, we suck :(

I'm inclined to merge it anyway - everyone already knows we suck, and
not many people will be affected and they suck too.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: platform setup for 5307 ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 5307 ColdFire parts.
Initial support is for the UARTs. DMA support moved to common code
for all ColdFire parts.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5307/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/5307/config.c
--- linux-2.6.24/arch/m68knommu/platform/5307/config.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/5307/config.c  2008-01-11 
13:37:38.0 +1000
@@ -13,11 +13,11 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 /***/
@@ -38,17 +38,51 @@ unsigned char ledbank = 0xff;
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
-MCF_MBAR + MCFDMA_BASE0,
-MCF_MBAR + MCFDMA_BASE1,
-MCF_MBAR + MCFDMA_BASE2,
-MCF_MBAR + MCFDMA_BASE3,
+static struct mcf_platform_uart m5307_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= 73,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= 74,
+   },
+   { },
+};
+
+static struct platform_device m5307_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m5307_uart_platform,
 };
 
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+static struct platform_device *m5307_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+static void __init m5307_uart_init_line(int line, int irq)
+{
+   if (line == 0) {
+   writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + 
MCFSIM_UART1ICR);
+   writeb(irq, MCFUART_BASE1 + MCFUART_UIVR);
+   mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
+   } else if (line == 1) {
+   writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + 
MCFSIM_UART2ICR);
+   writeb(irq, MCFUART_BASE2 + MCFUART_UIVR);
+   mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
+   }
+}
+
+static void __init m5307_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m5307_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m5307_uart_init_line(line, m5307_uart_platform[line].irq);
+}
 
 /***/
 
@@ -99,7 +133,7 @@ int mcf_timerirqpending(int timer)
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
mcf_setimr(MCFSIM_IMR_MASKALL);
 
@@ -117,7 +151,7 @@ void config_BSP(char *commandp, int size
 
mach_reset = coldfire_reset;
 
-#ifdef MCF_BDM_DISABLE
+#ifdef CONFIG_BDM_DISABLE
/*
 * Disable the BDM clocking.  This also turns off most of the rest of
 * the BDM device.  This is good for EMC reasons. This option is not
@@ -128,3 +162,14 @@ void config_BSP(char *commandp, int size
 }
 
 /***/
+
+static int __init init_BSP(void)
+{
+   m5307_uarts_init();
+   platform_add_devices(m5307_devices, ARRAY_SIZE(m5307_devices));
+   return 0;
+}
+
+arch_initcall(init_BSP);
+
+/***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: platform setup for 5407 ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 5407 ColdFire parts.
Initial support is for the UARTs. DMA support moved to common code
for all ColdFire parts.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5407/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/5407/config.c
--- linux-2.6.24/arch/m68knommu/platform/5407/config.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/5407/config.c  2008-01-11 
13:37:39.0 +1000
@@ -13,11 +13,11 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /***/
 
@@ -29,17 +29,51 @@ extern unsigned int mcf_timerlevel;
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
-MCF_MBAR + MCFDMA_BASE0,
-MCF_MBAR + MCFDMA_BASE1,
-MCF_MBAR + MCFDMA_BASE2,
-MCF_MBAR + MCFDMA_BASE3,
+static struct mcf_platform_uart m5407_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= 73,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= 74,
+   },
+   { },
 };
 
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+static struct platform_device m5407_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m5407_uart_platform,
+};
+
+static struct platform_device *m5407_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+static void __init m5407_uart_init_line(int line, int irq)
+{
+   if (line == 0) {
+   writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + 
MCFSIM_UART1ICR);
+   writeb(irq, MCFUART_BASE1 + MCFUART_UIVR);
+   mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
+   } else if (line == 1) {
+   writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + 
MCFSIM_UART2ICR);
+   writeb(irq, MCFUART_BASE2 + MCFUART_UIVR);
+   mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
+   }
+}
+
+static void __init m5407_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m5407_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m5407_uart_init_line(line, m5407_uart_platform[line].irq);
+}
 
 /***/
 
@@ -90,7 +124,7 @@ int mcf_timerirqpending(int timer)
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
mcf_setimr(MCFSIM_IMR_MASKALL);
 
@@ -105,3 +139,14 @@ void config_BSP(char *commandp, int size
 }
 
 /***/
+
+static int __init init_BSP(void)
+{
+   m5407_uarts_init();
+   platform_add_devices(m5407_devices, ARRAY_SIZE(m5407_devices));
+   return 0;
+}
+
+arch_initcall(init_BSP);
+
+/***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: platform setup for 5249 ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 5249 ColdFire parts.
Initial support is for the UARTs. DMA support moved to common code
for all ColdFire parts.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5249/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/5249/config.c
--- linux-2.6.24/arch/m68knommu/platform/5249/config.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/5249/config.c  2008-01-11 
13:37:38.0 +1000
@@ -12,11 +12,11 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /***/
 
@@ -24,17 +24,51 @@ void coldfire_reset(void);
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
-MCF_MBAR + MCFDMA_BASE0,
-MCF_MBAR + MCFDMA_BASE1,
-MCF_MBAR + MCFDMA_BASE2,
-MCF_MBAR + MCFDMA_BASE3,
+static struct mcf_platform_uart m5249_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= 73,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= 74,
+   }
+};
+
+static struct platform_device m5249_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m5249_uart_platform,
 };
 
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+static struct platform_device *m5249_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+static void __init m5249_uart_init_line(int line, int irq)
+{
+   if (line == 0) {
+   writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + 
MCFSIM_UART1ICR);
+   writeb(irq, MCFUART_BASE1 + MCFUART_UIVR);
+   mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
+   } else if (line == 1) {
+   writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + 
MCFSIM_UART2ICR);
+   writeb(irq, MCFUART_BASE2 + MCFUART_UIVR);
+   mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
+   }
+}
+
+static void __init m5249_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m5249_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m5249_uart_init_line(line, m5249_uart_platform[line].irq);
+}
+
 
 /***/
 
@@ -85,10 +119,21 @@ int mcf_timerirqpending(int timer)
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
mcf_setimr(MCFSIM_IMR_MASKALL);
mach_reset = coldfire_reset;
 }
 
 /***/
+
+static int __init init_BSP(void)
+{
+   m5249_uarts_init();
+   platform_add_devices(m5249_devices, ARRAY_SIZE(m5249_devices));
+   return 0;
+}
+
+arch_initcall(init_BSP);
+
+/***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: platform setup for 532x ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 532x ColdFire parts.
Initial support is for the UARTs. DMA support moved to common code
for all ColdFire parts.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/532x/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/532x/config.c
--- linux-2.6.24/arch/m68knommu/platform/532x/config.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/532x/config.c  2008-01-11 
13:37:38.0 +1000
@@ -21,10 +21,11 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -38,11 +39,60 @@ extern unsigned int mcf_timerlevel;
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int dma_base_addr[MAX_M68K_DMA_CHANNELS] = { };
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+static struct mcf_platform_uart m532x_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= MCFINT_VECBASE + MCFINT_UART0,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= MCFINT_VECBASE + MCFINT_UART1,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE3,
+   .irq= MCFINT_VECBASE + MCFINT_UART2,
+   },
+   { },
+};
+
+static struct platform_device m532x_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m532x_uart_platform,
+};
+
+static struct platform_device *m532x_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+static void __init m532x_uart_init_line(int line, int irq)
+{
+   if (line == 0) {
+   MCF_INTC0_ICR26 = 0x3;
+   MCF_INTC0_CIMR = 26;
+   /* GPIO initialization */
+   MCF_GPIO_PAR_UART |= 0x000F;
+   } else if (line == 1) {
+   MCF_INTC0_ICR27 = 0x3;
+   MCF_INTC0_CIMR = 27;
+   /* GPIO initialization */
+   MCF_GPIO_PAR_UART |= 0x0FF0;
+   } else if (line == 2) {
+   MCF_INTC0_ICR28 = 0x3;
+   MCF_INTC0_CIMR = 28;
+   }
+}
+
+static void __init m532x_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m532x_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m532x_uart_init_line(line, m532x_uart_platform[line].irq);
+}
 
 /***/
 
@@ -80,7 +130,7 @@ int mcf_timerirqpending(int timer)
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
mcf_setimr(MCFSIM_IMR_MASKALL);
 
@@ -99,7 +149,7 @@ void config_BSP(char *commandp, int size
mcf_profilevector = 64+33;
mach_reset = coldfire_reset;
 
-#ifdef MCF_BDM_DISABLE
+#ifdef CONFIG_BDM_DISABLE
/*
 * Disable the BDM clocking.  This also turns off most of the rest of
 * the BDM device.  This is good for EMC reasons. This option is not
@@ -110,9 +160,19 @@ void config_BSP(char *commandp, int size
 }
 
 /***/
-/* Board initialization */
 
-//
+static int __init init_BSP(void)
+{
+   m532x_uarts_init();
+   platform_add_devices(m532x_devices, ARRAY_SIZE(m532x_devices));
+   return 0;
+}
+
+arch_initcall(init_BSP);
+
+/***/
+/* Board initialization */
+/***/
 /* 
  * PLL min/max specifications
  */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: platform setup for 5272 ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 5272 ColdFire parts.
Initial support is for the UARTs. DMA support moved to common code
for all ColdFire parts.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5272/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/5272/config.c
--- linux-2.6.24/arch/m68knommu/platform/5272/config.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/5272/config.c  2008-01-11 
13:37:38.0 +1000
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /***/
 
@@ -37,14 +37,57 @@ unsigned char ledbank = 0xff;
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
-MCF_MBAR + MCFDMA_BASE0,
+static struct mcf_platform_uart m5272_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= 73,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= 74,
+   },
+   { },
+};
+
+static struct platform_device m5272_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m5272_uart_platform,
 };
 
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+static struct platform_device *m5272_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+static void __init m5272_uart_init_line(int line, int irq)
+{
+   u32 v;
+
+   if ((line >= 0) && (line < 2)) {
+   v = (line) ? 0x0e00 : 0xe000;
+   writel(v, MCF_MBAR + MCFSIM_ICR2);
+
+   /* Enable the output lines for the serial ports */
+   v = readl(MCF_MBAR + MCFSIM_PBCNT);
+   v = (v & ~0x00ff) | 0x0055;
+   writel(v, MCF_MBAR + MCFSIM_PBCNT);
+
+   v = readl(MCF_MBAR + MCFSIM_PDCNT);
+   v = (v & ~0x03fc) | 0x02a8;
+   writel(v, MCF_MBAR + MCFSIM_PDCNT);
+   }
+}
+
+static void __init m5272_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m5272_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m5272_uart_init_line(line, m5272_uart_platform[line].irq);
+}
 
 /***/
 
@@ -93,7 +136,7 @@ int mcf_timerirqpending(int timer)
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
 #if defined (CONFIG_MOD5272)
volatile unsigned char  *pivrp;
@@ -125,3 +168,14 @@ void config_BSP(char *commandp, int size
 }
 
 /***/
+
+static int __init init_BSP(void)
+{
+   m5272_uarts_init();
+   platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices));
+   return 0;
+}
+
+arch_initcall(init_BSP);
+
+/***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: platform setup for 523x ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 523x ColdFire parts.
Initial support is for the UARTs. DMA support moved to common code
for all ColdFire parts.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/523x/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/523x/config.c
--- linux-2.6.24/arch/m68knommu/platform/523x/config.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/523x/config.c  2007-11-30 
11:03:11.0 +1000
@@ -16,11 +16,11 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /***/
 
@@ -28,14 +28,58 @@ void coldfire_reset(void);
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
-MCF_MBAR + MCFDMA_BASE0,
+static struct mcf_platform_uart m523x_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= MCFINT_VECBASE + MCFINT_UART0,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= MCFINT_VECBASE + MCFINT_UART0 + 1,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE3,
+   .irq= MCFINT_VECBASE + MCFINT_UART0 + 2,
+   },
+   { },
 };
 
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+static struct platform_device m523x_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m523x_uart_platform,
+};
+
+static struct platform_device *m523x_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+#defineINTC0   (MCF_MBAR + MCFICM_INTC0)
+
+static void __init m523x_uart_init_line(int line, int irq)
+{
+   u32 imr;
+
+   if ((line < 0) || (line > 2))
+   return;
+
+   writeb(0x30+line, (INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line));
+
+   imr = readl(INTC0 + MCFINTC_IMRL);
+   imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
+   writel(imr, INTC0 + MCFINTC_IMRL);
+}
+
+static void __init m523x_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m523x_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m523x_uart_init_line(line, m523x_uart_platform[line].irq);
+}
 
 /***/
 
@@ -49,15 +93,26 @@ void mcf_disableall(void)
 
 void mcf_autovector(unsigned int vec)
 {
-   /* Everything is auto-vectored on the 5272 */
+   /* Everything is auto-vectored on the 523x */
 }
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
mcf_disableall();
mach_reset = coldfire_reset;
+   m523x_uarts_init();
 }
 
 /***/
+
+static int __init init_BSP(void)
+{
+   platform_add_devices(m523x_devices, ARRAY_SIZE(m523x_devices));
+   return 0;
+}
+
+arch_initcall(init_BSP);
+
+/***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: platform setup for 5206e ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 5206e ColdFire parts.
Initial support is for the UARTs. DMA support is moved to common code.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5206e/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/5206e/config.c
--- linux-2.6.24/arch/m68knommu/platform/5206e/config.c 2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/5206e/config.c 2008-01-11 
13:37:38.0 +1000
@@ -10,8 +10,9 @@
 
 #include 
 #include 
+#include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -23,15 +24,51 @@ void coldfire_reset(void);
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
-MCF_MBAR + MCFDMA_BASE0,
-MCF_MBAR + MCFDMA_BASE1,
+static struct mcf_platform_uart m5206e_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= 73,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= 74,
+   },
+   { },
 };
 
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+static struct platform_device m5206e_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m5206e_uart_platform,
+};
+
+static struct platform_device *m5206e_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+static void __init m5206_uart_init_line(int line, int irq)
+{
+   if (line == 0) {
+   writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + 
MCFSIM_UART1ICR);
+   writeb(irq, MCFUART_BASE1 + MCFUART_UIVR);
+   mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
+   } else if (line == 1) {
+   writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + 
MCFSIM_UART2ICR);
+   writeb(irq, MCFUART_BASE2 + MCFUART_UIVR);
+   mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
+   }
+}
+
+static void __init m5206e_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m5206e_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m5206e_uart_init_line(line, m5206e_uart_platform[line].irq);
+}
 
 /***/
 
@@ -85,7 +122,7 @@ int mcf_timerirqpending(int timer)
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
mcf_setimr(MCFSIM_IMR_MASKALL);
 
@@ -99,3 +136,14 @@ void config_BSP(char *commandp, int size
 }
 
 /***/
+
+static int __init init_BSP(void)
+{
+   m5206e_uarts_init();
+   platform_add_devices(m5206e_devices, ARRAY_SIZE(m5206e_devices));
+   return 0;
+}
+
+arch_initcall(init_BSP);
+
+/***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: platform setup for 520x ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 520x ColdFire parts.
Initial support is for the UARTs. DMA support moved to common code
for all ColdFire parts.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/520x/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/520x/config.c
--- linux-2.6.24/arch/m68knommu/platform/520x/config.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/520x/config.c  2007-11-30 
11:03:11.0 +1000
@@ -5,7 +5,7 @@
  *
  *  Copyright (C) 2005,  Freescale (www.freescale.com)
  *  Copyright (C) 2005,  Intec Automation ([EMAIL PROTECTED])
- *  Copyright (C) 1999-2003, Greg Ungerer ([EMAIL PROTECTED])
+ *  Copyright (C) 1999-2007, Greg Ungerer ([EMAIL PROTECTED])
  *  Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
  */
 
@@ -13,21 +13,93 @@
 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
-#include 
+#include 
+#include 
+#include 
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int dma_base_addr[MAX_M68K_DMA_CHANNELS];
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+void coldfire_reset(void);
 
 /***/
 
-void coldfire_reset(void);
+static struct mcf_platform_uart m520x_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= MCFINT_VECBASE + MCFINT_UART0,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= MCFINT_VECBASE + MCFINT_UART1,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE3,
+   .irq= MCFINT_VECBASE + MCFINT_UART2,
+   },
+   { },
+};
+
+static struct platform_device m520x_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m520x_uart_platform,
+};
+
+static struct platform_device *m520x_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+#defineINTC0   (MCF_MBAR + MCFICM_INTC0)
+
+static void __init m520x_uart_init_line(int line, int irq)
+{
+   u32 imr;
+   u16 par;
+   u8 par2;
+
+   writeb(0x03, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
+
+   imr = readl(INTC0 + MCFINTC_IMRL);
+   imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
+   writel(imr, INTC0 + MCFINTC_IMRL);
+
+   switch (line) {
+   case 0:
+   par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
+   par |= MCF_GPIO_PAR_UART_PAR_UTXD0 |
+  MCF_GPIO_PAR_UART_PAR_URXD0;
+   writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
+   break;
+   case 1:
+   par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
+   par |= MCF_GPIO_PAR_UART_PAR_UTXD1 |
+  MCF_GPIO_PAR_UART_PAR_URXD1;
+   writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
+   break;
+   case 2:
+   par2 = readb(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
+   par2 &= ~0x0F;
+   par2 |= MCF_GPIO_PAR_FECI2C_PAR_SCL_UTXD2 |
+   MCF_GPIO_PAR_FECI2C_PAR_SDA_URXD2;
+   writeb(par2, MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
+   break;
+   }
+}
+
+static void __init m520x_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m520x_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m520x_uart_init_line(line, m520x_uart_platform[line].irq);
+}
 
 /***/
 
@@ -42,9 +114,20 @@ void mcf_autovector(unsigned int vec)
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
mach_reset = coldfire_reset;
+   m520x_uarts_init();
+}
+
+/***/
+
+static int __init init_BSP(void)
+{
+   platform_add_devices(m520x_devices, ARRAY_SIZE(m520x_devices));
+   return 0;
 }
 
+arch_initcall(init_BSP);
+
 /***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: configure support for new ColdFire serial driver

2008-01-31 Thread Greg Ungerer
Add configure support for new ColdFire serial driver.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---

--- linux-2.6.24/drivers/serial/Kconfig 2008-01-25 08:58:37.0 +1000
+++ linux-2.6.24.1/drivers/serial/Kconfig   2008-01-30 21:34:11.0 
+1000
@@ -960,6 +960,30 @@
  This driver supports the built-in serial ports of the Motorola 
ColdFire
  family of CPUs.
 
+config SERIAL_MCF
+   bool "Coldfire serial support (new style driver)"
+   depends on COLDFIRE
+   select SERIAL_CORE
+   help
+ This new serial driver supports the Freescale Coldfire serial ports
+ using the new serial driver subsystem.
+
+config SERIAL_MCF_BAUDRATE
+   int "Default baudrate for Coldfire serial ports"
+   depends on SERIAL_MCF
+   default 19200
+   help
+ This setting lets you define what the default baudrate is for the
+ ColdFire serial ports. The usual default varies from board to board,
+ and this setting is a way of catering for that.
+
+config SERIAL_MCF_CONSOLE
+   bool "Coldfire serial console support"
+   depends on SERIAL_MCF
+   select SERIAL_CORE_CONSOLE
+   help
+ Enable a ColdFire internal serial port to be the system console.
+
 config SERIAL_68360_SMC
bool "68360 SMC uart support"
depends on M68360
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: platform setup for 5206 ColdFire parts

2008-01-31 Thread Greg Ungerer
Switch to platform style configuration for 5206 ColdFire parts.
Initial support is for the UARTs. DMA support moved to common code
for all ColdFire parts.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---


diff -Naurp linux-2.6.24/arch/m68knommu/platform/5206/config.c 
linux-2.6.24-uc0/arch/m68knommu/platform/5206/config.c
--- linux-2.6.24/arch/m68knommu/platform/5206/config.c  2008-01-25 
08:58:37.0 +1000
+++ linux-2.6.24-uc0/arch/m68knommu/platform/5206/config.c  2008-01-11 
13:37:38.0 +1000
@@ -13,12 +13,11 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
-#include 
 #include 
-#include 
+#include 
 
 /***/
 
@@ -26,15 +25,51 @@ void coldfire_reset(void);
 
 /***/
 
-/*
- * DMA channel base address table.
- */
-unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
-MCF_MBAR + MCFDMA_BASE0,
-MCF_MBAR + MCFDMA_BASE1,
+static struct mcf_platform_uart m5206_uart_platform[] = {
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE1,
+   .irq= 73,
+   },
+   {
+   .mapbase= MCF_MBAR + MCFUART_BASE2,
+   .irq= 74,
+   },
+   { },
 };
 
-unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
+static struct platform_device m5206_uart = {
+   .name   = "mcfuart",
+   .id = 0,
+   .dev.platform_data  = m5206_uart_platform,
+};
+
+static struct platform_device *m5206_devices[] __initdata = {
+   _uart,
+};
+
+/***/
+
+static void __init m5206_uart_init_line(int line, int irq)
+{
+   if (line == 0) {
+   writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + 
MCFSIM_UART1ICR);
+   writeb(irq, MCFUART_BASE1 + MCFUART_UIVR);
+   mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
+   } else if (line == 1) {
+   writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + 
MCFSIM_UART2ICR);
+   writeb(irq, MCFUART_BASE2 + MCFUART_UIVR);
+   mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
+   }
+}
+
+static void __init m5206_uarts_init(void)
+{
+   const int nrlines = ARRAY_SIZE(m5206_uart_platform);
+   int line;
+
+   for (line = 0; (line < nrlines); line++)
+   m5206_uart_init_line(line, m5206_uart_platform[line].irq);
+}
 
 /***/
 
@@ -88,10 +123,21 @@ int mcf_timerirqpending(int timer)
 
 /***/
 
-void config_BSP(char *commandp, int size)
+void __init config_BSP(char *commandp, int size)
 {
mcf_setimr(MCFSIM_IMR_MASKALL);
mach_reset = coldfire_reset;
 }
 
 /***/
+
+static int __init init_BSP(void)
+{
+   m5206_uarts_init();
+   platform_add_devices(m5206_devices, ARRAY_SIZE(m5206_devices));
+   return 0;
+}
+
+arch_initcall(init_BSP);
+
+/***/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[M68KNOMMU]: build support for new ColdFire serial driver

2008-01-31 Thread Greg Ungerer
Add build support for new ColdFire serial driver.

Signed-off-by: Greg Ungerer <[EMAIL PROTECTED]>
---

--- linux-2.6.24/drivers/serial/Makefile2008-01-25 08:58:37.0 
+1000
+++ linux-2.6.24.1/drivers/serial/Makefile  2008-01-30 21:33:00.0 
+1000
@@ -39,6 +39,7 @@
 obj-$(CONFIG_SERIAL_68328) += 68328serial.o
 obj-$(CONFIG_SERIAL_68360) += 68360serial.o
 obj-$(CONFIG_SERIAL_COLDFIRE) += mcfserial.o
+obj-$(CONFIG_SERIAL_MCF) += mcf.o
 obj-$(CONFIG_V850E_UART) += v850e_uart.o
 obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
 obj-$(CONFIG_SERIAL_LH7A40X) += serial_lh7a40x.o
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] nozomi: constify driver

2008-01-31 Thread Sam Ravnborg
On Fri, Feb 01, 2008 at 07:25:05AM +0100, Frank Seidel wrote:
> On Thursday 31 January 2008 22:39, Jan Engelhardt wrote:
> > On Jan 31 2008 22:10, Frank Seidel wrote:
> > >(Re: [PATCH 012/196 ver2] nozomi driver) and is a rework
> > >of the nozomi constify patch from Jan Engelhardt.
> > 
> > It's hard to find what you actually reworked...
> 
> No, just use interdiff and its easy :-) .. and btw
> I didn't say i did a full rewrite ;-)
> 
> > >-static struct pci_device_id nozomi_pci_tbl[] = {
> > >+static const struct pci_device_id nozomi_pci_tbl[] __devinitdata = {
> > 
> > This is bogus.
> 
> In what way? First i tested this patch well (compiling and
> usage doesn't break a single thing) and second this (static
> const struct pci_device_id .. __devinitdata) can be found in many
> drivers.
> So, please explain why you think so.

__devinitdata is for non-const data.
__devinitconst is for const data.

You cannot mix const and non-const data in the same section,
if you do so gcc will complain.
It may build for you if all uses of __devinitdata in the
same source file is either const or non-const but when you
mix it then it breaks.

So please use the correct annotation.


> P.S.: btw this is the interdiff. Yes, its not big, but even
> then why not combine it with yours ;-)

We do small incremental steps whenever we can. The challenge is
often to split up patches and not to combine them.

Where we combine two patches this is when the second patch fix
a bug in the first patch.

Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] x86: sparse warnings in pageattr.c

2008-01-31 Thread Harvey Harrison
Adjust the definition of lookup_address to take an unsigned long
level argument.  Adjust callers in xen/mmu.c that pass in a
dummy variable.

arch/x86/mm/pageattr.c:99:38: warning: incorrect type in argument 2 (different 
signedness)
arch/x86/mm/pageattr.c:99:38:expected int *level
arch/x86/mm/pageattr.c:99:38:got unsigned int *
arch/x86/mm/pageattr.c:215:33: warning: incorrect type in argument 2 (different 
signedness)
arch/x86/mm/pageattr.c:215:33:expected int *level
arch/x86/mm/pageattr.c:215:33:got unsigned int *

Signed-off-by: Harvey Harrison <[EMAIL PROTECTED]>
---
 arch/x86/mm/pageattr.c|5 +++--
 arch/x86/xen/mmu.c|6 +++---
 include/asm-x86/pgtable.h |2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index e297bd6..d29cb9a 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -142,7 +142,7 @@ static inline pgprot_t static_protections(pgprot_t prot, 
unsigned long address)
return prot;
 }
 
-pte_t *lookup_address(unsigned long address, int *level)
+pte_t *lookup_address(unsigned long address, unsigned int *level)
 {
pgd_t *pgd = pgd_offset_k(address);
pud_t *pud;
@@ -254,7 +254,8 @@ __change_page_attr(unsigned long address, unsigned long pfn,
   pgprot_t mask_set, pgprot_t mask_clr)
 {
struct page *kpte_page;
-   int level, err = 0;
+   unsigned int level;
+   int err = 0;
pte_t *kpte;
 
 #ifdef CONFIG_X86_32
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 45aa771..0144395 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -58,7 +58,7 @@
 
 xmaddr_t arbitrary_virt_to_machine(unsigned long address)
 {
-   int level;
+   unsigned int level;
pte_t *pte = lookup_address(address, );
unsigned offset = address & PAGE_MASK;
 
@@ -71,7 +71,7 @@ void make_lowmem_page_readonly(void *vaddr)
 {
pte_t *pte, ptev;
unsigned long address = (unsigned long)vaddr;
-   int level;
+   unsigned int level;
 
pte = lookup_address(address, );
BUG_ON(pte == NULL);
@@ -86,7 +86,7 @@ void make_lowmem_page_readwrite(void *vaddr)
 {
pte_t *pte, ptev;
unsigned long address = (unsigned long)vaddr;
-   int level;
+   unsigned int level;
 
pte = lookup_address(address, );
BUG_ON(pte == NULL);
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index cd2524f..de27abf 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -251,7 +251,7 @@ enum {
  * NOTE: the return type is pte_t but if the pmd is PSE then we return it
  * as a pte too.
  */
-extern pte_t *lookup_address(unsigned long address, int *level);
+extern pte_t *lookup_address(unsigned long address, unsigned int *level);
 
 /* local pte updates need not use xchg for locking */
 static inline pte_t native_local_ptep_get_and_clear(pte_t *ptep)
-- 
1.5.4.rc4.1142.gf5a97



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2.6.24] Add new string functions strict_strto* and convert kernel params to use them, take 2

2008-01-31 Thread Yi Yang
This patch is a resend, it changes previous name "real_" to "strict_" 
according to Randy Dunlap's feedback. Please consider to apply. thanks.

Currently, for every sysfs node, the callers will be responsible for
implementing store operation, so many many callers are doing duplicate
things to validate input, they have the same mistakes because they are
calling simple_strtol/ul/ll/uul, especially for module params, they are
just numeric, but you can echo such values as 0x1234xxx, 0888 and
1234aaa, for these cases, module params store operation just ignores
succesive invalid char and converts prefix part to a numeric although
input is acctually invalid.

This patch tries to fix the aforementioned issues and implements strict_strtox
serial functions, kernel/params.c uses them to strictly validate input,
so module params will reject such values as 0x1234 and returns an error:

write error: Invalid argument

Any modules which export numeric sysfs node can use strict_strtox instead of
simple_strtox to reject any invalid input.

Here are some test results:

Before applying this patch:

[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]# echo 0x1000 > /sys/module/e1000/parameters/copybreak
[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]# echo 0x1000g > /sys/module/e1000/parameters/copybreak
[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]# echo 0x1000 > 
/sys/module/e1000/parameters/copybreak
[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]# echo 01 > /sys/module/e1000/parameters/copybreak
[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]# echo 018 > /sys/module/e1000/parameters/copybreak
[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]# echo 01a > /sys/module/e1000/parameters/copybreak
[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]#


After applying this patch:

[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]# echo 0x1000 > /sys/module/e1000/parameters/copybreak
[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]# echo 0x1000g > /sys/module/e1000/parameters/copybreak
-bash: echo: write error: Invalid argument
[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]# echo 0x1000 > 
/sys/module/e1000/parameters/copybreak
-bash: echo: write error: Invalid argument
[EMAIL PROTECTED] /]# echo 01 > /sys/module/e1000/parameters/copybreak
[EMAIL PROTECTED] /]# echo 018 > /sys/module/e1000/parameters/copybreak
-bash: echo: write error: Invalid argument
[EMAIL PROTECTED] /]# echo 01a > /sys/module/e1000/parameters/copybreak
-bash: echo: write error: Invalid argument
[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]# echo -n 4096 > /sys/module/e1000/parameters/copybreak
[EMAIL PROTECTED] /]# cat /sys/module/e1000/parameters/copybreak
4096
[EMAIL PROTECTED] /]#


Signed-off-by: Yi Yang <[EMAIL PROTECTED]>
---
 include/linux/kernel.h |4 
 kernel/params.c|   20 ++--
 lib/vsprintf.c |   46 ++
 3 files changed, 60 insertions(+), 10 deletions(-)

--- a/include/linux/kernel.h2008-01-31 00:41:46.0 +0800
--- b/include/linux/kernel.h2008-02-01 04:30:49.0 +0800
@@ -141,6 +141,10 @@ extern unsigned long simple_strtoul(cons
 extern long simple_strtol(const char *,char **,unsigned int);
 extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
 extern long long simple_strtoll(const char *,char **,unsigned int);
+extern int strict_strtoul(const char *, unsigned int, unsigned long *);
+extern int strict_strtol(const char *, unsigned int, long *);
+extern int strict_strtoull(const char *, unsigned int, unsigned long long *);
+extern int strict_strtoll(const char *, unsigned int, long long *);
 extern int sprintf(char * buf, const char * fmt, ...)
__attribute__ ((format (printf, 2, 3)));
 extern int vsprintf(char *buf, const char *, va_list)
--- a/lib/vsprintf.c2008-01-30 08:13:03.0 +0800
--- b/lib/vsprintf.c2008-02-01 04:33:27.0 +0800
@@ -126,6 +126,52 @@ long long simple_strtoll(const char *cp,
return simple_strtoull(cp,endp,base);
 }
 
+#define define_strict_strtoux(type, valtype)   \
+int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\
+{  \
+   char *tail; \
+   valtype val;\
+   size_t len; \
+  

Re: hibernate/suspend-to-disk: to turn power or not?

2008-01-31 Thread Michael Tokarev
Pavel Machek wrote:
[]
>> I'm looking at the uswsusp source (while the kernel compiles),
>> and have a question here.  Is it possible to call some external
>> application (typically a shell script) to do the final work after
>> when the image has been written?  I mean in principle - I
>> understand there are some limitations here, but I don't know
>> which exactly.
> 
> No, you can't exec() anything. That would write mtime back to disk and
> cause badness.

Now that's.. interesting.

s2disk writes to a swap device/file, which should update
mtime of this device node/file.  Isn't it something which
also causes the same badness?

Also, if the only concern is mtime update, what's really
wrong with it?  I mean, regardless of whether such update
will finally hit the disk or not, there's not much difference
really - it updates just mtime field, and there should be
no harm in that.  Unless such update first goes to a
journal (in a journalling filesystem) - which DOES modify
some on-disk structures.

>> it typically involves writing/reading something to/from
>> a given serial port (/dev/ttySxx), or to an USB device,

> Create libups.so, and link s2disk to it?

And what's the difference here again?  We'll open a serial
port and write something to it - which, again, will update
mtime of that device node.  Unless the said node is on a
tmpfs, exactly the same badness will happen.  Not all the
world is udev, after all.

So I don't get the reason why we can't exec something here,
still.  (And, for example, call splashy commands as external
processes, instead of linking all this cruft into s2disk and
resume.)

What I'm thinking about here is - s2ram mlock()s its memory.
If it will fork/exec something, that something will obviously
NOT be locked like that.  Is it of some concern?  Probably
not, because that something will be executed after we've
taken the snapshot.

/mjt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Feature Removals for 2.6.25

2008-01-31 Thread Stephen Hemminger

> Ping?
> What:   sk98lin network driver
> When:   Feburary 2008
> Why:In kernel tree version of driver is unmaintained. Sk98lin driver
>   replaced by the skge driver. 
> Who:Stephen Hemminger <[EMAIL PROTECTED]>
> 

Sent a removal patch to Jeff, it probably was too big for the mailing list.
-- 
Stephen Hemminger <[EMAIL PROTECTED]>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Feature Removals for 2.6.25

2008-01-31 Thread Harvey Harrison
On Thu, 2008-01-31 at 22:33 -0800, Arjan van de Ven wrote:
> Harvey Harrison wrote:
> > Something like the following (grep found me two example symbols)
> 
> to be honest, nobody reads this file with such detail; the actual UNUSED 
> marking
> is a lot more louder and people are more likely to notice those for all I 
> care
> we nuke the entire entry from the removals file.

Well, if there is interest in having an up-to-date file, I'm willing to
do the bookkeeping to make this usable and try to keep it up to date.

Anybody think this is worthwhile?

Harvey

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Feature Removals for 2.6.25

2008-01-31 Thread Arjan van de Ven

Harvey Harrison wrote:

Something like the following (grep found me two example symbols)


to be honest, nobody reads this file with such detail; the actual UNUSED marking
is a lot more louder and people are more likely to notice those for all I 
care
we nuke the entire entry from the removals file.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] nozomi: constify driver

2008-01-31 Thread Frank Seidel
On Thursday 31 January 2008 22:39, Jan Engelhardt wrote:
> On Jan 31 2008 22:10, Frank Seidel wrote:
> >(Re: [PATCH 012/196 ver2] nozomi driver) and is a rework
> >of the nozomi constify patch from Jan Engelhardt.
> 
> It's hard to find what you actually reworked...

No, just use interdiff and its easy :-) .. and btw
I didn't say i did a full rewrite ;-)

> >-static struct pci_device_id nozomi_pci_tbl[] = {
> >+static const struct pci_device_id nozomi_pci_tbl[] __devinitdata = {
> 
> This is bogus.

In what way? First i tested this patch well (compiling and
usage doesn't break a single thing) and second this (static
const struct pci_device_id .. __devinitdata) can be found in many
drivers.
So, please explain why you think so.

Thanks,
Frank

P.S.: btw this is the interdiff. Yes, its not big, but even
then why not combine it with yours ;-)
---
diff -u b/drivers/char/nozomi.c b/drivers/char/nozomi.c
--- b/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -395,7 +395,7 @@
 } __attribute__ ((packed));
 
 /*Global variables */
-static struct pci_device_id nozomi_pci_tbl[] __devinitdata = {
+static const struct pci_device_id nozomi_pci_tbl[] __devinitdata = {
{PCI_DEVICE(VENDOR1, DEVICE1)},
{},
 };
@@ -778,13 +778,13 @@
  * Return 1 - send buffer to card and ack.
  * Return 0 - don't ack, don't send buffer to card.
  */
-static int send_data(enum port_type index, struct nozomi *dc)
+static int send_data(enum port_type index, const struct nozomi *dc)
 {
u32 size = 0;
const struct port *port = >port[index];
-   u8 toggle = port->toggle_ul;
+   const u8 toggle = port->toggle_ul;
void __iomem *addr = port->ul_addr[toggle];
-   u32 ul_size = port->ul_size[toggle];
+   const u32 ul_size = port->ul_size[toggle];
struct tty_struct *tty = port->tty;
 
/* Get data from tty and place in buf for now */
@@ -1732,7 +1732,7 @@
 static int ntty_cflags_changed(struct port *port, unsigned long flags,
struct async_icount *cprev)
 {
-   struct async_icount cnow = port->tty_icount;
+   const struct async_icount cnow = port->tty_icount;
int ret;
 
ret =   ((flags & TIOCM_RNG) && (cnow.rng != cprev->rng)) ||
@@ -1747,7 +1747,7 @@
 
 static int ntty_ioctl_tiocgicount(struct port *port, void __user *argp)
 {
-   struct async_icount cnow = port->tty_icount;
+   const struct async_icount cnow = port->tty_icount;
struct serial_icounter_struct icount;
 
icount.cts = cnow.cts;
@@ -1858,7 +1858,7 @@
return rval;
 }
 
-static struct tty_operations tty_ops = {
+static const struct tty_operations tty_ops = {
.ioctl = ntty_ioctl,
.open = ntty_open,
.close = ntty_close,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


rtc : lockdep warning

2008-01-31 Thread Dave Young
[ cut here ]
WARNING: at kernel/lockdep.c:2033 trace_hardirqs_on+0xe3/0x130()
Modules linked in: btusb intel_agp bluetooth snd_hda_intel evdev
agpgart thermal sg processor rtc_cmos button serio_raw i2c_i801
snd_pcm rtc_core pcspkr 3c59x rtc_lib snd_timer snd soundcore
snd_page_alloc
Pid: 2307, comm: hwclock Not tainted 2.6.24 #25
 [] ? zap_locks+0x40/0x70
 [] warn_on_slowpath+0x54/0x80
 [] ? mark_lock_irq+0x79/0x3b0
 [] ? validate_chain+0x1d2/0x320
 [] ? mark_lock+0x93/0x1d0
 [] ? native_sched_clock+0x85/0xe0
 [] ? put_lock_stats+0xd/0x30
 [] ? lock_release_holdtime+0x60/0x80
 [] ? hpet_rtc_interrupt+0xcf/0x230
 [] ? __lock_release+0x47/0x70
 [] ? hpet_rtc_interrupt+0xcf/0x230
 [] ? _spin_unlock_irq+0x22/0x50
 [] trace_hardirqs_on+0xe3/0x130
 [] _spin_unlock_irq+0x22/0x50
 [] hpet_rtc_interrupt+0xcf/0x230
 [] ? handle_edge_irq+0xaf/0x150
 [] handle_IRQ_event+0x28/0x60
 [] handle_edge_irq+0xb8/0x150
 [] do_IRQ+0x3c/0x80
 [] ? trace_hardirqs_on+0xb9/0x130
 [] common_interrupt+0x2e/0x34
 ===
---[ end trace fb50847cfa3f5ac9 ]---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] x86: sparse errors from string_32.h

2008-01-31 Thread Harvey Harrison
include/asm/string_32.h:216:26: warning: cast truncates bits from constant 
value ( becomes cc)
include/asm/string_32.h:219:27: warning: cast truncates bits from constant 
value ( becomes )
include/asm/string_32.h:222:27: warning: cast truncates bits from constant 
value ( becomes )
include/asm/string_32.h:223:30: warning: cast truncates bits from constant 
value ( becomes cc)

Signed-off-by: Harvey Harrison <[EMAIL PROTECTED]>
---
Ingo, this shows up over and over again during the build, this
doesn't change anything as they are known compile-time constants
at this point, the and-ing just makes the truncation explicit.

If you disagree with this method, no worries.

 include/asm-x86/string_32.h |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/asm-x86/string_32.h b/include/asm-x86/string_32.h
index 55bfa30..c5d13a8 100644
--- a/include/asm-x86/string_32.h
+++ b/include/asm-x86/string_32.h
@@ -213,14 +213,14 @@ static __always_inline void * 
__constant_c_and_count_memset(void * s, unsigned l
case 0:
return s;
case 1:
-   *(unsigned char *)s = pattern;
+   *(unsigned char *)s = pattern & 0xff;
return s;
case 2:
-   *(unsigned short *)s = pattern;
+   *(unsigned short *)s = pattern & 0x;
return s;
case 3:
-   *(unsigned short *)s = pattern;
-   *(2+(unsigned char *)s) = pattern;
+   *(unsigned short *)s = pattern & 0x;
+   *(2+(unsigned char *)s) = pattern & 0xff;
return s;
case 4:
*(unsigned long *)s = pattern;
-- 
1.5.4.rc4.1142.gf5a97



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: cups slow on linux-2.6.24

2008-01-31 Thread Patrick McHardy

David Newall wrote:

I'm not debating that checksums are wrong. The question was how and
where? It's not as if there are any unreliable communication paths in a
loopback interface, so it's surprising that they could be wrong. How? Where?



As I said, loopback doesn't perform full checksum calculation.
Its simply an optimization, nothing to worry about ...

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] docbook: rapidio: fix fatal filename error

2008-01-31 Thread Randy.Dunlap

From: Randy Dunlap <[EMAIL PROTECTED]>

Fix docbook fatal error (files were renamed):
docproc: linux-2.6.24-git9/arch/ppc/kernel/rio.c: No such file or directory

Signed-off-by: Randy Dunlap <[EMAIL PROTECTED]>
---
 Documentation/DocBook/rapidio.tmpl |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- linux-2.6.24-git9.orig/Documentation/DocBook/rapidio.tmpl
+++ linux-2.6.24-git9/Documentation/DocBook/rapidio.tmpl
@@ -133,9 +133,9 @@
 !Idrivers/rapidio/rio-sysfs.c
  
  PPC32 support
-!Iarch/ppc/kernel/rio.c
-!Earch/ppc/syslib/ppc85xx_rio.c
-!Iarch/ppc/syslib/ppc85xx_rio.c
+!Iarch/powerpc/kernel/rio.c
+!Earch/powerpc/sysdev/fsl_rio.c
+!Iarch/powerpc/sysdev/fsl_rio.c
  
   

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: cups slow on linux-2.6.24

2008-01-31 Thread David Newall
David Miller wrote:
> From: David Newall <[EMAIL PROTECTED]>
> Date: Fri, 01 Feb 2008 11:17:14 +1030
>
>   
>> Patrick McHardy wrote:
>> 
>>> Jozsef Kadlecsik wrote:
>>>   
 Strange, but there are a lot of incorrect checksum packets. How does
 it come on the loopback interface?
 
>>> Loopback doesn't perform full checksumming, so thats expected.
>>>   
>> The question remains: How do loopback packets get incorrect checksum? 
>> Where and how can they get corrupted?
>> 
>
> There are zeros there, which is an incorrect checksum most
> of the time.
>   

I'm not debating that checksums are wrong. The question was how and
where? It's not as if there are any unreliable communication paths in a
loopback interface, so it's surprising that they could be wrong. How? Where?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] feature-removal: Document suspend/hibernate deprecations

2008-01-31 Thread Harvey Harrison
Let this appear as deprecated in 2.6.25, remove after three
releases (2.6.28).

Signed-off-by: Harvey Harrison <[EMAIL PROTECTED]>
---
Something like this should be included if you are deprecating
userspace functionality.  I tried to come up with a useful
reason from your changelogs, but you should fill this in.

 Documentation/feature-removal-schedule.txt |   25 +
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/Documentation/feature-removal-schedule.txt 
b/Documentation/feature-removal-schedule.txt
index 181bff0..cb005de 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -354,3 +354,28 @@ Why:   The support code for the old firmware hurts 
code readability/maintainabilit
and slightly hurts runtime performance. Bugfixes for the old firmware
are not provided by Broadcom anymore.
 Who:   Michael Buesch <[EMAIL PROTECTED]>
+
+---
+
+What:  SNAPSHOT_PMOPS ioctl
+When:  2.6.28
+Why:   Badly designed interface, obsoleted by SNAPSHOT_PLATFORM_SUPPORT and
+   SNAPSHOT_POWER_OFF
+Who:   Len Brown <[EMAIL PROTECTED]>
+
+---
+
+What:  SNAPSHOT_SET_SWAP_FILE ioctl
+When:  2.6.28
+Why:   Insert reason here
+Who:   Len Brown <[EMAIL PROTECTED]>
+
+---
+
+What:  SNAPSHOT_ATOMIC_SNAPSHOT, SNAPSHOT_AVAIL_SWAP, SNAPSHOT_GET_SWAP_PAGE 
ioctls
+When:  2.6.28
+Why:   Defined in a non-portable manner, new numbers introduced, old numbers
+   deprecated.
+Who:   Len Brown <[EMAIL PROTECTED]>
+
+---
-- 
1.5.4.rc4.1142.gf5a97



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] x86: add a crc32 checksum to the kernel image.

2008-01-31 Thread David Newall
H. Peter Anvin wrote:
> David Newall wrote:
>> Isn't a crc32 calculation already defined?  Yes; in lib/crc32.c.  One is
>> surely enough.
>
> As long as it can be included in user-space code we should use that one. 

You're right.  I misread the patch.  I thought the calculation was being
added to kernel code.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Xmit buffer overflow in pl2303

2008-01-31 Thread David Newall
I've been working on a buffer overflow problem in pl2303.  Admittedly
I'm using a 2.4 kernel, but I've back-ported the latest pl2303.c. 
(Please make no unnecessary fuss over that.)  For the record, the
pl2303.c from 2.6.23 is substantially identical to that from 2.4.  The
significant change, other than addition of some extra product ids, is
the inclusion of a couple of 1k circular buffers, which hide the
problem; but buffers are finite and when sufficiently motivated, the
problem reappears.

The problem relates to hardware handshaking.  When CTS is off, the
userspace application can continue to write to the device, eventually
filling all buffers, both kernel and hardware, after which data is
dropped and pl2303_write returns 0.  Loading the module with debug=1, I
see each user write of n bytes reflected in the log as a sequence of
writes of length n, n-1, ..., 0.  I guess something above the module is
catching the 0 return from pl2303_write and repeating with one less byte
each time, perhaps on the basis that a smaller count might succeed where
the larger doesn't.  At no point does the user application block until
CTS is re-asserted.  The driver correctly records CTS (and other line)
state transitions, but nothing seems to care.

I have inserted code in pl2303_write which sleeps while CTS is off (if
it's being monitored), and likewise DSR.  That works nicely, but it
seems to me that this is a common requirement that should be handled
elsewhere.  I don't see it in char/tty, either in usbserial.  I don't
even see it in any other driver.  Where should I be looking?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: dl2k stopped working on 2.6.24

2008-01-31 Thread Al Viro
On Fri, Feb 01, 2008 at 01:04:42AM +0100, Santiago Garcia Mantinan wrote:
> > I have today compiled dl2k from git, the version with the 2007-12-23 patches
> > from Al Viro: dl2k endianness fixes (.24 fodder?) Right before the Al Viro
> > patches. This seems to be working perfectly on my system.
> 
> Ok, I've been applying Al's patches one by one, everything went fine till I
> applied the "dl2k: MSCR, MSSR, ESR, PHY_SCR fixes" patch. With this patch I
> experimented the behaviour I commented on my first message.
> 
> I don't know what else to try now, any ideas?
> 
> Regards...

Very interesting.  Relevant part seems to be
-   mscr.image = mii_read (dev, phy_addr, MII_MSCR);
-   mssr.image = mii_read (dev, phy_addr, MII_MSSR);
-   if (mscr.bits.media_1000BT_FD & mssr.bits.lp_1000BT_FD) {
+   mscr = mii_read (dev, phy_addr, MII_MSCR);
+   mssr = mii_read (dev, phy_addr, MII_MSSR);
+   if (mscr & MII_MSCR_1000BT_FD && mssr & MII_MSSR_LP_1000BT_FD) {
np->speed = 1000;
np->full_duplex = 1;
printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n");
-   } else if (mscr.bits.media_1000BT_HD & mssr.bits.lp_1000BT_HD) {
+   } else if (mscr & MII_MSCR_1000BT_HD && mssr & 
MII_MSSR_LP_1000BT_HD) {
np->speed = 1000;
np->full_duplex = 0;
printk (KERN_INFO "Auto 1000 Mbps, Half duplex\n");

More specifically, this:
-   if (mscr.bits.media_1000BT_FD & mssr.bits.lp_1000BT_FD) {
+   if (mscr & MII_MSCR_1000BT_FD && mssr & MII_MSSR_LP_1000BT_FD) {

We used to have mscr declared as
typedef union t_MII_MSCR {
   u16 image;
   struct {
   u16 _bit_7_0:8; // bit 7:0
   u16 media_1000BT_HD:1;  // bit 8
   u16 media_1000BT_FD:1;  // bit 9
   u16 port_type:1;// bit 10
   u16 cfg_value:1;// bit 11
   u16 cfg_enable:1;   // bit 12
   u16 test_mode:3;// bit 15:13
   } bits;
} MSCR_t, *PMSCR_t;

and mssr as
typedef union t_MII_MSSR {
   u16 image;
   struct {
   u16 idle_err_count:8;   // bit 7:0
   u16 _bit_9_8:2; // bit 9:8
   u16 lp_1000BT_HD:1; // bit 10
   u16 lp_1000BT_FD:1; // bit 11
   u16 remote_rcv_status:1;// bit 12
   u16 local_rcv_status:1; // bit 13
   u16 cfg_resolution:1;   // bit 14
   u16 cfg_fault:1;// bit 15
   } bits;
} MSSR_t, *PMSSR_t;

so it looks like these constants had not been right...  Damn right, they
had not - 
MII_MSSR_LP_1000BT_HD = 0x0800,
MII_MSSR_LP_1000BT_FD = 0x0400,
and that has HD at bit 11 and FD at bit 10 - swapped, IOW.  Driver had them
defined wrong all along, but they were not used until now, so bug had not been
noticed.

See if the patch below takes care of all of that:

diff --git a/drivers/net/dl2k.h b/drivers/net/dl2k.h
index d66c605..266ec87 100644
--- a/drivers/net/dl2k.h
+++ b/drivers/net/dl2k.h
@@ -388,8 +388,8 @@ enum _mii_mssr {
MII_MSSR_CFG_RES = 0x4000,
MII_MSSR_LOCAL_RCV_STATUS = 0x2000,
MII_MSSR_REMOTE_RCVR = 0x1000,
-   MII_MSSR_LP_1000BT_HD = 0x0800,
-   MII_MSSR_LP_1000BT_FD = 0x0400,
+   MII_MSSR_LP_1000BT_FD = 0x0800,
+   MII_MSSR_LP_1000BT_HD = 0x0400,
MII_MSSR_IDLE_ERR_COUNT = 0x00ff,
 };
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: missing asm-x86_64 detection

2008-01-31 Thread Nish Aravamudan
On 1/31/08, Reinaldo Carvalho <[EMAIL PROTECTED]> wrote:
> :/# uname -a
> Linux devil 2.6.22.16-amd64 #15 SMP Sat Jan 19 13:58:02 BRT 2008
> x86_64 GNU/Linux
>
> :/# cd /usr/src/linux-2.6.22
> :/# patch -p1 -R < ../patch-2.6.22.16
> :/# patch -p1 < ../patch-2.6.23
> :/# patch -p1 < ../patch-2.6.24
> :/# cd /usr/src/ ; mv linux-2.6.22 linux-2.6.24; cd linux-2.6.24
> :/usr/src/linux-2.6.24# make oldconfig
> :/usr/src/linux-2.6.24# make all
>   CHK include/linux/version.h
>   CHK include/linux/utsrelease.h
> ERROR: the symlink include/asm points to asm-x86_64 but asm-x86 was expected
>set ARCH or save .config and run 'make mrproper' to fix it
> make: ** [include/asm] Erro 1
>
> :/usr/src/linux-2.6.24# cp .config ../config-2.6.24
> :/usr/src/linux-2.6.24# make mrproper
>   CLEAN   scripts/basic
>   CLEAN   scripts/genksyms
>   CLEAN   scripts/kconfig
>   CLEAN   scripts/mod
>   CLEAN   scripts
>   CLEAN   include/config
>   CLEAN   .config .config.old include/asm .version
> include/linux/autoconf.h include/linux/version.h
> include/linux/utsrelease.h Module.symvers
> devil:/usr/src/linux-2.6.24# cp ../config-2.6.24 .config
> devil:/usr/src/linux-2.6.24# make oldconfig
> devil:/usr/src/linux-2.6.24# make all
> scripts/kconfig/conf -s arch/x86/Kconfig
>   CHK include/linux/version.h
>   UPD include/linux/version.h
>   CHK include/linux/utsrelease.h
>   UPD include/linux/utsrelease.h
>   SYMLINK include/asm -> include/asm-x86
>   CC  arch/x86/kernel/asm-offsets.s
>   GEN include/asm-x86/asm-offsets.h
> ...
>
> system is x86_64!

And your point? The archs are being merged into just x86 (instead of
x86_32 and x86_64 being separate). That's why the asm-x86_64 symlink
was complained about above.

There is no error. Check your config that CONFIG_64BIT and
CONFIG_X86_64 are set.

Thanks,
Nish
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Removing dev.power.power_state (WAS: Feature Removals for 2.6.25)

2008-01-31 Thread David Brownell
Quoth Harvey Harrison:

> Ping?
> What: dev->power.power_state
> When: July 2007
> Why:  Broken design for runtime control over driver power states, confusing
>   driver-internal runtime power management with:  mechanisms to support
>   system-wide sleep state transitions; event codes that distinguish
>   different phases of swsusp "sleep" transitions; and userspace policy
>   inputs.  This framework was never widely used, and most attempts to
>   use it were broken.  Drivers should instead be exposing domain-specific
>   interfaces either to kernel or to userspace.
> Who:  Pavel Machek <[EMAIL PROTECTED]>

A lot of the infrastructure using that has already been deleted, and
there are some incremental improvements pending for 2.6.25:

 - drivers/input/touchscreen/ads7846.c ... patch fixing this
   should be in either MM or the input queue

 - Documentation/power/devices.txt ... patch fixing this is
   in the suspend tree, due to merge RSN

 - drivers/spi/spi.c ... patch fixing this is in MM, due to
   merge with other SPI patches

 - drivers/pcmcia/ds.c ... at least I *think* that patch got sent

But there are still quite a few users left, and a new one was (sigh)
recently added.

 - drivers/rtc/rtc-sa1100.c ... new usage, merged last week

 - drivers/usb/... has various users, HCDs look easy enough to fix but
   the other bits will take more thought

 - drivers/ata/... has some too

 - drivers/ide/ppc/pmac.c

 - drivers/spi/... some controller drivers use this (look easy to fix)

 - drivers/scsi/mesh.c

 - drivers/input/serio/... has a few users

 - ... more ...

I'll probably send in a few more patches for easy stuff in areas
that I touch semi-frequently, but other folk should fix ATA, IDE,
SCSI, SERIO, and so forth.  It'd be good if Alan would help fix
the USB stuff too.  I'm not sure what Pavel's doing there...

- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Feature Removals for 2.6.25

2008-01-31 Thread Harvey Harrison
On Thu, 2008-01-31 at 20:53 -0800, Arjan van de Ven wrote:
> > 
> > ---
> > 
> > What:   CONFIG_FORCED_INLINING
> > When:   June 2006
> > Why:Config option is there to see if gcc is good enough. (in january
> > 2006). If it is, the behavior should just be the default. If it's 
> > not,
> > the option should just go away entirely.
> > Who:Arjan van de Ven
> > 
> > Patch submitted to Arjan, maybe 2.6.25?
> 
> Ingo picked it up, but no rush for .25, .26 is fine for this as well
> 

OK, it shouldn't be any change from what's there now, but no rush.

> > 
> > What:   Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports
> > (temporary transition config option provided until then)
> > The transition config option will also be removed at the same time.
> > When:   before 2.6.19
> > Why:Unused symbols are both increasing the size of the kernel binary
> > and are often a sign of "wrong API"
> > Who:Arjan van de Ven <[EMAIL PROTECTED]>
> 
> this is an ongoing work; symbols get marked unused and then garbage collected
> when they're due; for example akpm has several of that kind in his pile right 
> now

How do they get marked?  As this is an ongoing effort, should this be
moved to the top of the file, and the actual symbols+date be listed?
That would make it easy to figure out what's going away.

Something like the following (grep found me two example symbols)

Harvey

---
From: Harvey Harrison <[EMAIL PROTECTED]>
Subject: [PATCH] feature-removal: document symbols going away

Signed-off-by: Harvey Harrison <[EMAIL PROTECTED]>
---
 Documentation/feature-removal-schedule.txt |   25 +++--
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/Documentation/feature-removal-schedule.txt 
b/Documentation/feature-removal-schedule.txt
index 3a46d1f..0c418e6 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -5,6 +5,21 @@ the work.  When the feature is removed from the kernel, it 
should also
 be removed from this file.
 
 ---
+What:  Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports
+   (temporary transition config option provided until then)
+   The transition config option will also be removed at the same time.
+Why:   Unused symbols are both increasing the size of the kernel binary
+   and are often a sign of "wrong API"
+Who:   Arjan van de Ven <[EMAIL PROTECTED]>
+
+When: 2.6.25
+fs/open.c:sys_open
+fs/read_write.c:sys_read
+
+When: 2.6.26
+
+
+---
 
 What:  MXSER
 When:  December 2007
@@ -137,16 +152,6 @@ Who:Adrian Bunk <[EMAIL PROTECTED]>
 
 ---
 
-What:  Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports
-   (temporary transition config option provided until then)
-   The transition config option will also be removed at the same time.
-When:  before 2.6.19
-Why:   Unused symbols are both increasing the size of the kernel binary
-   and are often a sign of "wrong API"
-Who:   Arjan van de Ven <[EMAIL PROTECTED]>
-

-
 What:  USB driver API moves to EXPORT_SYMBOL_GPL
 When:  February 2008
 Files: include/linux/usb.h, drivers/usb/core/driver.c
-- 
1.5.4.rc4.1142.gf5a97



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/3] exporting capability code/name pairs (try #3)

2008-01-31 Thread Kohei KaiGai
>> All that being said, the friendliness factor of this is somewhat
>> undeniable, and so I can see why folk might want it in the kernel
>> anyway. If so, would it possible to move this code into
>> security/capability.c and not in the main kernel per-se - protected with
>> a configuration option? If it does appear in the kernel, we'll obviously
>> add your libcap changes too. If it doesn't, then perhaps we can meet
>> your needs with a slight modification to your libcap patch to read the
>> capabilities from an optional /etc/XXX file - and make text visibility
>> of 'late breaking' capabilities something that the admin can tweak as
>> needed?
> 
> I think optional configuration file is not a good idea.
> It can make unneeded confusion.
> 
> If necessary, I'll move this features into security/capability.c and
> add a Kconfig option to select it.

The following patch enables to export the list of capabilities supported
on the running kernel, under /sys/kernel/capability .

Changelog from the previous version:
- Implementation is moved into security/capability.c from kernel/capability.c
- A Kconfig option SECURITY_CAPABILITIES_EXPORT is added to tuen on/off this 
feature.

[EMAIL PROTECTED] ~]$ for x in /sys/kernel/capability/*
> do
>   echo "$x --> `cat $x`"
> done
/sys/kernel/capability/cap_audit_control --> 30
/sys/kernel/capability/cap_audit_write --> 29
- snip -
/sys/kernel/capability/cap_sys_time --> 25
/sys/kernel/capability/cap_sys_tty_config --> 26
/sys/kernel/capability/index --> 31
/sys/kernel/capability/version --> 0x19980330
[EMAIL PROTECTED] ~]$

Thanks,

Signed-off-by: KaiGai Kohei <[EMAIL PROTECTED]>

 scripts/mkcapnames.sh |   50 +
 security/Kconfig  |9 
 security/Makefile |   11 ++
 security/capability.c |   49 
 4 files changed, 119 insertions(+), 0 deletions(-)

diff --git a/scripts/mkcapnames.sh b/scripts/mkcapnames.sh
index e69de29..262478e 100644
--- a/scripts/mkcapnames.sh
+++ b/scripts/mkcapnames.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+#
+# generate a cap_names.h file from include/linux/capability.h
+#
+
+BASEDIR=`dirname $0`
+
+echo '#ifndef CAP_NAMES_H'
+echo '#define CAP_NAMES_H'
+echo
+echo '/*'
+echo ' * Do NOT edit this file directly.'
+echo ' * This file is generated from include/linux/capability.h automatically'
+echo ' */'
+echo
+echo '#ifndef SYSFS_CAPABILITY_ENTRY'
+echo '#error cap_names.h should be included from kernel/capability.c'
+echo '#else'
+
+echo 'SYSFS_CAPABILITY_ENTRY(version, "0x%08x\n", _LINUX_CAPABILITY_VERSION);'
+
+cat ${BASEDIR}/../include/linux/capability.h   \
+| egrep '^#define CAP_[A-Z_]+[ ]+[0-9]+$'  \
+| awk 'BEGIN {
+max_code = -1;
+}
+{
+if ($3 > max_code)
+max_code = $3;
+printf("SYSFS_CAPABILITY_ENTRY(%s, \"%%u\\n\", %s);\n", 
tolower($2), $2);
+}
+END {
+printf("SYSFS_CAPABILITY_ENTRY(index, \"%%u\\n\", %u);\n", 
max_code);
+}'
+
+echo
+echo 'static struct attribute *capability_attrs[] = {'
+echo '_attr.attr,'
+echo '_attr.attr,'
+
+cat ${BASEDIR}/../include/linux/capability.h\
+| egrep '^#define CAP_[A-Z_]+[ ]+[0-9]+$'   \
+| awk '{ printf ("&%s_attr.attr,\n", tolower($2)); }'
+
+echo 'NULL,'
+echo '};'
+
+echo '#endif   /* SYSFS_CAPABILITY_ENTRY */'
+echo '#endif   /* CAP_NAMES_H */'
diff --git a/security/Kconfig b/security/Kconfig
index 8086e61..e4d330c 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -90,6 +90,15 @@ config SECURITY_FILE_CAPABILITIES

  If in doubt, answer N.

+config SECURITY_CAPABILITIES_EXPORT
+   bool "Exporting capabilities kernel supported"
+   depends on SECURITY_CAPABILITIES && SYSFS
+   help
+  This enables to export any capabilities which are supported
+ in the running kernel.
+   
+ If you are unsure how to answer this question, answer Y.
+
 config SECURITY_ROOTPLUG
bool "Root Plug Support"
depends on USB=y && SECURITY
diff --git a/security/Makefile b/security/Makefile
index ef87df2..90a856d 100644
--- a/security/Makefile
+++ b/security/Makefile
@@ -16,3 +16,14 @@ obj-$(CONFIG_SECURITY)   += security.o 
dummy.o inode.o
 obj-$(CONFIG_SECURITY_SELINUX) += selinux/built-in.o
 obj-$(CONFIG_SECURITY_CAPABILITIES)+= commoncap.o capability.o
 obj-$(CONFIG_SECURITY_ROOTPLUG)+= commoncap.o root_plug.o
+
+ifeq ($(CONFIG_SECURITY_CAPABILITIES_EXPORT),y)
+# cap_names.h contains the code/name pair of capabilities.
+# It is generated using include/linux/capability.h automatically.
+$(obj)/capability.o: $(obj)/cap_names.h
+quiet_cmd_cap_names  = CAPS$@
+  cmd_cap_names  = /bin/sh $(src)/../scripts/mkcapnames.sh > $@
+targets += cap_names.h
+$(obj)/cap_names.h: $(src)/../scripts/mkcapnames.sh 

[PATCH] fix directory entry in arch-x86-Makefile

2008-01-31 Thread Steven Rostedt

Doing a make randconfig I came across this error in the Makefile.

This patch makes a directory out of arch/x86/mach-default for
CONFIG_X86_RDC321X

Signed-off-by: Steven Rostedt <[EMAIL PROTECTED]>

---
 arch/x86/Makefile |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-compile-i386.git/arch/x86/Makefile
===
--- linux-compile-i386.git.orig/arch/x86/Makefile   2008-01-31 
21:00:44.0 -0500
+++ linux-compile-i386.git/arch/x86/Makefile2008-02-01 00:09:54.0 
-0500
@@ -143,7 +143,7 @@ mcore-$(CONFIG_X86_ES7000)  := arch/x86/m

 # RDC R-321x subarch support
 mflags-$(CONFIG_X86_RDC321X)   := -Iinclude/asm-x86/mach-rdc321x
-mcore-$(CONFIG_X86_RDC321X):= arch/x86/mach-default
+mcore-$(CONFIG_X86_RDC321X):= arch/x86/mach-default/
 core-$(CONFIG_X86_RDC321X) += arch/x86/mach-rdc321x/

 # default subarch .h files

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Feature Removals for 2.6.25 (USB driver api)

2008-01-31 Thread Greg KH
> ---
> Ping?
> What: USB driver API moves to EXPORT_SYMBOL_GPL
> When: February 2008
> Files:include/linux/usb.h, drivers/usb/core/driver.c
> Why:  The USB subsystem has changed a lot over time, and it has been
>   possible to create userspace USB drivers using usbfs/libusb/gadgetfs
>   that operate as fast as the USB bus allows.  Because of this, the USB
>   subsystem will not be allowing closed source kernel drivers to
>   register with it, after this grace period is over.  If anyone needs
>   any help in converting their closed source drivers over to use the
>   userspace filesystems, please contact the
>   [EMAIL PROTECTED] mailing list, and the developers
>   there will be glad to help you out.
> Who:  Greg Kroah-Hartman <[EMAIL PROTECTED]>

This is queued up in my tree to go to Linus, see my previous post on
lkml and the linux-usb mailing list about this topic.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] pci: Remove users of pci_enable_device_bars()

2008-01-31 Thread Greg KH
On Thu, Jan 31, 2008 at 04:14:45PM -0800, Andrew Vasquez wrote:
> On Tue, 08 Jan 2008, Benjamin Herrenschmidt wrote:
> 
> > On Mon, 2008-01-07 at 11:42 -0800, Andrew Vasquez wrote:
> > > That's fine.  I take it these patches will be funneled via
> > > gregkh/pci-2.6.git.  There's some qla2xxx updates which are queued for
> > > post-2.6.24 consumption in jejb/scsi-misc-2.6.git which don't appear
> > > to have any conflicts.
> > > 
> > > I do though have a series of patches which I'll hold off on submitting
> > > to linux-scsi until these PCI changes are merged, as there's some
> > > minor conflicts merging the three branches.  James B, will that be
> > > fine?
> > > 
> > > The patches themselves appear to be working fine within several of our
> > > test rings.  I hold off on some of the cleanup post-merge time...
> > 
> > Thanks for testing ! They should be queued with Greg indeed.
> 
> Just curious, this patch-set hasn't made it upstream to linux-2.6.git,
> will the work be deferred to 2.6.26??

It's less than one week into the merge window, and people are getting
worried, sheesh :)

Yes, this is queued up to go to Linus, been busy working on other issues
at the moment, don't worry, I'll make the window.  Hopefully get them
all out tomorrow...

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch 4/4] mmu_notifier: Support for driverws with revers maps (f.e. for XPmem)

2008-01-31 Thread Christoph Lameter
Support for an additional 3rd class of users of mmu_notifier.

These special additional callbacks are required because XPmem does
use its own rmap (multiple processes on a serires of remote Linux instances
may be accessing the memory of a process). XPmem may have to send out
notifications to remote Linux instances and receive confirmation before a
page can be freed.

So we handle this like an additional Linux reverse map that is walked after
the existing rmaps have been walked. We leave the walking to the driver that
is then able to use something else than a spinlock to walk its reverse
maps. So we can actually call the driver without holding spinlocks.

However, we cannot determine the mm_struct that a page belongs to. That
will have to be determined by the device driver. Therefore we need to
have a global list of reverse map callbacks.

We add another pageflag (PageExternalRmap) that is set if a page has
been remotely mapped (f.e. by a process from another Linux instance).
We can then only perform the callbacks for pages that are actually in
remote use.

Rmap notifiers need an extra page bit and are only available
on 64 bit platforms. This functionality is not available on 32 bit!

A notifier that uses the reverse maps callbacks does not need to provide
the invalidate_page() methods that are called when locks are held.

Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]>

---
 include/linux/mmu_notifier.h |   70 +--
 include/linux/page-flags.h   |   11 ++
 mm/mmu_notifier.c|   36 +-
 mm/rmap.c|9 +
 4 files changed, 123 insertions(+), 3 deletions(-)

Index: linux-2.6/include/linux/page-flags.h
===
--- linux-2.6.orig/include/linux/page-flags.h   2008-01-31 20:56:03.0 
-0800
+++ linux-2.6/include/linux/page-flags.h2008-01-31 21:00:40.0 
-0800
@@ -105,6 +105,7 @@
  * 64 bit  |   FIELDS | ?? FLAGS |
  * 6332  0
  */
+#define PG_external_rmap   30  /* Page has external rmap */
 #define PG_uncached31  /* Page has been mapped as uncached */
 #endif
 
@@ -260,6 +261,16 @@ static inline void __ClearPageTail(struc
 #define SetPageUncached(page)  set_bit(PG_uncached, &(page)->flags)
 #define ClearPageUncached(page)clear_bit(PG_uncached, &(page)->flags)
 
+#if defined(CONFIG_MMU_NOTIFIER) && defined(CONFIG_64BIT)
+#define PageExternalRmap(page) test_bit(PG_external_rmap, &(page)->flags)
+#define SetPageExternalRmap(page) set_bit(PG_external_rmap, &(page)->flags)
+#define ClearPageExternalRmap(page) clear_bit(PG_external_rmap, \
+   &(page)->flags)
+#else
+#define ClearPageExternalRmap(page) do {} while (0)
+#define PageExternalRmap(page) 0
+#endif
+
 struct page;   /* forward declaration */
 
 extern void cancel_dirty_page(struct page *page, unsigned int account_size);
Index: linux-2.6/include/linux/mmu_notifier.h
===
--- linux-2.6.orig/include/linux/mmu_notifier.h 2008-01-31 20:58:05.0 
-0800
+++ linux-2.6/include/linux/mmu_notifier.h  2008-01-31 21:00:40.0 
-0800
@@ -23,6 +23,18 @@
  * where sleeping is allowed or in atomic contexts. A flag is passed
  * to indicate an atomic context.
  *
+ *
+ * 2. mmu_rmap_notifier
+ *
+ * Callbacks for subsystems that provide their own rmaps. These
+ * need to walk their own rmaps for a page. The invalidate_page
+ * callback is outside of locks so that we are not in a strictly
+ * atomic context (but we may be in a PF_MEMALLOC context if the
+ * notifier is called from reclaim code) and are able to sleep.
+ *
+ * Rmap notifiers need an extra page bit and are only available
+ * on 64 bit platforms.
+ *
  * Pages must be marked dirty if dirty bits are found to be set in
  * the external ptes.
  */
@@ -89,8 +101,26 @@ struct mmu_notifier_ops {
 int atomic);
 
void (*invalidate_range_end)(struct mmu_notifier *mn,
-unsigned long stat, unsigned long end,
-struct mm_struct *mm, int atomic);
+struct mm_struct *mm,
+unsigned long start, unsigned long end,
+int atomic);
+};
+
+struct mmu_rmap_notifier_ops;
+
+struct mmu_rmap_notifier {
+   struct hlist_node hlist;
+   const struct mmu_rmap_notifier_ops *ops;
+};
+
+struct mmu_rmap_notifier_ops {
+   /*
+* Called with the page lock held after ptes are modified or removed
+* so that a subsystem with its own rmap's can remove remote ptes
+* mapping a page.
+*/
+   void (*invalidate_page)(struct 

Re: ndiswrapper and GPL-only symbols redux

2008-01-31 Thread Pavel Roskin
On Wed, 2008-01-30 at 15:53 -0500, Richard Stallman wrote:
> I don't know what the circumstances are in this case, since the
> description quoted was quite sketchy.  I suggest that someone send a
> clear description of the case to [EMAIL PROTECTED] to find out what
> GPLv2 implies about it.

I don't think anyone implies that there are any real copyright issues
with ndiswrapper, at least in the US.  With all differences in
intonations, everybody seems to understand that.

It's understandable that kernel developers feel uncomfortable about
ndiswrapper, which loads non-free Windows drivers into the kernel
memory.  It's understandable that kernel developers don't want to
support systems where such code has been running at any time.

It's understandable that ndiswrapper can be considered as an unwelcome
alternative to free drivers, although it's actually used for reverse
engineering and it allows to check that the unsupported hardware is
functional without having to boot to a non-free OS.  A kernel that did
something unsupportable becomes "tainted".

Unfortunately, the code for making ndiswrapper taint the kernel is
similar to the code that makes non-free modules (i.e. non-free software
specifically designed to work with Linux) taint the kernel.  That's why
is has happened for the second time already that ndiswrapper was lumped
together with non-free modules and disallowed to use certain kernel
facilities that were only meant for free software.

Even though it was done by mistake both times, it looked as an
intentional change every time.  It is an emotional issue, but it has
little to do with copyright issues and more with understandable
antipathy of the kernel developer towards non-free software running with
the kernel privileges.

I think the whole idea to bring you into the discussion was based on
misunderstanding of my use of the word "linking".  There is a difference
between compiling and linking a non-free program from the source code
against free headers and free libraries and loading non-free code and
making it work by emulating non-free interfaces with free software.

I was merely saying that the later is OK.  I was not advocating the
former.

> If my message does not appear on linux-kernel@vger.kernel.org,
> would one of you please forward it?

It did appear on the list.

> It is not in general the case that "dynamic linking cannot violate the
> GPL".  It depends on circumstances.  Running a non-free program in a
> process in a GNU/Linux system is not linking of any kind with Linux.
> The program probably links with GNU libc, but the license of GNU libc
> permits that.

A better analogy would be running a non-free program in a free emulator.

I don't have any issues with ndiswrapper.  If anyone does, they should
write to FSF, or maybe to FSF Europe if the concern are about European
laws.

-- 
Regards,
Pavel Roskin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch 2/4] mmu_notifier: Callbacks to invalidate address ranges

2008-01-31 Thread Christoph Lameter
The invalidation of address ranges in a mm_struct needs to be
performed when pages are removed or permissions etc change.

invalidate_range_begin/end() is frequently called with only mmap_sem
held. If invalidate_range_begin() is called with locks held then we
pass a flag into invalidate_range() to indicate that no sleeping is
possible.

In two cases we use invalidate_range_begin/end to invalidate
single pages because the pair allows holding off new references
(idea by Robin Holt).

do_wp_page(): We hold off new references while update the pte.

xip_unmap: We are not taking the PageLock so we cannot
use the invalidate_page mmu_rmap_notifier. invalidate_range_begin/end
stands in.

Comments state that mmap_sem must be held for
remap_pfn_range() but various drivers do not seem to do this.

Signed-off-by: Andrea Arcangeli <[EMAIL PROTECTED]>
Signed-off-by: Robin Holt <[EMAIL PROTECTED]>
Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]>

---
 mm/filemap_xip.c |5 +
 mm/fremap.c  |3 +++
 mm/hugetlb.c |3 +++
 mm/memory.c  |   24 ++--
 mm/mmap.c|2 ++
 mm/mremap.c  |7 ++-
 6 files changed, 41 insertions(+), 3 deletions(-)

Index: linux-2.6/mm/fremap.c
===
--- linux-2.6.orig/mm/fremap.c  2008-01-31 20:56:03.0 -0800
+++ linux-2.6/mm/fremap.c   2008-01-31 20:59:14.0 -0800
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -211,7 +212,9 @@ asmlinkage long sys_remap_file_pages(uns
spin_unlock(>i_mmap_lock);
}
 
+   mmu_notifier(invalidate_range_begin, mm, start, start + size, 0);
err = populate_range(mm, vma, start, size, pgoff);
+   mmu_notifier(invalidate_range_end, mm, start, start + size, 0);
if (!err && !(flags & MAP_NONBLOCK)) {
if (unlikely(has_write_lock)) {
downgrade_write(>mmap_sem);
Index: linux-2.6/mm/memory.c
===
--- linux-2.6.orig/mm/memory.c  2008-01-31 20:56:03.0 -0800
+++ linux-2.6/mm/memory.c   2008-01-31 20:59:14.0 -0800
@@ -50,6 +50,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -601,6 +602,9 @@ int copy_page_range(struct mm_struct *ds
if (is_vm_hugetlb_page(vma))
return copy_hugetlb_page_range(dst_mm, src_mm, vma);
 
+   if (is_cow_mapping(vma->vm_flags))
+   mmu_notifier(invalidate_range_begin, src_mm, addr, end, 0);
+
dst_pgd = pgd_offset(dst_mm, addr);
src_pgd = pgd_offset(src_mm, addr);
do {
@@ -611,6 +615,11 @@ int copy_page_range(struct mm_struct *ds
vma, addr, next))
return -ENOMEM;
} while (dst_pgd++, src_pgd++, addr = next, addr != end);
+
+   if (is_cow_mapping(vma->vm_flags))
+   mmu_notifier(invalidate_range_end, src_mm,
+   vma->vm_start, end, 0);
+
return 0;
 }
 
@@ -883,13 +892,16 @@ unsigned long zap_page_range(struct vm_a
struct mmu_gather *tlb;
unsigned long end = address + size;
unsigned long nr_accounted = 0;
+   int atomic = details ? (details->i_mmap_lock != 0) : 0;
 
lru_add_drain();
tlb = tlb_gather_mmu(mm, 0);
update_hiwater_rss(mm);
+   mmu_notifier(invalidate_range_begin, mm, address, end, atomic);
end = unmap_vmas(, vma, address, end, _accounted, details);
if (tlb)
tlb_finish_mmu(tlb, address, end);
+   mmu_notifier(invalidate_range_end, mm, address, end, atomic);
return end;
 }
 
@@ -1318,7 +1330,7 @@ int remap_pfn_range(struct vm_area_struc
 {
pgd_t *pgd;
unsigned long next;
-   unsigned long end = addr + PAGE_ALIGN(size);
+   unsigned long start = addr, end = addr + PAGE_ALIGN(size);
struct mm_struct *mm = vma->vm_mm;
int err;
 
@@ -1352,6 +1364,7 @@ int remap_pfn_range(struct vm_area_struc
pfn -= addr >> PAGE_SHIFT;
pgd = pgd_offset(mm, addr);
flush_cache_range(vma, addr, end);
+   mmu_notifier(invalidate_range_begin, mm, start, end, 0);
do {
next = pgd_addr_end(addr, end);
err = remap_pud_range(mm, pgd, addr, next,
@@ -1359,6 +1372,7 @@ int remap_pfn_range(struct vm_area_struc
if (err)
break;
} while (pgd++, addr = next, addr != end);
+   mmu_notifier(invalidate_range_end, mm, start, end, 0);
return err;
 }
 EXPORT_SYMBOL(remap_pfn_range);
@@ -1442,10 +1456,11 @@ int apply_to_page_range(struct mm_struct
 {
pgd_t *pgd;
unsigned long next;
-   unsigned long end = addr + size;
+   unsigned long start = addr, end = addr + size;
int err;
 
BUG_ON(addr >= end);
+   

[patch 1/4] mmu_notifier: Core code

2008-01-31 Thread Christoph Lameter
Notifier functions for hardware and software that establishes external
references to pages of a Linux system. The notifier calls ensure that
external mappings are removed when the Linux VM removes memory ranges
or individual pages from a process.

This first portion is fitting for external mmu's that do not have their
own rmap or need the ability to sleep before removing individual pages.

Two categories of external mmus are possible:

1. KVM style external mmus that have their own page table.
   These are capable of tracking pages in their page tables and
   can therefore increase the refcount on pages. An increased
   refcount guarantees page existence regardless of the vms unmapping
   actions until the logic in the notifier call decides to drop a page.

2. GRU style external mmus that rely on the Linux page table for TLB lookups.
   These cannot track pages that are externally references.
   TLB entries can only be evicted as necessary.


Callbacks are registered with an mm_struct from a device drivers using
mmu_notifier_register. When the VM removes pages (or restricts
permissions on pages) then callbacks are triggered

The VM holds spinlocks in order to walk reverse maps in rmap.c. The single
page callback invalidate_page() is therefore always run with
spinlocks held (which limits what can be done in the callbacks).

The invalidate_range_start/end callbacks can be run in atomic as well as
sleepable contexts. A flag is passed to indicate an atomic context.
The notifier may decide to defer actions if the context is atomic.

Pages must be marked dirty if dirty bits are found to be set in
the external ptes.

Requirements on synchronization within the driver:

 Multiple invalidate_range_begin/ends may be nested or called
 concurrently. That is legit. However, no new external references
 may be established as long as any invalidate_xxx is running or as long
 as any invalidate_range_begin() and has not been completed through a
 corresponding call to invalidate_range_end().

 Locking within the notifier callbacks needs to serialize events
 correspondingly. One simple implementation would be the use of a spinlock
 that needs to be acquired for access to the page table or tlb managed by
 the driver. A rw lock could be used to allow multiplel concurrent 
invalidates
 to run but then the driver needs to have additional internal 
synchronization
 for access to hardware resources.

 If all invalidate_xx notifier calls take the driver lock then it is 
possible
 to run follow_page() under the same lock. The lock can then guarantee
 that no page is removed and provides an additional existence guarantee
 of the page independent of the page count.

 invalidate_range_begin() must clear all references in the range
 and stop the establishment of new references.

 invalidate_range_end() reenables the establishment of references.
 The atomic paramater passed to invalidatge_range_xx indicates that the 
function
 is called in an atomic context. We can sleep if atomic == 0.

Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]>
Signed-off-by: Andrea Arcangeli <[EMAIL PROTECTED]>

---
 include/linux/mm_types.h |8 +
 include/linux/mmu_notifier.h |  179 +++
 kernel/fork.c|2 
 mm/Kconfig   |4 
 mm/Makefile  |1 
 mm/mmap.c|2 
 mm/mmu_notifier.c|   76 ++
 7 files changed, 272 insertions(+)

Index: linux-2.6/include/linux/mm_types.h
===
--- linux-2.6.orig/include/linux/mm_types.h 2008-01-31 19:55:46.0 
-0800
+++ linux-2.6/include/linux/mm_types.h  2008-01-31 19:59:51.0 -0800
@@ -153,6 +153,12 @@ struct vm_area_struct {
 #endif
 };
 
+struct mmu_notifier_head {
+#ifdef CONFIG_MMU_NOTIFIER
+   struct hlist_head head;
+#endif
+};
+
 struct mm_struct {
struct vm_area_struct * mmap;   /* list of VMAs */
struct rb_root mm_rb;
@@ -219,6 +225,8 @@ struct mm_struct {
/* aio bits */
rwlock_tioctx_list_lock;
struct kioctx   *ioctx_list;
+
+   struct mmu_notifier_head mmu_notifier; /* MMU notifier list */
 };
 
 #endif /* _LINUX_MM_TYPES_H */
Index: linux-2.6/include/linux/mmu_notifier.h
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6/include/linux/mmu_notifier.h  2008-01-31 20:56:03.0 
-0800
@@ -0,0 +1,179 @@
+#ifndef _LINUX_MMU_NOTIFIER_H
+#define _LINUX_MMU_NOTIFIER_H
+
+/*
+ * MMU motifier
+ *
+ * Notifier functions for hardware and software that establishes external
+ * references to pages of a Linux system. The notifier calls ensure that
+ * external mappings are removed when the Linux VM removes memory ranges
+ * or individual pages from a 

[patch 3/4] mmu_notifier: invalidate_page callbacks

2008-01-31 Thread Christoph Lameter
Two callbacks to remove individual pages as done in rmap code

invalidate_page()

Called from the inner loop of rmap walks to invalidate pages.

age_page()

Called for the determination of the page referenced status.

If we do not care about page referenced status then an age_page callback
may be be omitted.

Signed-off-by: Christoph Lameter <[EMAIL PROTECTED]>
Signed-off-by: Robin Holt <[EMAIL PROTECTED]>

---
 mm/rmap.c |   13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Index: linux-2.6/mm/rmap.c
===
--- linux-2.6.orig/mm/rmap.c2008-01-31 19:55:45.0 -0800
+++ linux-2.6/mm/rmap.c 2008-01-31 20:28:35.0 -0800
@@ -49,6 +49,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -284,7 +285,8 @@ static int page_referenced_one(struct pa
if (!pte)
goto out;
 
-   if (ptep_clear_flush_young(vma, address, pte))
+   if (ptep_clear_flush_young(vma, address, pte) |
+   mmu_notifier_age_page(mm, address))
referenced++;
 
/* Pretend the page is referenced if the task has the
@@ -434,6 +436,7 @@ static int page_mkclean_one(struct page 
 
flush_cache_page(vma, address, pte_pfn(*pte));
entry = ptep_clear_flush(vma, address, pte);
+   mmu_notifier(invalidate_page, mm, address);
entry = pte_wrprotect(entry);
entry = pte_mkclean(entry);
set_pte_at(mm, address, pte, entry);
@@ -677,7 +680,8 @@ static int try_to_unmap_one(struct page 
 * skipped over this mm) then we should reactivate it.
 */
if (!migration && ((vma->vm_flags & VM_LOCKED) ||
-   (ptep_clear_flush_young(vma, address, pte {
+   (ptep_clear_flush_young(vma, address, pte) |
+   mmu_notifier_age_page(mm, address {
ret = SWAP_FAIL;
goto out_unmap;
}
@@ -685,6 +689,7 @@ static int try_to_unmap_one(struct page 
/* Nuke the page table entry. */
flush_cache_page(vma, address, page_to_pfn(page));
pteval = ptep_clear_flush(vma, address, pte);
+   mmu_notifier(invalidate_page, mm, address);
 
/* Move the dirty bit to the physical page now the pte is gone. */
if (pte_dirty(pteval))
@@ -809,12 +814,14 @@ static void try_to_unmap_cluster(unsigne
page = vm_normal_page(vma, address, *pte);
BUG_ON(!page || PageAnon(page));
 
-   if (ptep_clear_flush_young(vma, address, pte))
+   if (ptep_clear_flush_young(vma, address, pte) |
+   mmu_notifier_age_page(mm, address))
continue;
 
/* Nuke the page table entry. */
flush_cache_page(vma, address, pte_pfn(*pte));
pteval = ptep_clear_flush(vma, address, pte);
+   mmu_notifier(invalidate_page, mm, address);
 
/* If nonlinear, store the file page offset in the pte. */
if (page->index != linear_page_index(vma, address))

-- 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: There are smaller ways to encode a CRC32 table...

2008-01-31 Thread H. Peter Anvin

George Spelvin wrote:

The code to fill it in is smaller than the table itself.
Is it worth complicating things with some INIT code to reduce
the stored image size?  (The table is not compressible.)


I think it matters not at all either way.

-hpa

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch 0/4] [RFC] EMMU Notifiers V5

2008-01-31 Thread Christoph Lameter
This is a patchset implementing MMU notifier callbacks based on Andrea's
earlier work. These are needed if Linux pages are referenced from something
else than tracked by the rmaps of the kernel (an external MMU).

The known immediate users are

KVM
- Establishes a refcount to the page via get_user_pages().
- External references are called spte.
- Has page tables to track pages whose refcount was elevated(?) but
  no reverse maps.

GRU
- Simple additional hardware TLB (possibly covering multiple instances of
  Linux)
- Needs TLB shootdown when the VM unmaps pages.
- Determines page address via follow_page (from interrupt context) but can
  fall back to get_user_pages().
- No page reference possible since no page status is kept..

XPmem
- Allows use of a processes memory by remote instances of Linux.
- Provides its own reverse mappings to track remote pte.
- Established refcounts on the exported pages.
- Must sleep in order to wait for remote acks of ptes that are being
  cleared.



Known issues:

- RCU quiescent periods are required on registering
  notifiers to guarantee visibility to other processors.

Andrea's mmu_notifier #4 -> RFC V1

- Merge subsystem rmap based with Linux rmap based approach
- Move Linux rmap based notifiers out of macro
- Try to account for what locks are held while the notifiers are
  called.
- Develop a patch sequence that separates out the different types of
  hooks so that we can review their use.
- Avoid adding include to linux/mm_types.h
- Integrate RCU logic suggested by Peter.

V1->V2:
- Improve RCU support
- Use mmap_sem for mmu_notifier register / unregister
- Drop invalidate_page from COW, mm/fremap.c and mm/rmap.c since we
  already have invalidate_range() callbacks there.
- Clean compile for !MMU_NOTIFIER
- Isolate filemap_xip strangeness into its own diff
- Pass a the flag to invalidate_range to indicate if a spinlock
  is held.
- Add invalidate_all()

V2->V3:
- Further RCU fixes
- Fixes from Andrea to fixup aging and move invalidate_range() in do_wp_page
  and sys_remap_file_pages() after the pte clearing.

V3->V4:
- Drop locking and synchronize_rcu() on ->release since we know on release that
  we are the only executing thread. This is also true for invalidate_all() so
  we could drop off the mmu_notifier there early. Use hlist_del_init instead
  of hlist_del_rcu.
- Do the invalidation as begin/end pairs with the requirement that the driver
  holds off new references in between.
- Fixup filemap_xip.c
- Figure out a potential way in which XPmem can deal with locks that are held.
- Robin's patches to make the mmu_notifier logic manage the PageRmapExported 
bit.
- Strip cc list down a bit.
- Drop Peters new rcu list macro
- Add description to the core patch

V4->V5:
- Provide missing callouts for mremap.
- Provide missing callouts for copy_page_range.
- Reduce mm_struct space to zero if !MMU_NOTIFIER by #ifdeffing out
  structure contents.
- Get rid of the invalidate_all() callback by moving ->release in place
  of invalidate_all.
- Require holding mmap_sem on register/unregister instead of acquiring it
  ourselves. In some contexts where we want to register/unregister we are
  already holding mmap_sem.
- Split out the rmap support patch so that there is no need to apply
  all patches for KVM and GRU.

-- 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH powerpc] Fake NUMA emulation for PowerPC (Take 4)

2008-01-31 Thread Balbir Singh
* Michael Ellerman <[EMAIL PROTECTED]> [2008-01-30 00:04:58]:

> Why do you check !p after assigning to nid? I assume it's because we
> might have reached the end of the command line, ie. p == NULL, but we're
> still adding memory to the last node? If so it's a it's a little subtle
> and deserves a comment I think.
> 
> Otherwise this looks pretty good.
> 
> cheers
> 

Hi, Paul,

Could you please consider version 4 for inclusion?


Changelong v4

1. Add more comments around the checks for command line arguments.

Changelog v3
1. Remove the side-effect of not setting nodes online if they end
   up having no memory in them because of the memory limit.

Changelog v2

1. Get rid of the constant 5 (based on comments from
[EMAIL PROTECTED])
2. Implement suggestions from Olof Johannson
3. Check if cmdline is NULL in fake_numa_create_new_node()

Tested with additional parameters from Olof

numa=debug,fake=
numa=foo,fake=bar


Here's a dumb simple implementation of fake NUMA nodes for PowerPC. Fake
NUMA nodes can be specified using the following command line option

numa=fake=

node range is of the format ,,...

Each of the rangeX parameters is passed using memparse(). I find the patch
useful for fake NUMA emulation on my simple PowerPC machine. I've tested it
on a numa box with the following arguments

numa=fake=512M
numa=fake=512M,768M
numa=fake=256M,512M mem=512M
numa=fake=1G mem=768M
numa=fake=
without any numa= argument

The other side-effect introduced by this patch is that; in the case where we
don't have NUMA information, we now set a node online after adding each LMB.
This node could very well be node 0, but in the case that we enable fake
NUMA nodes, when we cross node boundaries, we need to set the new node online.


Signed-off-by: Balbir Singh <[EMAIL PROTECTED]>
---

 arch/powerpc/mm/numa.c |   66 ++---
 1 file changed, 63 insertions(+), 3 deletions(-)

diff -puN arch/powerpc/mm/numa.c~fakenumappc arch/powerpc/mm/numa.c
--- linux-2.6.24-rc8/arch/powerpc/mm/numa.c~fakenumappc 2008-01-28 
17:05:34.0 +0530
+++ linux-2.6.24-rc8-balbir/arch/powerpc/mm/numa.c  2008-02-01 
10:24:57.0 +0530
@@ -24,6 +24,8 @@
 
 static int numa_enabled = 1;
 
+static char *cmdline __initdata;
+
 static int numa_debug;
 #define dbg(args...) if (numa_debug) { printk(KERN_INFO args); }
 
@@ -39,6 +41,53 @@ static bootmem_data_t __initdata plat_no
 static int min_common_depth;
 static int n_mem_addr_cells, n_mem_size_cells;
 
+static int __cpuinit fake_numa_create_new_node(unsigned long end_pfn,
+   unsigned int *nid)
+{
+   unsigned long long mem;
+   char *p = cmdline;
+   static unsigned int fake_nid;
+   static unsigned long long curr_boundary;
+
+   /*
+* Modify node id, iff we started creating NUMA nodes
+* We want to continue from where we left of the last time
+*/
+   if (fake_nid)
+   *nid = fake_nid;
+   /*
+* In case there are no more arguments to parse, the
+* node_id should be the same as the last fake node id
+* (we've handled this above).
+*/
+   if (!p)
+   return 0;
+
+   mem = memparse(p, );
+   if (!mem)
+   return 0;
+
+   if (mem < curr_boundary)
+   return 0;
+
+   curr_boundary = mem;
+
+   if ((end_pfn << PAGE_SHIFT) > mem) {
+   /*
+* Skip commas and spaces
+*/
+   while (*p == ',' || *p == ' ' || *p == '\t')
+   p++;
+
+   cmdline = p;
+   fake_nid++;
+   *nid = fake_nid;
+   dbg("created new fake_node with id %d\n", fake_nid);
+   return 1;
+   }
+   return 0;
+}
+
 static void __cpuinit map_cpu_to_node(int cpu, int node)
 {
numa_cpu_lookup_table[cpu] = node;
@@ -344,6 +393,9 @@ static void __init parse_drconf_memory(s
if (nid == 0x || nid >= MAX_NUMNODES)
nid = default_nid;
}
+
+   fake_numa_create_new_node(((start + lmb_size) >> PAGE_SHIFT),
+   );
node_set_online(nid);
 
size = numa_enforce_memory_limit(start, lmb_size);
@@ -429,6 +481,8 @@ new_range:
nid = of_node_to_nid_single(memory);
if (nid < 0)
nid = default_nid;
+
+   fake_numa_create_new_node(((start + size) >> PAGE_SHIFT), );
node_set_online(nid);
 
if (!(size = numa_enforce_memory_limit(start, size))) {
@@ -461,7 +515,7 @@ static void __init setup_nonnuma(void)
unsigned long top_of_ram = lmb_end_of_DRAM();
unsigned long total_ram = lmb_phys_mem_size();
unsigned long start_pfn, end_pfn;
-   unsigned int i;
+   

Re: missing asm-x86_64 detection

2008-01-31 Thread H. Peter Anvin

Reinaldo Carvalho wrote:

:/# uname -a
Linux devil 2.6.22.16-amd64 #15 SMP Sat Jan 19 13:58:02 BRT 2008
x86_64 GNU/Linux

:/# cd /usr/src/linux-2.6.22
:/# patch -p1 -R < ../patch-2.6.22.16
:/# patch -p1 < ../patch-2.6.23
:/# patch -p1 < ../patch-2.6.24
:/# cd /usr/src/ ; mv linux-2.6.22 linux-2.6.24; cd linux-2.6.24
:/usr/src/linux-2.6.24# make oldconfig
:/usr/src/linux-2.6.24# make all
  CHK include/linux/version.h
  CHK include/linux/utsrelease.h
ERROR: the symlink include/asm points to asm-x86_64 but asm-x86 was expected
   set ARCH or save .config and run 'make mrproper' to fix it
make: ** [include/asm] Erro 1



"make mrproper" please.

-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: how to tell i386 from x86-64 kernel

2008-01-31 Thread H. Peter Anvin

Pavel Machek wrote:

Hi!

Quiz: on a booted system, how do you tell 32bit from 64bit kernel?

A1: zcat /proc/config.gz | grep CONFIG_64

...but config.gz is optional

A2: cat /proc/meminfo  | grep High

...but i386 kernel could have highmem disabled

What is _your_ answer? ;-)>
Pavel


uname -m

-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: missing asm-x86_64 detection

2008-01-31 Thread Lee Revell
On Jan 31, 2008 6:13 PM, Reinaldo Carvalho <[EMAIL PROTECTED]> wrote:
> system is x86_64!
>
> :/# grep model\ name /proc/cpuinfo
> model name  : AMD Turion(tm) 64 X2
> model name  : AMD Turion(tm) 64 X2

What does "head -20 /usr/src/config-2.6.24" say?

Lee
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Feature Removals for 2.6.25

2008-01-31 Thread Arjan van de Ven


---

What:   CONFIG_FORCED_INLINING
When:   June 2006
Why:Config option is there to see if gcc is good enough. (in january
2006). If it is, the behavior should just be the default. If it's not,
the option should just go away entirely.
Who:Arjan van de Ven

Patch submitted to Arjan, maybe 2.6.25?


Ingo picked it up, but no rush for .25, .26 is fine for this as well



What:   Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports
(temporary transition config option provided until then)
The transition config option will also be removed at the same time.
When:   before 2.6.19
Why:Unused symbols are both increasing the size of the kernel binary
and are often a sign of "wrong API"
Who:Arjan van de Ven <[EMAIL PROTECTED]>


this is an ongoing work; symbols get marked unused and then garbage collected
when they're due; for example akpm has several of that kind in his pile right 
now
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


There are smaller ways to encode a CRC32 table...

2008-01-31 Thread George Spelvin
The code to fill it in is smaller than the table itself.
Is it worth complicating things with some INIT code to reduce
the stored image size?  (The table is not compressible.)

#define CRC32POLY   0xedb88320  /* CRC32 polynomial, little-endian */

static uint32_t crctab32[256];

void
crc32init(void)
{
unsigned i, j;
uint32_t crc = 1;

crctab32[0] = 0;

for (i = 128; i; i >>= 1) {
crc = (crc >> 1) ^ ((crc & 1) ? CRC32POLY : 0);
for (j = 0; j < 256; j += 2*i)
crctab32[i+j] = crc ^ crctab32[j];
}
}

The above code basically computes the CRCs of the bytes 0x80, 0x40, ... 0x01,
and applies the identity crctab32[i^j] = crctab32[i] ^ crctab32[j].

And BTW, storing the inverse of the CRC only catches trailing (after the CRC)
all-zero padding.  If this is not a problem, it's not necessary, although you
still might want to do it just for consistency.  This inversion changes the
CRC of the entire image (body + CRC) from all-zero to a fixed non-zero value.
(To be precise, to the (non-inverted) CRC of 0x.)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/37] Hibernation: Correct definitions of some ioctls (rev. 2)

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Three ioctl numbers belonging to the hibernation userland interface,
SNAPSHOT_ATOMIC_SNAPSHOT, SNAPSHOT_AVAIL_SWAP, SNAPSHOT_GET_SWAP_PAGE,
are defined in a wrong way (eg. not portable).  Provide new ioctl numbers for
these ioctls and mark the existing ones as deprecated.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 Documentation/power/userland-swsusp.txt |   26 +-
 kernel/power/power.h|   10 +-
 kernel/power/user.c |   18 --
 3 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/Documentation/power/userland-swsusp.txt 
b/Documentation/power/userland-swsusp.txt
index 0785500..af52d53 100644
--- a/Documentation/power/userland-swsusp.txt
+++ b/Documentation/power/userland-swsusp.txt
@@ -27,17 +27,17 @@ once at a time.
 The ioctl() commands recognized by the device are:
 
 SNAPSHOT_FREEZE - freeze user space processes (the current process is
-   not frozen); this is required for SNAPSHOT_ATOMIC_SNAPSHOT
+   not frozen); this is required for SNAPSHOT_CREATE_IMAGE
and SNAPSHOT_ATOMIC_RESTORE to succeed
 
 SNAPSHOT_UNFREEZE - thaw user space processes frozen by SNAPSHOT_FREEZE
 
-SNAPSHOT_ATOMIC_SNAPSHOT - create a snapshot of the system memory; the
+SNAPSHOT_CREATE_IMAGE - create a snapshot of the system memory; the
last argument of ioctl() should be a pointer to an int variable,
the value of which will indicate whether the call returned after
creating the snapshot (1) or after restoring the system memory state
from it (0) (after resume the system finds itself finishing the
-   SNAPSHOT_ATOMIC_SNAPSHOT ioctl() again); after the snapshot
+   SNAPSHOT_CREATE_IMAGE ioctl() again); after the snapshot
has been created the read() operation can be used to transfer
it out of the kernel
 
@@ -49,23 +49,23 @@ SNAPSHOT_ATOMIC_RESTORE - restore the system memory state 
from the
 
 SNAPSHOT_FREE - free memory allocated for the snapshot image
 
-SNAPSHOT_SET_IMAGE_SIZE - set the preferred maximum size of the image
+SNAPSHOT_PREF_IMAGE_SIZE - set the preferred maximum size of the image
(the kernel will do its best to ensure the image size will not exceed
this number, but if it turns out to be impossible, the kernel will
create the smallest image possible)
 
 SNAPSHOT_GET_IMAGE_SIZE - return the actual size of the hibernation image
 
-SNAPSHOT_AVAIL_SWAP - return the amount of available swap in bytes (the last
-   argument should be a pointer to an unsigned int variable that will
+SNAPSHOT_AVAIL_SWAP_SIZE - return the amount of available swap in bytes (the
+   last argument should be a pointer to an unsigned int variable that will
contain the result if the call is successful).
 
-SNAPSHOT_GET_SWAP_PAGE - allocate a swap page from the resume partition
+SNAPSHOT_ALLOC_SWAP_PAGE - allocate a swap page from the resume partition
(the last argument should be a pointer to a loff_t variable that
will contain the swap page offset if the call is successful)
 
-SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated with
-   SNAPSHOT_GET_SWAP_PAGE
+SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated by
+   SNAPSHOT_ALLOC_SWAP_PAGE
 
 SNAPSHOT_SET_SWAP_AREA - set the resume partition and the offset (in 

units) from the beginning of the partition at which the swap header is
@@ -102,7 +102,7 @@ The device's write() operation is used for uploading the 
system memory snapshot
 into the kernel.  It has the same limitations as the read() operation.
 
 The release() operation frees all memory allocated for the snapshot image
-and all swap pages allocated with SNAPSHOT_GET_SWAP_PAGE (if any).
+and all swap pages allocated with SNAPSHOT_ALLOC_SWAP_PAGE (if any).
 Thus it is not necessary to use either SNAPSHOT_FREE or
 SNAPSHOT_FREE_SWAP_PAGES before closing the device (in fact it will also
 unfreeze user space processes frozen by SNAPSHOT_UNFREEZE if they are
@@ -113,7 +113,7 @@ snapshot image from/to the kernel will use a swap parition, 
called the resume
 partition, or a swap file as storage space (if a swap file is used, the resume
 partition is the partition that holds this file).  However, this is not really
 required, as they can use, for example, a special (blank) suspend partition or
-a file on a partition that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and
+a file on a partition that is unmounted before SNAPSHOT_CREATE_IMAGE and
 mounted afterwards.
 
 These utilities MUST NOT make any assumptions regarding the ordering of
@@ -135,7 +135,7 @@ means, such as checksums, to ensure the integrity of the 
snapshot image.
 The suspending and resuming utilities MUST lock themselves in memory,
 preferrably using mlockall(), before calling 

Re: [patch 2/3] mmu_notifier: Callbacks to invalidate address ranges

2008-01-31 Thread Christoph Lameter
On Thu, 31 Jan 2008, Robin Holt wrote:

> > Index: linux-2.6/mm/memory.c
> ...
> > @@ -1668,6 +1678,7 @@ gotten:
> > page_cache_release(old_page);
> >  unlock:
> > pte_unmap_unlock(page_table, ptl);
> > +   mmu_notifier(invalidate_range_end, mm, 0);
> 
> I think we can get an _end call without the _begin call before it.

If that would be true then also the pte would have been left locked.

We always hit unlock. Maybe I just do not see it?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 18/37] Hibernation: Fix comment in disk.c

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Fix a comment in kernel/power/disk.c so that it doesn't contain lines
longer that 80 characters.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 kernel/power/disk.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 2a4bada..3e24a20 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -568,8 +568,8 @@ static int software_resume(void)
 
if (noresume) {
/**
-* FIXME: If noresume is specified, we need to find the 
partition
-* and reset it back to normal swap space.
+* FIXME: If noresume is specified, we need to find the
+* partition and reset it back to normal swap space.
 */
mutex_unlock(_mutex);
return 0;
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/37] Hibernation: Introduce exportable suspend ioctls header (rev. 2)

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Move the definitions of hibernation ioctls to a separate header file in
include/linux, which can be exported to the user space.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 Documentation/power/userland-swsusp.txt |   10 
 include/linux/Kbuild|1 +
 include/linux/suspend_ioctls.h  |   32 +++
 kernel/power/power.h|   29 +---
 4 files changed, 39 insertions(+), 33 deletions(-)
 create mode 100644 include/linux/suspend_ioctls.h

diff --git a/Documentation/power/userland-swsusp.txt 
b/Documentation/power/userland-swsusp.txt
index af52d53..7b99636 100644
--- a/Documentation/power/userland-swsusp.txt
+++ b/Documentation/power/userland-swsusp.txt
@@ -14,7 +14,7 @@ are going to develop your own suspend/resume utilities.
 
 The interface consists of a character device providing the open(),
 release(), read(), and write() operations as well as several ioctl()
-commands defined in kernel/power/power.h.  The major and minor
+commands defined in include/linux/suspend_ioctls.h .  The major and minor
 numbers of the device are, respectively, 10 and 231, and they can
 be read from /sys/class/misc/snapshot/dev.
 
@@ -70,10 +70,10 @@ SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated by
 SNAPSHOT_SET_SWAP_AREA - set the resume partition and the offset (in 

units) from the beginning of the partition at which the swap header is
located (the last ioctl() argument should point to a struct
-   resume_swap_area, as defined in kernel/power/power.h, containing the
-   resume device specification and the offset); for swap partitions the
-   offset is always 0, but it is different from zero for swap files (see
-   Documentation/swsusp-and-swap-files.txt for details).
+   resume_swap_area, as defined in kernel/power/suspend_ioctls.h,
+   containing the resume device specification and the offset); for swap
+   partitions the offset is always 0, but it is different from zero for
+   swap files (see Documentation/swsusp-and-swap-files.txt for details).
 
 SNAPSHOT_PLATFORM_SUPPORT - enable/disable the hibernation platform support,
depending on the argument value (enable, if the argument is nonzero)
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 85b2482..c0f9bb7 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -143,6 +143,7 @@ header-y += snmp.h
 header-y += sockios.h
 header-y += som.h
 header-y += sound.h
+header-y += suspend_ioctls.h
 header-y += taskstats.h
 header-y += telephony.h
 header-y += termios.h
diff --git a/include/linux/suspend_ioctls.h b/include/linux/suspend_ioctls.h
new file mode 100644
index 000..2c6faec
--- /dev/null
+++ b/include/linux/suspend_ioctls.h
@@ -0,0 +1,32 @@
+#ifndef _LINUX_SUSPEND_IOCTLS_H
+#define _LINUX_SUSPEND_IOCTLS_H
+
+/*
+ * This structure is used to pass the values needed for the identification
+ * of the resume swap area from a user space to the kernel via the
+ * SNAPSHOT_SET_SWAP_AREA ioctl
+ */
+struct resume_swap_area {
+   loff_t offset;
+   u_int32_t dev;
+} __attribute__((packed));
+
+#define SNAPSHOT_IOC_MAGIC '3'
+#define SNAPSHOT_FREEZE_IO(SNAPSHOT_IOC_MAGIC, 1)
+#define SNAPSHOT_UNFREEZE  _IO(SNAPSHOT_IOC_MAGIC, 2)
+#define SNAPSHOT_ATOMIC_RESTORE_IO(SNAPSHOT_IOC_MAGIC, 4)
+#define SNAPSHOT_FREE  _IO(SNAPSHOT_IOC_MAGIC, 5)
+#define SNAPSHOT_FREE_SWAP_PAGES   _IO(SNAPSHOT_IOC_MAGIC, 9)
+#define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11)
+#define SNAPSHOT_SET_SWAP_AREA _IOW(SNAPSHOT_IOC_MAGIC, 13, \
+   struct resume_swap_area)
+#define SNAPSHOT_GET_IMAGE_SIZE_IOR(SNAPSHOT_IOC_MAGIC, 14, 
loff_t)
+#define SNAPSHOT_PLATFORM_SUPPORT  _IO(SNAPSHOT_IOC_MAGIC, 15)
+#define SNAPSHOT_POWER_OFF _IO(SNAPSHOT_IOC_MAGIC, 16)
+#define SNAPSHOT_CREATE_IMAGE  _IOW(SNAPSHOT_IOC_MAGIC, 17, int)
+#define SNAPSHOT_PREF_IMAGE_SIZE   _IO(SNAPSHOT_IOC_MAGIC, 18)
+#define SNAPSHOT_AVAIL_SWAP_SIZE   _IOR(SNAPSHOT_IOC_MAGIC, 19, loff_t)
+#define SNAPSHOT_ALLOC_SWAP_PAGE   _IOR(SNAPSHOT_IOC_MAGIC, 20, loff_t)
+#define SNAPSHOT_IOC_MAXNR 20
+
+#endif /* _LINUX_SUSPEND_IOCTLS_H */
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 0dd66fa..ef90605 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -1,4 +1,5 @@
 #include 
+#include 
 #include 
 
 struct swsusp_info {
@@ -134,34 +135,6 @@ extern int snapshot_write_next(struct snapshot_handle 
*handle, size_t count);
 extern void snapshot_write_finalize(struct snapshot_handle *handle);
 extern int snapshot_image_loaded(struct snapshot_handle *handle);
 
-/*
- * This structure is 

[PATCH 16/37] Hibernation: Move low level resume to disk.c

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Move the low level restore code to kernel/power/disk.c , since the
corresponding low level hibernation code is already there.

Make restore fail if device_power_down(PMSG_PRETHAW) returns an
error.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 kernel/power/disk.c   |   49 -
 kernel/power/power.h  |1 -
 kernel/power/swsusp.c |   35 ---
 3 files changed, 48 insertions(+), 37 deletions(-)

diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 0866b16..2a4bada 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -275,6 +275,53 @@ int hibernation_snapshot(int platform_mode)
 }
 
 /**
+ * resume_target_kernel - prepare devices that need to be suspended with
+ * interrupts off, restore the contents of highmem that have not been
+ * restored yet from the image and run the low level code that will restore
+ * the remaining contents of memory and switch to the just restored target
+ * kernel.
+ */
+
+static int resume_target_kernel(void)
+{
+   int error;
+
+   local_irq_disable();
+   error = device_power_down(PMSG_PRETHAW);
+   if (error) {
+   printk(KERN_ERR "Some devices failed to power down, "
+   "aborting resume\n");
+   goto Enable_irqs;
+   }
+   /* We'll ignore saved state, but this gets preempt count (etc) right */
+   save_processor_state();
+   error = restore_highmem();
+   if (!error) {
+   error = swsusp_arch_resume();
+   /*
+* The code below is only ever reached in case of a failure.
+* Otherwise execution continues at place where
+* swsusp_arch_suspend() was called
+*/
+   BUG_ON(!error);
+   /* This call to restore_highmem() undos the previous one */
+   restore_highmem();
+   }
+   /*
+* The only reason why swsusp_arch_resume() can fail is memory being
+* very tight, so we have to free it as soon as we can to avoid
+* subsequent failures
+*/
+   swsusp_free();
+   restore_processor_state();
+   touch_softlockup_watchdog();
+   device_power_up();
+ Enable_irqs:
+   local_irq_enable();
+   return error;
+}
+
+/**
  * hibernation_restore - quiesce devices and restore the hibernation
  * snapshot image.  If successful, control returns in hibernation_snaphot()
  * @platform_mode - if set, use the platform driver, if available, to
@@ -297,7 +344,7 @@ int hibernation_restore(int platform_mode)
if (!error) {
error = disable_nonboot_cpus();
if (!error)
-   error = swsusp_resume();
+   error = resume_target_kernel();
enable_nonboot_cpus();
}
platform_restore_cleanup(platform_mode);
diff --git a/kernel/power/power.h b/kernel/power/power.h
index a9732fd..8ec5499 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -152,7 +152,6 @@ extern int swsusp_swap_in_use(void);
 extern int swsusp_check(void);
 extern int swsusp_shrink_memory(void);
 extern void swsusp_free(void);
-extern int swsusp_resume(void);
 extern int swsusp_read(unsigned int *flags_p);
 extern int swsusp_write(unsigned int flags);
 extern void swsusp_close(void);
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 605c536..dc29a20 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -261,38 +261,3 @@ int swsusp_shrink_memory(void)
 
return 0;
 }
-
-int swsusp_resume(void)
-{
-   int error;
-
-   local_irq_disable();
-   /* NOTE:  device_power_down() is just a suspend() with irqs off;
-* it has no special "power things down" semantics
-*/
-   if (device_power_down(PMSG_PRETHAW))
-   printk(KERN_ERR "Some devices failed to power down, very 
bad\n");
-   /* We'll ignore saved state, but this gets preempt count (etc) right */
-   save_processor_state();
-   error = restore_highmem();
-   if (!error) {
-   error = swsusp_arch_resume();
-   /* The code below is only ever reached in case of a failure.
-* Otherwise execution continues at place where
-* swsusp_arch_suspend() was called
-*/
-   BUG_ON(!error);
-   /* This call to restore_highmem() undos the previous one */
-   restore_highmem();
-   }
-   /* The only reason why swsusp_arch_resume() can fail is memory being
-* very tight, so we have to free it as soon as we can to avoid
-* subsequent failures
-*/
-   swsusp_free();
-   restore_processor_state();
-   touch_softlockup_watchdog();
-   

[PATCH 26/37] Suspend: Introduce begin() and end() callbacks

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

On ACPI systems the target state set by acpi_pm_set_target() is
reset by acpi_pm_finish(), but that need not be called if the
suspend fails.  All platforms that use the .set_target() global
suspend callback are affected by analogous issues.

For this reason, we need an additional global suspend callback that
will reset the target state regardless of whether or not the suspend
is successful.  Also, it is reasonable to rename the .set_target()
callback, since it will be used for a different purpose on ACPI
systems (due to ACPI 1.0x code ordering requirements).

Introduce the global suspend callback .end() to be executed at the
end of the suspend sequence and rename the .set_target() global
suspend callback to .begin().

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 arch/arm/mach-at91/pm.c   |   17 +
 arch/powerpc/platforms/52xx/lite5200_pm.c |   10 --
 drivers/acpi/sleep/main.c |   22 ++
 include/linux/suspend.h   |   29 ++---
 kernel/power/main.c   |9 ++---
 5 files changed, 63 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 4b120cc..a67defd 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -52,7 +52,7 @@ static suspend_state_t target_state;
 /*
  * Called after processes are frozen, but before we shutdown devices.
  */
-static int at91_pm_set_target(suspend_state_t state)
+static int at91_pm_begin(suspend_state_t state)
 {
target_state = state;
return 0;
@@ -202,11 +202,20 @@ error:
return 0;
 }
 
+/*
+ * Called right prior to thawing processes.
+ */
+static void at91_pm_end(void)
+{
+   target_state = PM_SUSPEND_ON;
+}
+
 
 static struct platform_suspend_ops at91_pm_ops ={
-   .valid  = at91_pm_valid_state,
-   .set_target = at91_pm_set_target,
-   .enter  = at91_pm_enter,
+   .valid  = at91_pm_valid_state,
+   .begin  = at91_pm_begin,
+   .enter  = at91_pm_enter,
+   .end= at91_pm_end,
 };
 
 static int __init at91_pm_init(void)
diff --git a/arch/powerpc/platforms/52xx/lite5200_pm.c 
b/arch/powerpc/platforms/52xx/lite5200_pm.c
index c0f13e8..41c7fd9 100644
--- a/arch/powerpc/platforms/52xx/lite5200_pm.c
+++ b/arch/powerpc/platforms/52xx/lite5200_pm.c
@@ -31,7 +31,7 @@ static int lite5200_pm_valid(suspend_state_t state)
}
 }
 
-static int lite5200_pm_set_target(suspend_state_t state)
+static int lite5200_pm_begin(suspend_state_t state)
 {
if (lite5200_pm_valid(state)) {
lite5200_pm_target_state = state;
@@ -219,12 +219,18 @@ static void lite5200_pm_finish(void)
mpc52xx_pm_finish();
 }
 
+static void lite5200_pm_end(void)
+{
+   lite5200_pm_target_state = PM_SUSPEND_ON;
+}
+
 static struct platform_suspend_ops lite5200_pm_ops = {
.valid  = lite5200_pm_valid,
-   .set_target = lite5200_pm_set_target,
+   .begin  = lite5200_pm_begin,
.prepare= lite5200_pm_prepare,
.enter  = lite5200_pm_enter,
.finish = lite5200_pm_finish,
+   .end= lite5200_pm_end,
 };
 
 int __init lite5200_pm_init(void)
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 96d23b3..e2e4e61 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -63,11 +63,11 @@ static u32 acpi_suspend_states[] = {
 static int init_8259A_after_S1;
 
 /**
- * acpi_pm_set_target - Set the target system sleep state to the state
+ * acpi_pm_begin - Set the target system sleep state to the state
  * associated with given @pm_state, if supported.
  */
 
-static int acpi_pm_set_target(suspend_state_t pm_state)
+static int acpi_pm_begin(suspend_state_t pm_state)
 {
u32 acpi_state = acpi_suspend_states[pm_state];
int error = 0;
@@ -164,7 +164,7 @@ static int acpi_pm_enter(suspend_state_t pm_state)
 }
 
 /**
- * acpi_pm_finish - Finish up suspend sequence.
+ * acpi_pm_finish - Instruct the platform to leave a sleep state.
  *
  * This is called after we wake back up (or if entering the sleep state
  * failed). 
@@ -190,6 +190,19 @@ static void acpi_pm_finish(void)
 #endif
 }
 
+/**
+ * acpi_pm_end - Finish up suspend sequence.
+ */
+
+static void acpi_pm_end(void)
+{
+   /*
+* This is necessary in case acpi_pm_finish() is not called during a
+* failing transition to a sleep state.
+*/
+   acpi_target_sleep_state = ACPI_STATE_S0;
+}
+
 static int acpi_pm_state_valid(suspend_state_t pm_state)
 {
u32 acpi_state;
@@ -208,10 +221,11 @@ static int acpi_pm_state_valid(suspend_state_t pm_state)
 
 static struct platform_suspend_ops acpi_pm_ops = {
.valid = acpi_pm_state_valid,
-   

[PATCH 15/37] Suspend: Fix compilation warning for CONFIG_SUSPEND unset

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Suspend: Make debug facility depend on CONFIG_SUSPEND

Make the new suspend debug facility code depend on CONFIG_SUSPEND,
as appropriate, to remove the compiler warning printed when CONFIG_PM is set
and CONFIG_SUSPEND is not set.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 kernel/power/main.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/power/main.c b/kernel/power/main.c
index 0a9f269..7fb805d 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -55,6 +55,8 @@ int pm_notifier_call_chain(unsigned long val)
 
 #endif /* CONFIG_PM_SLEEP */
 
+#ifdef CONFIG_SUSPEND
+
 #ifdef CONFIG_PM_DEBUG
 int pm_test_level = TEST_NONE;
 
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 34/37] Suspend: Clean up suspend_64.c

2008-01-31 Thread Len Brown
From: Borislav Petkov <[EMAIL PROTECTED]>

There's a freakishly long comment in suspend_64.c, shorten it.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 arch/x86/kernel/suspend_64.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/suspend_64.c b/arch/x86/kernel/suspend_64.c
index 0919951..7ac7130 100644
--- a/arch/x86/kernel/suspend_64.c
+++ b/arch/x86/kernel/suspend_64.c
@@ -140,7 +140,12 @@ static void fix_processor_context(void)
int cpu = smp_processor_id();
struct tss_struct *t = _cpu(init_tss, cpu);
 
-   set_tss_desc(cpu,t);/* This just modifies memory; should not be 
necessary. But... This is necessary, because 386 hardware has concept of busy 
TSS or some similar stupidity. */
+   /*
+* This just modifies memory; should not be necessary. But... This
+* is necessary, because 386 hardware has concept of busy TSS or some
+* similar stupidity.
+*/
+   set_tss_desc(cpu, t);
 
get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
 
@@ -160,7 +165,6 @@ static void fix_processor_context(void)
 loaddebug(>thread, 6);
 loaddebug(>thread, 7);
}
-
 }
 
 #ifdef CONFIG_HIBERNATION
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 27/37] ACPI: Separate invocations of _GTS and _BFS from _PTS and _WAK

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

The execution of ACPI global control methods _GTS and _BFS is
currently tied to the preparation to enter a sleep state and to the
leaving of the sleep state, respectively.  However, these functions
are called before disabling the nonboot CPUs and after enabling
them, respectively (in fact, on ACPI 1.0x systems the first of them
ought to be called before suspending devices), while according to the
ACPI specification, _GTS is to be executed right prior to entering
the system sleep state and _BFS is to be executed right after the
platfor firmware has returned control to the OS on wake up.

Move the execution of _GTS and _BFS to the right places.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 drivers/acpi/hardware/hwsleep.c |   75 +-
 drivers/acpi/sleep/main.c   |7 
 include/acpi/acpixf.h   |2 +
 3 files changed, 66 insertions(+), 18 deletions(-)

diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 81b2484..13c93a1 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -192,18 +192,13 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
arg.type = ACPI_TYPE_INTEGER;
arg.integer.value = sleep_state;
 
-   /* Run the _PTS and _GTS methods */
+   /* Run the _PTS method */
 
status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, _list, NULL);
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
return_ACPI_STATUS(status);
}
 
-   status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, _list, NULL);
-   if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
-   return_ACPI_STATUS(status);
-   }
-
/* Setup the argument to _SST */
 
switch (sleep_state) {
@@ -262,6 +257,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 
sleep_state)
struct acpi_bit_register_info *sleep_type_reg_info;
struct acpi_bit_register_info *sleep_enable_reg_info;
u32 in_value;
+   struct acpi_object_list arg_list;
+   union acpi_object arg;
acpi_status status;
 
ACPI_FUNCTION_TRACE(acpi_enter_sleep_state);
@@ -307,6 +304,18 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 
sleep_state)
return_ACPI_STATUS(status);
}
 
+   /* Execute the _GTS method */
+
+   arg_list.count = 1;
+   arg_list.pointer = 
+   arg.type = ACPI_TYPE_INTEGER;
+   arg.integer.value = sleep_state;
+
+   status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, _list, NULL);
+   if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
+   return_ACPI_STATUS(status);
+   }
+
/* Get current value of PM1A control */
 
status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, );
@@ -473,17 +482,18 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
 
 
/***
  *
- * FUNCTION:acpi_leave_sleep_state
+ * FUNCTION:acpi_leave_sleep_state_prep
  *
- * PARAMETERS:  sleep_state - Which sleep state we just exited
+ * PARAMETERS:  sleep_state - Which sleep state we are exiting
  *
  * RETURN:  Status
  *
- * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
- *  Called with interrupts ENABLED.
+ * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
+ *  sleep.
+ *  Called with interrupts DISABLED.
  *
  
**/
-acpi_status acpi_leave_sleep_state(u8 sleep_state)
+acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
 {
struct acpi_object_list arg_list;
union acpi_object arg;
@@ -493,7 +503,7 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
u32 PM1Acontrol;
u32 PM1Bcontrol;
 
-   ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
+   ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep);
 
/*
 * Set SLP_TYPE and SLP_EN to state S0.
@@ -540,6 +550,41 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
}
}
 
+   /* Execute the _BFS method */
+
+   arg_list.count = 1;
+   arg_list.pointer = 
+   arg.type = ACPI_TYPE_INTEGER;
+   arg.integer.value = sleep_state;
+
+   status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, _list, NULL);
+   if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
+   ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
+   }
+
+   return_ACPI_STATUS(status);
+}
+
+/***
+ *
+ * FUNCTION:acpi_leave_sleep_state
+ *
+ * PARAMETERS:  sleep_state - Which sleep state we just exited
+ *
+ * RETURN:  Status
+ 

[PATCH 29/37] ACPI suspend: Call _PTS before suspending devices

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

The ACPI 1.0 specification wants us to put devices into low power
states after executing the _PTS global control method, while ACPI
2.0 and later want us to do that in the reverse order.  The current
suspend code follows ACPI 2.0 in that respect which causes some
ACPI 1.0x systems to hang during suspend (ref.
http://bugzilla.kernel.org/show_bug.cgi?id=9528).

Make the suspend code execute _PTS before putting devices into low
power states (ie. in accordance with ACPI 1.0x) and provide a command
line option to override the default if need be.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 Documentation/kernel-parameters.txt |5 +++
 drivers/acpi/sleep/main.c   |   51 ++-
 2 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index 92c40d1..cf38689 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -168,6 +168,11 @@ and is between 256 and 4096 characters. It is defined in 
the file
acpi_irq_isa=   [HW,ACPI] If irq_balance, mark listed IRQs used by ISA
Format: ,...
 
+   acpi_new_pts_ordering [HW,ACPI]
+   Enforce the ACPI 2.0 ordering of the _PTS control
+   method wrt putting devices into low power states
+   default: pre ACPI 2.0 ordering of _PTS
+
acpi_no_auto_ssdt   [HW,ACPI] Disable automatic loading of SSDT
 
acpi_os_name=   [HW,ACPI] Tell ACPI BIOS the name of the OS
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 198ff8a..c37c4ea 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -26,6 +26,21 @@ u8 sleep_states[ACPI_S_STATE_COUNT];
 
 #ifdef CONFIG_PM_SLEEP
 static u32 acpi_target_sleep_state = ACPI_STATE_S0;
+static bool acpi_sleep_finish_wake_up;
+
+/*
+ * ACPI 2.0 and later want us to execute _PTS after suspending devices, so we
+ * allow the user to request that behavior by using the 'acpi_new_pts_ordering'
+ * kernel command line option that causes the following variable to be set.
+ */
+static bool new_pts_ordering;
+
+static int __init acpi_new_pts_ordering(char *str)
+{
+   new_pts_ordering = true;
+   return 1;
+}
+__setup("acpi_new_pts_ordering", acpi_new_pts_ordering);
 #endif
 
 int acpi_sleep_prepare(u32 acpi_state)
@@ -74,6 +89,14 @@ static int acpi_pm_begin(suspend_state_t pm_state)
 
if (sleep_states[acpi_state]) {
acpi_target_sleep_state = acpi_state;
+   if (new_pts_ordering)
+   return 0;
+
+   error = acpi_sleep_prepare(acpi_state);
+   if (error)
+   acpi_target_sleep_state = ACPI_STATE_S0;
+   else
+   acpi_sleep_finish_wake_up = true;
} else {
printk(KERN_ERR "ACPI does not support this state: %d\n",
pm_state);
@@ -91,15 +114,17 @@ static int acpi_pm_begin(suspend_state_t pm_state)
 
 static int acpi_pm_prepare(void)
 {
-   int error;
+   if (new_pts_ordering) {
+   int error = acpi_sleep_prepare(acpi_target_sleep_state);
 
-   error = acpi_sleep_prepare(acpi_target_sleep_state);
-   if (error)
-   acpi_target_sleep_state = ACPI_STATE_S0;
-   else if (!ACPI_SUCCESS(acpi_hw_disable_all_gpes()))
-   error = -EFAULT;
+   if (error) {
+   acpi_target_sleep_state = ACPI_STATE_S0;
+   return error;
+   }
+   acpi_sleep_finish_wake_up = true;
+   }
 
-   return error;
+   return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT;
 }
 
 /**
@@ -123,10 +148,8 @@ static int acpi_pm_enter(suspend_state_t pm_state)
if (acpi_state == ACPI_STATE_S3) {
int error = acpi_save_state_mem();
 
-   if (error) {
-   acpi_target_sleep_state = ACPI_STATE_S0;
+   if (error)
return error;
-   }
}
 
local_irq_save(flags);
@@ -187,6 +210,7 @@ static void acpi_pm_finish(void)
acpi_set_firmware_waking_vector((acpi_physical_address) 0);
 
acpi_target_sleep_state = ACPI_STATE_S0;
+   acpi_sleep_finish_wake_up = false;
 
 #ifdef CONFIG_X86
if (init_8259A_after_S1) {
@@ -203,10 +227,11 @@ static void acpi_pm_finish(void)
 static void acpi_pm_end(void)
 {
/*
-* This is necessary in case acpi_pm_finish() is not called during a
-* failing transition to a sleep state.
+* This is necessary in case acpi_pm_finish() is not called directly
+* during a failing transition to a sleep state.
 */
-   acpi_target_sleep_state = ACPI_STATE_S0;
+   if 

[PATCH 33/37] Suspend: Add config option to disable the freezer if architecture wants that

2008-01-31 Thread Len Brown
From: Johannes Berg <[EMAIL PROTECTED]>

This patch makes the freezer optional for suspend to allow the
system to work (or not work) like the original PMU suspend.

Signed-off-by: Johannes Berg <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 arch/powerpc/Kconfig |4 
 kernel/power/Kconfig |   11 +++
 kernel/power/main.c  |6 +++---
 kernel/power/power.h |   22 ++
 4 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 824140d..4a22c99 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -405,6 +405,10 @@ config CMDLINE
  most cases you will need to specify the root device here.
 
 if !44x || BROKEN
+config ARCH_WANTS_FREEZER_CONTROL
+   def_bool y
+   depends on ADB_PMU
+
 source kernel/power/Kconfig
 endif
 
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index f8153fd..ef9b802 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -104,6 +104,17 @@ config SUSPEND
  powered and thus its contents are preserved, such as the
  suspend-to-RAM state (e.g. the ACPI S3 state).
 
+config SUSPEND_FREEZER
+   bool "Enable freezer for suspend to RAM/standby" \
+   if ARCH_WANTS_FREEZER_CONTROL || BROKEN
+   depends on SUSPEND
+   default y
+   help
+ This allows you to turn off the freezer for suspend. If this is
+ done, no tasks are frozen for suspend to RAM/standby.
+
+ Turning OFF this setting is NOT recommended! If in doubt, say Y.
+
 config HIBERNATION
bool "Hibernation (aka 'suspend to disk')"
depends on PM && SWAP && ARCH_HIBERNATION_POSSIBLE
diff --git a/kernel/power/main.c b/kernel/power/main.c
index d9bba45..e47214c 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -181,7 +181,7 @@ static int suspend_prepare(void)
 
pm_prepare_console();
 
-   if (freeze_processes()) {
+   if (suspend_freeze_processes()) {
error = -EAGAIN;
goto Thaw;
}
@@ -199,7 +199,7 @@ static int suspend_prepare(void)
return 0;
 
  Thaw:
-   thaw_processes();
+   suspend_thaw_processes();
pm_restore_console();
  Finish:
pm_notifier_call_chain(PM_POST_SUSPEND);
@@ -308,7 +308,7 @@ int suspend_devices_and_enter(suspend_state_t state)
  */
 static void suspend_finish(void)
 {
-   thaw_processes();
+   suspend_thaw_processes();
pm_restore_console();
pm_notifier_call_chain(PM_POST_SUSPEND);
 }
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 8ec5499..700f44e 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -1,6 +1,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct swsusp_info {
struct new_utsname  uts;
@@ -203,3 +204,24 @@ enum {
 #define TEST_MAX   (__TEST_AFTER_LAST - 1)
 
 extern int pm_test_level;
+
+#ifdef CONFIG_SUSPEND_FREEZER
+static inline int suspend_freeze_processes(void)
+{
+   return freeze_processes();
+}
+
+static inline void suspend_thaw_processes(void)
+{
+   thaw_processes();
+}
+#else
+static inline int suspend_freeze_processes(void)
+{
+   return 0;
+}
+
+static inline void suspend_thaw_processes(void)
+{
+}
+#endif
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 17/37] Suspend: Fix comment in main.c

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Fix a comment in kernel/power/main.c so that it doesn't contain lines
longer that 80 characters.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 kernel/power/main.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/power/main.c b/kernel/power/main.c
index 7fb805d..d0cedaa 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -250,8 +250,8 @@ static int suspend_enter(suspend_state_t state)
 }
 
 /**
- * suspend_devices_and_enter - suspend devices and enter the desired 
system sleep
- *   state.
+ * suspend_devices_and_enter - suspend devices and enter the desired system
+ * sleep state.
  * @state:   state to enter
  */
 int suspend_devices_and_enter(suspend_state_t state)
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 20/37] Suspend: Use common prefix in messages

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Make suspend messages start with one common prefix "PM: ".

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 kernel/power/main.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/power/main.c b/kernel/power/main.c
index d0cedaa..5688168 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -235,7 +235,7 @@ static int suspend_enter(suspend_state_t state)
BUG_ON(!irqs_disabled());
 
if ((error = device_power_down(PMSG_SUSPEND))) {
-   printk(KERN_ERR "Some devices failed to power down\n");
+   printk(KERN_ERR "PM: Some devices failed to power down\n");
goto Done;
}
 
@@ -269,7 +269,7 @@ int suspend_devices_and_enter(suspend_state_t state)
suspend_console();
error = device_suspend(PMSG_SUSPEND);
if (error) {
-   printk(KERN_ERR "Some devices failed to suspend\n");
+   printk(KERN_ERR "PM: Some devices failed to suspend\n");
goto Resume_console;
}
 
@@ -352,7 +352,7 @@ static int enter_state(suspend_state_t state)
if (!mutex_trylock(_mutex))
return -EBUSY;
 
-   printk("Syncing filesystems ... ");
+   printk(KERN_INFO "PM: Syncing filesystems ... ");
sys_sync();
printk("done.\n");
 
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 37/37] PM: Remove obsolete /sys/devices/.../power/state docs

2008-01-31 Thread Len Brown
From: David Brownell <[EMAIL PROTECTED]>

The /sys/devices/.../power/state files have been gone for a while
now, but I just noticed some documentation that still refers to
them.  (Fortunately described as DEPRECATED and WILL REMOVE).

Time to remove that obsolete documentation too ...

Signed-off-by: David Brownell <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 Documentation/power/devices.txt |   49 ---
 1 files changed, 0 insertions(+), 49 deletions(-)

diff --git a/Documentation/power/devices.txt b/Documentation/power/devices.txt
index d0e79d5..c53d263 100644
--- a/Documentation/power/devices.txt
+++ b/Documentation/power/devices.txt
@@ -502,52 +502,3 @@ If the CPU can have a "cpufreq" driver, there also may be 
opportunities
 to shift to lower voltage settings and reduce the power cost of executing
 a given number of instructions.  (Without voltage adjustment, it's rare
 for cpufreq to save much power; the cost-per-instruction must go down.)
-
-
-/sys/devices/.../power/state files
-==
-For now you can also test some of this functionality using sysfs.
-
-   DEPRECATED:  USE "power/state" ONLY FOR DRIVER TESTING, AND
-   AVOID USING dev->power.power_state IN DRIVERS.
-
-   THESE WILL BE REMOVED.  IF THE "power/state" FILE GETS REPLACED,
-   IT WILL BECOME SOMETHING COUPLED TO THE BUS OR DRIVER.
-
-In each device's directory, there is a 'power' directory, which contains
-at least a 'state' file.  The value of this field is effectively boolean,
-PM_EVENT_ON or PM_EVENT_SUSPEND.
-
-   *   Reading from this file displays a value corresponding to
-   the power.power_state.event field.  All nonzero values are
-   displayed as "2", corresponding to a low power state; zero
-   is displayed as "0", corresponding to normal operation.
-
-   *   Writing to this file initiates a transition using the
-   specified event code number; only '0', '2', and '3' are
-   accepted (without a newline); '2' and '3' are both
-   mapped to PM_EVENT_SUSPEND.
-
-On writes, the PM core relies on that recorded event code and the device/bus
-capabilities to determine whether it uses a partial suspend() or resume()
-sequence to change things so that the recorded event corresponds to the
-numeric parameter.
-
-   -   If the bus requires the irqs-disabled suspend_late()/resume_early()
-   phases, writes fail because those operations are not supported here.
-
-   -   If the recorded value is the expected value, nothing is done.
-
-   -   If the recorded value is nonzero, the device is partially resumed,
-   using the bus.resume() and/or class.resume() methods.
-
-   -   If the target value is nonzero, the device is partially suspended,
-   using the class.suspend() and/or bus.suspend() methods and the
-   PM_EVENT_SUSPEND message.
-
-Drivers have no way to tell whether their suspend() and resume() calls
-have come through the sysfs power/state file or as part of entering a
-system sleep state, except that when accessed through sysfs the normal
-parent/child sequencing rules are ignored.  Drivers (such as bus, bridge,
-or hub drivers) which expose child devices may need to enforce those rules
-on their own.
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 36/37] Hibernation: Invoke suspend notifications after console switch

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Following the recent change in the suspend code path, switch consoles before
calling PM notifiers during hibernation.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 kernel/power/disk.c |   17 +++--
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 53c22d9..d09da08 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -458,20 +458,13 @@ static void power_down(void)
while(1);
 }
 
-static void unprepare_processes(void)
-{
-   thaw_processes();
-   pm_restore_console();
-}
-
 static int prepare_processes(void)
 {
int error = 0;
 
-   pm_prepare_console();
if (freeze_processes()) {
error = -EBUSY;
-   unprepare_processes();
+   thaw_processes();
}
return error;
 }
@@ -491,6 +484,7 @@ int hibernate(void)
goto Unlock;
}
 
+   pm_prepare_console();
error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
if (error)
goto Exit;
@@ -530,11 +524,12 @@ int hibernate(void)
swsusp_free();
}
  Thaw:
-   unprepare_processes();
+   thaw_processes();
  Finish:
free_basic_memory_bitmaps();
  Exit:
pm_notifier_call_chain(PM_POST_HIBERNATION);
+   pm_restore_console();
atomic_inc(_device_available);
  Unlock:
mutex_unlock(_mutex);
@@ -603,6 +598,7 @@ static int software_resume(void)
goto Unlock;
}
 
+   pm_prepare_console();
error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
if (error)
goto Finish;
@@ -626,11 +622,12 @@ static int software_resume(void)
 
printk(KERN_ERR "PM: Restore failed, recovering.\n");
swsusp_free();
-   unprepare_processes();
+   thaw_processes();
  Done:
free_basic_memory_bitmaps();
  Finish:
pm_notifier_call_chain(PM_POST_RESTORE);
+   pm_restore_console();
atomic_inc(_device_available);
/* For success case, the suspend path will release the lock */
  Unlock:
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 35/37] Suspend: Invoke suspend notifications after console switch

2008-01-31 Thread Len Brown
From: Johannes Berg <[EMAIL PROTECTED]>

In order to fix APM emulation it is necessary to enable apm-emulation
notifications for suspends triggered in various ways via the suspend
notifiers.  However, this will cause the systems using APM emulation
to lock up between X being needed to switch away from the VT and X
already waiting for resume in the APM ioctl.

This patch moves the console switch (if enabled) before the suspend
notification (and after the resume notification) to avoid this issue.

Signed-off-by: Johannes Berg <[EMAIL PROTECTED]>
Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 kernel/power/main.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/power/main.c b/kernel/power/main.c
index e47214c..6a6d5eb 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -175,12 +175,12 @@ static int suspend_prepare(void)
if (!suspend_ops || !suspend_ops->enter)
return -EPERM;
 
+   pm_prepare_console();
+
error = pm_notifier_call_chain(PM_SUSPEND_PREPARE);
if (error)
goto Finish;
 
-   pm_prepare_console();
-
if (suspend_freeze_processes()) {
error = -EAGAIN;
goto Thaw;
@@ -200,9 +200,9 @@ static int suspend_prepare(void)
 
  Thaw:
suspend_thaw_processes();
-   pm_restore_console();
  Finish:
pm_notifier_call_chain(PM_POST_SUSPEND);
+   pm_restore_console();
return error;
 }
 
@@ -309,8 +309,8 @@ int suspend_devices_and_enter(suspend_state_t state)
 static void suspend_finish(void)
 {
suspend_thaw_processes();
-   pm_restore_console();
pm_notifier_call_chain(PM_POST_SUSPEND);
+   pm_restore_console();
 }
 
 
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 32/37] ACPI: Print message before calling _PTS

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Make acpi_sleep_prepare() static and cause it to print a message
specifying the ACPI system sleep state to be entered (helpful for
debugging the suspend/hibernation code).

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 drivers/acpi/sleep/main.c  |4 +++-
 drivers/acpi/sleep/sleep.h |2 --
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 10db899..485de13 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -43,7 +43,7 @@ static int __init acpi_new_pts_ordering(char *str)
 __setup("acpi_new_pts_ordering", acpi_new_pts_ordering);
 #endif
 
-int acpi_sleep_prepare(u32 acpi_state)
+static int acpi_sleep_prepare(u32 acpi_state)
 {
 #ifdef CONFIG_ACPI_SLEEP
/* do we have a wakeup address for S2 and S3? */
@@ -59,6 +59,8 @@ int acpi_sleep_prepare(u32 acpi_state)
ACPI_FLUSH_CPU_CACHE();
acpi_enable_wakeup_device_prep(acpi_state);
 #endif
+   printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n",
+   acpi_state);
acpi_enter_sleep_state_prep(acpi_state);
return 0;
 }
diff --git a/drivers/acpi/sleep/sleep.h b/drivers/acpi/sleep/sleep.h
index a2ea125..cfaf8f5 100644
--- a/drivers/acpi/sleep/sleep.h
+++ b/drivers/acpi/sleep/sleep.h
@@ -5,5 +5,3 @@ extern int acpi_suspend (u32 state);
 extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
 extern void acpi_enable_wakeup_device(u8 sleep_state);
 extern void acpi_disable_wakeup_device(u8 sleep_state);
-
-extern int acpi_sleep_prepare(u32 acpi_state);
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 30/37] Hibernation: Introduce begin() and end() callbacks

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Introduce global hibernation callback .end() and rename global
hibernation callback .start() to .begin(), in analogy with the
recent modifications of the global suspend callbacks.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 drivers/acpi/sleep/main.c |   14 --
 include/linux/suspend.h   |   14 +-
 kernel/power/disk.c   |   33 -
 3 files changed, 45 insertions(+), 16 deletions(-)

diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index c37c4ea..31e8e58 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -281,7 +281,7 @@ static struct dmi_system_id __initdata 
acpisleep_dmi_table[] = {
 #endif /* CONFIG_SUSPEND */
 
 #ifdef CONFIG_HIBERNATION
-static int acpi_hibernation_start(void)
+static int acpi_hibernation_begin(void)
 {
acpi_target_sleep_state = ACPI_STATE_S4;
return 0;
@@ -341,6 +341,15 @@ static void acpi_hibernation_finish(void)
acpi_target_sleep_state = ACPI_STATE_S0;
 }
 
+static void acpi_hibernation_end(void)
+{
+   /*
+* This is necessary in case acpi_hibernation_finish() is not called
+* during a failing transition to the sleep state.
+*/
+   acpi_target_sleep_state = ACPI_STATE_S0;
+}
+
 static int acpi_hibernation_pre_restore(void)
 {
acpi_status status;
@@ -356,7 +365,8 @@ static void acpi_hibernation_restore_cleanup(void)
 }
 
 static struct platform_hibernation_ops acpi_hibernation_ops = {
-   .start = acpi_hibernation_start,
+   .begin = acpi_hibernation_begin,
+   .end = acpi_hibernation_end,
.pre_snapshot = acpi_hibernation_prepare,
.finish = acpi_hibernation_finish,
.prepare = acpi_hibernation_prepare,
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index a0b1dbb..646ce2d 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -136,14 +136,17 @@ extern void mark_free_pages(struct zone *zone);
 /**
  * struct platform_hibernation_ops - hibernation platform support
  *
- * The methods in this structure allow a platform to override the default
- * mechanism of shutting down the machine during a hibernation transition.
+ * The methods in this structure allow a platform to carry out special
+ * operations required by it during a hibernation transition.
  *
- * All three methods must be assigned.
+ * All the methods below must be implemented.
  *
- * @start: Tell the platform driver that we're starting hibernation.
+ * @begin: Tell the platform driver that we're starting hibernation.
  * Called right after shrinking memory and before freezing devices.
  *
+ * @end: Called by the PM core right after resuming devices, to indicate to
+ * the platform that the system has returned to the working state.
+ *
  * @pre_snapshot: Prepare the platform for creating the hibernation image.
  * Called right after devices have been frozen and before the nonboot
  * CPUs are disabled (runs with IRQs on).
@@ -178,7 +181,8 @@ extern void mark_free_pages(struct zone *zone);
  * thawing devices (runs with IRQs on).
  */
 struct platform_hibernation_ops {
-   int (*start)(void);
+   int (*begin)(void);
+   void (*end)(void);
int (*pre_snapshot)(void);
void (*finish)(void);
int (*prepare)(void);
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 64e42ab..53c22d9 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -54,8 +54,8 @@ static struct platform_hibernation_ops *hibernation_ops;
 
 void hibernation_set_ops(struct platform_hibernation_ops *ops)
 {
-   if (ops && !(ops->start && ops->pre_snapshot && ops->finish
-   && ops->prepare && ops->enter && ops->pre_restore
+   if (ops && !(ops->begin && ops->end &&  ops->pre_snapshot
+   && ops->prepare && ops->finish && ops->enter && ops->pre_restore
&& ops->restore_cleanup)) {
WARN_ON(1);
return;
@@ -100,14 +100,25 @@ static int hibernation_test(int level) { return 0; }
 #endif /* !CONFIG_PM_DEBUG */
 
 /**
- * platform_start - tell the platform driver that we're starting
+ * platform_begin - tell the platform driver that we're starting
  * hibernation
  */
 
-static int platform_start(int platform_mode)
+static int platform_begin(int platform_mode)
 {
return (platform_mode && hibernation_ops) ?
-   hibernation_ops->start() : 0;
+   hibernation_ops->begin() : 0;
+}
+
+/**
+ * platform_end - tell the platform driver that we've entered the
+ * working state
+ */
+
+static void platform_end(int platform_mode)
+{
+   if (platform_mode && hibernation_ops)
+   hibernation_ops->end();
 }
 
 /**
@@ -237,9 +248,9 @@ int hibernation_snapshot(int platform_mode)
if (error)
return error;
 
-   error = 

[PATCH 28/37] ACPI: Separate disabling of GPEs from _PTS

2008-01-31 Thread Len Brown
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

The preparation to enter an ACPI system sleep state is now tied to
the disabling of GPEs, but the GPEs should not be disabled before
suspending devices.  Since on ACPI 1.0x systems the _PTS global
control method should be executed before suspending devices, we
need to disable GPEs separately.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 drivers/acpi/hardware/hwsleep.c |4 
 drivers/acpi/sleep/main.c   |   17 +++--
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 13c93a1..fd1c4ba 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -229,10 +229,6 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
"While executing method _SST"));
}
 
-   /* Disable/Clear all GPEs */
-
-   status = acpi_hw_disable_all_gpes();
-
return_ACPI_STATUS(status);
 }
 
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index fdd8139..198ff8a 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -91,10 +91,13 @@ static int acpi_pm_begin(suspend_state_t pm_state)
 
 static int acpi_pm_prepare(void)
 {
-   int error = acpi_sleep_prepare(acpi_target_sleep_state);
+   int error;
 
+   error = acpi_sleep_prepare(acpi_target_sleep_state);
if (error)
acpi_target_sleep_state = ACPI_STATE_S0;
+   else if (!ACPI_SUCCESS(acpi_hw_disable_all_gpes()))
+   error = -EFAULT;
 
return error;
 }
@@ -261,7 +264,16 @@ static int acpi_hibernation_start(void)
 
 static int acpi_hibernation_prepare(void)
 {
-   return acpi_sleep_prepare(ACPI_STATE_S4);
+   int error;
+
+   error = acpi_sleep_prepare(ACPI_STATE_S4);
+   if (error)
+   return error;
+
+   if (!ACPI_SUCCESS(acpi_hw_disable_all_gpes()))
+   error = -EFAULT;
+
+   return error;
 }
 
 static int acpi_hibernation_enter(void)
@@ -426,6 +438,7 @@ static void acpi_power_off_prepare(void)
 {
/* Prepare to power off the system */
acpi_sleep_prepare(ACPI_STATE_S5);
+   acpi_hw_disable_all_gpes();
 }
 
 static void acpi_power_off(void)
-- 
1.5.4.rc5.16.gc0279

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >