]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge master.kernel.org:/home/rmk/linux-2.6-arm
authorLinus Torvalds <torvalds@g5.osdl.org>
Mon, 10 Oct 2005 17:39:14 +0000 (10:39 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 10 Oct 2005 17:39:14 +0000 (10:39 -0700)
16 files changed:
arch/i386/kernel/signal.c
arch/sparc64/kernel/irq.c
arch/um/Makefile
arch/um/drivers/cow.h
arch/um/drivers/cow_user.c
arch/um/os-Linux/start_up.c
arch/um/scripts/Makefile.rules
arch/um/sys-x86_64/stub_segv.c
arch/x86_64/ia32/ia32_signal.c
arch/x86_64/kernel/suspend.c
arch/x86_64/kernel/suspend_asm.S
drivers/ide/ide-io.c
drivers/pcmcia/cs.c
fs/relayfs/buffers.c
include/linux/suspend.h
kernel/power/swsusp.c

index 61eb0c8a6e47dc9763c8f78d85f3aa3e7be40456..adcd069db91e8cae96ec53eeb2861f9c9e8c4b92 100644 (file)
@@ -338,7 +338,11 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
                esp = (unsigned long) ka->sa.sa_restorer;
        }
 
-       return (void __user *)((esp - frame_size) & -8ul);
+       esp -= frame_size;
+       /* Align the stack pointer according to the i386 ABI,
+        * i.e. so that on function entry ((sp + 4) & 15) == 0. */
+       esp = ((esp + 4) & -16ul) - 4;
+       return (void __user *) esp;
 }
 
 /* These symbols are defined with the addresses in the vsyscall page.
index c9b69167632a7b666ee829f1dec5c696a384e20b..233526ba3abe23d7a684143b56cbc4a9aa36c503 100644 (file)
@@ -27,6 +27,7 @@
 #include <asm/atomic.h>
 #include <asm/system.h>
 #include <asm/irq.h>
+#include <asm/io.h>
 #include <asm/sbus.h>
 #include <asm/iommu.h>
 #include <asm/upa.h>
index 7af37e342e331bf89f0880c2ae0ae4d690f3cbea..e1ffad2246053651339c07281a5aa003aa60c3d9 100644 (file)
@@ -152,7 +152,7 @@ archclean:
 $(SYMLINK_HEADERS):
        @echo '  SYMLINK $@'
 ifneq ($(KBUILD_SRC),)
-       ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
+       $(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
 else
        $(Q)cd $(TOPDIR)/$(dir $@) ; \
        ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
index 4fcf3a8d13f4a356ee8e8d8a4d341d0d37aeb3c8..dc36b222100b9abde780f996407a758f336afce4 100644 (file)
@@ -3,15 +3,40 @@
 
 #include <asm/types.h>
 
-#if defined(__BIG_ENDIAN)
-# define ntohll(x) (x)
-# define htonll(x) (x)
-#elif defined(__LITTLE_ENDIAN)
-# define ntohll(x)  bswap_64(x)
-# define htonll(x)  bswap_64(x)
+#if defined(__KERNEL__)
+
+# include <asm/byteorder.h>
+
+# if defined(__BIG_ENDIAN)
+#      define ntohll(x) (x)
+#      define htonll(x) (x)
+# elif defined(__LITTLE_ENDIAN)
+#      define ntohll(x)  be64_to_cpu(x)
+#      define htonll(x)  cpu_to_be64(x)
+# else
+#      error "Could not determine byte order"
+# endif
+
 #else
-#error "__BYTE_ORDER not defined"
+/* For the definition of ntohl, htonl and __BYTE_ORDER */
+#include <endian.h>
+#include <netinet/in.h>
+#if defined(__BYTE_ORDER)
+
+#  if __BYTE_ORDER == __BIG_ENDIAN
+#      define ntohll(x) (x)
+#      define htonll(x) (x)
+#  elif __BYTE_ORDER == __LITTLE_ENDIAN
+#      define ntohll(x)  bswap_64(x)
+#      define htonll(x)  bswap_64(x)
+#  else
+#      error "Could not determine byte order: __BYTE_ORDER uncorrectly defined"
+#  endif
+
+#else  /* ! defined(__BYTE_ORDER) */
+#      error "Could not determine byte order: __BYTE_ORDER not defined"
 #endif
+#endif /* ! defined(__KERNEL__) */
 
 extern int init_cow_file(int fd, char *cow_file, char *backing_file,
                         int sectorsize, int alignment, int *bitmap_offset_out,
index a8ce6fc3ef26b1ca8db782fe93f26fd301cc3aa0..fbe2217db5dd29676462ea9567b443579b9767a6 100644 (file)
@@ -9,7 +9,6 @@
 #include <sys/time.h>
 #include <sys/param.h>
 #include <sys/user.h>
-#include <netinet/in.h>
 
 #include "os.h"
 
index 6af83171ca4eaf2b6ad8e170602d1372d0498906..b99ab414542fcb6700b39285fe28aeb5f881c33b 100644 (file)
@@ -143,11 +143,22 @@ static int __init skas0_cmd_param(char *str, int* add)
        return 0;
 }
 
+/* The two __uml_setup would conflict, without this stupid alias. */
+
+static int __init mode_skas0_cmd_param(char *str, int* add)
+       __attribute__((alias("skas0_cmd_param")));
+
 __uml_setup("skas0", skas0_cmd_param,
                "skas0\n"
                "    Disables SKAS3 usage, so that SKAS0 is used, unless \n"
                "    you specify mode=tt.\n\n");
 
+__uml_setup("mode=skas0", mode_skas0_cmd_param,
+               "mode=skas0\n"
+               "    Disables SKAS3 usage, so that SKAS0 is used, unless you \n"
+               "    specify mode=tt. Note that this was recently added - on \n"
+               "    older kernels you must use simply \"skas0\".\n\n");
+
 static int force_sysemu_disabled = 0;
 
 static int __init nosysemu_cmd_param(char *str, int* add)
index 59a1291f477e3642a0585e3f7f3fe4930cf0ac27..651d9d88b6564dd0c901aa451a5a6e1b2cbad5bb 100644 (file)
@@ -7,8 +7,8 @@ USER_SINGLE_OBJS := \
 USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m)  $(USER_SINGLE_OBJS))
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
-$(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \
-       $(CFLAGS_$(notdir $@))
+$(USER_OBJS) $(USER_OBJS:.o=.i) $(USER_OBJS:.o=.s) $(USER_OBJS:.o=.lst): \
+       c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(notdir $@))
 $(USER_OBJS): cmd_checksrc =
 $(USER_OBJS): quiet_cmd_checksrc =
 $(USER_OBJS): cmd_force_checksrc =
index 65a131b362b689b634608f0ae83ddbc6ebf5e029..d1e53bdf2e85e7240c21511e9ed62953920cf828 100644 (file)
 #include "uml-config.h"
 #include "sysdep/sigcontext.h"
 #include "sysdep/faultinfo.h"
+#include <stddef.h>
+
+/* Copied from sys-x86_64/signal.c - Can't find an equivalent definition
+ * in the libc headers anywhere.
+ */
+struct rt_sigframe
+{
+       char *pretcode;
+       struct ucontext uc;
+       struct siginfo info;
+};
+
+/* Copied here from <linux/kernel.h> - we're userspace. */
+#define container_of(ptr, type, member) ({                   \
+       const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+       (type *)( (char *)__mptr - offsetof(type,member) );})
 
 void __attribute__ ((__section__ (".__syscall_stub")))
 stub_segv_handler(int sig)
@@ -17,16 +33,19 @@ stub_segv_handler(int sig)
        struct ucontext *uc;
 
        __asm__("movq %%rdx, %0" : "=g" (uc) :);
-        GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA),
-                              &uc->uc_mcontext);
+       GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA),
+                             &uc->uc_mcontext);
 
-       __asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid));
+       __asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid));       
        __asm__("movq %%rax, %%rdi ; movq %0, %%rax ; movq %1, %%rsi ;"
-               "syscall": : "g" (__NR_kill), "g" (SIGUSR1));
-       /* Two popqs to restore the stack to the state just before entering
-        * the handler, one pops the return address, the other pops the frame
-        * pointer.
+               "syscall": : "g" (__NR_kill), "g" (SIGUSR1) : 
+               "%rdi", "%rax", "%rsi");
+       /* sys_sigreturn expects that the stack pointer will be 8 bytes into
+        * the signal frame.  So, we use the ucontext pointer, which we know
+        * already, to get the signal frame pointer, and add 8 to that.
         */
-       __asm__("popq %%rax ; popq %%rax ; movq %0, %%rax ; syscall" : : "g"
-               (__NR_rt_sigreturn));
+       __asm__("movq %0, %%rsp": : 
+               "g" ((unsigned long) container_of(uc, struct rt_sigframe, 
+                                                 uc) + 8));
+       __asm__("movq %0, %%rax ; syscall" : : "g" (__NR_rt_sigreturn));
 }
index 66e2821533db70d6607f580eab2bff3c501c8ea4..0903cc1faef22a34a9e74d3e3934f0889b701b13 100644 (file)
@@ -425,7 +425,11 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
                rsp = (unsigned long) ka->sa.sa_restorer;
        }
 
-       return (void __user *)((rsp - frame_size) & -8UL);
+       rsp -= frame_size;
+       /* Align the stack pointer according to the i386 ABI,
+        * i.e. so that on function entry ((sp + 4) & 15) == 0. */
+       rsp = ((rsp + 4) & -16ul) - 4;
+       return (void __user *) rsp;
 }
 
 int ia32_setup_frame(int sig, struct k_sigaction *ka,
index ebb9abf3ce6dae3269711f583b0ef2f827d148cb..f066c6ab3618f24a5d7d7323de14d4a9cd0c1144 100644 (file)
@@ -11,6 +11,8 @@
 #include <linux/smp.h>
 #include <linux/suspend.h>
 #include <asm/proto.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
 
 struct saved_context saved_context;
 
@@ -140,4 +142,129 @@ void fix_processor_context(void)
 
 }
 
+#ifdef CONFIG_SOFTWARE_SUSPEND
+/* Defined in arch/x86_64/kernel/suspend_asm.S */
+extern int restore_image(void);
 
+pgd_t *temp_level4_pgt;
+
+static void **pages;
+
+static inline void *__add_page(void)
+{
+       void **c;
+
+       c = (void **)get_usable_page(GFP_ATOMIC);
+       if (c) {
+               *c = pages;
+               pages = c;
+       }
+       return c;
+}
+
+static inline void *__next_page(void)
+{
+       void **c;
+
+       c = pages;
+       if (c) {
+               pages = *c;
+               *c = NULL;
+       }
+       return c;
+}
+
+/*
+ * Try to allocate as many usable pages as needed and daisy chain them.
+ * If one allocation fails, free the pages allocated so far
+ */
+static int alloc_usable_pages(unsigned long n)
+{
+       void *p;
+
+       pages = NULL;
+       do
+               if (!__add_page())
+                       break;
+       while (--n);
+       if (n) {
+               p = __next_page();
+               while (p) {
+                       free_page((unsigned long)p);
+                       p = __next_page();
+               }
+               return -ENOMEM;
+       }
+       return 0;
+}
+
+static void res_phys_pud_init(pud_t *pud, unsigned long address, unsigned long end)
+{
+       long i, j;
+
+       i = pud_index(address);
+       pud = pud + i;
+       for (; i < PTRS_PER_PUD; pud++, i++) {
+               unsigned long paddr;
+               pmd_t *pmd;
+
+               paddr = address + i*PUD_SIZE;
+               if (paddr >= end)
+                       break;
+
+               pmd = (pmd_t *)__next_page();
+               set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE));
+               for (j = 0; j < PTRS_PER_PMD; pmd++, j++, paddr += PMD_SIZE) {
+                       unsigned long pe;
+
+                       if (paddr >= end)
+                               break;
+                       pe = _PAGE_NX | _PAGE_PSE | _KERNPG_TABLE | paddr;
+                       pe &= __supported_pte_mask;
+                       set_pmd(pmd, __pmd(pe));
+               }
+       }
+}
+
+static void set_up_temporary_mappings(void)
+{
+       unsigned long start, end, next;
+
+       temp_level4_pgt = (pgd_t *)__next_page();
+
+       /* It is safe to reuse the original kernel mapping */
+       set_pgd(temp_level4_pgt + pgd_index(__START_KERNEL_map),
+               init_level4_pgt[pgd_index(__START_KERNEL_map)]);
+
+       /* Set up the direct mapping from scratch */
+       start = (unsigned long)pfn_to_kaddr(0);
+       end = (unsigned long)pfn_to_kaddr(end_pfn);
+
+       for (; start < end; start = next) {
+               pud_t *pud = (pud_t *)__next_page();
+               next = start + PGDIR_SIZE;
+               if (next > end)
+                       next = end;
+               res_phys_pud_init(pud, __pa(start), __pa(next));
+               set_pgd(temp_level4_pgt + pgd_index(start),
+                       mk_kernel_pgd(__pa(pud)));
+       }
+}
+
+int swsusp_arch_resume(void)
+{
+       unsigned long n;
+
+       n = ((end_pfn << PAGE_SHIFT) + PUD_SIZE - 1) >> PUD_SHIFT;
+       n += (n + PTRS_PER_PUD - 1) / PTRS_PER_PUD + 1;
+       pr_debug("swsusp_arch_resume(): pages needed = %lu\n", n);
+       if (alloc_usable_pages(n)) {
+               free_eaten_memory();
+               return -ENOMEM;
+       }
+       /* We have got enough memory and from now on we cannot recover */
+       set_up_temporary_mappings();
+       restore_image();
+       return 0;
+}
+#endif /* CONFIG_SOFTWARE_SUSPEND */
index 4d659e97df100b354fc07f4aaa4f39f86ca686ff..320b6fb00ccadf9a426e39ce9055174ee692dec2 100644 (file)
@@ -39,12 +39,13 @@ ENTRY(swsusp_arch_suspend)
        call swsusp_save
        ret
 
-ENTRY(swsusp_arch_resume)
-       /* set up cr3 */        
-       leaq    init_level4_pgt(%rip),%rax
-       subq    $__START_KERNEL_map,%rax
-       movq    %rax,%cr3
-
+ENTRY(restore_image)
+       /* switch to temporary page tables */
+       movq    $__PAGE_OFFSET, %rdx
+       movq    temp_level4_pgt(%rip), %rax
+       subq    %rdx, %rax
+       movq    %rax, %cr3
+       /* Flush TLB */
        movq    mmu_cr4_features(%rip), %rax
        movq    %rax, %rdx
        andq    $~(1<<7), %rdx  # PGE
@@ -69,6 +70,10 @@ loop:
        movq    pbe_next(%rdx), %rdx
        jmp     loop
 done:
+       /* go back to the original page tables */
+       leaq    init_level4_pgt(%rip), %rax
+       subq    $__START_KERNEL_map, %rax
+       movq    %rax, %cr3
        /* Flush TLB, including "global" things (vmalloc) */
        movq    mmu_cr4_features(%rip), %rax
        movq    %rax, %rdx
index 9e9cf1407311f92eabc53cf702913f70537b6c17..5275cbb1afe9c790fe9b427c0c916dcfa7c4b9a3 100644 (file)
@@ -1101,6 +1101,7 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
        ide_hwif_t      *hwif;
        struct request  *rq;
        ide_startstop_t startstop;
+       int             loops = 0;
 
        /* for atari only: POSSIBLY BROKEN HERE(?) */
        ide_get_lock(ide_intr, hwgroup);
@@ -1153,6 +1154,7 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
                        /* no more work for this hwgroup (for now) */
                        return;
                }
+       again:
                hwif = HWIF(drive);
                if (hwgroup->hwif->sharing_irq &&
                    hwif != hwgroup->hwif &&
@@ -1192,8 +1194,14 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
                 * though. I hope that doesn't happen too much, hopefully not
                 * unless the subdriver triggers such a thing in its own PM
                 * state machine.
+                *
+                * We count how many times we loop here to make sure we service
+                * all drives in the hwgroup without looping for ever
                 */
                if (drive->blocked && !blk_pm_request(rq) && !(rq->flags & REQ_PREEMPT)) {
+                       drive = drive->next ? drive->next : hwgroup->drive;
+                       if (loops++ < 4 && !blk_queue_plugged(drive->queue))
+                               goto again;
                        /* We clear busy, there should be no pending ATA command at this point. */
                        hwgroup->busy = 0;
                        break;
index fabd3529cebcb035e56769354986c99e561ecb08..d5e76423a0ee89b15a3888e0b411f688e49b05fb 100644 (file)
@@ -689,6 +689,9 @@ static int pccardd(void *__skt)
                schedule();
                try_to_freeze();
        }
+       /* make sure we are running before we exit */
+       set_current_state(TASK_RUNNING);
+
        remove_wait_queue(&skt->thread_wait, &wait);
 
        /* remove from the device core */
index 2aa8e27199999d6eb7bcdb09cb7114bc33edab23..84e21ffa5ca8e8e695dcfcad6fa5a3eb3bb9e7cc 100644 (file)
@@ -109,7 +109,7 @@ static void *relay_alloc_buf(struct rchan_buf *buf, unsigned long size)
                if (unlikely(!buf->page_array[i]))
                        goto depopulate;
        }
-       mem = vmap(buf->page_array, n_pages, GFP_KERNEL, PAGE_KERNEL);
+       mem = vmap(buf->page_array, n_pages, VM_MAP, PAGE_KERNEL);
        if (!mem)
                goto depopulate;
 
index f2e96fdfaae01604e207fc9362f55d9286b1b95c..ad15a54806d8134342d195e7b120e11fb584f7ac 100644 (file)
@@ -71,5 +71,7 @@ void restore_processor_state(void);
 struct saved_context;
 void __save_processor_state(struct saved_context *ctxt);
 void __restore_processor_state(struct saved_context *ctxt);
+extern unsigned long get_usable_page(unsigned gfp_mask);
+extern void free_eaten_memory(void);
 
 #endif /* _LINUX_SWSUSP_H */
index acf79ac1cb6d5f13667916aac50fd81ddd3af04e..2d5c4567644279d3f73c6d0563b0b72ee4b40dc2 100644 (file)
@@ -1095,7 +1095,7 @@ static inline void eat_page(void *page)
        *eaten_memory = c;
 }
 
-static unsigned long get_usable_page(unsigned gfp_mask)
+unsigned long get_usable_page(unsigned gfp_mask)
 {
        unsigned long m;
 
@@ -1109,7 +1109,7 @@ static unsigned long get_usable_page(unsigned gfp_mask)
        return m;
 }
 
-static void free_eaten_memory(void)
+void free_eaten_memory(void)
 {
        unsigned long m;
        void **c;
@@ -1481,11 +1481,12 @@ static int read_suspend_image(void)
        /* Allocate memory for the image and read the data from swap */
 
        error = check_pagedir(pagedir_nosave);
-       free_eaten_memory();
+
        if (!error)
                error = data_read(pagedir_nosave);
 
        if (error) { /* We fail cleanly */
+               free_eaten_memory();
                for_each_pbe (p, pagedir_nosave)
                        if (p->address) {
                                free_page(p->address);