[PATCH 2.6.13-rc1 08/10] IOCHK interface for I/O error handling/detecting

2005-07-05 Thread Hidetoshi Seto

[This is 8 of 10 patches, "iochk-08-mcadrv.patch"]

- Touching poisoned data become a MCA, so now it assumed as
  a fatal error, directly will be a system down. But since
  the MCA tells us a physical address - "where it happens",
  we can do some action to survive.

  If the address is present in resource of "check-in" device,
  it is guaranteed that its driver will call iochk_read in
  the very near future, and that now the driver have a
  ability and responsibility of recovery from the error.

  So if it was "check-in" address, what OS should do is mark
  "check-in" devices and just restart usual works. Soon
  the driver will notice the error and operate it properly.

  Note:
We can identify a affected device, but because of SAL
behavior (mentioned at 6 of 10), we need to mark all
"check-in" devices. Fix in future, if possible.

Changes from previous one for 2.6.11.11:
  - (non)

Signed-off-by: Hidetoshi Seto <[EMAIL PROTECTED]>

---

 arch/ia64/kernel/mca_drv.c  |   84 
 arch/ia64/lib/iomap_check.c |1
 2 files changed, 85 insertions(+)

Index: linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
===
--- linux-2.6.13-rc1.orig/arch/ia64/lib/iomap_check.c
+++ linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
@@ -147,3 +147,4 @@ void clear_bridge_error(struct pci_dev *

 EXPORT_SYMBOL(iochk_read);
 EXPORT_SYMBOL(iochk_clear);
+EXPORT_SYMBOL(iochk_devices);  /* for MCA driver */
Index: linux-2.6.13-rc1/arch/ia64/kernel/mca_drv.c
===
--- linux-2.6.13-rc1.orig/arch/ia64/kernel/mca_drv.c
+++ linux-2.6.13-rc1/arch/ia64/kernel/mca_drv.c
@@ -35,6 +35,12 @@

 #include "mca_drv.h"

+#ifdef CONFIG_IOMAP_CHECK
+#include 
+#include 
+extern struct list_head iochk_devices;
+#endif
+
 /* max size of SAL error record (default) */
 static int sal_rec_max = 1;

@@ -377,6 +383,79 @@ is_mca_global(peidx_table_t *peidx, pal_
return MCA_IS_GLOBAL;
 }

+#ifdef CONFIG_IOMAP_CHECK
+
+/**
+ * get_target_identifier - get address of target_identifier
+ * @peidx: pointer of index of processor error section
+ *
+ * Return value:
+ * addr if valid / 0 if not valid
+ */
+static u64 get_target_identifier(peidx_table_t *peidx)
+{
+   sal_log_mod_error_info_t *smei;
+
+   smei = peidx_bus_check(peidx, 0);
+   if (smei->valid.target_identifier)
+   return (smei->target_identifier);
+   return 0;
+}
+
+/**
+ * offending_addr_in_check - Check if the addr is in checking resource.
+ * @addr:  address offending this MCA
+ *
+ * Return value:
+ * 1 if in / 0 if out
+ */
+static int offending_addr_in_check(u64 addr)
+{
+   int i;
+   struct pci_dev *tdev;
+   iocookie *cookie;
+
+   if (list_empty(&iochk_devices))
+   return 0;
+
+   list_for_each_entry(cookie, &iochk_devices, list) {
+   tdev = cookie->dev;
+   for (i = 0; i < PCI_ROM_RESOURCE; i++) {
+ if (tdev->resource[i].start <= addr
+ && addr <= tdev->resource[i].end)
+   return 1;
+ if ((tdev->resource[i].flags
+ & (PCI_BASE_ADDRESS_SPACE|PCI_BASE_ADDRESS_MEM_TYPE_MASK))
+ == 
(PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64))
+   i++;
+   }
+   }
+   return 0;
+}
+
+/**
+ * pci_error_recovery - Check if MCA occur on transaction in iochk.
+ * @peidx: pointer of index of processor error section
+ *
+ * Return value:
+ * 1 if error could be cought in driver / 0 if not
+ */
+static int pci_error_recovery(peidx_table_t *peidx)
+{
+   u64 addr;
+
+   addr = get_target_identifier(peidx);
+   if (!addr)
+   return 0;
+
+   if (offending_addr_in_check(addr))
+   return 1;
+
+   return 0;
+}
+
+#endif /* CONFIG_IOMAP_CHECK */
+
 /**
  * recover_from_read_error - Try to recover the errors which type are "read"s.
  * @slidx: pointer of index of SAL error record
@@ -399,6 +478,11 @@ recover_from_read_error(slidx_table_t *s
if (!pbci->tv)
return 0;

+#ifdef CONFIG_IOMAP_CHECK
+   if (pci_error_recovery(peidx))
+   return 1;
+#endif
+
/*
 * cpu read or memory-mapped io read
 *


-
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.13-rc1 06/10] IOCHK interface for I/O error handling/detecting

2005-07-05 Thread Hidetoshi Seto

[This is 6 of 10 patches, "iochk-06-mcanotify.patch"]

- This is a headache:
  When ia64 get a problem on hardware, OS could request
  SAL(System Abstraction Layer: ia64 firmware) to gather
  system status via calling SAL_GET_STATE_INFO procedure.

  However (depend on implementation of SAL for its platform,
  hopefully), on the way of gathering, SAL also checks
  every host bridges and its status, and after that, resets
  the state...

  So we should take care of this reset by SAL.

  Handling MCA(Machine Check Abort) is one of a situation
  should we take care. Originally MCA is designed as a
  critical interruption, so when MCA comes, without OS's
  order, SAL gathers system status before OS gets its control.
  So since states of bridges are already reset on entrance of
  MCA, OS should notify "lost of state" to all "check-in"
  contexts, by marking its error flag, iocookie->error.

  There would be better way if OS can know the bridge state
  from data which SAL gathered, but in the meanwhile, I
  just do simple way.

PCI-parity error is one of MCA causes, is it OK?
Next, "data poisoning" helps us... see next (7 of 10).

Changes from previous one for 2.6.11.11:
  - (non)

Signed-off-by: Hidetoshi Seto <[EMAIL PROTECTED]>

---

 arch/ia64/kernel/mca.c  |   13 +
 arch/ia64/lib/iomap_check.c |7 ++-
 2 files changed, 19 insertions(+), 1 deletion(-)

Index: linux-2.6.13-rc1/arch/ia64/kernel/mca.c
===
--- linux-2.6.13-rc1.orig/arch/ia64/kernel/mca.c
+++ linux-2.6.13-rc1/arch/ia64/kernel/mca.c
@@ -77,6 +77,11 @@
 #include 
 #include 

+#ifdef CONFIG_IOMAP_CHECK
+#include 
+extern void notify_bridge_error(struct pci_dev *bridge);
+#endif
+
 #if defined(IA64_MCA_DEBUG_INFO)
 # define IA64_MCA_DEBUG(fmt...)printk(fmt)
 #else
@@ -893,6 +898,14 @@ ia64_mca_ucmc_handler(void)
sal_log_record_header_t *rh = 
IA64_LOG_CURR_BUFFER(SAL_INFO_TYPE_MCA);
rh->severity = sal_log_severity_corrected;
ia64_sal_clear_state_info(SAL_INFO_TYPE_MCA);
+
+#ifdef CONFIG_IOMAP_CHECK
+   /*
+* SAL already reads and clears error bits on bridge registers,
+* so we should have all running transactions to retry.
+*/
+   notify_bridge_error(0);
+#endif
}
/*
 *  Wakeup all the processors which are spinning in the rendezvous
Index: linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
===
--- linux-2.6.13-rc1.orig/arch/ia64/lib/iomap_check.c
+++ linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
@@ -111,7 +111,12 @@ void notify_bridge_error(struct pci_dev
return;

/* notify error to all transactions using this host bridge */
-   if (bridge) {
+   if (!bridge) {
+   /* global notify, ex. MCA */
+   list_for_each_entry(cookie, &iochk_devices, list) {
+   cookie->error = 1;
+   }
+   } else {
/* local notify, ex. Parity, Abort etc. */
list_for_each_entry(cookie, &iochk_devices, list) {
if (cookie->host == bridge)

-
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.13-rc1 07/10] IOCHK interface for I/O error handling/detecting

2005-07-05 Thread Hidetoshi Seto

[This is 7 of 10 patches, "iochk-07-poison.patch"]

- When bus-error occur on write, write data is broken on
  the bus, so target device gets broken data.

  There are 2 way for such device to take:
   - send PERR(Parity Error) to host, expecting immediate panic.
   - mark status register as error, expecting its driver to read
 it and decide to retry.

  So it is not difficult for drivers to recover from error on
  write if it can take latter way, and if it don't worry about
  taking time to wait completion of write.

- When bus-error occur on read, read data is broken on
  the bus, so host bridge gets broken data.

  There are 2 way for such bridge to take:
   - send BERR(Bus Error) to host, expecting immediate panic.
   - mark data as "poisoned" and throw it to destination,
 expecting panic if system touched it but cannot stop data
 pollution.

  Former is traditional way, latter is modern way, called
  "data poisoning". The important difference is whether OS
  can get a chance to recover from the error.
  Usually, sending BERR doesn't tell us "where it comes",
  "who it orders", so we cannot do anything except panic.
  In the other hand, poisoned data will reach its destination
  and will cause a error on there again. Yes, destination is
  "where who lives".

  Well, the idea is quite simple:
   "driver checks read data, and recover if it was poisoned."

  Checking all read at once (ex. take a memo of all read
  addresses touched after iochk_clear and check them all in
  iochk_read) does not make sense. Practical way is check
  each read, keep its result, and read it at end.

Touching poisoned data become a MCA, so now it directly means
a system down. But since the MCA tells us "where it happens",
we can recover it...? All right, let's see next (8 of 10).

Changes from previous one for 2.6.11.11:
  - move barrier function macro into gcc_inirin.h.
  - could anyone write same barrier for intel compiler?
Tony or David, could you help me?

Signed-off-by: Hidetoshi Seto <[EMAIL PROTECTED]>

---

 include/asm-ia64/gcc_intrin.h |   16 +++
 include/asm-ia64/io.h |   96 ++
 2 files changed, 112 insertions(+)

Index: linux-2.6.13-rc1/include/asm-ia64/io.h
===
--- linux-2.6.13-rc1.orig/include/asm-ia64/io.h
+++ linux-2.6.13-rc1/include/asm-ia64/io.h
@@ -189,6 +189,8 @@ __ia64_mk_io_addr (unsigned long port)
  * during optimization, which is why we use "volatile" pointers.
  */

+#ifdef CONFIG_IOMAP_CHECK
+
 static inline unsigned int
 ___ia64_inb (unsigned long port)
 {
@@ -197,6 +199,8 @@ ___ia64_inb (unsigned long port)

ret = *addr;
__ia64_mf_a();
+   ia64_mca_barrier(ret);
+
return ret;
 }

@@ -208,6 +212,8 @@ ___ia64_inw (unsigned long port)

ret = *addr;
__ia64_mf_a();
+   ia64_mca_barrier(ret);
+
return ret;
 }

@@ -219,9 +225,48 @@ ___ia64_inl (unsigned long port)

ret = *addr;
__ia64_mf_a();
+   ia64_mca_barrier(ret);
+
+   return ret;
+}
+
+#else /* CONFIG_IOMAP_CHECK */
+
+static inline unsigned int
+___ia64_inb (unsigned long port)
+{
+   volatile unsigned char *addr = __ia64_mk_io_addr(port);
+   unsigned char ret;
+
+   ret = *addr;
+   __ia64_mf_a();
+   return ret;
+}
+
+static inline unsigned int
+___ia64_inw (unsigned long port)
+{
+   volatile unsigned short *addr = __ia64_mk_io_addr(port);
+   unsigned short ret;
+
+   ret = *addr;
+   __ia64_mf_a();
return ret;
 }

+static inline unsigned int
+___ia64_inl (unsigned long port)
+{
+   volatile unsigned int *addr = __ia64_mk_io_addr(port);
+   unsigned int ret;
+
+   ret = *addr;
+   __ia64_mf_a();
+   return ret;
+}
+
+#endif /* CONFIG_IOMAP_CHECK */
+
 static inline void
 ___ia64_outb (unsigned char val, unsigned long port)
 {
@@ -338,6 +383,55 @@ __outsl (unsigned long port, const void
  * a good idea).  Writes are ok though for all existing ia64 platforms (and
  * hopefully it'll stay that way).
  */
+
+#ifdef CONFIG_IOMAP_CHECK
+
+static inline unsigned char
+___ia64_readb (const volatile void __iomem *addr)
+{
+   unsigned char val;
+
+   val = *(volatile unsigned char __force *)addr;
+   ia64_mca_barrier(val);
+
+   return val;
+}
+
+static inline unsigned short
+___ia64_readw (const volatile void __iomem *addr)
+{
+   unsigned short val;
+
+   val = *(volatile unsigned short __force *)addr;
+   ia64_mca_barrier(val);
+
+   return val;
+}
+
+static inline unsigned int
+___ia64_readl (const volatile void __iomem *addr)
+{
+   unsigned int val;
+
+   val = *(volatile unsigned int __force *) addr;
+   ia64_mca_barrier(val);
+
+   return val;
+}
+
+static inline unsigned long
+___ia64_readq (const volatile void __iomem *addr)
+{
+   unsigned long val;
+
+   val = *(volatile unsigned long __force *) addr;
+   ia64

[PATCH 2.6.13-rc1 05/10] IOCHK interface for I/O error handling/detecting

2005-07-05 Thread Hidetoshi Seto

[This is 5 of 10 patches, "iochk-05-check_bridge.patch"]

- Consider three devices, A, B, and C are placed under a same
  host bridge H. After A and B checked-in (=passed iochk_clear,
  doing some I/Os, not come to call iochk_read yet), now C is
  going to check-in, just entered iochk_clear, but C finds out
  that H indicates error.

  It means that A or B hits a bus error, but there is no data
  which one actually hits the error. So, C should notify the
  error to both of A and B, and clear the H's status to start
  its own I/Os.

  If there are only two devices, it become more simple. It is
  clear if one find a bridge error while another is check-in,
  the error is nothing except for another's.

Well, works concerning registers (devices and bridges) are
almost shaped up. So, from next, I'll move to deep phase
to implement more arch-specific codes... see next (6 of 10).

Changes from previous one for 2.6.11.11:
  - (non)

Signed-off-by: Hidetoshi Seto <[EMAIL PROTECTED]>

---

 arch/ia64/lib/iomap_check.c |   45 
 1 files changed, 45 insertions(+)

Index: linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
===
--- linux-2.6.13-rc1.orig/arch/ia64/lib/iomap_check.c
+++ linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
@@ -17,6 +17,9 @@ DEFINE_SPINLOCK(iochk_lock);  /* all work
 static struct pci_dev *search_host_bridge(struct pci_dev *dev);
 static int have_error(struct pci_dev *dev);

+void notify_bridge_error(struct pci_dev *bridge);
+void clear_bridge_error(struct pci_dev *bridge);
+
 void iochk_init(void)
 {
/* setup */
@@ -33,6 +36,11 @@ void iochk_clear(iocookie *cookie, struc
cookie->host = search_host_bridge(dev);

spin_lock_irqsave(&iochk_lock, flag);
+   if (cookie->host && have_error(cookie->host)) {
+   /* someone under my bridge causes error... */
+   notify_bridge_error(cookie->host);
+   clear_bridge_error(cookie->host);
+   }
list_add(&cookie->list, &iochk_devices);
spin_unlock_irqrestore(&iochk_lock, flag);

@@ -95,5 +103,42 @@ static int have_error(struct pci_dev *de
return 0;
 }

+void notify_bridge_error(struct pci_dev *bridge)
+{
+   iocookie *cookie;
+
+   if (list_empty(&iochk_devices))
+   return;
+
+   /* notify error to all transactions using this host bridge */
+   if (bridge) {
+   /* local notify, ex. Parity, Abort etc. */
+   list_for_each_entry(cookie, &iochk_devices, list) {
+   if (cookie->host == bridge)
+   cookie->error = 1;
+   }
+   }
+}
+
+void clear_bridge_error(struct pci_dev *bridge)
+{
+   u16 status = ( PCI_STATUS_REC_TARGET_ABORT
+ | PCI_STATUS_REC_MASTER_ABORT
+ | PCI_STATUS_DETECTED_PARITY );
+
+   /* clear bridge status */
+   switch (bridge->hdr_type) {
+   case PCI_HEADER_TYPE_NORMAL: /* 0 */
+   pci_write_config_word(bridge, PCI_STATUS, status);
+   break;
+   case PCI_HEADER_TYPE_BRIDGE: /* 1 */
+   pci_write_config_word(bridge, PCI_SEC_STATUS, status);
+   break;
+   case PCI_HEADER_TYPE_CARDBUS: /* 2 */
+   default:
+   BUG();
+   }
+}
+
 EXPORT_SYMBOL(iochk_read);
 EXPORT_SYMBOL(iochk_clear);

-
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] Filesystem capabilities support

2005-07-05 Thread Nathan Scott
Hi Nicholas,

On Sat, Jul 02, 2005 at 10:41:08PM +0100, Nicholas Hans Simmonds wrote:
> This is a simple attempt at providing capability support through extended
> attributes.
> ...
> +#define XATTR_CAP_SET XATTR_SECURITY_PREFIX "cap_set"
> ...
> + ret = bprm_getxattr(bprm_dentry,XATTR_CAP_SET,&caps,sizeof(caps));
> + if(ret == sizeof(caps)) {
> + if(caps.version == _LINUX_CAPABILITY_VERSION) {
> + cap_t(bprm->cap_effective) &= caps.mask_effective;
> ...

Since this is being stored on-disk, you may want to consider
endianness issues.  I guess for binaries this isn't really a
problem (since they're unlikely to be run on other platforms),
though perhaps it is for shell scripts and the like.  Storing
values in native endianness poses problems for backup/restore
programs, NFS, etc.

IIRC, the other LSM security attribute values are stored as
ASCII strings on-disk to avoid this sort of issue.

cheers.

-- 
Nathan
-
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.13-rc1 04/10] IOCHK interface for I/O error handling/detecting

2005-07-05 Thread Hidetoshi Seto

[This is 4 of 10 patches, "iochk-04-register_bridge.patch"]

- Since there could be a (PCI-)bus-error, some kind of error
  cannot detected on the device but on its hosting bridge.
  So, it is also required to check the bridge's register.

  In other words, to check a bus-error correctly, we need to
  check both end of the bus, device and its host bridge.

OK, but often bridges are shared by multiple devices, right?
So we need care to handle it... Yes, see next (5 of 10).

Changes from previous one for 2.6.11.11:
  - trivial coding style fix.

Signed-off-by: Hidetoshi Seto <[EMAIL PROTECTED]>

---

 arch/ia64/lib/iomap_check.c |   20 +++-
 include/asm-ia64/io.h   |1 +
 2 files changed, 20 insertions(+), 1 deletion(-)

Index: linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
===
--- linux-2.6.13-rc1.orig/arch/ia64/lib/iomap_check.c
+++ linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
@@ -14,6 +14,7 @@ int  iochk_read(iocookie *cookie);
 struct list_head iochk_devices;
 DEFINE_SPINLOCK(iochk_lock);   /* all works are excluded on this lock */

+static struct pci_dev *search_host_bridge(struct pci_dev *dev);
 static int have_error(struct pci_dev *dev);

 void iochk_init(void)
@@ -29,6 +30,7 @@ void iochk_clear(iocookie *cookie, struc
INIT_LIST_HEAD(&(cookie->list));

cookie->dev = dev;
+   cookie->host = search_host_bridge(dev);

spin_lock_irqsave(&iochk_lock, flag);
list_add(&cookie->list, &iochk_devices);
@@ -43,7 +45,8 @@ int iochk_read(iocookie *cookie)
int ret = 0;

spin_lock_irqsave(&iochk_lock, flag);
-   if (cookie->error || have_error(cookie->dev))
+   if ( cookie->error || have_error(cookie->dev)
+   || (cookie->host && have_error(cookie->host)) )
ret = 1;
list_del(&cookie->list);
spin_unlock_irqrestore(&iochk_lock, flag);
@@ -51,6 +54,21 @@ int iochk_read(iocookie *cookie)
return ret;
 }

+struct pci_dev *search_host_bridge(struct pci_dev *dev)
+{
+   struct pci_bus *pbus;
+
+   /* there is no bridge */
+   if (!dev->bus->self)
+   return NULL;
+
+   /* find root bus bridge */
+   for (pbus = dev->bus; pbus->parent && pbus->parent->self;
+   pbus = pbus->parent);
+
+   return pbus->self;
+}
+
 static int have_error(struct pci_dev *dev)
 {
u16 status;
Index: linux-2.6.13-rc1/include/asm-ia64/io.h
===
--- linux-2.6.13-rc1.orig/include/asm-ia64/io.h
+++ linux-2.6.13-rc1/include/asm-ia64/io.h
@@ -78,6 +78,7 @@ extern unsigned int num_io_spaces;
 typedef struct {
struct list_headlist;
struct pci_dev  *dev;   /* target device */
+   struct pci_dev  *host;  /* hosting bridge */
unsigned long   error;  /* error flag */
 } iocookie;


-
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.13-rc1 03/10] IOCHK interface for I/O error handling/detecting

2005-07-05 Thread Hidetoshi Seto

[This is 3 of 10 patches, "iochk-03-register.patch"]

- Implement ia64 version of basic codes:
iochk_clear, iochk_read, iochk_init, and iocookie

  The direction is:

- Have a "now in check" global list, "iochk_devices",
  for future use.

- Take a lock, "iochk_lock", to protect the global list.

- iochk_clear packs *dev into iocookie, and add it to
  the global list. After all prepared, clear error-flag
  in cookie to start io-critical-session.

- iochk_read checks error-flag and device's status
  register. After removing iocookie from list, return
  the result.

This is too simple. We need more codes... See next (4 of 10).

Changes from previous one for 2.6.11.11:
  - trivial coding style fix.

Signed-off-by: Hidetoshi Seto <[EMAIL PROTECTED]>

---

 arch/ia64/lib/iomap_check.c |   55 ++--
 include/asm-ia64/io.h   |5 +++-
 2 files changed, 57 insertions(+), 3 deletions(-)

Index: linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
===
--- linux-2.6.13-rc1.orig/arch/ia64/lib/iomap_check.c
+++ linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
@@ -4,24 +4,75 @@
  */

 #include 
+#include 
+#include 

 void iochk_init(void);
 void iochk_clear(iocookie *cookie, struct pci_dev *dev);
 int  iochk_read(iocookie *cookie);

+struct list_head iochk_devices;
+DEFINE_SPINLOCK(iochk_lock);   /* all works are excluded on this lock */
+
+static int have_error(struct pci_dev *dev);
+
 void iochk_init(void)
 {
/* setup */
+   INIT_LIST_HEAD(&iochk_devices);
 }

 void iochk_clear(iocookie *cookie, struct pci_dev *dev)
 {
-   /* register device etc. */
+   unsigned long flag;
+
+   INIT_LIST_HEAD(&(cookie->list));
+
+   cookie->dev = dev;
+
+   spin_lock_irqsave(&iochk_lock, flag);
+   list_add(&cookie->list, &iochk_devices);
+   spin_unlock_irqrestore(&iochk_lock, flag);
+
+   cookie->error = 0;
 }

 int iochk_read(iocookie *cookie)
 {
-   /* check error etc. */
+   unsigned long flag;
+   int ret = 0;
+
+   spin_lock_irqsave(&iochk_lock, flag);
+   if (cookie->error || have_error(cookie->dev))
+   ret = 1;
+   list_del(&cookie->list);
+   spin_unlock_irqrestore(&iochk_lock, flag);
+
+   return ret;
+}
+
+static int have_error(struct pci_dev *dev)
+{
+   u16 status;
+
+   /* check status */
+   switch (dev->hdr_type) {
+   case PCI_HEADER_TYPE_NORMAL: /* 0 */
+   pci_read_config_word(dev, PCI_STATUS, &status);
+   break;
+   case PCI_HEADER_TYPE_BRIDGE: /* 1 */
+   pci_read_config_word(dev, PCI_SEC_STATUS, &status);
+   break;
+   case PCI_HEADER_TYPE_CARDBUS: /* 2 */
+   return 0; /* FIX ME */
+   default:
+   BUG();
+   }
+
+   if ( (status & PCI_STATUS_REC_TARGET_ABORT)
+   || (status & PCI_STATUS_REC_MASTER_ABORT)
+   || (status & PCI_STATUS_DETECTED_PARITY) )
+   return 1;

return 0;
 }
Index: linux-2.6.13-rc1/include/asm-ia64/io.h
===
--- linux-2.6.13-rc1.orig/include/asm-ia64/io.h
+++ linux-2.6.13-rc1/include/asm-ia64/io.h
@@ -72,10 +72,13 @@ extern unsigned int num_io_spaces;
 #include 

 #ifdef CONFIG_IOMAP_CHECK
+#include 

 /* ia64 iocookie */
 typedef struct {
-   int dummy;
+   struct list_headlist;
+   struct pci_dev  *dev;   /* target device */
+   unsigned long   error;  /* error flag */
 } iocookie;

 /* Enable ia64 iochk - See arch/ia64/lib/iomap_check.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/


[PATCH 2.6.13-rc1 02/10] IOCHK interface for I/O error handling/detecting

2005-07-05 Thread Hidetoshi Seto

[This is 2 of 10 patches, "iochk-02-ia64.patch"]

- Add "config IOMAP_CHECK" to change definitions from generic
  to specific.

- Defines ia64 version of:
iochk_clear, iochk_read, iochk_init, and iocookie
  But they are no-ops yet. See next patch (3 of 10).

Changes from previous one for 2.6.11.11:
  - simplify define of iocookie structure.

Signed-off-by: Hidetoshi Seto <[EMAIL PROTECTED]>

---

 arch/ia64/Kconfig   |   13 +
 arch/ia64/lib/Makefile  |1 +
 arch/ia64/lib/iomap_check.c |   30 ++
 include/asm-ia64/io.h   |   13 +
 4 files changed, 57 insertions(+)

Index: linux-2.6.13-rc1/arch/ia64/lib/Makefile
===
--- linux-2.6.13-rc1.orig/arch/ia64/lib/Makefile
+++ linux-2.6.13-rc1/arch/ia64/lib/Makefile
@@ -16,6 +16,7 @@ lib-$(CONFIG_MCKINLEY)+= copy_page_mck.
 lib-$(CONFIG_PERFMON)  += carta_random.o
 lib-$(CONFIG_MD_RAID5) += xor.o
 lib-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o
+lib-$(CONFIG_IOMAP_CHECK) += iomap_check.o

 AFLAGS___divdi3.o  =
 AFLAGS___udivdi3.o = -DUNSIGNED
Index: linux-2.6.13-rc1/arch/ia64/Kconfig
===
--- linux-2.6.13-rc1.orig/arch/ia64/Kconfig
+++ linux-2.6.13-rc1/arch/ia64/Kconfig
@@ -413,6 +413,19 @@ config PCI_DOMAINS
bool
default PCI

+config IOMAP_CHECK
+   bool "Support iochk interfaces for IO error detection."
+   depends on PCI && EXPERIMENTAL
+   ---help---
+ Saying Y provides iochk infrastructure for "RAS-aware" drivers
+ to detect and recover some IO errors, which strongly required by
+ some of very-high-reliable systems.
+ The implementation of this infrastructure is highly depend on arch,
+ bus system, chipset and so on.
+ Currentry, very few drivers on few arch actually implements this.
+
+ If you don't know what to do here, say N.
+
 source "drivers/pci/Kconfig"

 source "drivers/pci/hotplug/Kconfig"
Index: linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
===
--- /dev/null
+++ linux-2.6.13-rc1/arch/ia64/lib/iomap_check.c
@@ -0,0 +1,30 @@
+/*
+ * File:iomap_check.c
+ * Purpose: Implement the IA64 specific iomap recovery interfaces
+ */
+
+#include 
+
+void iochk_init(void);
+void iochk_clear(iocookie *cookie, struct pci_dev *dev);
+int  iochk_read(iocookie *cookie);
+
+void iochk_init(void)
+{
+   /* setup */
+}
+
+void iochk_clear(iocookie *cookie, struct pci_dev *dev)
+{
+   /* register device etc. */
+}
+
+int iochk_read(iocookie *cookie)
+{
+   /* check error etc. */
+
+   return 0;
+}
+
+EXPORT_SYMBOL(iochk_read);
+EXPORT_SYMBOL(iochk_clear);
Index: linux-2.6.13-rc1/include/asm-ia64/io.h
===
--- linux-2.6.13-rc1.orig/include/asm-ia64/io.h
+++ linux-2.6.13-rc1/include/asm-ia64/io.h
@@ -70,6 +70,19 @@ extern unsigned int num_io_spaces;
 #include 
 #include 
 #include 
+
+#ifdef CONFIG_IOMAP_CHECK
+
+/* ia64 iocookie */
+typedef struct {
+   int dummy;
+} iocookie;
+
+/* Enable ia64 iochk - See arch/ia64/lib/iomap_check.c */
+#define HAVE_ARCH_IOMAP_CHECK
+
+#endif /* CONFIG_IOMAP_CHECK  */
+
 #include 

 /*


-
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: ALPS psmouse_reset on reconnect confusing Tecra M2

2005-07-05 Thread Micheal Marineau
Dmitry Torokhov wrote:
> On Monday 04 July 2005 16:14, Mike Waychison wrote:
> 
>>Hi,
>>
>>I just upgrade my Tecra M2 this weekend to the latest GIT tree and
>>noticed that my mouse pointer/touchpad is now broken on resume.
>>
>>Investigating, it appears that mouse device gets confused due to the
>>introduced psmouse_reset(psmouse) during reconnect:
>>
>>http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f3a5c73d5ecb40909db662c4d2ace497b25c5940
> 
> 
> Hi,
> 
> Please try the following patch:
> 
>   http://www.ucw.cz/~vojtech/input/alps-suspend-typo
>  

This fixed the problem for mylaptop, but ONLY if I had #define DEBUG in
alps.c, switch it back to the usual #undef and the exact same problem
happens.  I've got no idea what's going on, I'll poke at it more when
I'm awake


-- 
Michael Marineau
[EMAIL PROTECTED]
Oregon State University


signature.asc
Description: OpenPGP digital signature


Re: [git patches] IDE update

2005-07-05 Thread Grant Coady
On Tue, 5 Jul 2005 17:51:50 -0700 (PDT), Linus Torvalds <[EMAIL PROTECTED]> 
wrote:
>
>Btw, can you try this same thing (or at least a subset) with a large file
>on a filesystem? Does that show the same pattern, or is it always just the 
>raw device?
>
Sure, take a while longer to vary by block size.  One effect seems 
to be wrong is interaction between /dev/hda and /dev/hdc in 'peetoo', 
the IDE channels not independent?

write:  time $(dd if=/dev/zero bs=1M count=500 of=/zeroes; sync)
read:   time dd of=/dev/null bs=1M if=/zeroes

summary 2.4.31-hf1  2.6.12.2
boxen \ time ->  w   r   w   r
--- 
menace  58.550  57  47.5
pooh24  24  22.527
peetoo  33  20  26.522
(simultaneuous  57  37.552  38.5)
silly   54  24  49  25
tosh30  19.527  19.5

filesystem: reiserfs 3.6, distro: slackware-10.1 + updates
hardware config, etc: http://scatter.mine.nu/test/

--Grant

the long story:

[EMAIL PROTECTED]:~# uname -r
2.4.31-hf1
[EMAIL PROTECTED]:~# df
Filesystem   1K-blocks  Used Available Use% Mounted on
/dev/hda3  1991992   1074516917476  54% /
deltree:/home/share2064256   1042968   1021288  51% /home/share

[EMAIL PROTECTED]:~# time $(dd if=/dev/zero bs=1M count=500 of=/zeroes; sync)
500+0 records in
500+0 records out

real0m57.830s
user0m0.050s
sys 0m20.940s
[EMAIL PROTECTED]:~# time $(dd if=/dev/zero bs=1M count=500 of=/zeroes; sync)
500+0 records in
500+0 records out

real0m59.041s
user0m0.030s
sys 0m21.780s
[EMAIL PROTECTED]:~# time dd of=/dev/null bs=1M if=/zeroes
500+0 records in
500+0 records out

real0m49.963s
user0m0.000s
sys 0m15.510s
- - -
[EMAIL PROTECTED]:~# uname -r
2.6.12.2a
[EMAIL PROTECTED]:~# time $(dd if=/dev/zero bs=1M count=500 of=/zeroes; sync)
500+0 records in
500+0 records out

real0m57.199s
user0m0.022s
sys 0m15.040s
[EMAIL PROTECTED]:~# time $(dd if=/dev/zero bs=1M count=500 of=/zeroes; sync)
500+0 records in
500+0 records out

real0m56.825s
user0m0.024s
sys 0m14.893s
[EMAIL PROTECTED]:~# time dd of=/dev/null bs=1M if=/zeroes
500+0 records in
500+0 records out

real0m47.560s
user0m0.017s
sys 0m15.533s
[EMAIL PROTECTED]:~# time dd of=/dev/null bs=1M if=/zeroes
500+0 records in
500+0 records out

real0m47.842s
user0m0.012s
sys 0m15.647s

o o o
[EMAIL PROTECTED]:~# df
Filesystem   1K-blocks  Used Available Use% Mounted on
/dev/hda3  3084380   2018240   1066140  66% /
/dev/hda6  2056220   1049544   1006676  52% /usr/src
/dev/hda7   256996 34260222736  14% /usr/local
/dev/hda8   256996 33896223100  14% /home
/dev/hda1420562536 32840  20529696   1% /home/pooh
deltree:/home/share2064256   1042968   1021288  51% /home/share

[EMAIL PROTECTED]:~# uname -r
2.4.31-hf1
[EMAIL PROTECTED]:~# time $(dd if=/dev/zero bs=1M count=500 of=/zeroes; sync)
500+0 records in
500+0 records out

real0m23.912s
user0m0.010s
sys 0m19.820s
[EMAIL PROTECTED]:~# time dd of=/dev/null bs=1M if=/zeroes
500+0 records in
500+0 records out

real0m24.302s
user0m0.020s
sys 0m16.760s
- - -
[EMAIL PROTECTED]:~# uname -r
2.6.12.2a
[EMAIL PROTECTED]:~# time $(dd if=/dev/zero bs=1M count=500 of=/zeroes; sync)
500+0 records in
500+0 records out

real0m22.449s
user0m0.017s
sys 0m13.576s
[EMAIL PROTECTED]:~# time dd of=/dev/null bs=1M if=/zeroes
500+0 records in
500+0 records out

real0m26.780s
user0m0.010s
sys 0m13.398s

o o o

peetoo:~$ df
Filesystem   1K-blocks  Used Available Use% Mounted on
/dev/hda3  2586348   1075652   1510696  42% /
/dev/hdc3  2586348   2044228542120  80% /usr
/dev/hdc6  2586348   1217568   1368780  48% /usr/src
/dev/hda9 20562504  10821500   9741004  53% /home/install
/dev/hdc9 20562504   4329320  16233184  22% /home/public
/dev/hda1041446344  39676256   1770088  96% /home/archive
deltree:/home/share2064256   1042968   1021288  51% /home/share

peetoo:~$ uname -r
2.4.31-hf1
peetoo:~$ time $(dd if=/dev/zero bs=1M count=500 of=/zeroes; sync)
500+0 records in
500+0 records out

real0m33.322s
user0m0.000s
sys 0m13.650s
peetoo:~$ time $(dd if=/dev/zero bs=1M count=500 of=/zeroes; sync)
500+0 records in
500+0 records out

real0m32.983s
user0m0.010s
sys 0m13.740s
peetoo:~$ time $(dd if=/dev/zero bs=1M count=500 of=/usr/zeroes; sync)
500+0 records in
500+0 records out

real0m30.775s
user0m0.000s
sys 0m13.600s
peetoo:~$ time $(dd if=/dev/zero bs=1M count=500 of=/usr/zeroes; sync)
500+0 records in
500+0 records out

real0m33.077s
user0m0.010s
sys 0m13.740s
peetoo:~$ time dd of=/dev/null bs=1M if=/zeroes
500+0 records in
500+0 records out

real

Re: XFS corruption during power-blackout

2005-07-05 Thread Nathan Scott
On Wed, Jul 06, 2005 at 07:24:03AM +0300, Al Boldi wrote:
> Was ordered mode disabled/removed when XFS was add to the vanilla-kernel?

No, XFS has never supported such a mode.

cheers.

-- 
Nathan
-
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/


oops in free_block in 2.6.12-git5

2005-07-05 Thread Alessandro Suardi
Hi all,

  my bittorrent box running 2.6.12-git5 (AMD K7-800,
  256MB RAM, fairly recently updated FC3) decided to
  oops  a few hours ago. On the console I had a very long
  trace before the actual lockup, but I didn't write it down
  (it had ide_dma__request  and bh_ calls as
  main part of the trace, though it took up all of my screen
  and more so I can't tell where the EIP was).

At reboot however I have an oops with EIP in free_block
 very likely happened after/during an updatedb run which
 very closely resembles this report that hit isofs in 2.6.9-rc2:

http://www.ussg.iu.edu/hypermail/linux/kernel/0409.1/1790.html

The only thing running on the box at that time was a
 download of a 8GB torrent with bittorrent from the
 FC3 bittorrent-4.1.1-2.1.fc3.rf package.

Attached the oops trace and the decoded oops
 after I edited the trace to remove the timed printks
 and ran it through ksymoops 2.4.11.

kernel isn't running CONFIG_DEBUG_SLAB but
 if you think this is a legitimate slab bug I'll later
 update to the current -git kernel and enable the
 slab debugging.

Thanks,

--alessandro

 "When it comes to luck / you make your own
  Tonight I've got dirt on my hands
  But I'm building me a new home"

(Bruce Springsteen - "Lucky Town")


oops-02.txt.decoded
Description: Binary data
Jul  6 04:02:11 donkey kernel: [198064.853894] Unable to handle kernel paging 
request at virtual address 2071fce4
Jul  6 04:02:11 donkey kernel: [198064.854464]  printing eip:
Jul  6 04:02:11 donkey kernel: [198064.854665] c013c8ef
Jul  6 04:02:11 donkey kernel: [198064.854828] *pde = 
Jul  6 04:02:11 donkey kernel: [198064.855035] Oops:  [#1]
Jul  6 04:02:11 donkey kernel: [198064.855242] PREEMPT
Jul  6 04:02:11 donkey kernel: [198064.855416] Modules linked in: nls_iso8859_1 
parport_pc parport 8139too floppy
Jul  6 04:02:11 donkey kernel: [198064.856021] CPU:0
Jul  6 04:02:11 donkey kernel: [198064.856023] EIP:0060:[]Not 
tainted VLI
Jul  6 04:02:11 donkey kernel: [198064.856027] EFLAGS: 00010016   (2.6.12-git5)
Jul  6 04:02:11 donkey kernel: [198064.856901] EIP is at free_block+0x6f/0xe0
Jul  6 04:02:11 donkey kernel: [198064.857202] eax: 0080   ebx: 2071fce0   
ecx:    edx: c100
Jul  6 04:02:11 donkey kernel: [198064.857691] esi: cffef1e0   edi: 004f   
ebp: cffa3ef0   esp: cffa3ed4
Jul  6 04:02:11 donkey kernel: [198064.858177] ds: 007b   es: 007b   ss: 0068
Jul  6 04:02:11 donkey kernel: [198064.858476] Process events/0 (pid: 3, 
threadinfo=cffa2000 task=c127a020)
Jul  6 04:02:11 donkey kernel: [198064.858956] Stack: cffef1ec cffef1fc 
2972c214 cffea210 cffea210 cffea200 2972c214 cffa3f08
Jul  6 04:02:11 donkey kernel: [198064.859678]c013cfbf cffef1e0 
cffef6fc cffef1e0 0003 cffa3f34 c013d074 cffa2000
Jul  6 04:02:11 donkey kernel: [198064.860398]cffef6fc cffa2000 
cffa2000 cffef250 cffa3f34 c046ca80 0297 c046ca84
Jul  6 04:02:11 donkey kernel: [198064.861118] Call Trace:
Jul  6 04:02:11 donkey kernel: [198064.861494]  [] 
show_stack+0x7a/0x90
Jul  6 04:02:11 donkey kernel: [198064.862016]  [] 
show_registers+0x156/0x1d0
Jul  6 04:02:11 donkey kernel: [198064.862570]  [] die+0xe4/0x170
Jul  6 04:02:11 donkey kernel: [198064.863049]  [] 
do_page_fault+0x453/0x671
Jul  6 04:02:11 donkey kernel: [198064.863604]  [] 
error_code+0x4f/0x54
Jul  6 04:02:11 donkey kernel: [198064.864120]  [] 
drain_array_locked+0x5f/0xa0
Jul  6 04:02:11 donkey kernel: [198064.864686]  [] 
cache_reap+0x74/0x1d0
Jul  6 04:02:11 donkey kernel: [198064.865209]  [] 
worker_thread+0x1c4/0x280
Jul  6 04:02:11 donkey kernel: [198064.865762]  [] kthread+0x8b/0xc0
Jul  6 04:02:11 donkey kernel: [198064.866266]  [] 
kernel_thread_helper+0x5/0x10
Jul  6 04:02:11 donkey kernel: [198064.866835] Code: 8b 55 e8 89 5e 1c 89 53 04 
47 3b 7d ec 7d 6d 8b 45 f0 8b 15 90 cb 46 c0 8b 0c b8 8d 81 00 00 00 40 c1 e8 
0c c1 e0 05 8b 5c 10 1c <8b> 53 04 8b 03 89 50 04 89 02 31 d2 2b 4b 0c c7 03 00 
01 10 00
Jul  6 04:02:11 donkey kernel: [198064.955135]  <6>note: events/0[3] exited 
with preempt_count 1


[PATCH 2.6.13-rc1 01/10] IOCHK interface for I/O error handling/detecting

2005-07-05 Thread Hidetoshi Seto

Hi all,

The followings are updated version of patches I've posted to
implement IOCHK interface for I/O error handling/detecting.

The abstraction of patches hasn't changed, so please refer
archives if you need, e.g.: http://lwn.net/Articles/139240/

Tony, how do you think about applying my patches to your tree?

Thanks,
H.Seto

[This is 1 of 10 patches, "iochk-01-generic.patch"]

- It defines:
a pair of function  : iochk_clear and iochk_read
a function for init : iochk_init
type of control var : iocookie
  and describe "no-ops" as its "generic" action.

- HAVE_ARCH_IOMAP_CHECK allows us to change whole definition
  of these functions and type from generic one to specific one.
  See next patch (2 of 10).

Changes from previous one for 2.6.11.11:
  - reform default "nop" functions in static inline style.
  - I don't mind using EXPORT_SYMBOL_GPL but keep them as
before. Does anyone worry about this?

Signed-off-by: Hidetoshi Seto <[EMAIL PROTECTED]>

---

 drivers/pci/pci.c   |2 ++
 include/asm-generic/iomap.h |   32 
 lib/iomap.c |6 ++
 3 files changed, 40 insertions(+)

Index: linux-2.6.13-rc1/lib/iomap.c
===
--- linux-2.6.13-rc1.orig/lib/iomap.c
+++ linux-2.6.13-rc1/lib/iomap.c
@@ -230,3 +230,9 @@ void pci_iounmap(struct pci_dev *dev, vo
 }
 EXPORT_SYMBOL(pci_iomap);
 EXPORT_SYMBOL(pci_iounmap);
+
+#ifndef HAVE_ARCH_IOMAP_CHECK
+/* Since generic funcs are inlined and defined in header, just export */
+EXPORT_SYMBOL(iochk_clear);
+EXPORT_SYMBOL(iochk_read);
+#endif
Index: linux-2.6.13-rc1/include/asm-generic/iomap.h
===
--- linux-2.6.13-rc1.orig/include/asm-generic/iomap.h
+++ linux-2.6.13-rc1/include/asm-generic/iomap.h
@@ -65,4 +65,36 @@ struct pci_dev;
 extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long 
max);
 extern void pci_iounmap(struct pci_dev *dev, void __iomem *);

+/*
+ * IOMAP_CHECK provides additional interfaces for drivers to detect
+ * some IO errors, supports drivers having ability to recover errors.
+ *
+ * All works around iomap-check depends on the design of "iocookie"
+ * structure. Every architecture owning its iomap-check is free to
+ * define the actual design of iocookie to fit its special style.
+ */
+#ifndef HAVE_ARCH_IOMAP_CHECK
+/* Dummy definition of default iocookie */
+typedef int iocookie;
+#endif
+
+/*
+ * Clear/Read iocookie to check IO error while using iomap.
+ *
+ * Note that default iochk_clear-read pair interfaces don't have
+ * any effective error check, but some high-reliable platforms
+ * would provide useful information to you.
+ * And note that some action may be limited (ex. irq-unsafe)
+ * between the pair depend on the facility of the platform.
+ */
+#ifdef HAVE_ARCH_IOMAP_CHECK
+extern void iochk_init(void);
+extern void iochk_clear(iocookie *cookie, struct pci_dev *dev);
+extern int iochk_read(iocookie *cookie);
+#else
+static inline void iochk_init(void) {}
+static inline void iochk_clear(iocookie *cookie, struct pci_dev *dev) {}
+static inline int iochk_read(iocookie *cookie) { return 0; }
+#endif
+
 #endif
Index: linux-2.6.13-rc1/drivers/pci/pci.c
===
--- linux-2.6.13-rc1.orig/drivers/pci/pci.c
+++ linux-2.6.13-rc1/drivers/pci/pci.c
@@ -767,6 +767,8 @@ static int __devinit pci_init(void)
while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
pci_fixup_device(pci_fixup_final, dev);
}
+
+   iochk_init();
return 0;
 }



-
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: A "new driver model" and EXPORT_SYMBOL_GPL question

2005-07-05 Thread Michal Jaegermann
On Tue, Jul 05, 2005 at 02:57:40PM -0700, Greg KH wrote:
> On Tue, Jul 05, 2005 at 03:50:43PM -0600, Zan Lynx wrote:
> > Sourced from here:
> > http://hulllug.principalhosting.net/archive/index.php/t-52440.html
> 
> No, that is not the same topic or thread.

Formally you are correct but from my POV this sounds casuistic and
fit for a patent lawyer.  You were "recently advised not to change
these symbols" and you stated that you will not. So instead you did
an end run and you removed an old interface and introduced a
replacement; but this time with EXPORT_SYMBOL_GPL - which has the
same effect as what you told you will not do.

> If you know of any closed source code, using those functions, please put
> them in contact with me.

Well, I gave an example in my original question.  Yes, I asked them
to contact you.  If they will do that I have no idea.

   Michal
-
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: WARNING : kernel 2.6.11.7 (others) kills megaraid 4e/Si dead

2005-07-05 Thread Jussi Hamalainen

On Tue, 5 Jul 2005, Chris Wright wrote:


Any news on this matter?
I hvr a PE1850 waiting for kernel upgrade, but I'm afraid to do so now...

I can't break my box with tests since it's in active use...
For now I'm running a 2.6.8.1 based kernel on the box...


Last known good one (that Andy tested) was 2.6.10.  His was the only
report I've seen, and I haven't found any more details on it.


I have several PE1850s running 2.6.11.10 and above. I have never had 
a megaraid controller die on me. This might be something related to a 
particular firmware version or setup. I could check the firmware 
versions if you want.


--
-=[ Count Zero / TBH - Jussi Hämäläinen - email [EMAIL PROTECTED] ]=-

Linux 2.6.13-rc2

2005-07-05 Thread Linus Torvalds

Ok,
 -rc3 is pretty small, with the bulk of the diff being some defconfig
updates, and cleanup of xtensa (notably removal of another copy of zlib).

But there are ia64/arm/ppc64 updates and the TSO update from Davem is
probably worth pointing out to people. And various smaller things which
are more easily just seen from the shortlog.

Among the one-liners of note is the silly block level spinlock bugfix that 
obviously hit -rc1 and made itself felt on SMP and preempt under moderate 
IO loads.

Linus



Adrian Bunk:
  drivers/ide/Makefile: kill dead CONFIG_BLK_DEV_IDE_TCQ entry
  MMC: wbsd cleanups

Alexey Dobriyan:
  [NET]: Remove __ARGS from include/net/slhc_vj.h

Andrei Konovalov:
  ppc32: add Freescale MPC885ADS board support

Andrew Morton:
  fatfs sectioning fix
  reiserfs: handle_attrs() fix

Andy Whitcroft:
  gregkh-pci-pci-assign-unassigned-resources fix

Arnd Bergmann:
  ppc64: simplify nvram partition scanning code

Ben Dooks:
  ARM: 2785/1: S3C24XX - serial calls request_irq() with IRQs disabled
  ARM: 2783/1: Remove omnimeter_defconfig as there is no kernel support
  ARM: 2765/1: S3C24XX - small cleanups in arch/arm/mach-s3c2410
  ARM: 2764/1: S3C24XX - Common PM functions for Simtec boards

Bjorn Helgaas:
  [IA64] Recognize HP sx2000 chipset

Bruce Losure:
  [IA64-SGI] Altix patch to tiocx, add subsys_initcall

Catalin Marinas:
  ARM: 2784/1: Fix the block cache flush operation range
  ARM: 2780/1: AFS partition length calculation fix
  ARM: 2779/1: Fix the V bit setting for the ARM1020x CPUs
  ARM: 2778/1: Add -mno-thumb-interwork to CFLAGS_ABI
  ARM: 2777/1: Fix broken comment arch/arm/mm/proc-arm1020.S
  ARM: 2769/1: cpu_init() stack setup fix

Chris Zankel:
  xtensa: Fix asm macro
  xtensa: Removed local copy of zlib and fixed O= support
  xtensa: Added mm/Kconfig to get a flat memory layout
  xtensa: cleanups for errno and ipc.

Christoph Hellwig:
  [SHAPER]: Switch to spinlocks.
  [SPARC]: bpp: remove sleep_on usage
  udf_find_entry() cleanup

Colin Ngam:
  [IA64-SGI] Fix TIO IOSPACE MMR Addres

Cornelia Huck:
  driver core: add bus_find_device & driver_find_device functions

David Chau:
  [NET]: improve readability of dev_set_promiscuity() in net/core/dev.c

David Mosberger-Tang:
  [IA64] Replace stale KDB-code with useful MAGIC_SYSRQ code in simserial.c
  [IA64] Speed up lfetch.fault [NULL]
  [IA64] Fix convert_to_non_syscall() so gdb inferior calls work again
  [IA64] Merge audit fix for fsyscalls with syscall-optimizations
  [IA64] need r29=psr *after* rsm psr.i
  [IA64] use srlz.d instead of srlz.i in ia64_leave_kernel()
  [IA64] Annotate fsys_bubble_down() with McKinley dispatch info.
  [IA64] Reschedule fsys_bubble_down().
  [IA64] Annotate __kernel_syscall_via_epc() with McKinley dispatch info.
  [IA64] Reschedule __kernel_syscall_via_epc().
  [IA64] Reschedule break_fault() for better performance.
  [IA64] In ia64_leave_syscall(), fix comments and whitespace only.
  [IA64] Schedule ia64_leave_syscall() to read ar.bsp earlier
  [IA64] In syscall-entry, use st8 instead of stf8 to clear pt_regs.r8
  [IA64] On return from syscall, hint b7 with __kernel_syscall_via_epc().
  [IA64] Schedule fp-clearing insns at least 6 cycles after reading ar.bsp.
  [IA64] Use dynamic prediction for RSE-clearing branches.
  [IA64] __ia64_syscall() is no longer used anywhere in the kernel.  Remove it.

David S. Miller:
  [SPARC64]: Fix UltraSPARC-III fallout from membar changes.
  [TCP]: Never TSO defer under periods of congestion.
  [TCP]: Move to new TSO segmenting scheme.
  [TCP]: Break out send buffer expansion test.
  [TCP]: Do not call tcp_tso_acked() if no work to do.
  [TCP]: Kill bogus comment above tcp_tso_acked().
  [TCP]: Fix send-side cpu utiliziation regression.
  [TCP]: Eliminate redundant computations in tcp_write_xmit().
  [TCP]: Break out tcp_snd_test() into it's constituent parts.
  [TCP]: Fix __tcp_push_pending_frames() 'nonagle' handling.
  [TCP]: Fix redundant calculations of tcp_current_mss()
  [TCP]: tcp_write_xmit() tabbing cleanup
  [TCP]: Kill extra cwnd validate in __tcp_push_pending_frames().
  [TCP]: Add missing skb_header_release() call to tcp_fragment().
  [TCP]: Move __tcp_data_snd_check into tcp_output.c
  [TCP]: Move send test logic out of net/tcp.h
  [TCP]: Fix quick-ack decrementing with TSO.
  [TCP]: Simplify SKB data portion allocation with NETIF_F_SG.
  [TG3]: Update driver version and reldate.
  [SKGE]: Fix build on big-endian
  [SPARC64]: Fix IRQ retry interval timer value on sparc64 PCI controllers.
  [SPARC64]: Small Schizo PCI controller programming tweaks.
  [SPARC64]: Do proper DMA IRQ syncing on Tomatillo
  [SPARC64]: Add support for IRQ pre-handlers.

Denis Vlasenko:
  ide: fix line break in ide messages

Dominik Brodowski:
  pcmcia: update Documentation
  pcmcia: fix modalias attribute in sysfs

Eric Dumazet:
  [IPV4]: Bug fix in rt_check_expire()
  [IPV4]: Use the fancy alloc_large_system_hash() function for route hash table
  [NET

RE: XFS corruption during power-blackout

2005-07-05 Thread Al Boldi
Sonny Rao wrote: {
> > > >On Wed, Jun 29, 2005 at 07:53:09AM +0300, Al Boldi wrote:
> > > >>What I found were 4 things in the dest dir:
> > > >>1. Missing Dirs,Files. That's OK.
> > > >>2. Files of size 0. That's acceptable.
> > > >>3. Corrupted Files. That's unacceptable.
> > > >>4. Corrupted Files with original fingerprint. That's ABSOLUTELY 
> > > >>unacceptable.
> > > >
> > 2. Moral of the story is: What's ext3 doing the others aren't?
> 
> Ext3 has stronger guaranties than basic filesystem consistency.
> I.e. in ordered mode, file data is always written before metadata, so 
> the worst that could happen is a growing file's new data is written 
> but the metadata isn't updated before a power failure... so the new 
> writes wouldn't be seen afterwards.
> 
I believe in newer 2.6 kernels that Reiser has ordered mode (IIRC, courtesy
of Chris Mason), but XFS and JFS do not support it.
}

Was ordered mode disabled/removed when XFS was add to the vanilla-kernel?


-
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] char: Add Dell Systems Management Base driver

2005-07-05 Thread Greg KH
On Tue, Jul 05, 2005 at 07:13:34PM -0500, Doug Warzecha wrote:
> This patch adds the Dell Systems Management Base driver.
> 
> The Dell Systems Management Base driver is a character driver that
> implements ioctls for Dell systems management software to use to
> communicate with the driver.  The driver provides support for Dell
> systems management software to manage the following Dell PowerEdge
> systems: 300, 1300, 1400, 400SC, 500SC, 1500SC, 1550, 600SC, 1600SC,
> 650, 1655MC, 700, and 750.
> 
> By making a contribution to this project, I certify that:
> The contribution was created in whole or in part by me and
> I have the right to submit it under the open source license
> indicated in the file.
> 
> Signed-off-by: Doug Warzecha <[EMAIL PROTECTED]>
> ---
> 
> diff -uprN linux-2.6.13-rc1.orig/drivers/char/dcdbas.c 
> linux-2.6.13-rc1/drivers/char/dcdbas.c
> --- linux-2.6.13-rc1.orig/drivers/char/dcdbas.c   1969-12-31 
> 18:00:00.0 -0600
> +++ linux-2.6.13-rc1/drivers/char/dcdbas.c2005-07-05 10:26:22.355056432 
> -0500
> @@ -0,0 +1,777 @@
> +/*
> + *  dcdbas.c: Dell Systems Management Base Driver
> + *
> + *  Copyright (C) 1995-2005 Dell Inc.
> + *
> + *  The Dell Systems Management Base driver is a character driver that
> + *  implements ioctls for Dell systems management software to use to
> + *  communicate with the driver.  The driver provides support for Dell
> + *  systems management software to manage the following Dell PowerEdge
> + *  systems: 300, 1300, 1400, 400SC, 500SC, 1500SC, 1550, 600SC, 1600SC,
> + *  650, 1655MC, 700, and 750.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License v2.0 as published by
> + *  the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "dcdbas.h"
> +
> +#define DRIVER_NAME  "dcdbas"
> +#define DRIVER_VERSION   "5.6.0-1"
> +#define DRIVER_DESCRIPTION   "Systems Management Base Driver"
> +
> +static int driver_major;

Why do you need a whole major for this driver?  You have more than one
device in the system at a time?

> +/**
> + * dcdbas_device_release - device release method
> + * @dev: device
> + */

Don't document functions that do nothing, that's just busy work...

> +static void dcdbas_device_release(struct device *dev)
> +{
> + /* nothing to release */
> +}

This is a symptom of a broken driver.

Hm, I wonder if there's some way for the compiler to check the fact that
a function pointer passed to another function, is really a null
function.  That would stop this kind of nonsense...

I'm sure I commented on this driver already, yet, I never got a response
and the code is not changed.  Is there some reason for this?  That's a
sure way to prevent your patch from ever being applied...

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: aio-stress throughput regressions from 2.6.11 to 2.6.12

2005-07-05 Thread Suparna Bhattacharya
On Fri, Jul 01, 2005 at 10:25:55AM -0400, Benjamin LaHaise wrote:
> On Fri, Jul 01, 2005 at 01:26:00PM +0530, Suparna Bhattacharya wrote:
> > On one test system I see a degradation from around 17+ MB/s to 11MB/s
> > for random O_DIRECT AIO (aio-stress -o3 testext3/rwfile5) from 2.6.11
> > to 2.6.12. It doesn't seem filesystem specific. Not good :(
> 
> What sort of io subsystem does it have?  Also, does changing the 

aic7xxx.
> elevator make any difference?  I'm away for the long weekend, but will 

I tried switching to the noop elevator - the regression was still there.

> help look into this next week.

Do you see the regression as well, or is it just me ?

Regards
Suparna

> 
>   -ben

-- 
Suparna Bhattacharya ([EMAIL PROTECTED])
Linux Technology Center
IBM Software Lab, India

-
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/


Confirmation for subscribe linux-kernel

2005-07-05 Thread Bhagyashri Bijwe
-- 
***
   Ms Bhagyashri Bijwe
 Project Eng.
 Networking and Internet Software Group,
 Centre for Research and Development,
 Pune,India
 Ph.25694000 Ext-484/462
 B.E.( Computer Sci. and Engg. )
-
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: Sending ethernet frames one after another

2005-07-05 Thread jscottkasten


--- Karel Kulhavy <[EMAIL PROTECTED]> wrote:

> Hello
> 
> I have written a software to test connected optical
> datalink in loopback
> mode which works by sending a burst of e. g. 1024
> raw Ethernet frames
> directly to that interface, then waiting a little
> bit, and counting from
> ifconfig how many were received.
> 
> Some people report a problem that on their eepro100
> in IBM Thinkpad, the
> program (probably sendto) is returning error "No
> buffer space available".
> 
> Why doesn't the sendto block instead? Does it mean
> that I cannot use

Are you sure that it is the program getting this
error?  Have you traced this to a bad return from the
sendto function?

I have a couple thoughs.  One issue with the memory is
that going in and out of the driver, the network
buffers are DMA quality memory (meaning hardware
accessable address space, and contiguous physically,
rather than virtually).  When things get churned up it
can be difficult to get memory that fits those
criteria.

-S-
-
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] [19/48] Suspend2 2.1.9.8 for 2.6.12: 510-version-specific-mac.patch

2005-07-05 Thread Nigel Cunningham
Hi.

I've just noticed that all the subject lines are off by one. Sorry.
Shall I repost with it right this time?

Regarding this x86_64 patch, I haven't been able to test x86_64 support
yet (no hardware here), so I'm sure you're right about all the things.
I've really just parroted what swsusp does in its lowlevel code, since
saving and restoring cpu state is one thing we do the same way.

Will apply changes.

Regards,

Nigel

On Wed, 2005-07-06 at 13:53, Zwane Mwaikambo wrote:
> On Wed, 6 Jul 2005, Nigel Cunningham wrote:
> 
> > +   /*
> > +* eflags
> > +*/
> > +   asm volatile ("pushfl ; popl (%0)" : "=m" 
> > (suspend2_saved_context.eflags));
> 
> To be future proof you probably want to do pushfq/popq
> 
> > +
> > +   /*
> > +* control registers 
> > +*/
> > +   asm volatile ("movl %%cr0, %0" : "=r" (suspend2_saved_context.cr0));
> > +   asm volatile ("movl %%cr2, %0" : "=r" (suspend2_saved_context.cr2));
> > +   asm volatile ("movl %%cr3, %0" : "=r" (suspend2_saved_context.cr3));
> > +   asm volatile ("movl %%cr4, %0" : "=r" (suspend2_saved_context.cr4));
> 
> I guess we don't have to worry about %cr8 for now?
> 
> > + * a little clearer, but it needs to be inlined because we won't have a
> > + * stack when we get here (so we can't push a return address).
> > + */
> > +static inline void restore_processor_context(void)
> > +{
> > +   /*
> > +* first restore %ds, so we can access our data properly
> > +*/
> > +   //asm volatile ("movw %0, %%ds" :: "r" ((u16)__KERNEL_DS));
> > +   
> > +   __flush_tlb_global(); /* INLINE? */
> > +
> > +   asm volatile ("movl $24, %eax");
> > +   asm volatile ("movl %eax, %ds");
> 
> Shouldn't that be KERNEL_DS?
> 
> > +   asm volatile ("pushl %0 ; popfl" :: "m" 
> > (suspend2_saved_context.eflags));
> 
> pushq/popfq?
> 
> > +   save_and_set_irq_affinity();
> > +   
> > +   c_loops_per_jiffy_ref[_smp_processor_id()] = 
> > current_cpu_data.loops_per_jiffy;
> > +#ifndef CONFIG_SMP
> > +   cpu_khz_ref = cpu_khz;
> > +   c_loops_per_jiffy_ref[_smp_processor_id()] = loops_per_jiffy;
> > +#endif
> > +   
> > +   /* We want to run from swsusp_pg_dir, since swsusp_pg_dir is stored in 
> > constant
> > +* place in memory 
> > +*/
> > +
> > +__asm__( "movl %%ecx,%%cr3\n" ::"c"(__pa(swsusp_pg_dir)));
> 
> This looks like it depends on the swsusp_pg_dir being in lower 32bit 
> address space, shouldn't it be a movq %%rcx?
> 
-- 
Evolution.
Enumerate the requirements.
Consider the interdependencies.
Calculate the probabilities.
Be amazed that people believe it 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/


How to debug the kernel for X86_64 SMP?

2005-07-05 Thread Neo Jia

All,

These days, I am trying to debug the kernel (2.6.9) on x86_64 SMP. But 
the Kprobes and UML cannot work probably for my case, due to the patch 
file for x86_64 arch.


Is there anyone who is working on the same topic? Any hint and help 
would be appreciated!


Thanks,
Neo

--
I would remember that if researchers were not ambitious 
probably today we haven't the technology we are using! 


-
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] [19/48] Suspend2 2.1.9.8 for 2.6.12: 510-version-specific-mac.patch

2005-07-05 Thread Nigel Cunningham
Hi.

This patch came from Hu Gang.

Regards,

Nigel

On Wed, 2005-07-06 at 12:20, Nigel Cunningham wrote:
> diff -ruNp 
> 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/asm-offsets.c 
> 520-version-specific-x86_64.patch-new/arch/x86_64/kernel/asm-offsets.c
> --- 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/asm-offsets.c
> 2005-06-20 11:46:49.0 +1000
> +++ 520-version-specific-x86_64.patch-new/arch/x86_64/kernel/asm-offsets.c
> 2005-07-04 23:14:19.0 +1000
> @@ -62,8 +62,10 @@ int main(void)
>  offsetof (struct rt_sigframe32, uc.uc_mcontext));
>   BLANK();
>  #endif
> +#ifdef CONFIG_PM
>   DEFINE(pbe_address, offsetof(struct pbe, address));
>   DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
>   DEFINE(pbe_next, offsetof(struct pbe, next));
> +#endif
>   return 0;
>  }
> diff -ruNp 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/Makefile 
> 520-version-specific-x86_64.patch-new/arch/x86_64/kernel/Makefile
> --- 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/Makefile 
> 2005-06-20 11:46:49.0 +1000
> +++ 520-version-specific-x86_64.patch-new/arch/x86_64/kernel/Makefile 
> 2005-07-04 23:14:19.0 +1000
> @@ -22,6 +22,7 @@ obj-$(CONFIG_X86_IO_APIC)   += io_apic.o m
>   genapic.o genapic_cluster.o genapic_flat.o
>  obj-$(CONFIG_PM) += suspend.o
>  obj-$(CONFIG_SOFTWARE_SUSPEND)   += suspend_asm.o
> +obj-$(CONFIG_SUSPEND2)   += suspend2.o
>  obj-$(CONFIG_CPU_FREQ)   += cpufreq/
>  obj-$(CONFIG_EARLY_PRINTK)   += early_printk.o
>  obj-$(CONFIG_GART_IOMMU) += pci-gart.o aperture.o
> diff -ruNp 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/suspend.c 
> 520-version-specific-x86_64.patch-new/arch/x86_64/kernel/suspend.c
> --- 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/suspend.c
> 2004-11-03 21:53:44.0 +1100
> +++ 520-version-specific-x86_64.patch-new/arch/x86_64/kernel/suspend.c
> 2005-07-04 23:14:19.0 +1000
> @@ -26,6 +26,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  struct saved_context saved_context;
>  
> @@ -35,6 +36,8 @@ unsigned long saved_context_r08, saved_c
>  unsigned long saved_context_r12, saved_context_r13, saved_context_r14, 
> saved_context_r15;
>  unsigned long saved_context_eflags;
>  
> +void fix_processor_context(void);
> +
>  void __save_processor_state(struct saved_context *ctxt)
>  {
>   kernel_fpu_begin();
> diff -ruNp 520-version-specific-x86_64.patch-old/arch/x86_64/mm/init.c 
> 520-version-specific-x86_64.patch-new/arch/x86_64/mm/init.c
> --- 520-version-specific-x86_64.patch-old/arch/x86_64/mm/init.c   
> 2005-06-20 11:46:49.0 +1000
> +++ 520-version-specific-x86_64.patch-new/arch/x86_64/mm/init.c   
> 2005-07-04 23:14:19.0 +1000
> @@ -618,3 +618,22 @@ int in_gate_area_no_task(unsigned long a
>  {
>   return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
>  }
> +
> +#if defined(CONFIG_PM_DISK) || defined(CONFIG_SOFTWARE_SUSPEND) || 
> defined(CONFIG_SUSPEND2)
> +/*
> + * Software suspend & friends need this for resume because things like the 
> intel-agp
> + * driver might have split up a kernel 4MB mapping.
> + */
> +char __nosavedata swsusp_pg_dir[PAGE_SIZE]
> + __attribute__ ((aligned (PAGE_SIZE)));
> +
> +static inline void save_pg_dir(void)
> +{
> + memcpy(swsusp_pg_dir, swapper_pg_dir, PAGE_SIZE);
> +}
> +#else
> +static inline void save_pg_dir(void)
> +{
> +}
> +#endif
> +
> diff -ruNp 
> 520-version-specific-x86_64.patch-old/include/asm-x86_64/suspend2.h 
> 520-version-specific-x86_64.patch-new/include/asm-x86_64/suspend2.h
> --- 520-version-specific-x86_64.patch-old/include/asm-x86_64/suspend2.h   
> 1970-01-01 10:00:00.0 +1000
> +++ 520-version-specific-x86_64.patch-new/include/asm-x86_64/suspend2.h   
> 2005-07-05 23:56:15.0 +1000
> @@ -0,0 +1,432 @@
> + /*
> +  * Copyright 2005 Nigel Cunningham <[EMAIL PROTECTED]>
> +  * Based on code
> +  * Copyright 2001-2002 Pavel Machek <[EMAIL PROTECTED]>
> +  * Based on code
> +  * Copyright 2001 Patrick Mochel <[EMAIL PROTECTED]>
> +  */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#undef inline
> +#define inline   __inline__ __attribute__((always_inline))
> +
> +/* image of the saved processor states */
> +struct suspend2_saved_context {
> + unsigned long eax, ebx, ecx, edx;
> + unsigned long esp, ebp, esi, edi;
> + unsigned long r8, r9, r10, r11;
> + unsigned long r12, r13, r14, r15;
> +
> +#if 0
> + u16 es, fs, gs, ss;
> + u32 cr0, cr2, cr3, cr4;
> + u16 gdt_pad;
> + u16 gdt_limit;
> + u32 gdt_base;
> + u16 idt_pad;
> + u16 idt_limit;
> + u32 idt_base;
> + u16 ldt;
> + u16 tss;
> + u32 tr;
> + u32 safety;
> + u32 return_address;
> +#endif
> + unsigned long eflags;
> +} __attribute__((packed));
> +
> +extern s

Re: [PATCH] [24/48] Suspend2 2.1.9.8 for 2.6.12: 601-kernel_power_power-header.patch

2005-07-05 Thread Nigel Cunningham
Hi.

On Wed, 2005-07-06 at 13:42, Zwane Mwaikambo wrote:
> On Wed, 6 Jul 2005, Nigel Cunningham wrote:
> 
> > diff -ruNp 602-smp.patch-old/kernel/power/suspend2_core/smp.c 
> > 602-smp.patch-new/kernel/power/suspend2_core/smp.c
> > --- 602-smp.patch-old/kernel/power/suspend2_core/smp.c  1970-01-01 
> > 10:00:00.0 +1000
> > +++ 602-smp.patch-new/kernel/power/suspend2_core/smp.c  2005-07-04 
> > 23:14:19.0 +1000
> > @@ -0,0 +1,12 @@
> > +#include 
> > +
> > +void ensure_on_processor_zero(void)
> > +{
> > +   set_cpus_allowed(current, cpumask_of_cpu(0));
> > +   BUG_ON(smp_processor_id() != 0);
> > +}
> > +
> > +void return_to_all_processors(void)
> > +{
> > +   set_cpus_allowed(current, CPU_MASK_ALL);
> > +}
> 
> Do we really need to wrap these?

Fair enough. If I remember rightly, it's just a result of the flux with
testing cpu hotplug, so I should certainly drop the wrappers.

Nigel
-- 
Evolution.
Enumerate the requirements.
Consider the interdependencies.
Calculate the probabilities.
Be amazed that people believe it 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/


Re: [PATCH] [24/48] Suspend2 2.1.9.8 for 2.6.12: 601-kernel_power_power-header.patch

2005-07-05 Thread Zwane Mwaikambo
On Wed, 6 Jul 2005, Nigel Cunningham wrote:

> diff -ruNp 602-smp.patch-old/kernel/power/suspend2_core/smp.c 
> 602-smp.patch-new/kernel/power/suspend2_core/smp.c
> --- 602-smp.patch-old/kernel/power/suspend2_core/smp.c1970-01-01 
> 10:00:00.0 +1000
> +++ 602-smp.patch-new/kernel/power/suspend2_core/smp.c2005-07-04 
> 23:14:19.0 +1000
> @@ -0,0 +1,12 @@
> +#include 
> +
> +void ensure_on_processor_zero(void)
> +{
> + set_cpus_allowed(current, cpumask_of_cpu(0));
> + BUG_ON(smp_processor_id() != 0);
> +}
> +
> +void return_to_all_processors(void)
> +{
> + set_cpus_allowed(current, CPU_MASK_ALL);
> +}

Do we really need to wrap these?

-
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] [19/48] Suspend2 2.1.9.8 for 2.6.12: 510-version-specific-mac.patch

2005-07-05 Thread Zwane Mwaikambo
On Wed, 6 Jul 2005, Nigel Cunningham wrote:

> + /*
> +  * eflags
> +  */
> + asm volatile ("pushfl ; popl (%0)" : "=m" 
> (suspend2_saved_context.eflags));

To be future proof you probably want to do pushfq/popq

> +
> + /*
> +  * control registers 
> +  */
> + asm volatile ("movl %%cr0, %0" : "=r" (suspend2_saved_context.cr0));
> + asm volatile ("movl %%cr2, %0" : "=r" (suspend2_saved_context.cr2));
> + asm volatile ("movl %%cr3, %0" : "=r" (suspend2_saved_context.cr3));
> + asm volatile ("movl %%cr4, %0" : "=r" (suspend2_saved_context.cr4));

I guess we don't have to worry about %cr8 for now?

> + * a little clearer, but it needs to be inlined because we won't have a
> + * stack when we get here (so we can't push a return address).
> + */
> +static inline void restore_processor_context(void)
> +{
> + /*
> +  * first restore %ds, so we can access our data properly
> +  */
> + //asm volatile ("movw %0, %%ds" :: "r" ((u16)__KERNEL_DS));
> + 
> + __flush_tlb_global(); /* INLINE? */
> +
> + asm volatile ("movl $24, %eax");
> + asm volatile ("movl %eax, %ds");

Shouldn't that be KERNEL_DS?

> + asm volatile ("pushl %0 ; popfl" :: "m" 
> (suspend2_saved_context.eflags));

pushq/popfq?

> + save_and_set_irq_affinity();
> + 
> + c_loops_per_jiffy_ref[_smp_processor_id()] = 
> current_cpu_data.loops_per_jiffy;
> +#ifndef CONFIG_SMP
> + cpu_khz_ref = cpu_khz;
> + c_loops_per_jiffy_ref[_smp_processor_id()] = loops_per_jiffy;
> +#endif
> + 
> + /* We want to run from swsusp_pg_dir, since swsusp_pg_dir is stored in 
> constant
> +  * place in memory 
> +  */
> +
> +__asm__( "movl %%ecx,%%cr3\n" ::"c"(__pa(swsusp_pg_dir)));

This looks like it depends on the swsusp_pg_dir being in lower 32bit 
address space, shouldn't it be a movq %%rcx?
-
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] [11/48] Suspend2 2.1.9.8 for 2.6.12: 401-e820-table-support.patch

2005-07-05 Thread Zwane Mwaikambo
On Wed, 6 Jul 2005, Nigel Cunningham wrote:

> diff -ruNp 402-mtrr-remove-sysdev.patch-old/arch/i386/kernel/cpu/mtrr/main.c 
> 402-mtrr-remove-sysdev.patch-new/arch/i386/kernel/cpu/mtrr/main.c
> --- 402-mtrr-remove-sysdev.patch-old/arch/i386/kernel/cpu/mtrr/main.c 
> 2005-06-20 11:46:42.0 +1000
> +++ 402-mtrr-remove-sysdev.patch-new/arch/i386/kernel/cpu/mtrr/main.c 
> 2005-07-04 23:14:19.0 +1000
> @@ -166,7 +166,6 @@ static void ipi_handler(void *info)
>   atomic_dec(&data->count);
>   local_irq_restore(flags);
>  }
> -
>  #endif
>  
>  /**
> @@ -560,7 +559,7 @@ struct mtrr_value {
>  
>  static struct mtrr_value * mtrr_state;
>  
> -static int mtrr_save(struct sys_device * sysdev, u32 state)
> +int mtrr_save(void)
>  {
>   int i;
>   int size = num_var_ranges * sizeof(struct mtrr_value);
> @@ -580,28 +579,27 @@ static int mtrr_save(struct sys_device *
>   return 0;
>  }

Isn't this covered by Shaohua Li's patch?
-
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] [11/48] Suspend2 2.1.9.8 for 2.6.12: 401-e820-table-support.patch

2005-07-05 Thread Nigel Cunningham
Hi.

On Wed, 2005-07-06 at 13:35, Zwane Mwaikambo wrote:
> On Wed, 6 Jul 2005, Nigel Cunningham wrote:
> 
> > diff -ruNp 
> > 402-mtrr-remove-sysdev.patch-old/arch/i386/kernel/cpu/mtrr/main.c 
> > 402-mtrr-remove-sysdev.patch-new/arch/i386/kernel/cpu/mtrr/main.c
> > --- 402-mtrr-remove-sysdev.patch-old/arch/i386/kernel/cpu/mtrr/main.c   
> > 2005-06-20 11:46:42.0 +1000
> > +++ 402-mtrr-remove-sysdev.patch-new/arch/i386/kernel/cpu/mtrr/main.c   
> > 2005-07-04 23:14:19.0 +1000
> > @@ -166,7 +166,6 @@ static void ipi_handler(void *info)
> > atomic_dec(&data->count);
> > local_irq_restore(flags);
> >  }
> > -
> >  #endif
> >  
> >  /**
> > @@ -560,7 +559,7 @@ struct mtrr_value {
> >  
> >  static struct mtrr_value * mtrr_state;
> >  
> > -static int mtrr_save(struct sys_device * sysdev, u32 state)
> > +int mtrr_save(void)
> >  {
> > int i;
> > int size = num_var_ranges * sizeof(struct mtrr_value);
> > @@ -580,28 +579,27 @@ static int mtrr_save(struct sys_device *
> > return 0;
> >  }
> 
> Isn't this covered by Shaohua Li's patch?

I believe so, but Shaohua Li's patch isn't merged in 2.6.12 (is it yet
at all). This is the solution I've been using for... can't remember how
long.

Thanks for the feedback.

Regards,

Nigel

-- 
Evolution.
Enumerate the requirements.
Consider the interdependencies.
Calculate the probabilities.
Be amazed that people believe it 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/


Re: [PATCH] [7/48] Suspend2 2.1.9.8 for 2.6.12: 352-disable-pdflush-during-suspend.patch

2005-07-05 Thread Nigel Cunningham
Hi.

On Wed, 2005-07-06 at 13:34, Zwane Mwaikambo wrote:
> On Wed, 6 Jul 2005, Nigel Cunningham wrote:
> 
> > diff -ruNp 
> > 353-disable-highmem-tlb-flush-for-copyback.patch-old/mm/highmem.c 
> > 353-disable-highmem-tlb-flush-for-copyback.patch-new/mm/highmem.c
> > --- 353-disable-highmem-tlb-flush-for-copyback.patch-old/mm/highmem.c   
> > 2005-06-20 11:47:32.0 +1000
> > +++ 353-disable-highmem-tlb-flush-for-copyback.patch-new/mm/highmem.c   
> > 2005-07-04 23:14:20.0 +1000
> > @@ -26,6 +26,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  
> >  static mempool_t *page_pool, *isa_page_pool;
> > @@ -95,7 +96,10 @@ static void flush_all_zero_pkmaps(void)
> >  
> > set_page_address(page, NULL);
> > }
> > -   flush_tlb_kernel_range(PKMAP_ADDR(0), PKMAP_ADDR(LAST_PKMAP));
> > +   if (test_suspend_state(SUSPEND_FREEZE_SMP))
> > +   __flush_tlb();
> > +   else
> > +   flush_tlb_kernel_range(PKMAP_ADDR(0), PKMAP_ADDR(LAST_PKMAP));
> >  }
> >  
> >  static inline unsigned long map_new_virtual(struct page *page)
> 
> What state are the other processors in when you hit this path?

Looping in arch specific code, waiting for an atomic_t to tell them it's
time to restore state and carry on. They're there the whole time CPU0 is
restoring the image and highmem.

Regards,

Nigel
-- 
Evolution.
Enumerate the requirements.
Consider the interdependencies.
Calculate the probabilities.
Be amazed that people believe it 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/


Re: [PATCH] [17/48] Suspend2 2.1.9.8 for 2.6.12: 500-version-specific-i386.patch

2005-07-05 Thread YOSHIFUJI Hideaki / 吉藤英明
In article <[EMAIL PROTECTED]> (at Wed, 6 Jul 2005 12:20:41 +1000), Nigel 
Cunningham <[EMAIL PROTECTED]> says:

>  #define local_flush_tlb() __flush_tlb()
> +#define local_flush_tlb_all() __flush_tlb_all();

You should remove ";".

>  extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
> +extern void do_flush_tlb_all(void * info);
> +
> +#define local_flush_tlb_all() \
> + do_flush_tlb_all(NULL);
>  

ditto

--yoshfuji
-
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: [git patches] IDE update

2005-07-05 Thread Al Boldi
Linus Torvalds wrote: {
On Wed, 6 Jul 2005, Grant Coady wrote:
> 
> Executive Summary

Btw, can you try this same thing (or at least a subset) with a large file on
a filesystem? Does that show the same pattern, or is it always just the raw
device?
}

Linus,
Cat /dev/hda > /dev/null and cat /tmp/tst.dsk > /dev/null show the same
symptoms.
The problem shows most when the cpu is slow and the hd is fast.
When the cpu is fast and the hd is slow the cpu will make up for lost cycles
and the problem will not show!


-
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] [7/48] Suspend2 2.1.9.8 for 2.6.12: 352-disable-pdflush-during-suspend.patch

2005-07-05 Thread Zwane Mwaikambo
On Wed, 6 Jul 2005, Nigel Cunningham wrote:

> diff -ruNp 353-disable-highmem-tlb-flush-for-copyback.patch-old/mm/highmem.c 
> 353-disable-highmem-tlb-flush-for-copyback.patch-new/mm/highmem.c
> --- 353-disable-highmem-tlb-flush-for-copyback.patch-old/mm/highmem.c 
> 2005-06-20 11:47:32.0 +1000
> +++ 353-disable-highmem-tlb-flush-for-copyback.patch-new/mm/highmem.c 
> 2005-07-04 23:14:20.0 +1000
> @@ -26,6 +26,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  static mempool_t *page_pool, *isa_page_pool;
> @@ -95,7 +96,10 @@ static void flush_all_zero_pkmaps(void)
>  
>   set_page_address(page, NULL);
>   }
> - flush_tlb_kernel_range(PKMAP_ADDR(0), PKMAP_ADDR(LAST_PKMAP));
> + if (test_suspend_state(SUSPEND_FREEZE_SMP))
> + __flush_tlb();
> + else
> + flush_tlb_kernel_range(PKMAP_ADDR(0), PKMAP_ADDR(LAST_PKMAP));
>  }
>  
>  static inline unsigned long map_new_virtual(struct page *page)

What state are the other processors in when you hit this path?

-
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/


sata_sil 3112 activity LED patch

2005-07-05 Thread Aric Cyr
After finally getting fed up with not having my activity light working
for my SATA drives, I came up with a small patch (more like hack) to
make it work.  It works quite well, but I'm afraid that there are many
restriction that this patch does not check for that it probably
should... so consider this a work-in-progress.  My information is
based on a document from Silicon Image that appears to no longer be
available on their website (Sil-AN-0082-E; 8112-0082.pdf).  I still
have a copy if anyone is interested.

There are two restrictions that are not checked:

1) Is the chip a 3112 or 3114?  I assume that this would only work on
   a 3112, but whether it is "a bad thing" on a 3114 I do not know.

2) BAR5 + 0x54 is apparently used for the flash memory address and
   data lines.  However for most motherboards (i.e. not add-on cards)
   with the chip, like my EPOX 8RDA3+, there is no flash memory, so
   these lines are hijacked as LED GPIO.  I assume that this is a
   common practice for motherboard makers using the sil3112 since
   Silicon Image went out of their way to produce the above mentioned
   document.  Anyways, the problem is that this patch does not check
   if flash memory is installed or not before twiddling with the GPIO
   lines.  This could be extremely bad for people running the 3112
   from add-on cards (or any implementation with flash memory
   installed).

Setting the low 8bits at BAR5+54h seems to enable the LED circuit.  It
seems that this circuit is patched through into the motherboard as it
lights the regular hard drive light on the front of my case.  Setting
bits [8:15] at BAR5+54h clears the bits, disabling the LED.  I hooked
this logic into the ata_bmdma_start and ata_bmdma_stop which were made
into simple wrapper functions in sata_sil.c that just set the GPIO
bits and calls ata_bmdma_*.

As a sanity test, I ran my drive, loaded, overnight with no problems.

If there is a better way to do this, I would be happy to hear any
suggestions... it is kind of ugly as it is now.

-- 
Aric Cyr (http://acyr.net)
gpg fingerprint: 943A 1549 47AC D766 B7F8  D551 6703 7142 C282 D542
--- sata_sil.c.orig 2005-06-15 17:48:23.0 +0900
+++ sata_sil.c  2005-07-06 01:58:28.0 +0900
@@ -45,6 +45,7 @@
sil_3114= 1,
 
SIL_SYSCFG  = 0x48,
+   SIL_GPIO= 0x54,
SIL_MASK_IDE0_INT   = (1 << 22),
SIL_MASK_IDE1_INT   = (1 << 23),
SIL_MASK_IDE2_INT   = (1 << 24),
@@ -65,6 +66,8 @@
 static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg);
 static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
 static void sil_post_set_mode (struct ata_port *ap);
+static void sil_bmdma_start(struct ata_queued_cmd *qc);
+static void sil_bmdma_stop(struct ata_port *ap);
 
 static struct pci_device_id sil_pci_tbl[] = {
{ 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
@@ -138,8 +140,8 @@
.phy_reset  = sata_phy_reset,
.post_set_mode  = sil_post_set_mode,
.bmdma_setup= ata_bmdma_setup,
-   .bmdma_start= ata_bmdma_start,
-   .bmdma_stop = ata_bmdma_stop,
+   .bmdma_start= sil_bmdma_start,
+   .bmdma_stop = sil_bmdma_stop,
.bmdma_status   = ata_bmdma_status,
.qc_prep= ata_qc_prep,
.qc_issue   = ata_qc_issue_prot,
@@ -198,6 +200,35 @@
 MODULE_DEVICE_TABLE(pci, sil_pci_tbl);
 MODULE_VERSION(DRV_VERSION);
 
+static void sil_bmdma_start(struct ata_queued_cmd *qc)
+{
+  void* mmio_base = qc->ap->host_set->mmio_base;
+  u32 gpio = readl(mmio_base + SIL_GPIO);
+
+  /* setting the lower 8 bits to activate the activity LED */
+  gpio |= 0x00ff;
+  writel(gpio, mmio_base + SIL_GPIO);
+  readl(mmio_base + SIL_GPIO); /* flush */
+
+  ata_bmdma_start(qc);
+}
+
+static void sil_bmdma_stop(struct ata_port *ap)
+{
+  void* mmio_base = ap->host_set->mmio_base;
+  u32 gpio = readl(mmio_base + SIL_GPIO);
+
+  ata_bmdma_stop(ap);
+
+  /* 
+   * setting bits [8:15] clears the lower 8 bits,
+   * deactivating the activity LED
+   */
+  gpio |= 0xff00;
+  writel(gpio, mmio_base + SIL_GPIO);
+  readl(mmio_base + SIL_GPIO); /* flush */
+}
+
 static void sil_post_set_mode (struct ata_port *ap)
 {
struct ata_host_set *host_set = ap->host_set;


pgphTlWdestWb.pgp
Description: PGP signature


Re: Build TAGS problem with O=

2005-07-05 Thread George Anzinger

George Anzinger wrote:

If you try:
make O=/usr/src/ver/2.6.13-rc/obj/ -j5 LOCALVERSION=_2.6.13-rc TAGS 
ARCH=i386


it fails with:
  MAKE   TAGS
find: security/selinux/include: No such file or directory
find: include: No such file or directory
find: include/asm-i386: No such file or directory
find: include/asm-generic: No such file or directory


The problem seems to be this bit of the topdir Makefile:


#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
#(which is the most common case IMHO) to avoid unneeded clutter in the 
big tags file.

#Adding $(srctree) adds about 20M on i386 to the size of the output file!

ifeq ($(KBUILD_OUTPUT),)
__srctree =
else
__srctree = $(srctree)/
endif

It would appear that the "ifeq ($(KBUILD_OUTPUT),)" is doing the wrong 
thing.  I am not a make expert, but I have had a lot of BAD experience 
trying to use this construct.  Any one up to proposing a fix?


The problem appears to be that KBUILD_OUTPUT is NOT defined after make reruns 
itself.  Here is a fix:


Signed-off-by:  George Anzinger  

--- /usr/src/linux-2.6.12-org/Makefile  2005-07-01 14:37:44.0 -0700
+++ /usr/src/linux-2.6.13-rc/Makefile   2005-07-05 19:45:00.588314304 -0700
@@ -1149,7 +1149,7 @@
 #(which is the most common case IMHO) to avoid unneeded clutter in the big 
tags file.

 #Adding $(srctree) adds about 20M on i386 to the size of the output file!

-ifeq ($(KBUILD_OUTPUT),)
+ifeq ($(src),$(obj))
 __srctree =
 else
 __srctree = $(srctree)/



--
George Anzinger   george@mvista.com
HRT (High-res-timers):  http://sourceforge.net/projects/high-res-timers/
-
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: Thread_Id

2005-07-05 Thread Robert Hancock

RVK wrote:
Can anyone suggest me how to get the threadId using 2.6.x kernels. 
pthread_self() does not work and returns some -ve integer.


What do you mean, negative integer? It's not an integer, it's a 
pthread_t, you're not even supposed to look at it..


--
Robert Hancock  Saskatoon, SK, Canada
To email, remove "nospam" from [EMAIL PROTECTED]
Home Page: http://www.roberthancock.com/

-
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: [linux-usb-devel] Kernel unable to read partition table on US B Memory Key

2005-07-05 Thread Roberts-Thomson, James
Alan,
 
> Try putting delays at various spots in sd_revalidate_disk: 
> the beginning, the middle, and the end.

OK, the attached patch works for me when sd_mod was loaded with delay_use=1.

Now I'm quite prepared to be told that this is a really horrible and
inapproprate hack (given that I am not a kernel developer, I don't really
know the "correct" way to solve this problem); and I'll cheerfully admit
that it doesn't really solve the problem cleanly as can be seen below:

Jul  6 14:44:50 pc196344 kernel: usb 1-6: new high speed USB device using
ehci_hcd and address 6
Jul  6 14:44:50 pc196344 kernel: Initializing USB Mass Storage driver...
Jul  6 14:44:50 pc196344 kernel: scsi5 : SCSI emulation for USB Mass Storage
devices
Jul  6 14:44:50 pc196344 kernel: usbcore: registered new driver usb-storage
Jul  6 14:44:50 pc196344 kernel: USB Mass Storage support registered.
Jul  6 14:44:50 pc196344 kernel: usb-storage: device found at 6
Jul  6 14:44:50 pc196344 kernel: usb-storage: waiting for device to settle
before scanning
Jul  6 14:44:52 pc196344 kernel:   Vendor: OTi   Model: Flash Disk
Rev: 2.00
Jul  6 14:44:52 pc196344 kernel:   Type:   Direct-Access
ANSI SCSI revision: 02
Jul  6 14:44:52 pc196344 kernel: Attached scsi generic sg1 at scsi5, channel
0, id 0, lun 0,  type 0
Jul  6 14:44:52 pc196344 kernel: usb-storage: device scan complete
Jul  6 14:44:52 pc196344 scsi.agent[27245]: disk at
/devices/pci:00/:00:1d.7/usb1/1-6/1-6:1.0/host5/target5:0:0/5:0:0:0
Jul  6 14:44:52 pc196344 kernel: sd: waiting for device to get ready.
Jul  6 14:44:53 pc196344 kernel: sda: Unit Not Ready, sense:
Jul  6 14:44:53 pc196344 kernel: : Current: sense key: Unit Attention
Jul  6 14:44:53 pc196344 kernel: Additional sense: Not ready to ready
change, medium may have changed
Jul  6 14:44:53 pc196344 kernel: sda : READ CAPACITY failed.
Jul  6 14:44:53 pc196344 kernel: sda : status=1, message=00, host=0,
driver=08
Jul  6 14:44:53 pc196344 kernel: sd: Current: sense key: Unit Attention
Jul  6 14:44:53 pc196344 kernel: Additional sense: Not ready to ready
change, medium may have changed
Jul  6 14:44:53 pc196344 kernel: sda: test WP failed, assume Write Enabled
Jul  6 14:44:53 pc196344 kernel: sda: assuming drive cache: write through
Jul  6 14:44:53 pc196344 kernel: sd: waiting for device to get ready.
Jul  6 14:44:54 pc196344 kernel: sda: Unit Not Ready, sense:
Jul  6 14:44:54 pc196344 kernel: : Current: sense key: Unit Attention
Jul  6 14:44:54 pc196344 kernel: Additional sense: Not ready to ready
change, medium may have changed
Jul  6 14:44:54 pc196344 kernel: sda : READ CAPACITY failed.
Jul  6 14:44:54 pc196344 kernel: sda : status=1, message=00, host=0,
driver=08
Jul  6 14:44:54 pc196344 kernel: sd: Current: sense key: Unit Attention
Jul  6 14:44:54 pc196344 kernel: Additional sense: Not ready to ready
change, medium may have changed
Jul  6 14:44:54 pc196344 kernel: sda: test WP failed, assume Write Enabled
Jul  6 14:44:54 pc196344 kernel: sda: assuming drive cache: write through
Jul  6 14:44:54 pc196344 kernel: sd: waiting for device to get ready.
Jul  6 14:44:55 pc196344 kernel: SCSI device sda: 255488 512-byte hdwr
sectors (131 MB)
Jul  6 14:44:55 pc196344 kernel: sda: Write Protect is off
Jul  6 14:44:55 pc196344 kernel: sda: Mode Sense: 03 00 00 00
Jul  6 14:44:55 pc196344 kernel: sda: assuming drive cache: write through
Jul  6 14:44:55 pc196344 kernel:  /dev/scsi/host5/bus0/target0/lun0: p1
Jul  6 14:44:55 pc196344 kernel: Attached scsi removable disk sda at scsi5,
channel 0, id 0, lun 0

There are three delays from my patch in the above list, and increasing the
delay to 3 seconds didn't help, as I got three one-second delays.  

However, if someone with the appropriate knowledge could transform my kludge
into a proper fix, then I would be very happy.

Alan, thanks very much for your help - I really appreciate the quick
responses you have given me.

Note that I now have the output from the USB Snoop tool under Windows if
anyone wants it - please ask if needed to help solve the issue "correctly".

James Roberts-Thomson
--
Hardware:  The parts of a computer system that can be kicked.

Mailing list Readers:  Please ignore the following disclaimer - this email
is explicitly declared to be non confidential and does not contain
privileged information.


This communication is confidential and may contain privileged material.
If you are not the intended recipient you must not use, disclose, copy or 
retain it.
If you have received it in error please immediately notify me by return email
and delete the emails.
Thank you.


oti-usb-key.patch
Description: Binary data


Re: [PATCH] add class_interface pointer to add and remove functions

2005-07-05 Thread John Lenz
On Sun, July 3, 2005 3:59 pm, Greg KH said:
> On Thu, Jun 30, 2005 at 04:18:42PM -0500, John Lenz wrote:
>> Here is a patch that updates every usage of class_interface I could
>> find.
>
> Do you have a patch that will take advantage of this change?  I would
> prefer to have that before accepting this patch.
>

No, not for inclusion.  I needed this change while I was working on the
touchscreen driver for Zaurus (http://www.cs.wisc.edu/~lenz/zaurus).  I
have not yet completed that driver, and am currently working on some other
drivers.  So I won't really have a patch until I (or someone else, we can
always use volunteers!) goes back and tries to work on the touchscreen
driver.

I just thought that since the class API is changing anyway, this API
change could come along.  Otherwise I will resubmit this patch when I (or
someone else) gets around to working on the touchscreen driver.

John

-
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] [43/48] Suspend2 2.1.9.8 for 2.6.12: 619-userspace-nofreeze.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 620-userui-header.patch-old/include/linux/netlink.h 
620-userui-header.patch-new/include/linux/netlink.h
--- 620-userui-header.patch-old/include/linux/netlink.h 2005-06-20 
11:47:29.0 +1000
+++ 620-userui-header.patch-new/include/linux/netlink.h 2005-07-04 
23:14:19.0 +1000
@@ -14,6 +14,7 @@
 #define NETLINK_SELINUX7   /* SELinux event notifications 
*/
 #define NETLINK_ARPD   8
 #define NETLINK_AUDIT  9   /* auditing */
+#define NETLINK_SUSPEND2_USERUI10  /* For suspend2's userui */
 #define NETLINK_ROUTE6 11  /* af_inet6 route comm channel */
 #define NETLINK_IP6_FW 13
 #define NETLINK_DNRTMSG14  /* DECnet routing messages */
diff -ruNp 620-userui-header.patch-old/kernel/power/suspend2_core/ui.c 
620-userui-header.patch-new/kernel/power/suspend2_core/ui.c
--- 620-userui-header.patch-old/kernel/power/suspend2_core/ui.c 1970-01-01 
10:00:00.0 +1000
+++ 620-userui-header.patch-new/kernel/power/suspend2_core/ui.c 2005-07-05 
23:48:59.0 +1000
@@ -0,0 +1,1186 @@
+/*
+ * kernel/power/ui.c
+ *
+ * Copyright (C) 1998-2001 Gabor Kuti <[EMAIL PROTECTED]>
+ * Copyright (C) 1998,2001,2002 Pavel Machek <[EMAIL PROTECTED]>
+ * Copyright (C) 2002-2003 Florent Chabaud <[EMAIL PROTECTED]>
+ * Copyright (C) 2002-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * Routines for Software Suspend's user interface.
+ *
+ * The user interface code talks to a userspace program via a
+ * netlink socket.
+ *
+ * The kernel side:
+ * - starts the userui program;
+ * - sends text messages and progress bar status;
+ *
+ * The user space side:
+ * - passes messages regarding user requests (abort, toggle reboot etc)
+ *
+ */
+#define SUSPEND_CONSOLE_C
+
+#define __KERNEL_SYSCALLS__
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+ 
+#include "proc.h"
+#include "plugins.h"
+#include "suspend.h"
+#include "suspend2_common.h"
+#include "ui.h"
+#include "version.h"
+#include "userui.h"
+
+#include "../power.h"
+
+static struct suspend_plugin_ops userui_ops;
+static int orig_loglevel;
+static int orig_default_message_loglevel;
+static int orig_kmsg;
+
+static char local_printf_buf[1024];/* Same as printk - should be safe */
+static char lastheader[512];
+static int lastheader_message_len = 0;
+
+#define NUM_USERUI_SKBS 16 /* Number of preallocated skbs for emergencies */
+
+static char userui_program[256] = "";
+
+/* Number of distinct progress amounts that userspace can display */
+static int progress_granularity = 50;
+
+static struct sock *userui_nl;
+static u32 userui_sock_seq;
+static struct sk_buff *userui_skbs[NUM_USERUI_SKBS];
+static int next_free_userui_skb;
+static pid_t userui_pid = -1;
+
+DECLARE_WAIT_QUEUE_HEAD(userui_wait_for_process);
+DECLARE_WAIT_QUEUE_HEAD(userui_wait_for_key);
+
+void s2_userui_message(unsigned long section, unsigned long level,
+   int normally_logged,
+   const char *fmt, va_list args);
+unsigned long userui_update_progress(unsigned long value, unsigned long 
maximum,
+   const char *fmt, va_list args);
+void userui_prepare_console(void);
+void userui_cleanup_console(void);
+
+/* 
+ * Refill our pool of SKBs for use in emergencies (eg, when eating memory and 
none
+ * can be allocated).
+ */
+static void userui_replenish_skbs(void)
+{
+   while (next_free_userui_skb+1 < NUM_USERUI_SKBS) {
+   userui_skbs[next_free_userui_skb+1] =
+   alloc_skb(NLMSG_SPACE(sizeof(struct 
userui_msg_params)), GFP_ATOMIC);
+   if (userui_skbs[next_free_userui_skb+1])
+   next_free_userui_skb++;
+   else
+   break;
+   }
+}
+
+/* 
+ * Return a single skbuff either from our pool, or try to allocate one if
+ * the pool is exhausted.
+ */
+static struct sk_buff * userui_get_skb(void)
+{
+   struct sk_buff *skb;
+   if (next_free_userui_skb == -1)
+   skb = alloc_skb(NLMSG_SPACE(sizeof(struct userui_msg_params)), 
GFP_ATOMIC);
+   else {
+   skb = userui_skbs[next_free_userui_skb];
+   userui_skbs[next_free_userui_skb] = NULL;
+   next_free_userui_skb--;
+   }
+
+   userui_replenish_skbs();
+
+   return skb;
+}
+
+static void userui_notify_userspace(void* data)
+{
+   struct task_struct *t;
+   read_lock(&tasklist_lock);
+   if ((t = find_task_by_pid(userui_pid)))
+   wake_up_process(t);
+   read_unlock(&tasklist_lock);
+}
+
+DECLARE_WORK(userui_notify_userspace_work, userui_notify_userspace, NULL);
+
+static void userui_send_message(int type, void* params, size_t len)
+{
+   struct sk_buff *skb;
+   struct nlmsghdr *nlh;
+   void *dest;
+
+   skb = userui_get_skb();
+   if (!skb) {
+   printk("s

[PATCH] [46/48] Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 623-generic-block-io.patch-old/kernel/power/block_io.h 
623-generic-block-io.patch-new/kernel/power/block_io.h
--- 623-generic-block-io.patch-old/kernel/power/block_io.h  1970-01-01 
10:00:00.0 +1000
+++ 623-generic-block-io.patch-new/kernel/power/block_io.h  2005-07-05 
23:48:59.0 +1000
@@ -0,0 +1,55 @@
+/*
+ * block_io.h
+ *
+ * Copyright 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * Distributed under GPLv2.
+ *
+ * This file contains declarations for functions exported from
+ * block_io.c, which contains low level io functions.
+ */
+
+/* 
+ * The maximum amount of I/O we submit at once.
+ */
+#define MAX_READAHEAD 1024
+
+/* Forward Declarations */
+
+/*
+ * submit_params
+ *
+ * The structure we use for tracking submitted I/O.
+ */
+struct submit_params {
+   swp_entry_t swap_address;
+   struct page * page;
+   struct block_device * dev;
+   long block[8];
+   int readahead_index;
+   struct submit_params * next;
+};
+
+
+/* 
+ * Our exported interface so the swapwriter and filewriter don't
+ * need these functions duplicated.
+ */
+struct suspend_bio_ops {
+   int (*set_block_size) (struct block_device * bdev, int size);
+   int (*get_block_size) (struct block_device * bdev);
+   int (*submit_io) (int rw, 
+   struct submit_params * submit_info, int syncio);
+   int (*bdev_page_io) (int rw, struct block_device * bdev, long pos,
+   struct page * page);
+   void (*wait_on_readahead) (int readahead_index);
+   void (*check_io_stats) (void);
+   void (*reset_io_stats) (void);
+   void (*finish_all_io) (void);
+   int (*prepare_readahead) (int index);
+   void (*cleanup_readahead) (int index);
+   struct page ** readahead_pages;
+   int (*readahead_ready) (int readahead_index);
+};
+
+extern struct suspend_bio_ops suspend_bio_ops;
diff -ruNp 623-generic-block-io.patch-old/kernel/power/suspend_block_io.c 
623-generic-block-io.patch-new/kernel/power/suspend_block_io.c
--- 623-generic-block-io.patch-old/kernel/power/suspend_block_io.c  
1970-01-01 10:00:00.0 +1000
+++ 623-generic-block-io.patch-new/kernel/power/suspend_block_io.c  
2005-07-05 23:48:59.0 +1000
@@ -0,0 +1,817 @@
+/*
+ * block_io.c
+ *
+ * Copyright 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * Distributed under GPLv2.
+ * 
+ * This file contains block io functions for suspend2. These are
+ * used by the swapwriter and it is planned that they will also
+ * be used by the NFSwriter.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "suspend2_core/suspend.h"
+#include "suspend2_core/proc.h"
+#include "suspend2_core/plugins.h"
+#include "suspend2_core/utility.h"
+#include "suspend2_core/prepare_image.h"
+
+#include "block_io.h"
+
+/* Bits in struct io_info->flags */
+#define IO_WRITING 1
+#define IO_RESTORE_PAGE_PROT 2
+#define IO_AWAITING_READ 3
+#define IO_AWAITING_WRITE 4
+#define IO_AWAITING_SUBMIT 5
+#define IO_AWAITING_CLEANUP 6
+#define IO_HANDLE_PAGE_PROT 7
+
+#define MAX_OUTSTANDING_IO 1024
+
+/*
+ * ---
+ *
+ * IO in progress information storage and helpers
+ *
+ * ---
+ */
+
+struct io_info {
+   struct bio * sys_struct;
+   long block[PAGE_SIZE/512];
+   struct page * buffer_page;
+   struct page * data_page;
+   unsigned long flags;
+   struct block_device * dev;
+   struct list_head list;
+   int readahead_index;
+   struct work_struct work;
+};
+
+/* Locks separated to allow better SMP support.
+ * An io_struct moves through the lists as follows.
+ * free -> submit_batch -> busy -> ready_for_cleanup -> free
+ */
+static LIST_HEAD(ioinfo_free);
+static spinlock_t ioinfo_free_lock = SPIN_LOCK_UNLOCKED;
+
+static LIST_HEAD(ioinfo_ready_for_cleanup);
+static spinlock_t ioinfo_ready_lock = SPIN_LOCK_UNLOCKED;
+
+static LIST_HEAD(ioinfo_submit_batch);
+static spinlock_t ioinfo_submit_lock = SPIN_LOCK_UNLOCKED;
+
+static LIST_HEAD(ioinfo_busy);
+static spinlock_t ioinfo_busy_lock = SPIN_LOCK_UNLOCKED;
+
+static atomic_t submit_batch;
+static int submit_batch_size = 64;
+static int submit_batched(void);
+
+struct task_struct * suspend_bio_task;
+
+/* [Max] number of I/O operations pending */
+static atomic_t outstanding_io;
+static int max_outstanding_io = 0;
+static atomic_t buffer_allocs, buffer_frees;
+
+/* [Max] number of pages used for above struct */
+static int infopages = 0;
+static int maxinfopages = 0;
+
+#define BITS_PER_UL (8 * sizeof(unsigned long))
+static volatile unsigned long suspend_readahead_flags[(MAX_READAHEAD + 
BITS_PER_UL - 1) / BITS_PER_UL];
+static spinlock_t suspend_readahead_flags_lock = SPIN_LOCK_UNLOCKED;
+static struct page * suspend_readahead_pages[MAX_READAHEAD];
+
+static unsigned long nr_schedule_calls[8];
+
+static char * sch_call

[PATCH] [45/48] Suspend2 2.1.9.8 for 2.6.12: 621-swsusp-tidy.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 622-swapwriter.patch-old/kernel/power/suspend_swap.c 
622-swapwriter.patch-new/kernel/power/suspend_swap.c
--- 622-swapwriter.patch-old/kernel/power/suspend_swap.c1970-01-01 
10:00:00.0 +1000
+++ 622-swapwriter.patch-new/kernel/power/suspend_swap.c2005-07-05 
23:48:59.0 +1000
@@ -0,0 +1,1713 @@
+/*
+ * Swapwriter.c
+ *
+ * Copyright 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * Distributed under GPLv2.
+ * 
+ * This file encapsulates functions for usage of swap space as a
+ * backing store.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "suspend2_core/suspend.h"
+#include "suspend2_core/suspend2_common.h"
+#include "suspend2_core/version.h"
+#include "suspend2_core/proc.h"
+#include "suspend2_core/plugins.h"
+#include "suspend2_core/io.h"
+#include "suspend2_core/ui.h"
+#include "suspend2_core/extent.h"
+#include "suspend2_core/utility.h"
+
+#include "block_io.h"
+
+static struct suspend_plugin_ops swapwriterops;
+
+#define SIGNATURE_VER 6
+#define BYTES_PER_HEADER_PAGE (PAGE_SIZE - sizeof(swp_entry_t))
+
+/* --- Struct of pages stored on disk */
+
+struct swaplink {
+   char dummy[BYTES_PER_HEADER_PAGE];
+   swp_entry_t next;
+};
+
+union diskpage {
+   union swap_header swh;  /* swh.magic is the only member used */
+   struct swaplink link;
+   struct suspend_header sh;
+};
+
+union p_diskpage {
+   union diskpage *pointer;
+   char *ptr;
+unsigned long address;
+};
+
+// Higher Level
+static int readahead_index = 0, readahead_submit_index = 0;
+static int readahead_allocs = 0, readahead_frees = 0;
+
+static char * swapwriter_buffer = NULL;
+static int swapwriter_buffer_posn = 0;
+static unsigned long * header_link = NULL;
+
+/*
+ * ---
+ *
+ * Internal Data Structures
+ *
+ * ---
+ */
+
+/* header_data contains data that is needed to reload pagedir1, and
+ * is therefore saved in the suspend header.
+ *
+ * Pagedir2 swap comes before pagedir1 swap (save order), and the first swap
+ * entry for pagedir1 to use is set when pagedir2 is written (when we know how
+ * much swap it used). Since this first entry is almost certainly not at the
+ * start of a extent, the firstoffset variable below tells us where to start in
+ * the extent. All of this means we don't have to worry about getting different
+ * compression ratios for the kernel and cache (when compressing the image).
+ * We can simply allocate one pool of swap (size determined using expected
+ * compression ratio) and use it without worrying whether one pageset
+ * compresses better and the other worse (this is what happens). As long as the
+ * user gets the expected compression right, it will work.
+ */
+
+struct {
+   /* Extent chains for swap & blocks */
+   struct extentchain swapextents;
+   struct extentchain block_chain[MAX_SWAPFILES];
+   
+   /* Location of start of pagedir 1 */
+   struct extent * pd1start_block_extent;
+   int pd1start_chain;
+   int pd1start_extent_number;
+   unsigned long pd1start_block_offset;
+
+   /* Devices used for swap */
+   dev_t swapdevs[MAX_SWAPFILES];
+   char blocksizes[MAX_SWAPFILES];
+
+} header_data;
+
+static dev_t header_device = 0;
+static struct block_device * header_block_device = NULL;
+static int headerblocksize = PAGE_SIZE;
+static int headerblock;
+
+/* For swapfile automatically swapon/off'd. */
+static char swapfilename[256] = "";
+extern asmlinkage long sys_swapon(const char * specialfile, int swap_flags);
+extern asmlinkage long sys_swapoff(const char * specialfile);
+static int suspend_swapon_status = 0;
+
+/*
+ * ---
+ *
+ * Current state.
+ *
+ * ---
+ */
+
+/* Which pagedir are we saving/reloading? Needed so we can know whether to
+ * remember the last swap entry used at the end of writing pageset2, and
+ * get that location when saving or reloading pageset1.*/
+static int current_stream = 0;
+
+/* Pointer to current swap entry being loaded/saved. */
+static struct extent * currentblockextent = NULL;
+static unsigned long currentblockoffset = 0;
+static int currentblockchain = 0;
+static int currentblocksperpage = 0;
+
+/* Header Page Information */
+static int header_pages_allocated = 0;
+static struct submit_params * first_header_submit_info = NULL,
+ * last_header_submit_info = NULL, * current_header_submit_info = NULL;
+
+/*
+ * ---
+ *
+ * User Specified Parameters
+ *
+ * ---
+ */
+
+static int resume_firstblock = 0;
+static int resume_firstblocksize = PAGE_SIZE;
+static dev_t resume_device = 0;
+static struct block_device * resume_block_device = NULL;
+
+struct sysinf

[PATCH] [41/48] Suspend2 2.1.9.8 for 2.6.12: 617-proc.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 618-core.patch-old/kernel/power/suspend2_core/suspend.c 
618-core.patch-new/kernel/power/suspend2_core/suspend.c
--- 618-core.patch-old/kernel/power/suspend2_core/suspend.c 1970-01-01 
10:00:00.0 +1000
+++ 618-core.patch-new/kernel/power/suspend2_core/suspend.c 2005-07-04 
23:14:19.0 +1000
@@ -0,0 +1,1180 @@
+/*
+ * kernel/power/suspend2.c
+ */
+/** \mainpage Software Suspend 2.
+ *
+ * Suspend2 provides support for saving and restoring an image of
+ * system memory to an arbitrary storage device, either on the local computer,
+ * or across some network. The support is entirely OS based, so Suspend2 
+ * works without requiring BIOS, APM or ACPI support. The vast majority of the
+ * code is also architecture independant, so it should be very easy to port
+ * the code to new architectures. Suspend includes support for SMP, 4G HighMem
+ * and preemption. Initramfses and initrds are also supported.
+ *
+ * Suspend2 uses a modular design, in which the method of storing the image is
+ * completely abstracted from the core code, as are transformations on the data
+ * such as compression and/or encryption (multiple 'plugins' can be used to
+ * provide arbitrary combinations of functionality). The user interface is also
+ * modular, so that arbitrarily simple or complex interfaces can be used to
+ * provide anything from debugging information through to eye candy.
+ * 
+ * \section Copyright
+ *
+ * Suspend2 is released under the GPLv2.
+ *
+ * Copyright (C) 1998-2001 Gabor Kuti <[EMAIL PROTECTED]>
+ * Copyright (C) 1998,2001,2002 Pavel Machek <[EMAIL PROTECTED]>
+ * Copyright (C) 2002-2003 Florent Chabaud <[EMAIL PROTECTED]>
+ * Copyright (C) 2002-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * \section Credits
+ * 
+ * Nigel would like to thank the following people for their work:
+ * 
+ * Pavel Machek <[EMAIL PROTECTED]>
+ * Modifications, defectiveness pointing, being with Gabor at the very 
beginning,
+ * suspend to swap space, stop all tasks. Port to 2.4.18-ac and 2.5.17.
+ *
+ * Steve Doddi <[EMAIL PROTECTED]> 
+ * Support the possibility of hardware state restoring.
+ *
+ * Raph <[EMAIL PROTECTED]>
+ * Support for preserving states of network devices and virtual console
+ * (including X and svgatextmode)
+ *
+ * Kurt Garloff <[EMAIL PROTECTED]>
+ * Straightened the critical function in order to prevent compilers from
+ * playing tricks with local variables.
+ *
+ * Andreas Mohr <[EMAIL PROTECTED]>
+ *
+ * Alex Badea <[EMAIL PROTECTED]>
+ * Fixed runaway init
+ *
+ * Jeff Snyder <[EMAIL PROTECTED]>
+ * ACPI patch
+ *
+ * Nathan Friess <[EMAIL PROTECTED]>
+ * Some patches.
+ *
+ * Michael Frank <[EMAIL PROTECTED]>
+ * Extensive testing and help with improving stability. Nigel was constantly
+ * amazed by the quality and quantity of Michael's help.
+ *
+ * Bernard Blackham <[EMAIL PROTECTED]>
+ * Web page & Wiki administration, some coding. Another person without whom
+ * Suspend would not be where it is.
+ *
+ * ..and of course the myriads of Suspend2 users who have helped diagnose
+ * and fix bugs, made suggestions on how to improve the code, proofread
+ * documentation, and donated time and money.
+ *
+ * Thanks also to corporate sponsors:
+ *
+ * Cyclades.com. Nigel's employers from Dec 2004, who allow him to work 
on
+ * Suspend and PM related issues on company time.
+ * 
+ * LinuxFund.org. Sponsored Nigel's work on Suspend for four months Oct 
2003
+ * to Jan 2004.
+ *
+ * LAC Linux. Donated P4 hardware that enabled development and ongoing
+ * maintenance of SMP and Highmem support.
+ *
+ * OSDL. Provided access to various hardware configurations, make 
occasional
+ * small donations to the project.
+ */
+
+#define SUSPEND_MAIN_C
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "version.h"
+#include "suspend.h"
+#include "driver_model.h"
+#include "plugins.h"
+#include "proc.h"
+#include "pageflags.h"
+#include "prepare_image.h"
+#include "io.h"
+#include "ui.h"
+#include "version.h"
+#include "suspend2_common.h"
+#include "extent.h"
+#include "power_off.h"
+#include "utility.h"
+#include "smp.h"
+#include "atomic_copy.h"
+ 
+#ifdef  CONFIG_X86
+#include  /* for kernel_fpu_end */
+#endif
+
+/* Variables to be preserved over suspend */
+int pageset1_sizelow = 0, pageset2_sizelow = 0, image_size_limit = 0;
+unsigned long suspend2_orig_mem_free = 0;
+
+static dyn_pageflags_t pageset1_check_map;
+static dyn_pageflags_t pageset2_check_map;
+static char * debug_info_buffer;
+static char suspend_core_version[] = SUSPEND_CORE_VERSION;
+
+extern void do_suspend2_lowlevel(int resume);
+extern __nosavedata char resume_commandline[COMMAND_LINE_SIZE];
+
+/* 
+ *-  Variables ---
+ * 
+ * The following are used by the arch specific low level routines 
+ * and only needed if suspend2 is compiled in. Other variables,
+ * used by the freezer even if suspend2 is not compiled in, 

[PATCH] [47/48] Suspend2 2.1.9.8 for 2.6.12: 623-generic-block-io.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 624-filewriter.patch-old/kernel/power/suspend_file.c 
624-filewriter.patch-new/kernel/power/suspend_file.c
--- 624-filewriter.patch-old/kernel/power/suspend_file.c1970-01-01 
10:00:00.0 +1000
+++ 624-filewriter.patch-new/kernel/power/suspend_file.c2005-07-05 
23:48:59.0 +1000
@@ -0,0 +1,1616 @@
+/*
+ * Filewriter.c
+ *
+ * Copyright 2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * Distributed under GPLv2.
+ * 
+ * This file encapsulates functions for usage of a simple file as a
+ * backing store. It is based upon the swapwriter, and shares the
+ * same basic working. Here, though, we have nothing to do with
+ * swapspace, and only one device to worry about.
+ *
+ * The user can just
+ *
+ * echo Suspend2 > /path/to/my_file
+ *
+ * and
+ *
+ * echo /path/to/my_file > /proc/software_suspend/filewriter_target
+ *
+ * then put what they find in /proc/software_suspend/resume2
+ * as their resume2= parameter in lilo.conf (and rerun lilo if using it).
+ *
+ * Having done this, they're ready to suspend and resume.
+ *
+ * TODO:
+ * - File resizing.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "suspend2_core/suspend.h"
+#include "suspend2_core/suspend2_common.h"
+#include "suspend2_core/version.h"
+#include "suspend2_core/proc.h"
+#include "suspend2_core/plugins.h"
+#include "suspend2_core/ui.h"
+#include "suspend2_core/extent.h"
+#include "suspend2_core/utility.h"
+#include "suspend2_core/io.h"
+
+#include "block_io.h"
+
+/*
+ * General Declarations.
+ */
+
+static struct suspend_proc_data filewriter_proc_data[];
+static struct suspend_plugin_ops filewriterops;
+
+/*
+ * External Declarations
+ */
+
+extern asmlinkage long sys_open(const char __user * filename, int flags, int 
mode);
+extern asmlinkage long sys_close(unsigned int fd);
+
+/*
+ * Forward Declarations
+ */
+
+static int filewriter_invalidate_image(void);
+static int filewriter_storage_available(void);
+
+/*
+ * Details of our target.
+ */
+
+char filewriter_target[256];
+static struct inode * target_inode;
+static int target_fd = -1;
+static struct block_device * target_bdev;
+static int used_devt = 0;
+static dev_t target_dev_t = 0;
+static int target_firstblock = 0;
+static int target_blocksize = PAGE_SIZE;
+static int target_storage_available = 0;
+static unsigned int target_blkbits;
+#define target_blockshift (PAGE_SHIFT - target_blkbits)
+#define target_blocksperpage (1 << target_blockshift)
+
+static int target_type = -1;
+
+/*
+static char * description[7] = {
+   "Socket",
+   "Link",
+   "Regular file",
+   "Block device",
+   "Directory",
+   "Character device",
+   "Fifo",
+};
+*/
+
+static char HaveImage[] = "HaveImage\n";
+static char NoImage[] =   "Suspend2\n";
+static const int resumed_before_byte = sizeof(HaveImage) + 1;
+#define sig_size resumed_before_byte
+
+/* Header_pages must be big enough for signature */
+static int header_pages, main_pages;
+
+static unsigned long * header_link = NULL;
+#define BYTES_PER_HEADER_PAGE (PAGE_SIZE - sizeof(sector_t))
+
+#define target_is_normal_file() (S_ISREG(target_inode->i_mode))
+
+/*
+ * Readahead Variables
+ */
+
+// Higher Level
+static int readahead_index = 0, readahead_submit_index = 0;
+static int readahead_allocs = 0, readahead_frees = 0;
+
+static char * filewriter_buffer = NULL;
+static int filewriter_buffer_posn = 0;
+static int filewriter_page_index = 0;
+
+/*
+ * ---
+ *
+ * Internal Data Structures
+ *
+ * ---
+ */
+
+/* header_data contains data that is needed to reload pagedir1, and
+ * is therefore saved in the suspend header.
+ *
+ * Pagedir2 data gets stored before pagedir1 (save order), and the first
+ * page for pagedir1 to use is set when pagedir2 is written (when we know how
+ * much storage it used). Since this first entry is almost certainly not at the
+ * start of a extent, the firstoffset variable below tells us where to start in
+ * the extent. All of this means we don't have to worry about getting different
+ * compression ratios for the kernel and cache (when compressing the image).
+ * We can simply allocate one pool of storage (size determined using expected
+ * compression ratio) and use it without worrying whether one pageset
+ * compresses better and the other worse (this is what happens). As long as the
+ * user gets the expected compression right, it will work.
+ */
+
+static struct {
+   /* Location of start of pagedir 1 */
+   struct extent * pd1start_block_extent;
+   int pd1start_extent_number;
+   unsigned long pd1start_block_offset;
+
+} filewriter_header_data;
+
+/* Extent chain for blocks */
+static struct extentchain block_chain;
+
+/*
+ * ---
+ *
+ * Current state.
+ 

[PATCH] [48/48] Suspend2 2.1.9.8 for 2.6.12: 624-filewriter.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 625-crypto-api-work.patch-old/crypto/Kconfig 
625-crypto-api-work.patch-new/crypto/Kconfig
--- 625-crypto-api-work.patch-old/crypto/Kconfig2005-06-20 
11:46:49.0 +1000
+++ 625-crypto-api-work.patch-new/crypto/Kconfig2005-07-04 
23:14:19.0 +1000
@@ -262,6 +262,13 @@ config CRYPTO_DEFLATE
  
  You will most probably want this if using IPSec.
 
+config CRYPTO_LZF
+   tristate "LZF compression algorithm"
+   depends on CRYPTO
+   help
+ This is the LZF algorithm. It is especially useful for Suspend2,
+ because it achieves good compression quickly.
+
 config CRYPTO_MICHAEL_MIC
tristate "Michael MIC keyed digest algorithm"
depends on CRYPTO
diff -ruNp 625-crypto-api-work.patch-old/crypto/lzf.c 
625-crypto-api-work.patch-new/crypto/lzf.c
--- 625-crypto-api-work.patch-old/crypto/lzf.c  1970-01-01 10:00:00.0 
+1000
+++ 625-crypto-api-work.patch-new/crypto/lzf.c  2005-07-05 23:57:15.0 
+1000
@@ -0,0 +1,442 @@
+/* 
+ * Cryptoapi LZF compression module.
+ *
+ * Copyright (c) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * based on the deflate.c file:
+ * 
+ * Copyright (c) 2003 James Morris <[EMAIL PROTECTED]>
+ * 
+ * and upon the LZF compression module donated to the Suspend2 project with
+ * the following copyright:
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option) 
+ * any later version.
+ * Copyright (c) 2000-2003 Marc Alexander Lehmann <[EMAIL PROTECTED]>
+ * 
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ * 
+ *   1.  Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * 
+ *   2.  Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * 
+ *   3.  The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
+ * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
+ * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
+ * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * the GNU General Public License version 2 (the "GPL"), in which case the
+ * provisions of the GPL are applicable instead of the above. If you wish to
+ * allow the use of your version of this file only under the terms of the
+ * GPL and not to allow others to use your version of this file under the
+ * BSD license, indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by the GPL. If
+ * you do not delete the provisions above, a recipient may use your version
+ * of this file under either the BSD or the GPL.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct lzf_ctx {
+   void * hbuf;
+   char * local_buffer;
+   char * page_buffer;
+   unsigned int bufofs;
+   int first_call;
+};
+
+/*
+ * size of hashtable is (1 << HLOG) * sizeof (char *)
+ * decompression is independent of the hash table size
+ * the difference between 15 and 14 is very small
+ * for small blocks (and 14 is also faster).
+ * For a low-memory configuration, use HLOG == 13;
+ * For best compression, use 15 or 16.
+ */
+#define HLOG 14
+
+/*
+ * sacrifice some compression quality in favour of compression speed.
+ * (roughly 1-2% worse compression for large blocks and
+ * 9-10% for small, redundant, blocks and >>20% better speed in both cases)
+ * In short: enable this for binary data, disable this for text data.
+ */
+#define ULTRA_FAST 1
+
+#define STRICT_ALIGN 0
+#define USE_MEMCPY 1
+#define INIT_HTAB 0
+
+#define HSIZE (1 << (HLOG))
+
+/*
+ * don't play with this unless you benchmark!
+ * decompression is not dependent on the hash function
+ * the hashing function might seem strange, just believe me
+ * it works ;)
+ */
+#d

[PATCH] [2/48] Suspend2 2.1.9.8 for 2.6.12: 300-reboot-handler-hook.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 
301-proc-acpi-sleep-activate-hook.patch-old/drivers/acpi/sleep/proc.c 
301-proc-acpi-sleep-activate-hook.patch-new/drivers/acpi/sleep/proc.c
--- 301-proc-acpi-sleep-activate-hook.patch-old/drivers/acpi/sleep/proc.c   
2005-06-20 11:46:50.0 +1000
+++ 301-proc-acpi-sleep-activate-hook.patch-new/drivers/acpi/sleep/proc.c   
2005-07-04 23:14:18.0 +1000
@@ -68,6 +68,17 @@ acpi_system_write_sleep (
goto Done;
}
state = simple_strtoul(str, NULL, 0);
+#ifdef CONFIG_SUSPEND2
+   /* 
+* I used to put this after the CONFIG_SOFTWARE_SUSPEND
+* test, but people who compile in suspend2 usually want
+* to use it instead of swsusp.   --NC
+*/
+   if (state == 4) {
+   suspend2_try_suspend();
+   goto Done;
+   }
+#endif
 #ifdef CONFIG_SOFTWARE_SUSPEND
if (state == 4) {
error = software_suspend();

-
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/48] Suspend2 2.1.9.8 for 2.6.12: 609-driver-model.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 610-encryption.patch-old/kernel/power/suspend2_core/encryption.c 
610-encryption.patch-new/kernel/power/suspend2_core/encryption.c
--- 610-encryption.patch-old/kernel/power/suspend2_core/encryption.c
1970-01-01 10:00:00.0 +1000
+++ 610-encryption.patch-new/kernel/power/suspend2_core/encryption.c
2005-07-05 23:54:31.0 +1000
@@ -0,0 +1,598 @@
+/*
+ * kernel/power/suspend2_core/encryption.c
+ *
+ * Copyright (C) 2003-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * This file contains data encryption routines for suspend,
+ * using cryptoapi transforms.
+ *
+ * ToDo:
+ * - Apply min/max_keysize the cipher changes.
+ * - Test.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "suspend.h"
+#include "plugins.h"
+#include "proc.h"
+#include "suspend2_common.h"
+#include "utility.h"
+#include "io.h"
+
+#define S2C_WRITE 0
+#define S2C_READ 1
+
+static struct suspend_plugin_ops s2_encryption_ops;
+static struct suspend_plugin_ops * next_driver;
+
+static char s2_encryptor_name[32];
+static struct crypto_tfm * s2_encryptor_transform;
+static char s2_encryptor_key[256];
+static int s2_key_len;
+static char s2_encryptor_iv[256];
+static int s2_encryptor_mode;
+static int s2_encryptor_save_key_and_iv;
+
+static u8 *page_buffer = NULL;
+static unsigned int bufofs;
+
+static struct scatterlist s2_crypt_sg[PAGE_SIZE/8];
+
+/*  Local buffer management  */
+
+/* allocate_local_buffer
+ *
+ * Description:Allocates a page of memory for buffering output.
+ * Returns:Int: Zero if successful, -ENONEM otherwise.
+ */
+
+static int allocate_local_buffer(void)
+{
+   if (!page_buffer) {
+   int i;
+   
+   page_buffer = (char *) get_zeroed_page(GFP_ATOMIC);
+   
+   if (!page_buffer) {
+   printk(KERN_ERR
+   "Failed to allocate the page buffer for "
+   "suspend2 encryption driver.\n");
+   return -ENOMEM;
+   }
+
+   for (i=0; i < (PAGE_SIZE / s2_key_len); i++) {
+   s2_crypt_sg[i].page = virt_to_page(page_buffer);
+   s2_crypt_sg[i].offset = s2_key_len * i;
+   s2_crypt_sg[i].length = s2_key_len;
+   }
+   }
+
+   return 0;
+}
+
+/* free_local_buffer
+ *
+ * Description:Frees memory allocated for buffering output.
+ */
+
+static inline void free_local_buffer(void)
+{
+   if (page_buffer)
+   free_pages((unsigned long) page_buffer, 0);
+
+   page_buffer = NULL;
+}
+
+/* suspend2_crypto_cleanup
+ *
+ * Description:Frees memory allocated for our labours.
+ */
+
+static void suspend2_crypto_cleanup(void)
+{
+   if (s2_encryptor_transform) {
+   crypto_free_tfm(s2_encryptor_transform);
+   s2_encryptor_transform = NULL;
+   }
+}
+
+/* suspend2_crypto_prepare
+ *
+ * Description:Prepare to do some work by allocating buffers and 
transforms.
+ * Returns:Int: Zero if successful, -ENONEM otherwise.
+ */
+
+static int s2_encrypt_crypto_prepare(int mode)
+{
+   if (!*s2_encryptor_name) {
+   printk("Suspend2: Encryptor enabled but no name set.\n");
+   return 1;
+   }
+
+   if (!(s2_encryptor_transform = crypto_alloc_tfm(s2_encryptor_name,
+   1 << s2_encryptor_mode))) {
+   printk("Suspend2: Failed to initialise the encryption transform 
(%s, mode %d).\n",
+   s2_encryptor_name, s2_encryptor_mode);
+   return 1;
+   }
+
+   if (mode)
+   bufofs = PAGE_SIZE;
+   else
+   bufofs = 0;
+
+   s2_key_len = strlen(s2_encryptor_key);
+
+   if (crypto_cipher_setkey(s2_encryptor_transform, s2_encryptor_key, 
+   s2_key_len)) {
+   printk("%d is an invalid key length for cipher %s.\n",
+   s2_key_len,
+   s2_encryptor_name);
+   return 1;
+   }
+   
+   if (!mode) {
+   crypto_cipher_set_iv(s2_encryptor_transform,
+   s2_encryptor_iv,
+   crypto_tfm_alg_ivsize(s2_encryptor_transform));
+   }
+   
+   return 0;
+}
+
+/*  Exported functions  */
+
+/* write_init()
+ *
+ * Description:Allocate buffers and prepare to encrypt data.
+ * Arguments:  Stream_number:  Ignored.
+ * Returns:Zero on success, -ENOMEM if unable to vmalloc.
+ */
+
+static int s2_encrypt_write_init(int stream_number)
+{
+   int result;
+   
+   next_driver = get_next_filter(&s2_encryption_ops);
+
+   if (!next_driver) {
+   printk("Encryption Driver: Argh! No one wants my output!");
+

[PATCH] [44/48] Suspend2 2.1.9.8 for 2.6.12: 620-userui.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 621-swsusp-tidy.patch-old/kernel/power/swsusp.c 
621-swsusp-tidy.patch-new/kernel/power/swsusp.c
--- 621-swsusp-tidy.patch-old/kernel/power/swsusp.c 2005-06-20 
11:47:31.0 +1000
+++ 621-swsusp-tidy.patch-new/kernel/power/swsusp.c 2005-07-04 
23:14:19.0 +1000
@@ -36,6 +36,8 @@
  * For TODOs,FIXMEs also look in Documentation/power/swsusp.txt
  */
 
+#define KERNEL_POWER_SWSUSP_C
+
 #include 
 #include 
 #include 
@@ -51,9 +53,7 @@
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -71,9 +71,7 @@
 #include 
 
 #include "power.h"
-
-/* References to section boundaries */
-extern const void __nosave_begin, __nosave_end;
+#include "suspend.h"
 
 /* Variables to be preserved over suspend */
 static int nr_copy_pages_check;

-
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] [1/48] Suspend2 2.1.9.8 for 2.6.12: submit_intro

2005-07-05 Thread Nigel Cunningham
diff -ruNp 300-reboot-handler-hook.patch-old/kernel/sys.c 
300-reboot-handler-hook.patch-new/kernel/sys.c
--- 300-reboot-handler-hook.patch-old/kernel/sys.c  2005-06-20 
11:47:32.0 +1000
+++ 300-reboot-handler-hook.patch-new/kernel/sys.c  2005-07-04 
23:14:18.0 +1000
@@ -436,12 +436,12 @@ asmlinkage long sys_reboot(int magic1, i
machine_restart(buffer);
break;
 
-#ifdef CONFIG_SOFTWARE_SUSPEND
+#ifdef CONFIG_SUSPEND2
case LINUX_REBOOT_CMD_SW_SUSPEND:
{
-   int ret = software_suspend();
+   suspend2_try_suspend();
unlock_kernel();
-   return ret;
+   return 0;
}
 #endif
 

-
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/48] Suspend2 2.1.9.8 for 2.6.12: 610-extent.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 611-io.patch-old/kernel/power/suspend2_core/io.c 
611-io.patch-new/kernel/power/suspend2_core/io.c
--- 611-io.patch-old/kernel/power/suspend2_core/io.c1970-01-01 
10:00:00.0 +1000
+++ 611-io.patch-new/kernel/power/suspend2_core/io.c2005-07-05 
23:48:59.0 +1000
@@ -0,0 +1,1006 @@
+/*
+ * kernel/power/io.c
+ *
+ * Copyright (C) 1998-2001 Gabor Kuti <[EMAIL PROTECTED]>
+ * Copyright (C) 1998,2001,2002 Pavel Machek <[EMAIL PROTECTED]>
+ * Copyright (C) 2002-2003 Florent Chabaud <[EMAIL PROTECTED]>
+ * Copyright (C) 2002-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * It contains high level IO routines for suspending.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include "version.h"
+#include "plugins.h"
+#include "pageflags.h"
+#include "io.h"
+#include "ui.h"
+#include "suspend2_common.h"
+#include "suspend.h"
+
+/* attempt_to_parse_resume_device
+ *
+ * Can we suspend, using the current resume2= parameter?
+ */
+void attempt_to_parse_resume_device(void)
+{
+   struct list_head *writer;
+   struct suspend_plugin_ops * this_writer;
+   int result = 0;
+
+   active_writer = NULL;
+   clear_suspend_state(SUSPEND_RESUME_DEVICE_OK);
+   set_suspend_state(SUSPEND_DISABLED);
+   CLEAR_RESULT_STATE(SUSPEND_ABORTED);
+
+   if (!num_writers) {
+   printk(name_suspend "No writers have been registered. 
Suspending will be disabled.\n");
+   return;
+   }
+   
+   if (!resume2_file[0]) {
+   printk(name_suspend "Resume2 parameter is empty. Suspending 
will be disabled.\n");
+   return;
+   }
+
+   list_for_each(writer, &suspend_writers) {
+   this_writer = list_entry(writer, struct suspend_plugin_ops,
+   ops.writer.writer_list);
+
+   /* 
+* Not sure why you'd want to disable a writer, but
+* we should honour the flag if we're providing it
+*/
+   if (this_writer->disabled) {
+   printk(name_suspend
+   "Writer '%s' is disabled. Ignoring 
it.\n",
+   this_writer->name);
+   continue;
+   }
+
+   result = this_writer->ops.writer.parse_image_location(
+   resume2_file, (num_writers == 1));
+
+   switch (result) {
+   case -EINVAL:
+   /* 
+* For this writer, but not a valid 
+* configuration. Error already printed.
+*/
+
+   return;
+
+   case 0:
+   /*
+* For this writer and valid.
+*/
+
+   active_writer = this_writer;
+
+   set_suspend_state(SUSPEND_RESUME_DEVICE_OK);
+   clear_suspend_state(SUSPEND_DISABLED);
+   printk(name_suspend "Suspending enabled.\n");
+
+   return;
+   }
+   }
+   printk(name_suspend "No matching enabled writer found. Suspending 
disabled.\n");
+}
+
+/* suspend2_cleanup_finished_io
+ *
+ * Description:Very simple helper function to save #including all the
+ * suspend code in fs/buffer.c and anywhere else we might
+ * want to wait on suspend I/O in future.
+ */
+
+void suspend2_cleanup_finished_io(void)
+{
+   active_writer->ops.writer.wait_on_io(0);
+}
+
+/* noresume_reset_plugins
+ *
+ * Description:When we read the start of an image, plugins (and 
especially the
+ * active writer) might need to reset data structures if we decide
+ * to invalidate the image rather than resuming from it.
+ */
+
+static void noresume_reset_plugins(void)
+{
+   struct suspend_plugin_ops * this_filter;
+   
+   list_for_each_entry(this_filter, &suspend_filters, 
ops.filter.filter_list) {
+   if (this_filter->ops.filter.noresume_reset)
+   this_filter->ops.filter.noresume_reset();
+   }
+
+   if (active_writer && active_writer->ops.writer.noresume_reset)
+   active_writer->ops.writer.noresume_reset();
+}
+
+/* fill_suspend_header()
+ * 
+ * Description:Fill the suspend header structure.
+ * Arguments:  struct suspend_header: Header data structure to be filled.
+ */
+
+static void fill_suspend_header(struct suspend_header *sh)
+{
+   int i;
+   
+   memset((char *)sh, 0, sizeof(*sh));
+
+   sh->version_code = LINUX_VERSION_CODE;
+   sh->num_physpages = num_physpages;
+   sh->orig_mem_free = suspend2_orig_mem_free;
+   strncpy(sh->machine, system_utsnam

[PATCH] [9/48] Suspend2 2.1.9.8 for 2.6.12: 354-disable-mce-checking-during-suspend-avoid-smp-deadlock.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 360-reset-kswapd-max-order-after-resume.patch-old/mm/vmscan.c 
360-reset-kswapd-max-order-after-resume.patch-new/mm/vmscan.c
--- 360-reset-kswapd-max-order-after-resume.patch-old/mm/vmscan.c   
2005-07-06 11:18:05.0 +1000
+++ 360-reset-kswapd-max-order-after-resume.patch-new/mm/vmscan.c   
2005-07-04 23:14:20.0 +1000
@@ -1228,8 +1228,10 @@ static int kswapd(void *p)
order = 0;
for ( ; ; ) {
unsigned long new_order;
-
-   try_to_freeze();
+   if (freezing(current)) {
+   try_to_freeze();
+   pgdat->kswapd_max_order = 0;
+   }
 
prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
new_order = pgdat->kswapd_max_order;

-
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] [15/48] Suspend2 2.1.9.8 for 2.6.12: 405-clear-swapfile-bdev-in-swapoff.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 406-dynamic-pageflags.patch-old/include/linux/dyn_pageflags.h 
406-dynamic-pageflags.patch-new/include/linux/dyn_pageflags.h
--- 406-dynamic-pageflags.patch-old/include/linux/dyn_pageflags.h   
1970-01-01 10:00:00.0 +1000
+++ 406-dynamic-pageflags.patch-new/include/linux/dyn_pageflags.h   
2005-07-04 23:14:20.0 +1000
@@ -0,0 +1,63 @@
+/*
+ * include/linux/dyn_pageflags.h
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * It implements support for dynamically allocated bitmaps that are
+ * used for temporary or infrequently used pageflags, in lieu of
+ * bits in the struct page flags entry.
+ */
+
+#ifndef DYN_PAGEFLAGS_H
+#define DYN_PAGEFLAGS_H
+
+#include 
+
+typedef unsigned long ** dyn_pageflags_t;
+
+#define BITNUMBER(page) (page_to_pfn(page))
+
+#define PAGEBIT(page) ((int) ((page_to_pfn(page))%(8 * sizeof(unsigned long
+
+#define BITS_PER_PAGE (PAGE_SIZE * 8)
+#define PAGES_PER_BITMAP ((max_mapnr + BITS_PER_PAGE - 1) / BITS_PER_PAGE)
+#define PAGENUMBER(page) (BITNUMBER(page) / BITS_PER_PAGE)
+
+#define PAGEINDEX(page) ((BITNUMBER(page) - (BITS_PER_PAGE * 
PAGENUMBER(page)))/(8*sizeof(unsigned long)))
+
+#define PAGE_UL_PTR(bitmap, pagenum) 
((bitmap[PAGENUMBER(pagenum)])+PAGEINDEX(pagenum))
+
+#define __get_next_bit_on_safe(bitmap, counter) \
+   do { \
+   (counter)++; \
+   } while(((counter) < max_mapnr) && \
+   (!test_bit(PAGEBIT(pfn_to_page((counter))), \
+   PAGE_UL_PTR(bitmap, pfn_to_page((counter));
+
+static inline int __get_next_bit_on(dyn_pageflags_t bitmap, int counter)
+{
+   do {
+   counter++;
+   } while((counter < max_mapnr) &&
+   (!test_bit(PAGEBIT(pfn_to_page(counter)),
+   PAGE_UL_PTR(bitmap, pfn_to_page(counter);
+   return counter;
+}
+
+/* With the above macros defined, you can do...
+
+#define PageInUse(page)\
+   test_bit(PAGEBIT(page), PAGE_UL_PTR(in_use_map, page))
+#define SetPageInUse(page) \
+   set_bit(PAGEBIT(page), PAGE_UL_PTR(in_use_map, page))
+#define ClearPageInUse(page) \
+   clear_bit(PAGEBIT(page), PAGE_UL_PTR(in_use_map, page))
+*/
+
+extern void clear_dyn_pageflags(dyn_pageflags_t pagemap);
+extern int allocate_dyn_pageflags(dyn_pageflags_t *pagemap);
+extern int free_dyn_pageflags(dyn_pageflags_t *pagemap);
+
+#endif
diff -ruNp 406-dynamic-pageflags.patch-old/lib/dyn_pageflags.c 
406-dynamic-pageflags.patch-new/lib/dyn_pageflags.c
--- 406-dynamic-pageflags.patch-old/lib/dyn_pageflags.c 1970-01-01 
10:00:00.0 +1000
+++ 406-dynamic-pageflags.patch-new/lib/dyn_pageflags.c 2005-07-04 
23:14:20.0 +1000
@@ -0,0 +1,78 @@
+/*
+ * lib/dyn_pageflags.c
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ * 
+ * This file is released under the GPLv2.
+ *
+ * Routines for dynamically allocating and releasing bitmaps
+ * used as pseudo-pageflags.
+ *
+ * Arrays are not contiguous. The first sizeof(void *) bytes are
+ * the pointer to the next page in the bitmap. This allows us to
+ * work under low memory conditions where order 0 might be all
+ * that's available. In their original use (suspend2), it also
+ * lets us save the pages at suspend time, reload and relocate them
+ * as necessary at resume time without much effort.
+ */
+
+#include 
+#include 
+
+/* clear_map
+ *
+ * Description:Clear an array used to store local page flags.
+ * Arguments:  dyn_pageflags_t:The pagemap to be cleared.
+ */
+
+void clear_dyn_pageflags(dyn_pageflags_t pagemap)
+{
+   int i = 0;
+   
+   for (i = 0; i < PAGES_PER_BITMAP; i++)
+   memset((pagemap[i]), 0, PAGE_SIZE);
+}
+
+/* allocate_local_pageflags
+ *
+ * Description:Allocate a bitmap for local page flags.
+ * Arguments:  dyn_pageflags_t *:  Pointer to the bitmap.
+ */
+int allocate_dyn_pageflags(dyn_pageflags_t *pagemap)
+{
+   int i;
+
+   BUG_ON(*pagemap);
+
+   *pagemap = kmalloc(sizeof(void *) * PAGES_PER_BITMAP, GFP_ATOMIC);
+
+   for (i = 0; i < PAGES_PER_BITMAP; i++) {
+   (*pagemap)[i] = (unsigned long *) get_zeroed_page(GFP_ATOMIC);
+   if (!(*pagemap)[i]) {
+   printk("Error. Unable to allocate memory for "
+   "dynamic pageflags.");
+   free_dyn_pageflags(pagemap);
+   return 1;
+   }
+   }
+   return 0;
+}
+
+/* free_dyn_pageflags
+ *
+ * Description:Free a dynamically allocated pageflags bitmap.
+ * Arguments:  dyn_pageflags_t *: Pointer to the bitmap being freed.
+ */
+int free_dyn_pageflags(dyn_pageflags_t *pagemap)
+{
+   int i = 0;
+   if (!*pagemap)
+   return 1;
+   
+   for (i = 0; i < PAGES_PER_BITMAP; i++)
+   free_pages((unsigned long) (*pagemap)[i], 0);
+   
+   kfree(

[PATCH] [33/48] Suspend2 2.1.9.8 for 2.6.12: 610-encryption.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 610-extent.patch-old/kernel/power/suspend2_core/extent.c 
610-extent.patch-new/kernel/power/suspend2_core/extent.c
--- 610-extent.patch-old/kernel/power/suspend2_core/extent.c1970-01-01 
10:00:00.0 +1000
+++ 610-extent.patch-new/kernel/power/suspend2_core/extent.c2005-07-04 
23:14:19.0 +1000
@@ -0,0 +1,206 @@
+/*
+ * kernel/power/suspend2_core/extent.c
+ * 
+ * Suspend2 routines for manipulating extents.
+ *
+ * (C) 2003-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * Distributed under GPLv2.
+ * 
+ * These functions encapsulate the manipulation of extents.
+ * They work like this:
+ *
+ * A lot of the data that suspend saves involves continguous extents of memory
+ * or storage. Let's say that we're storing data on disk in blocks 1-32768 and
+ * 49152-49848 of a swap partition. Rather than recording 1, 2, 3... in arrays
+ * pointing to the locations, we simply use:
+ *
+ * struct extent {
+ * unsigned long min;
+ * unsigned long max;
+ * struct extent * next;
+ * }
+ *
+ * We can then store 1-32768 and 49152-49848 in 2 struct extents, using 24 
bytes
+ * instead of something like 133,860. This is of course inefficient where a 
extent
+ * covers only one or two values, but the benefits gained by the much larger
+ * extents more than outweigh these instances.
+ *
+ * When _all_ the metadata was stored in extents, we used to have fancier code 
that
+ * stored them in pages and was optimised for our usage. Nowadays they are only
+ * used for storage information. We therefore kmalloc them as required, and
+ * provide a far simpler routine to serialise them in the image header.
+ */
+
+#include 
+#include 
+#include "plugins.h"
+#include "extent.h"
+#include "ui.h"
+
+int extents_allocated = 0, max_extents_used = 0;
+
+/* get_extent
+ *
+ * Returns a free extent.
+ * May fail, returning NULL instead.
+ */
+
+static struct extent * get_extent(void)
+{
+   struct extent * result;
+   
+   if (!(result = kmalloc(sizeof(struct extent), GFP_ATOMIC)))
+   return NULL;
+
+   extents_allocated++;
+   if (extents_allocated > max_extents_used)
+   max_extents_used++;
+   result->minimum = result->maximum = 0;
+   result->next = NULL;
+   return result;
+}
+
+/*
+ * put_extent.
+ *
+ * Frees an extent.
+ *
+ * Assumes unlinking is done by the caller.
+ */
+void put_extent(struct extent * extent)
+{
+   if (!extent) {
+   printk("Error! put_extent called with NULL extent.\n");
+   return;
+   }
+   kfree(extent);
+   extents_allocated--;
+}
+
+/*
+ * put_extent_chain.
+ *
+ * Frees a whole chain of extents.
+ */
+void put_extent_chain(struct extentchain * chain)
+{
+   struct extent * this;
+
+   this = chain->first;
+
+   if (!this)
+   return;
+
+   while(this) {
+   struct extent * next = this->next;
+   kfree(this);
+   chain->frees++;
+   extents_allocated --;
+   this = next;
+   }
+   
+   BUG_ON(chain->frees != chain->allocs);
+   chain->first = chain->last = NULL;
+   chain->size = chain->allocs = chain->frees = 0;
+}
+
+/* 
+ * append_extent_to_extent_chain
+ *
+ * Used where we know a extent is to be added to the end of the list
+ * and does not need merging with the current last extent.
+ */
+
+int append_extent_to_extent_chain(struct extentchain * chain, 
+   unsigned long minimum, unsigned long maximum)
+{
+   struct extent * newextent = NULL;
+
+   newextent = get_extent();
+   if (!newextent) {
+   printk("Error unable to append a new extent to the chain.\n");
+   return 2;
+   }
+
+   chain->allocs++;
+   chain->size+= (maximum - minimum + 1);
+   newextent->minimum = minimum;
+   newextent->maximum = maximum;
+   newextent->next = NULL;
+
+   if (chain->last) {
+   chain->last->next = newextent;
+   chain->last = newextent;
+   } else 
+   chain->last = chain->first = newextent;
+
+   /* No need to reset optimisation info since added to end */
+   return 0;
+}
+
+/* 
+ * serialise_extent_chain
+ *
+ * Write a chain in the image.
+ */
+int serialise_extent_chain(struct extentchain * chain)
+{
+   struct extent * this;
+   int ret, i = 1;
+   
+   if ((ret = active_writer->ops.writer.write_header_chunk((char *) chain,
+   sizeof(struct extentchain) - 2 * sizeof(struct extent * {
+   printk("Write header chunk returned %d - aborting serialising 
chain.\n",
+   ret);
+   return ret;
+   }
+
+   this = chain->first;
+   while (this) {
+   if ((ret = active_writer->ops.writer.write_header_chunk((char 
*) this,
+   2 * sizeof(unsigned long {
+   printk("Failed to write extent.\n");
+  

[PATCH] [39/48] Suspend2 2.1.9.8 for 2.6.12: 615-poweroff.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 
616-prepare_image.patch-old/kernel/power/suspend2_core/prepare_image.c 
616-prepare_image.patch-new/kernel/power/suspend2_core/prepare_image.c
--- 616-prepare_image.patch-old/kernel/power/suspend2_core/prepare_image.c  
1970-01-01 10:00:00.0 +1000
+++ 616-prepare_image.patch-new/kernel/power/suspend2_core/prepare_image.c  
2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,585 @@
+/*
+ * kernel/power/prepare_image.c
+ *
+ * Copyright (C) 2003-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * We need to eat memory until we can:
+ * 1. Perform the save without changing anything (RAM_NEEDED < max_mapnr)
+ * 2. Fit it all in available space (active_writer->available_space() >= 
STORAGE_NEEDED)
+ * 3. Reload the pagedir and pageset1 to places that don't collide with their
+ *final destinations, not knowing to what extent the resumed kernel will
+ *overlap with the one loaded at boot time. I think the resumed kernel 
should overlap
+ *completely, but I don't want to rely on this as it is an unproven 
assumption. We
+ *therefore assume there will be no overlap at all (worse case).
+ * 4. Meet the user's requested limit (if any) on the size of the image.
+ *The limit is in MB, so pages/256 (assuming 4K pages).
+ *
+ *(Final test in save_image doesn't use EATEN_ENOUGH_MEMORY)
+ */
+
+#include 
+
+#include "suspend.h"
+#include "pageflags.h"
+#include "plugins.h"
+#include "suspend2_common.h"
+#include "io.h"
+#include "ui.h"
+#include "extent.h"
+#include "prepare_image.h"
+
+#define EATEN_ENOUGH_MEMORY() (amount_needed(1) < 1)
+static int arefrozen = 0, numnosave = 0;
+static int header_space_allocated = 0;
+static int storage_allocated = 0;
+static int storage_available = 0;
+
+static int num_pcp_pages(void)
+{
+   struct zone *zone;
+   int result = 0, i = 0;
+
+   /* PCP lists */
+   for_each_zone(zone) {
+   struct per_cpu_pageset *pset;
+   int cpu;
+   
+   if (!zone->present_pages)
+   continue;
+   
+   for (cpu = 0; cpu < NR_CPUS; cpu++) {
+   if (!cpu_possible(cpu))
+   continue;
+
+   pset = &zone->pageset[cpu];
+
+   for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
+   struct per_cpu_pages *pcp;
+
+   pcp = &pset->pcp[i];
+   result += pcp->count;
+   }
+   }
+   }
+   return result;
+}
+
+int real_nr_free_pages(void)
+{
+   return nr_free_pages() + num_pcp_pages();
+}
+
+/* generate_free_page_map
+ *
+ * Description:This routine generates a bitmap of free pages from the
+ * lists used by the memory manager. We then use the bitmap
+ * to quickly calculate which pages to save and in which
+ * pagesets.
+ */
+static void generate_free_page_map(void) 
+{
+   int i, order, loop, cpu;
+   struct page * page;
+   unsigned long flags;
+   struct zone *zone;
+   struct per_cpu_pageset *pset;
+
+   for(i=0; i < max_mapnr; i++)
+   SetPageInUse(pfn_to_page(i));
+   
+   for_each_zone(zone) {
+   if (!zone->present_pages)
+   continue;
+   spin_lock_irqsave(&zone->lock, flags);
+   for (order = MAX_ORDER - 1; order >= 0; --order) {
+   list_for_each_entry(page, 
&zone->free_area[order].free_list, lru)
+   for(loop=0; loop < (1 << order); loop++) {
+   ClearPageInUse(page+loop);
+   ClearPagePageset2(page+loop);
+   }
+   }
+
+   
+   for (cpu = 0; cpu < NR_CPUS; cpu++) {
+   if (!cpu_possible(cpu))
+   continue;
+
+   pset = &zone->pageset[cpu];
+
+   for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
+   struct per_cpu_pages *pcp;
+   struct page * page;
+
+   pcp = &pset->pcp[i];
+   list_for_each_entry(page, &pcp->list, lru) {
+   ClearPageInUse(page);
+   ClearPagePageset2(page);
+   }
+   }
+   }
+   
+   spin_unlock_irqrestore(&zone->lock, flags);
+   }
+}
+
+/* size_of_free_region
+ * 
+ * Description:Return the number of pages that are free, beginning 
with and 
+ * including this one.
+ */
+static int size_of_free_region(struct page * page)
+{
+   struct page * posn = page;
+
+   while (((page_to_pf

[PATCH] [40/48] Suspend2 2.1.9.8 for 2.6.12: 616-prepare_image.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 617-proc.patch-old/kernel/power/suspend2_core/proc.c 
617-proc.patch-new/kernel/power/suspend2_core/proc.c
--- 617-proc.patch-old/kernel/power/suspend2_core/proc.c1970-01-01 
10:00:00.0 +1000
+++ 617-proc.patch-new/kernel/power/suspend2_core/proc.c2005-07-04 
23:14:19.0 +1000
@@ -0,0 +1,336 @@
+/*
+ * /kernel/power/proc.c
+ *
+ * Copyright (C) 2002-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * This file contains support for proc entries for tuning Software Suspend.
+ *
+ * We have a generic handler that deals with the most common cases, and
+ * hooks for special handlers to use.
+ *
+ * Versions:
+ * 1: /proc/sys/kernel/suspend the only tuning interface
+ * 2: Initial version of this file
+ * 3: Removed kernel debugger parameter.
+ *Added checkpage parameter (for checking checksum of a page over time).
+ * 4: Added entry for maximum granularity in splash screen progress bar.
+ *(Progress bar is slow, but the right setting will vary with disk &
+ *processor speed and the user's tastes).
+ * 5: Added enable_escape to control ability to cancel aborting by pressing
+ *ESC key.
+ * 6: Removed checksumming and checkpage parameter. Made all debugging proc
+ *entries dependant upon debugging being compiled in.
+ *Meaning of some flags also changed in this version.
+ * 7: Added header_locations entry to simplify getting the resume= parameter 
for
+ *swapfiles easy and swapfile entry for automatically doing swapon/off from
+ *swapfiles as well as partitions.
+ * 8: Added option for marking process pages as pageset 2 (processes_pageset2).
+ * 9: Added option for keep image mode.
+ *Enumeration patch from Michael Frank applied.
+ * 10: Various corrections to when options are disabled/enabled;
+ * Added option for specifying expected compression.
+ * 11: Added option for freezer testing. Debug only.
+ * 12: Removed test entries no_async_[read|write], processes_pageset2 and
+ * NoPageset2.
+ * 13: Make default_console_level available when debugging disabled, but 
limited
+ * to 0 or 1.
+ * 14: Rewrite to allow for dynamic registration of proc entries and smooth the
+ * transition to kobjects in 2.6.
+ * 15: Add setting resume2 parameter without rebooting (still need to run lilo
+ * though!). Add support for generic string handling and switch resume2 to 
use
+ * it.
+ * 16: Switched to cryptoapi, adding entries for selecting encryptor and 
compressor.
+ */
+
+#define SUSPEND_PROC_C
+
+static int suspend_proc_version = 16;
+static int suspend_proc_initialised = 0;
+
+#include 
+#include 
+#include 
+
+#include "proc.h"
+#include "suspend.h"
+
+static struct list_head suspend_proc_entries;
+static struct proc_dir_entry *suspend_dir;
+static struct suspend_proc_data proc_params[];
+
+extern void __suspend2_try_resume(void);
+extern void __suspend2_try_suspend(void);
+
+/* suspend2_read_proc
+ *
+ * Generic handling for reading the contents of bits, integers,
+ * unsigned longs and strings.
+ */
+static int suspend2_read_proc(char * page, char ** start, off_t off, int count,
+   int *eof, void *data)
+{
+   int len = 0;
+   struct suspend_proc_data * proc_data = (struct suspend_proc_data *) 
data;
+
+   if (suspend_start_anything(0))
+   return -EBUSY;
+   
+   switch (proc_data->type) {
+   case SUSPEND_PROC_DATA_CUSTOM:
+   if (proc_data->data.special.read_proc) {
+   read_proc_t * read_proc = 
proc_data->data.special.read_proc;
+   len = read_proc(page, start, off, count, eof, 
data);
+   } else
+   len = 0;
+   break;
+   case SUSPEND_PROC_DATA_BIT:
+   len = sprintf(page, "%d\n", 
+   -test_bit(proc_data->data.bit.bit,
+   proc_data->data.bit.bit_vector));
+   break;
+   case SUSPEND_PROC_DATA_INTEGER:
+   {
+   int * variable = 
proc_data->data.integer.variable;
+   len = sprintf(page, "%d\n", *variable);
+   break;
+   }
+   case SUSPEND_PROC_DATA_UL:
+   {
+   long * variable = proc_data->data.ul.variable;
+   len = sprintf(page, "%lu\n", *variable);
+   break;
+   }
+   case SUSPEND_PROC_DATA_STRING:
+   {
+   char * variable = 
proc_data->data.string.variable;
+   len = sprintf(page, "%s\n", variable);
+   break;
+   }
+   }
+   /* Side effect ro

[PATCH] [42/48] Suspend2 2.1.9.8 for 2.6.12: 618-core.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 
619-userspace-nofreeze.patch-old/kernel/power/suspend2_core/userspace-nofreeze.c
 
619-userspace-nofreeze.patch-new/kernel/power/suspend2_core/userspace-nofreeze.c
--- 
619-userspace-nofreeze.patch-old/kernel/power/suspend2_core/userspace-nofreeze.c
1970-01-01 10:00:00.0 +1000
+++ 
619-userspace-nofreeze.patch-new/kernel/power/suspend2_core/userspace-nofreeze.c
2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,69 @@
+/*
+ * kernel/power/suspend2_core/userspace-nofreeze.c
+ *
+ * Mark/unmark userspace processes as PF_NOFREEZE.
+ *
+ * This should be used with extreme caution!
+ *
+ * Initial purpose: make nbd-client about to be NOFREEZE.
+ */
+
+#include 
+#include 
+#include 
+#include "../suspend.h"
+
+int toggle_pid;
+
+/*
+ * toggle_thread_nofreeze
+ *
+ * Toggle a thread's PF_NOFREEZE flag
+ *
+ * Returns:
+ * -1: PID not found
+ *  0: NO_FREEZE cleared.
+ *  1: NO_FREEZE set.
+ */
+static int __toggle_thread_nofreeze(int pid)
+{
+   struct task_struct *p, *g;
+   int result = -1;
+
+   read_lock(&tasklist_lock);
+
+   do_each_thread(g, p) {
+   if (p->pid == pid) {
+   if (p->mm) {
+   p->flags ^=PF_NOFREEZE;
+   result = !!(p->flags & PF_NOFREEZE);
+   } else
+   printk("Cowardly refusing to toggle NOFREEZE on 
a real kernel thread!");
+   }
+   } while_each_thread(g, p);
+
+   read_unlock(&tasklist_lock);
+
+   return result;
+}
+
+void toggle_thread_nofreeze(void)
+{
+   int result;
+   printk("Seeking %d... ", toggle_pid);
+
+   switch ((result = __toggle_thread_nofreeze(toggle_pid)))
+   {
+   case -1:
+   printk("Can't toggle NO_FREEZE for thread - not 
found.\n");
+   break;
+   case 0:
+   printk("NO_FREEZE flag cleared.\n");
+   break;
+   case 1:
+   printk("NO_FREEZE flag set.\n");
+   break;
+   default:
+   printk("what does %d mean?!", result);
+   }
+}

-
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] [10/48] Suspend2 2.1.9.8 for 2.6.12: 360-reset-kswapd-max-order-after-resume.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 401-e820-table-support.patch-old/arch/i386/mm/init.c 
401-e820-table-support.patch-new/arch/i386/mm/init.c
--- 401-e820-table-support.patch-old/arch/i386/mm/init.c2005-06-20 
11:46:43.0 +1000
+++ 401-e820-table-support.patch-new/arch/i386/mm/init.c2005-07-04 
23:14:18.0 +1000
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -269,12 +270,15 @@ void __init one_highpage_init(struct pag
 {
if (page_is_ram(pfn) && !(bad_ppro && page_kills_ppro(pfn))) {
ClearPageReserved(page);
+   ClearPageNosave(page);
set_bit(PG_highmem, &page->flags);
set_page_count(page, 1);
__free_page(page);
totalhigh_pages++;
-   } else
+   } else {
SetPageReserved(page);
+   SetPageNosave(page);
+   }
 }
 
 #ifndef CONFIG_DISCONTIGMEM
@@ -352,7 +356,7 @@ static void __init pagetable_init (void)
 #endif
 }
 
-#if defined(CONFIG_PM_DISK) || defined(CONFIG_SOFTWARE_SUSPEND)
+#ifdef CONFIG_PM
 /*
  * Swap suspend & friends need this for resume because things like the 
intel-agp
  * driver might have split up a kernel 4MB mapping.
@@ -539,6 +543,7 @@ void __init mem_init(void)
int codesize, reservedpages, datasize, initsize;
int tmp;
int bad_ppro;
+   void * addr;
 
 #ifndef CONFIG_DISCONTIGMEM
if (!mem_map)
@@ -569,12 +574,25 @@ void __init mem_init(void)
totalram_pages += free_all_bootmem();
 
reservedpages = 0;
-   for (tmp = 0; tmp < max_low_pfn; tmp++)
-   /*
-* Only count reserved RAM pages
-*/
-   if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp)))
-   reservedpages++;
+   addr = __va(0);
+   for (tmp = 0; tmp < max_low_pfn; tmp++, addr += PAGE_SIZE) {
+   if (page_is_ram(tmp)) {
+   /*
+* Only count reserved RAM pages
+*/
+   if (PageReserved(mem_map+tmp))
+   reservedpages++;
+   /*
+* Mark nosave pages
+*/
+   if (addr >= (void *)&__nosave_begin && addr < (void 
*)&__nosave_end)
+   SetPageNosave(mem_map+tmp);
+   } else
+   /*
+* Non-RAM pages are always nosave
+*/
+   SetPageNosave(mem_map+tmp);
+   }
 
set_highmem_pages_init(bad_ppro);
 
@@ -673,6 +691,7 @@ void free_initmem(void)
addr = (unsigned long)(&__init_begin);
for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
+   ClearPageNosave(virt_to_page(addr));
set_page_count(virt_to_page(addr), 1);
memset((void *)addr, 0xcc, PAGE_SIZE);
free_page(addr);
@@ -688,6 +707,7 @@ void free_initrd_mem(unsigned long start
printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - 
start) >> 10);
for (; start < end; start += PAGE_SIZE) {
ClearPageReserved(virt_to_page(start));
+   ClearPageNosave(virt_to_page(start));
set_page_count(virt_to_page(start), 1);
free_page(start);
totalram_pages++;
diff -ruNp 401-e820-table-support.patch-old/mm/bootmem.c 
401-e820-table-support.patch-new/mm/bootmem.c
--- 401-e820-table-support.patch-old/mm/bootmem.c   2005-02-03 
22:33:50.0 +1100
+++ 401-e820-table-support.patch-new/mm/bootmem.c   2005-07-04 
23:14:18.0 +1000
@@ -280,12 +280,14 @@ static unsigned long __init free_all_boo
 
count += BITS_PER_LONG;
__ClearPageReserved(page);
+   ClearPageNosave(page);
order = ffs(BITS_PER_LONG) - 1;
set_page_refs(page, order);
for (j = 1; j < BITS_PER_LONG; j++) {
if (j + 16 < BITS_PER_LONG)
prefetchw(page + j + 16);
__ClearPageReserved(page + j);
+   ClearPageNosave(page + j);
}
__free_pages(page, order);
i += BITS_PER_LONG;
@@ -296,6 +298,7 @@ static unsigned long __init free_all_boo
if (v & m) {
count++;
__ClearPageReserved(page);
+   ClearPageNosave(page);
set_page_refs(page, 0);
__free_page(page);
   

[PATCH] [17/48] Suspend2 2.1.9.8 for 2.6.12: 500-version-specific-i386.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 501-tlb-flushing-functions.patch-old/arch/i386/kernel/smp.c 
501-tlb-flushing-functions.patch-new/arch/i386/kernel/smp.c
--- 501-tlb-flushing-functions.patch-old/arch/i386/kernel/smp.c 2005-07-06 
11:24:23.0 +1000
+++ 501-tlb-flushing-functions.patch-new/arch/i386/kernel/smp.c 2005-07-04 
23:14:19.0 +1000
@@ -476,7 +476,7 @@ void flush_tlb_page(struct vm_area_struc
preempt_enable();
 }
 
-static void do_flush_tlb_all(void* info)
+void do_flush_tlb_all(void* info)
 {
unsigned long cpu = smp_processor_id();
 
diff -ruNp 501-tlb-flushing-functions.patch-old/include/asm-i386/tlbflush.h 
501-tlb-flushing-functions.patch-new/include/asm-i386/tlbflush.h
--- 501-tlb-flushing-functions.patch-old/include/asm-i386/tlbflush.h
2004-11-03 21:55:01.0 +1100
+++ 501-tlb-flushing-functions.patch-new/include/asm-i386/tlbflush.h
2005-07-04 23:14:19.0 +1000
@@ -82,6 +82,7 @@ extern unsigned long pgkern_mask;
 #define flush_tlb() __flush_tlb()
 #define flush_tlb_all() __flush_tlb_all()
 #define local_flush_tlb() __flush_tlb()
+#define local_flush_tlb_all() __flush_tlb_all();
 
 static inline void flush_tlb_mm(struct mm_struct *mm)
 {
@@ -114,6 +115,10 @@ extern void flush_tlb_all(void);
 extern void flush_tlb_current_task(void);
 extern void flush_tlb_mm(struct mm_struct *);
 extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
+extern void do_flush_tlb_all(void * info);
+
+#define local_flush_tlb_all() \
+   do_flush_tlb_all(NULL);
 
 #define flush_tlb()flush_tlb_current_task()
 

-
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/48] Suspend2 2.1.9.8 for 2.6.12: 613-pageflags.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 614-plugins.patch-old/kernel/power/suspend2_core/plugins.c 
614-plugins.patch-new/kernel/power/suspend2_core/plugins.c
--- 614-plugins.patch-old/kernel/power/suspend2_core/plugins.c  1970-01-01 
10:00:00.0 +1000
+++ 614-plugins.patch-new/kernel/power/suspend2_core/plugins.c  2005-07-04 
23:14:19.0 +1000
@@ -0,0 +1,341 @@
+/*
+ * kernel/power/plugins.c
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ */
+
+#include 
+#include 
+#include "suspend.h"
+#include "plugins.h"
+
+struct list_head suspend_filters, suspend_writers, suspend_plugins;
+struct suspend_plugin_ops * active_writer = NULL;
+static int num_filters = 0, num_ui = 0;
+int num_writers = 0, num_plugins = 0;
+
+/*
+ * header_storage_for_plugins
+ *
+ * Returns the amount of space needed to store configuration
+ * data needed by the plugins prior to copying back the original
+ * kernel. We can exclude data for pageset2 because it will be
+ * available anyway once the kernel is copied back.
+ */
+unsigned long header_storage_for_plugins(void)
+{
+   struct suspend_plugin_ops * this_plugin;
+   unsigned long bytes = 0;
+   
+   list_for_each_entry(this_plugin, &suspend_plugins, plugin_list) {
+   if (this_plugin->disabled)
+   continue;
+   if (this_plugin->storage_needed)
+   bytes += this_plugin->storage_needed();
+   }
+
+   return bytes;
+}
+
+/*
+ * expected_compression_ratio
+ *
+ * Returns the expected ratio between the amount of memory
+ * to be saved and the amount of space required on the
+ * storage device.
+ */
+int expected_compression_ratio(void)
+{
+   struct suspend_plugin_ops * this_filter;
+   unsigned long ratio = 100;
+   
+   list_for_each_entry(this_filter, &suspend_filters, 
ops.filter.filter_list) {
+   if (this_filter->disabled)
+   continue;
+   if (this_filter->ops.filter.expected_compression)
+   ratio = ratio * 
this_filter->ops.filter.expected_compression() / 100;
+   }
+
+   return (int) ratio;
+}
+
+/*
+ * memory_for_plugins
+ *
+ * Returns the amount of memory requested by plugins for
+ * doing their work during the cycle.
+ */
+
+unsigned long memory_for_plugins(void)
+{
+   unsigned long bytes = 0;
+   struct suspend_plugin_ops * this_plugin;
+
+   list_for_each_entry(this_plugin, &suspend_plugins, plugin_list) {
+   if (this_plugin->disabled)
+   continue;
+   if (this_plugin->memory_needed)
+   bytes += this_plugin->memory_needed();
+   }
+
+   return ((bytes + PAGE_SIZE - 1) >> PAGE_SHIFT);
+}
+
+/* find_plugin_given_name
+ * Functionality : Return a plugin (if found), given a pointer
+ * to its name
+ */
+
+struct suspend_plugin_ops * find_plugin_given_name(char * name)
+{
+   struct suspend_plugin_ops * this_plugin, * found_plugin = NULL;
+   
+   list_for_each_entry(this_plugin, &suspend_plugins, plugin_list) {
+   if (!strcmp(name, this_plugin->name)) {
+   found_plugin = this_plugin;
+   break;
+   }   
+   }
+
+   return found_plugin;
+}
+
+/*
+ * print_plugin_debug_info
+ * Functionality   : Get debugging info from plugins into a buffer.
+ */
+int print_plugin_debug_info(char * buffer, int buffer_size)
+{
+   struct suspend_plugin_ops *this_plugin;
+   int len = 0;
+
+   list_for_each_entry(this_plugin, &suspend_plugins, plugin_list) {
+   if (this_plugin->disabled)
+   continue;
+   if (this_plugin->print_debug_info) {
+   int result;
+   result = this_plugin->print_debug_info(buffer + len, 
+   buffer_size - len);
+   len += result;
+   }
+   }
+
+   return len;
+}
+
+/*
+ * suspend_register_plugin
+ *
+ * Register a plugin.
+ */
+int suspend_register_plugin(struct suspend_plugin_ops * plugin)
+{
+   if (find_plugin_given_name(plugin->name))
+   return -EBUSY;
+
+   switch (plugin->type) {
+   case FILTER_PLUGIN:
+   list_add_tail(&plugin->ops.filter.filter_list,
+   &suspend_filters);
+   num_filters++;
+   break;
+
+   case WRITER_PLUGIN:
+   list_add_tail(&plugin->ops.writer.writer_list,
+   &suspend_writers);
+   num_writers++;
+   break;
+
+   case MISC_PLUGIN:
+   break;
+
+   default:
+   printk("Hmmm. Plugin '%s' has an invalid type."
+   " It has been ignored.\n", plugin->

[PATCH] [35/48] Suspend2 2.1.9.8 for 2.6.12: 611-io.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 612-pagedir.patch-old/kernel/power/suspend2_core/pagedir.c 
612-pagedir.patch-new/kernel/power/suspend2_core/pagedir.c
--- 612-pagedir.patch-old/kernel/power/suspend2_core/pagedir.c  1970-01-01 
10:00:00.0 +1000
+++ 612-pagedir.patch-new/kernel/power/suspend2_core/pagedir.c  2005-07-05 
23:48:59.0 +1000
@@ -0,0 +1,336 @@
+/*
+ * kernel/power/pagedir.c
+ *
+ * Copyright (C) 1998-2001 Gabor Kuti <[EMAIL PROTECTED]>
+ * Copyright (C) 1998,2001,2002 Pavel Machek <[EMAIL PROTECTED]>
+ * Copyright (C) 2002-2003 Florent Chabaud <[EMAIL PROTECTED]>
+ * Copyright (C) 2002-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * Routines for handling pagesets.
+ * Note that pbes aren't actually stored as such. They're stored as
+ * bitmaps and extents.
+ */
+
+#include 
+#include 
+#include 
+
+#include "pageflags.h"
+#include "ui.h"
+#include "pagedir.h"
+
+int extra_pagedir_pages_allocated = 0;
+static LIST_HEAD(conflicting_pages);
+
+/* suspend2_free_pagedir_data
+ *
+ * Description:Free a previously pagedir metadata.
+ */
+void suspend2_free_pagedir_data(void)
+{
+   int pagenumber;
+
+   free_dyn_pageflags(&pageset1_map);
+   free_dyn_pageflags(&pageset2_map);
+   free_dyn_pageflags(&pageset1_copy_map);
+
+   /* Free allocated pages */
+   if (allocd_pages_map) {
+   BITMAP_FOR_EACH_SET(allocd_pages_map, pagenumber) {
+   struct page * page = pfn_to_page(pagenumber);
+   ClearPageNosave(page);
+   __free_pages(page, 0);
+   extra_pagedir_pages_allocated--;
+   }
+   free_dyn_pageflags(&allocd_pages_map);
+   }
+
+   pagedir1.pageset_size = pagedir2.pageset_size = 0;
+}
+
+/* suspend2_allocate_extra_pagedir_memory
+ *
+ * Description:Allocate memory for making the atomic copy of pagedir1 
in the
+ * case where it is bigger than pagedir2.
+ * Arguments:  struct pagedir *:   The pagedir for which we should 
+ * allocate memory.
+ * int:Size of pageset 1.
+ * int:Size of pageset 2.
+ * Result: int. Zero on success. One if unable to allocate enough memory.
+ */
+int suspend2_allocate_extra_pagedir_memory(struct pagedir * p, int 
pageset_size,
+   int alloc_from)
+{
+   int num_to_alloc = pageset_size - alloc_from - 
extra_pagedir_pages_allocated;
+   int j, order;
+
+   if (num_to_alloc < 1)
+   num_to_alloc = 0;
+
+   if (num_to_alloc) {
+   int num_added = 0;
+   
+   order = generic_fls(num_to_alloc);
+   if (order >= MAX_ORDER)
+   order = MAX_ORDER - 1;
+
+   while (num_added < num_to_alloc) {
+   struct page * newpage;
+   unsigned long virt;
+   
+   while ((1 << order) > (num_to_alloc - num_added))
+   order--;
+
+   virt = __get_free_pages(GFP_ATOMIC, order);
+   while ((!virt) && (order > 0)) {
+   order--;
+   virt = __get_free_pages(GFP_ATOMIC, order);
+   }
+
+   if (!virt) {
+   p->pageset_size += num_added;
+   return 1;
+   }
+
+   newpage = virt_to_page(virt);
+   for (j = 0; j < (1 << order); j++) {
+   SetPageNosave(newpage + j);
+   /* Pages will be freed one at a time. */
+   set_page_count(newpage + j, 1);
+   SetPageAllocd(newpage + j);
+   extra_pagedir_pages_allocated++;
+   }
+   num_added+= (1 << order);
+   }
+   }
+
+   //p->pageset_size = pageset_size;
+   return 0;
+}
+
+/*
+ * suspend2_mark_task_as_pageset1
+ * Functionality   : Marks all the pages belonging to a given process as
+ *   pageset 1 pages.
+ * Called From : pagedir.c - mark_pages_for_pageset2
+ *
+ * This is a builtin to avoid exporting follow_page.
+ */
+void suspend2_mark_task_as_pageset1(struct task_struct *t)
+{
+   struct vm_area_struct *vma;
+   struct mm_struct *mm;
+
+   mm = t->active_mm;
+
+   if (!mm || !mm->mmap) return;
+
+   down_read(&mm->mmap_sem);
+   for (vma = mm->mmap; vma; vma = vma->vm_next) {
+   unsigned long posn;
+
+   if (!vma->vm_start)
+   continue;
+
+   for (posn = vma->vm_start; posn < vma->vm_end; posn += 
PAGE_SIZE) {
+   struct page *page = follow_page(mm, posn, 

[PATCH] [38/48] Suspend2 2.1.9.8 for 2.6.12: 614-plugins.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 615-poweroff.patch-old/kernel/power/suspend2_core/power_off.c 
615-poweroff.patch-new/kernel/power/suspend2_core/power_off.c
--- 615-poweroff.patch-old/kernel/power/suspend2_core/power_off.c   
1970-01-01 10:00:00.0 +1000
+++ 615-poweroff.patch-new/kernel/power/suspend2_core/power_off.c   
2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,148 @@
+/*
+ * kernel/power/suspend2_core/power_off.c
+ *
+ * Copyright (C) 2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * Support for powering down.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "suspend2_common.h"
+#include "suspend.h"
+#include "ui.h"
+
+unsigned long suspend2_powerdown_method = 5; /* S5 = off */
+static int suspend_pm_state_used = 0;
+
+extern struct pm_ops * pm_ops;
+
+#ifdef CONFIG_ACPI
+extern u32 acpi_leave_sleep_state (u8 sleep_state);
+#endif
+
+/* suspend_power_off
+ *
+ * Power off the machine.
+ */
+static void suspend_power_off(void)
+{
+   machine_power_off();
+   suspend2_prepare_status(1, 0, "Probably not capable for powerdown.");
+   while (1)
+   cpu_relax();
+   /* NOTREACHED */
+}
+
+/* suspend_pm_state_prepare
+ *
+ * Prepare to enter the sleep state.
+ */
+static int suspend_pm_state_prepare(void)
+{
+   int ret = 0;
+   
+   if (suspend2_powerdown_method == 3 ||
+   suspend2_powerdown_method == 4)
+   if (pm_ops && pm_ops->prepare)
+   ret = pm_ops->prepare(suspend2_powerdown_method);
+
+   return ret;
+}
+
+/* suspend_pm_sleep_state_enter
+ * 
+ * Enter the sleep state requested.
+ */
+static int suspend_pm_state_enter(u32 state)
+{
+   int ret = 0;
+   unsigned long flags;
+   suspend_pm_state_used = state;
+
+   local_irq_save(flags);
+   device_power_down(PMSG_SUSPEND);
+   if (pm_ops && pm_ops->enter)
+   ret = pm_ops->enter(state);
+   else 
+   printk("Failed to enter state.\n");
+
+   device_power_up();
+   local_irq_restore(flags);
+
+   return ret;
+}
+
+/* suspend_pm_state_finish
+ *
+ * Finish the sleep state.
+ */
+int suspend_pm_state_finish(void)
+{
+   int ret = 0;
+
+   if (suspend2_powerdown_method == 3 ||
+   suspend2_powerdown_method == 4)
+   if (pm_ops && pm_ops->finish)
+   ret = pm_ops->finish(suspend2_powerdown_method);
+
+   device_resume();
+
+   return ret;
+}
+
+/*
+ * suspend_power_down
+ * Functionality   : Powers down or reboots the computer once the image
+ *   has been written to disk.
+ * Key Assumptions : Able to reboot/power down via code called or that
+ *   the warning emitted if the calls fail will be visible
+ *   to the user (ie printk resumes devices).
+ * Called From : do_suspend2_suspend_2
+ */
+
+void suspend_power_down(void)
+{
+   if (TEST_ACTION_STATE(SUSPEND_REBOOT)) {
+   suspend2_prepare_status(1, 0, "Ready to reboot.");
+   device_shutdown();
+   machine_restart(NULL);
+   }
+
+   if (suspend2_powerdown_method == 3 ||
+   suspend2_powerdown_method == 4) {
+   suspend2_prepare_status(1, 0, "Seeking to enter ACPI state");
+   if (suspend_pm_state_prepare()) {
+   suspend2_prepare_status(1, 0, "Preparing to enter ACPI 
state failed. Using normal powerdown.");
+   goto abort_ACPI_sleep;
+   }
+   if (device_suspend(PMSG_SUSPEND)) {
+   suspend2_prepare_status(1, 0, "Suspending devices 
failed. Using normal powerdown.");
+   suspend_pm_state_finish();
+   goto abort_ACPI_sleep;
+   }
+   if (suspend_pm_state_enter(suspend2_powerdown_method)) {
+   suspend2_prepare_status(1, 0, "Entering ACPI state 
failed. Using normal powerdown.");
+   suspend_pm_state_finish();
+   goto abort_ACPI_sleep;
+   }
+   suspend_pm_state_finish();
+   return;
+   } else
+   suspend2_prepare_status(1, 0, "Powering down.");
+   
+abort_ACPI_sleep:
+   /* 
+* FIXME: At resume, we'll still think we used S4 if we tried it.
+* Does it matter?
+*/
+   suspend_pm_state_used = 0;
+   device_shutdown();
+   suspend_power_off();
+}
+
diff -ruNp 615-poweroff.patch-old/kernel/power/suspend2_core/power_off.h 
615-poweroff.patch-new/kernel/power/suspend2_core/power_off.h
--- 615-poweroff.patch-old/kernel/power/suspend2_core/power_off.h   
1970-01-01 10:00:00.0 +1000
+++ 615-poweroff.patch-new/kernel/power/suspend2_core/power_off.h   
2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,13 @@
+/*
+ * kernel/power/suspend2_core/power_off.h
+ *
+ * Copyright (C) 2005 Nigel Cunningham <[EM

[PATCH] [36/48] Suspend2 2.1.9.8 for 2.6.12: 612-pagedir.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 613-pageflags.patch-old/kernel/power/suspend2_core/pageflags.c 
613-pageflags.patch-new/kernel/power/suspend2_core/pageflags.c
--- 613-pageflags.patch-old/kernel/power/suspend2_core/pageflags.c  
1970-01-01 10:00:00.0 +1000
+++ 613-pageflags.patch-new/kernel/power/suspend2_core/pageflags.c  
2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,126 @@
+/*
+ * kernel/power/suspend2_core/pageflags.c
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ * 
+ * This file is released under the GPLv2.
+ *
+ * Routines for dynamically allocating and releasing bitmaps
+ * used as pseudo-pageflags.
+ *
+ * Arrays are not contiguous. The first sizeof(void *) bytes are
+ * the pointer to the next page in the bitmap. This allows us to
+ * 1) work under low memory conditions where order 0 might be all
+ *that's available
+ * 2) save the pages at suspend time, reload and relocate them as
+ *necessary at resume time without breaking anything (cf
+ *extent pages).
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "pageflags.h"
+#include "plugins.h"
+#include "pagedir.h"
+
+/* Maps used in copying the image back are in builtin.c */
+dyn_pageflags_t pageset1_map;
+dyn_pageflags_t pageset1_copy_map;
+dyn_pageflags_t pageset2_map;
+dyn_pageflags_t in_use_map;
+dyn_pageflags_t allocd_pages_map;
+#ifdef CONFIG_DEBUG_PAGEALLOC
+dyn_pageflags_t unmap_map;
+#endif
+
+/* suspend_allocate_dyn_pageflags
+ *
+ * Description:Allocate a bitmap for local page flags.
+ * Arguments:  dyn_pageflags_t *:  Pointer to the bitmap.
+ *
+ * A version of allocate_dyn_pageflags that saves us then having
+ * to relocate the flags when resuming.
+ */
+int suspend_allocate_dyn_pageflags(dyn_pageflags_t *pagemap)
+{
+   int i;
+
+   BUG_ON(*pagemap);
+
+   if (test_suspend_state(SUSPEND_NOW_RESUMING)) {
+   /* 
+* We use kfree unconditionally below. That's not a problem
+* because we only use this path when reloading pageset1.
+*/
+   *pagemap = (dyn_pageflags_t) suspend2_get_nonconflicting_page();
+   if (! *pagemap) {
+   printk("Failed to allocate a non-conflicting page for 
pageflags.\n");
+   return 1;
+   }
+   } else 
+   *pagemap = kmalloc(sizeof(void *) * PAGES_PER_BITMAP, 
GFP_ATOMIC);
+
+   for (i = 0; i < PAGES_PER_BITMAP; i++) {
+   (*pagemap)[i] = (unsigned long *) get_zeroed_page(GFP_ATOMIC);
+   if (!(*pagemap)[i]) {
+   printk("Error. Unable to allocate memory for "
+   "local page flags.");
+   free_dyn_pageflags(pagemap);
+   return 1;
+   }
+   }
+   return 0;
+}
+
+/* savepageflags
+ *
+ * Description: Save a set of pageflags.
+ * Arguments:   dyn_pageflags_t *: Pointer to the bitmap being saved.
+ */
+
+void save_dyn_pageflags(dyn_pageflags_t pagemap)
+{
+   int i;
+
+   if (!*pagemap)
+   return;
+
+   for (i = 0; i < PAGES_PER_BITMAP; i++)
+   active_writer->ops.writer.write_header_chunk((char *) 
pagemap[i], PAGE_SIZE);
+}
+
+/* loadpageflags
+ *
+ * Description: Load a set of pageflags.
+ * Arguments:   dyn_pageflags_t *: Pointer to the bitmap being loaded.
+ *  (It must be allocated before calling this routine).
+ */
+
+void load_dyn_pageflags(dyn_pageflags_t pagemap)
+{
+   int i;
+
+   if (!pagemap)
+   return;
+
+   for (i = 0; i < PAGES_PER_BITMAP; i++)
+   active_writer->ops.writer.read_header_chunk((char *) 
pagemap[i], PAGE_SIZE);
+}
+
+void relocate_dyn_pageflags(dyn_pageflags_t *pagemap)
+{
+   int i;
+   LIST_HEAD(rejected_pages);
+
+   if (!*pagemap)
+   return;
+
+   suspend2_relocate_page_if_required((void *) pagemap);
+
+   for (i = 0; i < PAGES_PER_BITMAP; i++)
+   suspend2_relocate_page_if_required((void *) &((*pagemap)[i]));
+}
diff -ruNp 613-pageflags.patch-old/kernel/power/suspend2_core/pageflags.h 
613-pageflags.patch-new/kernel/power/suspend2_core/pageflags.h
--- 613-pageflags.patch-old/kernel/power/suspend2_core/pageflags.h  
1970-01-01 10:00:00.0 +1000
+++ 613-pageflags.patch-new/kernel/power/suspend2_core/pageflags.h  
2005-07-05 23:48:59.0 +1000
@@ -0,0 +1,84 @@
+/*
+ * kernel/power/pageflags.h
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * Suspend2 needs a few pageflags while working that aren't otherwise
+ * used. To save the struct page pageflags, we dynamically allocate
+ * a bitmap and use that. These are the only non order-0 allocations
+ * we do.
+ *
+ * NOTE!!!
+ * We assume that PAGE_SIZE - sizeof(void *) is a multiple of
+ * sizeof(unsigned long). Is this ever false?
+ */

[PATCH] [29/48] Suspend2 2.1.9.8 for 2.6.12: 606-all-settings.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 607-atomic-copy.patch-old/kernel/power/suspend2_core/atomic_copy.c 
607-atomic-copy.patch-new/kernel/power/suspend2_core/atomic_copy.c
--- 607-atomic-copy.patch-old/kernel/power/suspend2_core/atomic_copy.c  
1970-01-01 10:00:00.0 +1000
+++ 607-atomic-copy.patch-new/kernel/power/suspend2_core/atomic_copy.c  
2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,465 @@
+/*
+ * SMP support:
+ * CPU enters this routine during suspend. All other CPUs enter
+ * __smp_suspend_lowlevel. The one through
+ * which the suspend is initiated (which, for simplicity, is always CPU 0)
+ * sends the others here using an IPI during do_suspend2_suspend_1. They
+ * remain here until after the atomic copy of the kernel is made, to ensure
+ * that they don't mess with memory in the meantime (even just idling will
+ * do that). Once the atomic copy is made, they are free to carry on idling.
+ * Note that we must let them go, because if we're using compression, the
+ * vfree calls in the compressors will result in IPIs being called and hanging
+ * because the CPUs are still here.
+ *
+ * At resume time, we do a similar thing. CPU 0 sends the others in here using
+ * an IPI. It then copies the original kernel back, restores its own processor
+ * context and flushes local tlbs before freeing the others to do the same.
+ * They can then go back to idling while CPU 0 reloads pageset 2, cleans up
+ * and unfreezes the processes.
+ *
+ * (Remember that freezing and thawing processes also uses IPIs, as may
+ * decompressing the data. Again, therefore, we cannot leave the other 
processors
+ * in here).
+ * 
+ * At the moment, we do nothing about APICs, even though the code is there.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "suspend2_common.h"
+#include "io.h"
+#include "power_off.h"
+#include "version.h"
+#include "driver_model.h"
+#include "ui.h"
+#include "plugins.h"
+#include "atomic_copy.h"
+#include "suspend.h"
+#include "smp.h"
+
+volatile static int state1 __nosavedata = 0;
+volatile static int state2 __nosavedata = 0;
+volatile static int state3 __nosavedata = 0;
+volatile static int io_speed_save[2][2] __nosavedata;
+
+static dyn_pageflags_t __nosavedata origmap;
+static dyn_pageflags_t __nosavedata copymap;
+static int __nosavedata origoffset;
+static int __nosavedata copyoffset;
+
+__nosavedata char resume_commandline[COMMAND_LINE_SIZE];
+
+static atomic_t atomic_copy_hold;
+
+/**
+ * suspend2_resume_1
+ * Functionality   : Preparatory steps for copying the original kernel back.
+ * Called From : do_suspend2_lowlevel
+ **/
+
+static void suspend2_resume_1(void)
+{
+   suspend_message(SUSPEND_ANY_SECTION, SUSPEND_LOW, 1,
+   name_suspend "About to copy pageset1 back...\n");
+
+   suspend_drivers_suspend(SUSPEND_DRIVERS_IRQS_ENABLED);
+   local_irq_disable(); /* irqs might have been re-enabled on us */
+
+   suspend_drivers_suspend(SUSPEND_DRIVERS_IRQS_DISABLED);
+   local_irq_enable();
+
+   suspend2_map_atomic_copy_pages();
+
+   /* Get other cpus ready to restore their original contexts */
+   smp_suspend();
+
+   local_irq_disable();
+
+   preempt_disable();
+
+   barrier();
+   mb();
+}
+
+/*
+ * suspend2_resume_2
+ * Functionality   : Steps taken after copying back the original kernel at
+ *   resume.
+ * Key Assumptions : Will be able to read back secondary pagedir (if 
+ *   applicable).
+ * Called From : do_suspend2_lowlevel
+ */
+
+static void suspend2_resume_2(void)
+{
+   set_suspend_state(SUSPEND_NOW_RESUMING);
+   set_suspend_state(SUSPEND_PAGESET2_NOT_LOADED);
+
+   suspend2_unmap_atomic_copy_pages();
+
+   preempt_enable();
+
+   local_irq_disable();
+   suspend_drivers_resume(SUSPEND_DRIVERS_IRQS_DISABLED);
+   local_irq_enable();
+
+#if defined(CONFIG_PREEMPT) && defined(CONFIG_USE_3DNOW)
+   preempt_enable();
+#endif
+
+   suspend_drivers_resume(SUSPEND_DRIVERS_IRQS_ENABLED);
+
+   userui_redraw();
+
+   check_shift_keys(1, "About to reload secondary pagedir.");
+
+   read_pageset2(0);
+   clear_suspend_state(SUSPEND_PAGESET2_NOT_LOADED);
+   
+   suspend2_prepare_status(0, 0, "Cleaning up...");
+}
+
+
+/*
+ * suspend2_suspend_1
+ * Functionality   : Steps taken prior to saving CPU state and the image
+ *   itself.
+ * Called From : do_suspend2_lowlevel
+ */
+
+static void suspend2_suspend_1(void)
+{
+   /* Save other cpu contexts */
+   smp_suspend();
+
+   suspend_drivers_suspend(SUSPEND_DRIVERS_IRQS_ENABLED);
+
+   mb();
+   barrier();
+
+   preempt_disable();
+   local_irq_disable();
+
+   suspend_drivers_suspend(SUSPEND_DRIVERS_IRQS_DISABLED);
+}
+
+/*
+ * suspend2_suspend_2
+ * Functionality   : Steps taken after saving CPU state to save the
+ *   image and powerdown/reboot or recover on failure.
+ * Key Assumptions : 

[PATCH] [25/48] Suspend2 2.1.9.8 for 2.6.12: 602-smp.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 
603-suspend2_common-headers.patch-old/kernel/power/suspend2_core/suspend2_common.h
 
603-suspend2_common-headers.patch-new/kernel/power/suspend2_core/suspend2_common.h
--- 
603-suspend2_common-headers.patch-old/kernel/power/suspend2_core/suspend2_common.h
  1970-01-01 10:00:00.0 +1000
+++ 
603-suspend2_common-headers.patch-new/kernel/power/suspend2_core/suspend2_common.h
  2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,49 @@
+#ifdef CONFIG_PM_DEBUG
+#define SET_DEBUG_STATE(bit) (test_and_set_bit(bit, &suspend_debug_state))
+#define CLEAR_DEBUG_STATE(bit) (test_and_clear_bit(bit, &suspend_debug_state))
+#else
+#define SET_DEBUG_STATE(bit) (0)
+#define CLEAR_DEBUG_STATE(bit) (0)
+#endif
+
+#define SET_RESULT_STATE(bit) (test_and_set_bit(bit, &suspend_result))
+#define CLEAR_RESULT_STATE(bit) (test_and_clear_bit(bit, &suspend_result))
+
+#define SUSPEND_ABORT_REQUESTED1
+#define SUSPEND_NOSTORAGE_AVAILABLE2
+#define SUSPEND_INSUFFICIENT_STORAGE   3
+#define SUSPEND_FREEZING_FAILED4
+#define SUSPEND_UNEXPECTED_ALLOC   5
+#define SUSPEND_KEPT_IMAGE 6
+#define SUSPEND_WOULD_EAT_MEMORY   7
+#define SUSPEND_UNABLE_TO_FREE_ENOUGH_MEMORY 8
+#define SUSPEND_ENCRYPTION_SETUP_FAILED9
+
+/* second status register */
+#define SUSPEND_REBOOT 1
+#define SUSPEND_PAUSE  2
+#define SUSPEND_SLOW   3
+#define SUSPEND_NOPAGESET2 4
+#define SUSPEND_LOGALL 5
+#define SUSPEND_CAN_CANCEL 6
+#define SUSPEND_KEEP_IMAGE 7
+#define SUSPEND_FREEZER_TEST   8
+#define SUSPEND_FREEZER_TEST_SHOWALL   9
+#define SUSPEND_SINGLESTEP 10
+#define SUSPEND_PAUSE_NEAR_PAGESET_END 11
+#define SUSPEND_USE_ACPI_S412
+#define SUSPEND_KEEP_METADATA  13
+#define SUSPEND_TEST_FILTER_SPEED  14
+#define SUSPEND_FREEZE_TIMERS  15
+#define SUSPEND_DISABLE_SYSDEV_SUPPORT 16
+#define SUSPEND_VGA_POST   17
+
+#define TEST_ACTION_STATE(bit) (test_bit(bit, &suspend_action))
+#define SET_ACTION_STATE(bit) (test_and_set_bit(bit, &suspend_action))
+#define CLEAR_ACTION_STATE(bit) (test_and_clear_bit(bit, &suspend_action))
+
+extern int suspend_act_used;
+extern int suspend_lvl_used;
+extern int suspend_dbg_used;
+extern int suspend_default_console_level;
+extern unsigned int nr_suspends;
diff -ruNp 
603-suspend2_common-headers.patch-old/kernel/power/suspend2_core/suspend.h 
603-suspend2_common-headers.patch-new/kernel/power/suspend2_core/suspend.h
--- 603-suspend2_common-headers.patch-old/kernel/power/suspend2_core/suspend.h  
1970-01-01 10:00:00.0 +1000
+++ 603-suspend2_common-headers.patch-new/kernel/power/suspend2_core/suspend.h  
2005-07-05 23:48:59.0 +1000
@@ -0,0 +1,24 @@
+/*
+ * kernel/power/suspend2.h
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * It contains declarations used throughout swsusp and suspend2.
+ *
+ */
+#ifndef KERNEL_POWER_SUSPEND_CORE_H
+#define KERNEL_POWER_SUSPEND_CORE_H
+
+#include 
+#include 
+
+extern unsigned long suspend2_orig_mem_free;
+
+#define KB(x) ((x) << (PAGE_SHIFT - 10))
+#define MB(x) ((x) >> (20 - PAGE_SHIFT))
+
+extern int suspend_start_anything(int starting_cycle);
+extern void suspend_finish_anything(int finishing_cycle);
+#endif
diff -ruNp 
603-suspend2_common-headers.patch-old/kernel/power/suspend2_core/version.h 
603-suspend2_common-headers.patch-new/kernel/power/suspend2_core/version.h
--- 603-suspend2_common-headers.patch-old/kernel/power/suspend2_core/version.h  
1970-01-01 10:00:00.0 +1000
+++ 603-suspend2_common-headers.patch-new/kernel/power/suspend2_core/version.h  
2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,5 @@
+#define SUSPEND_CORE_VERSION "2.1.9.8"
+#ifndef KERNEL_POWER_SWSUSP_C
+#define name_suspend "Software Suspend " SUSPEND_CORE_VERSION ": "
+#endif
+

-
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/48] Suspend2 2.1.9.8 for 2.6.12: 607-atomic-copy.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 608-compression.patch-old/kernel/power/suspend2_core/compression.c 
608-compression.patch-new/kernel/power/suspend2_core/compression.c
--- 608-compression.patch-old/kernel/power/suspend2_core/compression.c  
1970-01-01 10:00:00.0 +1000
+++ 608-compression.patch-new/kernel/power/suspend2_core/compression.c  
2005-07-05 23:52:59.0 +1000
@@ -0,0 +1,636 @@
+/*
+ * kernel/power/suspend2_core/compression.c
+ *
+ * Copyright (C) 2003-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * This file contains data compression routines for suspend,
+ * using LZH compression.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "suspend.h"
+#include "plugins.h"
+#include "proc.h"
+#include "suspend2_common.h"
+#include "utility.h"
+#include "io.h"
+
+#define S2C_WRITE 0
+#define S2C_READ 1
+
+static int s2_expected_compression = 0;
+
+static struct suspend_plugin_ops s2_compression_ops;
+static struct suspend_plugin_ops * next_driver;
+
+static char s2_compressor_name[32];
+static struct crypto_tfm * s2_compressor_transform;
+
+static u8 *local_buffer = NULL;
+static u8 *page_buffer = NULL;
+static unsigned int bufofs;
+
+static int position = 0;
+
+/*  Local buffer management  */
+
+/* allocate_local_buffer
+ *
+ * Description:Allocates a page of memory for buffering output.
+ * Returns:Int: Zero if successful, -ENONEM otherwise.
+ */
+
+static int allocate_local_buffer(void)
+{
+   if (!local_buffer) {
+   local_buffer = (char *) get_zeroed_page(GFP_ATOMIC);
+   
+   if (!local_buffer) {
+   printk(KERN_ERR
+   "Failed to allocate the local buffer for "
+   "suspend2 compression driver.\n");
+   return -ENOMEM;
+   }
+   }
+
+   if (!page_buffer) {
+   page_buffer = (char *) get_zeroed_page(GFP_ATOMIC);
+   
+   if (!page_buffer) {
+   printk(KERN_ERR
+   "Failed to allocate the page buffer for "
+   "suspend2 compression driver.\n");
+   return -ENOMEM;
+   }
+   }
+
+   return 0;
+}
+
+/* free_local_buffer
+ *
+ * Description:Frees memory allocated for buffering output.
+ */
+
+static inline void free_local_buffer(void)
+{
+   if (local_buffer)
+   free_pages((unsigned long) local_buffer, 0);
+
+   local_buffer = NULL;
+
+   if (page_buffer)
+   free_pages((unsigned long) page_buffer, 0);
+
+   page_buffer = NULL;
+}
+
+/* suspend2_crypto_cleanup
+ *
+ * Description:Frees memory allocated for our labours.
+ */
+
+static void suspend2_crypto_cleanup(void)
+{
+   if (s2_compressor_transform) {
+   crypto_free_tfm(s2_compressor_transform);
+   s2_compressor_transform = NULL;
+   }
+}
+
+/* suspend2_crypto_prepare
+ *
+ * Description:Prepare to do some work by allocating buffers and 
transforms.
+ * Returns:Int: Zero if successful, -ENONEM otherwise.
+ */
+
+static int s2_compress_crypto_prepare(int mode)
+{
+   if (!*s2_compressor_name) {
+   printk("Suspend2: Compression enabled but no compressor name 
set.\n");
+   return 1;
+   }
+
+   if (!(s2_compressor_transform = crypto_alloc_tfm(s2_compressor_name, 
0))) {
+   printk("Suspend2: Failed to initialise the compression 
transform.\n");
+   return 1;
+   }
+
+   return 0;
+}
+
+/*  Exported functions  */
+
+/* write_init()
+ *
+ * Description:Allocate buffers and prepare to compress data.
+ * Arguments:  Stream_number:  Ignored.
+ * Returns:Zero on success, -ENOMEM if unable to vmalloc.
+ */
+
+static int s2_compress_write_init(int stream_number)
+{
+   int result;
+   
+   next_driver = get_next_filter(&s2_compression_ops);
+
+   if (!next_driver) {
+   printk("Compression Driver: Argh! No one wants my output!");
+   return -ECHILD;
+   }
+
+   if ((result = s2_compress_crypto_prepare(S2C_WRITE))) {
+   return result;
+   }
+   
+   if ((result = allocate_local_buffer()))
+   return result;
+
+   /* Only reset the stats if starting to write an image */
+   if (stream_number == 2)
+   bytes_in = bytes_out = 0;
+   
+   bufofs = 0;
+
+   position = 0;
+
+   return 0;
+}
+
+/* s2_compress_write()
+ *
+ * Description:Helper function for write_chunk. Write the compressed 
data.
+ * Arguments:  u8*:Output buffer to be written.
+ * unsigned int:   Length of buffer.
+ * Return: int:Result to be passed back to caller.
+ */
+
+static int s2_compress_write (u8 *buffer, unsigned int len)
+{
+   int ret;
+
+   bytes_out +

[PATCH] [21/48] Suspend2 2.1.9.8 for 2.6.12: 550-documentation.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 560-Kconfig-and-Makefile-for-suspend2.patch-old/kernel/power/Kconfig 
560-Kconfig-and-Makefile-for-suspend2.patch-new/kernel/power/Kconfig
--- 560-Kconfig-and-Makefile-for-suspend2.patch-old/kernel/power/Kconfig
2005-02-03 22:33:50.0 +1100
+++ 560-Kconfig-and-Makefile-for-suspend2.patch-new/kernel/power/Kconfig
2005-07-04 23:14:19.0 +1000
@@ -1,5 +1,6 @@
 config PM
bool "Power Management support"
+   select SYSFS
---help---
  "Power Management" means that parts of your computer are shut
  off or put into a power conserving "sleep" mode if they are not
@@ -30,6 +31,8 @@ config SOFTWARE_SUSPEND
bool "Software Suspend (EXPERIMENTAL)"
depends on EXPERIMENTAL && PM && SWAP
---help---
+ Pavel's original version.
+
  Enable the possibility of suspending the machine.
  It doesn't need APM.
  You may suspend your machine by 'swsusp' or 'shutdown -z ' 
@@ -72,3 +75,77 @@ config PM_STD_PARTITION
  suspended image to. It will simply pick the first available swap 
  device.
 
+menuconfig SUSPEND2
+   bool "Software Suspend 2"
+   depends on PM
+   ---help---
+ Software Suspend 2 is the 'new and improved' suspend support.
+ 
+ See the Software Suspend home page (suspend2.net)
+ for FAQs, HOWTOs and other documentation.
+
+   comment 'Image Storage (you need at least one writer)'
+   depends on SUSPEND2
+   
+   config SUSPEND2_FILEWRITER
+   bool '  File Writer'
+   depends on SUSPEND2
+   ---help---
+ This option enables support for storing an image in a
+ simple file. This should be possible, but we're still
+ testing it.
+
+   config SUSPEND2_SWAPWRITER
+   bool '  Swap Writer'
+   depends on SWAP && SUSPEND2
+   ---help---
+ This option enables support for storing an image in your
+ swap space.
+
+   comment 'General Options'
+   depends on SUSPEND2
+
+   config SUSPEND2_DEFAULT_RESUME2
+   string '  Default resume device name'
+   depends on SUSPEND2
+   ---help---
+ You normally need to add a resume2= parameter to your 
lilo.conf or
+ equivalent. With this option properly set, the kernel has a 
value
+ to default. No damage will be done if the value is invalid.
+
+   config SUSPEND2_KEEP_IMAGE
+   bool '  Allow Keep Image Mode'
+   depends on SUSPEND2
+   ---help---
+ This option allows you to keep and image and reuse it. It is 
intended
+ __ONLY__ for use with systems where all filesystems are 
mounted read-
+ only (kiosks, for example). To use it, compile this option in 
and boot
+ normally. Set the KEEP_IMAGE flag in /proc/software_suspend 
and suspend.
+ When you resume, the image will not be removed. You will be 
unable to turn
+ off swap partitions (assuming you are using the swap writer), 
but future
+ suspends simply do a power-down. The image can be updated 
using the
+ kernel command line parameter suspend_act= to turn off the 
keep image
+ bit. Keep image mode is a little less user friendly on 
purpose - it
+ should not be used without thought!
+
+   config SUSPEND2_CHECK_RESUME_SAFE
+   bool '  Warn if possibility of filesystem corruption'
+   depends on SUSPEND2
+   default y
+   ---help---
+ This option enables code that looks at what filesystems you 
have
+ mounted prior to resuming. If you have any filesystems of type
+ ext2, ext3, reiser or such like mounted rw, it will warn you
+ before resuming and default to removing the image instead of
+ resuming.
+ 
+ If you're just beginning to set up suspend, it is a good idea 
to
+ leave this option on. You can always turn this option off 
later -
+ if you only change this option, recompiling the kernel/modules
+ won't take long at all.
+
+ Note that if you have this on and use an initrd/initramfs, you
+ may well need to add
+   mount / -o remount,ro
+ prior to the echo > /proc/software_suspend/resume call in your
+ initrd/initramfs. You might want to remount it rw again 
afterwards.
diff -ruNp 
560-Kconfig-and-Makefile-for-suspend2.patch-old/kernel/power/Makefile 
560-Kconfig-and-Makefile-for-suspend2.patch-new/kernel/power/Makefile
--- 560-Kconfig-and-Makefile-for-suspend2.patch-old/kernel/power/M

[PATCH] [27/48] Suspend2 2.1.9.8 for 2.6.12: 604-utility.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 605-kernel_power_suspend-header.patch-old/kernel/power/suspend.h 
605-kernel_power_suspend-header.patch-new/kernel/power/suspend.h
--- 605-kernel_power_suspend-header.patch-old/kernel/power/suspend.h
1970-01-01 10:00:00.0 +1000
+++ 605-kernel_power_suspend-header.patch-new/kernel/power/suspend.h
2005-07-05 23:48:59.0 +1000
@@ -0,0 +1,28 @@
+/*
+ * kernel/power/suspend.h
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * It contains declarations used throughout swsusp.
+ *
+ */
+
+#ifndef KERNEL_POWER_SUSPEND_H
+#define KERNEL_POWER_SUSPEND_H
+
+#define SUSPEND_PD_PAGES(x) (((x)*sizeof(struct pbe))/PAGE_SIZE+1)
+   
+/* mm/page_alloc.c */
+extern void drain_local_pages(void);
+
+void save_processor_state(void);
+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 suspend_pagedir_t *pagedir_nosave __nosavedata;
+
+#endif

-
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] [22/48] Suspend2 2.1.9.8 for 2.6.12: 560-Kconfig-and-Makefile-for-suspend2.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 600-suspend-header.patch-old/include/linux/suspend2.h 
600-suspend-header.patch-new/include/linux/suspend2.h
--- 600-suspend-header.patch-old/include/linux/suspend2.h   1970-01-01 
10:00:00.0 +1000
+++ 600-suspend-header.patch-new/include/linux/suspend2.h   2005-07-04 
23:14:19.0 +1000
@@ -0,0 +1,213 @@
+#ifndef _LINUX_SUSPEND2_H
+#define _LINUX_SUSPEND2_H
+
+#include 
+#include 
+
+/* arch/i386/mm/init.c */
+extern char __nosave_begin, __nosave_end;
+
+extern char __nosavedata swsusp_pg_dir[PAGE_SIZE]
+  __attribute__ ((aligned (PAGE_SIZE)));
+
+/* kernel/power/process.c */
+
+/* fs/buffer.c */
+extern unsigned int suspend_task;
+
+#define SUSPEND_KEY_KEYBOARD 1
+#define SUSPEND_KEY_SERIAL 2
+
+/* kernel/power/main.c */
+extern unsigned long suspend_result;
+
+/* kernel/power/process.c */
+extern unsigned long suspend_debug_state;
+
+/* arch/i386/power/suspend2.c */
+extern unsigned long suspend_action;
+extern int suspend_io_time[2][2];
+
+/* Pre and post lowlevel routines */
+//extern void suspend2_suspend_1 (void);
+//extern void suspend2_suspend_2 (void);
+//extern void suspend2_resume_1 (void);
+//extern void suspend2_resume_2 (void);
+
+extern dyn_pageflags_t pageset1_map;
+extern dyn_pageflags_t pageset1_copy_map;
+
+#ifdef CONFIG_PM_DEBUG
+#define TEST_DEBUG_STATE(bit) (test_bit(bit, &suspend_debug_state))
+#else
+#define TEST_DEBUG_STATE(bit) (0)
+#endif
+
+#define TEST_RESULT_STATE(bit) (test_bit(bit, &suspend_result))
+
+/* 
+ * First status register - this is suspend's return code.
+ *
+ * All the rest are in kernel/power/suspend2_common.h
+ */
+#define SUSPEND_ABORTED0
+
+/* Second status register - ditto */
+#define SUSPEND_RETRY_RESUME   0
+
+/* Debug sections  - if debugging compiled in */
+#define SUSPEND_ANY_SECTION0
+#define SUSPEND_FREEZER1
+#define SUSPEND_EAT_MEMORY 2
+#define SUSPEND_PAGESETS   3
+#define SUSPEND_IO 4
+#define SUSPEND_BMAP   5
+#define SUSPEND_HEADER 6
+#define SUSPEND_WRITER 7
+#define SUSPEND_MEMORY 8
+#define SUSPEND_EXTENTS9
+#define SUSPEND_SPINLOCKS  10
+#define SUSPEND_MEM_POOL   11
+#define SUSPEND_RANGE_PARANOIA 12
+#define SUSPEND_NOSAVE 13
+#define SUSPEND_INTEGRITY  14
+
+/* debugging levels. */
+#define SUSPEND_STATUS 0
+#define SUSPEND_ERROR  2
+#define SUSPEND_LOW3
+#define SUSPEND_MEDIUM 4
+#define SUSPEND_HIGH   5
+#define SUSPEND_VERBOSE6
+
+extern void __suspend_message(unsigned long section, unsigned long level, int 
log_normally,
+   const char *fmt, ...);
+
+#ifdef CONFIG_PM_DEBUG
+#define suspend_message(sn, lev, log, fmt, a...) \
+do { \
+   if (TEST_DEBUG_STATE(sn)) \
+   __suspend_message(sn, lev, log, fmt, ##a); \
+} while(0)
+#else /* CONFIG_PM_DEBUG */
+#define suspend_message(sn, lev, log, fmt, a...) \
+do { \
+   if (lev == 0) \
+   __suspend_message(sn, lev, log, fmt, ##a); \
+} while(0)
+#endif /* CONFIG_PM_DEBUG */
+  
+/* Suspend 2 */
+
+#define SUSPEND_DISABLED   0
+#define SUSPEND_RUNNING1
+#define SUSPEND_RESUME_DEVICE_OK   2
+#define SUSPEND_NORESUME_SPECIFIED 3
+#define SUSPEND_COMMANDLINE_ERROR  4
+#define SUSPEND_IGNORE_IMAGE   5
+#define SUSPEND_SANITY_CHECK_PROMPT6
+#define SUSPEND_FREEZER_ON 7
+#define SUSPEND_DISABLE_SYNCING8
+#define SUSPEND_BLOCK_PAGE_ALLOCATIONS 9
+#define SUSPEND_USE_MEMORY_POOL10
+#define SUSPEND_STAGE2_CONTINUE11
+#define SUSPEND_FREEZE_SMP 12
+#define SUSPEND_PAGESET2_NOT_LOADED13
+#define SUSPEND_CONTINUE_REQ   14
+#define SUSPEND_RESUMED_BEFORE 15
+#define SUSPEND_RUNNING_INITRD 16
+#define SUSPEND_RESUME_NOT_DONE17
+#define SUSPEND_BOOT_TIME  18
+#define SUSPEND_NOW_RESUMING   19
+#define SUSPEND_SLAB_ALLOC_FALLBACK20
+#define SUSPEND_IGNORE_LOGLEVEL21
+#define SUSPEND_TIMER_FREEZER_ON   22
+#define SUSPEND_ACT_USED   23
+#define SUSPEND_DBG_USED   24
+#define SUSPEND_LVL_USED   25
+#define SUSPEND_TRYING_TO_RESUME   27
+
+#define test_and_set_suspend_state(bit) \
+   (test_and_set_bit(bit, &software_suspend_state))
+
+#define get_suspend_state()(software_suspend_state)
+#define restore_suspend_state(saved_state) \
+   do { software_suspend_state = saved_state; } while(0)
+   
+/* Kernel threads are type 3 */
+#define FREEZER_ALL_THREADS 0
+#define FREEZER_KERNEL_THREADS 3
+
+/* - */
+#ifdef CONFIG_SUSPEND2
+
+/* Used in init dir files */
+extern unsigned long software_suspend_state;
+
+extern void suspend2_try_resume(void);
+extern int suspend_early_boot_mess

[PATCH] [20/48] Suspend2 2.1.9.8 for 2.6.12: 520-version-specific-x86_64.patch

2005-07-05 Thread Nigel Cunningham
the kernel to ensure consistency of the image. Without a second pageset,
+   that would limit us to an image that was at most half the amount of memory
+   available. Using two pagesets allows us to store a full image. Since pageset
+   2 pages won't be needed in saving pageset 1, we first save pageset 2 pages.
+   We can then make our atomic copy of the remaining pages using both pageset 2
+   pages and any other pages that are free. While saving both pagesets, we are
+   careful not to corrupt the image. Among other things, we use lowlevel block
+   I/O routines that don't change the pagecache contents.
+
+   The next step, then, is writing pageset 2.
+
+   e. Suspending drivers and storing processor context.
+
+   Having written pageset2, Suspend2 calls the power management functions to
+   notify drivers of the suspend, and saves the processor state in preparation
+   for the atomic copy of memory we are about to make.
+
+   f. Atomic copy.
+
+   At this stage, everything else but the Suspend2 code is halted. Processes
+   are frozen or idling, drivers are quiesced and have stored (ideally and 
where
+   necessary) their configuration in memory we are about to atomically copy.
+   In our lowlevel architecture specific code, we have saved the CPU state.
+   We can therefore now do our atomic copy before resuming drivers etc.
+
+   g. Save the atomic copy (pageset 1).
+
+   Suspend can then write the atomic copy of the remaining pages. Since we
+   have copied the pages into other locations, we can continue to use the
+   normal block I/O routines without fear of corruption our image.
+
+   f. Save the suspend header.
+
+   Nearly there! We save our settings and other parameters needed for
+   reloading pageset 1 in a 'suspend header'. We also tell our writer to
+   serialise its data at this stage, so that it can reread the image at resume
+   time. Note that the writer can write this data in any format - in the case
+   of the swapwriter, for example, it splits header pages in 4092 byte blocks,
+   using the last four bytes to link pages of data together. This is completely
+   transparent to the core.
+
+   g. Set the image header.
+
+   Finally, we edit the header at our resume2= location. The signature is
+   changed by the writer to reflect the fact that an image exists, and to point
+   to the start of that data if necessary (swapwriter).
+
+   h. Power down.
+
+   Or reboot if we're debugging and the appropriate option is selected.
+
+   Whew!
+
+   Reloading the image.
+   
+
+   Reloading the image is essentially the reverse of all the above. We load
+   our copy of pageset 1, being careful to choose locations that aren't going
+   to be overwritten as we copy it back (We start very early in the boot
+   process, so there are no other processes to quiesce here). We then copy
+   pageset 1 back to its original location in memory and restore the process
+   context. We are now running with the original kernel. Next, we reload the
+   pageset 2 pages, free the memory and swap used by Suspend2, restore
+   the pageset header and restart processes. Sounds easy in comparison to
+   suspending, doesn't it!
+
+   There is of course more to Suspend2 than this, but this explanation
+   should be a good start. If there's interest, I'll write further
+   documentation on range pages and the low level I/O.
+
+10. Who wrote Suspend2?
+
+   (Answer based on the writings of Florent Chabaud, credits in files and
+   Nigel's limited knowledge; apologies to anyone missed out!)
+
+   The main developers of Suspend2 have been...
+
+   Gabor Kuti
+   Pavel Machek
+   Florent Chabaud
+   Bernard Blackham
+   Nigel Cunningham
+
+   They have been aided in their efforts by a host of hundreds, if not 
thousands
+   of testers and people who have submitted bug fixes & suggestions. Of special
+   note are the efforts of Michael Frank, who had his computers repetitively
+   suspend and resume for literally tens of thousands of cycles and developed
+   scripts to stress the system and test Suspend2 far beyond the point
+   most of us (Nigel included!) would consider testing. His efforts have
+   contributed as much to Suspend2 as any of the names above.
diff -ruNp 550-documentation.patch-old/Documentation/power/todo.txt 
550-documentation.patch-new/Documentation/power/todo.txt
--- 550-documentation.patch-old/Documentation/power/todo.txt1970-01-01 
10:00:00.0 +1000
+++ 550-documentation.patch-new/Documentation/power/todo.txt2005-07-05 
23:44:36.0 +1000
@@ -0,0 +1,12 @@
+Suspend2 todo list
+
+20050705
+  2.1.9.8 known issues:
+  
+- NFS support missing
+- DRI support for 2.4 & 2.6
+- USB support under 2.4 and 2.6
+- Incomplete support in other drivers
+- No support for discontig memory
+- Currently requires PSE extension (/proc/cpuinfo)
+- Highmem >4GB not supported

-
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] [28/48] Suspend2 2.1.9.8 for 2.6.12: 605-kernel_power_suspend.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 606-all-settings.patch-old/kernel/power/suspend2_core/all_settings.c 
606-all-settings.patch-new/kernel/power/suspend2_core/all_settings.c
--- 606-all-settings.patch-old/kernel/power/suspend2_core/all_settings.c
1970-01-01 10:00:00.0 +1000
+++ 606-all-settings.patch-new/kernel/power/suspend2_core/all_settings.c
2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,325 @@
+/*
+ * /kernel/power/suspend2_core/all_settings.c
+ *
+ * Suspend2 is released under the GPLv2.
+ * 
+ * Copyright (C) 2002-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file provides the all_settings proc entry, used to save
+ * and restore all suspend2 settings en masse.
+ */
+
+#include 
+#include 
+#include 
+
+#include "plugins.h"
+#include "proc.h"
+#include "suspend2_common.h"
+#include "prepare_image.h"
+#include "power_off.h"
+#include "io.h"
+
+#define ALL_SETTINGS_VERSION 4
+
+static int resume2_len;
+
+/*
+ * suspend_write2_compat_proc.
+ *
+ * This entry allows all of the settings to be set at once. 
+ * It was originally for compatibility with pre- /proc/suspend
+ * versions, but has been retained because it makes saving and
+ * restoring the configuration simpler.
+ */
+static int suspend2_write_compat_proc(struct file *file, const char * buffer,
+   unsigned long count, void * data)
+{
+   char * buf1 = (char *) get_zeroed_page(GFP_ATOMIC), *curbuf, *lastbuf;
+   char * buf2 = (char *) get_zeroed_page(GFP_ATOMIC); 
+   int i, file_offset = 0, used_size = 0, reparse_resume_device = 0;
+   unsigned long nextval;
+   struct suspend_plugin_ops * plugin;
+   struct plugin_header * plugin_header = NULL;
+   int version_applying = 0;
+
+   if ((!buf1) || (!buf2)) {
+   count = -ENOMEM;
+   goto out2;
+   }
+
+   while (file_offset < count) {
+   int length = count - file_offset;
+   if (length > (PAGE_SIZE - used_size))
+   length = PAGE_SIZE - used_size;
+
+   if (copy_from_user(buf1 + used_size, buffer + file_offset, 
length)) {
+   count = -EFAULT;
+   goto out2;
+   }
+
+   curbuf = buf1;
+
+   if (!file_offset) {
+   /* Integers first */
+   for (i = 0; i < 8; i++) {
+   if (!*curbuf)
+   break;
+   lastbuf = curbuf;
+   nextval = simple_strtoul(curbuf, &curbuf, 0);
+   if (curbuf == lastbuf)
+   break;
+   switch (i) {
+   case 0:
+   version_applying = nextval;
+   if (nextval < 3) {
+   printk("Error loading 
saved settings. This data is for version %ld, but kernel module supports format 
3 or later.\n",
+   
nextval);
+   goto out2;
+   }
+   case 1:
+   suspend_result = nextval;
+   break;
+   case 2:
+   suspend_action = nextval;
+   break;
+   case 3:
+#ifdef CONFIG_PM_DEBUG
+   suspend_debug_state = nextval;
+#endif
+   break;
+   case 4:
+   suspend_default_console_level = 
nextval;
+#ifndef CONFIG_PM_DEBUG
+   if 
(suspend_default_console_level > 1)
+   
suspend_default_console_level = 1;
+#endif
+   break;
+   case 5:
+   image_size_limit = nextval;
+   break;
+   case 6:
+#ifdef CONFIG_ACPI
+   suspend2_powerdown_method = 
nextval;
+   if (suspend2_powerdown_method < 
3)
+   
suspend2_powerdown_method = 3;
+   if (suspend2_powerdown_method > 
5)
+#endif
+   
suspend2_powerdown_method = 5;
+  

[PATCH] [19/48] Suspend2 2.1.9.8 for 2.6.12: 510-version-specific-mac.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 
520-version-specific-x86_64.patch-old/arch/x86_64/kernel/asm-offsets.c 
520-version-specific-x86_64.patch-new/arch/x86_64/kernel/asm-offsets.c
--- 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/asm-offsets.c  
2005-06-20 11:46:49.0 +1000
+++ 520-version-specific-x86_64.patch-new/arch/x86_64/kernel/asm-offsets.c  
2005-07-04 23:14:19.0 +1000
@@ -62,8 +62,10 @@ int main(void)
   offsetof (struct rt_sigframe32, uc.uc_mcontext));
BLANK();
 #endif
+#ifdef CONFIG_PM
DEFINE(pbe_address, offsetof(struct pbe, address));
DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
DEFINE(pbe_next, offsetof(struct pbe, next));
+#endif
return 0;
 }
diff -ruNp 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/Makefile 
520-version-specific-x86_64.patch-new/arch/x86_64/kernel/Makefile
--- 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/Makefile   
2005-06-20 11:46:49.0 +1000
+++ 520-version-specific-x86_64.patch-new/arch/x86_64/kernel/Makefile   
2005-07-04 23:14:19.0 +1000
@@ -22,6 +22,7 @@ obj-$(CONFIG_X86_IO_APIC) += io_apic.o m
genapic.o genapic_cluster.o genapic_flat.o
 obj-$(CONFIG_PM)   += suspend.o
 obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o
+obj-$(CONFIG_SUSPEND2) += suspend2.o
 obj-$(CONFIG_CPU_FREQ) += cpufreq/
 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
 obj-$(CONFIG_GART_IOMMU)   += pci-gart.o aperture.o
diff -ruNp 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/suspend.c 
520-version-specific-x86_64.patch-new/arch/x86_64/kernel/suspend.c
--- 520-version-specific-x86_64.patch-old/arch/x86_64/kernel/suspend.c  
2004-11-03 21:53:44.0 +1100
+++ 520-version-specific-x86_64.patch-new/arch/x86_64/kernel/suspend.c  
2005-07-04 23:14:19.0 +1000
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct saved_context saved_context;
 
@@ -35,6 +36,8 @@ unsigned long saved_context_r08, saved_c
 unsigned long saved_context_r12, saved_context_r13, saved_context_r14, 
saved_context_r15;
 unsigned long saved_context_eflags;
 
+void fix_processor_context(void);
+
 void __save_processor_state(struct saved_context *ctxt)
 {
kernel_fpu_begin();
diff -ruNp 520-version-specific-x86_64.patch-old/arch/x86_64/mm/init.c 
520-version-specific-x86_64.patch-new/arch/x86_64/mm/init.c
--- 520-version-specific-x86_64.patch-old/arch/x86_64/mm/init.c 2005-06-20 
11:46:49.0 +1000
+++ 520-version-specific-x86_64.patch-new/arch/x86_64/mm/init.c 2005-07-04 
23:14:19.0 +1000
@@ -618,3 +618,22 @@ int in_gate_area_no_task(unsigned long a
 {
return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
 }
+
+#if defined(CONFIG_PM_DISK) || defined(CONFIG_SOFTWARE_SUSPEND) || 
defined(CONFIG_SUSPEND2)
+/*
+ * Software suspend & friends need this for resume because things like the 
intel-agp
+ * driver might have split up a kernel 4MB mapping.
+ */
+char __nosavedata swsusp_pg_dir[PAGE_SIZE]
+   __attribute__ ((aligned (PAGE_SIZE)));
+
+static inline void save_pg_dir(void)
+{
+   memcpy(swsusp_pg_dir, swapper_pg_dir, PAGE_SIZE);
+}
+#else
+static inline void save_pg_dir(void)
+{
+}
+#endif
+
diff -ruNp 520-version-specific-x86_64.patch-old/include/asm-x86_64/suspend2.h 
520-version-specific-x86_64.patch-new/include/asm-x86_64/suspend2.h
--- 520-version-specific-x86_64.patch-old/include/asm-x86_64/suspend2.h 
1970-01-01 10:00:00.0 +1000
+++ 520-version-specific-x86_64.patch-new/include/asm-x86_64/suspend2.h 
2005-07-05 23:56:15.0 +1000
@@ -0,0 +1,432 @@
+ /*
+  * Copyright 2005 Nigel Cunningham <[EMAIL PROTECTED]>
+  * Based on code
+  * Copyright 2001-2002 Pavel Machek <[EMAIL PROTECTED]>
+  * Based on code
+  * Copyright 2001 Patrick Mochel <[EMAIL PROTECTED]>
+  */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#undef inline
+#define inline __inline__ __attribute__((always_inline))
+
+/* image of the saved processor states */
+struct suspend2_saved_context {
+   unsigned long eax, ebx, ecx, edx;
+   unsigned long esp, ebp, esi, edi;
+   unsigned long r8, r9, r10, r11;
+   unsigned long r12, r13, r14, r15;
+
+#if 0
+   u16 es, fs, gs, ss;
+   u32 cr0, cr2, cr3, cr4;
+   u16 gdt_pad;
+   u16 gdt_limit;
+   u32 gdt_base;
+   u16 idt_pad;
+   u16 idt_limit;
+   u32 idt_base;
+   u16 ldt;
+   u16 tss;
+   u32 tr;
+   u32 safety;
+   u32 return_address;
+#endif
+   unsigned long eflags;
+} __attribute__((packed));
+
+extern struct suspend2_saved_context suspend2_saved_context;   /* temporary 
storage */
+
+#ifdef CONFIG_MTRR
+/* MTRR functions */
+extern int mtrr_save(void);
+extern int mtrr_restore_one_cpu(void);
+extern void mtrr_restore_finish(void);
+#else
+#define mtrr_save() do { } while(0)
+#define mtrr_restore_one_cpu() do { } while(0)
+#define mtrr_restore_finish() do { } whil

[PATCH] [23/48] Suspend2 2.1.9.8 for 2.6.12: 600-suspend-header.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 601-kernel_power_power-header.patch-old/kernel/power/power.h 
601-kernel_power_power-header.patch-new/kernel/power/power.h
--- 601-kernel_power_power-header.patch-old/kernel/power/power.h
2005-07-06 11:29:15.0 +1000
+++ 601-kernel_power_power-header.patch-new/kernel/power/power.h
2005-07-04 23:14:19.0 +1000
@@ -1,6 +1,8 @@
 #include 
 #include 
 
+#include "suspend.h"
+
 /* With SUSPEND_CONSOLE defined, it suspend looks *really* cool, but
we probably do not take enough locks for switching consoles, etc,
so bad things might happen.

-
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] [31/48] Suspend2 2.1.9.8 for 2.6.12: 608-compression.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 609-driver-model.patch-old/kernel/power/suspend2_core/driver_model.c 
609-driver-model.patch-new/kernel/power/suspend2_core/driver_model.c
--- 609-driver-model.patch-old/kernel/power/suspend2_core/driver_model.c
1970-01-01 10:00:00.0 +1000
+++ 609-driver-model.patch-new/kernel/power/suspend2_core/driver_model.c
2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,95 @@
+/*
+ * kernel/power/suspend2_core/driver_model.c
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * Support for the driver model and ACPI sleep states.
+ */
+
+#include 
+#include "driver_model.h"
+#include "power_off.h"
+
+extern struct pm_ops * pm_ops;
+static u32 pm_disk_mode_save;
+
+#ifdef CONFIG_ACPI
+static int suspend_pm_state_used = 0;
+extern u32 acpi_leave_sleep_state (u8 sleep_state);
+#endif
+
+/* suspend_drivers_init
+ *
+ * Store the original pm ops settings.
+ */
+int suspend_drivers_init(void)
+{
+   if (pm_ops) {
+   pm_disk_mode_save = pm_ops->pm_disk_mode;
+   pm_ops->pm_disk_mode = PM_DISK_PLATFORM;
+   }
+   
+   return 0;
+}
+
+/* suspend_drivers_cleanup
+ *
+ * Restore the original pm disk mode.
+ */
+void suspend_drivers_cleanup(void)
+{
+   if (pm_ops)
+   pm_ops->pm_disk_mode = pm_disk_mode_save;
+}
+
+/* suspend_drivers_suspend
+ *
+ * Suspend the drivers after an atomic copy.
+ */
+int suspend_drivers_suspend(int stage)
+{
+   int result = 0;
+   const pm_message_t state = PMSG_FREEZE;
+
+   switch (stage) {
+   case SUSPEND_DRIVERS_IRQS_DISABLED:
+   BUG_ON(!irqs_disabled());
+   result = device_power_down(state);
+   BUG_ON(!irqs_disabled());
+   break;
+
+   case SUSPEND_DRIVERS_IRQS_ENABLED:
+   BUG_ON(irqs_disabled());
+   result = device_suspend(state);
+   BUG_ON(irqs_disabled());
+   break;
+   }
+   return result;
+}
+
+/* suspend_drivers_resume
+ *
+ * Resume the drivers after an atomic copy (save or restore)
+ */
+void suspend_drivers_resume(int stage)
+{
+   switch (stage) {
+   case SUSPEND_DRIVERS_IRQS_DISABLED:
+   BUG_ON(!irqs_disabled());
+   device_power_up();
+   BUG_ON(!irqs_disabled());
+   break;
+
+   case SUSPEND_DRIVERS_IRQS_ENABLED:
+   BUG_ON(irqs_disabled());
+#ifdef CONFIG_ACPI
+   if (suspend_pm_state_used)
+   acpi_leave_sleep_state(suspend_pm_state_used);
+#endif
+   suspend_pm_state_finish();
+   BUG_ON(irqs_disabled());
+   break;
+   }
+}
diff -ruNp 609-driver-model.patch-old/kernel/power/suspend2_core/driver_model.h 
609-driver-model.patch-new/kernel/power/suspend2_core/driver_model.h
--- 609-driver-model.patch-old/kernel/power/suspend2_core/driver_model.h
1970-01-01 10:00:00.0 +1000
+++ 609-driver-model.patch-new/kernel/power/suspend2_core/driver_model.h
2005-07-04 23:14:19.0 +1000
@@ -0,0 +1,24 @@
+/*
+ * kernel/power/driver_model.h
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ * Support for the driver model.
+ */
+
+/* suspend_drivers_resume
+ * @stage - One of...
+ */
+
+enum {
+   SUSPEND_DRIVERS_IRQS_DISABLED,
+   SUSPEND_DRIVERS_IRQS_ENABLED,
+};
+
+extern int suspend_drivers_init(void);
+extern void suspend_drivers_cleanup(void);
+
+extern int suspend_drivers_suspend(int stage);
+extern void suspend_drivers_resume(int stage);

-
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] [26/48] Suspend2 2.1.9.8 for 2.6.12: 603-suspend2_common-headers.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 604-utility-header.patch-old/kernel/power/suspend2_core/utility.c 
604-utility-header.patch-new/kernel/power/suspend2_core/utility.c
--- 604-utility-header.patch-old/kernel/power/suspend2_core/utility.c   
1970-01-01 10:00:00.0 +1000
+++ 604-utility-header.patch-new/kernel/power/suspend2_core/utility.c   
2005-07-05 23:48:59.0 +1000
@@ -0,0 +1,46 @@
+/*
+ * kernel/power/utility.c
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ * 
+ * This file is released under the GPLv2.
+ *
+ * Routines that only suspend uses at the moment, but which might move
+ * when we merge because they're generic.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "pageflags.h"
+
+/*
+ * suspend_snprintf
+ *
+ * Functionality: Print a string with parameters to a buffer of a 
+ *limited size. Unlike vsnprintf, we return the number
+ *of bytes actually put in the buffer, not the number
+ *that would have been put in if it was big enough.
+ */
+int suspend_snprintf(char * buffer, int buffer_size, const char *fmt, ...)
+{
+   int result;
+   va_list args;
+
+   if (!buffer_size) {
+   return 0;
+   }
+
+   va_start(args, fmt);
+   result = vsnprintf(buffer, buffer_size, fmt, args);
+   va_end(args);
+
+   if (result > buffer_size) {
+   return buffer_size;
+   }
+
+   return result;
+}
diff -ruNp 604-utility-header.patch-old/kernel/power/suspend2_core/utility.h 
604-utility-header.patch-new/kernel/power/suspend2_core/utility.h
--- 604-utility-header.patch-old/kernel/power/suspend2_core/utility.h   
1970-01-01 10:00:00.0 +1000
+++ 604-utility-header.patch-new/kernel/power/suspend2_core/utility.h   
2005-07-05 23:48:59.0 +1000
@@ -0,0 +1,12 @@
+/*
+ * kernel/power/suspend2_core/utility.h
+ *
+ * Copyright (C) 2004-2005 Nigel Cunningham <[EMAIL PROTECTED]>
+ * 
+ * This file is released under the GPLv2.
+ *
+ * Routines that only suspend uses at the moment, but which might move
+ * when we merge because they're generic.
+ */
+
+extern int suspend_snprintf(char * buffer, int buffer_size, const char *fmt, 
...);

-
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] [24/48] Suspend2 2.1.9.8 for 2.6.12: 601-kernel_power_power-header.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 602-smp.patch-old/kernel/power/suspend2_core/smp.c 
602-smp.patch-new/kernel/power/suspend2_core/smp.c
--- 602-smp.patch-old/kernel/power/suspend2_core/smp.c  1970-01-01 
10:00:00.0 +1000
+++ 602-smp.patch-new/kernel/power/suspend2_core/smp.c  2005-07-04 
23:14:19.0 +1000
@@ -0,0 +1,12 @@
+#include 
+
+void ensure_on_processor_zero(void)
+{
+   set_cpus_allowed(current, cpumask_of_cpu(0));
+   BUG_ON(smp_processor_id() != 0);
+}
+
+void return_to_all_processors(void)
+{
+   set_cpus_allowed(current, CPU_MASK_ALL);
+}
diff -ruNp 602-smp.patch-old/kernel/power/suspend2_core/smp.h 
602-smp.patch-new/kernel/power/suspend2_core/smp.h
--- 602-smp.patch-old/kernel/power/suspend2_core/smp.h  1970-01-01 
10:00:00.0 +1000
+++ 602-smp.patch-new/kernel/power/suspend2_core/smp.h  2005-07-04 
23:14:19.0 +1000
@@ -0,0 +1,7 @@
+#ifdef CONFIG_SMP
+extern void ensure_on_processor_zero(void);
+extern void return_to_all_processors(void);
+#else
+#define ensure_on_processor_zero() do { } while(0)
+#define return_to_all_processors() do { } while(0)
+#endif

-
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] [13/48] Suspend2 2.1.9.8 for 2.6.12: 403-debug-pagealloc-support.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 404-check-mounts-support.patch-old/drivers/usb/core/inode.c 
404-check-mounts-support.patch-new/drivers/usb/core/inode.c
--- 404-check-mounts-support.patch-old/drivers/usb/core/inode.c 2005-06-20 
11:47:07.0 +1000
+++ 404-check-mounts-support.patch-new/drivers/usb/core/inode.c 2005-07-04 
23:14:19.0 +1000
@@ -569,6 +569,7 @@ static struct file_system_type usb_fs_ty
.name = "usbfs",
.get_sb =   usb_get_sb,
.kill_sb =  kill_litter_super,
+   .fs_flags = FS_RW_S4_RESUME_SAFE,
 };
 
 /* - */
diff -ruNp 404-check-mounts-support.patch-old/fs/block_dev.c 
404-check-mounts-support.patch-new/fs/block_dev.c
--- 404-check-mounts-support.patch-old/fs/block_dev.c   2005-06-20 
11:47:11.0 +1000
+++ 404-check-mounts-support.patch-new/fs/block_dev.c   2005-07-04 
23:14:19.0 +1000
@@ -310,6 +310,7 @@ static struct file_system_type bd_type =
.name   = "bdev",
.get_sb = bd_get_sb,
.kill_sb= kill_anon_super,
+   .fs_flags   = FS_RW_S4_RESUME_SAFE,
 };
 
 static struct vfsmount *bd_mnt;
diff -ruNp 404-check-mounts-support.patch-old/fs/debugfs/inode.c 
404-check-mounts-support.patch-new/fs/debugfs/inode.c
--- 404-check-mounts-support.patch-old/fs/debugfs/inode.c   2005-02-03 
22:33:40.0 +1100
+++ 404-check-mounts-support.patch-new/fs/debugfs/inode.c   2005-07-04 
23:14:19.0 +1000
@@ -132,6 +132,7 @@ static struct file_system_type debug_fs_
.name = "debugfs",
.get_sb =   debug_get_sb,
.kill_sb =  kill_litter_super,
+   .fs_flags   = FS_RW_S4_RESUME_SAFE,
 };
 
 static int debugfs_create_by_name(const char *name, mode_t mode,
diff -ruNp 404-check-mounts-support.patch-old/fs/devfs/base.c 
404-check-mounts-support.patch-new/fs/devfs/base.c
--- 404-check-mounts-support.patch-old/fs/devfs/base.c  2005-02-03 
22:33:40.0 +1100
+++ 404-check-mounts-support.patch-new/fs/devfs/base.c  2005-07-04 
23:14:19.0 +1000
@@ -2560,6 +2560,7 @@ static struct file_system_type devfs_fs_
.name = DEVFS_NAME,
.get_sb = devfs_get_sb,
.kill_sb = kill_anon_super,
+   .fs_flags = FS_RW_S4_RESUME_SAFE,
 };
 
 /*  File operations for devfsd follow  */
diff -ruNp 404-check-mounts-support.patch-old/fs/devpts/inode.c 
404-check-mounts-support.patch-new/fs/devpts/inode.c
--- 404-check-mounts-support.patch-old/fs/devpts/inode.c2005-02-03 
22:33:40.0 +1100
+++ 404-check-mounts-support.patch-new/fs/devpts/inode.c2005-07-04 
23:14:19.0 +1000
@@ -139,6 +139,7 @@ static struct file_system_type devpts_fs
.name   = "devpts",
.get_sb = devpts_get_sb,
.kill_sb= kill_anon_super,
+   .fs_flags   = FS_RW_S4_RESUME_SAFE,
 };
 
 /*
diff -ruNp 404-check-mounts-support.patch-old/fs/eventpoll.c 
404-check-mounts-support.patch-new/fs/eventpoll.c
--- 404-check-mounts-support.patch-old/fs/eventpoll.c   2005-06-20 
11:47:12.0 +1000
+++ 404-check-mounts-support.patch-new/fs/eventpoll.c   2005-07-04 
23:14:19.0 +1000
@@ -348,6 +348,7 @@ static struct file_system_type eventpoll
.name   = "eventpollfs",
.get_sb = eventpollfs_get_sb,
.kill_sb= kill_anon_super,
+   .fs_flags   = FS_RW_S4_RESUME_SAFE,
 };
 
 /* Very basic directory entry operations for the eventpoll virtual file system 
*/
diff -ruNp 404-check-mounts-support.patch-old/fs/hugetlbfs/inode.c 
404-check-mounts-support.patch-new/fs/hugetlbfs/inode.c
--- 404-check-mounts-support.patch-old/fs/hugetlbfs/inode.c 2005-06-20 
11:47:12.0 +1000
+++ 404-check-mounts-support.patch-new/fs/hugetlbfs/inode.c 2005-07-04 
23:14:19.0 +1000
@@ -728,6 +728,7 @@ static struct file_system_type hugetlbfs
.name   = "hugetlbfs",
.get_sb = hugetlbfs_get_sb,
.kill_sb= kill_litter_super,
+   .fs_flags   = FS_RW_S4_RESUME_SAFE,
 };
 
 static struct vfsmount *hugetlbfs_vfsmount;
diff -ruNp 404-check-mounts-support.patch-old/fs/nfs/inode.c 
404-check-mounts-support.patch-new/fs/nfs/inode.c
--- 404-check-mounts-support.patch-old/fs/nfs/inode.c   2005-06-20 
11:47:13.0 +1000
+++ 404-check-mounts-support.patch-new/fs/nfs/inode.c   2005-07-04 
23:14:19.0 +1000
@@ -1490,7 +1490,7 @@ static struct file_system_type nfs_fs_ty
.name   = "nfs",
.get_sb = nfs_get_sb,
.kill_sb= nfs_kill_super,
-   .fs_flags   = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
+   .fs_flags   = 
FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA|FS_RW_S4_RESUME_SAFE,
 };
 
 #ifdef CONFIG_NFS_V4
diff -ruNp 404-check-mounts-support.patch-old/fs/pipe.c 
404-check-mounts-support.patch-new/fs/pipe.c
--- 404-check-mounts-support.patch-old/fs/pipe.c2005

[PATCH] [16/48] Suspend2 2.1.9.8 for 2.6.12: 406-dynamic-pageflags.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 500-version-specific-i386.patch-old/arch/i386/power/Makefile 
500-version-specific-i386.patch-new/arch/i386/power/Makefile
--- 500-version-specific-i386.patch-old/arch/i386/power/Makefile
2004-11-03 21:52:57.0 +1100
+++ 500-version-specific-i386.patch-new/arch/i386/power/Makefile
2005-07-04 23:14:19.0 +1000
@@ -1,2 +1,2 @@
-obj-$(CONFIG_PM)   += cpu.o
+obj-$(CONFIG_PM)   += cpu.o smp.o
 obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o
diff -ruNp 500-version-specific-i386.patch-old/arch/i386/power/smp.c 
500-version-specific-i386.patch-new/arch/i386/power/smp.c
--- 500-version-specific-i386.patch-old/arch/i386/power/smp.c   1970-01-01 
10:00:00.0 +1000
+++ 500-version-specific-i386.patch-new/arch/i386/power/smp.c   2005-07-04 
23:14:19.0 +1000
@@ -0,0 +1,84 @@
+//#ifdef CONFIG_SMP
+#include 
+#include 
+#include 
+#include 
+
+extern atomic_t suspend_cpu_counter __nosavedata;
+unsigned char * my_saved_context __nosavedata;
+static unsigned long c_loops_per_jiffy_ref[NR_CPUS] __nosavedata;
+
+struct suspend2_saved_context suspend2_saved_contexts[NR_CPUS];
+struct suspend2_saved_context suspend2_saved_context;  /* temporary storage */
+cpumask_t saved_affinity[NR_IRQS];
+
+/*
+ * Save and restore processor state for secondary processors.
+ * IRQs (and therefore preemption) are already disabled 
+ * when we enter here (IPI).
+ */
+
+static volatile int loop __nosavedata;
+
+void __smp_suspend_lowlevel(void * data)
+{
+   __asm__( "movl %%ecx,%%cr3\n" ::"c"(__pa(swsusp_pg_dir)));
+
+   if (test_suspend_state(SUSPEND_NOW_RESUMING)) {
+   BUG_ON(!irqs_disabled());
+   kernel_fpu_begin();
+   c_loops_per_jiffy_ref[_smp_processor_id()] = 
current_cpu_data.loops_per_jiffy;
+   atomic_inc(&suspend_cpu_counter);
+
+   /* Only image copied back while we spin in this loop. Our
+* task info should not be looked at while this is happening
+* (which smp_processor_id() will do( */
+   while (test_suspend_state(SUSPEND_FREEZE_SMP)) { 
+   cpu_relax();
+   barrier();
+   }
+
+   while (atomic_read(&suspend_cpu_counter) != 
_smp_processor_id()) {
+   cpu_relax();
+   barrier();
+   }
+   my_saved_context = (unsigned char *) (suspend2_saved_contexts + 
_smp_processor_id());
+   for (loop = sizeof(struct suspend2_saved_context); loop--; loop)
+   *(((unsigned char *) &suspend2_saved_context) + loop - 
1) = *(my_saved_context + loop - 1);
+   suspend2_restore_processor_context();
+   cpu_clear(_smp_processor_id(), per_cpu(cpu_tlbstate, 
_smp_processor_id()).active_mm->cpu_vm_mask);
+   load_cr3(swapper_pg_dir);
+   wbinvd();
+   __flush_tlb_all();
+   current_cpu_data.loops_per_jiffy = 
c_loops_per_jiffy_ref[_smp_processor_id()];
+   mtrr_restore_one_cpu();
+   atomic_dec(&suspend_cpu_counter);
+   } else {/* suspending */
+   BUG_ON(!irqs_disabled());
+   /* 
+*Save context and go back to idling.
+* Note that we cannot leave the processor
+* here. It must be able to receive IPIs if
+* the LZF compression driver (eg) does a
+* vfree after compressing the kernel etc
+*/
+   while (test_suspend_state(SUSPEND_FREEZE_SMP) &&
+   (atomic_read(&suspend_cpu_counter) != 
(_smp_processor_id() - 1))) {
+   cpu_relax();
+   barrier();
+   }
+   suspend2_save_processor_context();
+   my_saved_context = (unsigned char *) (suspend2_saved_contexts + 
_smp_processor_id());
+   for (loop = sizeof(struct suspend2_saved_context); loop--; loop)
+   *(my_saved_context + loop - 1) = *(((unsigned char *) 
&suspend2_saved_context) + loop - 1);
+   atomic_inc(&suspend_cpu_counter);
+   /* Now spin until the atomic copy of the kernel is made. */
+   while (test_suspend_state(SUSPEND_FREEZE_SMP)) {
+   cpu_relax();
+   barrier();
+   }
+   atomic_dec(&suspend_cpu_counter);
+   kernel_fpu_end();
+   }
+}
+//#endif
diff -ruNp 500-version-specific-i386.patch-old/include/asm-i386/suspend2.h 
500-version-specific-i386.patch-new/include/asm-i386/suspend2.h
--- 500-version-specific-i386.patch-old/include/asm-i386/suspend2.h 
1970-01-01 10:00:00.0 +1000
+++ 500-version-specific-i386.patch-new/include/asm-i386/suspend2.h 
2005-07-05 23:56:41.0 +1000
@@ -0,0 +1,391 @@
+ /*
+  * Copyright 2003-2005 Nigel Cunningham <[EMAIL PRO

[0/48] Suspend2 2.1.9.8 for 2.6.12

2005-07-05 Thread Nigel Cunningham
As requested, here are the patches that form Suspend2, for review.

I've tried to split it up into byte size chunks, but please don't expect
that these will be patches that can mutate swsusp into Suspend2. That
would roughly equivalent to asking for patches that patch Reiser3 into
Reiser4 - it's a redesign.

There are a few extra patches not included here, all of which are not
core to Suspend2. Since I'm not expecting this code to get merged as is,
I haven't worried about including them. If that's a problem, let me know.

Regards,

Nigel
-- 
Evolution.
Enumerate the requirements.
Consider the interdependencies.
Calculate the probabilities.
Be amazed that people believe it 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/


[PATCH] [14/48] Suspend2 2.1.9.8 for 2.6.12: 404-check-mounts-support.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 405-clear-swapfile-bdev-in-swapoff.patch-old/mm/swapfile.c 
405-clear-swapfile-bdev-in-swapoff.patch-new/mm/swapfile.c
--- 405-clear-swapfile-bdev-in-swapoff.patch-old/mm/swapfile.c  2005-07-06 
11:22:01.0 +1000
+++ 405-clear-swapfile-bdev-in-swapoff.patch-new/mm/swapfile.c  2005-07-04 
23:14:19.0 +1000
@@ -1162,6 +1162,7 @@ asmlinkage long sys_swapoff(const char _
swap_file = p->swap_file;
p->swap_file = NULL;
p->max = 0;
+   p->bdev = NULL;
swap_map = p->swap_map;
p->swap_map = NULL;
p->flags = 0;

-
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/48] Suspend2 2.1.9.8 for 2.6.12: 302-init-hooks.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 350-workthreads.patch-old/drivers/acpi/osl.c 
350-workthreads.patch-new/drivers/acpi/osl.c
--- 350-workthreads.patch-old/drivers/acpi/osl.c2005-06-20 
11:46:50.0 +1000
+++ 350-workthreads.patch-new/drivers/acpi/osl.c2005-07-04 
23:14:18.0 +1000
@@ -95,7 +95,7 @@ acpi_os_initialize1(void)
return AE_NULL_ENTRY;
}
 #endif
-   kacpid_wq = create_singlethread_workqueue("kacpid");
+   kacpid_wq = create_singlethread_workqueue("kacpid", PF_NOFREEZE);
BUG_ON(!kacpid_wq);
 
return AE_OK;
diff -ruNp 350-workthreads.patch-old/drivers/block/ll_rw_blk.c 
350-workthreads.patch-new/drivers/block/ll_rw_blk.c
--- 350-workthreads.patch-old/drivers/block/ll_rw_blk.c 2005-06-20 
11:46:50.0 +1000
+++ 350-workthreads.patch-new/drivers/block/ll_rw_blk.c 2005-07-04 
23:14:18.0 +1000
@@ -3266,7 +3266,7 @@ EXPORT_SYMBOL(kblockd_flush);
 
 int __init blk_dev_init(void)
 {
-   kblockd_workqueue = create_workqueue("kblockd");
+   kblockd_workqueue = create_workqueue("kblockd", PF_NOFREEZE);
if (!kblockd_workqueue)
panic("Failed to create kblockd\n");
 
diff -ruNp 350-workthreads.patch-old/drivers/block/pktcdvd.c 
350-workthreads.patch-new/drivers/block/pktcdvd.c
--- 350-workthreads.patch-old/drivers/block/pktcdvd.c   2005-07-06 
11:14:09.0 +1000
+++ 350-workthreads.patch-new/drivers/block/pktcdvd.c   2005-07-04 
23:14:18.0 +1000
@@ -2373,7 +2373,7 @@ static int pkt_new_dev(struct pktcdvd_de
pkt_init_queue(pd);
 
atomic_set(&pd->cdrw.pending_bios, 0);
-   pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->name);
+   pd->cdrw.thread = kthread_run(kcdrwd, pd, 0, "%s", pd->name);
if (IS_ERR(pd->cdrw.thread)) {
printk("pktcdvd: can't start kernel thread\n");
ret = -ENOMEM;
diff -ruNp 350-workthreads.patch-old/drivers/char/hvc_console.c 
350-workthreads.patch-new/drivers/char/hvc_console.c
--- 350-workthreads.patch-old/drivers/char/hvc_console.c2005-02-03 
22:33:25.0 +1100
+++ 350-workthreads.patch-new/drivers/char/hvc_console.c2005-07-04 
23:14:18.0 +1000
@@ -709,7 +709,7 @@ int __init hvc_init(void)
 
/* Always start the kthread because there can be hotplug vty adapters
 * added later. */
-   hvc_task = kthread_run(khvcd, NULL, "khvcd");
+   hvc_task = kthread_run(khvcd, NULL, PF_NOFREEZE, "khvcd");
if (IS_ERR(hvc_task)) {
panic("Couldn't create kthread for console.\n");
put_tty_driver(hvc_driver);
diff -ruNp 350-workthreads.patch-old/drivers/char/hvcs.c 
350-workthreads.patch-new/drivers/char/hvcs.c
--- 350-workthreads.patch-old/drivers/char/hvcs.c   2005-02-14 
09:05:25.0 +1100
+++ 350-workthreads.patch-new/drivers/char/hvcs.c   2005-07-04 
23:14:18.0 +1000
@@ -1403,7 +1403,7 @@ static int __init hvcs_module_init(void)
return -ENOMEM;
}
 
-   hvcs_task = kthread_run(khvcsd, NULL, "khvcsd");
+   hvcs_task = kthread_run(khvcsd, NULL, PF_NOFREEZE, "khvcsd");
if (IS_ERR(hvcs_task)) {
printk(KERN_ERR "HVCS: khvcsd creation failed.  Driver not 
loaded.\n");
kfree(hvcs_pi_buff);
diff -ruNp 350-workthreads.patch-old/drivers/infiniband/core/fmr_pool.c 
350-workthreads.patch-new/drivers/infiniband/core/fmr_pool.c
--- 350-workthreads.patch-old/drivers/infiniband/core/fmr_pool.c
2005-06-20 11:46:54.0 +1000
+++ 350-workthreads.patch-new/drivers/infiniband/core/fmr_pool.c
2005-07-04 23:14:18.0 +1000
@@ -266,6 +266,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(s
 
pool->thread = kthread_create(ib_fmr_cleanup_thread,
  pool,
+ 0,
  "ib_fmr(%s)",
  device->name);
if (IS_ERR(pool->thread)) {
diff -ruNp 350-workthreads.patch-old/drivers/infiniband/core/mad.c 
350-workthreads.patch-new/drivers/infiniband/core/mad.c
--- 350-workthreads.patch-old/drivers/infiniband/core/mad.c 2005-06-20 
11:46:54.0 +1000
+++ 350-workthreads.patch-new/drivers/infiniband/core/mad.c 2005-07-04 
23:14:18.0 +1000
@@ -2502,7 +2502,7 @@ static int ib_mad_port_open(struct ib_de
goto error7;
 
snprintf(name, sizeof name, "ib_mad%d", port_num);
-   port_priv->wq = create_singlethread_workqueue(name);
+   port_priv->wq = create_singlethread_workqueue(name, 0);
if (!port_priv->wq) {
ret = -ENOMEM;
goto error8;
diff -ruNp 350-workthreads.patch-old/drivers/infiniband/ulp/ipoib/ipoib_main.c 
350-workthreads.patch-new/drivers/infiniband/ulp/ipoib/ipoib_main.c
--- 350-workthreads.patch-old/drivers/infiniband/ulp/ipoib/ipoib_main.c 
2005-06-20 11:46:54.0 +1000
+++ 350-workthreads.patch-new/drivers/in

[PATCH] [7/48] Suspend2 2.1.9.8 for 2.6.12: 352-disable-pdflush-during-suspend.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 353-disable-highmem-tlb-flush-for-copyback.patch-old/mm/highmem.c 
353-disable-highmem-tlb-flush-for-copyback.patch-new/mm/highmem.c
--- 353-disable-highmem-tlb-flush-for-copyback.patch-old/mm/highmem.c   
2005-06-20 11:47:32.0 +1000
+++ 353-disable-highmem-tlb-flush-for-copyback.patch-new/mm/highmem.c   
2005-07-04 23:14:20.0 +1000
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static mempool_t *page_pool, *isa_page_pool;
@@ -95,7 +96,10 @@ static void flush_all_zero_pkmaps(void)
 
set_page_address(page, NULL);
}
-   flush_tlb_kernel_range(PKMAP_ADDR(0), PKMAP_ADDR(LAST_PKMAP));
+   if (test_suspend_state(SUSPEND_FREEZE_SMP))
+   __flush_tlb();
+   else
+   flush_tlb_kernel_range(PKMAP_ADDR(0), PKMAP_ADDR(LAST_PKMAP));
 }
 
 static inline unsigned long map_new_virtual(struct page *page)

-
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/48] Suspend2 2.1.9.8 for 2.6.12: 501-tlb-flushing-functions.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 510-version-specific-mac.patch-old/arch/ppc/Kconfig 
510-version-specific-mac.patch-new/arch/ppc/Kconfig
--- 510-version-specific-mac.patch-old/arch/ppc/Kconfig 2005-06-20 
11:46:44.0 +1000
+++ 510-version-specific-mac.patch-new/arch/ppc/Kconfig 2005-07-04 
23:14:19.0 +1000
@@ -1081,7 +1081,7 @@ config PROC_HARDWARE
 
 source "drivers/zorro/Kconfig"
 
-source kernel/power/Kconfig
+source "kernel/power/Kconfig"
 
 endmenu
 
diff -ruNp 510-version-specific-mac.patch-old/arch/ppc/kernel/signal.c 
510-version-specific-mac.patch-new/arch/ppc/kernel/signal.c
--- 510-version-specific-mac.patch-old/arch/ppc/kernel/signal.c 2005-07-06 
11:25:14.0 +1000
+++ 510-version-specific-mac.patch-new/arch/ppc/kernel/signal.c 2005-07-04 
23:14:19.0 +1000
@@ -711,6 +711,15 @@ int do_signal(sigset_t *oldset, struct p
goto no_signal;
}
 
+   if (freezing(current)) {
+   try_to_freeze();
+   signr = 0;
+   ret = regs->gpr[3];
+   recalc_sigpending();
+   if (!signal_pending(current))
+   goto no_signal;
+   }
+
if (!oldset)
oldset = ¤t->blocked;
 
diff -ruNp 510-version-specific-mac.patch-old/arch/ppc/kernel/swsusp.c 
510-version-specific-mac.patch-new/arch/ppc/kernel/swsusp.c
--- 510-version-specific-mac.patch-old/arch/ppc/kernel/swsusp.c 1970-01-01 
10:00:00.0 +1000
+++ 510-version-specific-mac.patch-new/arch/ppc/kernel/swsusp.c 2005-07-04 
23:14:19.0 +1000
@@ -0,0 +1,88 @@
+/*
+ * Written by Hu Gang ([EMAIL PROTECTED])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "cpu_context.h"
+
+extern suspend_pagedir_t *pagedir_nosave __nosavedata;
+extern int nr_copy_pages __nosavedata;
+
+extern asmlinkage int swsusp_save(void);
+
+static void inline do_swsusp_copyback(void)
+{
+   register int i = 0; 
+   
+   for (i = 0; i < nr_copy_pages; i++) {
+   register int loop;
+   register unsigned long *orig, *copy;
+   
+   copy = (unsigned long *)pagedir_nosave[i].address;
+   orig = (unsigned long *)pagedir_nosave[i].orig_address;
+   
+   for (loop = 0; 
+loop < (PAGE_SIZE / sizeof(unsigned long));
+loop ++)
+   *(orig + loop) = *(copy + loop);
+   }
+}
+
+static struct saved_context swsusp_saved_context;
+
+void save_processor_state(void)
+{
+   __save_processor_state(&swsusp_saved_context);
+}
+
+void restore_processor_state(void)
+{
+   __restore_processor_state(&swsusp_saved_context);
+}
+
+void __flush_tlb_global(void)
+{
+   /* do nothing */
+}
+
+static struct saved_context saved_context;
+
+void swsusp_arch_suspend(void)
+{
+   save_context();
+   __save_processor_state(&saved_context);
+   swsusp_save();
+}
+
+void swsusp_arch_resume(void)
+{
+   save_context();
+   do_swsusp_copyback();
+   __restore_processor_state(&saved_context);
+   restore_context();
+}
diff -ruNp 510-version-specific-mac.patch-old/arch/ppc/kernel/vmlinux.lds.S 
510-version-specific-mac.patch-new/arch/ppc/kernel/vmlinux.lds.S
--- 510-version-specific-mac.patch-old/arch/ppc/kernel/vmlinux.lds.S
2005-06-20 11:46:45.0 +1000
+++ 510-version-specific-mac.patch-new/arch/ppc/kernel/vmlinux.lds.S
2005-07-04 23:14:19.0 +1000
@@ -80,6 +80,12 @@ SECTIONS
   . = ALIGN(4096);
   __nosave_end = .;
 
+  . = ALIGN(4096);
+  __nosave_begin = .;
+  .data_nosave : { *(.data.nosave) }
+  . = ALIGN(4096);
+  __nosave_end = .;
+
   . = ALIGN(32);
   .data.cacheline_aligned : { *(.data.cacheline_aligned) }
 
diff -ruNp 510-version-specific-mac.patch-old/arch/ppc/mm/init.c 
510-version-specific-mac.patch-new/arch/ppc/mm/init.c
--- 510-version-specific-mac.patch-old/arch/ppc/mm/init.c   2005-06-20 
11:46:45.0 +1000
+++ 510-version-specific-mac.patch-new/arch/ppc/mm/init.c   2005-07-04 
23:14:19.0 +1000
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -150,6 +151,7 @@ static void free_sec(unsigned long start
 
while (start < end) {
ClearPageReserved(virt_to_page(start));
+   ClearPageNosave(virt_to_page(start));
set_page_count(virt_to_page(start), 1);
free_page(start);
cnt++;
@@ -190,6 +192,7 @@ void free_initrd_mem(unsigned long start
 
for (; start < end; start +=

[PATCH] [6/48] Suspend2 2.1.9.8 for 2.6.12: 351-syncthreads.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 352-disable-pdflush-during-suspend.patch-old/mm/page-writeback.c 
352-disable-pdflush-during-suspend.patch-new/mm/page-writeback.c
--- 352-disable-pdflush-during-suspend.patch-old/mm/page-writeback.c
2005-06-20 11:47:32.0 +1000
+++ 352-disable-pdflush-during-suspend.patch-new/mm/page-writeback.c
2005-07-04 23:14:19.0 +1000
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * The maximum number of pages to writeout in a single bdflush/kupdate
@@ -404,6 +405,12 @@ static void wb_kupdate(unsigned long arg
.for_kupdate= 1,
};
 
+   if (test_suspend_state(SUSPEND_DISABLE_SYNCING)) {
+   start_jif = jiffies;
+   next_jif = start_jif + (dirty_writeback_centisecs * HZ) / 100;
+   goto out;
+   }
+
sync_supers();
 
get_writeback_state(&wbs);
@@ -424,6 +431,8 @@ static void wb_kupdate(unsigned long arg
}
nr_to_write -= MAX_WRITEBACK_PAGES - wbc.nr_to_write;
}
+
+out:
if (time_before(next_jif, jiffies + HZ))
next_jif = jiffies + HZ;
if (dirty_writeback_centisecs)

-
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] [5/48] Suspend2 2.1.9.8 for 2.6.12: 350-workthreads.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 351-syncthreads.patch-old/fs/buffer.c 
351-syncthreads.patch-new/fs/buffer.c
--- 351-syncthreads.patch-old/fs/buffer.c   2005-07-06 11:15:04.0 
+1000
+++ 351-syncthreads.patch-new/fs/buffer.c   2005-07-04 23:14:18.0 
+1000
@@ -173,6 +173,15 @@ EXPORT_SYMBOL(sync_blockdev);
  */
 int fsync_super(struct super_block *sb)
 {
+   int ret;
+
+   /* A safety net. During suspend, we might overwrite
+* memory containing filesystem info. We don't then
+* want to sync it to disk. */
+   BUG_ON(test_suspend_state(SUSPEND_DISABLE_SYNCING));
+   
+   current->flags |= PF_SYNCTHREAD;
+
sync_inodes_sb(sb, 0);
DQUOT_SYNC(sb);
lock_super(sb);
@@ -184,7 +193,10 @@ int fsync_super(struct super_block *sb)
sync_blockdev(sb->s_bdev);
sync_inodes_sb(sb, 1);
 
-   return sync_blockdev(sb->s_bdev);
+   ret = sync_blockdev(sb->s_bdev);
+
+   current->flags &= ~PF_SYNCTHREAD;
+   return ret;
 }
 
 /*
@@ -195,12 +207,21 @@ int fsync_super(struct super_block *sb)
 int fsync_bdev(struct block_device *bdev)
 {
struct super_block *sb = get_super(bdev);
+   int ret;
+
+   BUG_ON(test_suspend_state(SUSPEND_DISABLE_SYNCING));
+
+   current->flags |= PF_SYNCTHREAD;
+
if (sb) {
int res = fsync_super(sb);
drop_super(sb);
+   current->flags &= ~PF_SYNCTHREAD;
return res;
}
-   return sync_blockdev(bdev);
+   ret = sync_blockdev(bdev);
+   current->flags &= ~PF_SYNCTHREAD;
+   return ret;
 }
 
 /**
@@ -280,6 +301,13 @@ EXPORT_SYMBOL(thaw_bdev);
  */
 static void do_sync(unsigned long wait)
 {
+   /* A safety net. During suspend, we might overwrite
+* memory containing filesystem info. We don't then
+* want to sync it to disk. */
+   BUG_ON(test_suspend_state(SUSPEND_DISABLE_SYNCING));
+
+   current->flags |= PF_SYNCTHREAD;
+
wakeup_bdflush(0);
sync_inodes(0); /* All mappings, inodes and their blockdevs */
DQUOT_SYNC(NULL);
@@ -291,6 +319,8 @@ static void do_sync(unsigned long wait)
printk("Emergency Sync complete\n");
if (unlikely(laptop_mode))
laptop_sync_completion();
+
+   current->flags &= ~PF_SYNCTHREAD;
 }
 
 asmlinkage long sys_sync(void)
@@ -316,6 +346,10 @@ int file_fsync(struct file *filp, struct
struct super_block * sb;
int ret, err;
 
+   BUG_ON(test_suspend_state(SUSPEND_DISABLE_SYNCING));
+
+   current->flags |= PF_SYNCTHREAD;
+
/* sync the inode to buffers */
ret = write_inode_now(inode, 0);
 
@@ -330,6 +364,8 @@ int file_fsync(struct file *filp, struct
err = sync_blockdev(sb->s_bdev);
if (!ret)
ret = err;
+
+   current->flags &= ~PF_SYNCTHREAD;
return ret;
 }
 
@@ -339,6 +375,10 @@ asmlinkage long sys_fsync(unsigned int f
struct address_space *mapping;
int ret, err;
 
+   BUG_ON(test_suspend_state(SUSPEND_DISABLE_SYNCING));
+
+   current->flags |= PF_SYNCTHREAD;
+
ret = -EBADF;
file = fget(fd);
if (!file)
@@ -372,6 +412,7 @@ asmlinkage long sys_fsync(unsigned int f
 out_putf:
fput(file);
 out:
+   current->flags &= ~PF_SYNCTHREAD;
return ret;
 }
 
@@ -381,6 +422,10 @@ asmlinkage long sys_fdatasync(unsigned i
struct address_space *mapping;
int ret, err;
 
+   BUG_ON(test_suspend_state(SUSPEND_DISABLE_SYNCING));
+
+   current->flags |= PF_SYNCTHREAD;
+
ret = -EBADF;
file = fget(fd);
if (!file)
@@ -407,6 +452,7 @@ asmlinkage long sys_fdatasync(unsigned i
 out_putf:
fput(file);
 out:
+   current->flags &= ~PF_SYNCTHREAD;
return ret;
 }
 
diff -ruNp 351-syncthreads.patch-old/fs/jbd/journal.c 
351-syncthreads.patch-new/fs/jbd/journal.c
--- 351-syncthreads.patch-old/fs/jbd/journal.c  2005-07-06 11:15:04.0 
+1000
+++ 351-syncthreads.patch-new/fs/jbd/journal.c  2005-07-04 23:14:19.0 
+1000
@@ -130,6 +130,7 @@ int kjournald(void *arg)
current_journal = journal;
 
daemonize("kjournald");
+   current->flags |= PF_SYNCTHREAD;
 
/* Set up an interval timer which can be used to trigger a
commit wakeup after the commit interval expires */
diff -ruNp 351-syncthreads.patch-old/fs/jffs/intrep.c 
351-syncthreads.patch-new/fs/jffs/intrep.c
--- 351-syncthreads.patch-old/fs/jffs/intrep.c  2005-07-06 11:15:04.0 
+1000
+++ 351-syncthreads.patch-new/fs/jffs/intrep.c  2005-07-04 23:14:19.0 
+1000
@@ -3364,6 +3364,7 @@ jffs_garbage_collect_thread(void *ptr)
D1(int i = 1);
 
daemonize("jffs_gcd");
+   current->flags |= PF_SYNCTHREAD;
 
c->gc_task = current;
 
diff -ruNp 351-syncthreads.patch-old/fs/jfs/jfs_logmgr.c 
351-syncthreads.patch-new/fs/jfs/jfs_logmgr.c
--- 351-syncthreads.patch-old/fs/jfs/jfs_logmgr.

[PATCH] [12/48] Suspend2 2.1.9.8 for 2.6.12: 402-mtrr-remove-sysdev.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 403-debug-pagealloc-support.patch-old/arch/i386/mm/pageattr.c 
403-debug-pagealloc-support.patch-new/arch/i386/mm/pageattr.c
--- 403-debug-pagealloc-support.patch-old/arch/i386/mm/pageattr.c   
2005-06-20 11:46:43.0 +1000
+++ 403-debug-pagealloc-support.patch-new/arch/i386/mm/pageattr.c   
2005-07-04 23:14:19.0 +1000
@@ -217,5 +217,46 @@ void kernel_map_pages(struct page *page,
 }
 #endif
 
+#ifdef CONFIG_SUSPEND2
+#ifdef CONFIG_DEBUG_PAGEALLOC
+static int page_is_kernel_mapped(struct page * page)
+{
+   pte_t *kpte; 
+   unsigned long address;
+
+   if (PageHighMem(page))
+   return 0;
+
+   address = (unsigned long)page_address(page);
+   
+   kpte = lookup_address(address);
+   if (!kpte)
+   return 0;
+
+   if (pte_same(*kpte, mk_pte(page, PAGE_KERNEL)))
+   return 1;
+
+   return 0;
+}
+
+int suspend_map_kernel_page(struct page * page, int enable)
+{
+   int is_already_mapped = page_is_kernel_mapped(page);
+
+   if (enable == is_already_mapped)
+   return 1;
+
+   kernel_map_pages(page, 1, enable);
+
+   return 0;
+}
+#else
+int suspend_map_kernel_page(struct page * page, int enable)
+{
+   return (enable == 1);
+}
+#endif
+#endif
+
 EXPORT_SYMBOL(change_page_attr);
 EXPORT_SYMBOL(global_flush_tlb);

-
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] [11/48] Suspend2 2.1.9.8 for 2.6.12: 401-e820-table-support.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 402-mtrr-remove-sysdev.patch-old/arch/i386/kernel/cpu/mtrr/main.c 
402-mtrr-remove-sysdev.patch-new/arch/i386/kernel/cpu/mtrr/main.c
--- 402-mtrr-remove-sysdev.patch-old/arch/i386/kernel/cpu/mtrr/main.c   
2005-06-20 11:46:42.0 +1000
+++ 402-mtrr-remove-sysdev.patch-new/arch/i386/kernel/cpu/mtrr/main.c   
2005-07-04 23:14:19.0 +1000
@@ -166,7 +166,6 @@ static void ipi_handler(void *info)
atomic_dec(&data->count);
local_irq_restore(flags);
 }
-
 #endif
 
 /**
@@ -560,7 +559,7 @@ struct mtrr_value {
 
 static struct mtrr_value * mtrr_state;
 
-static int mtrr_save(struct sys_device * sysdev, u32 state)
+int mtrr_save(void)
 {
int i;
int size = num_var_ranges * sizeof(struct mtrr_value);
@@ -580,28 +579,27 @@ static int mtrr_save(struct sys_device *
return 0;
 }
 
-static int mtrr_restore(struct sys_device * sysdev)
+/* Restore mtrrs on this CPU only.
+ * Done with interrupts disabled via __smp_lowlevel_suspend
+ */
+int mtrr_restore_one_cpu(void)
 {
int i;
 
for (i = 0; i < num_var_ranges; i++) {
if (mtrr_state[i].lsize) 
-   set_mtrr(i,
+   mtrr_if->set(i,
 mtrr_state[i].lbase,
 mtrr_state[i].lsize,
 mtrr_state[i].ltype);
}
-   kfree(mtrr_state);
return 0;
 }
 
-
-
-static struct sysdev_driver mtrr_sysdev_driver = {
-   .suspend= mtrr_save,
-   .resume = mtrr_restore,
-};
-
+void mtrr_restore_finish(void)
+{
+   kfree(mtrr_state);
+}
 
 /**
  * mtrr_init - initialize mtrrs on the boot CPU
@@ -669,8 +667,7 @@ static int __init mtrr_init(void)
init_table();
init_other_cpus();
 
-   return sysdev_driver_register(&cpu_sysdev_class,
- &mtrr_sysdev_driver);
+   return 0;
}
return -ENXIO;
 }

-
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] [3/48] Suspend2 2.1.9.8 for 2.6.12: 301-proc-acpi-sleep-activate-hook.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 302-init-hooks.patch-old/init/do_mounts.c 
302-init-hooks.patch-new/init/do_mounts.c
--- 302-init-hooks.patch-old/init/do_mounts.c   2005-06-20 11:47:31.0 
+1000
+++ 302-init-hooks.patch-new/init/do_mounts.c   2005-07-04 23:14:19.0 
+1000
@@ -140,11 +140,16 @@ dev_t name_to_dev_t(char *name)
char s[32];
char *p;
dev_t res = 0;
-   int part;
+   int part, mount_result;
 
 #ifdef CONFIG_SYSFS
int mkdir_err = sys_mkdir("/sys", 0700);
-   if (sys_mount("sysfs", "/sys", "sysfs", 0, NULL) < 0)
+   /* 
+* When changing resume2 parameter for Software Suspend, sysfs may
+* already be mounted. 
+*/
+   mount_result = sys_mount("sysfs", "/sys", "sysfs", 0, NULL);
+   if (mount_result < 0 && mount_result != -EBUSY)
goto out;
 #endif
 
@@ -196,7 +201,8 @@ dev_t name_to_dev_t(char *name)
res = try_name(s, part);
 done:
 #ifdef CONFIG_SYSFS
-   sys_umount("/sys", 0);
+   if (mount_result >= 0)
+   sys_umount("/sys", 0);
 out:
if (!mkdir_err)
sys_rmdir("/sys");
@@ -413,9 +419,25 @@ void __init prepare_namespace(void)
 
is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
 
+   /* Suspend2:
+* By this point, suspend_early_init has been called to initialise our
+* proc interface. If modules are built in, they have registered (all
+* of the above via late_initcalls).
+* 
+* We have not yet looked to see if an image exists, however. If we
+* have an initrd, it is expected that the user will have set it up
+* to echo > /proc/software_suspend/activate and thus initiate any
+* resume. If they don'tdo that, we do it immediately after the initrd
+* is finished (major issues if they mount filesystems rw from the
+* initrd! - they are warned. If there's no usable initrd, we do our
+* check next
+*/
if (initrd_load())
goto out;
 
+   if (test_suspend_state(SUSPEND_RESUME_NOT_DONE))
+   suspend2_try_resume();
+   
if (is_floppy && rd_doload && rd_load_disk(0))
ROOT_DEV = Root_RAM0;
 
diff -ruNp 302-init-hooks.patch-old/init/do_mounts_initrd.c 
302-init-hooks.patch-new/init/do_mounts_initrd.c
--- 302-init-hooks.patch-old/init/do_mounts_initrd.c2004-11-03 
21:51:15.0 +1100
+++ 302-init-hooks.patch-new/init/do_mounts_initrd.c2005-07-04 
23:14:19.0 +1000
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "do_mounts.h"
 
@@ -58,9 +59,20 @@ static void __init handle_initrd(void)
 
pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
if (pid > 0) {
-   while (pid != sys_wait4(-1, &i, 0, NULL))
+   while (pid != sys_wait4(-1, &i, 0, NULL)) {
yield();
+   try_to_freeze();
+   }
+   }
+
+   if (test_suspend_state(SUSPEND_RESUME_NOT_DONE)) {
+   if (resume2_file[0])
+   suspend_early_boot_message(1, SUSPEND_CONTINUE_REQ,
+   "Initrd not properly configured for resuming.");
+   else
+   printk("Suspend2: Initrd not properly configured for 
resuming and no resume2= specified.\n");
}
+   clear_suspend_state(SUSPEND_BOOT_TIME);
 
/* move initrd to rootfs' /old */
sys_fchdir(old_fd);
diff -ruNp 302-init-hooks.patch-old/init/main.c 
302-init-hooks.patch-new/init/main.c
--- 302-init-hooks.patch-old/init/main.c2005-07-06 11:13:20.0 
+1000
+++ 302-init-hooks.patch-new/init/main.c2005-07-04 23:14:19.0 
+1000
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -701,7 +702,9 @@ static int init(void * unused)
 
/*
 * check if there is an early userspace init.  If yes, let it do all
-* the work
+* the work. For suspend2, we assume that it will do the right thing
+* with regard to trying to resume at the right place. When that
+* happens, the BOOT_TIME flag will be cleared.
 */
if (sys_access((const char __user *) "/init", 0) == 0)
execute_command = "/init";

-
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] [8/48] Suspend2 2.1.9.8 for 2.6.12: 353-disable-highmem-tlb-flush-for-copyback.patch

2005-07-05 Thread Nigel Cunningham
diff -ruNp 
354-disable-mce-checking-during-suspend-avoid-smp-deadlock.patch-old/arch/i386/kernel/cpu/mcheck/non-fatal.c
 
354-disable-mce-checking-during-suspend-avoid-smp-deadlock.patch-new/arch/i386/kernel/cpu/mcheck/non-fatal.c
--- 
354-disable-mce-checking-during-suspend-avoid-smp-deadlock.patch-old/arch/i386/kernel/cpu/mcheck/non-fatal.c
2004-12-10 14:26:18.0 +1100
+++ 
354-disable-mce-checking-during-suspend-avoid-smp-deadlock.patch-new/arch/i386/kernel/cpu/mcheck/non-fatal.c
2005-07-04 23:14:20.0 +1000
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include  
 #include 
@@ -58,7 +59,8 @@ static DECLARE_WORK(mce_work, mce_work_f
 
 static void mce_work_fn(void *data)
 { 
-   on_each_cpu(mce_checkregs, NULL, 1, 1);
+   if (!test_suspend_state(SUSPEND_RUNNING))
+   on_each_cpu(mce_checkregs, NULL, 1, 1);
schedule_delayed_work(&mce_work, MCE_RATE);
 } 
 

-
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: reiser4 plugins

2005-07-05 Thread Neil Brown
On Tuesday July 5, [EMAIL PROTECTED] wrote:
> I got it slightly wrong.
> 
> One can have hardlinks to a directory without cycles provided that one
> does not have hardlinks from the children of that directory to any file
> not a child of that directory.  (Mountpoints currently implement that
> restriction.)
> 
> Question: can one implement that lesser restriction above with elegant
> code?  Is the greater restriction below easier to code?  (If no to the
> first and yes to the second is correct, then I can accept the greater
> restriction described below.)


I think the "lesser restriction above" can be implemented elegantly,
but it would require major dcache surgery.

Currently all the dentries of names in a directory are linked to the
dentry of the directory.  As you would have to let a directory have
multiple dentries, it would be best to change that linkage so that the
dentries of names in a directory were linked to the "inode" of that
directory (of which there is still only one).
Thus instead of just having a dentry tree with inodes attached at each
point, you would have a dentry/inode tree with inodes a more integral
part of the tree. (i.e. the path from the root down would be dentry ->
inode -> dentry ->inode -> dentry etc).
This would have major implications for the current code.

The "greater restriction below" should be easy to code providing you
were willing to have two sorts of directories: those which could be
linked (ie. they sometimes look like files) and those which cannot
(they never look like files).  Then for each dentry, you remember the
closest parent which is a can-be-linked directory an make sure a
hard-link will never want to change the can-be-linked directory for
the target.

If you want to be more general, and have only one sort of directory
that just behaves differently in different situations, then it would
be much harder.
You have to make sure both 
 a/ that you never hard link a file that is under a hard-linked
directory to somewhere outside of that hard-linked directory and
 b/ that you never hard link a directory that contains a file which is
hard-linked to somewhere outside that directory.

The first is probably quite manageable.  The second is essentially the
cycle-detection problem.




SUN used to advertise:
  "The network is the computer"
However I think we have all come to realise that the network is the
network, and the computer is the computer.

Now Hans wants to tells that
   "The directory is the file"

but I don't find it any more convincing than SUN's message...




If you really want to change traditional Unix semantics, I would
suggest you get rid of hard-links.  They really are more trouble than
they are worth, and discarding them makes this whole issue moot.


NeilBrown
-
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] update( Documentation -> vfs.txt -> file_system_type );

2005-07-05 Thread Frank Schruefer

Hy,

The current description was tagged as of kernel 2.1.99 - so whatever story
I'll write here should be more truthful than that fossil ;-)


Stone:/usr/src # diff -r -u linux-2.6.13-rc1.UNTOUCHED linux-2.6.13-rc1
--SNIPON---
diff -r -u linux-2.6.13-rc1.UNTOUCHED/Documentation/filesystems/vfs.txt 
linux-2.6.13-rc1/Documentation/filesystems/vfs.txt
--- linux-2.6.13-rc1.UNTOUCHED/Documentation/filesystems/vfs.txt
2005-06-30 01:00:53.0 +0200
+++ linux-2.6.13-rc1/Documentation/filesystems/vfs.txt  2005-07-06 
03:36:23.0 +0200
@@ -126,46 +126,53 @@
 struct file_system_type   
 ===

-This describes the filesystem. As of kernel 2.1.99, the following
+This describes the filesystem. As of kernel 2.6.13, the following
 members are defined:

 struct file_system_type {
-   const char *name;
-   int fs_flags;
-   struct super_block *(*read_super) (struct super_block *, void *, int);
-   struct file_system_type * next;
-};
-
-  name: the name of the filesystem type, such as "ext2", "iso9660",
-   "msdos" and so on
-
-  fs_flags: various flags (i.e. FS_REQUIRES_DEV, FS_NO_DCACHE, etc.)
-
-  read_super: the method to call when a new instance of this
-   filesystem should be mounted
-
-  next: for internal VFS use: you should initialise this to NULL
-
-The read_super() method has the following arguments:
-
-  struct super_block *sb: the superblock structure. This is partially
-   initialised by the VFS and the rest must be initialised by the
-   read_super() method
-
-  void *data: arbitrary mount options, usually comes as an ASCII
-   string
+const char *name;
+int fs_flags;
+struct super_block *(*get_sb)
+   (struct file_system_type *, int, const char *, void *);
+void (*kill_sb) (struct super_block *);
+struct module *owner;
+struct file_system_type * next;
+struct list_head fs_supers;
+   };
+
+  name: The name of the filesystem type, such as "ext2", "iso9660",
+   "msdos" and so on.
+
+  fs_flags: A combination of: FS_REQUIRES_DEV, FS_BINARY_MOUNTDATA,
+   FS_REVAL_DOT, FS_ODD_RENAME (deprecated). See include/linux/fs.h.
+
+  get_sb: The function responsible for returning the super_block structure
+   containing the filesystems blocksize, it's super block,
+   super operations struct s_op (which is the most interesting field
+   filled by this method and a pointer to struct super_operations
+   which describes the next level of the filesystem implementation),
+   the magic byte and max filesize and the like.
+   It is called when a new instance of this filesystem is mounted and
+   replaces the read_super function of former kernels (see porting).
+   As an example of what to do here please look at one of the default
+   functions in the kernel code named 'get_sb_nodev'.
+   The get_sb_nodev functions last parameter is a pointer to a function
+   which would act like the former read_super function just mentioned.
+   The data parameter contains arbitrary mount options passed by the
+   unix mount program, it usually comes as an ASCII string but can
+   be set to come as binary (now please don't ask me where I saw this
+   flag, look at the source, Mr. Skywalker ;-).
+   Return value: New super block on success, ERR_PTR if failed.
+
+  kill_sb: the function which gets called when the sb needs to be destroyed.
+   One generic function for this is 'kill_anon_super', look there for
+   more inspiration.

-  int silent: whether or not to be silent on error
+  owner: This is usually set to the macro 'THIS_MODULE'.

-The read_super() method must determine if the block device specified
-in the superblock contains a filesystem of the type the method
-supports. On success the method returns the superblock pointer, on
-failure it returns NULL.
+  next: Managed by the kernel. Please leave it as NULL.

-The most interesting member of the superblock structure that the
-read_super() method fills in is the "s_op" field. This is a pointer to
-a "struct super_operations" which describes the next level of the
-filesystem implementation.
+  fs_supers: Managed by the kernel. Please leave it as NULL.


 struct super_operations   
--SNIPOFF--
Stone:/usr/src #

--

Thanks,
   Frank Schruefer
   SITEFORUM Software Europe GmbH
   Germany (Thuringia)

-
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: realtime-preempt-2.6.12-final-V0.7.51-01 compile error and more problems

2005-07-05 Thread Lee Revell
On Tue, 2005-07-05 at 18:13 -0700, William Weston wrote:
> Audio without xruns is an RT requirement, IMHO  ;-}
> 

This isn't even an opinion, it's a fact.  If you are capturing data and
your audio handling thread does not get scheduled in (periods_per_buffer
- 1) * period_time time units, you lose that chunk of sound *forever*.

Some people on this list make the ridiculous argument that this is
different from more conventional RT applications because "they can
always record again".  Try telling that to someone who is paying for
studio time; you won't be running a studio for long.  Pro audio is
exactly like controlling a satellite or monitoring a power plant, if you
don't get scheduled in time, it's a fatal error.

In practice you only have to be more reliable than the alternatives,
which are pretty reliable these days.

> > 4) Xruns occur every 10-60 minutes even when the system is
> practically 
> > idle (no playback
> > or recording). When copying large files (between sata disks on two 
> > sil3112 controllers)
> > xruns frequency is much higher.  When sound is used xruns occur
> every 2 
> > or 20 minutes.
> 
> Do these xruns coincide with the RTC 'Read missed before next
> interrupt'
> messages?
> 
> Have you tried running JACK with a larger buffer period size?  Some
> cards

Disable CONFIG_RTC_HISTOGRAM.

Then before you try anything else, check the /proc/latency trace output.
What's the max reported latency?  Is it significantly less than the
xruns?

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: [patch 1/] timers: tsc using for cpu scheduling

2005-07-05 Thread john stultz
On Tue, 2005-07-05 at 21:08 +0400, Ananiev, Leonid I wrote:
>   Not only page faults may increase process priority. Someone can
> write two threads with mutexes so that each thread will spent much less
> than 1 msec for calculations on cpu than lock-unlock mutexes and yield
> cpu to brother which wait mutex unlock and will do the same. Both
> threads will have high priority according to other threads during
> infinite time. The scheduler will not see the time spent by both
> considered threads on cpu.

Oh, I don't doubt there is a problem. I'm just asking if using the TSC
is really the only way to properly ding the process? 

I'm not a scheduler guy, so forgive my ignorance, but since the TSC may
not be available everywhere, might there be an alternative way to ding
the process? Surely something is keeping track of how many pagefaults a
process causes. Maybe a counter of how many times it has switched off
the cpu within the current tick? Couldn't these values be used as
scheduler weights?

I realize that ideally having super a fine grained notion of how much
cputime every process has had executing would be great. But it isn't
possible everywhere, so what can we do instead?

>   The cpu scheduler does not need in real time value. It is need
> the number of cpu clocks spent for considered task/thread for priority
> calculation. It is not need to modify TSC tick rate for cpu scheduling.

The problem is that some CPUs give you time, others give you work, and
sometimes those values are related. If you really want to re-define
sched_clock so that it gives you some vague work-unit instead of
nanoseconds, then that's fine, but it will need some additional
documentation and its likely you don't want to use the cycles_2_ns()
functions.

I don't really care too much about changes to sched_clock() as its
always been a special case interface just for the scheduler. I just want
it documented well enough so others don't think its a valid timekeeping
interface.


>   The TSC can be used for priority calculation in NUMA because we
> do not compare TSCs of different cpu's. 

If you can guarantee that, then great! I know that was the original
intention, but some folks had problems with it which resulting in the
conditional #if NUMA code.


> > there are other cases where the TSC cannot be used for
> > sched_clock, such as on systems that do not have TSCs...
> 
> > You're patch removes any fallback for the case where the TSC cannot be
> used.
> No. Now there is two global kernel values: cyc2ns_scale and use_tsc.
> We may say that
>   use_tsc = (cyc2ns_scale != 0);
> Now instead of 
>  'if (use_tsc) than ...'
>   I propose to write
>  'if ((cyc2ns_scale != 0) than...'


That's fine if its what you propose, I just didn't see it in your patch.
As it was written it would have broken NUMAQ and other systems that do
not have usable TSCs (ie: i386/i486).

> > This I don't agree with because there are situations where we cannot
> use
> the TSC.
> 
> The patch says that if there are PMT and TSC timers concurrently than
> Linux will use TSC for CPU scheduler priority calculatin.
> 1 millisecond jiffies on the base of PMT were used patch in Linux before
> this. So user can see that if CPU has TSC it is worst than CPU which has
> not TSC because Linux choose slightly more precise but exactly 100
> times more gross variant in this case.

Try re-spinning the patch to address the above issues and I'll happily
review it again. I just want to make sure the issue is addressed
properly and doesn't break other systems.

thanks
-john



-
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/


BOUNCE 3d@Softimage.COM: Non-member submission from [linux-kernel@vger.kernel.org]

2005-07-05 Thread owner-3d
>From [EMAIL PROTECTED] Tue Jul  5 21:41:25 2005
Received: from mtl-smtpgw2.global.avidww.com (mtl-smtpgw2.global.avidww.com 
[172.24.33.104])
by paperboy.global.avidww.com (8.12.9/8.12.6) with ESMTP id 
j661fPvU029215
for <[EMAIL PROTECTED]>; Tue, 5 Jul 2005 21:41:25 -0400
Received: from softgate1.softimage.com ([172.24.33.30]) by 
mtl-smtpgw2.global.avidww.com with Microsoft SMTPSVC(5.0.2195.6713);
 Tue, 5 Jul 2005 21:40:08 -0400
Received: from servweb.santerne.fr (IDENT:[EMAIL PROTECTED] [127.0.0.1])
by softgate1.softimage.com (8.12.11/8.12.1) with SMTP id j660aaqR004775
for <[EMAIL PROTECTED]>; Tue, 5 Jul 2005 20:36:37 -0400
Received: from intratech.pw3.vinci-energies.net (intratech [192.9.15.89])
by servweb.santerne.fr (8.13.3/8.13.3) with ESMTP id j661e3oJ008918
for <[EMAIL PROTECTED]>; Wed, 6 Jul 2005 03:40:03 +0200
Received: from pctrend (smtp.pw3.vinci-energies.net [192.9.15.213])
by intratech.pw3.vinci-energies.net (8.12.8/linuxconf) with SMTP id 
j661hdmu001439
for <[EMAIL PROTECTED]>; Wed, 6 Jul 2005 03:43:39 +0200
Message-Id: <[EMAIL PROTECTED]>
From: linux-kernel@vger.kernel.org
To: [EMAIL PROTECTED]
Subject: SPAM!!! Mail System Error - Returned Mail
Date: Wed, 6 Jul 2005 03:44:04 +0200
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.
Content-Type: multipart/mixed; boundary="--=_42CB3677.3193A1A0"
X-Spam-Flag: YES
X-Spam-Status: Yes, score=5.0 required=5.0 tests=FORGED_MUA_OUTLOOK,
NO_REAL_NAME,RCVD_IN_BL_SPAMCOP_NET autolearn=no version=3.0.2-gr1
X-Spam-Level: *
X-Spam-Checker-Version: SpamAssassin 3.0.2-gr1 (2004-11-16) on 
servweb.santerne.fr
X-OriginalArrivalTime: 06 Jul 2005 01:40:08.0869 (UTC) 
FILETIME=[A488A550:01C581CB]

This is a multi-part message in MIME format.

=_42CB3677.3193A1A0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by softgate1.softimage.com 
id j660aaqR004775

-- D=E9but de Rapport SpamAssassin -
Ce message est probablement du SPAM (message non sollicit=E9 envoy=E9 en
masse, publicit=E9, escroquerie...).

Cette notice a =E9t=E9 ajout=E9e par le syst=E8me d'analyse "SpamAssassin=
" sur
votre serveur de courrier "servweb.santerne.fr", pour vous
aider =E0 identifier ce type de messages.

Le syst=E8me SpamAssassin ajoute un en-t=EAte "X-Spam-Flag: YES" aux
messages qu'il consid=E8re comme =E9tant probablement du Spam.
Vous pouvez si vous le souhaitez utiliser cette caract=E9ristique
pour r=E9gler un filtre dans votre logiciel de lecture de courrier,
afin de d=E9truire ou de classer =E0 part ce type de message.

Si ce robot a classifi=E9 incorrectement un message qui vous =E9tait
destin=E9, ou pour toute question, veuillez contacter l'administrateur
du syst=E8me par e-mail =E0 the administrator of that system .

Voir http://spamassassin.apache.org/tag/ pour plus de d=E9tails (en angla=
is).

D=E9tails de l'analyse du message:   (5.0 points, 5.0 requis)
 0.2 NO_REAL_NAME   Le champ From: ne contient pas le nom complet=
 de l'exp=E9diteur
 1.8 RCVD_IN_BL_SPAMCOP_NET RBL: Relais list=E9 dans http://spamcop.net/b=
l.shtml
 [Blocked - see ]
 3.0 FORGED_MUA_OUTLOOK Message falsifi=E9 pr=E9tendant provenir du l=
ogiciel MS Outlook

 Fin de Rapport SpamAssassin -

Le message original n'=E9tant pas au format text brut, il est peut-=EAtre
dangereux de l'ouvrir avec votre logiciel e-mail ; en particulier il
pourrait contenir un virus, ou confirmer =E0 l'exp=E9diteur que votre
adresse e-mail est active, et peut recevoir du spam. Si vous voulez
lire ce message, et n'=EAtes pas certain de la s=E9curit=E9 de votre logi=
ciel
e-mail, il est plus prudent d'enregistrer ce message sur votre disque
dur, et de l'afficher ensuite avec un =E9diteur de texte.


=_42CB3677.3193A1A0
Content-Type: message/rfc822; x-spam-type=original
Content-Description: original message before SpamAssassin
Content-Disposition: attachment

X-Envelope-From: 
X-Envelope-To: <[EMAIL PROTECTED]>
Received: from intratech.pw3.vinci-energies.net (intratech [192.9.15.89]) by 
servweb.santerne.fr;
Received: from pctrend (smtp.pw3.vinci-energies.net [192.9.15.213])
by intratech.pw3.vinci-energies.net (8.12.8/linuxconf) with SMTP id 
j661hdmu001439
for <[EMAIL PROTECTED]>; Wed, 6 Jul 2005 03:43:39 +0200
Message-Id: <[EMAIL PROTECTED]>
From: linux-kernel@vger.kernel.org
To: [EMAIL PROTECTED]
Subject: Mail System Error - Returned Mail
Date: Wed, 6 Jul 2005 03:44:04 +0200
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.26

Re: slab not freeing with current -git

2005-07-05 Thread Christoph Lameter
On Wed, 6 Jul 2005, Anton Blanchard wrote:

>  
> > That is the issue. It should fall back to kmalloc. One piece of the 
> > patchset dropped out between Andrew and Linus.
> 
> That helped, but I still had lots of free memory in the request_queue
> slab. Giving kmem_cache_alloc_node the same treatment fixed it, although
> I wonder if we just shouldnt be passing in -1.

No. No. -1 is the sign for undetermined that is also used in other pieces 
of slab.c. Meaning do not do node specific allocs. The fix  
should only modify kmem_cache_alloc_node. But we wont need that if the 
new slab allocator would get in. Andrew?

Also if powerpc wants to use node specific allocations for block devices 
then the powerpc arch needs to supply a pcibus_to_node function that does 
return the correct node for the pcibus.

Index: linux-2.6.git/mm/slab.c
===
--- linux-2.6.git.orig/mm/slab.c2005-07-05 17:03:30.0 -0700
+++ linux-2.6.git/mm/slab.c 2005-07-05 18:25:20.0 -0700
@@ -2372,6 +2372,9 @@
struct slab *slabp;
kmem_bufctl_t next;
 
+   if (nodeid == -1)
+   return kmem_cache_alloc_node(cachep, flags);
+
for (loop = 0;;loop++) {
struct list_head *q;
 
-
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: reiser4 plugins

2005-07-05 Thread Hubert Chan
On Tue, 05 Jul 2005 20:50:08 -0400 EDT, "Alexander G. M. Smith" <[EMAIL 
PROTECTED]> said:

> That sounds equivalent to no hard links (other than the usual parent
> directory one).  If there's any directory with two links to it, then
> there will be a cycle somewhere!

What we want is no directed cycles.  That is A is the parent of B is the
parent of C is the parent of A.  We don't care about A is the parent of
B is the parent of C; A is the parent of B is the parent of C.

OK, here's a random idea that just popped into my head, and to which
I've given little thought (read: none whatsoever), and may be the
stupidest idea ever proposed on LKML, but thought I would just toss it
out to see if it could stimulate someone to come up with something
better (read: sane):  Conceptually, foo/ is just a symlink to
/meta/[filesystem]/[inode of foo].

And a question: is it feasible to store, for each inode, its parent(s),
instead of just the hard link count?

-- 
Hubert Chan <[EMAIL PROTECTED]> - http://www.uhoreg.ca/
PGP/GnuPG key: 1024D/124B61FA
Fingerprint: 96C5 012F 5F74 A5F7 1FF7  5291 AF29 C719 124B 61FA
Key available at wwwkeys.pgp.net.   Encrypted e-mail preferred.

-
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: realtime-preempt-2.6.12-final-V0.7.51-01 compile error and more problems

2005-07-05 Thread William Weston
On Wed, 6 Jul 2005, Carlo Scarfoglio wrote:

> Compilation stops at this point:
> 
> make[1]: `arch/i386/kernel/asm-offsets.s' is up to date.
>CHK include/linux/compile.h
>CHK usr/initramfs_list
>CC  net/ipv4/netfilter/ip_conntrack_proto_tcp.o
> net/ipv4/netfilter/ip_conntrack_proto_tcp.c: In function 
> `tcp_print_conntrack':
> net/ipv4/netfilter/ip_conntrack_proto_tcp.c:333: error: `tcp_lock' 
> undeclared (first use in this function)
> net/ipv4/netfilter/ip_conntrack_proto_tcp.c:333: error: (Each undeclared 
> identifier is reported only once
> net/ipv4/netfilter/ip_conntrack_proto_tcp.c:333: error: for each 
> function it appears in.)
> net/ipv4/netfilter/ip_conntrack_proto_tcp.c:333: warning: type defaults 
> to `int' in declaration of `type name'
> etc. etc..
> 
> Most likely it depends on the redefinition of DECLARE_RWLOCK in lockhelp.h

Same here...

> More problems
> 
> Patch 7.50-48 has been the first rt kernel that compiled and booted 
> cleanly on my system.

-50-43 is the most recent out of the -50 series that's compiled and
operated cleanly on my Athlon box.  So far, it appears to be rock-solid.  
I'd recommend giving it a try if you haven't already.

> I'm testing the rt kernels because I want to use jack as my system sound 
> mixer/router
> and to record lp's with my ice1712-based sound card. I have no rt 
> requrements, of course,
> but I want to get rid of xruns. Kernel 2.6.12 vanilla is quite good 
> already (a big improvement
> over previous kernels) but still ...

Audio without xruns is an RT requirement, IMHO  ;-}

> Patch 7.50-48 been running for two days now and seems pretty stable but:
> 
> 1) My logs are filled with Apic errors all like this
> 
> Jul  5 04:30:01 linux kernel: APIC error on CPU0: 02(02)
> 
> every 2 seconds, or minute, at random. I've never seen these messages 
> before with vanilla kernels,
> so it's a bit weird.

Have you tried disabling CONFIG_X86_IOAPIC_FAST?  This is new in the
realtime-preempt patches.  It's currently stable on 3 out of the 4 boxes
I'm testing RT on.  On the fourth (P4 with an SIS chipset), it didn't seem
to make any difference.  I finally had to switch from APIC to PIC (in
BIOS) to get the APIC errors on CPU0 to go away.

> 2) Whenever I play an mp3 or watch a movie (through jack) I get 
> thousands of times these errors in the logs
> 
> Jul  5 20:45:56 linux kernel: `IRQ 8'[828] is being piggy. 
> need_resched=0, cpu=0
> Jul  5 20:45:56 linux kernel: Read missed before next interrupt
> Jul  5 20:45:56 linux kernel: wow!  That was a 12 millisec bump
> Jul  5 20:45:56 linux kernel: bug in rtc_read(): called in state S_IDLE!
> Jul  5 20:45:56 linux kernel: `IRQ 8'[828] is being piggy. 
> need_resched=0, cpu=0
> Jul  5 20:45:56 linux kernel: Read missed before next interrupt
> Jul  5 20:45:56 linux kernel: wow!  That was a 3 millisec bump
> Jul  5 20:45:56 linux kernel: bug in rtc_read(): called in state S_IDLE!
> 
> This is a known issue, RTC  interrupts are missed. I have noticed it 
> many times when ntp is
> running. It stops working after a few minutes of playing when the the 
> error exceeds 500 PPM.
> But I thought that ntp compared external reference clocks to the system 
> timer, so the system
> was missing int 0, not int 8.  My mobo has a crappy timer anyway. I had 
> to reduce the tick to 9934
> in order to allow ntp to run.

Is the RTC the only thing on IRQ 8?  The last time I saw the 'IRQ 8 is 
being piggy' messages on my Athlon box was when the RTC was sharing IRQ 8 
with either the video or the USB.

> 3) I had to disable polling of the cpu temperature by kacpid because 
> whenever it did the sound
> stopped for 1-3 seconds. The polling took longer and longer after a few 
> hours of uptime.
> The nice thing is, it caused no xruns. Kernel 2.6.12 vanilla has the 
> same problem, though.
> 
> 4) Xruns occur every 10-60 minutes even when the system is practically 
> idle (no playback
> or recording). When copying large files (between sata disks on two 
> sil3112 controllers)
> xruns frequency is much higher.  When sound is used xruns occur every 2 
> or 20 minutes.

Do these xruns coincide with the RTC 'Read missed before next interrupt'
messages?

Have you tried running JACK with a larger buffer period size?  Some cards
are perfectly happy with -p64, while others need -p128 or -p256 to be xrun
free for an extended time.  In the past, I've seen a difference between
running with 2 and 3 buffer periods (-n2 or -n3).

Also, have you tried bumping up JACK's RT priority?  If JACK is running at 
a lower priority than the IRQ threads for your SATA, then disk activity 
will most likely cause additional xruns.  I've had good luck running JACK 
with '-R -P60', which sets it's realtime priority above all the IRQ 
threads.

You may also want to run the IRQ threads for your audio hardware at a 
slightly higher RT priority than the rest of the IRQ threads.

> This is a nForce2-mobo (Abit NF7-S V 2.0), Athlon 2800, 1 GB 

Re: slab not freeing with current -git

2005-07-05 Thread Anton Blanchard
 
> That is the issue. It should fall back to kmalloc. One piece of the 
> patchset dropped out between Andrew and Linus.

That helped, but I still had lots of free memory in the request_queue
slab. Giving kmem_cache_alloc_node the same treatment fixed it, although
I wonder if we just shouldnt be passing in -1.

Anton

Index: foobar2/mm/slab.c
===
--- foobar2.orig/mm/slab.c  2005-07-06 10:47:47.950435997 +1000
+++ foobar2/mm/slab.c   2005-07-06 10:59:59.945684235 +1000
@@ -2372,6 +2372,9 @@
struct slab *slabp;
kmem_bufctl_t next;
 
+   if (nodeid == -1)
+   return kmem_cache_alloc(cachep, flags);
+
for (loop = 0;;loop++) {
struct list_head *q;
 
@@ -2443,6 +2446,9 @@
 {
kmem_cache_t *cachep;
 
+   if (node == -1)
+   return kmalloc(size, flags);
+
cachep = kmem_find_general_cachep(size, flags);
if (unlikely(cachep == NULL))
return NULL;
-
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] char: Add Dell Systems Management Base driver

2005-07-05 Thread randy_dunlap
On Tue, 5 Jul 2005 19:13:34 -0500 Doug Warzecha wrote:

| This patch adds the Dell Systems Management Base driver.
| 
| The Dell Systems Management Base driver is a character driver that
| implements ioctls for Dell systems management software to use to
| communicate with the driver.  The driver provides support for Dell
| systems management software to manage the following Dell PowerEdge
| systems: 300, 1300, 1400, 400SC, 500SC, 1500SC, 1550, 600SC, 1600SC,
| 650, 1655MC, 700, and 750.
| 
| By making a contribution to this project, I certify that:
| The contribution was created in whole or in part by me and
| I have the right to submit it under the open source license
| indicated in the file.

Could you possibly reply to some earlier comments that have been posted
from Chris Wedgwood and me (and possibly others) instead of
ignoring them?

e.g.,
http://marc.theaimsgroup.com/?l=linux-kernel&m=111984209416906&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=111966319714417&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=111895964717480&w=2
and others.

Thanks,
---
~Randy
-
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] char: Add Dell Systems Management Base driver

2005-07-05 Thread Chris Wedgwood
On Tue, Jul 05, 2005 at 07:13:34PM -0500, Doug Warzecha wrote:

> This patch adds the Dell Systems Management Base driver.

You keep posting this driver without explaining/showing how it's used.
Could you perhaps give some more details here please?
-
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: [git patches] IDE update

2005-07-05 Thread Linus Torvalds


On Wed, 6 Jul 2005, Grant Coady wrote:
> 
> Executive Summary

Btw, can you try this same thing (or at least a subset) with a large file
on a filesystem? Does that show the same pattern, or is it always just the 
raw device?

Linus
-
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: reiser4 plugins

2005-07-05 Thread Alexander G. M. Smith
Hans Reiser wrote on Tue, 05 Jul 2005 16:56:02 -0700:
> One can have hardlinks to a directory without cycles provided that one
> does not have hardlinks from the children of that directory to any file
> not a child of that directory.  (Mountpoints currently implement that
> restriction.)
> 
> Question: can one implement that lesser restriction above with elegant
> code?  Is the greater restriction below easier to code?  (If no to the
> first and yes to the second is correct, then I can accept the greater
> restriction described below.)
> 
> One can have hardlinks to directories
> without cycles provided that one does not allow any child of the
> directory to have a hardlink.

That sounds equivalent to no hard links (other than the usual parent
directory one).  If there's any directory with two links to it, then
there will be a cycle somewhere!

The tradeoff is the size of the cycle to the amount of memory and other
resources needed to clean up the cycle when rename/deletion changes the
directory graph structure.  Various artificial limits can be imposed,
such as not creating a link which would result in a cycle of more than
some number of files/directories (adjust so that cleanup fits in the
memory size of the machine).  Or just fail the cleanup if it is too
complex (user deletes individual items in the cycle then tries again).

Perhaps you are thinking about the speed improvement for cycle checking
that comes from marking directories as known to not contain children
pointing outside the graph rooted at that directory.  Then that directory
can be treated as an ordinary directory in the cycle cleanup procedure,
avoiding the need to trace down the links to all its descendants.  That's
essentially what your mount point restriction is.

- Alex
-
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   >