[GIT PULL] s390 patches for the 3.8 merge window #2

2012-12-18 Thread Martin Schwidefsky
Hi Linus,

please pull from the 'for-linus' branch of

git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git for-linus

to receive the following updates:
The main patch is the function measurement blocks extension for PCI to do
performance statistics and help with debugging. The other patch is a small
cleanup in ccwdev.h.

Cornelia Huck (1):
  s390/ccwdev: Include asm/schid.h.

Jan Glauber (1):
  s390/pci: performance statistics and debug infrastructure

 arch/s390/include/asm/ccwdev.h|4 +-
 arch/s390/include/asm/pci.h   |   39 
 arch/s390/include/asm/pci_debug.h |   36 +++
 arch/s390/pci/Makefile|2 +-
 arch/s390/pci/pci.c   |   73 +-
 arch/s390/pci/pci_clp.c   |1 +
 arch/s390/pci/pci_debug.c |  193 +
 arch/s390/pci/pci_dma.c   |8 +-
 arch/s390/pci/pci_event.c |2 +
 9 files changed, 350 insertions(+), 8 deletions(-)
 create mode 100644 arch/s390/include/asm/pci_debug.h
 create mode 100644 arch/s390/pci/pci_debug.c

diff --git a/arch/s390/include/asm/ccwdev.h b/arch/s390/include/asm/ccwdev.h
index 6d1f357..e606161 100644
--- a/arch/s390/include/asm/ccwdev.h
+++ b/arch/s390/include/asm/ccwdev.h
@@ -12,15 +12,13 @@
 #include 
 #include 
 #include 
+#include 
 
 /* structs from asm/cio.h */
 struct irb;
 struct ccw1;
 struct ccw_dev_id;
 
-/* from asm/schid.h */
-struct subchannel_id;
-
 /* simplified initializers for struct ccw_device:
  * CCW_DEVICE and CCW_DEVICE_DEVTYPE initialize one
  * entry in your MODULE_DEVICE_TABLE and set the match_flag correctly */
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index a6175ad..b1fa93c 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define PCIBIOS_MIN_IO 0x1000
 #define PCIBIOS_MIN_MEM0x1000
@@ -33,6 +34,25 @@ int pci_proc_domain(struct pci_bus *);
 #define ZPCI_FC_BLOCKED0x20
 #define ZPCI_FC_DMA_ENABLED0x10
 
+struct zpci_fmb {
+   u32 format  :  8;
+   u32 dma_valid   :  1;
+   u32 : 23;
+   u32 samples;
+   u64 last_update;
+   /* hardware counters */
+   u64 ld_ops;
+   u64 st_ops;
+   u64 stb_ops;
+   u64 rpcit_ops;
+   u64 dma_rbytes;
+   u64 dma_wbytes;
+   /* software counters */
+   atomic64_t allocated_pages;
+   atomic64_t mapped_pages;
+   atomic64_t unmapped_pages;
+} __packed __aligned(16);
+
 struct msi_map {
unsigned long irq;
struct msi_desc *msi;
@@ -92,7 +112,15 @@ struct zpci_dev {
u64 end_dma;/* End of available DMA addresses */
u64 dma_mask;   /* DMA address space mask */
 
+   /* Function measurement block */
+   struct zpci_fmb *fmb;
+   u16 fmb_update; /* update interval */
+
enum pci_bus_speed max_bus_speed;
+
+   struct dentry   *debugfs_dev;
+   struct dentry   *debugfs_perf;
+   struct dentry   *debugfs_debug;
 };
 
 struct pci_hp_callback_ops {
@@ -155,4 +183,15 @@ extern struct list_head zpci_list;
 extern struct pci_hp_callback_ops hotplug_ops;
 extern unsigned int pci_probe;
 
+/* FMB */
+int zpci_fmb_enable_device(struct zpci_dev *);
+int zpci_fmb_disable_device(struct zpci_dev *);
+
+/* Debug */
+int zpci_debug_init(void);
+void zpci_debug_exit(void);
+void zpci_debug_init_device(struct zpci_dev *);
+void zpci_debug_exit_device(struct zpci_dev *);
+void zpci_debug_info(struct zpci_dev *, struct seq_file *);
+
 #endif
diff --git a/arch/s390/include/asm/pci_debug.h 
b/arch/s390/include/asm/pci_debug.h
new file mode 100644
index 000..6bbec42
--- /dev/null
+++ b/arch/s390/include/asm/pci_debug.h
@@ -0,0 +1,36 @@
+#ifndef _S390_ASM_PCI_DEBUG_H
+#define _S390_ASM_PCI_DEBUG_H
+
+#include 
+
+extern debug_info_t *pci_debug_msg_id;
+extern debug_info_t *pci_debug_err_id;
+
+#ifdef CONFIG_PCI_DEBUG
+#define zpci_dbg(fmt, args...) 
\
+   do {
\
+   if (pci_debug_msg_id->level >= 2)   
\
+   debug_sprintf_event(pci_debug_msg_id, 2, fmt , ## 
args);\
+   } while (0)
+
+#else /* !CONFIG_PCI_DEBUG */
+#define zpci_dbg(fmt, args...) do { } while (0)
+#endif
+
+#define zpci_err(text...)  
\
+   do {
\
+   char debug_buffer[16];  
\
+   snprintf(debug_buffer, 16, text);   
\
+   debug_text_event(pci_debug_err_id, 0, debug_buffer);
\
+   } while (0)
+
+static inline void zpci_err_hex(void 

[GIT PULL] s390 patches for the 3.8 merge window #2

2012-12-18 Thread Martin Schwidefsky
Hi Linus,

please pull from the 'for-linus' branch of

git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git for-linus

to receive the following updates:
The main patch is the function measurement blocks extension for PCI to do
performance statistics and help with debugging. The other patch is a small
cleanup in ccwdev.h.

Cornelia Huck (1):
  s390/ccwdev: Include asm/schid.h.

Jan Glauber (1):
  s390/pci: performance statistics and debug infrastructure

 arch/s390/include/asm/ccwdev.h|4 +-
 arch/s390/include/asm/pci.h   |   39 
 arch/s390/include/asm/pci_debug.h |   36 +++
 arch/s390/pci/Makefile|2 +-
 arch/s390/pci/pci.c   |   73 +-
 arch/s390/pci/pci_clp.c   |1 +
 arch/s390/pci/pci_debug.c |  193 +
 arch/s390/pci/pci_dma.c   |8 +-
 arch/s390/pci/pci_event.c |2 +
 9 files changed, 350 insertions(+), 8 deletions(-)
 create mode 100644 arch/s390/include/asm/pci_debug.h
 create mode 100644 arch/s390/pci/pci_debug.c

diff --git a/arch/s390/include/asm/ccwdev.h b/arch/s390/include/asm/ccwdev.h
index 6d1f357..e606161 100644
--- a/arch/s390/include/asm/ccwdev.h
+++ b/arch/s390/include/asm/ccwdev.h
@@ -12,15 +12,13 @@
 #include linux/mod_devicetable.h
 #include asm/fcx.h
 #include asm/irq.h
+#include asm/schid.h
 
 /* structs from asm/cio.h */
 struct irb;
 struct ccw1;
 struct ccw_dev_id;
 
-/* from asm/schid.h */
-struct subchannel_id;
-
 /* simplified initializers for struct ccw_device:
  * CCW_DEVICE and CCW_DEVICE_DEVTYPE initialize one
  * entry in your MODULE_DEVICE_TABLE and set the match_flag correctly */
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index a6175ad..b1fa93c 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -9,6 +9,7 @@
 #include asm-generic/pci.h
 #include asm-generic/pci-dma-compat.h
 #include asm/pci_clp.h
+#include asm/pci_debug.h
 
 #define PCIBIOS_MIN_IO 0x1000
 #define PCIBIOS_MIN_MEM0x1000
@@ -33,6 +34,25 @@ int pci_proc_domain(struct pci_bus *);
 #define ZPCI_FC_BLOCKED0x20
 #define ZPCI_FC_DMA_ENABLED0x10
 
+struct zpci_fmb {
+   u32 format  :  8;
+   u32 dma_valid   :  1;
+   u32 : 23;
+   u32 samples;
+   u64 last_update;
+   /* hardware counters */
+   u64 ld_ops;
+   u64 st_ops;
+   u64 stb_ops;
+   u64 rpcit_ops;
+   u64 dma_rbytes;
+   u64 dma_wbytes;
+   /* software counters */
+   atomic64_t allocated_pages;
+   atomic64_t mapped_pages;
+   atomic64_t unmapped_pages;
+} __packed __aligned(16);
+
 struct msi_map {
unsigned long irq;
struct msi_desc *msi;
@@ -92,7 +112,15 @@ struct zpci_dev {
u64 end_dma;/* End of available DMA addresses */
u64 dma_mask;   /* DMA address space mask */
 
+   /* Function measurement block */
+   struct zpci_fmb *fmb;
+   u16 fmb_update; /* update interval */
+
enum pci_bus_speed max_bus_speed;
+
+   struct dentry   *debugfs_dev;
+   struct dentry   *debugfs_perf;
+   struct dentry   *debugfs_debug;
 };
 
 struct pci_hp_callback_ops {
@@ -155,4 +183,15 @@ extern struct list_head zpci_list;
 extern struct pci_hp_callback_ops hotplug_ops;
 extern unsigned int pci_probe;
 
+/* FMB */
+int zpci_fmb_enable_device(struct zpci_dev *);
+int zpci_fmb_disable_device(struct zpci_dev *);
+
+/* Debug */
+int zpci_debug_init(void);
+void zpci_debug_exit(void);
+void zpci_debug_init_device(struct zpci_dev *);
+void zpci_debug_exit_device(struct zpci_dev *);
+void zpci_debug_info(struct zpci_dev *, struct seq_file *);
+
 #endif
diff --git a/arch/s390/include/asm/pci_debug.h 
b/arch/s390/include/asm/pci_debug.h
new file mode 100644
index 000..6bbec42
--- /dev/null
+++ b/arch/s390/include/asm/pci_debug.h
@@ -0,0 +1,36 @@
+#ifndef _S390_ASM_PCI_DEBUG_H
+#define _S390_ASM_PCI_DEBUG_H
+
+#include asm/debug.h
+
+extern debug_info_t *pci_debug_msg_id;
+extern debug_info_t *pci_debug_err_id;
+
+#ifdef CONFIG_PCI_DEBUG
+#define zpci_dbg(fmt, args...) 
\
+   do {
\
+   if (pci_debug_msg_id-level = 2)   
\
+   debug_sprintf_event(pci_debug_msg_id, 2, fmt , ## 
args);\
+   } while (0)
+
+#else /* !CONFIG_PCI_DEBUG */
+#define zpci_dbg(fmt, args...) do { } while (0)
+#endif
+
+#define zpci_err(text...)  
\
+   do {
\
+   char debug_buffer[16];  
\
+   snprintf(debug_buffer, 16, text);   
\
+