dm: fix memory leak in dm_create_persistent() when starting metadata update thread fails

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=851a8a7fd451db3dcd5d44d784083f0f66b24d57
Commit: 851a8a7fd451db3dcd5d44d784083f0f66b24d57
Parent: cb32da0416b823b7f4b65e7e85d6cba16ca4d1e1
Author: Jesper Juhl [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 00:49:08 2007 -0700
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:38:22 2007 -0700

dm: fix memory leak in dm_create_persistent() when starting metadata update 
thread fails

If, in dm_create_persistent(), the call to create_singlethread_workqueue()
fails then we'll return without freeing the memory allocated to 'ps', thus
leaking sizeof(struct pstore) bytes.  This patch fixes the leak.

Signed-off-by: Jesper Juhl [EMAIL PROTECTED]
Acked-by: Alasdair G Kergon [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 drivers/md/dm-exception-store.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index 3d65917..8fe81e1 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -623,6 +623,7 @@ int dm_create_persistent(struct exception_store *store)
 
ps-metadata_wq = create_singlethread_workqueue(ksnaphd);
if (!ps-metadata_wq) {
+   kfree(ps);
DMERR(couldn't start header metadata update thread);
return -ENOMEM;
}
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


fbdev: make fb_append_extra_logo() depend on fb=y

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=04e08d0e9b936b91e761454b3134e260c4f50696
Commit: 04e08d0e9b936b91e761454b3134e260c4f50696
Parent: 851a8a7fd451db3dcd5d44d784083f0f66b24d57
Author: Arnd Bergmann [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 00:49:09 2007 -0700
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:38:22 2007 -0700

fbdev: make fb_append_extra_logo() depend on fb=y

We can't show the extra logo from boot code if FB is built as a module.
Make the FB_LOGO_EXTRA depend on FB=y.

Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
Cc: Al Viro [EMAIL PROTECTED]
Cc: Antonino A. Daplas [EMAIL PROTECTED]
Acked-by: Geert Uytterhoeven [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 drivers/video/logo/Kconfig |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig
index da219c0..9de1c11 100644
--- a/drivers/video/logo/Kconfig
+++ b/drivers/video/logo/Kconfig
@@ -12,7 +12,7 @@ if LOGO
 
 config FB_LOGO_EXTRA
bool
-   depends on FB
+   depends on FB=y
default y if SPU_BASE
 
 config LOGO_LINUX_MONO
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


serial: add early_serial_setup() back to header file

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b187f180cc942e50007aa039f8e3a620ee5f3171
Commit: b187f180cc942e50007aa039f8e3a620ee5f3171
Parent: 04e08d0e9b936b91e761454b3134e260c4f50696
Author: Yinghai Lu [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 00:49:10 2007 -0700
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:38:22 2007 -0700

serial: add early_serial_setup() back to header file

early_serial_setup was removed from serial.h, but forgot to put in
serial_8250.h

Signed-off-by: Yinghai Lu [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 arch/frv/kernel/setup.c   |1 +
 arch/mips/basler/excite/excite_setup.c|1 +
 arch/mips/gt64120/wrppmc/setup.c  |1 +
 arch/mips/mips-boards/atlas/atlas_setup.c |1 +
 arch/mips/mips-boards/sead/sead_setup.c   |1 +
 arch/mips/mipssim/sim_setup.c |1 +
 arch/mips/pmc-sierra/msp71xx/msp_serial.c |1 +
 arch/mips/pmc-sierra/yosemite/setup.c |1 +
 arch/ppc/platforms/4xx/bamboo.c   |1 +
 arch/ppc/platforms/4xx/bubinga.c  |1 +
 arch/ppc/platforms/4xx/cpci405.c  |1 +
 arch/ppc/platforms/4xx/ebony.c|1 +
 arch/ppc/platforms/4xx/luan.c |1 +
 arch/ppc/platforms/4xx/ocotea.c   |1 +
 arch/ppc/platforms/4xx/taishan.c  |1 +
 arch/ppc/platforms/4xx/yucca.c|1 +
 arch/ppc/platforms/85xx/sbc8560.c |1 +
 arch/ppc/platforms/chestnut.c |1 +
 arch/ppc/platforms/ev64260.c  |1 +
 arch/ppc/platforms/radstone_ppc7d.c   |1 +
 arch/ppc/platforms/spruce.c   |1 +
 drivers/parisc/superio.c  |1 +
 drivers/serial/8250_hp300.c   |1 +
 include/linux/serial_8250.h   |2 ++
 24 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/arch/frv/kernel/setup.c b/arch/frv/kernel/setup.c
index c1c32e4..a74c087 100644
--- a/arch/frv/kernel/setup.c
+++ b/arch/frv/kernel/setup.c
@@ -29,6 +29,7 @@
 #include linux/serial.h
 #include linux/serial_core.h
 #include linux/serial_reg.h
+#include linux/serial_8250.h
 
 #include asm/setup.h
 #include asm/irq.h
diff --git a/arch/mips/basler/excite/excite_setup.c 
b/arch/mips/basler/excite/excite_setup.c
index 2f0e4c0..5600318 100644
--- a/arch/mips/basler/excite/excite_setup.c
+++ b/arch/mips/basler/excite/excite_setup.c
@@ -26,6 +26,7 @@
 #include linux/tty.h
 #include linux/serial_core.h
 #include linux/serial.h
+#include linux/serial_8250.h
 #include linux/ioport.h
 #include linux/spinlock.h
 #include asm/bootinfo.h
diff --git a/arch/mips/gt64120/wrppmc/setup.c b/arch/mips/gt64120/wrppmc/setup.c
index ea96552..ed58c13 100644
--- a/arch/mips/gt64120/wrppmc/setup.c
+++ b/arch/mips/gt64120/wrppmc/setup.c
@@ -14,6 +14,7 @@
 #include linux/tty.h
 #include linux/serial.h
 #include linux/serial_core.h
+#include linux/serial_8250.h
 #include linux/pm.h
 
 #include asm/io.h
diff --git a/arch/mips/mips-boards/atlas/atlas_setup.c 
b/arch/mips/mips-boards/atlas/atlas_setup.c
index 1cc6ebb..c68358a 100644
--- a/arch/mips/mips-boards/atlas/atlas_setup.c
+++ b/arch/mips/mips-boards/atlas/atlas_setup.c
@@ -22,6 +22,7 @@
 #include linux/tty.h
 #include linux/serial.h
 #include linux/serial_core.h
+#include linux/serial_8250.h
 
 #include asm/cpu.h
 #include asm/bootinfo.h
diff --git a/arch/mips/mips-boards/sead/sead_setup.c 
b/arch/mips/mips-boards/sead/sead_setup.c
index bb80140..5f70eaf 100644
--- a/arch/mips/mips-boards/sead/sead_setup.c
+++ b/arch/mips/mips-boards/sead/sead_setup.c
@@ -23,6 +23,7 @@
 #include linux/tty.h
 #include linux/serial.h
 #include linux/serial_core.h
+#include linux/serial_8250.h
 
 #include asm/cpu.h
 #include asm/bootinfo.h
diff --git a/arch/mips/mipssim/sim_setup.c b/arch/mips/mipssim/sim_setup.c
index 60e6690..17819b5 100644
--- a/arch/mips/mipssim/sim_setup.c
+++ b/arch/mips/mipssim/sim_setup.c
@@ -26,6 +26,7 @@
 #include linux/tty.h
 #include linux/serial.h
 #include linux/serial_core.h
+#include linux/serial_8250.h
 
 #include asm/cpu.h
 #include asm/bootinfo.h
diff --git a/arch/mips/pmc-sierra/msp71xx/msp_serial.c 
b/arch/mips/pmc-sierra/msp71xx/msp_serial.c
index c41b53f..e25bac5 100644
--- a/arch/mips/pmc-sierra/msp71xx/msp_serial.c
+++ b/arch/mips/pmc-sierra/msp71xx/msp_serial.c
@@ -32,6 +32,7 @@
 #include asm/io.h
 #include asm/processor.h
 #include asm/serial.h
+#include linux/serial_8250.h
 
 #include msp_prom.h
 #include msp_int.h
diff --git a/arch/mips/pmc-sierra/yosemite/setup.c 
b/arch/mips/pmc-sierra/yosemite/setup.c
index 6a6e15e..f7f93ae 100644
--- a/arch/mips/pmc-sierra/yosemite/setup.c
+++ b/arch/mips/pmc-sierra/yosemite/setup.c
@@ -39,6 +39,7 @@
 #include linux/tty.h
 #include linux/serial.h
 #include linux/serial_core.h
+#include linux/serial_8250.h
 
 #include 

Fix compile failure in arch/powerpc/kernel/pci-common.c

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4f3731da16678026a564b1d7ae218131e4af6810
Commit: 4f3731da16678026a564b1d7ae218131e4af6810
Parent: 8b4a40809e5330c9da5d20107d693d92d73b31dc
Author: Tony Breeds [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 11:03:55 2007 +1000
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Wed Jul 18 10:17:39 2007 -0700

Fix compile failure in arch/powerpc/kernel/pci-common.c

This fixes the fallout from the recent powerpc merge (commit
489de30259e667d7bc47da9da44a0270b050cd97):

   CC  arch/powerpc/kernel/pci-common.o
  arch/powerpc/kernel/pci-common.c:160: error: conflicting types for 
'pcibios_add_platform_entries'
  include/linux/pci.h:889: error: previous declaration of 
'pcibios_add_platform_entries' was here

Signed-off-by: Tony Breeds [EMAIL PROTECTED]
Tested-by: Bret Towe [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 arch/powerpc/kernel/pci-common.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index faf5ef3..94b4a02 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -156,11 +156,14 @@ static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, 
NULL);
 #endif /* CONFIG_PPC_OF */
 
 /* Add sysfs properties */
-void pcibios_add_platform_entries(struct pci_dev *pdev)
+int pcibios_add_platform_entries(struct pci_dev *pdev)
 {
 #ifdef CONFIG_PPC_OF
-   device_create_file(pdev-dev, dev_attr_devspec);
+   return device_create_file(pdev-dev, dev_attr_devspec);
+#else
+   return 0;
 #endif /* CONFIG_PPC_OF */
+
 }
 
 char __init *pcibios_setup(char *str)
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Revert [POWERPC] Do firmware feature fixups after features are initialised

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=826ea8f22cf612d534f33c492c98f7895043bfd1
Commit: 826ea8f22cf612d534f33c492c98f7895043bfd1
Parent: 4f3731da16678026a564b1d7ae218131e4af6810
Author: Tony Breeds [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 16:17:48 2007 +1000
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Wed Jul 18 10:17:39 2007 -0700

Revert [POWERPC] Do firmware feature fixups after features are initialised

This reverts commit 5a26f6bbb767d7ad23311a1e81cfdd2bebefb855.

The original patch causes boot failures when built with ppc64_defconfig.  
The
quickest fix is to revert it while alterates are investigated.

Signed-off-by: Tony Breeds [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 arch/powerpc/kernel/setup_64.c |   12 
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index bc43bba..6018178 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -350,11 +350,13 @@ void __init setup_system(void)
 {
DBG( - setup_system()\n);
 
-   /* Apply CPUs-specific fixups to kernel text (nop out sections
-* not relevant to this CPU)
+   /* Apply the CPUs-specific and firmware specific fixups to kernel
+* text (nop out sections not relevant to this CPU or this firmware)
 */
do_feature_fixups(cur_cpu_spec-cpu_features,
  __start___ftr_fixup, __stop___ftr_fixup);
+   do_feature_fixups(powerpc_firmware_features,
+ __start___fw_ftr_fixup, __stop___fw_ftr_fixup);
 
/*
 * Unflatten the device-tree passed by prom_init or kexec
@@ -392,12 +394,6 @@ void __init setup_system(void)
if (ppc_md.init_early)
ppc_md.init_early();
 
-   /* Apply firmware specific fixups to kernel text (nop out
-* sections not relevant to this firmware)
-*/
-   do_feature_fixups(powerpc_firmware_features,
- __start___fw_ftr_fixup, __stop___fw_ftr_fixup);
-
/*
 * We can discover serial ports now since the above did setup the
 * hash table management for us, thus ioremap works. We do that early
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


add kstrndup

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1e66df3ee301209f4a38df097d7cc5cb9b367a3f
Commit: 1e66df3ee301209f4a38df097d7cc5cb9b367a3f
Parent: 8b4a40809e5330c9da5d20107d693d92d73b31dc
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:02 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:39 2007 -0700

add kstrndup

Add a kstrndup function, modelled on strndup.  Like strndup this
returns a string copied into its own allocated memory, but it copies
no more than the specified number of bytes from the source.

Remove private strndup() from irda code.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Cc: Andrew Morton [EMAIL PROTECTED]
Cc: Randy Dunlap [EMAIL PROTECTED]
Cc: YOSHIFUJI Hideaki [EMAIL PROTECTED]
Cc: Akinobu Mita [EMAIL PROTECTED]
Cc: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Cc: Al Viro [EMAIL PROTECTED]
Cc: Panagiotis Issaris [EMAIL PROTECTED]
Cc: Rene Scharfe [EMAIL PROTECTED]
---
 include/linux/string.h  |1 +
 mm/util.c   |   26 --
 net/irda/irias_object.c |   43 +--
 3 files changed, 30 insertions(+), 40 deletions(-)

diff --git a/include/linux/string.h b/include/linux/string.h
index 7f2eb6a..ee5e9cc 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -105,6 +105,7 @@ extern void * memchr(const void *,int,__kernel_size_t);
 #endif
 
 extern char *kstrdup(const char *s, gfp_t gfp);
+extern char *kstrndup(const char *s, size_t len, gfp_t gfp);
 extern void *kmemdup(const void *src, size_t len, gfp_t gfp);
 
 #ifdef __cplusplus
diff --git a/mm/util.c b/mm/util.c
index 78f3783..bf340d8 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -6,7 +6,6 @@
 
 /**
  * kstrdup - allocate space for and copy an existing string
- *
  * @s: the string to duplicate
  * @gfp: the GFP mask used in the kmalloc() call when allocating memory
  */
@@ -27,6 +26,30 @@ char *kstrdup(const char *s, gfp_t gfp)
 EXPORT_SYMBOL(kstrdup);
 
 /**
+ * kstrndup - allocate space for and copy an existing string
+ * @s: the string to duplicate
+ * @max: read at most @max chars from @s
+ * @gfp: the GFP mask used in the kmalloc() call when allocating memory
+ */
+char *kstrndup(const char *s, size_t max, gfp_t gfp)
+{
+   size_t len;
+   char *buf;
+
+   if (!s)
+   return NULL;
+
+   len = strnlen(s, max);
+   buf = kmalloc_track_caller(len+1, gfp);
+   if (buf) {
+   memcpy(buf, s, len);
+   buf[len] = '\0';
+   }
+   return buf;
+}
+EXPORT_SYMBOL(kstrndup);
+
+/**
  * kmemdup - duplicate region of memory
  *
  * @src: memory region to duplicate
@@ -80,7 +103,6 @@ EXPORT_SYMBOL(krealloc);
 
 /*
  * strndup_user - duplicate an existing string from user space
- *
  * @s: The string to duplicate
  * @n: Maximum number of bytes to copy, including the trailing NUL.
  */
diff --git a/net/irda/irias_object.c b/net/irda/irias_object.c
index 4adaae2..cf30245 100644
--- a/net/irda/irias_object.c
+++ b/net/irda/irias_object.c
@@ -36,39 +36,6 @@ hashbin_t *irias_objects;
  */
 struct ias_value irias_missing = { IAS_MISSING, 0, 0, 0, {0}};
 
-/*
- * Function strndup (str, max)
- *
- *My own kernel version of strndup!
- *
- * Faster, check boundary... Jean II
- */
-static char *strndup(char *str, size_t max)
-{
-   char *new_str;
-   int len;
-
-   /* Check string */
-   if (str == NULL)
-   return NULL;
-   /* Check length, truncate */
-   len = strlen(str);
-   if(len  max)
-   len = max;
-
-   /* Allocate new string */
-   new_str = kmalloc(len + 1, GFP_ATOMIC);
-   if (new_str == NULL) {
-   IRDA_WARNING(%s: Unable to kmalloc!\n, __FUNCTION__);
-   return NULL;
-   }
-
-   /* Copy and truncate */
-   memcpy(new_str, str, len);
-   new_str[len] = '\0';
-
-   return new_str;
-}
 
 /*
  * Function ias_new_object (name, id)
@@ -90,7 +57,7 @@ struct ias_object *irias_new_object( char *name, int id)
}
 
obj-magic = IAS_OBJECT_MAGIC;
-   obj-name = strndup(name, IAS_MAX_CLASSNAME);
+   obj-name = kstrndup(name, IAS_MAX_CLASSNAME, GFP_ATOMIC);
if (!obj-name) {
IRDA_WARNING(%s(), Unable to allocate name!\n,
 __FUNCTION__);
@@ -360,7 +327,7 @@ void irias_add_integer_attrib(struct ias_object *obj, char 
*name, int value,
}
 
attrib-magic = IAS_ATTRIB_MAGIC;
-   attrib-name = strndup(name, IAS_MAX_ATTRIBNAME);
+   attrib-name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC);
 
/* Insert value */
attrib-value = irias_new_integer_value(value);
@@ -404,7 +371,7 @@ void irias_add_octseq_attrib(struct ias_object *obj, char 
*name, __u8 

add argv_split()

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d84d1cc7647c7e4f77d517e2d87b4a106a0420d9
Commit: d84d1cc7647c7e4f77d517e2d87b4a106a0420d9
Parent: 1e66df3ee301209f4a38df097d7cc5cb9b367a3f
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:02 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:40 2007 -0700

add argv_split()

argv_split() is a helper function which takes a string, splits it at
whitespace, and returns a NULL-terminated argv vector.  This is
deliberately simple - it does no quote processing of any kind.

[ Seems to me that this is something which is already being done in
  the kernel, but I couldn't find any other implementations, either to
  steal or replace.  Keep an eye out. ]

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Cc: Andrew Morton [EMAIL PROTECTED]
Cc: Randy Dunlap [EMAIL PROTECTED]
---
 include/linux/string.h |3 +
 lib/Makefile   |2 +-
 lib/argv_split.c   |  105 
 3 files changed, 109 insertions(+), 1 deletions(-)

diff --git a/include/linux/string.h b/include/linux/string.h
index ee5e9cc..836062b 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -108,6 +108,9 @@ extern char *kstrdup(const char *s, gfp_t gfp);
 extern char *kstrndup(const char *s, size_t len, gfp_t gfp);
 extern void *kmemdup(const void *src, size_t len, gfp_t gfp);
 
+extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
+extern void argv_free(char **argv);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/Makefile b/lib/Makefile
index da68b2c..6149663 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -5,7 +5,7 @@
 lib-y := ctype.o string.o vsprintf.o cmdline.o \
 rbtree.o radix-tree.o dump_stack.o \
 idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \
-sha1.o irq_regs.o reciprocal_div.o
+sha1.o irq_regs.o reciprocal_div.o argv_split.o
 
 lib-$(CONFIG_MMU) += ioremap.o
 lib-$(CONFIG_SMP) += cpumask.o
diff --git a/lib/argv_split.c b/lib/argv_split.c
new file mode 100644
index 000..4096ed4
--- /dev/null
+++ b/lib/argv_split.c
@@ -0,0 +1,105 @@
+/*
+ * Helper function for splitting a string into an argv-like array.
+ */
+
+#include linux/kernel.h
+#include linux/ctype.h
+#include linux/bug.h
+
+static const char *skip_sep(const char *cp)
+{
+   while (*cp  isspace(*cp))
+   cp++;
+
+   return cp;
+}
+
+static const char *skip_arg(const char *cp)
+{
+   while (*cp  !isspace(*cp))
+   cp++;
+
+   return cp;
+}
+
+static int count_argc(const char *str)
+{
+   int count = 0;
+
+   while (*str) {
+   str = skip_sep(str);
+   if (*str) {
+   count++;
+   str = skip_arg(str);
+   }
+   }
+
+   return count;
+}
+
+/**
+ * argv_free - free an argv
+ * @argv - the argument vector to be freed
+ *
+ * Frees an argv and the strings it points to.
+ */
+void argv_free(char **argv)
+{
+   char **p;
+   for (p = argv; *p; p++)
+   kfree(*p);
+
+   kfree(argv);
+}
+EXPORT_SYMBOL(argv_free);
+
+/**
+ * argv_split - split a string at whitespace, returning an argv
+ * @gfp: the GFP mask used to allocate memory
+ * @str: the string to be split
+ * @argcp: returned argument count
+ *
+ * Returns an array of pointers to strings which are split out from
+ * @str.  This is performed by strictly splitting on white-space; no
+ * quote processing is performed.  Multiple whitespace characters are
+ * considered to be a single argument separator.  The returned array
+ * is always NULL-terminated.  Returns NULL on memory allocation
+ * failure.
+ */
+char **argv_split(gfp_t gfp, const char *str, int *argcp)
+{
+   int argc = count_argc(str);
+   char **argv = kzalloc(sizeof(*argv) * (argc+1), gfp);
+   char **argvp;
+
+   if (argv == NULL)
+   goto out;
+
+   *argcp = argc;
+   argvp = argv;
+
+   while (*str) {
+   str = skip_sep(str);
+
+   if (*str) {
+   const char *p = str;
+   char *t;
+
+   str = skip_arg(str);
+
+   t = kstrndup(p, str-p, gfp);
+   if (t == NULL)
+   goto fail;
+   *argvp++ = t;
+   }
+   }
+   *argvp = NULL;
+
+  out:
+   return argv;
+
+  fail:
+   argv_free(argv);
+   return NULL;
+}
+EXPORT_SYMBOL(argv_split);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


usermodehelper: split setup from execution

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0ab4dc92278a0f3816e486d6350c6652a72e06c8
Commit: 0ab4dc92278a0f3816e486d6350c6652a72e06c8
Parent: d84d1cc7647c7e4f77d517e2d87b4a106a0420d9
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:02 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:40 2007 -0700

usermodehelper: split setup from execution

Rather than having hundreds of variations of call_usermodehelper for
various pieces of usermode state which could be set up, split the
info allocation and initialization from the actual process execution.

This means the general pattern becomes:
 info = call_usermodehelper_setup(path, argv, envp); /* basic state */
 call_usermodehelper_SET EXTRA STATE(info, stuff...); /* extra state 
*/
 call_usermodehelper_exec(info, wait);  /* run process and free info */

This patch introduces wrappers for all the existing calling styles for
call_usermodehelper_*, but folds their implementations into one.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Cc: Andi Kleen [EMAIL PROTECTED]
Cc: Rusty Russell [EMAIL PROTECTED]
Cc: David Howells [EMAIL PROTECTED]
Cc: Bj?rn Steinbrink [EMAIL PROTECTED]
Cc: Randy Dunlap [EMAIL PROTECTED]
---
 include/linux/kmod.h |   44 +++-
 kernel/kmod.c|  191 +++---
 2 files changed, 176 insertions(+), 59 deletions(-)

diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 10f505c..c4cbe59 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -36,13 +36,51 @@ static inline int request_module(const char * name, ...) { 
return -ENOSYS; }
 #define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x)))
 
 struct key;
-extern int call_usermodehelper_keys(char *path, char *argv[], char *envp[],
-   struct key *session_keyring, int wait);
+struct file;
+struct subprocess_info;
+
+/* Allocate a subprocess_info structure */
+struct subprocess_info *call_usermodehelper_setup(char *path,
+ char **argv, char **envp);
+
+/* Set various pieces of state into the subprocess_info structure */
+void call_usermodehelper_setkeys(struct subprocess_info *info,
+struct key *session_keyring);
+int call_usermodehelper_stdinpipe(struct subprocess_info *sub_info,
+ struct file **filp);
+void call_usermodehelper_setcleanup(struct subprocess_info *info,
+   void (*cleanup)(char **argv, char **envp));
+
+/* Actually execute the sub-process */
+int call_usermodehelper_exec(struct subprocess_info *info, int wait);
+
+/* Free the subprocess_info. This is only needed if you're not going
+   to call call_usermodehelper_exec */
+void call_usermodehelper_freeinfo(struct subprocess_info *info);
 
 static inline int
 call_usermodehelper(char *path, char **argv, char **envp, int wait)
 {
-   return call_usermodehelper_keys(path, argv, envp, NULL, wait);
+   struct subprocess_info *info;
+
+   info = call_usermodehelper_setup(path, argv, envp);
+   if (info == NULL)
+   return -ENOMEM;
+   return call_usermodehelper_exec(info, wait);
+}
+
+static inline int
+call_usermodehelper_keys(char *path, char **argv, char **envp,
+struct key *session_keyring, int wait)
+{
+   struct subprocess_info *info;
+
+   info = call_usermodehelper_setup(path, argv, envp);
+   if (info == NULL)
+   return -ENOMEM;
+
+   call_usermodehelper_setkeys(info, session_keyring);
+   return call_usermodehelper_exec(info, wait);
 }
 
 extern void usermodehelper_init(void);
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 4d32eb0..d2dce71 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -122,6 +122,7 @@ struct subprocess_info {
int wait;
int retval;
struct file *stdin;
+   void (*cleanup)(char **argv, char **envp);
 };
 
 /*
@@ -180,6 +181,14 @@ static int call_usermodehelper(void *data)
do_exit(0);
 }
 
+void call_usermodehelper_freeinfo(struct subprocess_info *info)
+{
+   if (info-cleanup)
+   (*info-cleanup)(info-argv, info-envp);
+   kfree(info);
+}
+EXPORT_SYMBOL(call_usermodehelper_freeinfo);
+
 /* Keventd can't block, but this (a child) can. */
 static int wait_for_helper(void *data)
 {
@@ -217,7 +226,7 @@ static int wait_for_helper(void *data)
}
 
if (sub_info-wait  0)
-   kfree(sub_info);
+   call_usermodehelper_freeinfo(sub_info);
else
complete(sub_info-complete);
return 0;
@@ -252,11 +261,94 @@ static void __call_usermodehelper(struct work_struct 
*work)
 }
 
 /**
- * call_usermodehelper_keys - start a usermode 

Add common orderly_poweroff()

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=10a0a8d4e3f6bf2d077f9431909abe670f5a
Commit: 10a0a8d4e3f6bf2d077f9431909abe670f5a
Parent: 0ab4dc92278a0f3816e486d6350c6652a72e06c8
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:02 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:40 2007 -0700

Add common orderly_poweroff()

Various pieces of code around the kernel want to be able to trigger an
orderly poweroff.  This pulls them together into a single
implementation.

By default the poweroff command is /sbin/poweroff, but it can be set
via sysctl: kernel/poweroff_cmd.  This is split at whitespace, so it
can include command-line arguments.

This patch replaces four other instances of invoking either poweroff
or shutdown -h now: two sbus drivers, and acpi thermal
management.

sparc64 has its own powerd; still need to determine whether it should
be replaced by orderly_poweroff().

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Acked-by: Len Brown [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Cc: Andrew Morton [EMAIL PROTECTED]
Cc: Randy Dunlap [EMAIL PROTECTED]
Cc: Andi Kleen [EMAIL PROTECTED]
Cc: Al Viro [EMAIL PROTECTED]
Cc: Arnd Bergmann [EMAIL PROTECTED]
Cc: David S. Miller [EMAIL PROTECTED]
---
 drivers/acpi/thermal.c  |   24 +---
 drivers/sbus/char/bbc_envctrl.c |5 +--
 drivers/sbus/char/envctrl.c |7 +---
 include/linux/reboot.h  |5 +++
 kernel/sys.c|   58 +++
 kernel/sysctl.c |   10 +++
 6 files changed, 79 insertions(+), 30 deletions(-)

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 88a6fc7..58f1338 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -40,6 +40,7 @@
 #include linux/jiffies.h
 #include linux/kmod.h
 #include linux/seq_file.h
+#include linux/reboot.h
 #include asm/uaccess.h
 
 #include acpi/acpi_bus.h
@@ -59,7 +60,6 @@
 #define ACPI_THERMAL_NOTIFY_CRITICAL   0xF0
 #define ACPI_THERMAL_NOTIFY_HOT0xF1
 #define ACPI_THERMAL_MODE_ACTIVE   0x00
-#define ACPI_THERMAL_PATH_POWEROFF /sbin/poweroff
 
 #define ACPI_THERMAL_MAX_ACTIVE10
 #define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65
@@ -419,26 +419,6 @@ static int acpi_thermal_get_devices(struct acpi_thermal 
*tz)
return 0;
 }
 
-static int acpi_thermal_call_usermode(char *path)
-{
-   char *argv[2] = { NULL, NULL };
-   char *envp[3] = { NULL, NULL, NULL };
-
-
-   if (!path)
-   return -EINVAL;
-
-   argv[0] = path;
-
-   /* minimal command environment */
-   envp[0] = HOME=/;
-   envp[1] = PATH=/sbin:/bin:/usr/sbin:/usr/bin;
-
-   call_usermodehelper(argv[0], argv, envp, 0);
-
-   return 0;
-}
-
 static int acpi_thermal_critical(struct acpi_thermal *tz)
 {
if (!tz || !tz-trips.critical.flags.valid)
@@ -456,7 +436,7 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
acpi_bus_generate_event(tz-device, ACPI_THERMAL_NOTIFY_CRITICAL,
tz-trips.critical.flags.enabled);
 
-   acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF);
+   orderly_poweroff(true);
 
return 0;
 }
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index a54e414..e821a15 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -7,6 +7,7 @@
 #include linux/kthread.h
 #include linux/delay.h
 #include linux/kmod.h
+#include linux/reboot.h
 #include asm/oplib.h
 #include asm/ebus.h
 
@@ -170,8 +171,6 @@ static void get_current_temps(struct bbc_cpu_temperature 
*tp)
 static void do_envctrl_shutdown(struct bbc_cpu_temperature *tp)
 {
static int shutting_down = 0;
-   static char *envp[] = { HOME=/, TERM=linux, 
PATH=/sbin:/usr/sbin:/bin:/usr/bin, NULL };
-   char *argv[] = { /sbin/shutdown, -h, now, NULL };
char *type = ???;
s8 val = -1;
 
@@ -195,7 +194,7 @@ static void do_envctrl_shutdown(struct bbc_cpu_temperature 
*tp)
printk(KERN_CRIT kenvctrld: Shutting down the system now.\n);
 
shutting_down = 1;
-   if (call_usermodehelper(/sbin/shutdown, argv, envp, 0)  0)
+   if (orderly_poweroff(true)  0)
printk(KERN_CRIT envctrl: shutdown execution failed\n);
 }
 
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index 8328aca..dadabef 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -26,6 +26,7 @@
 #include linux/ioport.h
 #include linux/miscdevice.h
 #include linux/kmod.h
+#include linux/reboot.h
 
 #include asm/ebus.h
 #include asm/uaccess.h
@@ -966,10 +967,6 @@ static struct i2c_child_t *envctrl_get_i2c_child(unsigned 
char mon_type)
 static 

usermodehelper: Tidy up waiting

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=86313c488a6848b7ec2ba04e74f25f79dd32a0b7
Commit: 86313c488a6848b7ec2ba04e74f25f79dd32a0b7
Parent: 10a0a8d4e3f6bf2d077f9431909abe670f5a
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:03 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:40 2007 -0700

usermodehelper: Tidy up waiting

Rather than using a tri-state integer for the wait flag in
call_usermodehelper_exec, define a proper enum, and use that.  I've
preserved the integer values so that any callers I've missed should
still work OK.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Cc: James Bottomley [EMAIL PROTECTED]
Cc: Randy Dunlap [EMAIL PROTECTED]
Cc: Christoph Hellwig [EMAIL PROTECTED]
Cc: Andi Kleen [EMAIL PROTECTED]
Cc: Paul Mackerras [EMAIL PROTECTED]
Cc: Johannes Berg [EMAIL PROTECTED]
Cc: Ralf Baechle [EMAIL PROTECTED]
Cc: Bjorn Helgaas [EMAIL PROTECTED]
Cc: Joel Becker [EMAIL PROTECTED]
Cc: Tony Luck [EMAIL PROTECTED]
Cc: Kay Sievers [EMAIL PROTECTED]
Cc: Srivatsa Vaddagiri [EMAIL PROTECTED]
Cc: Oleg Nesterov [EMAIL PROTECTED]
Cc: David Howells [EMAIL PROTECTED]
---
 arch/i386/mach-voyager/voyager_thread.c |2 +-
 arch/x86_64/kernel/mce.c|2 +-
 drivers/macintosh/therm_pm72.c  |3 ++-
 drivers/macintosh/windfarm_core.c   |3 ++-
 drivers/net/hamradio/baycom_epp.c   |2 +-
 drivers/pnp/pnpbios/core.c  |2 +-
 fs/ocfs2/heartbeat.c|2 +-
 include/linux/kmod.h|   12 +---
 kernel/cpuset.c |2 +-
 kernel/kmod.c   |   27 ---
 kernel/sys.c|2 +-
 lib/kobject_uevent.c|2 +-
 net/bridge/br_stp_if.c  |2 +-
 security/keys/request_key.c |3 ++-
 14 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/arch/i386/mach-voyager/voyager_thread.c 
b/arch/i386/mach-voyager/voyager_thread.c
index b4b24e0..f9d5953 100644
--- a/arch/i386/mach-voyager/voyager_thread.c
+++ b/arch/i386/mach-voyager/voyager_thread.c
@@ -52,7 +52,7 @@ execute(const char *string)
NULL,
};
 
-   if ((ret = call_usermodehelper(argv[0], argv, envp, 1)) != 0) {
+   if ((ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC)) != 
0) {
printk(KERN_ERR Voyager failed to run \%s\: %i\n,
   string, ret);
}
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index aa1d159..f3fb817 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -174,7 +174,7 @@ static void do_mce_trigger(void)
if (events != atomic_read(mce_logged)  trigger[0]) {
/* Small race window, but should be harmless.  */
atomic_set(mce_logged, events);
-   call_usermodehelper(trigger, trigger_argv, NULL, -1);
+   call_usermodehelper(trigger, trigger_argv, NULL, UMH_NO_WAIT);
}
 }
 
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index dbb2240..3d90fc0 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -1770,7 +1770,8 @@ static int call_critical_overtemp(void)
PATH=/sbin:/usr/sbin:/bin:/usr/bin,
NULL };
 
-   return call_usermodehelper(critical_overtemp_path, argv, envp, 0);
+   return call_usermodehelper(critical_overtemp_path,
+  argv, envp, UMH_WAIT_EXEC);
 }
 
 
diff --git a/drivers/macintosh/windfarm_core.c 
b/drivers/macintosh/windfarm_core.c
index e18d265..516d943 100644
--- a/drivers/macintosh/windfarm_core.c
+++ b/drivers/macintosh/windfarm_core.c
@@ -80,7 +80,8 @@ int wf_critical_overtemp(void)
PATH=/sbin:/usr/sbin:/bin:/usr/bin,
NULL };
 
-   return call_usermodehelper(critical_overtemp_path, argv, envp, 0);
+   return call_usermodehelper(critical_overtemp_path,
+  argv, envp, UMH_WAIT_EXEC);
 }
 EXPORT_SYMBOL_GPL(wf_critical_overtemp);
 
diff --git a/drivers/net/hamradio/baycom_epp.c 
b/drivers/net/hamradio/baycom_epp.c
index 84aa211..355c6cf 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -320,7 +320,7 @@ static int eppconfig(struct baycom_state *bc)
sprintf(portarg, %ld, bc-pdev-port-base);
printk(KERN_DEBUG %s: %s -s -p %s -m %s\n, bc_drvname, 
eppconfig_path, portarg, modearg);
 
-   return call_usermodehelper(eppconfig_path, argv, envp, 1);
+   return call_usermodehelper(eppconfig_path, argv, envp, UMH_WAIT_PROC);
 }
 
 /* 

use elfnote.h to generate vsyscall notes.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=810bab448e563ffd1718d78e9a3756806b626acc
Commit: 810bab448e563ffd1718d78e9a3756806b626acc
Parent: 86313c488a6848b7ec2ba04e74f25f79dd32a0b7
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:03 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:40 2007 -0700

use elfnote.h to generate vsyscall notes.

Use existing elfnote.h to generate vsyscall notes, rather than doing
it locally.  Changes elfnote.h a bit to suit, since this is the first
asm user, and it wasn't quite right.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Cc: Eric W. Biederman [EMAIL PROTECTED]
Cc: Roland McGrath [EMAIL PROTECTED]
Cc: Andrew Morton [EMAIL PROTECTED]
---
 arch/i386/kernel/vsyscall-note.S |   23 ++-
 include/linux/elfnote.h  |   22 +++---
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/arch/i386/kernel/vsyscall-note.S b/arch/i386/kernel/vsyscall-note.S
index d4b5be4..52e0cbb 100644
--- a/arch/i386/kernel/vsyscall-note.S
+++ b/arch/i386/kernel/vsyscall-note.S
@@ -3,23 +3,12 @@
  * Here we can supply some information useful to userland.
  */
 
-#include linux/uts.h
 #include linux/version.h
+#include linux/elfnote.h
 
-#define ASM_ELF_NOTE_BEGIN(name, flags, vendor, type)\
-   .section name, flags; \
-   .balign 4;\
-   .long 1f - 0f;  /* name length */ \
-   .long 3f - 2f;  /* data length */ \
-   .long type; /* note type */   \
-0: .asciz vendor;  /* vendor name */ \
-1: .balign 4;\
-2:
-
-#define ASM_ELF_NOTE_END \
-3: .balign 4;  /* pad out section */ \
-   .previous
-
-   ASM_ELF_NOTE_BEGIN(.note.kernel-version, a, UTS_SYSNAME, 0)
+/* Ideally this would use UTS_NAME, but using a quoted string here
+   doesn't work. Remember to change this when changing the
+   kernel's name. */
+ELFNOTE_START(Linux, 0, a)
.long LINUX_VERSION_CODE
-   ASM_ELF_NOTE_END
+ELFNOTE_END
diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
index 9a1e067..e831759 100644
--- a/include/linux/elfnote.h
+++ b/include/linux/elfnote.h
@@ -38,17 +38,25 @@
  * e.g. ELFNOTE(XYZCo, 42, .asciz, forty-two)
  *  ELFNOTE(XYZCo, 12, .long, 0xdeadbeef)
  */
-#define ELFNOTE(name, type, desctype, descdata)\
-.pushsection .note.name, ,@note  ;   \
-  .align 4 ;   \
+#define ELFNOTE_START(name, type, flags)   \
+.pushsection .note.name, flags,@note   ;   \
+  .balign 4;   \
   .long 2f - 1f/* namesz */;   \
-  .long 4f - 3f/* descsz */;   \
+  .long 4484f - 3f /* descsz */;   \
   .long type   ;   \
 1:.asciz #name ;   \
-2:.align 4 ;   \
-3:desctype descdata;   \
-4:.align 4 ;   \
+2:.balign 4;   \
+3:
+
+#define ELFNOTE_END\
+4484:.balign 4 ;   \
 .popsection;
+
+#define ELFNOTE(name, type, desc)  \
+   ELFNOTE_START(name, type, )   \
+   desc;   \
+   ELFNOTE_END
+
 #else  /* !__ASSEMBLER__ */
 #include linux/elf.h
 /*
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


paravirt: add an mm argument to alloc_pt

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fdb4c338c8d1d494e17c3422a3ea2129f6791596
Commit: fdb4c338c8d1d494e17c3422a3ea2129f6791596
Parent: 810bab448e563ffd1718d78e9a3756806b626acc
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:03 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:40 2007 -0700

paravirt: add an mm argument to alloc_pt

It's useful to know which mm is allocating a pagetable.  Xen uses this
to determine whether the pagetable being added to is pinned or not.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
---
 arch/i386/kernel/vmi.c  |2 +-
 arch/i386/mm/init.c |2 +-
 arch/i386/mm/pageattr.c |2 +-
 include/asm-i386/paravirt.h |6 +++---
 include/asm-i386/pgalloc.h  |6 +++---
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/i386/kernel/vmi.c b/arch/i386/kernel/vmi.c
index c12720d..234bd6f 100644
--- a/arch/i386/kernel/vmi.c
+++ b/arch/i386/kernel/vmi.c
@@ -362,7 +362,7 @@ static void *vmi_kmap_atomic_pte(struct page *page, enum 
km_type type)
 }
 #endif
 
-static void vmi_allocate_pt(u32 pfn)
+static void vmi_allocate_pt(struct mm_struct *mm, u32 pfn)
 {
vmi_set_page_type(pfn, VMI_PAGE_L1);
vmi_ops.allocate_page(pfn, VMI_PAGE_L1, 0, 0, 0);
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index 7135946..f9b6a88 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -87,7 +87,7 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
if (!(pmd_val(*pmd)  _PAGE_PRESENT)) {
pte_t *page_table = (pte_t *) 
alloc_bootmem_low_pages(PAGE_SIZE);
 
-   paravirt_alloc_pt(__pa(page_table)  PAGE_SHIFT);
+   paravirt_alloc_pt(init_mm, __pa(page_table)  PAGE_SHIFT);
set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
BUG_ON(page_table != pte_offset_kernel(pmd, 0));
}
diff --git a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c
index 2eb14a7..37992ff 100644
--- a/arch/i386/mm/pageattr.c
+++ b/arch/i386/mm/pageattr.c
@@ -60,7 +60,7 @@ static struct page *split_large_page(unsigned long address, 
pgprot_t prot,
address = __pa(address);
addr = address  LARGE_PAGE_MASK; 
pbase = (pte_t *)page_address(base);
-   paravirt_alloc_pt(page_to_pfn(base));
+   paravirt_alloc_pt(init_mm, page_to_pfn(base));
for (i = 0; i  PTRS_PER_PTE; i++, addr += PAGE_SIZE) {
set_pte(pbase[i], pfn_pte(addr  PAGE_SHIFT,
   addr == address ? prot : ref_prot));
diff --git a/include/asm-i386/paravirt.h b/include/asm-i386/paravirt.h
index 7f846a7..99bf661 100644
--- a/include/asm-i386/paravirt.h
+++ b/include/asm-i386/paravirt.h
@@ -173,7 +173,7 @@ struct paravirt_ops
 unsigned long va);
 
/* Hooks for allocating/releasing pagetable pages */
-   void (*alloc_pt)(u32 pfn);
+   void (*alloc_pt)(struct mm_struct *mm, u32 pfn);
void (*alloc_pd)(u32 pfn);
void (*alloc_pd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count);
void (*release_pt)(u32 pfn);
@@ -725,9 +725,9 @@ static inline void flush_tlb_others(cpumask_t cpumask, 
struct mm_struct *mm,
PVOP_VCALL3(flush_tlb_others, cpumask, mm, va);
 }
 
-static inline void paravirt_alloc_pt(unsigned pfn)
+static inline void paravirt_alloc_pt(struct mm_struct *mm, unsigned pfn)
 {
-   PVOP_VCALL1(alloc_pt, pfn);
+   PVOP_VCALL2(alloc_pt, mm, pfn);
 }
 static inline void paravirt_release_pt(unsigned pfn)
 {
diff --git a/include/asm-i386/pgalloc.h b/include/asm-i386/pgalloc.h
index d07b7af..f2fc33c 100644
--- a/include/asm-i386/pgalloc.h
+++ b/include/asm-i386/pgalloc.h
@@ -7,7 +7,7 @@
 #ifdef CONFIG_PARAVIRT
 #include asm/paravirt.h
 #else
-#define paravirt_alloc_pt(pfn) do { } while (0)
+#define paravirt_alloc_pt(mm, pfn) do { } while (0)
 #define paravirt_alloc_pd(pfn) do { } while (0)
 #define paravirt_alloc_pd(pfn) do { } while (0)
 #define paravirt_alloc_pd_clone(pfn, clonepfn, start, count) do { } while (0)
@@ -17,13 +17,13 @@
 
 #define pmd_populate_kernel(mm, pmd, pte)  \
 do {   \
-   paravirt_alloc_pt(__pa(pte)  PAGE_SHIFT); \
+   paravirt_alloc_pt(mm, __pa(pte)  PAGE_SHIFT); \
set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)));   \
 } while (0)
 
 #define pmd_populate(mm, pmd, pte) \
 do {   \
-   paravirt_alloc_pt(page_to_pfn(pte));\
+   paravirt_alloc_pt(mm, page_to_pfn(pte));\
set_pmd(pmd, __pmd(_PAGE_TABLE +\
((unsigned long long)page_to_pfn(pte) \
(unsigned long 

paravirt: add a hook for once the allocator is ready

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6996d3b63fd9a64341bc80dad1b556fd3eb81272
Commit: 6996d3b63fd9a64341bc80dad1b556fd3eb81272
Parent: fdb4c338c8d1d494e17c3422a3ea2129f6791596
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:03 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:41 2007 -0700

paravirt: add a hook for once the allocator is ready

Add a hook so that the paravirt backend knows when the allocator is
ready.  This is useful for the obvious reason that the allocator is
available, but the other side-effect of having the bootmem allocator
available is that each page now has an associated struct page.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
---
 arch/i386/kernel/setup.c|2 ++
 include/asm-i386/paravirt.h |8 
 include/asm-i386/setup.h|4 
 3 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 2d61e65..74871d0 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -601,6 +601,8 @@ void __init setup_arch(char **cmdline_p)
 * NOTE: at this point the bootmem allocator is fully available.
 */
 
+   paravirt_post_allocator_init();
+
dmi_scan_machine();
 
 #ifdef CONFIG_X86_GENERICARCH
diff --git a/include/asm-i386/paravirt.h b/include/asm-i386/paravirt.h
index 99bf661..7868569 100644
--- a/include/asm-i386/paravirt.h
+++ b/include/asm-i386/paravirt.h
@@ -52,6 +52,8 @@ struct paravirt_ops
/* Basic arch-specific setup */
void (*arch_setup)(void);
char *(*memory_setup)(void);
+   void (*post_allocator_init)(void);
+
void (*init_IRQ)(void);
void (*time_init)(void);
 
@@ -669,6 +671,12 @@ static inline void setup_secondary_clock(void)
 }
 #endif
 
+static inline void paravirt_post_allocator_init(void)
+{
+   if (paravirt_ops.post_allocator_init)
+   (*paravirt_ops.post_allocator_init)();
+}
+
 static inline void paravirt_pagetable_setup_start(pgd_t *base)
 {
if (paravirt_ops.pagetable_setup_start)
diff --git a/include/asm-i386/setup.h b/include/asm-i386/setup.h
index 0d5bff9..7862fe8 100644
--- a/include/asm-i386/setup.h
+++ b/include/asm-i386/setup.h
@@ -81,6 +81,10 @@ void __init add_memory_region(unsigned long long start,
 
 extern unsigned long init_pg_tables_end;
 
+#ifndef CONFIG_PARAVIRT
+#define paravirt_post_allocator_init() do {} while (0)
+#endif
+
 #endif /* __ASSEMBLY__ */
 
 #endif  /*  __KERNEL__  */
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


paravirt: increase IRQ limit

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=03f0c2f950f813e3b26c56ed041ba170479d479c
Commit: 03f0c2f950f813e3b26c56ed041ba170479d479c
Parent: 6996d3b63fd9a64341bc80dad1b556fd3eb81272
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:03 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:41 2007 -0700

paravirt: increase IRQ limit

When running with CONFIG_PARAVIRT, we may want lots of IRQs even if
there's no IO APIC.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Cc: Eric W. Biederman [EMAIL PROTECTED]
---
 include/asm-i386/mach-default/irq_vectors_limits.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/asm-i386/mach-default/irq_vectors_limits.h 
b/include/asm-i386/mach-default/irq_vectors_limits.h
index 7f161e7..a90c7a6 100644
--- a/include/asm-i386/mach-default/irq_vectors_limits.h
+++ b/include/asm-i386/mach-default/irq_vectors_limits.h
@@ -1,7 +1,7 @@
 #ifndef _ASM_IRQ_VECTORS_LIMITS_H
 #define _ASM_IRQ_VECTORS_LIMITS_H
 
-#ifdef CONFIG_X86_IO_APIC
+#if defined(CONFIG_X86_IO_APIC) || defined(CONFIG_PARAVIRT)
 #define NR_IRQS 224
 # if (224 = 32 * NR_CPUS)
 # define NR_IRQ_VECTORS NR_IRQS
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


paravirt: unstatic leave_mm

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=53787013248f52af81d99f63454e5a5cf34d6f12
Commit: 53787013248f52af81d99f63454e5a5cf34d6f12
Parent: 03f0c2f950f813e3b26c56ed041ba170479d479c
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:03 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:41 2007 -0700

paravirt: unstatic leave_mm

Make globally leave_mm visible, specifically so that Xen can use it to
shoot-down lazy uses of cr3.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
---
 arch/i386/kernel/smp.c |5 +++--
 include/asm-i386/mmu_context.h |2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
index 6299c08..2d35d85 100644
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -22,6 +22,7 @@
 
 #include asm/mtrr.h
 #include asm/tlbflush.h
+#include asm/mmu_context.h
 #include mach_apic.h
 
 /*
@@ -249,13 +250,13 @@ static unsigned long flush_va;
 static DEFINE_SPINLOCK(tlbstate_lock);
 
 /*
- * We cannot call mmdrop() because we are in interrupt context, 
+ * We cannot call mmdrop() because we are in interrupt context,
  * instead update mm-cpu_vm_mask.
  *
  * We need to reload %cr3 since the page tables may be going
  * away from under us..
  */
-static inline void leave_mm (unsigned long cpu)
+void leave_mm(unsigned long cpu)
 {
if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_OK)
BUG();
diff --git a/include/asm-i386/mmu_context.h b/include/asm-i386/mmu_context.h
index 8198d1c..7eb0b0b 100644
--- a/include/asm-i386/mmu_context.h
+++ b/include/asm-i386/mmu_context.h
@@ -32,6 +32,8 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, 
struct task_struct *tsk)
 #endif
 }
 
+void leave_mm(unsigned long cpu);
+
 static inline void switch_mm(struct mm_struct *prev,
 struct mm_struct *next,
 struct task_struct *tsk)
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


paravirt: make siblingmap functions visible

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c70df74376c1e29a04e07e23dd3f4c384d6166dd
Commit: c70df74376c1e29a04e07e23dd3f4c384d6166dd
Parent: 724faa89ccd8fae65f3d41a47b0e1034cf07918b
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:03 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:41 2007 -0700

paravirt: make siblingmap functions visible

Paravirt implementations need to set the sibling map on new cpus.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
---
 arch/i386/kernel/smpboot.c |6 ++
 include/asm-i386/smp.h |3 +++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 2675293..5910d3f 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -308,8 +308,7 @@ cpumask_t cpu_coregroup_map(int cpu)
 /* representing cpus for which sibling maps can be computed */
 static cpumask_t cpu_sibling_setup_map;
 
-static inline void
-set_cpu_sibling_map(int cpu)
+void set_cpu_sibling_map(int cpu)
 {
int i;
struct cpuinfo_x86 *c = cpu_data;
@@ -1144,8 +1143,7 @@ void __init native_smp_prepare_boot_cpu(void)
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-static void
-remove_siblinginfo(int cpu)
+void remove_siblinginfo(int cpu)
 {
int sibling;
struct cpuinfo_x86 *c = cpu_data;
diff --git a/include/asm-i386/smp.h b/include/asm-i386/smp.h
index 0f54f44..1f73bde 100644
--- a/include/asm-i386/smp.h
+++ b/include/asm-i386/smp.h
@@ -43,9 +43,12 @@ extern u8 x86_cpu_to_apicid[];
 
 #define cpu_physical_id(cpu)   x86_cpu_to_apicid[cpu]
 
+extern void set_cpu_sibling_map(int cpu);
+
 #ifdef CONFIG_HOTPLUG_CPU
 extern void cpu_exit_clear(void);
 extern void cpu_uninit(void);
+extern void remove_siblinginfo(int cpu);
 #endif
 
 struct smp_ops
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


paravirt: export __supported_pte_mask

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=bdef40a6af64a0140a65df49bf504124d57094a9
Commit: bdef40a6af64a0140a65df49bf504124d57094a9
Parent: c70df74376c1e29a04e07e23dd3f4c384d6166dd
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:04 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:41 2007 -0700

paravirt: export __supported_pte_mask

__supported_pte_mask is needed when constructing pte values.  Xen
device drivers need to do this to make mappings of foreign pages (ie,
pages granted to us by other domains).

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
---
 arch/i386/mm/init.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index f9b6a88..6a68b1a 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -473,6 +473,7 @@ void zap_low_mappings (void)
 
 static int disable_nx __initdata = 0;
 u64 __supported_pte_mask __read_mostly = ~_PAGE_NX;
+EXPORT_SYMBOL_GPL(__supported_pte_mask);
 
 /*
  * noexec = on|off
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Allocate and free vmalloc areas

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5f4352fbffd6c45123dbce9e195efd54df4e177e
Commit: 5f4352fbffd6c45123dbce9e195efd54df4e177e
Parent: bdef40a6af64a0140a65df49bf504124d57094a9
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:04 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:41 2007 -0700

Allocate and free vmalloc areas

Allocate/release a chunk of vmalloc address space:
 alloc_vm_area reserves a chunk of address space, and makes sure all
 the pagetables are constructed for that address range - but no pages.

 free_vm_area releases the address space range.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Ian Pratt [EMAIL PROTECTED]
Signed-off-by: Christian Limpach [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Cc: Jan Beulich [EMAIL PROTECTED]
Cc: Andi Kleen [EMAIL PROTECTED]
---
 include/linux/vmalloc.h |4 +++
 mm/vmalloc.c|   53 +++
 2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 132b260..c2b10ca 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -70,6 +70,10 @@ extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
struct page ***pages);
 extern void unmap_kernel_range(unsigned long addr, unsigned long size);
 
+/* Allocate/destroy a 'vmalloc' VM area. */
+extern struct vm_struct *alloc_vm_area(size_t size);
+extern void free_vm_area(struct vm_struct *area);
+
 /*
  * Internals.  Dont't use..
  */
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 8e05a11..3130c34 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -767,3 +767,56 @@ EXPORT_SYMBOL(remap_vmalloc_range);
 void  __attribute__((weak)) vmalloc_sync_all(void)
 {
 }
+
+
+static int f(pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
+{
+   /* apply_to_page_range() does all the hard work. */
+   return 0;
+}
+
+/**
+ * alloc_vm_area - allocate a range of kernel address space
+ * @size:  size of the area
+ * @returns:   NULL on failure, vm_struct on success
+ *
+ * This function reserves a range of kernel address space, and
+ * allocates pagetables to map that range.  No actual mappings
+ * are created.  If the kernel address space is not shared
+ * between processes, it syncs the pagetable across all
+ * processes.
+ */
+struct vm_struct *alloc_vm_area(size_t size)
+{
+   struct vm_struct *area;
+
+   area = get_vm_area(size, VM_IOREMAP);
+   if (area == NULL)
+   return NULL;
+
+   /*
+* This ensures that page tables are constructed for this region
+* of kernel virtual address space and mapped into init_mm.
+*/
+   if (apply_to_page_range(init_mm, (unsigned long)area-addr,
+   area-size, f, NULL)) {
+   free_vm_area(area);
+   return NULL;
+   }
+
+   /* Make sure the pagetables are constructed in process kernel
+  mappings */
+   vmalloc_sync_all();
+
+   return area;
+}
+EXPORT_SYMBOL_GPL(alloc_vm_area);
+
+void free_vm_area(struct vm_struct *area)
+{
+   struct vm_struct *ret;
+   ret = remove_vm_area(area-addr);
+   BUG_ON(ret != area);
+   kfree(area);
+}
+EXPORT_SYMBOL_GPL(free_vm_area);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


paravirt: helper to disable all IO space

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d572929cdd12a60732c3522f7cf011bfa29165cf
Commit: d572929cdd12a60732c3522f7cf011bfa29165cf
Parent: 5f4352fbffd6c45123dbce9e195efd54df4e177e
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:04 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:42 2007 -0700

paravirt: helper to disable all IO space

In a virtual environment, device drivers such as legacy IDE will waste
quite a lot of time probing for their devices which will never appear.
This helper function allows a paravirt implementation to lay claim to
the whole iomem and ioport space, thereby disabling all device drivers
trying to claim IO resources.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Cc: Rusty Russell [EMAIL PROTECTED]
---
 arch/i386/kernel/paravirt.c |   35 +++
 include/asm-i386/paravirt.h |1 +
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/arch/i386/kernel/paravirt.c b/arch/i386/kernel/paravirt.c
index faab09a..60e08b9 100644
--- a/arch/i386/kernel/paravirt.c
+++ b/arch/i386/kernel/paravirt.c
@@ -228,6 +228,41 @@ static int __init print_banner(void)
 }
 core_initcall(print_banner);
 
+static struct resource reserve_ioports = {
+   .start = 0,
+   .end = IO_SPACE_LIMIT,
+   .name = paravirt-ioport,
+   .flags = IORESOURCE_IO | IORESOURCE_BUSY,
+};
+
+static struct resource reserve_iomem = {
+   .start = 0,
+   .end = -1,
+   .name = paravirt-iomem,
+   .flags = IORESOURCE_MEM | IORESOURCE_BUSY,
+};
+
+/*
+ * Reserve the whole legacy IO space to prevent any legacy drivers
+ * from wasting time probing for their hardware.  This is a fairly
+ * brute-force approach to disabling all non-virtual drivers.
+ *
+ * Note that this must be called very early to have any effect.
+ */
+int paravirt_disable_iospace(void)
+{
+   int ret;
+
+   ret = request_resource(ioport_resource, reserve_ioports);
+   if (ret == 0) {
+   ret = request_resource(iomem_resource, reserve_iomem);
+   if (ret)
+   release_resource(reserve_ioports);
+   }
+
+   return ret;
+}
+
 struct paravirt_ops paravirt_ops = {
.name = bare hardware,
.paravirt_enabled = 0,
diff --git a/include/asm-i386/paravirt.h b/include/asm-i386/paravirt.h
index 7868569..690ada2 100644
--- a/include/asm-i386/paravirt.h
+++ b/include/asm-i386/paravirt.h
@@ -262,6 +262,7 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void 
*site, unsigned len)
 unsigned paravirt_patch_insns(void *site, unsigned len,
  const char *start, const char *end);
 
+int paravirt_disable_iospace(void);
 
 /*
  * This generates an indirect call based on the operation type number.
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Add a sched_clock paravirt_op

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=688340ea34c61ad12473ccd837325b59aada9a93
Commit: 688340ea34c61ad12473ccd837325b59aada9a93
Parent: d572929cdd12a60732c3522f7cf011bfa29165cf
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:04 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:42 2007 -0700

Add a sched_clock paravirt_op

The tsc-based get_scheduled_cycles interface is not a good match for
Xen's runstate accounting, which reports everything in nanoseconds.

This patch replaces this interface with a sched_clock interface, which
matches both Xen and VMI's requirements.

In order to do this, we:
   1. replace get_scheduled_cycles with sched_clock
   2. hoist cycles_2_ns into a common header
   3. update vmi accordingly

One thing to note: because sched_clock is implemented as a weak
function in kernel/sched.c, we must define a real function in order to
override this weak binding.  This means the usual paravirt_ops
technique of using an inline function won't work in this case.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Cc: Zachary Amsden [EMAIL PROTECTED]
Cc: Dan Hecht [EMAIL PROTECTED]
Cc: john stultz [EMAIL PROTECTED]
---
 arch/i386/kernel/paravirt.c |2 +-
 arch/i386/kernel/tsc.c  |   23 +++
 arch/i386/kernel/vmi.c  |2 +-
 arch/i386/kernel/vmiclock.c |6 +++---
 include/asm-i386/paravirt.h |7 +--
 include/asm-i386/timer.h|   32 +++-
 include/asm-i386/vmi_time.h |2 +-
 7 files changed, 57 insertions(+), 17 deletions(-)

diff --git a/arch/i386/kernel/paravirt.c b/arch/i386/kernel/paravirt.c
index 60e08b9..53f07a8 100644
--- a/arch/i386/kernel/paravirt.c
+++ b/arch/i386/kernel/paravirt.c
@@ -302,7 +302,7 @@ struct paravirt_ops paravirt_ops = {
.write_msr = native_write_msr_safe,
.read_tsc = native_read_tsc,
.read_pmc = native_read_pmc,
-   .get_scheduled_cycles = native_read_tsc,
+   .sched_clock = native_sched_clock,
.get_cpu_khz = native_calculate_cpu_khz,
.load_tr_desc = native_load_tr_desc,
.set_ldt = native_set_ldt,
diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
index ea63a30..252f901 100644
--- a/arch/i386/kernel/tsc.c
+++ b/arch/i386/kernel/tsc.c
@@ -84,7 +84,7 @@ static inline int check_tsc_unstable(void)
  *
  * [EMAIL PROTECTED] math is hard, lets go shopping!
  */
-static unsigned long cyc2ns_scale __read_mostly;
+unsigned long cyc2ns_scale __read_mostly;
 
 #define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
 
@@ -93,15 +93,10 @@ static inline void set_cyc2ns_scale(unsigned long cpu_khz)
cyc2ns_scale = (100  CYC2NS_SCALE_FACTOR)/cpu_khz;
 }
 
-static inline unsigned long long cycles_2_ns(unsigned long long cyc)
-{
-   return (cyc * cyc2ns_scale)  CYC2NS_SCALE_FACTOR;
-}
-
 /*
  * Scheduler clock - returns current time in nanosec units.
  */
-unsigned long long sched_clock(void)
+unsigned long long native_sched_clock(void)
 {
unsigned long long this_offset;
 
@@ -118,12 +113,24 @@ unsigned long long sched_clock(void)
return (jiffies_64 - INITIAL_JIFFIES) * (10 / HZ);
 
/* read the Time Stamp Counter: */
-   get_scheduled_cycles(this_offset);
+   rdtscll(this_offset);
 
/* return the value in ns */
return cycles_2_ns(this_offset);
 }
 
+/* We need to define a real function for sched_clock, to override the
+   weak default version */
+#ifdef CONFIG_PARAVIRT
+unsigned long long sched_clock(void)
+{
+   return paravirt_sched_clock();
+}
+#else
+unsigned long long sched_clock(void)
+   __attribute__((alias(native_sched_clock)));
+#endif
+
 unsigned long native_calculate_cpu_khz(void)
 {
unsigned long long start, end;
diff --git a/arch/i386/kernel/vmi.c b/arch/i386/kernel/vmi.c
index 234bd6f..72042bb 100644
--- a/arch/i386/kernel/vmi.c
+++ b/arch/i386/kernel/vmi.c
@@ -891,7 +891,7 @@ static inline int __init activate_vmi(void)
paravirt_ops.setup_boot_clock = vmi_time_bsp_init;
paravirt_ops.setup_secondary_clock = vmi_time_ap_init;
 #endif
-   paravirt_ops.get_scheduled_cycles = vmi_get_sched_cycles;
+   paravirt_ops.sched_clock = vmi_sched_clock;
paravirt_ops.get_cpu_khz = vmi_cpu_khz;
 
/* We have true wallclock functions; disable CMOS clock sync */
diff --git a/arch/i386/kernel/vmiclock.c b/arch/i386/kernel/vmiclock.c
index 26a37f8..f9b845f 100644
--- a/arch/i386/kernel/vmiclock.c
+++ b/arch/i386/kernel/vmiclock.c
@@ -64,10 +64,10 @@ int vmi_set_wallclock(unsigned long now)
return 0;
 }
 
-/* paravirt_ops.get_scheduled_cycles = vmi_get_sched_cycles */
-unsigned long long vmi_get_sched_cycles(void)
+/* 

Add nosegneg capability to the vsyscall page notes

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=24037a8b69dbf15bfed8fd42a2a2e442d7b0395b
Commit: 24037a8b69dbf15bfed8fd42a2a2e442d7b0395b
Parent: 688340ea34c61ad12473ccd837325b59aada9a93
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:04 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:42 2007 -0700

Add nosegneg capability to the vsyscall page notes

Add the nosegneg fake capabilty to the vsyscall page notes. This is
used by the runtime linker to select a glibc version which then
disables negative-offset accesses to the thread-local segment via
%gs. These accesses require emulation in Xen (because segments are
truncated to protect the hypervisor address space) and avoiding them
provides a measurable performance boost.

Signed-off-by: Ian Pratt [EMAIL PROTECTED]
Signed-off-by: Christian Limpach [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Acked-by: Zachary Amsden [EMAIL PROTECTED]
Cc: Roland McGrath [EMAIL PROTECTED]
Cc: Ulrich Drepper [EMAIL PROTECTED]
---
 arch/i386/kernel/vsyscall-note.S |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/arch/i386/kernel/vsyscall-note.S b/arch/i386/kernel/vsyscall-note.S
index 52e0cbb..271f16a 100644
--- a/arch/i386/kernel/vsyscall-note.S
+++ b/arch/i386/kernel/vsyscall-note.S
@@ -12,3 +12,31 @@
 ELFNOTE_START(Linux, 0, a)
.long LINUX_VERSION_CODE
 ELFNOTE_END
+
+#ifdef CONFIG_XEN
+
+/*
+ * Add a special note telling glibc's dynamic linker a fake hardware
+ * flavor that it will use to choose the search path for libraries in the
+ * same way it uses real hardware capabilities like mmx.
+ * We supply nosegneg as the fake capability, to indicate that we
+ * do not like negative offsets in instructions using segment overrides,
+ * since we implement those inefficiently.  This makes it possible to
+ * install libraries optimized to avoid those access patterns in someplace
+ * like /lib/i686/tls/nosegneg.  Note that an /etc/ld.so.conf.d/file
+ * corresponding to the bits here is needed to make ldconfig work right.
+ * It should contain:
+ * hwcap 1 nosegneg
+ * to match the mapping of bit to name that we give here.
+ */
+
+/* Bit used for the pseudo-hwcap for non-negative segments.  We use
+   bit 1 to avoid bugs in some versions of glibc when bit 0 is
+   used; the choice is otherwise arbitrary. */
+#define VDSO_NOTE_NONEGSEG_BIT 1
+
+ELFNOTE_START(GNU, 2, a)
+   .long 1, 1VDSO_NOTE_NONEGSEG_BIT  /* ncaps, mask */
+   .byte VDSO_NOTE_NONEGSEG_BIT; .asciz nosegneg /* bit, name */
+ELFNOTE_END
+#endif
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


xen: Core Xen implementation

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5ead97c84fa7d63a6a7a2f4e9f18f452bd109045
Commit: 5ead97c84fa7d63a6a7a2f4e9f18f452bd109045
Parent: a42089dd358a7673a0a23126589a9029e57c2049
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:04 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:42 2007 -0700

xen: Core Xen implementation

This patch is a rollup of all the core pieces of the Xen
implementation, including:
 - booting and setup
 - pagetable setup
 - privileged instructions
 - segmentation
 - interrupt flags
 - upcalls
 - multicall batching

BOOTING AND SETUP

The vmlinux image is decorated with ELF notes which tell the Xen
domain builder what the kernel's requirements are; the domain builder
then constructs the address space accordingly and starts the kernel.

Xen has its own entrypoint for the kernel (contained in an ELF note).
The ELF notes are set up by xen-head.S, which is included into head.S.
In principle it could be linked separately, but it seems to provoke
lots of binutils bugs.

Because the domain builder starts the kernel in a fairly sane state
(32-bit protected mode, paging enabled, flat segments set up), there's
not a lot of setup needed before starting the kernel proper.  The main
steps are:
  1. Install the Xen paravirt_ops, which is simply a matter of a
 structure assignment.
  2. Set init_mm to use the Xen-supplied pagetables (analogous to the
 head.S generated pagetables in a native boot).
  3. Reserve address space for Xen, since it takes a chunk at the top
 of the address space for its own use.
  4. Call start_kernel()

PAGETABLE SETUP

Once we hit the main kernel boot sequence, it will end up calling back
via paravirt_ops to set up various pieces of Xen specific state.  One
of the critical things which requires a bit of extra care is the
construction of the initial init_mm pagetable.  Because Xen places
tight constraints on pagetables (an active pagetable must always be
valid, and must always be mapped read-only to the guest domain), we
need to be careful when constructing the new pagetable to keep these
constraints in mind.  It turns out that the easiest way to do this is
use the initial Xen-provided pagetable as a template, and then just
insert new mappings for memory where a mapping doesn't already exist.

This means that during pagetable setup, it uses a special version of
xen_set_pte which ignores any attempt to remap a read-only page as
read-write (since Xen will map its own initial pagetable as RO), but
lets other changes to the ptes happen, so that things like NX are set
properly.

PRIVILEGED INSTRUCTIONS AND SEGMENTATION

When the kernel runs under Xen, it runs in ring 1 rather than ring 0.
This means that it is more privileged than user-mode in ring 3, but it
still can't run privileged instructions directly.  Non-performance
critical instructions are dealt with by taking a privilege exception
and trapping into the hypervisor and emulating the instruction, but
more performance-critical instructions have their own specific
paravirt_ops.  In many cases we can avoid having to do any hypercalls
for these instructions, or the Xen implementation is quite different
from the normal native version.

The privileged instructions fall into the broad classes of:
  Segmentation: setting up the GDT and the GDT entries, LDT,
 TLS and so on.  Xen doesn't allow the GDT to be directly
 modified; all GDT updates are done via hypercalls where the new
 entries can be validated.  This is important because Xen uses
 segment limits to prevent the guest kernel from damaging the
 hypervisor itself.
  Traps and exceptions: Xen uses a special format for trap entrypoints,
 so when the kernel wants to set an IDT entry, it needs to be
 converted to the form Xen expects.  Xen sets int 0x80 up specially
 so that the trap goes straight from userspace into the guest kernel
 without going via the hypervisor.  sysenter isn't supported.
  Kernel stack: The esp0 entry is extracted from the tss and provided to
 Xen.
  TLB operations: the various TLB calls are mapped into corresponding
 Xen hypercalls.
  Control registers: all the control registers are privileged.  The most
 important is cr3, which points to the base of the current pagetable,
 and we handle it specially.

Another instruction we treat specially is CPUID, even though its not
privileged.  We want to control what CPU features are visible to the
rest of the kernel, and so CPUID ends up going into a paravirt_op.

xen: virtual mmu

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=3b827c1b3aadf3adb4c602d19863f2d24e7cbc18
Commit: 3b827c1b3aadf3adb4c602d19863f2d24e7cbc18
Parent: 5ead97c84fa7d63a6a7a2f4e9f18f452bd109045
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:04 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:42 2007 -0700

xen: virtual mmu

Xen pagetable handling, including the machinery to implement direct
pagetables.

Xen presents the real CPU's pagetables directly to guests, with no
added shadowing or other layer of abstraction.  Naturally this means
the hypervisor must maintain close control over what the guest can put
into the pagetable.

When the guest modifies the pte/pmd/pgd, it must convert its
domain-specific notion of a physical pfn into a global machine frame
number (mfn) before inserting the entry into the pagetable.  Xen will
check to make sure the domain is allowed to create a mapping of the
given mfn.

Xen also requires that all mappings the guest has of its own active
pagetable are read-only.  This is relatively easy to implement in
Linux because all pagetables share the same pte pages for kernel
mappings, so updating the pte in one pagetable will implicitly update
the mapping in all pagetables.

Normally a pagetable becomes active when you point to it with cr3 (or
the Xen equivalent), but when you do so, Xen must check the whole
pagetable for correctness, which is clearly a performance problem.

Xen solves this with pinning which keeps a pagetable effectively
active even if its currently unused, which means that all the normal
update rules are enforced.  This means that it need not revalidate the
pagetable when loading cr3.

This patch has a first-cut implementation of pinning, but it is more
fully implemented in a later patch.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
---
 arch/i386/xen/Makefile|2 +-
 arch/i386/xen/enlighten.c |   30 +++-
 arch/i386/xen/mmu.c   |  420 +
 arch/i386/xen/mmu.h   |   47 +
 4 files changed, 494 insertions(+), 5 deletions(-)

diff --git a/arch/i386/xen/Makefile b/arch/i386/xen/Makefile
index 60bc1cf..803c1ee 100644
--- a/arch/i386/xen/Makefile
+++ b/arch/i386/xen/Makefile
@@ -1 +1 @@
-obj-y  := enlighten.o setup.o features.o multicalls.o
+obj-y  := enlighten.o setup.o features.o multicalls.o mmu.o
diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 2d484f9..c0b0aa7 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -39,6 +39,7 @@
 #include asm/pgtable.h
 
 #include xen-ops.h
+#include mmu.h
 #include multicalls.h
 
 EXPORT_SYMBOL_GPL(hypercall_page);
@@ -579,11 +580,9 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
 * Should be set_fixmap(), but shared_info is a machine
 * address with no corresponding pseudo-phys address.
 */
-#if 0
set_pte_mfn(fix_to_virt(FIX_PARAVIRT_BOOTMAP),
PFN_DOWN(xen_start_info-shared_info),
PAGE_KERNEL);
-#endif
 
HYPERVISOR_shared_info =
(struct shared_info *)fix_to_virt(FIX_PARAVIRT_BOOTMAP);
@@ -592,9 +591,7 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
HYPERVISOR_shared_info =
(struct shared_info *)__va(xen_start_info-shared_info);
 
-#if 0
xen_pgd_pin(base);
-#endif
 
xen_vcpu_setup(smp_processor_id());
 }
@@ -690,6 +687,31 @@ static const struct paravirt_ops xen_paravirt_ops 
__initdata = {
.release_pd = xen_release_pd,
.release_pt = xen_release_pt,
 
+   .set_pte = xen_set_pte,
+   .set_pte_at = xen_set_pte_at,
+   .set_pmd = xen_set_pmd,
+
+   .pte_val = xen_pte_val,
+   .pgd_val = xen_pgd_val,
+
+   .make_pte = xen_make_pte,
+   .make_pgd = xen_make_pgd,
+
+#ifdef CONFIG_X86_PAE
+   .set_pte_atomic = xen_set_pte_atomic,
+   .set_pte_present = xen_set_pte_at,
+   .set_pud = xen_set_pud,
+   .pte_clear = xen_pte_clear,
+   .pmd_clear = xen_pmd_clear,
+
+   .make_pmd = xen_make_pmd,
+   .pmd_val = xen_pmd_val,
+#endif /* PAE */
+
+   .activate_mm = xen_activate_mm,
+   .dup_mmap = xen_dup_mmap,
+   .exit_mmap = xen_exit_mmap,
+
.set_lazy_mode = xen_set_lazy_mode,
 };
 
diff --git a/arch/i386/xen/mmu.c b/arch/i386/xen/mmu.c
new file mode 100644
index 000..de16cb5
--- /dev/null
+++ b/arch/i386/xen/mmu.c
@@ -0,0 +1,420 @@
+/*
+ * Xen mmu operations
+ *
+ * This file contains the various mmu fetch and update operations.
+ * The most important job they must perform is the mapping 

xen: event channels

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e46cdb66c8fc1c8d61cfae0f219ff47ac4b9d531
Commit: e46cdb66c8fc1c8d61cfae0f219ff47ac4b9d531
Parent: 3b827c1b3aadf3adb4c602d19863f2d24e7cbc18
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:05 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:42 2007 -0700

xen: event channels

Xen implements interrupts in terms of event channels.  Each guest
domain gets 1024 event channels which can be used for a variety of
purposes, such as Xen timer events, inter-domain events,
inter-processor events (IPI) or for real hardware IRQs.

Within the kernel, we map the event channels to IRQs, and implement
the whole interrupt handling using a Xen irq_chip.

Rather than setting NR_IRQ to 1024 under PARAVIRT in order to
accomodate Xen, we create a dynamic mapping between event channels and
IRQs.  Ideally, Linux will eventually move towards dynamically
allocating per-irq structures, and we can use a 1:1 mapping between
event channels and irqs.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Cc: Ingo Molnar [EMAIL PROTECTED]
Cc: Eric W. Biederman [EMAIL PROTECTED]
---
 arch/i386/xen/Makefile|3 +-
 arch/i386/xen/enlighten.c |1 +
 arch/i386/xen/events.c|  511 +
 include/xen/events.h  |   28 +++
 4 files changed, 542 insertions(+), 1 deletions(-)

diff --git a/arch/i386/xen/Makefile b/arch/i386/xen/Makefile
index 803c1ee..7a78f27 100644
--- a/arch/i386/xen/Makefile
+++ b/arch/i386/xen/Makefile
@@ -1 +1,2 @@
-obj-y  := enlighten.o setup.o features.o multicalls.o mmu.o
+obj-y  := enlighten.o setup.o features.o multicalls.o mmu.o \
+   events.o
diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index c0b0aa7..6417dfd 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -607,6 +607,7 @@ static const struct paravirt_ops xen_paravirt_ops 
__initdata = {
 
.memory_setup = xen_memory_setup,
.arch_setup = xen_arch_setup,
+   .init_IRQ = xen_init_IRQ,
 
.cpuid = xen_cpuid,
 
diff --git a/arch/i386/xen/events.c b/arch/i386/xen/events.c
new file mode 100644
index 000..e7c5d00
--- /dev/null
+++ b/arch/i386/xen/events.c
@@ -0,0 +1,511 @@
+/*
+ * Xen event channels
+ *
+ * Xen models interrupts with abstract event channels.  Because each
+ * domain gets 1024 event channels, but NR_IRQ is not that large, we
+ * must dynamically map irqs-event channels.  The event channels
+ * interface with the rest of the kernel by defining a xen interrupt
+ * chip.  When an event is recieved, it is mapped to an irq and sent
+ * through the normal interrupt processing path.
+ *
+ * There are four kinds of events which can be mapped to an event
+ * channel:
+ *
+ * 1. Inter-domain notifications.  This includes all the virtual
+ *device events, since they're driven by front-ends in another domain
+ *(typically dom0).
+ * 2. VIRQs, typically used for timers.  These are per-cpu events.
+ * 3. IPIs.
+ * 4. Hardware interrupts. Not supported at present.
+ *
+ * Jeremy Fitzhardinge [EMAIL PROTECTED], XenSource Inc, 2007
+ */
+
+#include linux/linkage.h
+#include linux/interrupt.h
+#include linux/irq.h
+#include linux/module.h
+#include linux/string.h
+
+#include asm/ptrace.h
+#include asm/irq.h
+#include asm/sync_bitops.h
+#include asm/xen/hypercall.h
+
+#include xen/events.h
+#include xen/interface/xen.h
+#include xen/interface/event_channel.h
+
+#include xen-ops.h
+
+/*
+ * This lock protects updates to the following mapping and reference-count
+ * arrays. The lock does not need to be acquired to read the mapping tables.
+ */
+static DEFINE_SPINLOCK(irq_mapping_update_lock);
+
+/* IRQ - VIRQ mapping. */
+static DEFINE_PER_CPU(int, virq_to_irq[NR_VIRQS]) = {[0 ... NR_VIRQS-1] = -1};
+
+/* Packed IRQ information: binding type, sub-type index, and event channel. */
+struct packed_irq
+{
+   unsigned short evtchn;
+   unsigned char index;
+   unsigned char type;
+};
+
+static struct packed_irq irq_info[NR_IRQS];
+
+/* Binding types. */
+enum { IRQT_UNBOUND, IRQT_PIRQ, IRQT_VIRQ, IRQT_IPI, IRQT_EVTCHN };
+
+/* Convenient shorthand for packed representation of an unbound IRQ. */
+#define IRQ_UNBOUNDmk_irq_info(IRQT_UNBOUND, 0, 0)
+
+static int evtchn_to_irq[NR_EVENT_CHANNELS] = {
+   [0 ... NR_EVENT_CHANNELS-1] = -1
+};
+static unsigned long cpu_evtchn_mask[NR_CPUS][NR_EVENT_CHANNELS/BITS_PER_LONG];
+static u8 cpu_evtchn[NR_EVENT_CHANNELS];
+
+/* Reference counts for bindings to IRQs. */
+static int irq_bindcount[NR_IRQS];
+
+/* Xen will never allocate port zero for any purpose. */
+#define VALID_EVTCHN(chn)  ((chn) != 0)
+
+/*
+ * Force a proper event-channel callback from Xen 

xen: time implementation

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=15c84731d647c34d1491793fa6be96f5de3432eb
Commit: 15c84731d647c34d1491793fa6be96f5de3432eb
Parent: e46cdb66c8fc1c8d61cfae0f219ff47ac4b9d531
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:05 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:43 2007 -0700

xen: time implementation

Xen maintains a base clock which measures nanoseconds since system
boot.  This is provided to guests via a shared page which contains a
base time in ns, a tsc timestamp at that point and tsc frequency
parameters.  Guests can compute the current time by reading the tsc
and using it to extrapolate the current time from the basetime.  The
hypervisor makes sure that the frequency parameters are updated
regularly, paricularly if the tsc changes rate or stops.

This is implemented as a clocksource, so the interface to the rest of
the kernel is a simple clocksource which simply returns the current
time directly in nanoseconds.

Xen also provides a simple timer mechanism, which allows a timeout to
be set in the future.  When that time arrives, a timer event is sent
to the guest.  There are two timer interfaces:
 - An old one which also delivers a stream of (unused) ticks at 100Hz,
   and on the same event, the actual timer events.  The 100Hz ticks
   cause a lot of spurious wakeups, but are basically harmless.
 - The new timer interface doesn't have the 100Hz ticks, and can also
   fail if the specified time is in the past.

This code presents the Xen timer as a clockevent driver, and uses the
new interface by preference.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Cc: Ingo Molnar [EMAIL PROTECTED]
Cc: Thomas Gleixner [EMAIL PROTECTED]
---
 arch/i386/xen/Makefile|2 +-
 arch/i386/xen/enlighten.c |6 +
 arch/i386/xen/time.c  |  407 +
 3 files changed, 414 insertions(+), 1 deletions(-)

diff --git a/arch/i386/xen/Makefile b/arch/i386/xen/Makefile
index 7a78f27..bf51cab 100644
--- a/arch/i386/xen/Makefile
+++ b/arch/i386/xen/Makefile
@@ -1,2 +1,2 @@
 obj-y  := enlighten.o setup.o features.o multicalls.o mmu.o \
-   events.o
+   events.o time.o
diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 6417dfd..25eb359 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -609,6 +609,12 @@ static const struct paravirt_ops xen_paravirt_ops 
__initdata = {
.arch_setup = xen_arch_setup,
.init_IRQ = xen_init_IRQ,
 
+   .time_init = xen_time_init,
+   .set_wallclock = xen_set_wallclock,
+   .get_wallclock = xen_get_wallclock,
+   .get_cpu_khz = xen_cpu_khz,
+   .sched_clock = xen_clocksource_read,
+
.cpuid = xen_cpuid,
 
.set_debugreg = xen_set_debugreg,
diff --git a/arch/i386/xen/time.c b/arch/i386/xen/time.c
new file mode 100644
index 000..b457980
--- /dev/null
+++ b/arch/i386/xen/time.c
@@ -0,0 +1,407 @@
+/*
+ * Xen time implementation.
+ *
+ * This is implemented in terms of a clocksource driver which uses
+ * the hypervisor clock as a nanosecond timebase, and a clockevent
+ * driver which uses the hypervisor's timer mechanism.
+ *
+ * Jeremy Fitzhardinge [EMAIL PROTECTED], XenSource Inc, 2007
+ */
+#include linux/kernel.h
+#include linux/interrupt.h
+#include linux/clocksource.h
+#include linux/clockchips.h
+
+#include asm/xen/hypervisor.h
+#include asm/xen/hypercall.h
+
+#include xen/events.h
+#include xen/interface/xen.h
+#include xen/interface/vcpu.h
+
+#include xen-ops.h
+
+#define XEN_SHIFT 22
+
+/* Xen may fire a timer up to this many ns early */
+#define TIMER_SLOP 10
+
+/* These are perodically updated in shared_info, and then copied here. */
+struct shadow_time_info {
+   u64 tsc_timestamp; /* TSC at last update of time vals.  */
+   u64 system_timestamp;  /* Time, in nanosecs, since boot.*/
+   u32 tsc_to_nsec_mul;
+   int tsc_shift;
+   u32 version;
+};
+
+static DEFINE_PER_CPU(struct shadow_time_info, shadow_time);
+
+unsigned long xen_cpu_khz(void)
+{
+   u64 cpu_khz = 100ULL  32;
+   const struct vcpu_time_info *info =
+   HYPERVISOR_shared_info-vcpu_info[0].time;
+
+   do_div(cpu_khz, info-tsc_to_system_mul);
+   if (info-tsc_shift  0)
+   cpu_khz = -info-tsc_shift;
+   else
+   cpu_khz = info-tsc_shift;
+
+   return cpu_khz;
+}
+
+/*
+ * Reads a consistent set of time-base values from Xen, into a shadow data
+ * area.
+ */
+static void get_time_values_from_xen(void)
+{
+   struct vcpu_time_info   *src;
+   struct shadow_time_info *dst;
+
+   preempt_disable();
+
+   /* src is 

xen: configuration

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e738fca8d7dffec30231c38f128eed56c8c8
Commit: e738fca8d7dffec30231c38f128eed56c8c8
Parent: 15c84731d647c34d1491793fa6be96f5de3432eb
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:05 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:43 2007 -0700

xen: configuration

Put config options for Xen after the core pieces are in place.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
---
 arch/i386/Kconfig |2 ++
 arch/i386/xen/Kconfig |   11 +++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index c7c9c2a..7a11b90 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -222,6 +222,8 @@ config PARAVIRT
  However, when run without a hypervisor the kernel is
  theoretically slower.  If in doubt, say N.
 
+source arch/i386/xen/Kconfig
+
 config VMI
bool VMI Paravirt-ops support
depends on PARAVIRT
diff --git a/arch/i386/xen/Kconfig b/arch/i386/xen/Kconfig
new file mode 100644
index 000..7c55500
--- /dev/null
+++ b/arch/i386/xen/Kconfig
@@ -0,0 +1,11 @@
+#
+# This Kconfig describes xen options
+#
+
+config XEN
+   bool Enable support for Xen hypervisor
+   depends on PARAVIRT  X86_CMPXCHG  X86_TSC  !(PREEMPT || SMP || 
NEED_MULTIPLE_NODES)
+   help
+ This is the Linux Xen port.  Enabling this will allow the
+ kernel to boot in a paravirtualized environment under the
+ Xen hypervisor.
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


xen: add pinned page flag

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c85b04c3749507546f6d5868976e4793e35c2ec0
Commit: c85b04c3749507546f6d5868976e4793e35c2ec0
Parent: e738fca8d7dffec30231c38f128eed56c8c8
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:05 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:43 2007 -0700

xen: add pinned page flag

Add a new definition for PG_owner_priv_1 to define PG_pinned on Xen
pagetable pages.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
---
 include/linux/page-flags.h |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index ae2d79f..731cd2a 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -92,6 +92,7 @@
 
 /* PG_owner_priv_1 users should have descriptive aliases */
 #define PG_checked PG_owner_priv_1 /* Used by some filesystems */
+#define PG_pinned  PG_owner_priv_1 /* Xen pinned pagetable */
 
 #if (BITS_PER_LONG  32)
 /*
@@ -170,6 +171,10 @@ static inline void SetPageUptodate(struct page *page)
 #define SetPageChecked(page)   set_bit(PG_checked, (page)-flags)
 #define ClearPageChecked(page) clear_bit(PG_checked, (page)-flags)
 
+#define PagePinned(page)   test_bit(PG_pinned, (page)-flags)
+#define SetPagePinned(page)set_bit(PG_pinned, (page)-flags)
+#define ClearPagePinned(page)  clear_bit(PG_pinned, (page)-flags)
+
 #define PageReserved(page) test_bit(PG_reserved, (page)-flags)
 #define SetPageReserved(page)  set_bit(PG_reserved, (page)-flags)
 #define ClearPageReserved(page)clear_bit(PG_reserved, (page)-flags)
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


xen: Complete pagetable pinning

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f4f97b3ea90130520afb478cbc2918be2b6587b8
Commit: f4f97b3ea90130520afb478cbc2918be2b6587b8
Parent: c85b04c3749507546f6d5868976e4793e35c2ec0
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:05 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:43 2007 -0700

xen: Complete pagetable pinning

Xen requires all active pagetables to be marked read-only.  When the
base of the pagetable is loaded into %cr3, the hypervisor validates
the entire pagetable and only allows the load to proceed if it all
checks out.

This is pretty slow, so to mitigate this cost Xen has a notion of
pinned pagetables.  Pinned pagetables are pagetables which are
considered to be active even if no processor's cr3 is pointing to is.
This means that it must remain read-only and all updates are validated
by the hypervisor.  This makes context switches much cheaper, because
the hypervisor doesn't need to revalidate the pagetable each time.

This also adds a new paravirt hook which is called during setup once
the zones and memory allocator have been initialized.  When the
init_mm pagetable is first built, the struct page array does not yet
exist, and so there's nowhere to put he init_mm pagetable's PG_pinned
flags.  Once the zones are initialized and the struct page array
exists, we can set the PG_pinned flags for those pages.

This patch also adds the Xen support for pte pages allocated out of
highmem (highpte) by implementing xen_kmap_atomic_pte.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Cc: Zach Amsden [EMAIL PROTECTED]
---
 arch/i386/xen/enlighten.c |   87 ---
 arch/i386/xen/mmu.c   |  260 +
 arch/i386/xen/mmu.h   |2 +-
 arch/i386/xen/xen-ops.h   |2 +
 4 files changed, 242 insertions(+), 109 deletions(-)

diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 25eb359..86e68e6 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -21,6 +21,9 @@
 #include linux/sched.h
 #include linux/bootmem.h
 #include linux/module.h
+#include linux/mm.h
+#include linux/page-flags.h
+#include linux/highmem.h
 
 #include xen/interface/xen.h
 #include xen/interface/physdev.h
@@ -500,32 +503,59 @@ static void xen_write_cr3(unsigned long cr3)
}
 }
 
-static void xen_alloc_pt(struct mm_struct *mm, u32 pfn)
+/* Early in boot, while setting up the initial pagetable, assume
+   everything is pinned. */
+static void xen_alloc_pt_init(struct mm_struct *mm, u32 pfn)
 {
-   /* XXX pfn isn't necessarily a lowmem page */
+   BUG_ON(mem_map);/* should only be used early */
make_lowmem_page_readonly(__va(PFN_PHYS(pfn)));
 }
 
-static void xen_alloc_pd(u32 pfn)
+/* This needs to make sure the new pte page is pinned iff its being
+   attached to a pinned pagetable. */
+static void xen_alloc_pt(struct mm_struct *mm, u32 pfn)
 {
-   make_lowmem_page_readonly(__va(PFN_PHYS(pfn)));
-}
+   struct page *page = pfn_to_page(pfn);
 
-static void xen_release_pd(u32 pfn)
-{
-   make_lowmem_page_readwrite(__va(PFN_PHYS(pfn)));
+   if (PagePinned(virt_to_page(mm-pgd))) {
+   SetPagePinned(page);
+
+   if (!PageHighMem(page))
+   make_lowmem_page_readonly(__va(PFN_PHYS(pfn)));
+   else
+   /* make sure there are no stray mappings of
+  this page */
+   kmap_flush_unused();
+   }
 }
 
+/* This should never happen until we're OK to use struct page */
 static void xen_release_pt(u32 pfn)
 {
-   make_lowmem_page_readwrite(__va(PFN_PHYS(pfn)));
+   struct page *page = pfn_to_page(pfn);
+
+   if (PagePinned(page)) {
+   if (!PageHighMem(page))
+   make_lowmem_page_readwrite(__va(PFN_PHYS(pfn)));
+   }
 }
 
-static void xen_alloc_pd_clone(u32 pfn, u32 clonepfn,
-   u32 start, u32 count)
+#ifdef CONFIG_HIGHPTE
+static void *xen_kmap_atomic_pte(struct page *page, enum km_type type)
 {
-   xen_alloc_pd(pfn);
+   pgprot_t prot = PAGE_KERNEL;
+
+   if (PagePinned(page))
+   prot = PAGE_KERNEL_RO;
+
+   if (0  PageHighMem(page))
+   printk(mapping highpte %lx type %d prot %s\n,
+  page_to_pfn(page), type,
+  (unsigned long)pgprot_val(prot)  _PAGE_RW ? WRITE : 
READ);
+
+   return kmap_atomic_prot(page, type, prot);
 }
+#endif
 
 static __init void xen_pagetable_setup_start(pgd_t *base)
 {
@@ -553,7 +583,7 @@ static __init void xen_pagetable_setup_start(pgd_t *base)
memcpy(pmd, (void 

xen: ignore RW mapping of RO pages in pagetable_init

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9a4029fd3409eb224eb62c32d9792071382694ec
Commit: 9a4029fd3409eb224eb62c32d9792071382694ec
Parent: f4f97b3ea90130520afb478cbc2918be2b6587b8
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:05 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:43 2007 -0700

xen: ignore RW mapping of RO pages in pagetable_init

When setting up the initial pagetable, which includes mappings of all
low physical memory, ignore a mapping which tries to set the RW bit on
an RO pte.  An RO pte indicates a page which is part of the current
pagetable, and so it cannot be allowed to become RW.

Once xen_pagetable_setup_done is called, set_pte reverts to its normal
behaviour.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Acked-by: Chris Wright [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED] (Eric W. Biederman)
---
 arch/i386/xen/enlighten.c |   27 +--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 86e68e6..9550ae3 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -505,7 +505,7 @@ static void xen_write_cr3(unsigned long cr3)
 
 /* Early in boot, while setting up the initial pagetable, assume
everything is pinned. */
-static void xen_alloc_pt_init(struct mm_struct *mm, u32 pfn)
+static __init void xen_alloc_pt_init(struct mm_struct *mm, u32 pfn)
 {
BUG_ON(mem_map);/* should only be used early */
make_lowmem_page_readonly(__va(PFN_PHYS(pfn)));
@@ -557,10 +557,32 @@ static void *xen_kmap_atomic_pte(struct page *page, enum 
km_type type)
 }
 #endif
 
+static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte)
+{
+   /* If there's an existing pte, then don't allow _PAGE_RW to be set */
+   if (pte_val_ma(*ptep)  _PAGE_PRESENT)
+   pte = __pte_ma(((pte_val_ma(*ptep)  _PAGE_RW) | ~_PAGE_RW) 
+  pte_val_ma(pte));
+
+   return pte;
+}
+
+/* Init-time set_pte while constructing initial pagetables, which
+   doesn't allow RO pagetable pages to be remapped RW */
+static __init void xen_set_pte_init(pte_t *ptep, pte_t pte)
+{
+   pte = mask_rw_pte(ptep, pte);
+
+   xen_set_pte(ptep, pte);
+}
+
 static __init void xen_pagetable_setup_start(pgd_t *base)
 {
pgd_t *xen_pgd = (pgd_t *)xen_start_info-pt_base;
 
+   /* special set_pte for pagetable initialization */
+   paravirt_ops.set_pte = xen_set_pte_init;
+
init_mm.pgd = base;
/*
 * copy top-level of Xen-supplied pagetable into place.  For
@@ -607,6 +629,7 @@ static __init void xen_pagetable_setup_done(pgd_t *base)
/* This will work as long as patching hasn't happened yet
   (which it hasn't) */
paravirt_ops.alloc_pt = xen_alloc_pt;
+   paravirt_ops.set_pte = xen_set_pte;
 
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
/*
@@ -745,7 +768,7 @@ static const struct paravirt_ops xen_paravirt_ops 
__initdata = {
.kmap_atomic_pte = xen_kmap_atomic_pte,
 #endif
 
-   .set_pte = xen_set_pte,
+   .set_pte = NULL,/* see xen_pagetable_setup_* */
.set_pte_at = xen_set_pte_at,
.set_pmd = xen_set_pmd,
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


xen: Account for stolen time

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f91a8b447b9af64f589f6e13fec7f09b5927563d
Commit: f91a8b447b9af64f589f6e13fec7f09b5927563d
Parent: 9a4029fd3409eb224eb62c32d9792071382694ec
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:05 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:43 2007 -0700

xen: Account for stolen time

This patch accounts for the time stolen from our VCPUs.  Stolen time is
time where a vcpu is runnable and could be running, but all available
physical CPUs are being used for something else.

This accounting gets run on each timer interrupt, just as a way to get
it run relatively often, and when interesting things are going on.
Stolen time is not really used by much in the kernel; it is reported
in /proc/stats, and that's about it.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Acked-by: Chris Wright [EMAIL PROTECTED]
Cc: john stultz [EMAIL PROTECTED]
Cc: Rik van Riel [EMAIL PROTECTED]
---
 arch/i386/xen/time.c |  159 +++---
 1 files changed, 150 insertions(+), 9 deletions(-)

diff --git a/arch/i386/xen/time.c b/arch/i386/xen/time.c
index b457980..acbfd99 100644
--- a/arch/i386/xen/time.c
+++ b/arch/i386/xen/time.c
@@ -11,6 +11,7 @@
 #include linux/interrupt.h
 #include linux/clocksource.h
 #include linux/clockchips.h
+#include linux/kernel_stat.h
 
 #include asm/xen/hypervisor.h
 #include asm/xen/hypercall.h
@@ -25,6 +26,7 @@
 
 /* Xen may fire a timer up to this many ns early */
 #define TIMER_SLOP 10
+#define NS_PER_TICK(10LL / HZ)
 
 /* These are perodically updated in shared_info, and then copied here. */
 struct shadow_time_info {
@@ -37,6 +39,139 @@ struct shadow_time_info {
 
 static DEFINE_PER_CPU(struct shadow_time_info, shadow_time);
 
+/* runstate info updated by Xen */
+static DEFINE_PER_CPU(struct vcpu_runstate_info, runstate);
+
+/* snapshots of runstate info */
+static DEFINE_PER_CPU(struct vcpu_runstate_info, runstate_snapshot);
+
+/* unused ns of stolen and blocked time */
+static DEFINE_PER_CPU(u64, residual_stolen);
+static DEFINE_PER_CPU(u64, residual_blocked);
+
+/* return an consistent snapshot of 64-bit time/counter value */
+static u64 get64(const u64 *p)
+{
+   u64 ret;
+
+   if (BITS_PER_LONG  64) {
+   u32 *p32 = (u32 *)p;
+   u32 h, l;
+
+   /*
+* Read high then low, and then make sure high is
+* still the same; this will only loop if low wraps
+* and carries into high.
+* XXX some clean way to make this endian-proof?
+*/
+   do {
+   h = p32[1];
+   barrier();
+   l = p32[0];
+   barrier();
+   } while (p32[1] != h);
+
+   ret = (((u64)h)  32) | l;
+   } else
+   ret = *p;
+
+   return ret;
+}
+
+/*
+ * Runstate accounting
+ */
+static void get_runstate_snapshot(struct vcpu_runstate_info *res)
+{
+   u64 state_time;
+   struct vcpu_runstate_info *state;
+
+   preempt_disable();
+
+   state = __get_cpu_var(runstate);
+
+   /*
+* The runstate info is always updated by the hypervisor on
+* the current CPU, so there's no need to use anything
+* stronger than a compiler barrier when fetching it.
+*/
+   do {
+   state_time = get64(state-state_entry_time);
+   barrier();
+   *res = *state;
+   barrier();
+   } while (get64(state-state_entry_time) != state_time);
+
+   preempt_enable();
+}
+
+static void setup_runstate_info(int cpu)
+{
+   struct vcpu_register_runstate_memory_area area;
+
+   area.addr.v = per_cpu(runstate, cpu);
+
+   if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area,
+  cpu, area))
+   BUG();
+}
+
+static void do_stolen_accounting(void)
+{
+   struct vcpu_runstate_info state;
+   struct vcpu_runstate_info *snap;
+   s64 blocked, runnable, offline, stolen;
+   cputime_t ticks;
+
+   get_runstate_snapshot(state);
+
+   WARN_ON(state.state != RUNSTATE_running);
+
+   snap = __get_cpu_var(runstate_snapshot);
+
+   /* work out how much time the VCPU has not been runn*ing*  */
+   blocked = state.time[RUNSTATE_blocked] - snap-time[RUNSTATE_blocked];
+   runnable = state.time[RUNSTATE_runnable] - 
snap-time[RUNSTATE_runnable];
+   offline = state.time[RUNSTATE_offline] - snap-time[RUNSTATE_offline];
+
+   *snap = state;
+
+   /* Add the appropriate number of ticks of stolen time,
+  including any left-overs from last time.  Passing NULL to
+  account_steal_time accounts the time as stolen. */
+   

xen: Implement sched_clock

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ab55028886dd1dd54585f22bf19a00eb23869340
Commit: ab55028886dd1dd54585f22bf19a00eb23869340
Parent: f91a8b447b9af64f589f6e13fec7f09b5927563d
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:05 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:43 2007 -0700

xen: Implement sched_clock

Implement xen_sched_clock, which returns the number of ns the current
vcpu has been actually in an unstolen state (ie, running or blocked,
vs runnable-but-not-running, or offline) since boot.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Acked-by: Chris Wright [EMAIL PROTECTED]
Cc: john stultz [EMAIL PROTECTED]
---
 arch/i386/xen/enlighten.c |2 +-
 arch/i386/xen/time.c  |   27 ++-
 arch/i386/xen/xen-ops.h   |3 +--
 3 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 9550ae3..a9ba834 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -683,7 +683,7 @@ static const struct paravirt_ops xen_paravirt_ops 
__initdata = {
.set_wallclock = xen_set_wallclock,
.get_wallclock = xen_get_wallclock,
.get_cpu_khz = xen_cpu_khz,
-   .sched_clock = xen_clocksource_read,
+   .sched_clock = xen_sched_clock,
 
.cpuid = xen_cpuid,
 
diff --git a/arch/i386/xen/time.c b/arch/i386/xen/time.c
index acbfd99..2aab44b 100644
--- a/arch/i386/xen/time.c
+++ b/arch/i386/xen/time.c
@@ -28,6 +28,8 @@
 #define TIMER_SLOP 10
 #define NS_PER_TICK(10LL / HZ)
 
+static cycle_t xen_clocksource_read(void);
+
 /* These are perodically updated in shared_info, and then copied here. */
 struct shadow_time_info {
u64 tsc_timestamp; /* TSC at last update of time vals.  */
@@ -169,6 +171,29 @@ static void do_stolen_accounting(void)
account_steal_time(idle_task(smp_processor_id()), ticks);
 }
 
+/*
+ * Xen sched_clock implementation.  Returns the number of unstolen
+ * nanoseconds, which is nanoseconds the VCPU spent in RUNNING+BLOCKED
+ * states.
+ */
+unsigned long long xen_sched_clock(void)
+{
+   struct vcpu_runstate_info state;
+   cycle_t now = xen_clocksource_read();
+   s64 offset;
+
+   get_runstate_snapshot(state);
+
+   WARN_ON(state.state != RUNSTATE_running);
+
+   offset = now - state.state_entry_time;
+   if (offset  0)
+   offset = 0;
+
+   return state.time[RUNSTATE_blocked] +
+   state.time[RUNSTATE_running] +
+   offset;
+}
 
 
 /* Get the CPU speed from Xen */
@@ -261,7 +286,7 @@ static u64 get_nsec_offset(struct shadow_time_info *shadow)
return scale_delta(delta, shadow-tsc_to_nsec_mul, shadow-tsc_shift);
 }
 
-cycle_t xen_clocksource_read(void)
+static cycle_t xen_clocksource_read(void)
 {
struct shadow_time_info *shadow = get_cpu_var(shadow_time);
cycle_t ret;
diff --git a/arch/i386/xen/xen-ops.h b/arch/i386/xen/xen-ops.h
index 54d98b5..7667abd 100644
--- a/arch/i386/xen/xen-ops.h
+++ b/arch/i386/xen/xen-ops.h
@@ -2,7 +2,6 @@
 #define XEN_OPS_H
 
 #include linux/init.h
-#include linux/clocksource.h
 
 DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
 DECLARE_PER_CPU(unsigned long, xen_cr3);
@@ -18,7 +17,7 @@ unsigned long xen_cpu_khz(void);
 void __init xen_time_init(void);
 unsigned long xen_get_wallclock(void);
 int xen_set_wallclock(unsigned long time);
-cycle_t xen_clocksource_read(void);
+unsigned long long xen_sched_clock(void);
 
 void xen_mark_init_mm_pinned(void);
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


xen: SMP guest support

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f87e4cac4f4e940b328d3deb5b53e642e3881f43
Commit: f87e4cac4f4e940b328d3deb5b53e642e3881f43
Parent: ab55028886dd1dd54585f22bf19a00eb23869340
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:06 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:44 2007 -0700

xen: SMP guest support

This is a fairly straightforward Xen implementation of smp_ops.

Xen has its own IPI mechanisms, and has no dependency on any
APIC-based IPI.  The smp_ops hooks and the flush_tlb_others pv_op
allow a Xen guest to avoid all APIC code in arch/i386 (the only apic
operation is a single apic_read for the apic version number).

One subtle point which needs to be addressed is unpinning pagetables
when another cpu may have a lazy tlb reference to the pagetable. Xen
will not allow an in-use pagetable to be unpinned, so we must find any
other cpus with a reference to the pagetable and get them to shoot
down their references.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Cc: Benjamin LaHaise [EMAIL PROTECTED]
Cc: Ingo Molnar [EMAIL PROTECTED]
Cc: Andi Kleen [EMAIL PROTECTED]
---
 arch/i386/xen/Kconfig |2 +-
 arch/i386/xen/Makefile|2 +
 arch/i386/xen/enlighten.c |  115 ++---
 arch/i386/xen/events.c|   80 +-
 arch/i386/xen/mmu.c   |   69 ++--
 arch/i386/xen/mmu.h   |   13 ++
 arch/i386/xen/setup.c |5 +
 arch/i386/xen/smp.c   |  407 +
 arch/i386/xen/time.c  |   13 +-
 arch/i386/xen/xen-ops.h   |   25 +++
 include/xen/events.h  |   27 +++-
 11 files changed, 705 insertions(+), 53 deletions(-)

diff --git a/arch/i386/xen/Kconfig b/arch/i386/xen/Kconfig
index 7c55500..b7697ff 100644
--- a/arch/i386/xen/Kconfig
+++ b/arch/i386/xen/Kconfig
@@ -4,7 +4,7 @@
 
 config XEN
bool Enable support for Xen hypervisor
-   depends on PARAVIRT  X86_CMPXCHG  X86_TSC  !(PREEMPT || SMP || 
NEED_MULTIPLE_NODES)
+   depends on PARAVIRT  X86_CMPXCHG  X86_TSC  !(PREEMPT || 
NEED_MULTIPLE_NODES)
help
  This is the Linux Xen port.  Enabling this will allow the
  kernel to boot in a paravirtualized environment under the
diff --git a/arch/i386/xen/Makefile b/arch/i386/xen/Makefile
index bf51cab..fd05f24 100644
--- a/arch/i386/xen/Makefile
+++ b/arch/i386/xen/Makefile
@@ -1,2 +1,4 @@
 obj-y  := enlighten.o setup.o features.o multicalls.o mmu.o \
events.o time.o
+
+obj-$(CONFIG_SMP)  += smp.o
diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index a9ba834..de62d66 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -24,6 +24,7 @@
 #include linux/mm.h
 #include linux/page-flags.h
 #include linux/highmem.h
+#include linux/smp.h
 
 #include xen/interface/xen.h
 #include xen/interface/physdev.h
@@ -40,6 +41,7 @@
 #include asm/setup.h
 #include asm/desc.h
 #include asm/pgtable.h
+#include asm/tlbflush.h
 
 #include xen-ops.h
 #include mmu.h
@@ -56,7 +58,7 @@ DEFINE_PER_CPU(unsigned long, xen_cr3);
 struct start_info *xen_start_info;
 EXPORT_SYMBOL_GPL(xen_start_info);
 
-static void xen_vcpu_setup(int cpu)
+void xen_vcpu_setup(int cpu)
 {
per_cpu(xen_vcpu, cpu) = HYPERVISOR_shared_info-vcpu_info[cpu];
 }
@@ -347,23 +349,14 @@ static void xen_write_idt_entry(struct desc_struct *dt, 
int entrynum,
}
 }
 
-/* Load a new IDT into Xen.  In principle this can be per-CPU, so we
-   hold a spinlock to protect the static traps[] array (static because
-   it avoids allocation, and saves stack space). */
-static void xen_load_idt(const struct Xgt_desc_struct *desc)
+static void xen_convert_trap_info(const struct Xgt_desc_struct *desc,
+ struct trap_info *traps)
 {
-   static DEFINE_SPINLOCK(lock);
-   static struct trap_info traps[257];
-
-   int cpu = smp_processor_id();
unsigned in, out, count;
 
-   per_cpu(idt_desc, cpu) = *desc;
-
count = (desc-size+1) / 8;
BUG_ON(count  256);
 
-   spin_lock(lock);
for (in = out = 0; in  count; in++) {
const u32 *entry = (u32 *)(desc-address + in * 8);
 
@@ -371,6 +364,31 @@ static void xen_load_idt(const struct Xgt_desc_struct 
*desc)
out++;
}
traps[out].address = 0;
+}
+
+void xen_copy_trap_info(struct trap_info *traps)
+{
+   const struct Xgt_desc_struct *desc = get_cpu_var(idt_desc);
+
+   xen_convert_trap_info(desc, traps);
+
+   put_cpu_var(idt_desc);
+}
+
+/* Load a new IDT into Xen.  In principle this can be per-CPU, so we
+   hold a spinlock to protect the static traps[] array (static because
+   it avoids allocation, and saves stack space). */
+static 

xen: Add support for preemption

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f120f13ea0dbb0b0d6675683d5f6faea71277e65
Commit: f120f13ea0dbb0b0d6675683d5f6faea71277e65
Parent: f87e4cac4f4e940b328d3deb5b53e642e3881f43
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:06 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:44 2007 -0700

xen: Add support for preemption

Add Xen support for preemption.  This is mostly a cleanup of existing
preempt_enable/disable calls, or just comments to explain the current
usage.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
---
 arch/i386/xen/Kconfig  |2 +-
 arch/i386/xen/enlighten.c  |   80 +++-
 arch/i386/xen/mmu.c|3 ++
 arch/i386/xen/multicalls.c |   11 +++---
 arch/i386/xen/time.c   |   22 +---
 5 files changed, 76 insertions(+), 42 deletions(-)

diff --git a/arch/i386/xen/Kconfig b/arch/i386/xen/Kconfig
index b7697ff..9df99e1 100644
--- a/arch/i386/xen/Kconfig
+++ b/arch/i386/xen/Kconfig
@@ -4,7 +4,7 @@
 
 config XEN
bool Enable support for Xen hypervisor
-   depends on PARAVIRT  X86_CMPXCHG  X86_TSC  !(PREEMPT || 
NEED_MULTIPLE_NODES)
+   depends on PARAVIRT  X86_CMPXCHG  X86_TSC  !NEED_MULTIPLE_NODES
help
  This is the Linux Xen port.  Enabling this will allow the
  kernel to boot in a paravirtualized environment under the
diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index de62d66..a1124b7 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -15,6 +15,7 @@
 #include linux/init.h
 #include linux/smp.h
 #include linux/preempt.h
+#include linux/hardirq.h
 #include linux/percpu.h
 #include linux/delay.h
 #include linux/start_kernel.h
@@ -108,11 +109,10 @@ static unsigned long xen_save_fl(void)
struct vcpu_info *vcpu;
unsigned long flags;
 
-   preempt_disable();
vcpu = x86_read_percpu(xen_vcpu);
+
/* flag has opposite sense of mask */
flags = !vcpu-evtchn_upcall_mask;
-   preempt_enable();
 
/* convert to IF type flag
   -0 - 0x
@@ -125,32 +125,35 @@ static void xen_restore_fl(unsigned long flags)
 {
struct vcpu_info *vcpu;
 
-   preempt_disable();
-
/* convert from IF type flag */
flags = !(flags  X86_EFLAGS_IF);
+
+   /* There's a one instruction preempt window here.  We need to
+  make sure we're don't switch CPUs between getting the vcpu
+  pointer and updating the mask. */
+   preempt_disable();
vcpu = x86_read_percpu(xen_vcpu);
vcpu-evtchn_upcall_mask = flags;
+   preempt_enable_no_resched();
 
-   if (flags == 0) {
-   /* Unmask then check (avoid races).  We're only protecting
-  against updates by this CPU, so there's no need for
-  anything stronger. */
-   barrier();
+   /* Doesn't matter if we get preempted here, because any
+  pending event will get dealt with anyway. */
 
+   if (flags == 0) {
+   preempt_check_resched();
+   barrier(); /* unmask then check (avoid races) */
if (unlikely(vcpu-evtchn_upcall_pending))
force_evtchn_callback();
-   preempt_enable();
-   } else
-   preempt_enable_no_resched();
+   }
 }
 
 static void xen_irq_disable(void)
 {
-   struct vcpu_info *vcpu;
+   /* There's a one instruction preempt window here.  We need to
+  make sure we're don't switch CPUs between getting the vcpu
+  pointer and updating the mask. */
preempt_disable();
-   vcpu = x86_read_percpu(xen_vcpu);
-   vcpu-evtchn_upcall_mask = 1;
+   x86_read_percpu(xen_vcpu)-evtchn_upcall_mask = 1;
preempt_enable_no_resched();
 }
 
@@ -158,18 +161,20 @@ static void xen_irq_enable(void)
 {
struct vcpu_info *vcpu;
 
+   /* There's a one instruction preempt window here.  We need to
+  make sure we're don't switch CPUs between getting the vcpu
+  pointer and updating the mask. */
preempt_disable();
vcpu = x86_read_percpu(xen_vcpu);
vcpu-evtchn_upcall_mask = 0;
+   preempt_enable_no_resched();
 
-   /* Unmask then check (avoid races).  We're only protecting
-  against updates by this CPU, so there's no need for
-  anything stronger. */
-   barrier();
+   /* Doesn't matter if we get preempted here, because any
+  pending event will get dealt with anyway. */
 
+   barrier(); /* unmask then check (avoid races) */
if (unlikely(vcpu-evtchn_upcall_pending))
force_evtchn_callback();
-   preempt_enable();
 }
 
 static void xen_safe_halt(void)
@@ -189,6 +194,8 @@ static void 

xen: lazy-mmu operations

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d66bf8fcf3fce058a1cd164a7c8ee6093fdf039c
Commit: d66bf8fcf3fce058a1cd164a7c8ee6093fdf039c
Parent: f120f13ea0dbb0b0d6675683d5f6faea71277e65
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:06 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:44 2007 -0700

xen: lazy-mmu operations

This patch uses the lazy-mmu hooks to batch mmu operations where
possible.  This is primarily useful for batching operations applied to
active pagetables, which happens during mprotect, munmap, mremap and
the like (mmap does not do bulk pagetable operations, so it isn't
helped).

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Acked-by: Chris Wright [EMAIL PROTECTED]
---
 arch/i386/xen/enlighten.c  |   48 ++--
 arch/i386/xen/mmu.c|   52 +---
 arch/i386/xen/multicalls.c |4 +-
 3 files changed, 72 insertions(+), 32 deletions(-)

diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index a1124b7..031dc1d 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -472,28 +472,38 @@ static void xen_apic_write(unsigned long reg, unsigned 
long val)
 
 static void xen_flush_tlb(void)
 {
-   struct mmuext_op op;
+   struct mmuext_op *op;
+   struct multicall_space mcs = xen_mc_entry(sizeof(*op));
 
-   op.cmd = MMUEXT_TLB_FLUSH_LOCAL;
-   if (HYPERVISOR_mmuext_op(op, 1, NULL, DOMID_SELF))
-   BUG();
+   op = mcs.args;
+   op-cmd = MMUEXT_TLB_FLUSH_LOCAL;
+   MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
+
+   xen_mc_issue(PARAVIRT_LAZY_MMU);
 }
 
 static void xen_flush_tlb_single(unsigned long addr)
 {
-   struct mmuext_op op;
+   struct mmuext_op *op;
+   struct multicall_space mcs = xen_mc_entry(sizeof(*op));
 
-   op.cmd = MMUEXT_INVLPG_LOCAL;
-   op.arg1.linear_addr = addr  PAGE_MASK;
-   if (HYPERVISOR_mmuext_op(op, 1, NULL, DOMID_SELF))
-   BUG();
+   op = mcs.args;
+   op-cmd = MMUEXT_INVLPG_LOCAL;
+   op-arg1.linear_addr = addr  PAGE_MASK;
+   MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
+
+   xen_mc_issue(PARAVIRT_LAZY_MMU);
 }
 
 static void xen_flush_tlb_others(const cpumask_t *cpus, struct mm_struct *mm,
 unsigned long va)
 {
-   struct mmuext_op op;
+   struct {
+   struct mmuext_op op;
+   cpumask_t mask;
+   } *args;
cpumask_t cpumask = *cpus;
+   struct multicall_space mcs;
 
/*
 * A couple of (to be removed) sanity checks:
@@ -510,17 +520,21 @@ static void xen_flush_tlb_others(const cpumask_t *cpus, 
struct mm_struct *mm,
if (cpus_empty(cpumask))
return;
 
+   mcs = xen_mc_entry(sizeof(*args));
+   args = mcs.args;
+   args-mask = cpumask;
+   args-op.arg2.vcpumask = args-mask;
+
if (va == TLB_FLUSH_ALL) {
-   op.cmd = MMUEXT_TLB_FLUSH_MULTI;
-   op.arg2.vcpumask = (void *)cpus;
+   args-op.cmd = MMUEXT_TLB_FLUSH_MULTI;
} else {
-   op.cmd = MMUEXT_INVLPG_MULTI;
-   op.arg1.linear_addr = va;
-   op.arg2.vcpumask = (void *)cpus;
+   args-op.cmd = MMUEXT_INVLPG_MULTI;
+   args-op.arg1.linear_addr = va;
}
 
-   if (HYPERVISOR_mmuext_op(op, 1, NULL, DOMID_SELF))
-   BUG();
+   MULTI_mmuext_op(mcs.mc, args-op, 1, NULL, DOMID_SELF);
+
+   xen_mc_issue(PARAVIRT_LAZY_MMU);
 }
 
 static unsigned long xen_read_cr2(void)
diff --git a/arch/i386/xen/mmu.c b/arch/i386/xen/mmu.c
index f431cf1..4ae038a 100644
--- a/arch/i386/xen/mmu.c
+++ b/arch/i386/xen/mmu.c
@@ -98,12 +98,20 @@ void make_lowmem_page_readwrite(void *vaddr)
 
 void xen_set_pmd(pmd_t *ptr, pmd_t val)
 {
-   struct mmu_update u;
+   struct multicall_space mcs;
+   struct mmu_update *u;
 
-   u.ptr = virt_to_machine(ptr).maddr;
-   u.val = pmd_val_ma(val);
-   if (HYPERVISOR_mmu_update(u, 1, NULL, DOMID_SELF)  0)
-   BUG();
+   preempt_disable();
+
+   mcs = xen_mc_entry(sizeof(*u));
+   u = mcs.args;
+   u-ptr = virt_to_machine(ptr).maddr;
+   u-val = pmd_val_ma(val);
+   MULTI_mmu_update(mcs.mc, u, 1, NULL, DOMID_SELF);
+
+   xen_mc_issue(PARAVIRT_LAZY_MMU);
+
+   preempt_enable();
 }
 
 /*
@@ -146,20 +154,38 @@ void set_pte_mfn(unsigned long vaddr, unsigned long mfn, 
pgprot_t flags)
 void xen_set_pte_at(struct mm_struct *mm, unsigned long addr,
pte_t *ptep, pte_t pteval)
 {
-   if ((mm != current-mm  mm != init_mm) ||
-   HYPERVISOR_update_va_mapping(addr, pteval, 0) != 0)
-   xen_set_pte(ptep, pteval);
+   if (mm == current-mm || mm == 

xen: hack to prevent bad segment register reload

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8b84ad942b534f8faeb34b68f0f7277ea375fed0
Commit: 8b84ad942b534f8faeb34b68f0f7277ea375fed0
Parent: d66bf8fcf3fce058a1cd164a7c8ee6093fdf039c
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:06 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:44 2007 -0700

xen: hack to prevent bad segment register reload

The hypervisor saves and restores the segment registers as part of the
state is saves while context switching.  If, during a context switch,
the next process doesn't use the TLS segments, it invalidates the GDT
entry, causing the segment register reload to fault.  This fault
effectively doubles the cost of a context switch.

This patch is a band-aid workaround which clears the usermode %gs
after it has been saved for the previous process, but before it gets
reloaded for the next, and it avoids having the hypervisor attempt to
erroneously reload it.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
---
 arch/i386/xen/enlighten.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 031dc1d..4275677 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -291,6 +291,18 @@ static void xen_load_tls(struct thread_struct *t, unsigned 
int cpu)
load_TLS_descriptor(t, cpu, 2);
 
xen_mc_issue(PARAVIRT_LAZY_CPU);
+
+   /*
+* XXX sleazy hack: If we're being called in a lazy-cpu zone,
+* it means we're in a context switch, and %gs has just been
+* saved.  This means we can zero it out to prevent faults on
+* exit from the hypervisor if the next process has no %gs.
+* Either way, it has been saved, and the new value will get
+* loaded properly.  This will go away as soon as Xen has been
+* modified to not save/restore %gs for normal hypercalls.
+*/
+   if (xen_get_lazy_mode() == PARAVIRT_LAZY_CPU)
+   loadsegment(gs, 0);
 }
 
 static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum,
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


xen: use the hvc console infrastructure for Xen console

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b536b4b9623084d86f2b1f19cb44a2d6d74f00bf
Commit: b536b4b9623084d86f2b1f19cb44a2d6d74f00bf
Parent: 8b84ad942b534f8faeb34b68f0f7277ea375fed0
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:06 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:44 2007 -0700

xen: use the hvc console infrastructure for Xen console

Implement a Xen back-end for hvc console.

* * *
Add early printk support via hvc console, enable using
earlyprintk=xen on the kernel command line.

From: Gerd Hoffmann [EMAIL PROTECTED]
Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Acked-by: Ingo Molnar [EMAIL PROTECTED]
Acked-by: Olof Johansson [EMAIL PROTECTED]
---
 arch/i386/xen/events.c|3 +-
 arch/x86_64/kernel/early_printk.c |5 +
 drivers/char/Kconfig  |8 ++
 drivers/char/Makefile |1 +
 drivers/char/hvc_xen.c|  159 +
 include/xen/events.h  |1 +
 include/xen/hvc-console.h |6 ++
 7 files changed, 182 insertions(+), 1 deletions(-)

diff --git a/arch/i386/xen/events.c b/arch/i386/xen/events.c
index 4103b8b..8904acc 100644
--- a/arch/i386/xen/events.c
+++ b/arch/i386/xen/events.c
@@ -244,7 +244,7 @@ static int find_unbound_irq(void)
return irq;
 }
 
-static int bind_evtchn_to_irq(unsigned int evtchn)
+int bind_evtchn_to_irq(unsigned int evtchn)
 {
int irq;
 
@@ -269,6 +269,7 @@ static int bind_evtchn_to_irq(unsigned int evtchn)
 
return irq;
 }
+EXPORT_SYMBOL_GPL(bind_evtchn_to_irq);
 
 static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
 {
diff --git a/arch/x86_64/kernel/early_printk.c 
b/arch/x86_64/kernel/early_printk.c
index 296d2b0..fd9aff3 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -6,6 +6,7 @@
 #include asm/io.h
 #include asm/processor.h
 #include asm/fcntl.h
+#include xen/hvc-console.h
 
 /* Simple VGA output */
 
@@ -242,6 +243,10 @@ static int __init setup_early_printk(char *buf)
simnow_init(buf + 6);
early_console = simnow_console;
keep_early = 1;
+#ifdef CONFIG_HVC_XEN
+   } else if (!strncmp(buf, xen, 3)) {
+   early_console = xenboot_console;
+#endif
}
 
if (keep_early)
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 97bd71b..9e8f214 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -604,6 +604,14 @@ config HVC_BEAT
help
  Toshiba's Cell Reference Set Beat Console device driver
 
+config HVC_XEN
+   bool Xen Hypervisor Console support
+   depends on XEN
+   select HVC_DRIVER
+   default y
+   help
+ Xen virtual console device driver
+
 config HVCS
tristate IBM Hypervisor Virtual Console Server support
depends on PPC_PSERIES
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index f2996a9..8852b8d 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o
 obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
 obj-$(CONFIG_HVC_BEAT) += hvc_beat.o
 obj-$(CONFIG_HVC_DRIVER)   += hvc_console.o
+obj-$(CONFIG_HVC_XEN)  += hvc_xen.o
 obj-$(CONFIG_RAW_DRIVER)   += raw.o
 obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
 obj-$(CONFIG_MSPEC)+= mspec.o
diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c
new file mode 100644
index 000..dd68f85
--- /dev/null
+++ b/drivers/char/hvc_xen.c
@@ -0,0 +1,159 @@
+/*
+ * xen console driver interface to hvc_console.c
+ *
+ * (c) 2007 Gerd Hoffmann [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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#include linux/console.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/init.h
+#include linux/types.h
+
+#include asm/xen/hypervisor.h
+#include xen/page.h
+#include xen/events.h
+#include xen/interface/io/console.h
+#include xen/hvc-console.h
+
+#include hvc_console.h
+
+#define HVC_COOKIE   0x58656e /* Xen in hex */
+
+static struct hvc_struct 

xen: Add grant table support

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ad9a86121f5a374b48ce2924f8a9d7e94a04db27
Commit: ad9a86121f5a374b48ce2924f8a9d7e94a04db27
Parent: b536b4b9623084d86f2b1f19cb44a2d6d74f00bf
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:06 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:44 2007 -0700

xen: Add grant table support

Add Xen 'grant table' driver which allows granting of access to
selected local memory pages by other virtual machines and,
symmetrically, the mapping of remote memory pages which other virtual
machines have granted access to.

This driver is a prerequisite for many of the Xen virtual device
drivers, which grant the 'device driver domain' restricted and
temporary access to only those memory pages that are currently
involved in I/O operations.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Ian Pratt [EMAIL PROTECTED]
Signed-off-by: Christian Limpach [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
---
 drivers/Makefile|2 +
 drivers/xen/Makefile|1 +
 drivers/xen/grant-table.c   |  582 +++
 include/xen/grant_table.h   |  107 +++
 include/xen/interface/grant_table.h |   94 +-
 5 files changed, 776 insertions(+), 10 deletions(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index 503d825..6d9d7fa 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -15,6 +15,8 @@ obj-$(CONFIG_ACPI)+= acpi/
 obj-$(CONFIG_PNP)  += pnp/
 obj-$(CONFIG_ARM_AMBA) += amba/
 
+obj-$(CONFIG_XEN)  += xen/
+
 # char/ comes before serial/ etc so that the VT console is the boot-time
 # default.
 obj-y  += char/
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
new file mode 100644
index 000..eb42b52
--- /dev/null
+++ b/drivers/xen/Makefile
@@ -0,0 +1 @@
+obj-y  += grant-table.o
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
new file mode 100644
index 000..ea94dba
--- /dev/null
+++ b/drivers/xen/grant-table.c
@@ -0,0 +1,582 @@
+/**
+ * grant_table.c
+ *
+ * Granting foreign access to our memory reservation.
+ *
+ * Copyright (c) 2005-2006, Christopher Clark
+ * Copyright (c) 2004-2005, K A Fraser
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the Software), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include linux/module.h
+#include linux/sched.h
+#include linux/mm.h
+#include linux/vmalloc.h
+#include linux/uaccess.h
+
+#include xen/interface/xen.h
+#include xen/page.h
+#include xen/grant_table.h
+
+#include asm/pgtable.h
+#include asm/sync_bitops.h
+
+
+/* External tools reserve first few grant table entries. */
+#define NR_RESERVED_ENTRIES 8
+#define GNTTAB_LIST_END 0x
+#define GREFS_PER_GRANT_FRAME (PAGE_SIZE / sizeof(struct grant_entry))
+
+static grant_ref_t **gnttab_list;
+static unsigned int nr_grant_frames;
+static unsigned int boot_max_nr_grant_frames;
+static int gnttab_free_count;
+static grant_ref_t gnttab_free_head;
+static DEFINE_SPINLOCK(gnttab_list_lock);
+
+static struct grant_entry *shared;
+
+static struct gnttab_free_callback *gnttab_free_callback_list;
+
+static int gnttab_expand(unsigned int req_entries);
+
+#define RPP (PAGE_SIZE / sizeof(grant_ref_t))
+
+static inline grant_ref_t *__gnttab_entry(grant_ref_t entry)
+{
+   return gnttab_list[(entry) / RPP][(entry) % RPP];
+}
+/* This can be used as an l-value 

xen: add virtual block device driver.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9f27ee595038653ddf8bca871200d39247d6f4fc
Commit: 9f27ee595038653ddf8bca871200d39247d6f4fc
Parent: 4bac07c993d03434ea902d3d4290d9e45944b66c
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:06 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:45 2007 -0700

xen: add virtual block device driver.

The block device frontend driver allows the kernel to access block
devices exported exported by a virtual machine containing a physical
block device driver.

Signed-off-by: Ian Pratt [EMAIL PROTECTED]
Signed-off-by: Christian Limpach [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Cc: Arjan van de Ven [EMAIL PROTECTED]
Cc: Greg KH [EMAIL PROTECTED]
Cc: Jens Axboe [EMAIL PROTECTED]
---
 drivers/block/Kconfig|9 +
 drivers/block/Makefile   |1 +
 drivers/block/xen-blkfront.c |  988 ++
 include/linux/major.h|2 +
 4 files changed, 1000 insertions(+), 0 deletions(-)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 8f65b88..a4a3119 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -427,4 +427,13 @@ config XILINX_SYSACE
help
  Include support for the Xilinx SystemACE CompactFlash interface
 
+config XEN_BLKDEV_FRONTEND
+   tristate Xen virtual block device support
+   depends on XEN
+   default y
+   help
+ This driver implements the front-end of the Xen virtual
+ block device driver.  It communicates with a back-end driver
+ in another domain which drives the actual block device.
+
 endif # BLK_DEV
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 9ee08ab..3e31532 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -29,3 +29,4 @@ obj-$(CONFIG_VIODASD) += viodasd.o
 obj-$(CONFIG_BLK_DEV_SX8)  += sx8.o
 obj-$(CONFIG_BLK_DEV_UB)   += ub.o
 
+obj-$(CONFIG_XEN_BLKDEV_FRONTEND)  += xen-blkfront.o
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
new file mode 100644
index 000..6746c29
--- /dev/null
+++ b/drivers/block/xen-blkfront.c
@@ -0,0 +1,988 @@
+/*
+ * blkfront.c
+ *
+ * XenLinux virtual block device driver.
+ *
+ * Copyright (c) 2003-2004, Keir Fraser  Steve Hand
+ * Modifications by Mark A. Williamson are (c) Intel Research Cambridge
+ * Copyright (c) 2004, Christian Limpach
+ * Copyright (c) 2004, Andrew Warfield
+ * Copyright (c) 2005, Christopher Clark
+ * Copyright (c) 2005, XenSource Ltd
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the Software), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include linux/interrupt.h
+#include linux/blkdev.h
+#include linux/module.h
+
+#include xen/xenbus.h
+#include xen/grant_table.h
+#include xen/events.h
+#include xen/page.h
+
+#include xen/interface/grant_table.h
+#include xen/interface/io/blkif.h
+
+#include asm/xen/hypervisor.h
+
+enum blkif_state {
+   BLKIF_STATE_DISCONNECTED,
+   BLKIF_STATE_CONNECTED,
+   BLKIF_STATE_SUSPENDED,
+};
+
+struct blk_shadow {
+   struct blkif_request req;
+   unsigned long request;
+   unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+};
+
+static struct block_device_operations xlvbd_block_fops;
+
+#define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE)
+
+/*
+ * We have one of these per vbd, whether ide, scsi or 'other'.  They
+ * hang in private_data off the gendisk structure. We may end up
+ * putting all kinds of interesting stuff here :-)
+ */
+struct 

xen: add virtual network device driver

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0d160211965b79de989cf2d170985abeb8da5ec6
Commit: 0d160211965b79de989cf2d170985abeb8da5ec6
Parent: 9f27ee595038653ddf8bca871200d39247d6f4fc
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:06 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:45 2007 -0700

xen: add virtual network device driver

The network device frontend driver allows the kernel to access network
devices exported exported by a virtual machine containing a physical
network device driver.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Signed-off-by: Chris Wright [EMAIL PROTECTED]
Acked-by: Jeff Garzik [EMAIL PROTECTED]
Cc: Ian Pratt [EMAIL PROTECTED]
Cc: Christian Limpach [EMAIL PROTECTED]
Cc: Stephen Hemminger [EMAIL PROTECTED]
Cc: Christoph Hellwig [EMAIL PROTECTED]
Cc: Rusty Russell [EMAIL PROTECTED]
Cc: Herbert Xu [EMAIL PROTECTED]
Cc: Keir Fraser [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
---
 drivers/net/Kconfig|   12 +
 drivers/net/Makefile   |2 +
 drivers/net/xen-netfront.c | 1863 
 3 files changed, 1877 insertions(+), 0 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 43d0317..5fb659f 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2486,6 +2486,18 @@ source drivers/atm/Kconfig
 
 source drivers/s390/net/Kconfig
 
+config XEN_NETDEV_FRONTEND
+   tristate Xen network device frontend driver
+   depends on XEN
+   default y
+   help
+ The network device frontend driver allows the kernel to
+ access network devices exported exported by a virtual
+ machine containing a physical network device driver. The
+ frontend driver is intended for unprivileged guest domains;
+ if you are compiling a kernel for a Xen guest, you almost
+ certainly want to enable this.
+
 config ISERIES_VETH
tristate iSeries Virtual Ethernet driver support
depends on PPC_ISERIES
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index eb41676..0e286ab 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -127,6 +127,8 @@ obj-$(CONFIG_PPPOL2TP) += pppox.o pppol2tp.o
 obj-$(CONFIG_SLIP) += slip.o
 obj-$(CONFIG_SLHC) += slhc.o
 
+obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
+
 obj-$(CONFIG_DUMMY) += dummy.o
 obj-$(CONFIG_IFB) += ifb.o
 obj-$(CONFIG_MACVLAN) += macvlan.o
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
new file mode 100644
index 000..489f69c
--- /dev/null
+++ b/drivers/net/xen-netfront.c
@@ -0,0 +1,1863 @@
+/*
+ * Virtual network driver for conversing with remote driver backends.
+ *
+ * Copyright (c) 2002-2005, K A Fraser
+ * Copyright (c) 2005, XenSource Ltd
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the Software), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include linux/module.h
+#include linux/kernel.h
+#include linux/netdevice.h
+#include linux/etherdevice.h
+#include linux/skbuff.h
+#include linux/ethtool.h
+#include linux/if_ether.h
+#include linux/tcp.h
+#include linux/udp.h
+#include linux/moduleparam.h
+#include linux/mm.h
+#include net/ip.h
+
+#include xen/xenbus.h
+#include xen/events.h
+#include xen/page.h
+#include xen/grant_table.h
+
+#include xen/interface/io/netif.h
+#include xen/interface/memory.h
+#include xen/interface/grant_table.h
+
+static struct ethtool_ops xennet_ethtool_ops;
+
+struct netfront_cb {
+   struct page *page;
+   unsigned offset;
+};
+
+#define NETFRONT_SKB_CB(skb)   

xen: machine operations

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fefa629abebe328cf6d07f99fe5796dbfc3e4981
Commit: fefa629abebe328cf6d07f99fe5796dbfc3e4981
Parent: 0d160211965b79de989cf2d170985abeb8da5ec6
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:07 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:45 2007 -0700

xen: machine operations

Make the appropriate hypercalls to halt and reboot the virtual machine.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Acked-by: Chris Wright [EMAIL PROTECTED]
---
 arch/i386/xen/enlighten.c |   43 +++
 arch/i386/xen/smp.c   |4 +---
 2 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 4275677..142e748 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -30,6 +30,7 @@
 #include xen/interface/xen.h
 #include xen/interface/physdev.h
 #include xen/interface/vcpu.h
+#include xen/interface/sched.h
 #include xen/features.h
 #include xen/page.h
 
@@ -43,6 +44,7 @@
 #include asm/desc.h
 #include asm/pgtable.h
 #include asm/tlbflush.h
+#include asm/reboot.h
 
 #include xen-ops.h
 #include mmu.h
@@ -900,6 +902,45 @@ static const struct smp_ops xen_smp_ops __initdata = {
 };
 #endif /* CONFIG_SMP */
 
+static void xen_reboot(int reason)
+{
+#ifdef CONFIG_SMP
+   smp_send_stop();
+#endif
+
+   if (HYPERVISOR_sched_op(SCHEDOP_shutdown, reason))
+   BUG();
+}
+
+static void xen_restart(char *msg)
+{
+   xen_reboot(SHUTDOWN_reboot);
+}
+
+static void xen_emergency_restart(void)
+{
+   xen_reboot(SHUTDOWN_reboot);
+}
+
+static void xen_machine_halt(void)
+{
+   xen_reboot(SHUTDOWN_poweroff);
+}
+
+static void xen_crash_shutdown(struct pt_regs *regs)
+{
+   xen_reboot(SHUTDOWN_crash);
+}
+
+static const struct machine_ops __initdata xen_machine_ops = {
+   .restart = xen_restart,
+   .halt = xen_machine_halt,
+   .power_off = xen_machine_halt,
+   .shutdown = xen_machine_halt,
+   .crash_shutdown = xen_crash_shutdown,
+   .emergency_restart = xen_emergency_restart,
+};
+
 /* First C function to be called on Xen boot */
 asmlinkage void __init xen_start_kernel(void)
 {
@@ -912,6 +953,8 @@ asmlinkage void __init xen_start_kernel(void)
 
/* Install Xen paravirt ops */
paravirt_ops = xen_paravirt_ops;
+   machine_ops = xen_machine_ops;
+
 #ifdef CONFIG_SMP
smp_ops = xen_smp_ops;
 #endif
diff --git a/arch/i386/xen/smp.c b/arch/i386/xen/smp.c
index a91587f..a620918 100644
--- a/arch/i386/xen/smp.c
+++ b/arch/i386/xen/smp.c
@@ -311,9 +311,7 @@ static void stop_self(void *v)
 
 void xen_smp_send_stop(void)
 {
-   cpumask_t mask = cpu_online_map;
-   cpu_clear(smp_processor_id(), mask);
-   xen_smp_call_function_mask(mask, stop_self, NULL, 0);
+   smp_call_function(stop_self, NULL, 0, 0);
 }
 
 void xen_smp_send_reschedule(int cpu)
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


xen: Place vcpu_info structure into per-cpu memory

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=60223a326fc8fa6e90e2c3fd28ae6de4a311d731
Commit: 60223a326fc8fa6e90e2c3fd28ae6de4a311d731
Parent: 3e2b8fbeec8f005672f2a2e862fb9c26a0bafedc
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:07 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:45 2007 -0700

xen: Place vcpu_info structure into per-cpu memory

An experimental patch for Xen allows guests to place their vcpu_info
structs anywhere.  We try to use this to place the vcpu_info into the
PDA, which allows direct access.

If this works, then switch to using direct access operations for
irq_enable, disable, save_fl and restore_fl.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Cc: Chris Wright [EMAIL PROTECTED]
Cc: Keir Fraser [EMAIL PROTECTED]
---
 arch/i386/xen/enlighten.c|  152 -
 arch/i386/xen/setup.c|8 --
 arch/i386/xen/smp.c  |5 +-
 arch/i386/xen/xen-ops.h  |2 +-
 include/xen/interface/vcpu.h |   13 
 5 files changed, 164 insertions(+), 16 deletions(-)

diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 142e748..e33fa09 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -61,9 +61,63 @@ DEFINE_PER_CPU(unsigned long, xen_cr3);
 struct start_info *xen_start_info;
 EXPORT_SYMBOL_GPL(xen_start_info);
 
-void xen_vcpu_setup(int cpu)
+static /* __initdata */ struct shared_info dummy_shared_info;
+
+/*
+ * Point at some empty memory to start with. We map the real shared_info
+ * page as soon as fixmap is up and running.
+ */
+struct shared_info *HYPERVISOR_shared_info = (void *)dummy_shared_info;
+
+/*
+ * Flag to determine whether vcpu info placement is available on all
+ * VCPUs.  We assume it is to start with, and then set it to zero on
+ * the first failure.  This is because it can succeed on some VCPUs
+ * and not others, since it can involve hypervisor memory allocation,
+ * or because the guest failed to guarantee all the appropriate
+ * constraints on all VCPUs (ie buffer can't cross a page boundary).
+ *
+ * Note that any particular CPU may be using a placed vcpu structure,
+ * but we can only optimise if the all are.
+ *
+ * 0: not available, 1: available
+ */
+static int have_vcpu_info_placement = 1;
+
+static void __init xen_vcpu_setup(int cpu)
 {
+   struct vcpu_register_vcpu_info info;
+   int err;
+   struct vcpu_info *vcpup;
+
per_cpu(xen_vcpu, cpu) = HYPERVISOR_shared_info-vcpu_info[cpu];
+
+   if (!have_vcpu_info_placement)
+   return; /* already tested, not available */
+
+   vcpup = per_cpu(xen_vcpu_info, cpu);
+
+   info.mfn = virt_to_mfn(vcpup);
+   info.offset = offset_in_page(vcpup);
+
+   printk(KERN_DEBUG trying to map vcpu_info %d at %p, mfn %x, offset 
%d\n,
+  cpu, vcpup, info.mfn, info.offset);
+
+   /* Check to see if the hypervisor will put the vcpu_info
+  structure where we want it, which allows direct access via
+  a percpu-variable. */
+   err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, cpu, info);
+
+   if (err) {
+   printk(KERN_DEBUG register_vcpu_info failed: err=%d\n, err);
+   have_vcpu_info_placement = 0;
+   } else {
+   /* This cpu is using the registered vcpu info, even if
+  later ones fail to. */
+   per_cpu(xen_vcpu, cpu) = vcpup;
+   printk(KERN_DEBUG cpu %d using vcpu_info at %p\n,
+  cpu, vcpup);
+   }
 }
 
 static void __init xen_banner(void)
@@ -123,6 +177,20 @@ static unsigned long xen_save_fl(void)
return (-flags)  X86_EFLAGS_IF;
 }
 
+static unsigned long xen_save_fl_direct(void)
+{
+   unsigned long flags;
+
+   /* flag has opposite sense of mask */
+   flags = !x86_read_percpu(xen_vcpu_info.evtchn_upcall_mask);
+
+   /* convert to IF type flag
+  -0 - 0x
+  -1 - 0x
+   */
+   return (-flags)  X86_EFLAGS_IF;
+}
+
 static void xen_restore_fl(unsigned long flags)
 {
struct vcpu_info *vcpu;
@@ -149,6 +217,25 @@ static void xen_restore_fl(unsigned long flags)
}
 }
 
+static void xen_restore_fl_direct(unsigned long flags)
+{
+   /* convert from IF type flag */
+   flags = !(flags  X86_EFLAGS_IF);
+
+   /* This is an atomic update, so no need to worry about
+  preemption. */
+   x86_write_percpu(xen_vcpu_info.evtchn_upcall_mask, flags);
+
+   /* If we get preempted here, then any pending event will be
+  handled anyway. */
+
+   if (flags == 0) {
+   barrier(); /* unmask then check (avoid races) */
+   if 
(unlikely(x86_read_percpu(xen_vcpu_info.evtchn_upcall_pending)))
+   

xen: Attempt to patch inline versions of common operations

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6487673b8a858f99a5348e1078b3f5aec700f9e0
Commit: 6487673b8a858f99a5348e1078b3f5aec700f9e0
Parent: 60223a326fc8fa6e90e2c3fd28ae6de4a311d731
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:07 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:45 2007 -0700

xen: Attempt to patch inline versions of common operations

This patchs adds the mechanism to allow us to patch inline versions of
common operations.

The implementations of the direct-access versions save_fl, restore_fl,
irq_enable and irq_disable are now in assembler, and the same code is
used for both out of line and inline uses.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Cc: Chris Wright [EMAIL PROTECTED]
Cc: Keir Fraser [EMAIL PROTECTED]
---
 arch/i386/kernel/asm-offsets.c |8 +++
 arch/i386/xen/Makefile |2 +-
 arch/i386/xen/enlighten.c  |  107 +++--
 arch/i386/xen/xen-asm.S|  114 
 arch/i386/xen/xen-ops.h|   13 +
 5 files changed, 190 insertions(+), 54 deletions(-)

diff --git a/arch/i386/kernel/asm-offsets.c b/arch/i386/kernel/asm-offsets.c
index 27a776c..a7c2947 100644
--- a/arch/i386/kernel/asm-offsets.c
+++ b/arch/i386/kernel/asm-offsets.c
@@ -17,6 +17,8 @@
 #include asm/thread_info.h
 #include asm/elf.h
 
+#include xen/interface/xen.h
+
 #define DEFINE(sym, val) \
 asm volatile(\n- #sym  %0  #val : : i (val))
 
@@ -115,4 +117,10 @@ void foo(void)
OFFSET(PARAVIRT_iret, paravirt_ops, iret);
OFFSET(PARAVIRT_read_cr0, paravirt_ops, read_cr0);
 #endif
+
+#ifdef CONFIG_XEN
+   BLANK();
+   OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
+   OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
+#endif
 }
diff --git a/arch/i386/xen/Makefile b/arch/i386/xen/Makefile
index 7bf2ce3..343df24 100644
--- a/arch/i386/xen/Makefile
+++ b/arch/i386/xen/Makefile
@@ -1,4 +1,4 @@
 obj-y  := enlighten.o setup.o features.o multicalls.o mmu.o \
-   events.o time.o manage.o
+   events.o time.o manage.o xen-asm.o
 
 obj-$(CONFIG_SMP)  += smp.o
diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index e33fa09..4fa62a4 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -115,6 +115,7 @@ static void __init xen_vcpu_setup(int cpu)
/* This cpu is using the registered vcpu info, even if
   later ones fail to. */
per_cpu(xen_vcpu, cpu) = vcpup;
+
printk(KERN_DEBUG cpu %d using vcpu_info at %p\n,
   cpu, vcpup);
}
@@ -177,20 +178,6 @@ static unsigned long xen_save_fl(void)
return (-flags)  X86_EFLAGS_IF;
 }
 
-static unsigned long xen_save_fl_direct(void)
-{
-   unsigned long flags;
-
-   /* flag has opposite sense of mask */
-   flags = !x86_read_percpu(xen_vcpu_info.evtchn_upcall_mask);
-
-   /* convert to IF type flag
-  -0 - 0x
-  -1 - 0x
-   */
-   return (-flags)  X86_EFLAGS_IF;
-}
-
 static void xen_restore_fl(unsigned long flags)
 {
struct vcpu_info *vcpu;
@@ -217,25 +204,6 @@ static void xen_restore_fl(unsigned long flags)
}
 }
 
-static void xen_restore_fl_direct(unsigned long flags)
-{
-   /* convert from IF type flag */
-   flags = !(flags  X86_EFLAGS_IF);
-
-   /* This is an atomic update, so no need to worry about
-  preemption. */
-   x86_write_percpu(xen_vcpu_info.evtchn_upcall_mask, flags);
-
-   /* If we get preempted here, then any pending event will be
-  handled anyway. */
-
-   if (flags == 0) {
-   barrier(); /* unmask then check (avoid races) */
-   if 
(unlikely(x86_read_percpu(xen_vcpu_info.evtchn_upcall_pending)))
-   force_evtchn_callback();
-   }
-}
-
 static void xen_irq_disable(void)
 {
/* There's a one instruction preempt window here.  We need to
@@ -246,12 +214,6 @@ static void xen_irq_disable(void)
preempt_enable_no_resched();
 }
 
-static void xen_irq_disable_direct(void)
-{
-   /* Atomic update, so preemption not a concern. */
-   x86_write_percpu(xen_vcpu_info.evtchn_upcall_mask, 1);
-}
-
 static void xen_irq_enable(void)
 {
struct vcpu_info *vcpu;
@@ -272,19 +234,6 @@ static void xen_irq_enable(void)
force_evtchn_callback();
 }
 
-static void xen_irq_enable_direct(void)
-{
-   /* Atomic update, so preemption not a concern. */
-   x86_write_percpu(xen_vcpu_info.evtchn_upcall_mask, 0);
-
-   /* Doesn't matter if we get preempted here, because any
-  pending event will get dealt with anyway. */
-
-   barrier(); /* unmask then check 

xen: suppress abs symbol warnings for unused reloc pointers

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=600b2fc242992e552e0b4e24c8c1f084b341f39b
Commit: 600b2fc242992e552e0b4e24c8c1f084b341f39b
Parent: 6487673b8a858f99a5348e1078b3f5aec700f9e0
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:07 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:45 2007 -0700

xen: suppress abs symbol warnings for unused reloc pointers

arch/i386/xen/xen-asm.S defines some small pieces of code which are
used to implement a few paravirt_ops.  They're designed so they can be
used either in-place, or be inline patched into their callsites if
there's enough space.

Some of those operations need to make calls out (specifically, if you
re-enable events [interrupts], and there's a pending event at that
time).  These calls need the call instruction to be relocated if the
code is patched inline.  In this case xen_foo_reloc is a
section-relative symbol which points to xen_foo's required relocation.

Other operations have no need of a relocation, and so their
corresponding xen_bar_reloc is absolute 0.  These are the cases which
are triggering the warning.

This patch adds those symbols to the list of safe abs symbols.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Cc: Adrian Bunk [EMAIL PROTECTED]
---
 arch/i386/boot/compressed/relocs.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/i386/boot/compressed/relocs.c 
b/arch/i386/boot/compressed/relocs.c
index ce4fda2..b0e21c3 100644
--- a/arch/i386/boot/compressed/relocs.c
+++ b/arch/i386/boot/compressed/relocs.c
@@ -31,6 +31,8 @@ static const char* safe_abs_relocs[] = {
__kernel_rt_sigreturn,
__kernel_sigreturn,
SYSENTER_RETURN,
+   xen_irq_disable_direct_reloc,
+   xen_save_fl_direct_reloc,
 };
 
 static int is_safe_abs_reloc(const char* sym_name)
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


xen: use iret directly when possible

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9ec2b804e099e8a326369e6cccab10dee1d172ee
Commit: 9ec2b804e099e8a326369e6cccab10dee1d172ee
Parent: 600b2fc242992e552e0b4e24c8c1f084b341f39b
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:07 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:46 2007 -0700

xen: use iret directly when possible

Most of the time we can simply use the iret instruction to exit the
kernel, rather than having to use the iret hypercall - the only
exception is if we're returning into vm86 mode, or from delivering an
NMI (which we don't support yet).

When running native, iret has the behaviour of testing for a pending
interrupt atomically with re-enabling interrupts.  Unfortunately
there's no way to do this with Xen, so there's a window in which we
could get a recursive exception after enabling events but before
actually returning to userspace.

This causes a problem: if the nested interrupt causes one of the
task's TIF_WORK_MASK flags to be set, they will not be checked again
before returning to userspace.  This means that pending work may be
left pending indefinitely, until the process enters and leaves the
kernel again.  The net effect is that a pending signal or reschedule
event could be delayed for an unbounded amount of time.

To deal with this, the xen event upcall handler checks to see if the
EIP is within the critical section of the iret code, after events
are (potentially) enabled up to the iret itself.  If its within this
range, it calls the iret critical section fixup, which adjusts the
stack to deal with any unrestored registers, and then shifts the
stack frame up to replace the previous invocation.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
---
 arch/i386/kernel/asm-offsets.c |1 +
 arch/i386/kernel/entry.S   |   16 +++-
 arch/i386/xen/enlighten.c  |1 +
 arch/i386/xen/xen-asm.S|  185 +++-
 arch/i386/xen/xen-ops.h|1 +
 5 files changed, 199 insertions(+), 5 deletions(-)

diff --git a/arch/i386/kernel/asm-offsets.c b/arch/i386/kernel/asm-offsets.c
index a7c2947..25f7eb5 100644
--- a/arch/i386/kernel/asm-offsets.c
+++ b/arch/i386/kernel/asm-offsets.c
@@ -61,6 +61,7 @@ void foo(void)
OFFSET(TI_addr_limit, thread_info, addr_limit);
OFFSET(TI_restart_block, thread_info, restart_block);
OFFSET(TI_sysenter_return, thread_info, sysenter_return);
+   OFFSET(TI_cpu, thread_info, cpu);
BLANK();
 
OFFSET(GDS_size, Xgt_desc_struct, size);
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
index ffb2365..32980b8 100644
--- a/arch/i386/kernel/entry.S
+++ b/arch/i386/kernel/entry.S
@@ -1030,7 +1030,21 @@ ENTRY(xen_hypervisor_callback)
CFI_ADJUST_CFA_OFFSET 4
SAVE_ALL
TRACE_IRQS_OFF
-   mov %esp, %eax
+
+   /* Check to see if we got the event in the critical
+  region in xen_iret_direct, after we've reenabled
+  events and checked for pending events.  This simulates
+  iret instruction's behaviour where it delivers a
+  pending interrupt when enabling interrupts. */
+   movl PT_EIP(%esp),%eax
+   cmpl $xen_iret_start_crit,%eax
+   jb   1f
+   cmpl $xen_iret_end_crit,%eax
+   jae  1f
+
+   call xen_iret_crit_fixup
+
+1: mov %esp, %eax
call xen_evtchn_do_upcall
jmp  ret_from_intr
CFI_ENDPROC
diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 4fa62a4..9a8c118 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -838,6 +838,7 @@ void __init xen_setup_vcpu_info_placement(void)
paravirt_ops.irq_disable = xen_irq_disable_direct;
paravirt_ops.irq_enable = xen_irq_enable_direct;
paravirt_ops.read_cr2 = xen_read_cr2_direct;
+   paravirt_ops.iret = xen_iret_direct;
}
 }
 
diff --git a/arch/i386/xen/xen-asm.S b/arch/i386/xen/xen-asm.S
index dc4d36d..1a43b60 100644
--- a/arch/i386/xen/xen-asm.S
+++ b/arch/i386/xen/xen-asm.S
@@ -12,15 +12,21 @@
  */
 
 #include linux/linkage.h
+
 #include asm/asm-offsets.h
 #include asm/thread_info.h
 #include asm/percpu.h
-#include asm/asm-offsets.h
 #include asm/processor-flags.h
+#include asm/segment.h
+
+#include xen/interface/xen.h
 
 #define RELOC(x, v).globl x##_reloc; x##_reloc=v
 #define ENDPATCH(x).globl x##_end; x##_end=.
 
+/* Pseudo-flag used for virtual NMI, which we don't implement yet */
+#define XEN_EFLAGS_NMI 0x8000
+
 /*
Enable events.  This clears the event mask and tests the pending
event status with one and operation.  If there are pending
@@ -81,13 +87,12 @@ ENDPATCH(xen_save_fl_direct)
  */
 ENTRY(xen_restore_fl_direct)

xen: disable all non-virtual drivers

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=dfdcdd42fdf63452ddd1bed6f49ae2a35dfb5d6c
Commit: dfdcdd42fdf63452ddd1bed6f49ae2a35dfb5d6c
Parent: 9ec2b804e099e8a326369e6cccab10dee1d172ee
Author: Jeremy Fitzhardinge [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 18:37:07 2007 -0700
Committer:  Jeremy Fitzhardinge [EMAIL PROTECTED]
CommitDate: Wed Jul 18 08:47:46 2007 -0700

xen: disable all non-virtual drivers

A domU Xen environment has no non-virtual drivers, so make sure
they're all disabled at once.

Signed-off-by: Jeremy Fitzhardinge [EMAIL PROTECTED]
Cc: Rusty Russell [EMAIL PROTECTED]
---
 arch/i386/xen/setup.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/i386/xen/setup.c b/arch/i386/xen/setup.c
index 3f8684e..2fe6eac 100644
--- a/arch/i386/xen/setup.c
+++ b/arch/i386/xen/setup.c
@@ -91,4 +91,6 @@ void __init xen_arch_setup(void)
/* fill cpus_possible with all available cpus */
xen_fill_possible_map();
 #endif
+
+   paravirt_disable_iospace();
 }
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[SPARC64]: Add basic infrastructure for MD add/remove notification.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=920c3ed741340a88f2042ab0c44a25b8c743a379
Commit: 920c3ed741340a88f2042ab0c44a25b8c743a379
Parent: cb32da0416b823b7f4b65e7e85d6cba16ca4d1e1
Author: David S. Miller [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 21:37:35 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:19:51 2007 -0700

[SPARC64]: Add basic infrastructure for MD add/remove notification.

And add dummy handlers for the VIO device layer.  These will be filled
in with real code after the vdc, vnet, and ds drivers are reworked to
have simpler dependencies on the VIO device tree.

Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 arch/sparc64/kernel/mdesc.c |   78 +--
 arch/sparc64/kernel/vio.c   |   33 ++
 include/asm-sparc64/mdesc.h |   10 +
 3 files changed, 118 insertions(+), 3 deletions(-)

diff --git a/arch/sparc64/kernel/mdesc.c b/arch/sparc64/kernel/mdesc.c
index de5310f..302ba5e 100644
--- a/arch/sparc64/kernel/mdesc.c
+++ b/arch/sparc64/kernel/mdesc.c
@@ -137,7 +137,7 @@ static struct mdesc_handle *mdesc_kmalloc(unsigned int 
mdesc_size)
   sizeof(struct mdesc_hdr) +
   mdesc_size);
 
-   base = kmalloc(handle_size + 15, GFP_KERNEL);
+   base = kmalloc(handle_size + 15, GFP_KERNEL | __GFP_NOFAIL);
if (base) {
struct mdesc_handle *hp;
unsigned long addr;
@@ -214,18 +214,83 @@ void mdesc_release(struct mdesc_handle *hp)
 }
 EXPORT_SYMBOL(mdesc_release);
 
+static DEFINE_MUTEX(mdesc_mutex);
+static struct mdesc_notifier_client *client_list;
+
+void mdesc_register_notifier(struct mdesc_notifier_client *client)
+{
+   u64 node;
+
+   mutex_lock(mdesc_mutex);
+   client-next = client_list;
+   client_list = client;
+
+   mdesc_for_each_node_by_name(cur_mdesc, node, client-node_name)
+   client-add(cur_mdesc, node);
+
+   mutex_unlock(mdesc_mutex);
+}
+
+/* Run 'func' on nodes which are in A but not in B.  */
+static void invoke_on_missing(const char *name,
+ struct mdesc_handle *a,
+ struct mdesc_handle *b,
+ void (*func)(struct mdesc_handle *, u64))
+{
+   u64 node;
+
+   mdesc_for_each_node_by_name(a, node, name) {
+   const u64 *id = mdesc_get_property(a, node, id, NULL);
+   int found = 0;
+   u64 fnode;
+
+   mdesc_for_each_node_by_name(b, fnode, name) {
+   const u64 *fid = mdesc_get_property(b, fnode,
+   id, NULL);
+
+   if (*id == *fid) {
+   found = 1;
+   break;
+   }
+   }
+   if (!found)
+   func(a, node);
+   }
+}
+
+static void notify_one(struct mdesc_notifier_client *p,
+  struct mdesc_handle *old_hp,
+  struct mdesc_handle *new_hp)
+{
+   invoke_on_missing(p-node_name, old_hp, new_hp, p-remove);
+   invoke_on_missing(p-node_name, new_hp, old_hp, p-add);
+}
+
+static void mdesc_notify_clients(struct mdesc_handle *old_hp,
+struct mdesc_handle *new_hp)
+{
+   struct mdesc_notifier_client *p = client_list;
+
+   while (p) {
+   notify_one(p, old_hp, new_hp);
+   p = p-next;
+   }
+}
+
 void mdesc_update(void)
 {
unsigned long len, real_len, status;
struct mdesc_handle *hp, *orig_hp;
unsigned long flags;
 
+   mutex_lock(mdesc_mutex);
+
(void) sun4v_mach_desc(0UL, 0UL, len);
 
hp = mdesc_alloc(len, kmalloc_mdesc_memops);
if (!hp) {
printk(KERN_ERR MD: mdesc alloc fails\n);
-   return;
+   goto out;
}
 
status = sun4v_mach_desc(__pa(hp-mdesc), len, real_len);
@@ -234,18 +299,25 @@ void mdesc_update(void)
   status);
atomic_dec(hp-refcnt);
mdesc_free(hp);
-   return;
+   goto out;
}
 
spin_lock_irqsave(mdesc_lock, flags);
orig_hp = cur_mdesc;
cur_mdesc = hp;
+   spin_unlock_irqrestore(mdesc_lock, flags);
 
+   mdesc_notify_clients(orig_hp, hp);
+
+   spin_lock_irqsave(mdesc_lock, flags);
if (atomic_dec_and_test(orig_hp-refcnt))
mdesc_free(orig_hp);
else
list_add(orig_hp-list, mdesc_zombie_list);
spin_unlock_irqrestore(mdesc_lock, flags);
+
+out:
+   mutex_unlock(mdesc_mutex);
 }
 
 static struct mdesc_elem *node_block(struct mdesc_hdr *mdesc)
diff --git a/arch/sparc64/kernel/vio.c b/arch/sparc64/kernel/vio.c
index 49569b4..d487be0 100644

[SPARC64]: Simplify VDC device probing.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=80dc35dfb98d2fbf3af0b829e3bf6e6a0f631cda
Commit: 80dc35dfb98d2fbf3af0b829e3bf6e6a0f631cda
Parent: 920c3ed741340a88f2042ab0c44a25b8c743a379
Author: David S. Miller [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 21:46:00 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:19:55 2007 -0700

[SPARC64]: Simplify VDC device probing.

We just need to match on the vdc-port nodes, the parent
is really not interesting at all.

Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/block/sunvdc.c |   97 +---
 1 files changed, 10 insertions(+), 87 deletions(-)

diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 0f5e3ca..2288b55 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -45,8 +45,6 @@ struct vdc_req_entry {
 struct vdc_port {
struct vio_driver_state vio;
 
-   struct vdc  *vp;
-
struct gendisk  *disk;
 
struct vdc_completion   *cmp;
@@ -72,8 +70,6 @@ struct vdc_port {
 
struct vio_disk_geomgeom;
struct vio_disk_vtoclabel;
-
-   struct list_headlist;
 };
 
 static inline struct vdc_port *to_vdc_port(struct vio_driver_state *vio)
@@ -81,15 +77,6 @@ static inline struct vdc_port *to_vdc_port(struct 
vio_driver_state *vio)
return container_of(vio, struct vdc_port, vio);
 }
 
-struct vdc {
-   /* Protects prot_list.  */
-   spinlock_t  lock;
-
-   struct vio_dev  *dev;
-
-   struct list_headport_list;
-};
-
 /* Ordered from largest major to lowest */
 static struct vio_version vdc_versions[] = {
{ .major = 1, .minor = 0 },
@@ -747,21 +734,23 @@ static struct vio_driver_ops vdc_vio_ops = {
.handshake_complete = vdc_handshake_complete,
 };
 
+static void print_version(void)
+{
+   static int version_printed;
+
+   if (version_printed++ == 0)
+   printk(KERN_INFO %s, version);
+}
+
 static int __devinit vdc_port_probe(struct vio_dev *vdev,
const struct vio_device_id *id)
 {
struct mdesc_handle *hp;
struct vdc_port *port;
-   unsigned long flags;
-   struct vdc *vp;
const u64 *port_id;
int err;
 
-   vp = dev_get_drvdata(vdev-dev.parent);
-   if (!vp) {
-   printk(KERN_ERR PFX Cannot find port parent vdc.\n);
-   return -ENODEV;
-   }
+   print_version();
 
hp = mdesc_grab();
 
@@ -783,7 +772,6 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev,
goto err_out_release_mdesc;
}
 
-   port-vp = vp;
port-dev_no = *port_id;
 
if (port-dev_no = 26)
@@ -818,12 +806,6 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev,
if (err)
goto err_out_free_tx_ring;
 
-   INIT_LIST_HEAD(port-list);
-
-   spin_lock_irqsave(vp-lock, flags);
-   list_add(port-list, vp-port_list);
-   spin_unlock_irqrestore(vp-lock, flags);
-
dev_set_drvdata(vdev-dev, port);
 
mdesc_release(hp);
@@ -879,58 +861,6 @@ static struct vio_driver vdc_port_driver = {
}
 };
 
-static int __devinit vdc_probe(struct vio_dev *vdev,
-  const struct vio_device_id *id)
-{
-   static int vdc_version_printed;
-   struct vdc *vp;
-
-   if (vdc_version_printed++ == 0)
-   printk(KERN_INFO %s, version);
-
-   vp = kzalloc(sizeof(struct vdc), GFP_KERNEL);
-   if (!vp)
-   return -ENOMEM;
-
-   spin_lock_init(vp-lock);
-   vp-dev = vdev;
-   INIT_LIST_HEAD(vp-port_list);
-
-   dev_set_drvdata(vdev-dev, vp);
-
-   return 0;
-}
-
-static int vdc_remove(struct vio_dev *vdev)
-{
-
-   struct vdc *vp = dev_get_drvdata(vdev-dev);
-
-   if (vp) {
-   kfree(vp);
-   dev_set_drvdata(vdev-dev, NULL);
-   }
-   return 0;
-}
-
-static struct vio_device_id vdc_match[] = {
-   {
-   .type = block,
-   },
-   {},
-};
-MODULE_DEVICE_TABLE(vio, vdc_match);
-
-static struct vio_driver vdc_driver = {
-   .id_table   = vdc_match,
-   .probe  = vdc_probe,
-   .remove = vdc_remove,
-   .driver = {
-   .name   = vdc,
-   .owner  = THIS_MODULE,
-   }
-};
-
 static int __init vdc_init(void)
 {
int err;
@@ -940,19 +870,13 @@ static int __init vdc_init(void)
goto out_err;
 
vdc_major = err;
-   err = vio_register_driver(vdc_driver);
-   if (err)
-   goto out_unregister_blkdev;
 
err = vio_register_driver(vdc_port_driver);
if (err)
-   goto out_unregister_vdc;
+   goto out_unregister_blkdev;
 
return 0;
 
-out_unregister_vdc:
-   

[SPARC64]: Simplify VNET probing.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9184a046328d2dfc9f2cf0f831e649a108492124
Commit: 9184a046328d2dfc9f2cf0f831e649a108492124
Parent: 80dc35dfb98d2fbf3af0b829e3bf6e6a0f631cda
Author: David S. Miller [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 22:19:10 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:20:00 2007 -0700

[SPARC64]: Simplify VNET probing.

Only probe on the vdc-port VIO devices, create parent
vnet objects on-demand.

Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/net/sunvnet.c |  258 -
 drivers/net/sunvnet.h |4 +-
 2 files changed, 130 insertions(+), 132 deletions(-)

diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c
index 8a667c1..b69f552 100644
--- a/drivers/net/sunvnet.c
+++ b/drivers/net/sunvnet.c
@@ -12,6 +12,7 @@
 #include linux/netdevice.h
 #include linux/ethtool.h
 #include linux/etherdevice.h
+#include linux/mutex.h
 
 #include asm/vio.h
 #include asm/ldc.h
@@ -875,6 +876,115 @@ err_out:
return err;
 }
 
+static LIST_HEAD(vnet_list);
+static DEFINE_MUTEX(vnet_list_mutex);
+
+static struct vnet * __devinit vnet_new(const u64 *local_mac)
+{
+   struct net_device *dev;
+   struct vnet *vp;
+   int err, i;
+
+   dev = alloc_etherdev(sizeof(*vp));
+   if (!dev) {
+   printk(KERN_ERR PFX Etherdev alloc failed, aborting.\n);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   for (i = 0; i  ETH_ALEN; i++)
+   dev-dev_addr[i] = (*local_mac  (5 - i) * 8)  0xff;
+
+   memcpy(dev-perm_addr, dev-dev_addr, dev-addr_len);
+
+   vp = netdev_priv(dev);
+
+   spin_lock_init(vp-lock);
+   vp-dev = dev;
+
+   INIT_LIST_HEAD(vp-port_list);
+   for (i = 0; i  VNET_PORT_HASH_SIZE; i++)
+   INIT_HLIST_HEAD(vp-port_hash[i]);
+   INIT_LIST_HEAD(vp-list);
+   vp-local_mac = *local_mac;
+
+   dev-open = vnet_open;
+   dev-stop = vnet_close;
+   dev-set_multicast_list = vnet_set_rx_mode;
+   dev-set_mac_address = vnet_set_mac_addr;
+   dev-tx_timeout = vnet_tx_timeout;
+   dev-ethtool_ops = vnet_ethtool_ops;
+   dev-watchdog_timeo = VNET_TX_TIMEOUT;
+   dev-change_mtu = vnet_change_mtu;
+   dev-hard_start_xmit = vnet_start_xmit;
+
+   err = register_netdev(dev);
+   if (err) {
+   printk(KERN_ERR PFX Cannot register net device, 
+  aborting.\n);
+   goto err_out_free_dev;
+   }
+
+   printk(KERN_INFO %s: Sun LDOM vnet , dev-name);
+
+   for (i = 0; i  6; i++)
+   printk(%2.2x%c, dev-dev_addr[i], i == 5 ? '\n' : ':');
+
+   list_add(vp-list, vnet_list);
+
+   return vp;
+
+err_out_free_dev:
+   free_netdev(dev);
+
+   return ERR_PTR(err);
+}
+
+static struct vnet * __devinit vnet_find_or_create(const u64 *local_mac)
+{
+   struct vnet *iter, *vp;
+
+   mutex_lock(vnet_list_mutex);
+   vp = NULL;
+   list_for_each_entry(iter, vnet_list, list) {
+   if (iter-local_mac == *local_mac) {
+   vp = iter;
+   break;
+   }
+   }
+   if (!vp)
+   vp = vnet_new(local_mac);
+   mutex_unlock(vnet_list_mutex);
+
+   return vp;
+}
+
+static const char *local_mac_prop = local-mac-address;
+
+static struct vnet * __devinit vnet_find_parent(struct mdesc_handle *hp,
+   u64 port_node)
+{
+   const u64 *local_mac = NULL;
+   u64 a;
+
+   mdesc_for_each_arc(a, hp, port_node, MDESC_ARC_TYPE_BACK) {
+   u64 target = mdesc_arc_target(hp, a);
+   const char *name;
+
+   name = mdesc_get_property(hp, target, name, NULL);
+   if (!name || strcmp(name, network))
+   continue;
+
+   local_mac = mdesc_get_property(hp, target,
+  local_mac_prop, NULL);
+   if (local_mac)
+   break;
+   }
+   if (!local_mac)
+   return ERR_PTR(-ENODEV);
+
+   return vnet_find_or_create(local_mac);
+}
+
 static struct ldc_channel_config vnet_ldc_cfg = {
.event  = vnet_event,
.mtu= 64,
@@ -887,6 +997,14 @@ static struct vio_driver_ops vnet_vio_ops = {
.handshake_complete = vnet_handshake_complete,
 };
 
+static void print_version(void)
+{
+   static int version_printed;
+
+   if (version_printed++ == 0)
+   printk(KERN_INFO %s, version);
+}
+
 const char *remote_macaddr_prop = remote-mac-address;
 
 static int __devinit vnet_port_probe(struct vio_dev *vdev,
@@ -899,14 +1017,17 @@ static int __devinit vnet_port_probe(struct vio_dev 
*vdev,
const u64 *rmac;
int len, i, err, switch_port;
 
-   vp = 

[SPARC64]: Massively simplify VIO device layer and support hot add/remove.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6160f63518406485c7009cb0f2e1588ea3abccc1
Commit: 6160f63518406485c7009cb0f2e1588ea3abccc1
Parent: 9184a046328d2dfc9f2cf0f831e649a108492124
Author: David S. Miller [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 23:03:47 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:20:04 2007 -0700

[SPARC64]: Massively simplify VIO device layer and support hot add/remove.

Create and destroy VIO devices in response to MD update events.  These
run synchronously inside of the MD update mutex so the VIO layer
doesn't need to do internal locking of any sort.

Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 arch/sparc64/kernel/vio.c |  123 +---
 include/asm-sparc64/vio.h |2 +-
 2 files changed, 60 insertions(+), 65 deletions(-)

diff --git a/arch/sparc64/kernel/vio.c b/arch/sparc64/kernel/vio.c
index d487be0..8d3cc4f 100644
--- a/arch/sparc64/kernel/vio.c
+++ b/arch/sparc64/kernel/vio.c
@@ -172,36 +172,6 @@ struct device_node *cdev_node;
 static struct vio_dev *root_vdev;
 static u64 cdev_cfg_handle;
 
-static void vio_add(struct mdesc_handle *hp, u64 node)
-{
-   const char *name = mdesc_get_property(hp, node, name, NULL);
-   const u64 *id = mdesc_get_property(hp, node, id, NULL);
-
-   printk(KERN_ERR VIO: Device add (%s) ID[%lx]\n,
-  name, *id);
-}
-
-static void vio_remove(struct mdesc_handle *hp, u64 node)
-{
-   const char *name = mdesc_get_property(hp, node, name, NULL);
-   const u64 *id = mdesc_get_property(hp, node, id, NULL);
-
-   printk(KERN_ERR VIO: Device remove (%s) ID[%lx]\n,
-  name, *id);
-}
-
-static struct mdesc_notifier_client vio_device_notifier = {
-   .add= vio_add,
-   .remove = vio_remove,
-   .node_name  = virtual-device-port,
-};
-
-static struct mdesc_notifier_client vio_ds_notifier = {
-   .add= vio_add,
-   .remove = vio_remove,
-   .node_name  = domain-services-port,
-};
-
 static void vio_fill_channel_info(struct mdesc_handle *hp, u64 mp,
  struct vio_dev *vdev)
 {
@@ -231,10 +201,11 @@ static void vio_fill_channel_info(struct mdesc_handle 
*hp, u64 mp,
 static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
  struct device *parent)
 {
-   const char *type, *compat;
+   const char *type, *compat, *bus_id_name;
struct device_node *dp;
struct vio_dev *vdev;
int err, tlen, clen;
+   const u64 *id;
 
type = mdesc_get_property(hp, mp, device-type, tlen);
if (!type) {
@@ -250,6 +221,16 @@ static struct vio_dev *vio_create_one(struct mdesc_handle 
*hp, u64 mp,
return NULL;
}
 
+   bus_id_name = type;
+   if (!strcmp(type, domain-services-port))
+   bus_id_name = ds;
+
+   if (strlen(bus_id_name) = KOBJ_NAME_LEN - 4) {
+   printk(KERN_ERR VIO: bus_id_name [%s] is too long.\n,
+  bus_id_name);
+   return NULL;
+   }
+
compat = mdesc_get_property(hp, mp, device-type, clen);
if (!compat) {
clen = 0;
@@ -279,7 +260,14 @@ static struct vio_dev *vio_create_one(struct mdesc_handle 
*hp, u64 mp,
 
vio_fill_channel_info(hp, mp, vdev);
 
-   snprintf(vdev-dev.bus_id, BUS_ID_SIZE, %lx, mp);
+   id = mdesc_get_property(hp, mp, id, NULL);
+   if (!id)
+   snprintf(vdev-dev.bus_id, BUS_ID_SIZE, %s,
+bus_id_name);
+   else
+   snprintf(vdev-dev.bus_id, BUS_ID_SIZE, %s-%lu,
+bus_id_name, *id);
+
vdev-dev.parent = parent;
vdev-dev.bus = vio_bus_type;
vdev-dev.release = vio_dev_release;
@@ -299,6 +287,8 @@ static struct vio_dev *vio_create_one(struct mdesc_handle 
*hp, u64 mp,
}
vdev-dp = dp;
 
+   printk(KERN_ERR VIO: Adding device %s\n, vdev-dev.bus_id);
+
err = device_register(vdev-dev);
if (err) {
printk(KERN_ERR VIO: Could not register device %s, err=%d\n,
@@ -313,46 +303,46 @@ static struct vio_dev *vio_create_one(struct mdesc_handle 
*hp, u64 mp,
return vdev;
 }
 
-static void walk_tree(struct mdesc_handle *hp, u64 n, struct vio_dev *parent)
+static void vio_add(struct mdesc_handle *hp, u64 node)
 {
-   u64 a;
-
-   mdesc_for_each_arc(a, hp, n, MDESC_ARC_TYPE_FWD) {
-   struct vio_dev *vdev;
-   u64 target;
-
-   target = mdesc_arc_target(hp, a);
-   vdev = vio_create_one(hp, target, parent-dev);
-   if (vdev)
-   walk_tree(hp, target, vdev);
-   }
+   (void) vio_create_one(hp, node, root_vdev-dev);
 }
 
-static void create_devices(struct mdesc_handle 

[SPARC64]: Handle LDC resets properly in domain-services driver.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8a2950cce6c8fa29bcbf6a3b33a63e0e68337f0e
Commit: 8a2950cce6c8fa29bcbf6a3b33a63e0e68337f0e
Parent: 6160f63518406485c7009cb0f2e1588ea3abccc1
Author: David S. Miller [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 23:12:20 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:20:09 2007 -0700

[SPARC64]: Handle LDC resets properly in domain-services driver.

Reset the handshake and per-capability state so that when the
link comes back up we'll renegotiate the DS version and then
reregister all of the services.

Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 arch/sparc64/kernel/ds.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/arch/sparc64/kernel/ds.c b/arch/sparc64/kernel/ds.c
index ba01533..fa1f04d 100644
--- a/arch/sparc64/kernel/ds.c
+++ b/arch/sparc64/kernel/ds.c
@@ -1013,6 +1013,19 @@ static void ds_up(struct ds_info *dp)
dp-hs_state = DS_HS_START;
 }
 
+static void ds_reset(struct ds_info *dp)
+{
+   int i;
+
+   dp-hs_state = 0;
+
+   for (i = 0; i  ARRAY_SIZE(ds_states); i++) {
+   struct ds_cap_state *cp = ds_states[i];
+
+   cp-state = CAP_STATE_UNKNOWN;
+   }
+}
+
 static void ds_event(void *arg, int event)
 {
struct ds_info *dp = arg;
@@ -1028,6 +1041,12 @@ static void ds_event(void *arg, int event)
return;
}
 
+   if (event == LDC_EVENT_RESET) {
+   ds_reset(dp);
+   spin_unlock_irqrestore(ds_lock, flags);
+   return;
+   }
+
if (event != LDC_EVENT_DATA_READY) {
printk(KERN_WARNING PFX Unexpected LDC event %d\n, event);
spin_unlock_irqrestore(ds_lock, flags);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[SPARC64]: Handle reset events in vio_link_state_change().

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a4cd184503f448dda346d2338aa61cb560cc1b14
Commit: a4cd184503f448dda346d2338aa61cb560cc1b14
Parent: 8a2950cce6c8fa29bcbf6a3b33a63e0e68337f0e
Author: David S. Miller [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 00:06:22 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:20:13 2007 -0700

[SPARC64]: Handle reset events in vio_link_state_change().

Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 arch/sparc64/kernel/viohs.c |   29 +
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/arch/sparc64/kernel/viohs.c b/arch/sparc64/kernel/viohs.c
index 15613ad..8eb381f 100644
--- a/arch/sparc64/kernel/viohs.c
+++ b/arch/sparc64/kernel/viohs.c
@@ -78,6 +78,23 @@ static int start_handshake(struct vio_driver_state *vio)
return 0;
 }
 
+static void flush_rx_dring(struct vio_driver_state *vio)
+{
+   struct vio_dring_state *dr;
+   u64 ident;
+
+   BUG_ON(!(vio-dr_state  VIO_DR_STATE_RXREG));
+
+   dr = vio-drings[VIO_DRIVER_RX_RING];
+   ident = dr-ident;
+
+   BUG_ON(!vio-desc_buf);
+   kfree(vio-desc_buf);
+
+   memset(dr, 0, sizeof(*dr));
+   dr-ident = ident;
+}
+
 void vio_link_state_change(struct vio_driver_state *vio, int event)
 {
if (event == LDC_EVENT_UP) {
@@ -98,6 +115,16 @@ void vio_link_state_change(struct vio_driver_state *vio, 
int event)
break;
}
start_handshake(vio);
+   } else if (event == LDC_EVENT_RESET) {
+   vio-hs_state = VIO_HS_INVALID;
+
+   if (vio-dr_state  VIO_DR_STATE_RXREG)
+   flush_rx_dring(vio);
+
+   vio-dr_state = 0x00;
+   memset(vio-ver, 0, sizeof(vio-ver));
+
+   ldc_disconnect(vio-lp);
}
 }
 EXPORT_SYMBOL(vio_link_state_change);
@@ -396,6 +423,8 @@ static int process_dreg_info(struct vio_driver_state *vio,
if (vio-dr_state  VIO_DR_STATE_RXREG)
goto send_nack;
 
+   BUG_ON(vio-desc_buf);
+
vio-desc_buf = kzalloc(pkt-descr_size, GFP_ATOMIC);
if (!vio-desc_buf)
goto send_nack;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[SPARC64]: Fix reset handling in VNET driver.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d762acdbd3b2bd9a714ace47d7b0c76133d7b295
Commit: d762acdbd3b2bd9a714ace47d7b0c76133d7b295
Parent: a4cd184503f448dda346d2338aa61cb560cc1b14
Author: David S. Miller [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 00:07:39 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:20:18 2007 -0700

[SPARC64]: Fix reset handling in VNET driver.

In vnet_event(), if the channel was reset, try to get the link
going again by invoking vio_port_up() after dropping the lock.

Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/net/sunvnet.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c
index b69f552..b801e3b 100644
--- a/drivers/net/sunvnet.c
+++ b/drivers/net/sunvnet.c
@@ -498,6 +498,8 @@ static void vnet_event(void *arg, int event)
vio_link_state_change(vio, event);
spin_unlock_irqrestore(vio-lock, flags);
 
+   if (event == LDC_EVENT_RESET)
+   vio_port_up(vio);
return;
}
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[SPARC]: Mark sparc and sparc64 as not having virt_to_bus

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0785b9dcdc3d93e67529e4bd819a427776d3a07e
Commit: 0785b9dcdc3d93e67529e4bd819a427776d3a07e
Parent: d762acdbd3b2bd9a714ace47d7b0c76133d7b295
Author: Stephen Rothwell [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 00:09:30 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:20:22 2007 -0700

[SPARC]: Mark sparc and sparc64 as not having virt_to_bus

Signed-off-by: Stephen Rothwell [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 arch/sparc/Kconfig   |3 +++
 arch/sparc64/Kconfig |3 +++
 include/asm-sparc64/io.h |5 -
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 73df711..603d83a 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -21,6 +21,9 @@ config GENERIC_ISA_DMA
bool
default y
 
+config ARCH_NO_VIRT_TO_BUS
+   def_bool y
+
 source init/Kconfig
 
 menu General machine setup
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index b84b6af..df6ee71 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -62,6 +62,9 @@ config AUDIT_ARCH
bool
default y
 
+config ARCH_NO_VIRT_TO_BUS
+   def_bool y
+
 choice
prompt Kernel page size
default SPARC64_PAGE_SIZE_8KB
diff --git a/include/asm-sparc64/io.h b/include/asm-sparc64/io.h
index ad595b6..9565a89 100644
--- a/include/asm-sparc64/io.h
+++ b/include/asm-sparc64/io.h
@@ -14,11 +14,6 @@
 #define __SLOW_DOWN_IO do { } while (0)
 #define SLOW_DOWN_IO   do { } while (0)
 
-extern unsigned long virt_to_bus_not_defined_use_pci_map(volatile void *addr);
-#define virt_to_bus virt_to_bus_not_defined_use_pci_map
-extern unsigned long bus_to_virt_not_defined_use_pci_map(volatile void *addr);
-#define bus_to_virt bus_to_virt_not_defined_use_pci_map
-
 /* BIO layer definitions. */
 extern unsigned long kern_base, kern_size;
 #define page_to_phys(page) (page_to_pfn(page)  PAGE_SHIFT)
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[SPARC64]: Set vio-desc_buf to NULL after freeing.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a5f8967e171a6fa27da8e6d06d3ef85f7fed43c1
Commit: a5f8967e171a6fa27da8e6d06d3ef85f7fed43c1
Parent: 0785b9dcdc3d93e67529e4bd819a427776d3a07e
Author: David S. Miller [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 00:33:23 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:20:26 2007 -0700

[SPARC64]: Set vio-desc_buf to NULL after freeing.

Otherwise we trigger assertions on the next link-up.

Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 arch/sparc64/kernel/viohs.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/sparc64/kernel/viohs.c b/arch/sparc64/kernel/viohs.c
index 8eb381f..09126fc 100644
--- a/arch/sparc64/kernel/viohs.c
+++ b/arch/sparc64/kernel/viohs.c
@@ -90,6 +90,7 @@ static void flush_rx_dring(struct vio_driver_state *vio)
 
BUG_ON(!vio-desc_buf);
kfree(vio-desc_buf);
+   vio-desc_buf = NULL;
 
memset(dr, 0, sizeof(*dr));
dr-ident = ident;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[BNX2]: Support NVRAM on 5709.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e30372c91273bb5777597362c74e63f96d9cd434
Commit: e30372c91273bb5777597362c74e63f96d9cd434
Parent: cb32da0416b823b7f4b65e7e85d6cba16ca4d1e1
Author: Michael Chan [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:26:23 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:46 2007 -0700

[BNX2]: Support NVRAM on 5709.

The NVRAM interface is slightly modified on the 5709.  To properly
support it, we need to change the buffered flag in the flash data
structure into multiple flags to indicate buffered operation, address
translation, and the use of write enable (WREN).  The 5709 flash
only requires the buffered operation bit to be set.

Signed-off-by: Michael Chan [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/net/bnx2.c |   74 +++
 drivers/net/bnx2.h |   10 ++-
 2 files changed, 54 insertions(+), 30 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index d23861c..311c859 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -126,91 +126,102 @@ static struct pci_device_id bnx2_pci_tbl[] = {
 
 static struct flash_spec flash_table[] =
 {
+#define BUFFERED_FLAGS (BNX2_NV_BUFFERED | BNX2_NV_TRANSLATE)
+#define NONBUFFERED_FLAGS  (BNX2_NV_WREN)
/* Slow EEPROM */
{0x, 0x40830380, 0x009f0081, 0xa184a053, 0xaf000400,
-1, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
+BUFFERED_FLAGS, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
 SEEPROM_BYTE_ADDR_MASK, SEEPROM_TOTAL_SIZE,
 EEPROM - slow},
/* Expansion entry 0001 */
{0x0802, 0x4b808201, 0x00050081, 0x03840253, 0xaf020406,
-0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
+NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
 SAIFUN_FLASH_BYTE_ADDR_MASK, 0,
 Entry 0001},
/* Saifun SA25F010 (non-buffered flash) */
/* strap, cfg1,  write1 need updates */
{0x0401, 0x47808201, 0x00050081, 0x03840253, 0xaf020406,
-0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
+NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE*2,
 Non-buffered flash (128kB)},
/* Saifun SA25F020 (non-buffered flash) */
/* strap, cfg1,  write1 need updates */
{0x0c03, 0x4f808201, 0x00050081, 0x03840253, 0xaf020406,
-0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
+NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE*4,
 Non-buffered flash (256kB)},
/* Expansion entry 0100 */
{0x1100, 0x53808201, 0x00050081, 0x03840253, 0xaf020406,
-0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
+NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
 SAIFUN_FLASH_BYTE_ADDR_MASK, 0,
 Entry 0100},
/* Entry 0101: ST M45PE10 (non-buffered flash, TetonII B0) */
{0x1902, 0x5b808201, 0x000500db, 0x03840253, 0xaf020406,
-0, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE,
+NONBUFFERED_FLAGS, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE,
 ST_MICRO_FLASH_BYTE_ADDR_MASK, ST_MICRO_FLASH_BASE_TOTAL_SIZE*2,
 Entry 0101: ST M45PE10 (128kB non-bufferred)},
/* Entry 0110: ST M45PE20 (non-buffered flash)*/
{0x1501, 0x57808201, 0x000500db, 0x03840253, 0xaf020406,
-0, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE,
+NONBUFFERED_FLAGS, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE,
 ST_MICRO_FLASH_BYTE_ADDR_MASK, ST_MICRO_FLASH_BASE_TOTAL_SIZE*4,
 Entry 0110: ST M45PE20 (256kB non-bufferred)},
/* Saifun SA25F005 (non-buffered flash) */
/* strap, cfg1,  write1 need updates */
{0x1d03, 0x5f808201, 0x00050081, 0x03840253, 0xaf020406,
-0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
+NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
 SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE,
 Non-buffered flash (64kB)},
/* Fast EEPROM */
{0x2200, 0x62808380, 0x009f0081, 0xa184a053, 0xaf000400,
-1, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
+BUFFERED_FLAGS, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE,
 SEEPROM_BYTE_ADDR_MASK, SEEPROM_TOTAL_SIZE,
 EEPROM - fast},
/* Expansion entry 1001 */
{0x2a02, 0x6b808201, 0x00050081, 0x03840253, 0xaf020406,
-0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
+NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE,
 SAIFUN_FLASH_BYTE_ADDR_MASK, 0,
 Entry 1001},
/* Expansion entry 

[BNX2]: Add delay before reading firmware version.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c2d3db8c7cbb94e77461627085b85d74dc64d716
Commit: c2d3db8c7cbb94e77461627085b85d74dc64d716
Parent: e30372c91273bb5777597362c74e63f96d9cd434
Author: Michael Chan [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:26:43 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:47 2007 -0700

[BNX2]: Add delay before reading firmware version.

The management firmware may still be loading during bnx2_init_one()
because of the D3hot - D0 transition and the firmware version may
not be available without waiting a bit.

Signed-off-by: Michael Chan [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/net/bnx2.c |   16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 311c859..28399d8 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -4143,10 +4143,6 @@ bnx2_init_chip(struct bnx2 *bp)
 
REG_WR(bp, BNX2_HC_ATTN_BITS_ENABLE, STATUS_ATTN_EVENTS);
 
-   if (REG_RD_IND(bp, bp-shmem_base + BNX2_PORT_FEATURE) 
-   BNX2_PORT_FEATURE_ASF_ENABLED)
-   bp-flags |= ASF_ENABLE_FLAG;
-
/* Initialize the receive filter. */
bnx2_set_rx_mode(bp-dev);
 
@@ -6645,6 +6641,18 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device 
*dev)
if (i != 2)
bp-fw_version[j++] = '.';
}
+   if (REG_RD_IND(bp, bp-shmem_base + BNX2_PORT_FEATURE) 
+   BNX2_PORT_FEATURE_ASF_ENABLED) {
+   bp-flags |= ASF_ENABLE_FLAG;
+
+   for (i = 0; i  30; i++) {
+   reg = REG_RD_IND(bp, bp-shmem_base +
+BNX2_BC_STATE_CONDITION);
+   if (reg  BNX2_CONDITION_MFW_RUN_MASK)
+   break;
+   msleep(10);
+   }
+   }
reg = REG_RD_IND(bp, bp-shmem_base + BNX2_BC_STATE_CONDITION);
reg = BNX2_CONDITION_MFW_RUN_MASK;
if (reg != BNX2_CONDITION_MFW_RUN_UNKNOWN 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[BNX2]: Use constants for stats ticks.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=7ea6920ee9480118e2bd2d712d667820703f55cd
Commit: 7ea6920ee9480118e2bd2d712d667820703f55cd
Parent: c2d3db8c7cbb94e77461627085b85d74dc64d716
Author: Michael Chan [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:27:10 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:48 2007 -0700

[BNX2]: Use constants for stats ticks.

Change all stats related magic numbers to constants.

Signed-off-by: Michael Chan [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/net/bnx2.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 28399d8..2dd002b 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -4123,7 +4123,7 @@ bnx2_init_chip(struct bnx2 *bp)
if (CHIP_NUM(bp) == CHIP_NUM_5708)
REG_WR(bp, BNX2_HC_STATS_TICKS, 0);
else
-   REG_WR(bp, BNX2_HC_STATS_TICKS, bp-stats_ticks  0x00);
+   REG_WR(bp, BNX2_HC_STATS_TICKS, bp-stats_ticks);
REG_WR(bp, BNX2_HC_STAT_COLLECT_TICKS, 0xbb8);  /* 3ms */
 
if (CHIP_ID(bp) == CHIP_ID_5706_A1)
@@ -5798,8 +5798,9 @@ bnx2_set_coalesce(struct net_device *dev, struct 
ethtool_coalesce *coal)
if (bp-stats_ticks != 0  bp-stats_ticks != USEC_PER_SEC)
bp-stats_ticks = USEC_PER_SEC;
}
-   if (bp-stats_ticks  0x00) bp-stats_ticks = 0x00;
-   bp-stats_ticks = 0x00;
+   if (bp-stats_ticks  BNX2_HC_STATS_TICKS_HC_STAT_TICKS)
+   bp-stats_ticks = BNX2_HC_STATS_TICKS_HC_STAT_TICKS;
+   bp-stats_ticks = BNX2_HC_STATS_TICKS_HC_STAT_TICKS;
 
if (netif_running(bp-dev)) {
bnx2_netif_stop(bp);
@@ -6696,7 +6697,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device 
*dev)
bp-rx_ticks_int = 18;
bp-rx_ticks = 18;
 
-   bp-stats_ticks = 100  0x00;
+   bp-stats_ticks = USEC_PER_SEC  BNX2_HC_STATS_TICKS_HC_STAT_TICKS;
 
bp-timer_interval =  HZ;
bp-current_interval =  HZ;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[BNX2]: Update version to 1.6.3.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=dd121c4bbf60336773485e91b5cfc57596b45151
Commit: dd121c4bbf60336773485e91b5cfc57596b45151
Parent: 7ea6920ee9480118e2bd2d712d667820703f55cd
Author: Michael Chan [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:27:32 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:49 2007 -0700

[BNX2]: Update version to 1.6.3.

Signed-off-by: Michael Chan [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/net/bnx2.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 2dd002b..a729da0 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -54,8 +54,8 @@
 
 #define DRV_MODULE_NAMEbnx2
 #define PFX DRV_MODULE_NAME: 
-#define DRV_MODULE_VERSION 1.6.2
-#define DRV_MODULE_RELDATE July 6, 2007
+#define DRV_MODULE_VERSION 1.6.3
+#define DRV_MODULE_RELDATE July 16, 2007
 
 #define RUN_AT(x) (jiffies + (x))
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[NET]: gen_estimator deadlock fix

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0929c2dd83317813425b937fbc0041013b8685ff
Commit: 0929c2dd83317813425b937fbc0041013b8685ff
Parent: dd121c4bbf60336773485e91b5cfc57596b45151
Author: Ranko Zivojnovic [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:28:32 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:50 2007 -0700

[NET]: gen_estimator deadlock fix

-Fixes ABBA deadlock noted by Patrick McHardy [EMAIL PROTECTED]:

 There is at least one ABBA deadlock, est_timer() does:
 read_lock(est_lock)
 spin_lock(e-stats_lock) (which is dev-queue_lock)

 and qdisc_destroy calls htb_destroy under dev-queue_lock, which
 calls htb_destroy_class, then gen_kill_estimator and this
 write_locks est_lock.

To fix the ABBA deadlock the rate estimators are now kept on an rcu list.

-The est_lock changes the use from protecting the list to protecting
the update to the 'bstat' pointer in order to avoid NULL dereferencing.

-The 'interval' member of the gen_estimator structure removed as it is
not needed.

Signed-off-by: Ranko Zivojnovic [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 net/core/gen_estimator.c |   81 --
 1 files changed, 49 insertions(+), 32 deletions(-)

diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c
index cc84d8d..590a767 100644
--- a/net/core/gen_estimator.c
+++ b/net/core/gen_estimator.c
@@ -79,27 +79,27 @@
 
 struct gen_estimator
 {
-   struct gen_estimator*next;
+   struct list_headlist;
struct gnet_stats_basic *bstats;
struct gnet_stats_rate_est  *rate_est;
spinlock_t  *stats_lock;
-   unsignedinterval;
int ewma_log;
u64 last_bytes;
u32 last_packets;
u32 avpps;
u32 avbps;
+   struct rcu_head e_rcu;
 };
 
 struct gen_estimator_head
 {
struct timer_list   timer;
-   struct gen_estimator*list;
+   struct list_headlist;
 };
 
 static struct gen_estimator_head elist[EST_MAX_INTERVAL+1];
 
-/* Estimator array lock */
+/* Protects against NULL dereference */
 static DEFINE_RWLOCK(est_lock);
 
 static void est_timer(unsigned long arg)
@@ -107,13 +107,17 @@ static void est_timer(unsigned long arg)
int idx = (int)arg;
struct gen_estimator *e;
 
-   read_lock(est_lock);
-   for (e = elist[idx].list; e; e = e-next) {
+   rcu_read_lock();
+   list_for_each_entry_rcu(e, elist[idx].list, list) {
u64 nbytes;
u32 npackets;
u32 rate;
 
spin_lock(e-stats_lock);
+   read_lock(est_lock);
+   if (e-bstats == NULL)
+   goto skip;
+
nbytes = e-bstats-bytes;
npackets = e-bstats-packets;
rate = (nbytes - e-last_bytes)(7 - idx);
@@ -125,12 +129,14 @@ static void est_timer(unsigned long arg)
e-last_packets = npackets;
e-avpps += ((long)rate - (long)e-avpps)  e-ewma_log;
e-rate_est-pps = (e-avpps+0x1FF)10;
+skip:
+   read_unlock(est_lock);
spin_unlock(e-stats_lock);
}
 
-   if (elist[idx].list != NULL)
+   if (!list_empty(elist[idx].list))
mod_timer(elist[idx].timer, jiffies + ((HZidx)/4));
-   read_unlock(est_lock);
+   rcu_read_unlock();
 }
 
 /**
@@ -147,12 +153,17 @@ static void est_timer(unsigned long arg)
  * rate_est with the statistics lock grabed during this period.
  *
  * Returns 0 on success or a negative error code.
+ *
+ * NOTE: Called under rtnl_mutex
  */
 int gen_new_estimator(struct gnet_stats_basic *bstats,
-   struct gnet_stats_rate_est *rate_est, spinlock_t *stats_lock, struct 
rtattr *opt)
+ struct gnet_stats_rate_est *rate_est,
+ spinlock_t *stats_lock,
+ struct rtattr *opt)
 {
struct gen_estimator *est;
struct gnet_estimator *parm = RTA_DATA(opt);
+   int idx;
 
if (RTA_PAYLOAD(opt)  sizeof(*parm))
return -EINVAL;
@@ -164,7 +175,7 @@ int gen_new_estimator(struct gnet_stats_basic *bstats,
if (est == NULL)
return -ENOBUFS;
 
-   est-interval = parm-interval + 2;
+   idx = parm-interval + 2;
est-bstats = bstats;
est-rate_est = rate_est;
est-stats_lock = stats_lock;
@@ -174,20 +185,25 @@ int gen_new_estimator(struct gnet_stats_basic *bstats,
est-last_packets = bstats-packets;
est-avpps = rate_est-pps10;
 
-   est-next = elist[est-interval].list;
-   if (est-next == NULL) {
-   

[ATM]: Eliminate dead config variable CONFIG_BR2684_FAST_TRANS.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b5492c4ed7a3fbbfa1a62db54e4934fd0b6a45ac
Commit: b5492c4ed7a3fbbfa1a62db54e4934fd0b6a45ac
Parent: 782f7956891c95e54c5b008b24ebf9e82fd84796
Author: Robert P. J. Day [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:31:24 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:52 2007 -0700

[ATM]: Eliminate dead config variable CONFIG_BR2684_FAST_TRANS.

Signed-off-by: chas williams [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 net/atm/br2684.c |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index faa6aaf..c0f6861 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -460,11 +460,7 @@ static void br2684_push(struct atm_vcc *atmvcc, struct 
sk_buff *skb)
skb_pull(skb, plen);
skb_set_mac_header(skb, -ETH_HLEN);
skb-pkt_type = PACKET_HOST;
-#ifdef CONFIG_BR2684_FAST_TRANS
-   skb-protocol = ((u16 *) skb-data)[-1];
-#else  /* some protocols might require this: */
skb-protocol = br_type_trans(skb, net_dev);
-#endif /* CONFIG_BR2684_FAST_TRANS */
 #else
skb_pull(skb, plen - ETH_HLEN);
skb-protocol = eth_type_trans(skb, net_dev);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[ATM]: [nicstar] Replace C code with call to ARRAY_SIZE() macro.

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2db84a8699db45c1c62dccdad61323eab56c111e
Commit: 2db84a8699db45c1c62dccdad61323eab56c111e
Parent: b5492c4ed7a3fbbfa1a62db54e4934fd0b6a45ac
Author: Robert P. J. Day [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:31:51 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:53 2007 -0700

[ATM]: [nicstar] Replace C code with call to ARRAY_SIZE() macro.

Signed-off-by: Robert P. J. Day [EMAIL PROTECTED]
Signed-off-by: chas williams [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/atm/nicstarmac.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/atm/nicstarmac.c b/drivers/atm/nicstarmac.c
index 480947f..842e26c 100644
--- a/drivers/atm/nicstarmac.c
+++ b/drivers/atm/nicstarmac.c
@@ -134,7 +134,7 @@ nicstar_read_eprom_status( virt_addr_t base )
/* Send read instruction */
val = NICSTAR_REG_READ( base, NICSTAR_REG_GENERAL_PURPOSE )  0xFFF0;
 
-   for (i=0; isizeof rdsrtab/sizeof rdsrtab[0]; i++)
+   for (i=0; iARRAY_SIZE(rdsrtab); i++)
{
NICSTAR_REG_WRITE( base, NICSTAR_REG_GENERAL_PURPOSE,
(val | rdsrtab[i]) );
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[ATM]: [lanai] sram_test_word() must be __devinit

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=de24a193124e40fc4f23160336982de1565d51fc
Commit: de24a193124e40fc4f23160336982de1565d51fc
Parent: 2db84a8699db45c1c62dccdad61323eab56c111e
Author: Adrian Bunk [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:34:04 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:54 2007 -0700

[ATM]: [lanai] sram_test_word() must be __devinit

Signed-off-by: Adrian Bunk [EMAIL PROTECTED]
Signed-off-by: chas williams [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/atm/lanai.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index 0e2c1ae..55fd1b4 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -552,8 +552,8 @@ static inline void sram_write(const struct lanai_dev *lanai,
writel(val, sram_addr(lanai, offset));
 }
 
-static int __init sram_test_word(
-   const struct lanai_dev *lanai, int offset, u32 pattern)
+static int __devinit sram_test_word(const struct lanai_dev *lanai,
+   int offset, u32 pattern)
 {
u32 readback;
sram_write(lanai, pattern, offset);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[ATM]: [drivers] ioremap balanced with iounmap

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=78e4be16e0563bb6bf25c178d1eb2f5f6f622eb2
Commit: 78e4be16e0563bb6bf25c178d1eb2f5f6f622eb2
Parent: de24a193124e40fc4f23160336982de1565d51fc
Author: Amol Lad [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:34:36 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:55 2007 -0700

[ATM]: [drivers] ioremap balanced with iounmap

Signed-off-by: Amol Lad [EMAIL PROTECTED]
Signed-off-by: chas williams [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/atm/eni.c|   19 +++
 drivers/atm/firestream.c |   14 +-
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index 77637e7..41b2204 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -1738,7 +1738,8 @@ static int __devinit eni_do_init(struct atm_dev *dev)
printk(KERN_ERR KERN_ERR DEV_LABEL (itf %d): bad 
magic - expected 0x%x, got 0x%x\n,dev-number,
ENI155_MAGIC,(unsigned) readl(eprom-magic));
-   return -EINVAL;
+   error = -EINVAL;
+   goto unmap;
}
}
eni_dev-phy = base+PHY_BASE;
@@ -1765,17 +1766,27 @@ static int __devinit eni_do_init(struct atm_dev *dev)
printk()\n);
printk(KERN_ERR DEV_LABEL (itf %d): ERROR - wrong id 0x%x\n,
dev-number,(unsigned) eni_in(MID_RES_ID_MCON));
-   return -EINVAL;
+   error = -EINVAL;
+   goto unmap;
}
error = eni_dev-asic ? get_esi_asic(dev) : get_esi_fpga(dev,base);
-   if (error) return error;
+   if (error)
+   goto unmap;
for (i = 0; i  ESI_LEN; i++)
printk(%s%02X,i ? - : ,dev-esi[i]);
printk()\n);
printk(KERN_NOTICE DEV_LABEL (itf %d): %s,%s\n,dev-number,
eni_in(MID_RES_ID_MCON)  0x200 ? ASIC : FPGA,
media_name[eni_in(MID_RES_ID_MCON)  DAUGTHER_ID]);
-   return suni_init(dev);
+
+   error = suni_init(dev);
+   if (error)
+   goto unmap;
+out:
+   return error;
+unmap:
+   iounmap(base);
+   goto out;
 }
 
 
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 38b688f..737cea4 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1710,7 +1710,7 @@ static int __devinit fs_init (struct fs_dev *dev)
/* This bit is documented as RESERVED */
if (isr  ISR_INIT_ERR) {
printk (KERN_ERR Error initializing the FS... \n);
-   return 1;
+   goto unmap;
}
if (isr  ISR_INIT) {
fs_dprintk (FS_DEBUG_INIT, Ha! Initialized OK!\n);
@@ -1723,7 +1723,7 @@ static int __devinit fs_init (struct fs_dev *dev)
 
if (!to) {
printk (KERN_ERR timeout initializing the FS... \n);
-   return 1;
+   goto unmap;
}
 
/* XXX fix for fs155 */
@@ -1803,7 +1803,7 @@ static int __devinit fs_init (struct fs_dev *dev)
if (!dev-atm_vccs) {
printk (KERN_WARNING Couldn't allocate memory for VCC buffers. 
Woops!\n);
/* XXX Clean up. */
-   return 1;
+   goto unmap;
}
 
dev-tx_inuse = kzalloc (dev-nchannels / 8 /* bits/byte */ , 
GFP_KERNEL);
@@ -1813,7 +1813,7 @@ static int __devinit fs_init (struct fs_dev *dev)
if (!dev-tx_inuse) {
printk (KERN_WARNING Couldn't allocate memory for tx_inuse 
bits!\n);
/* XXX Clean up. */
-   return 1;
+   goto unmap;
}
/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
/* -- RAS2 : FS50 only: Default is OK. */
@@ -1840,7 +1840,7 @@ static int __devinit fs_init (struct fs_dev *dev)
if (request_irq (dev-irq, fs_irq, IRQF_SHARED, firestream, dev)) {
printk (KERN_WARNING couldn't get irq %d for firestream.\n, 
pci_dev-irq);
/* XXX undo all previous stuff... */
-   return 1;
+   goto unmap;
}
fs_dprintk (FS_DEBUG_INIT, Grabbed irq %d for dev at %p.\n, dev-irq, 
dev);
   
@@ -1890,6 +1890,9 @@ static int __devinit fs_init (struct fs_dev *dev)
   
func_exit ();
return 0;
+unmap:
+   iounmap(dev-base);
+   return 1;
 }
 
 static int __devinit firestream_init_one (struct pci_dev *pci_dev,
@@ -2012,6 +2015,7 @@ static void __devexit firestream_remove_one (struct 
pci_dev *pdev)
for (i=0;i  FS_NR_RX_QUEUES;i++)
free_queue (dev, dev-rx_rq[i]);
 
+   iounmap(dev-base);
fs_dprintk 

[ATM]: [idt77252] Rename CONFIG_ATM_IDT77252_SEND_IDLE to not resemble a Kconfig variable

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=44beac008631d1b8a52f103e04eacba2bda81511
Commit: 44beac008631d1b8a52f103e04eacba2bda81511
Parent: 78e4be16e0563bb6bf25c178d1eb2f5f6f622eb2
Author: Robert P. J. Day [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:35:07 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:56 2007 -0700

[ATM]: [idt77252] Rename CONFIG_ATM_IDT77252_SEND_IDLE to not resemble a 
Kconfig variable

Signed-off-by: Robert P. J. Day [EMAIL PROTECTED]
Signed-off-by: chas williams [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/atm/idt77252.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 8f995ce..f8b1700 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -65,7 +65,7 @@ static char const rcsid[] =
 static unsigned int vpibits = 1;
 
 
-#define CONFIG_ATM_IDT77252_SEND_IDLE 1
+#define ATM_IDT77252_SEND_IDLE 1
 
 
 /*
@@ -3404,7 +3404,7 @@ init_card(struct atm_dev *dev)
conf =  SAR_CFG_TX_FIFO_SIZE_9 |/* Use maximum fifo size */
SAR_CFG_RXSTQ_SIZE_8k | /* Receive Status Queue is 8k */
SAR_CFG_IDLE_CLP |  /* Set CLP on idle cells */
-#ifndef CONFIG_ATM_IDT77252_SEND_IDLE
+#ifndef ATM_IDT77252_SEND_IDLE
SAR_CFG_NO_IDLE |   /* Do not send idle cells */
 #endif
0;
@@ -3541,7 +3541,7 @@ init_card(struct atm_dev *dev)
printk(%s: Linkrate on ATM line : %u bit/s, %u cell/s.\n,
   card-name, linkrate, card-link_pcr);
 
-#ifdef CONFIG_ATM_IDT77252_SEND_IDLE
+#ifdef ATM_IDT77252_SEND_IDLE
card-utopia_pcr = card-link_pcr;
 #else
card-utopia_pcr = (16000 / 8 / 54);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[TCP]: remove unused argument to cong_avoid op

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=16751347a060a10c09b11593bb179fd5b0240c04
Commit: 16751347a060a10c09b11593bb179fd5b0240c04
Parent: 44beac008631d1b8a52f103e04eacba2bda81511
Author: Stephen Hemminger [EMAIL PROTECTED]
AuthorDate: Mon Jul 16 18:35:52 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:46:58 2007 -0700

[TCP]: remove unused argument to cong_avoid op

None of the existing TCP congestion controls use the rtt value pased
in the ca_ops-cong_avoid interface.  Which is lucky because seq_rtt
could have been -1 when handling a duplicate ack.

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 include/net/tcp.h|6 ++
 net/ipv4/tcp_bic.c   |2 +-
 net/ipv4/tcp_cong.c  |3 +--
 net/ipv4/tcp_cubic.c |2 +-
 net/ipv4/tcp_highspeed.c |2 +-
 net/ipv4/tcp_htcp.c  |2 +-
 net/ipv4/tcp_hybla.c |4 ++--
 net/ipv4/tcp_illinois.c  |2 +-
 net/ipv4/tcp_input.c |8 
 net/ipv4/tcp_lp.c|5 ++---
 net/ipv4/tcp_scalable.c  |2 +-
 net/ipv4/tcp_vegas.c |6 +++---
 net/ipv4/tcp_veno.c  |6 +++---
 net/ipv4/tcp_yeah.c  |2 +-
 14 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index a8af9ae..8b404b1 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -652,8 +652,7 @@ struct tcp_congestion_ops {
/* lower bound for congestion window (optional) */
u32 (*min_cwnd)(const struct sock *sk);
/* do new cwnd calculation (required) */
-   void (*cong_avoid)(struct sock *sk, u32 ack,
-  u32 rtt, u32 in_flight, int good_ack);
+   void (*cong_avoid)(struct sock *sk, u32 ack, u32 in_flight, int 
good_ack);
/* call before changing ca_state (optional) */
void (*set_state)(struct sock *sk, u8 new_state);
/* call when cwnd event occurs (optional) */
@@ -684,8 +683,7 @@ extern void tcp_slow_start(struct tcp_sock *tp);
 
 extern struct tcp_congestion_ops tcp_init_congestion_ops;
 extern u32 tcp_reno_ssthresh(struct sock *sk);
-extern void tcp_reno_cong_avoid(struct sock *sk, u32 ack,
-   u32 rtt, u32 in_flight, int flag);
+extern void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 in_flight, int 
flag);
 extern u32 tcp_reno_min_cwnd(const struct sock *sk);
 extern struct tcp_congestion_ops tcp_reno;
 
diff --git a/net/ipv4/tcp_bic.c b/net/ipv4/tcp_bic.c
index dd9ef65..519de09 100644
--- a/net/ipv4/tcp_bic.c
+++ b/net/ipv4/tcp_bic.c
@@ -137,7 +137,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 
cwnd)
 }
 
 static void bictcp_cong_avoid(struct sock *sk, u32 ack,
- u32 seq_rtt, u32 in_flight, int data_acked)
+ u32 in_flight, int data_acked)
 {
struct tcp_sock *tp = tcp_sk(sk);
struct bictcp *ca = inet_csk_ca(sk);
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index 1260e52..55fca18 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -324,8 +324,7 @@ EXPORT_SYMBOL_GPL(tcp_slow_start);
 /* This is Jacobson's slow start and congestion avoidance.
  * SIGCOMM '88, p. 328.
  */
-void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 rtt, u32 in_flight,
-int flag)
+void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 in_flight, int flag)
 {
struct tcp_sock *tp = tcp_sk(sk);
 
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index ebfaac2..d17da30 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -270,7 +270,7 @@ static inline void measure_delay(struct sock *sk)
 }
 
 static void bictcp_cong_avoid(struct sock *sk, u32 ack,
- u32 seq_rtt, u32 in_flight, int data_acked)
+ u32 in_flight, int data_acked)
 {
struct tcp_sock *tp = tcp_sk(sk);
struct bictcp *ca = inet_csk_ca(sk);
diff --git a/net/ipv4/tcp_highspeed.c b/net/ipv4/tcp_highspeed.c
index 43d624e..14a073d 100644
--- a/net/ipv4/tcp_highspeed.c
+++ b/net/ipv4/tcp_highspeed.c
@@ -109,7 +109,7 @@ static void hstcp_init(struct sock *sk)
tp-snd_cwnd_clamp = min_t(u32, tp-snd_cwnd_clamp, 0x/128);
 }
 
-static void hstcp_cong_avoid(struct sock *sk, u32 adk, u32 rtt,
+static void hstcp_cong_avoid(struct sock *sk, u32 adk,
 u32 in_flight, int data_acked)
 {
struct tcp_sock *tp = tcp_sk(sk);
diff --git a/net/ipv4/tcp_htcp.c b/net/ipv4/tcp_htcp.c
index 4ba4a7a..632c05a 100644
--- a/net/ipv4/tcp_htcp.c
+++ b/net/ipv4/tcp_htcp.c
@@ -225,7 +225,7 @@ static u32 htcp_recalc_ssthresh(struct sock *sk)
return max((tp-snd_cwnd * ca-beta)  7, 2U);
 }
 
-static void htcp_cong_avoid(struct sock *sk, u32 ack, u32 rtt,
+static void htcp_cong_avoid(struct sock *sk, u32 ack, s32 rtt,

[XFRM]: Fix crash introduced by struct dst_entry reordering

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=bd0bf0765ea1fba80d7085e1f0375ec045631dc1
Commit: bd0bf0765ea1fba80d7085e1f0375ec045631dc1
Parent: 16751347a060a10c09b11593bb179fd5b0240c04
Author: Patrick McHardy [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 01:55:52 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 01:55:52 2007 -0700

[XFRM]: Fix crash introduced by struct dst_entry reordering

XFRM expects xfrm_dst-u.next to be same pointer as dst-next, which
was broken by the dst_entry reordering in commit 1e19e02c~, causing
an oops in xfrm_bundle_ok when walking the bundle upwards.

Kill xfrm_dst-u.next and change the only user to use dst-next instead.

Signed-off-by: Patrick McHardy [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 include/net/xfrm.h |1 -
 net/xfrm/xfrm_policy.c |2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index ae959e9..a5f80bf 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -585,7 +585,6 @@ static inline int xfrm_sec_ctx_match(struct xfrm_sec_ctx 
*s1, struct xfrm_sec_ct
 struct xfrm_dst
 {
union {
-   struct xfrm_dst *next;
struct dst_entrydst;
struct rtable   rt;
struct rt6_info rt6;
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 157bfbd..b48f06f 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2141,7 +2141,7 @@ int xfrm_bundle_ok(struct xfrm_policy *pol, struct 
xfrm_dst *first,
if (last == first)
break;
 
-   last = last-u.next;
+   last = (struct xfrm_dst *)last-u.dst.next;
last-child_mtu_cached = mtu;
}
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PKT_SCHED]: Some typo fixes in net/sched/Kconfig

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=99acaeb92fc2d52900f00b8e926d9ad81b6e93bb
Commit: 99acaeb92fc2d52900f00b8e926d9ad81b6e93bb
Parent: bd0bf0765ea1fba80d7085e1f0375ec045631dc1
Author: Gabriel Craciunescu [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 02:00:04 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 02:00:04 2007 -0700

[PKT_SCHED]: Some typo fixes in net/sched/Kconfig

Signed-off-by: Gabriel Craciunescu [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 net/sched/Kconfig |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index d3f7c3f..8a74cac 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -97,7 +97,7 @@ config NET_SCH_ATM
  select classes of this queuing discipline.  Each class maps
  the flow(s) it is handling to a given virtual circuit.
 
- See the top of file:net/sched/sch_atm.c) for more details.
+ See the top of file:net/sched/sch_atm.c for more details.
 
  To compile this code as a module, choose M here: the
  module will be called sch_atm.
@@ -137,7 +137,7 @@ config NET_SCH_SFQ
tristate Stochastic Fairness Queueing (SFQ)
---help---
  Say Y here if you want to use the Stochastic Fairness Queueing (SFQ)
- packet scheduling algorithm .
+ packet scheduling algorithm.
 
  See the top of file:net/sched/sch_sfq.c for more details.
 
@@ -306,7 +306,7 @@ config NET_CLS_RSVP6
  is important for real time data such as streaming sound or video.
 
  Say Y here if you want to be able to classify outgoing packets based
- on their RSVP requests and you are using the IPv6.
+ on their RSVP requests and you are using the IPv6 protocol.
 
  To compile this code as a module, choose M here: the
  module will be called cls_rsvp6.
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PPPOL2TP]: Reset meta-data in xmit function

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f77ae9390438409b535f3b1854672e54120cd38b
Commit: f77ae9390438409b535f3b1854672e54120cd38b
Parent: 7d4372b5ae2f891e8bfa96c98d450255f58b4dc1
Author: Patrick McHardy [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 02:04:39 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 02:04:39 2007 -0700

[PPPOL2TP]: Reset meta-data in xmit function

Reset netfilter data and IP CB, fix dst_entry leak.

Signed-off-by: Patrick McHardy [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/net/pppol2tp.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index 856610f..f871760 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -1049,7 +1049,13 @@ static int pppol2tp_xmit(struct ppp_channel *chan, 
struct sk_buff *skb)
printk(\n);
}
 
+   memset((IPCB(skb2)-opt), 0, sizeof(IPCB(skb2)-opt));
+   IPCB(skb2)-flags = ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
+  IPSKB_REROUTED);
+   nf_reset(skb2);
+
/* Get routing info from the tunnel socket */
+   dst_release(skb2-dst);
skb2-dst = sk_dst_get(sk_tun);
 
/* Queue the packet to IP for output */
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[NETLINK]: negative groups in netlink_setsockopt

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=eb4965344965530411359891214cd6fcab483649
Commit: eb4965344965530411359891214cd6fcab483649
Parent: f77ae9390438409b535f3b1854672e54120cd38b
Author: Johannes Berg [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 02:07:51 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 02:07:51 2007 -0700

[NETLINK]: negative groups in netlink_setsockopt

Reading netlink_setsockopt it's not immediately clear why there isn't a
bug when you pass in negative numbers, the reason being that the =
comparison is really unsigned although 'val' is signed because
nlk-ngroups is unsigned. Make 'val' unsigned too.

[ Update the get_user() cast to match.  --DaveM ]

Signed-off-by: Johannes Berg [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 net/netlink/af_netlink.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index a3c8e69..641cfbc 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1012,13 +1012,14 @@ static int netlink_setsockopt(struct socket *sock, int 
level, int optname,
 {
struct sock *sk = sock-sk;
struct netlink_sock *nlk = nlk_sk(sk);
-   int val = 0, err;
+   unsigned int val = 0;
+   int err;
 
if (level != SOL_NETLINK)
return -ENOPROTOOPT;
 
if (optlen = sizeof(int) 
-   get_user(val, (int __user *)optval))
+   get_user(val, (unsigned int __user *)optval))
return -EFAULT;
 
switch (optname) {
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[NET]: merge dev_unicast_discard and dev_mc_discard into one

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=26cc2522cb6ebf0c1c736485e102e9654cde1145
Commit: 26cc2522cb6ebf0c1c736485e102e9654cde1145
Parent: 456ad75c89cdb72e11dcdb6b0794802a6f50c8a3
Author: Denis Cheng [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 02:12:03 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 02:12:03 2007 -0700

[NET]: merge dev_unicast_discard and dev_mc_discard into one

this two functions could share the dev-_xmit_lock acquired context.

Signed-off-by: Denis Cheng [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 net/core/dev.c |   16 
 1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 3ba63aa..17c9cbd 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2777,23 +2777,16 @@ int dev_unicast_add(struct net_device *dev, void *addr, 
int alen)
 }
 EXPORT_SYMBOL(dev_unicast_add);
 
-static void dev_unicast_discard(struct net_device *dev)
+static void dev_addr_discard(struct net_device *dev)
 {
netif_tx_lock_bh(dev);
+
__dev_addr_discard(dev-uc_list);
dev-uc_count = 0;
-   netif_tx_unlock_bh(dev);
-}
 
-/*
- * Discard multicast list when a device is downed
- */
-
-static void dev_mc_discard(struct net_device *dev)
-{
-   netif_tx_lock_bh(dev);
__dev_addr_discard(dev-mc_list);
dev-mc_count = 0;
+
netif_tx_unlock_bh(dev);
 }
 
@@ -3751,8 +3744,7 @@ void unregister_netdevice(struct net_device *dev)
/*
 *  Flush the unicast and multicast chains
 */
-   dev_unicast_discard(dev);
-   dev_mc_discard(dev);
+   dev_addr_discard(dev);
 
if (dev-uninit)
dev-uninit(dev);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[NET]: move __dev_addr_discard adjacent to dev_addr_discard for readability

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=12972621c8a18465e3d20cc8e3006a8b7f7788df
Commit: 12972621c8a18465e3d20cc8e3006a8b7f7788df
Parent: 26cc2522cb6ebf0c1c736485e102e9654cde1145
Author: Denis Cheng [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 02:12:56 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 02:12:56 2007 -0700

[NET]: move __dev_addr_discard adjacent to dev_addr_discard for readability

Signed-off-by: Denis Cheng [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 net/core/dev.c |   28 ++--
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 17c9cbd..6357f54 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2715,20 +2715,6 @@ int __dev_addr_add(struct dev_addr_list **list, int 
*count,
return 0;
 }
 
-static void __dev_addr_discard(struct dev_addr_list **list)
-{
-   struct dev_addr_list *tmp;
-
-   while (*list != NULL) {
-   tmp = *list;
-   *list = tmp-next;
-   if (tmp-da_users  tmp-da_gusers)
-   printk(__dev_addr_discard: address leakage! 
-  da_users=%d\n, tmp-da_users);
-   kfree(tmp);
-   }
-}
-
 /**
  * dev_unicast_delete  - Release secondary unicast address.
  * @dev: device
@@ -2777,6 +2763,20 @@ int dev_unicast_add(struct net_device *dev, void *addr, 
int alen)
 }
 EXPORT_SYMBOL(dev_unicast_add);
 
+static void __dev_addr_discard(struct dev_addr_list **list)
+{
+   struct dev_addr_list *tmp;
+
+   while (*list != NULL) {
+   tmp = *list;
+   *list = tmp-next;
+   if (tmp-da_users  tmp-da_gusers)
+   printk(__dev_addr_discard: address leakage! 
+  da_users=%d\n, tmp-da_users);
+   kfree(tmp);
+   }
+}
+
 static void dev_addr_discard(struct net_device *dev)
 {
netif_tx_lock_bh(dev);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[ATM]: nicstar needs virt_to_bus

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=83ca46e7ac7b2883ae7d02503a01e8f1578afe4e
Commit: 83ca46e7ac7b2883ae7d02503a01e8f1578afe4e
Parent: 12972621c8a18465e3d20cc8e3006a8b7f7788df
Author: Stephen Rothwell [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 02:13:42 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 02:13:42 2007 -0700

[ATM]: nicstar needs virt_to_bus

Signed-off-by: Stephen Rothwell [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 drivers/atm/Kconfig |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/atm/Kconfig b/drivers/atm/Kconfig
index bb4ae62..bed9f58 100644
--- a/drivers/atm/Kconfig
+++ b/drivers/atm/Kconfig
@@ -172,7 +172,7 @@ config ATM_ZATM_DEBUG
 
 config ATM_NICSTAR
tristate IDT 77201 (NICStAR) (ForeRunnerLE)
-   depends on PCI  !64BIT
+   depends on PCI  !64BIT  VIRT_TO_BUS
help
  The NICStAR chipset family is used in a large number of ATM NICs for
  25 and for 155 Mbps, including IDT cards and the Fore ForeRunnerLE
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[IrDA]: Fix IrDA build failure

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=75a69ac6d66d2504ecbc4b46645fb0835a55a57c
Commit: 75a69ac6d66d2504ecbc4b46645fb0835a55a57c
Parent: 83ca46e7ac7b2883ae7d02503a01e8f1578afe4e
Author: Samuel Ortiz [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 02:16:30 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 02:16:30 2007 -0700

[IrDA]: Fix IrDA build failure

When having built-in IrDA, we hit the following error:

`irda_sysctl_unregister' referenced in section `.init.text' of
net/built-in.o: defined in discarded section `.exit.text' of
net/built-in.o
`irda_proc_unregister' referenced in section `.init.text' of
net/built-in.o: defined in discarded section `.exit.text' of
net/built-in.o
`irsock_cleanup' referenced in section `.init.text' of net/built-in.o:
defined in discarded section `.exit.text' of net/built-in.o
`irttp_cleanup' referenced in section `.init.text' of net/built-in.o:
defined in discarded section `.exit.text' of net/built-in.o
`iriap_cleanup' referenced in section `.init.text' of net/built-in.o:
defined in discarded section `.exit.text' of net/built-in.o
`irda_device_cleanup' referenced in section `.init.text' of
net/built-in.o: defined in discarded section `.exit.text' of
net/built-in.o
`irlap_cleanup' referenced in section `.init.text' of net/built-in.o:
defined in discarded section `.exit.text' of net/built-in.o
`irlmp_cleanup' referenced in section `.init.text' of net/built-in.o:
defined in discarded section `.exit.text' of net/built-in.o
make[1]: *** [.tmp_vmlinux1] Error 1
make: *** [_all] Error 2

This is due to the irda_init fix recently added, where we call __exit
routines from an __init one. It is a build failure that I didn't catch
because it doesn't show up when building IrDA as a module. My apologies
for that.
The following patch fixes that failure and is against your net-2.6
tree. I hope it can make it to the merge window, and [EMAIL PROTECTED]
is CCed on this mail.

Signed-off-by: Samuel Ortiz [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 net/irda/af_irda.c |2 +-
 net/irda/irda_device.c |4 ++--
 net/irda/iriap.c   |2 +-
 net/irda/irlap.c   |2 +-
 net/irda/irlmp.c   |2 +-
 net/irda/irproc.c  |2 +-
 net/irda/irsysctl.c|2 +-
 net/irda/irttp.c   |2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index dcd7e32..4c670cf 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -2567,7 +2567,7 @@ int __init irsock_init(void)
  *Remove IrDA protocol
  *
  */
-void __exit irsock_cleanup(void)
+void irsock_cleanup(void)
 {
sock_unregister(PF_IRDA);
proto_unregister(irda_proto);
diff --git a/net/irda/irda_device.c b/net/irda/irda_device.c
index 7b5def1..435b563 100644
--- a/net/irda/irda_device.c
+++ b/net/irda/irda_device.c
@@ -95,14 +95,14 @@ int __init irda_device_init( void)
return 0;
 }
 
-static void __exit leftover_dongle(void *arg)
+static void leftover_dongle(void *arg)
 {
struct dongle_reg *reg = arg;
IRDA_WARNING(IrDA: Dongle type %x not unregistered\n,
 reg-type);
 }
 
-void __exit irda_device_cleanup(void)
+void irda_device_cleanup(void)
 {
IRDA_DEBUG(4, %s()\n, __FUNCTION__);
 
diff --git a/net/irda/iriap.c b/net/irda/iriap.c
index 774eb70..ee3889f 100644
--- a/net/irda/iriap.c
+++ b/net/irda/iriap.c
@@ -153,7 +153,7 @@ int __init iriap_init(void)
  *Initializes the IrIAP layer, called by the module cleanup code in
  *irmod.c
  */
-void __exit iriap_cleanup(void)
+void iriap_cleanup(void)
 {
irlmp_unregister_service(service_handle);
 
diff --git a/net/irda/irlap.c b/net/irda/irlap.c
index 2fc9f51..3d76aaf 100644
--- a/net/irda/irlap.c
+++ b/net/irda/irlap.c
@@ -95,7 +95,7 @@ int __init irlap_init(void)
return 0;
 }
 
-void __exit irlap_cleanup(void)
+void irlap_cleanup(void)
 {
IRDA_ASSERT(irlap != NULL, return;);
 
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
index 24a5e3f..7efa930 100644
--- a/net/irda/irlmp.c
+++ b/net/irda/irlmp.c
@@ -116,7 +116,7 @@ int __init irlmp_init(void)
  *Remove IrLMP layer
  *
  */
-void __exit irlmp_cleanup(void)
+void irlmp_cleanup(void)
 {
/* Check for main structure */
IRDA_ASSERT(irlmp != NULL, return;);
diff --git a/net/irda/irproc.c b/net/irda/irproc.c
index d6f9aba..181cb51 100644
--- a/net/irda/irproc.c
+++ b/net/irda/irproc.c
@@ -84,7 +84,7 @@ void __init irda_proc_register(void)
  *Unregister irda entry in /proc file system
  *
  */
-void __exit irda_proc_unregister(void)
+void irda_proc_unregister(void)
 {
int i;
 
diff --git a/net/irda/irsysctl.c b/net/irda/irsysctl.c
index 2e968e7..957e04f 100644
--- a/net/irda/irsysctl.c

[NETFILTER]: ipt_iprange.h must #include linux/types.h

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ebd61cc042b16e6cf2486aafbfff9e4be8c213ee
Commit: ebd61cc042b16e6cf2486aafbfff9e4be8c213ee
Parent: 75a69ac6d66d2504ecbc4b46645fb0835a55a57c
Author: Adrian Bunk [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 02:21:50 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 02:21:50 2007 -0700

[NETFILTER]: ipt_iprange.h must #include linux/types.h

ipt_iprange.h must #include linux/types.h since it uses __be32.

This patch fixes kernel Bugzilla #7604.

Signed-off-by: Adrian Bunk [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 include/linux/netfilter_ipv4/ipt_iprange.h |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/linux/netfilter_ipv4/ipt_iprange.h 
b/include/linux/netfilter_ipv4/ipt_iprange.h
index 34ab0fb..a92fefc 100644
--- a/include/linux/netfilter_ipv4/ipt_iprange.h
+++ b/include/linux/netfilter_ipv4/ipt_iprange.h
@@ -1,6 +1,8 @@
 #ifndef _IPT_IPRANGE_H
 #define _IPT_IPRANGE_H
 
+#include linux/types.h
+
 #define IPRANGE_SRC0x01/* Match source IP address */
 #define IPRANGE_DST0x02/* Match destination IP address */
 #define IPRANGE_SRC_INV0x10/* Negate the condition */
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[NETFILTER]: xt_connlimit needs to depend on nf_conntrack

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=3fd8f9e4b6c184d03d340bc86630f700de967fa8
Commit: 3fd8f9e4b6c184d03d340bc86630f700de967fa8
Parent: ebd61cc042b16e6cf2486aafbfff9e4be8c213ee
Author: Cornelia Huck [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 02:38:32 2007 -0700
Committer:  David S. Miller [EMAIL PROTECTED]
CommitDate: Wed Jul 18 02:38:32 2007 -0700

[NETFILTER]: xt_connlimit needs to depend on nf_conntrack

With NF_CONNTRACK=n, NETFILTER_XT_MATCH_CONNLIMIT=m I get the
following errors on current git:

  CC [M]  net/netfilter/xt_connlimit.o
  In file included from net/netfilter/xt_connlimit.c:27:
  include/net/netfilter/nf_conntrack.h:100: error: field 'ct_general' has 
incomplete type
  include/net/netfilter/nf_conntrack.h: In function 'nf_ct_get':
  include/net/netfilter/nf_conntrack.h:164: error: 'const struct sk_buff' 
has no member named 'nfct'
  include/net/netfilter/nf_conntrack.h: In function 'nf_ct_put':
  include/net/netfilter/nf_conntrack.h:171: warning: implicit declaration 
of function 'nf_conntrack_put'
  include/net/netfilter/nf_conntrack.h: In function 'nf_ct_is_untracked':
  include/net/netfilter/nf_conntrack.h:253: error: 'const struct sk_buff' 
has no member named 'nfct'
  In file included from net/netfilter/xt_connlimit.c:28:
  include/net/netfilter/nf_conntrack_core.h: In function 
'nf_conntrack_confirm':
  include/net/netfilter/nf_conntrack_core.h:68: error: 'struct sk_buff' has 
no member named 'nfct'

Adding a dependency in Kconfig fixes this.

Signed-off-by: Cornelia Huck [EMAIL PROTECTED]
Signed-off-by: David S. Miller [EMAIL PROTECTED]
---
 net/netfilter/Kconfig |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index 3ac39f1..3599770 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -436,6 +436,7 @@ config NETFILTER_XT_MATCH_CONNBYTES
 config NETFILTER_XT_MATCH_CONNLIMIT
tristate 'connlimit match support'
depends on NETFILTER_XTABLES
+   depends on NF_CONNTRACK
---help---
  This match allows you to match against the number of parallel
  connections to a server per client IP address (or address block).
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: fix memory leak in checking code

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=341e1a0cf2d8965c8b2f7941a6b2f2c2170df469
Commit: 341e1a0cf2d8965c8b2f7941a6b2f2c2170df469
Parent: cb32da0416b823b7f4b65e7e85d6cba16ca4d1e1
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Thu May 3 11:59:51 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:52:13 2007 +0300

UBI: fix memory leak in checking code

Reported-by: Eric Sesterhenn / Snakebyte [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/scan.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 473f320..e445686 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -1310,8 +1310,10 @@ static int paranoid_check_si(const struct ubi_device 
*ubi,
memset(buf, 1, ubi-peb_count);
for (pnum = 0; pnum  ubi-peb_count; pnum++) {
err = ubi_io_is_bad(ubi, pnum);
-   if (err  0)
+   if (err  0) {
+   kfree(buf);
return err;
+   }
else if (err)
buf[pnum] = 0;
}
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: fix dereference after kfree

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c4e90ec0134d7bedebbe3fe58ed5d431293886d4
Commit: c4e90ec0134d7bedebbe3fe58ed5d431293886d4
Parent: 341e1a0cf2d8965c8b2f7941a6b2f2c2170df469
Author: Florin Malita [EMAIL PROTECTED]
AuthorDate: Thu May 3 11:49:57 2007 -0400
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:52:22 2007 +0300

UBI: fix dereference after kfree

Coverity (CID 1614) spotted new_seb being dereferenced after kfree() in
create_vtbl's write_error path.

Signed-off-by: Florin Malita [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/vtbl.c |   11 +--
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index b6fd6bb..83236c3 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -317,14 +317,13 @@ retry:
return err;
 
 write_error:
-   kfree(new_seb);
-   /* May be this physical eraseblock went bad, try to pick another one */
-   if (++tries = 5) {
+   /* Maybe this physical eraseblock went bad, try to pick another one */
+   if (++tries = 5)
err = ubi_scan_add_to_list(si, new_seb-pnum, new_seb-ec,
   si-corr);
-   if (!err)
-   goto retry;
-   }
+   kfree(new_seb);
+   if (!err)
+   goto retry;
 out_free:
ubi_free_vid_hdr(ubi, vid_hdr);
return err;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: fix error path in create_vtbl()

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=78d87c95b89ccf86c142494beada3082810ed368
Commit: 78d87c95b89ccf86c142494beada3082810ed368
Parent: c4e90ec0134d7bedebbe3fe58ed5d431293886d4
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Sat May 5 11:24:02 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:52:32 2007 +0300

UBI: fix error path in create_vtbl()

There were several bugs in volume table creation error path. Thanks to
Satyam Sharma [EMAIL PROTECTED] and Florin Malita [EMAIL PROTECTED]
for finding and analysing them: http://lkml.org/lkml/2007/5/3/274

This patch makes ubi_scan_add_to_list() static and renames it to
add_to_list(), just because it is not needed outside scan.c anymore.

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/scan.c |   46 +++---
 drivers/mtd/ubi/scan.h |2 --
 drivers/mtd/ubi/vtbl.c |   14 --
 3 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index e445686..30d536e 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -24,7 +24,7 @@
  * This unit is responsible for scanning the flash media, checking UBI
  * headers and providing complete information about the UBI flash image.
  *
- * The scanning information is reoresented by a struct ubi_scan_info' object.
+ * The scanning information is represented by a struct ubi_scan_info' object.
  * Information about found volumes is represented by struct ubi_scan_volume
  * objects which are kept in volume RB-tree with root at the @volumes field.
  * The RB-tree is indexed by the volume ID.
@@ -55,8 +55,19 @@ static int paranoid_check_si(const struct ubi_device *ubi,
 static struct ubi_ec_hdr *ech;
 static struct ubi_vid_hdr *vidh;
 
-int ubi_scan_add_to_list(struct ubi_scan_info *si, int pnum, int ec,
-struct list_head *list)
+/*
+ * add_to_list - add physical eraseblock to a list.
+ * @si: scanning information
+ * @pnum: physical eraseblock number to add
+ * @ec: erase counter of the physical eraseblock
+ * @list: the list to add to
+ *
+ * This function adds physical eraseblock @pnum to free, erase, corrupted or
+ * alien lists. Returns zero in case of success and a negative error code in
+ * case of failure.
+ */
+static int add_to_list(struct ubi_scan_info *si, int pnum, int ec,
+  struct list_head *list)
 {
struct ubi_scan_leb *seb;
 
@@ -492,11 +503,11 @@ int ubi_scan_add_used(const struct ubi_device *ubi, 
struct ubi_scan_info *si,
return err;
 
if (cmp_res  4)
-   err = ubi_scan_add_to_list(si, seb-pnum,
-  seb-ec, si-corr);
+   err = add_to_list(si, seb-pnum, seb-ec,
+ si-corr);
else
-   err = ubi_scan_add_to_list(si, seb-pnum,
-  seb-ec, si-erase);
+   err = add_to_list(si, seb-pnum, seb-ec,
+ si-erase);
if (err)
return err;
 
@@ -517,11 +528,9 @@ int ubi_scan_add_used(const struct ubi_device *ubi, struct 
ubi_scan_info *si,
 * previously.
 */
if (cmp_res  4)
-   return ubi_scan_add_to_list(si, pnum, ec,
-   si-corr);
+   return add_to_list(si, pnum, ec, si-corr);
else
-   return ubi_scan_add_to_list(si, pnum, ec,
-   si-erase);
+   return add_to_list(si, pnum, ec, si-erase);
}
}
 
@@ -754,7 +763,7 @@ struct ubi_scan_leb *ubi_scan_get_free_peb(const struct 
ubi_device *ubi,
  * @si: scanning information
  * @pnum: the physical eraseblock number
  *
- * This function returns a zero if the physical eraseblock was succesfully
+ * This function returns a zero if the physical eraseblock was successfully
  * handled and a negative error code in case of failure.
  */
 static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, int 
pnum)
@@ -783,8 +792,7 @@ static int process_eb(struct ubi_device *ubi, struct 
ubi_scan_info *si, int pnum
else if (err == UBI_IO_BITFLIPS)
bitflips = 1;
else if (err == UBI_IO_PEB_EMPTY)
-   return ubi_scan_add_to_list(si, pnum, UBI_SCAN_UNKNOWN_EC,
-   si-erase);
+   

UBI: do not let to read too much

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4ab60a0d7c92cab16f7e470f80ea039a0b174bce
Commit: 4ab60a0d7c92cab16f7e470f80ea039a0b174bce
Parent: 78d87c95b89ccf86c142494beada3082810ed368
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Sat May 5 14:59:23 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:52:42 2007 +0300

UBI: do not let to read too much

In case of static volumes it is prohibited to read more data
then available.

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/kapi.c |   11 ---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index d352c45..14c66b4 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -319,9 +319,14 @@ int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, 
char *buf, int offset,
offset + len  vol-usable_leb_size)
return -EINVAL;
 
-   if (vol-vol_type == UBI_STATIC_VOLUME  lnum == vol-used_ebs - 1 
-   offset + len  vol-last_eb_bytes)
-   return -EINVAL;
+   if (vol-vol_type == UBI_STATIC_VOLUME) {
+   if (vol-used_ebs == 0)
+   /* Empty static UBI volume */
+   return 0;
+   if (lnum == vol-used_ebs - 1 
+   offset + len  vol-last_eb_bytes)
+   return -EINVAL;
+   }
 
if (vol-upd_marker)
return -EBADF;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: set correct gluebi device size

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=941dfb07ed91451b1c58626a0d258dfdf468b593
Commit: 941dfb07ed91451b1c58626a0d258dfdf468b593
Parent: 4ab60a0d7c92cab16f7e470f80ea039a0b174bce
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Sat May 5 16:33:13 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:52:51 2007 +0300

UBI: set correct gluebi device size

In case of static volumes, make emulated MTD device size to
be equivalent to data size, rather then volume size.

Reported-by: John Smith [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/cdev.c   |1 +
 drivers/mtd/ubi/gluebi.c |   27 ++-
 drivers/mtd/ubi/scan.c   |2 +-
 drivers/mtd/ubi/ubi.h|2 ++
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 6612eb7..959044a 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -397,6 +397,7 @@ static ssize_t vol_cdev_write(struct file *file, const char 
__user *buf,
vol-corrupted = 1;
}
vol-checked = 1;
+   ubi_gluebi_updated(vol);
revoke_exclusive(desc, UBI_READWRITE);
}
 
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index fc9478d..41ff74c 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -282,7 +282,6 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct 
ubi_volume *vol)
mtd-flags = MTD_WRITEABLE;
mtd-writesize  = ubi-min_io_size;
mtd-owner  = THIS_MODULE;
-   mtd-size   = vol-usable_leb_size * vol-reserved_pebs;
mtd-erasesize  = vol-usable_leb_size;
mtd-read   = gluebi_read;
mtd-write  = gluebi_write;
@@ -290,6 +289,15 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct 
ubi_volume *vol)
mtd-get_device = gluebi_get_device;
mtd-put_device = gluebi_put_device;
 
+   /*
+* In case of dynamic volume, MTD device size is just volume size. In
+* case of a static volume the size is equivalent to the amount of data
+* bytes, which is zero at this moment and will be changed after volume
+* update.
+*/
+   if (vol-vol_type == UBI_DYNAMIC_VOLUME)
+   mtd-size = vol-usable_leb_size * vol-reserved_pebs;
+
if (add_mtd_device(mtd)) {
ubi_err(cannot not add MTD device\n);
kfree(mtd-name);
@@ -321,3 +329,20 @@ int ubi_destroy_gluebi(struct ubi_volume *vol)
kfree(mtd-name);
return 0;
 }
+
+/**
+ * ubi_gluebi_updated - UBI volume was updated notifier.
+ * @vol: volume description object
+ *
+ * This function is called every time an UBI volume is updated. This function
+ * does nothing if volume @vol is dynamic, and changes MTD device size if the
+ * volume is static. This is needed because static volumes cannot be read past
+ * data they contain.
+ */
+void ubi_gluebi_updated(struct ubi_volume *vol)
+{
+   struct mtd_info *mtd = vol-gluebi_mtd;
+
+   if (vol-vol_type == UBI_STATIC_VOLUME)
+   mtd-size = vol-used_bytes;
+}
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 30d536e..197cd65 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -55,7 +55,7 @@ static int paranoid_check_si(const struct ubi_device *ubi,
 static struct ubi_ec_hdr *ech;
 static struct ubi_vid_hdr *vidh;
 
-/*
+/**
  * add_to_list - add physical eraseblock to a list.
  * @si: scanning information
  * @pnum: physical eraseblock number to add
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index feb647f..c26edea 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -374,9 +374,11 @@ void ubi_calculate_reserved(struct ubi_device *ubi);
 #ifdef CONFIG_MTD_UBI_GLUEBI
 int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol);
 int ubi_destroy_gluebi(struct ubi_volume *vol);
+void ubi_gluebi_updated(struct ubi_volume *vol);
 #else
 #define ubi_create_gluebi(ubi, vol) 0
 #define ubi_destroy_gluebi(vol) 0
+#define ubi_gluebi_updated(vol)
 #endif
 
 /* eba.c */
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: add few more comments

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=79b510c0f21174f4bd055d1aab156e548ae3a5f2
Commit: 79b510c0f21174f4bd055d1aab156e548ae3a5f2
Parent: 941dfb07ed91451b1c58626a0d258dfdf468b593
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Sat May 5 17:36:17 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:53:00 2007 +0300

UBI: add few more comments

Add few comments above ubi_scan_add_used() to explain why it is so
complex. Requested by Satyam Sharma [EMAIL PROTECTED].

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/scan.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 197cd65..b24af21 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -407,8 +407,12 @@ out_free_vidh:
  * @vid_hdr: the volume identifier header
  * @bitflips: if bit-flips were detected when this physical eraseblock was read
  *
- * This function returns zero in case of success and a negative error code in
- * case of failure.
+ * This function adds information about a used physical eraseblock to the
+ * 'used' tree of the corresponding volume. The function is rather complex
+ * because it has to handle cases when this is not the first physical
+ * eraseblock belonging to the same logical eraseblock, and the newer one has
+ * to be picked, while the older one has to be dropped. This function returns
+ * zero in case of success and a negative error code in case of failure.
  */
 int ubi_scan_add_used(const struct ubi_device *ubi, struct ubi_scan_info *si,
  int pnum, int ec, const struct ubi_vid_hdr *vid_hdr,
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: use vmalloc for large buffers

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=92ad8f37509a7d9d5dd6e0092211b092a7ca7fb1
Commit: 92ad8f37509a7d9d5dd6e0092211b092a7ca7fb1
Parent: 79b510c0f21174f4bd055d1aab156e548ae3a5f2
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Sun May 6 16:12:54 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:53:08 2007 +0300

UBI: use vmalloc for large buffers

UBI allocates temporary buffers of PEB size, which may be 256KiB.
Use vmalloc instead of kmalloc for such big temporary buffers.

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/build.c |2 +-
 drivers/mtd/ubi/cdev.c  |   10 +-
 drivers/mtd/ubi/eba.c   |   22 +++---
 drivers/mtd/ubi/io.c|   11 ++-
 drivers/mtd/ubi/misc.c  |4 ++--
 drivers/mtd/ubi/scan.c  |6 +++---
 drivers/mtd/ubi/ubi.h   |1 +
 drivers/mtd/ubi/upd.c   |4 ++--
 drivers/mtd/ubi/vtbl.c  |   18 ++
 9 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 555d594..054a88d 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -650,7 +650,7 @@ static void detach_mtd_dev(struct ubi_device *ubi)
uif_close(ubi);
ubi_eba_close(ubi);
ubi_wl_close(ubi);
-   kfree(ubi-vtbl);
+   vfree(ubi-vtbl);
put_mtd_device(ubi-mtd);
kfree(ubi_devices[ubi_num]);
ubi_devices[ubi_num] = NULL;
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 959044a..34375ee 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -153,7 +153,7 @@ static int vol_cdev_release(struct inode *inode, struct 
file *file)
ubi_warn(update of volume %d not finished, volume is damaged,
 vol-vol_id);
vol-updating = 0;
-   kfree(vol-upd_buf);
+   vfree(vol-upd_buf);
}
 
ubi_close_volume(desc);
@@ -232,7 +232,7 @@ static ssize_t vol_cdev_read(struct file *file, __user char 
*buf, size_t count,
tbuf_size = vol-usable_leb_size;
if (count  tbuf_size)
tbuf_size = ALIGN(count, ubi-min_io_size);
-   tbuf = kmalloc(tbuf_size, GFP_KERNEL);
+   tbuf = vmalloc(tbuf_size);
if (!tbuf)
return -ENOMEM;
 
@@ -271,7 +271,7 @@ static ssize_t vol_cdev_read(struct file *file, __user char 
*buf, size_t count,
len = count  tbuf_size ? tbuf_size : count;
} while (count);
 
-   kfree(tbuf);
+   vfree(tbuf);
return err ? err : count_save - count;
 }
 
@@ -320,7 +320,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, 
const char __user *buf,
tbuf_size = vol-usable_leb_size;
if (count  tbuf_size)
tbuf_size = ALIGN(count, ubi-min_io_size);
-   tbuf = kmalloc(tbuf_size, GFP_KERNEL);
+   tbuf = vmalloc(tbuf_size);
if (!tbuf)
return -ENOMEM;
 
@@ -355,7 +355,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, 
const char __user *buf,
len = count  tbuf_size ? tbuf_size : count;
}
 
-   kfree(tbuf);
+   vfree(tbuf);
return err ? err : count_save - count;
 }
 
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 7c6b223..6964fe4 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -524,7 +524,7 @@ retry:
goto write_error;
 
data_size = offset + len;
-   new_buf = kmalloc(data_size, GFP_KERNEL);
+   new_buf = vmalloc(data_size);
if (!new_buf) {
err = -ENOMEM;
goto out_put;
@@ -535,7 +535,7 @@ retry:
if (offset  0) {
err = ubi_io_read_data(ubi, new_buf, pnum, 0, offset);
if (err  err != UBI_IO_BITFLIPS) {
-   kfree(new_buf);
+   vfree(new_buf);
goto out_put;
}
}
@@ -544,11 +544,11 @@ retry:
 
err = ubi_io_write_data(ubi, new_buf, new_pnum, 0, data_size);
if (err) {
-   kfree(new_buf);
+   vfree(new_buf);
goto write_error;
}
 
-   kfree(new_buf);
+   vfree(new_buf);
ubi_free_vid_hdr(ubi, vid_hdr);
 
vol-eba_tbl[lnum] = new_pnum;
@@ -977,7 +977,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int 
to,
data_size = aldata_size =
ubi-leb_size - ubi32_to_cpu(vid_hdr-data_pad);
 
-   buf = kmalloc(aldata_size, GFP_KERNEL);
+   buf = vmalloc(aldata_size);
if (!buf)
return -ENOMEM;
 
@@ -987,7 +987,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int 
to,
 */
err = leb_write_lock(ubi, vol_id, lnum);
if (err) {
-   kfree(buf);
+   vfree(buf);
 

UBI: minor comma fix

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f800f09bf44871f6c6e4d3e42a60946e1ea51b17
Commit: f800f09bf44871f6c6e4d3e42a60946e1ea51b17
Parent: 92ad8f37509a7d9d5dd6e0092211b092a7ca7fb1
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Sun May 6 16:45:43 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:53:17 2007 +0300

UBI: minor comma fix

Use coma at the the last elements of structure initializer.

Daniel Stone's explanation:

Because it turns:
-   .attr   = foo
+   .attr   = foo,
+   .bar= baz

into:
+   .bar= baz,

i.e., far less likely to screw up a merge.

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/cdev.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 34375ee..5fc9fd4 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -708,7 +708,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file 
*file,
 struct file_operations ubi_cdev_operations = {
.owner = THIS_MODULE,
.ioctl = ubi_cdev_ioctl,
-   .llseek = no_llseek
+   .llseek = no_llseek,
 };
 
 /* UBI volume character device operations */
@@ -719,5 +719,5 @@ struct file_operations ubi_vol_cdev_operations = {
.llseek  = vol_cdev_llseek,
.read= vol_cdev_read,
.write   = vol_cdev_write,
-   .ioctl   = vol_cdev_ioctl
+   .ioctl   = vol_cdev_ioctl,
 };
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: error path bugfix

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=16d8cd7ce408a20db1ab192e0fb565573e446b28
Commit: 16d8cd7ce408a20db1ab192e0fb565573e446b28
Parent: f800f09bf44871f6c6e4d3e42a60946e1ea51b17
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Wed May 16 15:49:16 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:53:27 2007 +0300

UBI: error path bugfix

No need to unlock the lock, this will be done at out_unlock.

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/vmt.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 622d0d1..4add5c8 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -243,7 +243,6 @@ int ubi_create_volume(struct ubi_device *ubi, struct 
ubi_mkvol_req *req)
/* Reserve physical eraseblocks */
if (vol-reserved_pebs  ubi-avail_pebs) {
dbg_err(not enough PEBs, only %d available, ubi-avail_pebs);
-   spin_unlock(ubi-volumes_lock);
err = -ENOSPC;
goto out_unlock;
}
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: cleanup ioctl handling

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=bf07803a6827ef8d4c9d840a1de800ba36db0213
Commit: bf07803a6827ef8d4c9d840a1de800ba36db0213
Parent: 16d8cd7ce408a20db1ab192e0fb565573e446b28
Author: Christoph Hellwig [EMAIL PROTECTED]
AuthorDate: Thu May 17 16:32:10 2007 +0200
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:53:36 2007 +0300

UBI: cleanup ioctl handling

- don't do access_ok + get/put user but use the proper macro
- remove useless checks

Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/cdev.c |   33 +
 1 files changed, 5 insertions(+), 28 deletions(-)

diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 5fc9fd4..fb238d7 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -414,19 +414,7 @@ static int vol_cdev_ioctl(struct inode *inode, struct file 
*file,
struct ubi_device *ubi = vol-ubi;
void __user *argp = (void __user *)arg;
 
-   if (_IOC_NR(cmd)  VOL_CDEV_IOC_MAX_SEQ ||
-   _IOC_TYPE(cmd) != UBI_VOL_IOC_MAGIC)
-   return -ENOTTY;
-
-   if (_IOC_DIR(cmd)  _IOC_READ)
-   err = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd));
-   else if (_IOC_DIR(cmd)  _IOC_WRITE)
-   err = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd));
-   if (err)
-   return -EFAULT;
-
switch (cmd) {
-
/* Volume update command */
case UBI_IOCVOLUP:
{
@@ -472,7 +460,7 @@ static int vol_cdev_ioctl(struct inode *inode, struct file 
*file,
{
int32_t lnum;
 
-   err = __get_user(lnum, (__user int32_t *)argp);
+   err = get_user(lnum, (__user int32_t *)argp);
if (err) {
err = -EFAULT;
break;
@@ -588,17 +576,6 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file 
*file,
struct ubi_volume_desc *desc;
void __user *argp = (void __user *)arg;
 
-   if (_IOC_NR(cmd)  UBI_CDEV_IOC_MAX_SEQ ||
-   _IOC_TYPE(cmd) != UBI_IOC_MAGIC)
-   return -ENOTTY;
-
-   if (_IOC_DIR(cmd)  _IOC_READ)
-   err = !access_ok(VERIFY_WRITE, argp, _IOC_SIZE(cmd));
-   else if (_IOC_DIR(cmd)  _IOC_WRITE)
-   err = !access_ok(VERIFY_READ, argp, _IOC_SIZE(cmd));
-   if (err)
-   return -EFAULT;
-
if (!capable(CAP_SYS_RESOURCE))
return -EPERM;
 
@@ -613,7 +590,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file 
*file,
struct ubi_mkvol_req req;
 
dbg_msg(create volume);
-   err = __copy_from_user(req, argp,
+   err = copy_from_user(req, argp,
   sizeof(struct ubi_mkvol_req));
if (err) {
err = -EFAULT;
@@ -630,7 +607,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file 
*file,
if (err)
break;
 
-   err = __put_user(req.vol_id, (__user int32_t *)argp);
+   err = put_user(req.vol_id, (__user int32_t *)argp);
if (err)
err = -EFAULT;
 
@@ -643,7 +620,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file 
*file,
int vol_id;
 
dbg_msg(remove volume);
-   err = __get_user(vol_id, (__user int32_t *)argp);
+   err = get_user(vol_id, (__user int32_t *)argp);
if (err) {
err = -EFAULT;
break;
@@ -670,7 +647,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file 
*file,
struct ubi_rsvol_req req;
 
dbg_msg(re-size volume);
-   err = __copy_from_user(req, argp,
+   err = copy_from_user(req, argp,
   sizeof(struct ubi_rsvol_req));
if (err) {
err = -EFAULT;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: bugfix in ubi_leb_change()

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a443db48e05a8d2d8db0a17409655c58da65a35e
Commit: a443db48e05a8d2d8db0a17409655c58da65a35e
Parent: 3261ebd7d4194ff30d0eae7ba8d937dcccf7235d
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Mon May 21 20:26:05 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:53:57 2007 +0300

UBI: bugfix in ubi_leb_change()

Do not call 'ubi_wl_put_peb()' if the LEB was unmapped.

Reported-by: Gabor Loki [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/eba.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index a182015..0db8dc7 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -891,11 +891,13 @@ retry:
goto write_error;
}
 
-   err = ubi_wl_put_peb(ubi, vol-eba_tbl[lnum], 1);
-   if (err) {
-   ubi_free_vid_hdr(ubi, vid_hdr);
-   leb_write_unlock(ubi, vol_id, lnum);
-   return err;
+   if (vol-eba_tbl[lnum] = 0) {
+   err = ubi_wl_put_peb(ubi, vol-eba_tbl[lnum], 1);
+   if (err) {
+   ubi_free_vid_hdr(ubi, vid_hdr);
+   leb_write_unlock(ubi, vol_id, lnum);
+   return err;
+   }
}
 
vol-eba_tbl[lnum] = pnum;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: fix MAINTAINERS

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=21600546ab84e451adb88771b52b64b97866a444
Commit: 21600546ab84e451adb88771b52b64b97866a444
Parent: a443db48e05a8d2d8db0a17409655c58da65a35e
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Tue May 22 12:23:21 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:54:06 2007 +0300

UBI: fix MAINTAINERS

Fix UBI git tree URL.

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 MAINTAINERS |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 368a718..210abd7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2393,7 +2393,7 @@ P:Artem Bityutskiy
 M: [EMAIL PROTECTED]
 W: http://www.linux-mtd.infradead.org/
 L: [EMAIL PROTECTED]
-T: git git://git.infradead.org/ubi-2.6.git
+T: git git://git.infradead.org/~dedekind/ubi-2.6.git
 S: Maintained
 
 MICROTEK X6 SCANNER
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: fix freeing ubi-vtbl while unloading

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d7f0c4dc31f1297a613f1e61a7d682dc9a5e859a
Commit: d7f0c4dc31f1297a613f1e61a7d682dc9a5e859a
Parent: 21600546ab84e451adb88771b52b64b97866a444
Author: Vinit Agnihotri [EMAIL PROTECTED]
AuthorDate: Fri Jun 15 15:31:22 2007 +0530
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:54:15 2007 +0300

UBI: fix freeing ubi-vtbl while unloading

ubi-vtbl is allocated using vmalloc() in vtbl.c empty_create_lvol(),
but it is freed in build.c with kfree()

Signed-off-by: Vinit Agnihotri [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/build.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 054a88d..08ca214 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -369,7 +369,7 @@ static int attach_by_scanning(struct ubi_device *ubi)
 out_wl:
ubi_wl_close(ubi);
 out_vtbl:
-   kfree(ubi-vtbl);
+   vfree(ubi-vtbl);
 out_si:
ubi_scan_destroy_si(si);
return err;
@@ -629,7 +629,7 @@ static int attach_mtd_dev(const char *mtd_dev, int 
vid_hdr_offset,
 out_detach:
ubi_eba_close(ubi);
ubi_wl_close(ubi);
-   kfree(ubi-vtbl);
+   vfree(ubi-vtbl);
 out_free:
kfree(ubi);
 out_mtd:
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: use is_power_of_2()

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=7753f1692f53d82b4cc08084462b0fd2803c1f04
Commit: 7753f1692f53d82b4cc08084462b0fd2803c1f04
Parent: d7f0c4dc31f1297a613f1e61a7d682dc9a5e859a
Author: Vignesh Babu [EMAIL PROTECTED]
AuthorDate: Tue Jun 12 10:31:05 2007 +0530
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:55:26 2007 +0300

UBI: use is_power_of_2()

Replacing (n  (n-1)) in the context of power of 2 checks
with is_power_of_2

Signed-off-by: Vignesh Babu [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/build.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 08ca214..eb8b55d 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -33,6 +33,7 @@
 #include linux/moduleparam.h
 #include linux/stringify.h
 #include linux/stat.h
+#include linux/log2.h
 #include ubi.h
 
 /* Maximum length of the 'mtd=' parameter */
@@ -422,8 +423,7 @@ static int io_init(struct ubi_device *ubi)
ubi-hdrs_min_io_size = ubi-mtd-writesize  ubi-mtd-subpage_sft;
 
/* Make sure minimal I/O unit is power of 2 */
-   if (ubi-min_io_size == 0 ||
-   (ubi-min_io_size  (ubi-min_io_size - 1))) {
+   if (!is_power_of_2(ubi-min_io_size)) {
ubi_err(bad min. I/O unit);
return -EINVAL;
}
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: fix debugging stuff

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b89044bfa06e8a9a82094fda031cc6d4e8d4a0b0
Commit: b89044bfa06e8a9a82094fda031cc6d4e8d4a0b0
Parent: 94784d916458d51043ba76849b9beaf330baef2f
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Mon Jun 18 16:29:30 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:56:05 2007 +0300

UBI: fix debugging stuff

Do not check volumes which are currently in use because thay may be
in inconsistent state.

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/vmt.c |   20 
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index a0c6e1e..d62dac9 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -644,21 +644,33 @@ void ubi_free_volume(struct ubi_device *ubi, int vol_id)
  * @ubi: UBI device description object
  * @vol_id: volume ID
  */
-static void paranoid_check_volume(const struct ubi_device *ubi, int vol_id)
+static void paranoid_check_volume(struct ubi_device *ubi, int vol_id)
 {
int idx = vol_id2idx(ubi, vol_id);
int reserved_pebs, alignment, data_pad, vol_type, name_len, upd_marker;
-   const struct ubi_volume *vol = ubi-volumes[idx];
+   const struct ubi_volume *vol;
long long n;
const char *name;
 
+   spin_lock(ubi-volumes_lock);
reserved_pebs = be32_to_cpu(ubi-vtbl[vol_id].reserved_pebs);
+   vol = ubi-volumes[idx];
 
if (!vol) {
if (reserved_pebs) {
ubi_err(no volume info, but volume exists);
goto fail;
}
+   spin_unlock(ubi-volumes_lock);
+   return;
+   }
+
+   if (vol-exclusive) {
+   /*
+* The volume may be being created at the moment, do not check
+* it (e.g., it may be in the middle of ubi_create_volume().
+*/
+   spin_unlock(ubi-volumes_lock);
return;
}
 
@@ -783,12 +795,14 @@ static void paranoid_check_volume(const struct ubi_device 
*ubi, int vol_id)
goto fail;
}
 
+   spin_unlock(ubi-volumes_lock);
return;
 
 fail:
ubi_err(paranoid check failed for volume %d, vol_id);
ubi_dbg_dump_vol_info(vol);
ubi_dbg_dump_vtbl_record(ubi-vtbl[vol_id], vol_id);
+   spin_unlock(ubi-volumes_lock);
BUG();
 }
 
@@ -801,10 +815,8 @@ static void paranoid_check_volumes(struct ubi_device *ubi)
int i;
 
mutex_lock(ubi-vtbl_mutex);
-   spin_lock(ubi-volumes_lock);
for (i = 0; i  ubi-vtbl_slots; i++)
paranoid_check_volume(ubi, i);
-   spin_unlock(ubi-volumes_lock);
mutex_unlock(ubi-vtbl_mutex);
 }
 #endif
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: bugfix in sqnum calculation

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=76eafe479ec30dd72b8cf209c4f576eac3c93112
Commit: 76eafe479ec30dd72b8cf209c4f576eac3c93112
Parent: 2f176f79877937082ce052977e552a75e23a73d1
Author: Brijesh Singh [EMAIL PROTECTED]
AuthorDate: Fri Jul 6 14:35:43 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:57:52 2007 +0300

UBI: bugfix in sqnum calculation

Hi,I came across problem of having two leb with same sequence no.This
happens when we continuously write one block again and again and reboot
machine before background thread erases those blocks.
The problem here was,when we find two blocks with same sequence no,we take
the higher one,but we were not updating max seq no,so next block may have
the same seqnum.
This patch solves this problem.

Signed-off-by: Brijesh Singh [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/scan.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 23e30ac..ce26b1b 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -437,6 +437,9 @@ int ubi_scan_add_used(const struct ubi_device *ubi, struct 
ubi_scan_info *si,
if (IS_ERR(sv)  0)
return PTR_ERR(sv);
 
+   if (si-max_sqnum  sqnum)
+   si-max_sqnum = sqnum;
+
/*
 * Walk the RB-tree of logical eraseblocks of volume @vol_id to look
 * if this is the first instance of this logical eraseblock or not.
@@ -563,9 +566,6 @@ int ubi_scan_add_used(const struct ubi_device *ubi, struct 
ubi_scan_info *si,
sv-last_data_size = be32_to_cpu(vid_hdr-data_size);
}
 
-   if (si-max_sqnum  sqnum)
-   si-max_sqnum = sqnum;
-
sv-leb_count += 1;
rb_link_node(seb-u.rb, parent, p);
rb_insert_color(seb-u.rb, sv-root);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: bugfix in max_sqnum calculation

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2f3cdb55eef4fa1398965e893f731fb6e6312d34
Commit: 2f3cdb55eef4fa1398965e893f731fb6e6312d34
Parent: 76eafe479ec30dd72b8cf209c4f576eac3c93112
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Fri Jul 6 14:38:46 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:58:02 2007 +0300

UBI: bugfix in max_sqnum calculation

Do not zero max_sqnum after a new volume has been found.

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/scan.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index ce26b1b..94ee549 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -222,7 +222,6 @@ static struct ubi_scan_volume *add_volume(struct 
ubi_scan_info *si, int vol_id,
return ERR_PTR(-ENOMEM);
 
sv-highest_lnum = sv-leb_count = 0;
-   si-max_sqnum = 0;
sv-vol_id = vol_id;
sv-root = RB_ROOT;
sv-used_ebs = be32_to_cpu(vid_hdr-used_ebs);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: fix overflow bug

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d08c3b78b8c46a01b8fa59037a0d9fbb777fb465
Commit: d08c3b78b8c46a01b8fa59037a0d9fbb777fb465
Parent: 2f3cdb55eef4fa1398965e893f731fb6e6312d34
Author: Vinit Agnihotri [EMAIL PROTECTED]
AuthorDate: Tue Jul 10 13:04:59 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:58:12 2007 +0300

UBI: fix overflow bug

I was experiencing overflows in multiplications for
volume-used_bytes in vmt.c  vtbl.c, while creating  resizing large 
volumes.

vol-used_bytes is long long however its 2 operands vol-used_ebs 
vol-usable_leb_size
are int. So their multiplication for larger values causes integer overflows.
Typecasting them solves the problem.

My machine  flash details:

64Bit dual-core AMD opteron, 1 GB RAM, linux 2.6.18.3.
mtd size = 6GB, volume size= 5GB, peb_size = 4MB.

heres patch which does the fix.

Signed-off-by: Vinit Agnihotri [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/vmt.c  |8 +---
 drivers/mtd/ubi/vtbl.c |9 ++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index d62dac9..ea0d5c8 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -280,7 +280,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct 
ubi_mkvol_req *req)
if (vol-vol_type == UBI_DYNAMIC_VOLUME) {
vol-used_ebs = vol-reserved_pebs;
vol-last_eb_bytes = vol-usable_leb_size;
-   vol-used_bytes = vol-used_ebs * vol-usable_leb_size;
+   vol-used_bytes =
+   (long long)vol-used_ebs * vol-usable_leb_size;
} else {
bytes = vol-used_bytes;
vol-last_eb_bytes = do_div(bytes, vol-usable_leb_size);
@@ -538,7 +539,8 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int 
reserved_pebs)
if (vol-vol_type == UBI_DYNAMIC_VOLUME) {
vol-used_ebs = reserved_pebs;
vol-last_eb_bytes = vol-usable_leb_size;
-   vol-used_bytes = vol-used_ebs * vol-usable_leb_size;
+   vol-used_bytes =
+   (long long)vol-used_ebs * vol-usable_leb_size;
}
 
paranoid_check_volumes(ubi);
@@ -739,7 +741,7 @@ static void paranoid_check_volume(struct ubi_device *ubi, 
int vol_id)
goto fail;
}
 
-   n = vol-used_ebs * vol-usable_leb_size;
+   n = (long long)vol-used_ebs * vol-usable_leb_size;
if (vol-vol_type == UBI_DYNAMIC_VOLUME) {
if (vol-corrupted != 0) {
ubi_err(corrupted dynamic volume);
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 1f48c76..bc5df50 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -531,7 +531,8 @@ static int init_volumes(struct ubi_device *ubi, const 
struct ubi_scan_info *si,
if (vol-vol_type == UBI_DYNAMIC_VOLUME) {
vol-used_ebs = vol-reserved_pebs;
vol-last_eb_bytes = vol-usable_leb_size;
-   vol-used_bytes = vol-used_ebs * vol-usable_leb_size;
+   vol-used_bytes =
+   (long long)vol-used_ebs * vol-usable_leb_size;
continue;
}
 
@@ -561,7 +562,8 @@ static int init_volumes(struct ubi_device *ubi, const 
struct ubi_scan_info *si,
}
 
vol-used_ebs = sv-used_ebs;
-   vol-used_bytes = (vol-used_ebs - 1) * vol-usable_leb_size;
+   vol-used_bytes =
+   (long long)(vol-used_ebs - 1) * vol-usable_leb_size;
vol-used_bytes += sv-last_data_size;
vol-last_eb_bytes = sv-last_data_size;
}
@@ -578,7 +580,8 @@ static int init_volumes(struct ubi_device *ubi, const 
struct ubi_scan_info *si,
vol-usable_leb_size = ubi-leb_size;
vol-used_ebs = vol-reserved_pebs;
vol-last_eb_bytes = vol-reserved_pebs;
-   vol-used_bytes = vol-used_ebs * (ubi-leb_size - vol-data_pad);
+   vol-used_bytes =
+   (long long)vol-used_ebs * (ubi-leb_size - vol-data_pad);
vol-vol_id = UBI_LAYOUT_VOL_ID;
 
ubi_assert(!ubi-volumes[i]);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: cleanup usage of try_module_get

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2db61c95c03d08bb885c87a816540e75190c924a
Commit: 2db61c95c03d08bb885c87a816540e75190c924a
Parent: d08c3b78b8c46a01b8fa59037a0d9fbb777fb465
Author: Fernando Luis Vázquez Cao [EMAIL PROTECTED]
AuthorDate: Wed Jul 11 17:11:45 2007 +0900
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:58:45 2007 +0300

UBI: cleanup usage of try_module_get

The use of try_module_get(THIS_MODULE) in ubi_get_device_info does not
offer real protection against unexpected driver unloads, since we could
be preempted before try_modules_get gets executed. It is the caller who
should manipulate the refcounts. Besides, ubi_get_device_info is an
exported symbol which guarantees protection when accessed through
symbol_get.

Signed-off-by: Fernando Luis Vazquez Cao [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/kapi.c |5 -
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 14c66b4..78cae49 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -37,12 +37,8 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info 
*di)
 {
const struct ubi_device *ubi;
 
-   if (!try_module_get(THIS_MODULE))
-   return -ENODEV;
-
if (ubi_num  0 || ubi_num = UBI_MAX_DEVICES ||
!ubi_devices[ubi_num]) {
-   module_put(THIS_MODULE);
return -ENODEV;
}
 
@@ -52,7 +48,6 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info 
*di)
di-min_io_size = ubi-min_io_size;
di-ro_mode = ubi-ro_mode;
di-cdev = MKDEV(ubi-major, 0);
-   module_put(THIS_MODULE);
return 0;
 }
 EXPORT_SYMBOL_GPL(ubi_get_device_info);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: remove unneeded error checks

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=503990ebb21e5aabe497a3eb1d39bef0bbc1be6f
Commit: 503990ebb21e5aabe497a3eb1d39bef0bbc1be6f
Parent: 2db61c95c03d08bb885c87a816540e75190c924a
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Wed Jul 11 16:03:29 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:58:53 2007 +0300

UBI: remove unneeded error checks

Pointed to by viro.

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/build.c |   12 +---
 drivers/mtd/ubi/kapi.c  |3 +--
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 336482a..1cb22bf 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -685,13 +685,6 @@ static int __init ubi_init(void)
struct mtd_dev_param *p = mtd_dev_param[i];
 
cond_resched();
-
-   if (!p-name) {
-   dbg_err(empty name);
-   err = -EINVAL;
-   goto out_detach;
-   }
-
err = attach_mtd_dev(p-name, p-vid_hdr_offs, p-data_offs);
if (err)
goto out_detach;
@@ -798,7 +791,7 @@ static int __init ubi_mtd_param_parse(const char *val, 
struct kernel_param *kp)
 
/* Get rid of the final newline */
if (buf[len - 1] == '\n')
-   buf[len - 1] = 0;
+   buf[len - 1] = '\0';
 
for (i = 0; i  3; i++)
tokens[i] = strsep(pbuf, ,);
@@ -808,9 +801,6 @@ static int __init ubi_mtd_param_parse(const char *val, 
struct kernel_param *kp)
return -EINVAL;
}
 
-   if (tokens[0] == '\0')
-   return -EINVAL;
-
p = mtd_dev_param[mtd_devs];
strcpy(p-name[0], tokens[0]);
 
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 78cae49..4a458e8 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -38,9 +38,8 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info 
*di)
const struct ubi_device *ubi;
 
if (ubi_num  0 || ubi_num = UBI_MAX_DEVICES ||
-   !ubi_devices[ubi_num]) {
+   !ubi_devices[ubi_num])
return -ENODEV;
-   }
 
ubi = ubi_devices[ubi_num];
di-ubi_num = ubi-ubi_num;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: fix comments

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=63b6c1ed56f69fdd35122dc591164587e3407ba0
Commit: 63b6c1ed56f69fdd35122dc591164587e3407ba0
Parent: 503990ebb21e5aabe497a3eb1d39bef0bbc1be6f
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 15:04:20 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:59:01 2007 +0300

UBI: fix comments

Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/io.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 81008ab..b0d8f4c 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -125,9 +125,9 @@ static int paranoid_check_all_ff(const struct ubi_device 
*ubi, int pnum,
  * o %UBI_IO_BITFLIPS if all the requested data were successfully read, but
  *   correctable bit-flips were detected; this is harmless but may indicate
  *   that this eraseblock may become bad soon (but do not have to);
- * o %-EBADMSG if the MTD subsystem reported about data data integrity
- *   problems, for example it can me an ECC error in case of NAND; this most
- *   probably means that the data is corrupted;
+ * o %-EBADMSG if the MTD subsystem reported about data integrity problems, for
+ *   example it can be an ECC error in case of NAND; this most probably means
+ *   that the data is corrupted;
  * o %-EIO if some I/O error occurred;
  * o other negative error codes in case of other errors.
  */
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UBI: fix error handling in erase worker

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=784c145444e7dd58ae740d406155b72ac658f151
Commit: 784c145444e7dd58ae740d406155b72ac658f151
Parent: 63b6c1ed56f69fdd35122dc591164587e3407ba0
Author: Artem Bityutskiy [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 13:42:10 2007 +0300
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:59:09 2007 +0300

UBI: fix error handling in erase worker

Do not switch to read-only mode in case of -EINTR and some
other obvious cases. Switch to RO mode only when we do not
know what is the error.

Reported-by: Vinit Agnihotri [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/wl.c |   89 +++---
 1 files changed, 48 insertions(+), 41 deletions(-)

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index d512cf1..9de9537 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1060,9 +1060,8 @@ out_unlock:
 static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
int cancel)
 {
-   int err;
struct ubi_wl_entry *e = wl_wrk-e;
-   int pnum = e-pnum;
+   int pnum = e-pnum, err, need;
 
if (cancel) {
dbg_wl(cancel erasure of PEB %d EC %d, pnum, e-ec);
@@ -1097,62 +1096,70 @@ static int erase_worker(struct ubi_device *ubi, struct 
ubi_work *wl_wrk,
kfree(wl_wrk);
kmem_cache_free(wl_entries_slab, e);
 
-   if (err != -EIO) {
+   if (err == -EINTR || err == -ENOMEM || err == -EAGAIN ||
+   err == -EBUSY) {
+   int err1;
+
+   /* Re-schedule the LEB for erasure */
+   err1 = schedule_erase(ubi, e, 0);
+   if (err1) {
+   err = err1;
+   goto out_ro;
+   }
+   return err;
+   } else if (err != -EIO) {
/*
 * If this is not %-EIO, we have no idea what to do. Scheduling
 * this physical eraseblock for erasure again would cause
 * errors again and again. Well, lets switch to RO mode.
 */
-   ubi_ro_mode(ubi);
-   return err;
+   goto out_ro;
}
 
/* It is %-EIO, the PEB went bad */
 
if (!ubi-bad_allowed) {
ubi_err(bad physical eraseblock %d detected, pnum);
-   ubi_ro_mode(ubi);
-   err = -EIO;
-   } else {
-   int need;
-
-   spin_lock(ubi-volumes_lock);
-   need = ubi-beb_rsvd_level - ubi-beb_rsvd_pebs + 1;
-   if (need  0) {
-   need = ubi-avail_pebs = need ? need : ubi-avail_pebs;
-   ubi-avail_pebs -= need;
-   ubi-rsvd_pebs += need;
-   ubi-beb_rsvd_pebs += need;
-   if (need  0)
-   ubi_msg(reserve more %d PEBs, need);
-   }
+   goto out_ro;
+   }
 
-   if (ubi-beb_rsvd_pebs == 0) {
-   spin_unlock(ubi-volumes_lock);
-   ubi_err(no reserved physical eraseblocks);
-   ubi_ro_mode(ubi);
-   return -EIO;
-   }
+   spin_lock(ubi-volumes_lock);
+   need = ubi-beb_rsvd_level - ubi-beb_rsvd_pebs + 1;
+   if (need  0) {
+   need = ubi-avail_pebs = need ? need : ubi-avail_pebs;
+   ubi-avail_pebs -= need;
+   ubi-rsvd_pebs += need;
+   ubi-beb_rsvd_pebs += need;
+   if (need  0)
+   ubi_msg(reserve more %d PEBs, need);
+   }
 
+   if (ubi-beb_rsvd_pebs == 0) {
spin_unlock(ubi-volumes_lock);
-   ubi_msg(mark PEB %d as bad, pnum);
+   ubi_err(no reserved physical eraseblocks);
+   goto out_ro;
+   }
 
-   err = ubi_io_mark_bad(ubi, pnum);
-   if (err) {
-   ubi_ro_mode(ubi);
-   return err;
-   }
+   spin_unlock(ubi-volumes_lock);
+   ubi_msg(mark PEB %d as bad, pnum);
 
-   spin_lock(ubi-volumes_lock);
-   ubi-beb_rsvd_pebs -= 1;
-   ubi-bad_peb_count += 1;
-   ubi-good_peb_count -= 1;
-   ubi_calculate_reserved(ubi);
-   if (ubi-beb_rsvd_pebs == 0)
-   ubi_warn(last PEB from the reserved pool was used);
-   spin_unlock(ubi-volumes_lock);
-   }
+   err = ubi_io_mark_bad(ubi, pnum);
+   if (err)
+   goto out_ro;
+
+   spin_lock(ubi-volumes_lock);
+   ubi-beb_rsvd_pebs -= 1;
+   ubi-bad_peb_count += 1;
+   ubi-good_peb_count -= 1;
+   ubi_calculate_reserved(ubi);
+   if (ubi-beb_rsvd_pebs == 0)
+  

UBI: fix compile warning

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=add0b43ca67bf281ef7ac8ab47e9ee7b2d97a69f
Commit: add0b43ca67bf281ef7ac8ab47e9ee7b2d97a69f
Parent: 784c145444e7dd58ae740d406155b72ac658f151
Author: Paul Mundt [EMAIL PROTECTED]
AuthorDate: Wed Jul 18 18:39:45 2007 +0900
Committer:  Artem Bityutskiy [EMAIL PROTECTED]
CommitDate: Wed Jul 18 16:59:17 2007 +0300

UBI: fix compile warning

cdev.c whines in current git:

drivers/mtd/ubi/cdev.c: In function `major_to_device':
drivers/mtd/ubi/cdev.c:67: warning: control reaches end of non-void function

Shut it up.

Signed-off-by: Paul Mundt [EMAIL PROTECTED]
Signed-off-by: Artem Bityutskiy [EMAIL PROTECTED]
---
 drivers/mtd/ubi/cdev.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index fb238d7..fe4da1e 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -64,6 +64,7 @@ static struct ubi_device *major_to_device(int major)
if (ubi_devices[i]  ubi_devices[i]-major == major)
return ubi_devices[i];
BUG();
+   return NULL;
 }
 
 /**
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


sys_fallocate() implementation on i386, x86_64 and powerpc

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=97ac73506c0ba93f30239bb57b4cfc5d73e68a62
Commit: 97ac73506c0ba93f30239bb57b4cfc5d73e68a62
Parent: cb32da0416b823b7f4b65e7e85d6cba16ca4d1e1
Author: Amit Arora [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 21:42:44 2007 -0400
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Tue Jul 17 21:42:44 2007 -0400

sys_fallocate() implementation on i386, x86_64 and powerpc

fallocate() is a new system call being proposed here which will allow
applications to preallocate space to any file(s) in a file system.
Each file system implementation that wants to use this feature will need
to support an inode operation called -fallocate().
Applications can use this feature to avoid fragmentation to certain
level and thus get faster access speed. With preallocation, applications
also get a guarantee of space for particular file(s) - even if later the
the system becomes full.

Currently, glibc provides an interface called posix_fallocate() which
can be used for similar cause. Though this has the advantage of working
on all file systems, but it is quite slow (since it writes zeroes to
each block that has to be preallocated). Without a doubt, file systems
can do this more efficiently within the kernel, by implementing
the proposed fallocate() system call. It is expected that
posix_fallocate() will be modified to call this new system call first
and incase the kernel/filesystem does not implement it, it should fall
back to the current implementation of writing zeroes to the new blocks.
ToDos:
1. Implementation on other architectures (other than i386, x86_64,
   and ppc). Patches for s390(x) and ia64 are already available from
   previous posts, but it was decided that they should be added later
   once fallocate is in the mainline. Hence not including those patches
   in this take.
2. Changes to glibc,
   a) to support fallocate() system call
   b) to make posix_fallocate() and posix_fallocate64() call fallocate()

Signed-off-by: Amit Arora [EMAIL PROTECTED]
---
 arch/i386/kernel/syscall_table.S |1 +
 arch/powerpc/kernel/sys_ppc32.c  |7 
 arch/x86_64/ia32/ia32entry.S |1 +
 arch/x86_64/ia32/sys_ia32.c  |8 +
 fs/open.c|   59 ++
 include/asm-i386/unistd.h|3 +-
 include/asm-powerpc/systbl.h |1 +
 include/asm-powerpc/unistd.h |3 +-
 include/asm-x86_64/unistd.h  |2 +
 include/linux/falloc.h   |6 
 include/linux/fs.h   |2 +
 include/linux/syscalls.h |1 +
 12 files changed, 92 insertions(+), 2 deletions(-)

diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
index bf6adce..8344c70 100644
--- a/arch/i386/kernel/syscall_table.S
+++ b/arch/i386/kernel/syscall_table.S
@@ -323,3 +323,4 @@ ENTRY(sys_call_table)
.long sys_signalfd
.long sys_timerfd
.long sys_eventfd
+   .long sys_fallocate
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index b42cbf1..bd85b5f 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -773,6 +773,13 @@ asmlinkage int compat_sys_truncate64(const char __user * 
path, u32 reg4,
return sys_truncate(path, (high  32) | low);
 }
 
+asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
+u32 lenhi, u32 lenlo)
+{
+   return sys_fallocate(fd, mode, ((loff_t)offhi  32) | offlo,
+((loff_t)lenhi  32) | lenlo);
+}
+
 asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long 
high,
 unsigned long low)
 {
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index 782dea8..3f66e97 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -719,4 +719,5 @@ ia32_sys_call_table:
.quad compat_sys_signalfd
.quad compat_sys_timerfd
.quad sys_eventfd
+   .quad sys32_fallocate
 ia32_syscall_end:
diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
index 99a78a3..bee96d6 100644
--- a/arch/x86_64/ia32/sys_ia32.c
+++ b/arch/x86_64/ia32/sys_ia32.c
@@ -879,3 +879,11 @@ asmlinkage long sys32_fadvise64(int fd, unsigned 
offset_lo, unsigned offset_hi,
return sys_fadvise64_64(fd, ((u64)offset_hi  32) | offset_lo,
len, advice);
 }
+
+asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
+   unsigned offset_hi, unsigned len_lo,
+   unsigned len_hi)
+{
+   return sys_fallocate(fd, mode, ((u64)offset_hi  32) | offset_lo,
+((u64)len_hi  32) | len_lo);
+}
diff --git 

fallocate support in ext4

2007-07-18 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a2df2a63407803a833f82e1fa6693826c8c9d584
Commit: a2df2a63407803a833f82e1fa6693826c8c9d584
Parent: 97ac73506c0ba93f30239bb57b4cfc5d73e68a62
Author: Amit Arora [EMAIL PROTECTED]
AuthorDate: Tue Jul 17 21:42:41 2007 -0400
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Tue Jul 17 21:42:41 2007 -0400

fallocate support in ext4

This patch implements -fallocate() inode operation in ext4. With this
patch users of ext4 file systems will be able to use fallocate() system
call for persistent preallocation. Current implementation only supports
preallocation for regular files (directories not supported as of date)
with extent maps. This patch does not support block-mapped files currently.
Only FALLOC_ALLOCATE and FALLOC_RESV_SPACE modes are being supported as of
now.

Signed-off-by: Amit Arora [EMAIL PROTECTED]
---
 fs/ext4/extents.c   |  249 ---
 fs/ext4/file.c  |1 +
 include/linux/ext4_fs.h |8 ++
 include/linux/ext4_fs_extents.h |   15 +++
 4 files changed, 232 insertions(+), 41 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index b9ce241..ba25832 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -39,6 +39,7 @@
 #include linux/quotaops.h
 #include linux/string.h
 #include linux/slab.h
+#include linux/falloc.h
 #include linux/ext4_fs_extents.h
 #include asm/uaccess.h
 
@@ -282,7 +283,7 @@ static void ext4_ext_show_path(struct inode *inode, struct 
ext4_ext_path *path)
} else if (path-p_ext) {
ext_debug(  %d:%d:%llu ,
  le32_to_cpu(path-p_ext-ee_block),
- le16_to_cpu(path-p_ext-ee_len),
+ ext4_ext_get_actual_len(path-p_ext),
  ext_pblock(path-p_ext));
} else
ext_debug(  []);
@@ -305,7 +306,7 @@ static void ext4_ext_show_leaf(struct inode *inode, struct 
ext4_ext_path *path)
 
for (i = 0; i  le16_to_cpu(eh-eh_entries); i++, ex++) {
ext_debug(%d:%d:%llu , le32_to_cpu(ex-ee_block),
- le16_to_cpu(ex-ee_len), ext_pblock(ex));
+ ext4_ext_get_actual_len(ex), ext_pblock(ex));
}
ext_debug(\n);
 }
@@ -425,7 +426,7 @@ ext4_ext_binsearch(struct inode *inode, struct 
ext4_ext_path *path, int block)
ext_debug(  - %d:%llu:%d ,
le32_to_cpu(path-p_ext-ee_block),
ext_pblock(path-p_ext),
-   le16_to_cpu(path-p_ext-ee_len));
+   ext4_ext_get_actual_len(path-p_ext));
 
 #ifdef CHECK_BINSEARCH
{
@@ -686,7 +687,7 @@ static int ext4_ext_split(handle_t *handle, struct inode 
*inode,
ext_debug(move %d:%llu:%d in new leaf %llu\n,
le32_to_cpu(path[depth].p_ext-ee_block),
ext_pblock(path[depth].p_ext),
-   le16_to_cpu(path[depth].p_ext-ee_len),
+   ext4_ext_get_actual_len(path[depth].p_ext),
newblock);
/*memmove(ex++, path[depth].p_ext++,
sizeof(struct ext4_extent));
@@ -1106,7 +1107,19 @@ static int
 ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
struct ext4_extent *ex2)
 {
-   if (le32_to_cpu(ex1-ee_block) + le16_to_cpu(ex1-ee_len) !=
+   unsigned short ext1_ee_len, ext2_ee_len;
+
+   /*
+* Make sure that either both extents are uninitialized, or
+* both are _not_.
+*/
+   if (ext4_ext_is_uninitialized(ex1) ^ ext4_ext_is_uninitialized(ex2))
+   return 0;
+
+   ext1_ee_len = ext4_ext_get_actual_len(ex1);
+   ext2_ee_len = ext4_ext_get_actual_len(ex2);
+
+   if (le32_to_cpu(ex1-ee_block) + ext1_ee_len !=
le32_to_cpu(ex2-ee_block))
return 0;
 
@@ -1115,14 +1128,14 @@ ext4_can_extents_be_merged(struct inode *inode, struct 
ext4_extent *ex1,
 * as an RO_COMPAT feature, refuse to merge to extents if
 * this can result in the top bit of ee_len being set.
 */
-   if (le16_to_cpu(ex1-ee_len) + le16_to_cpu(ex2-ee_len)  EXT_MAX_LEN)
+   if (ext1_ee_len + ext2_ee_len  EXT_MAX_LEN)
return 0;
 #ifdef AGGRESSIVE_TEST
if (le16_to_cpu(ex1-ee_len) = 4)
return 0;
 #endif
 
-   if (ext_pblock(ex1) + le16_to_cpu(ex1-ee_len) == ext_pblock(ex2))
+   if (ext_pblock(ex1) + ext1_ee_len == ext_pblock(ex2))
return 1;
return 0;
 }
@@ -1144,7 +1157,7 @@ unsigned int ext4_ext_check_overlap(struct inode *inode,
unsigned int ret = 0;
 

  1   2   3   4   >